exhibitionjs 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Exhibition:()=>_,ExhibitionMonacoEditor:()=>H,ExhibitionPreview:()=>N,exhibitionDefaultAttribute:()=>U});class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}class h extends Error{}function d(t){return Object.getPrototypeOf(t)===Object.prototype}const c=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],u=Symbol("WrapletSet");function p(t){return c(t,u)}class f extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const w=Symbol("WrapletSetReadonly");class g extends f{[w]=!0;[u]=!0}const y=Symbol("Core"),m=Symbol("NodeTreeParent");function b(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function v(t){const e={};for(const i in t){const s=t[i];e[i]=b(s);const r=s.map;r&&d(r)&&(e[i].map=v(r))}return e}const C=Symbol("DynamicMap");function E(t){return c(t,C)}class O{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=v(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const s=e[i].map;if(d(s))e=s;else{if(!E(s))throw new Error("Invalid map type.");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(E(t))return!0;if(!d(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new O(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol("ArgCreator");function D(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class I{node;[y]=!0;[m]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=D;constructor(t,e,i={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(d(e))this.mapWrapper=new O(e);else{if(!(e instanceof O))throw new s("The map provided to the Core is not a valid map.");this.mapWrapper=e}this.processInitOptions(i),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?p(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(p(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!p(i))throw new l("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new l("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,n=this.findChildren(r,i);if(this.validateElements(s,n,t),0===n.length)return null;if(n.length>1)throw new a(`${this.constructor.name}: More than one element was found for the "${s}" child. Selector used: "${r}".`);const o=n[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>c(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof h&&!e.required)return console.warn(`${i.message} Skipping instantiation of the "${t}" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new g;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new g;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new o("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new n("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(p(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new l("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new r("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new l("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,e){const i=e.selector,r=e.required;if(!i&&r)throw new s(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,e){if(e.required)throw new s(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(t,e,s){if(0===e.length&&s.required)throw new i(`${this.constructor.name}: Couldn't find a node for the wraplet "${t}". Selector used: "${s.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(p(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}const A=Symbol("Wraplet"),S=Symbol("Groupable");function z(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const i=t.status||this.status;await async function(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}(i,t.core)&&(e&&await e(),await async function(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}(i,t.destroyCallback))}}function W(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const i=t.status||this.status;await async function(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await async function(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}(i))}}class L{core;[A]=!0;[S]=!0;[m]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!c(t,y))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new h(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=(t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign((t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||W({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||z({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})})(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})})({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new I(t,e)}static createWraplets(t,e,i,s=[]){if(this===L)throw new Error("You cannot instantiate an abstract class.");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}function x(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}const P=Symbol("KeyValueStorage");class j extends Error{}class T{storage;defaults;validators;[P]=!0;constructor(t,e,i){this.storage=t,this.defaults=e,this.validators=i}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const i of t)void 0===e[i]&&(e[i]=this.defaults[i]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new j(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new j(`Attempted to set an invalid value for the key ${String(t)}.`)}}class G{isPartial;defaults;validators;[P]=!0;data=null;options;constructor(t,e,i,s={}){this.isPartial=t,this.defaults=e,this.validators=i,this.validateValidators(i),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new j(`Attempted to set an invalid value for the key ${String(t)}.`);const i=await this.getValue(),s=JSON.parse(i);s[t]=e,await this.setAll(s)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const i of t)delete e[i];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if("{"!==t.charAt(0))throw new j("Data has to be defined as an object.");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new j(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new j(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if("function"!=typeof t[e])throw new j(`Validator for ${e} is not a function.`)}}class k extends G{element;attribute;defaults;validators;constructor(t,e,i,s,r,n={}){super(t,s,r,n),this.element=e,this.attribute=i,this.defaults=s,this.validators=r}async getValue(){return this.element.getAttribute(this.attribute)||"{}"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class N extends L{alterers=[];currentBlobUrl=null;options;constructor(t,e={},i){super(t);const s={updateHeight:!0,updateHeightCallback:async t=>{setTimeout(()=>{t.updateHeight()},100)}},r=i||new k(!0,t.node,"data-js-options",{},{});this.options=new T(r,{...s,...e},{updateHeight:t=>"boolean"==typeof t,updateHeightCallback:t=>"function"==typeof t})}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLIFrameElement])}addDocumentAlterer(t,e=0){this.hasDocumentAlterer(t)||this.alterers.push({callback:t,priority:e})}hasDocumentAlterer(t){return this.alterers.some(e=>e.callback===t)}removeDocumentAlterer(t){this.alterers=this.alterers.filter(e=>e.callback!==t)}async update(){const t=document.implementation.createHTMLDocument();this.alterers.sort((t,e)=>e.priority-t.priority);for(const e of this.alterers)await e.callback(t);this.currentBlobUrl&&URL.revokeObjectURL(this.currentBlobUrl);const e="<!DOCTYPE html>\n"+t.documentElement.outerHTML,i=new Blob([e],{type:"text/html;charset=utf-8"});this.currentBlobUrl=URL.createObjectURL(i),this.node.src=this.currentBlobUrl,this.node.onload=async()=>{await this.options.get("updateHeight")||await(await this.options.get("updateHeightCallback"))(this),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),s=parseFloat(i.marginTop)+parseFloat(i.marginBottom),r=Math.ceil(e.offsetHeight+s);this.node.height=r+"px"}getIFrameDocument(){const t=this.node.contentDocument;if(!t)throw new Error("IFrame document is not available.");return t}getIFrameWindow(){const t=this.node.contentWindow;if(!t)throw new Error("IFrame window is not available.");return t}}const V={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function $(t){for(const[e,i]of Object.entries(V))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function q(t){return V[t].tag}function F(t){return Boolean(q(t))}class H extends L{monaco=null;editor=null;options;status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};priority=0;monacoEditorOptions=null;constructor(t,e,i){super(t),this.alterDocument=this.alterDocument.bind(this);const s={location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={location:t=>"string"==typeof t&&["head","body"].includes(t),priority:t=>Number.isInteger(t),tagAttributes:t=>"object"==typeof t,trimDefaultValue:t=>"boolean"==typeof t,monacoEditorCreator:t=>"function"==typeof t,monaco:t=>"object"==typeof t,monacoEditorOptions:()=>!0};e.monacoEditorOptions={...s.monacoEditorOptions,...e.monacoEditorOptions};const n=i||new k(!0,t.node,"data-js-options",{},{},{elementOptionsMerger:(t,i)=>(i.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions,...i.monacoEditorOptions},{...t,...e,...i})});this.options=new T(n,{...s,...e},r),this.wraplet=x({status:this.status,initialize:this.initialize.bind(this),destroy:this.destroy.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return z({core:this.core,destroyCallback:this.destroy,status:this.status},async()=>{if(this.status.isInitialized)throw new Error("ExhibitionMonacoEditor is already initialized");if(this.priority=await this.options.get("priority"),this.monacoEditorOptions=await this.options.get("monacoEditorOptions"),await this.options.get("trimDefaultValue")){const t=await this.options.get("monacoEditorOptions");t.value&&(t.value=H.trimDefaultValue(t.value),await this.options.set("monacoEditorOptions",t))}await this.validateOptions(),this.monaco=await this.getMonacoInstance();const t=await this.options.get("monacoEditorCreator")||(async(t,e,i)=>H.createMonacoEditor(t,e,i));this.editor=await t(await this.options.get("monacoEditorOptions"),this.node,this.monaco)})()}getPriority(){return this.priority}async getMonacoInstance(){const t=await this.options.get("monaco");if(!t)throw new Error("Monaco instance is not available");return t}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.monaco;if(!e)throw new Error("Monaco instance is not available. Is wraplet initialized?");const i=this.getLanguage(),s="typescript"===i?await this.getTSValueAsJS(e):this.getValue(),r=await this.options.get("location"),n=$(i);if(F(n)){const e=q(n),i=await this.options.get("tagAttributes")??{},a=t.createElement(e);for(const[t,e]of Object.entries(i))a.setAttribute(t,e);return a.innerHTML=s,void t[r].appendChild(a)}t[r].innerHTML+=s}getDocumentAlterer(){return this.alterDocument}async validateOptions(){if(!(await this.options.get("monacoEditorOptions")).language)throw new Error("Missing language in monacoOptions");if(!F($(this.getLanguage()))&&await this.options.get("tagAttributes"))throw new Error("'tagAttributes' option is only allowed for single tag types")}getEditor(){if(!this.editor)throw new Error("Editor is not initialized");return this.editor}async getTSValueAsJS(t){const e=this.getEditor().getModel();if(!e)throw new Error("Model is not available");t.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const i=e.uri;if("file"!==i.scheme)throw new Error(`Model must use file:// URI, got: ${i.toString()}`);const s=async(e=10)=>{try{return await t.languages.typescript.getTypeScriptWorker()}catch(t){if("TypeScript not registered!"!==t)throw t;return e<=0?null:(await new Promise(t=>setTimeout(t,200)),s(e-1))}},r=await s();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(i);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(i.toString());break}catch(t){if(/Could not find source file/.test(String(t))){await new Promise(t=>setTimeout(t,250));continue}throw t}const{outputFiles:a}=await n.getEmitOutput(i.toString());if(!a.length)throw new Error("No JS output produced");return a[0].text}getLanguage(){const t=this.monacoEditorOptions;if(!t)throw new Error("Monaco options are not available. Is wraplet initialized?");if(!t.language)throw new Error("Missing language in monacoOptions");return t.language}static trimDefaultValue(t){const e=t.split("\n"),i=e.find(t=>t.trim().length>0);if(!i)return t.trim();const s=i.search(/\S|$/);return e.map(t=>t.length>=s&&""===t.substring(0,s).trim()?t.substring(s):t).join("\n").trim()}async destroy(){return W({core:this.core,wraplet:this,destroyListeners:this.destroyListeners,status:this.status},async()=>{this.editor?.dispose()})()}static createMonacoEditor(t={},e,i){const s=t.language;if(!s)throw new Error("Missing language in editorOptions");const r=this.createMonacoModel(i,s,t.value||"");return i.editor.create(e,{...t,model:r})}static createMonacoModel(t,e,i){const s=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${s}.ts`))}static create(t,e){const i=new I(t,{});return new H(i,e)}}const U="data-js-exhibition",B={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:H,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:N,args:[]}};class _ extends L{status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};options;constructor(t,e={},i){super(t);const s=i??new k(!0,this.node,"data-js-options",{},{updaterSelector:t=>"string"==typeof t});this.options=new T(s,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t}),this.wraplet=x({status:this.status,initialize:this.initialize.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return z({core:this.core,status:this.status,destroyCallback:this.wraplet.destroy},async()=>{if(this.status.isInitialized)throw new Error("Exhibition is already initialized");for(const t of this.children.editors)t.wraplet.status.isInitialized||t.wraplet.status.isGettingInitialized||await t.wraplet.initialize(),this.children.preview.hasDocumentAlterer(t.getDocumentAlterer())||this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority());const t=this.node.querySelectorAll(await this.options.get("updaterSelector"));for(const e of t)this.core.addEventListener(e,"click",()=>{this.updatePreview()})})()}addEditor(t){this.children.editors.add(t),this.children.preview.addDocumentAlterer(t.getDocumentAlterer())}removeEditor(t){this.children.editors.delete(t),this.children.preview.removeDocumentAlterer(t.getDocumentAlterer())}hasEditor(t){return this.children.editors.has(t)}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}static async createMultiple(t,e,i={},s={},r=U){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const n=this.createWraplets(t,e,r,[i]);for(const t of n)await this.applyCreateOptions(t,s);return n}static async create(t,e,i={},s={}){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const r=new I(t,e),n=new _(r,i);return await this.applyCreateOptions(n,s),n}static fillCreateOptionsWithDefaults(t){return{init:!0,updatePreview:!1,...t}}static validateInitOptions(t,e){if(t.init&&void 0===e.editors.selector)throw new Error("Cannot initialize exhibition with undefined editors.selector");if(!t.init&&t.updatePreview)throw new Error("Cannot update preview without initializing exhibitions first")}static async applyCreateOptions(t,e={}){if(!e.init&&e.updatePreview)throw new Error("'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.");e.init&&await t.initialize(),e.updatePreview&&await t.updatePreview()}static getMap(t){const e=B,i={selectEditors:!0,Class:void 0,editorsOptions:{},previewOptions:{},...t};if(i.Class&&(e.editors.Class=i.Class),e.editors.Class instanceof H&&i.editorsOptions&&!i.editorsOptions.monaco)throw new Error("When using ExhibitionMonacoEditor as editors class, you must provide the 'monaco' option in the editors options.");return i.selectEditors||(e.editors.selector=void 0),i.previewOptions&&e.preview.args.push(i.previewOptions),i.editorsOptions&&e.editors.args.push(i.editorsOptions),e}}var R=exports;for(var J in e)R[J]=e[J];e.__esModule&&Object.defineProperty(R,"__esModule",{value:!0});
1
+ var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Exhibition:()=>_,ExhibitionMonacoEditor:()=>H,ExhibitionPreview:()=>N,exhibitionDefaultAttribute:()=>U});class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}class d extends Error{}function h(t){return Object.getPrototypeOf(t)===Object.prototype}const c=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],u=Symbol("WrapletSet");function p(t){return c(t,u)}class f extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const w=Symbol("WrapletSetReadonly");class g extends f{[w]=!0;[u]=!0}const y=Symbol("Core"),m=Symbol("NodeTreeParent");function b(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function v(t){const e={};for(const i in t){const s=t[i];e[i]=b(s);const r=s.map;r&&h(r)&&(e[i].map=v(r))}return e}const C=Symbol("DynamicMap");function E(t){return c(t,C)}class O{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=v(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const s=e[i].map;if(h(s))e=s;else{if(!E(s))throw new Error("Invalid map type.");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(E(t))return!0;if(!h(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new O(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol("ArgCreator");function D(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class I{node;[y]=!0;[m]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=D;constructor(t,e,i={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(h(e))this.mapWrapper=new O(e);else{if(!(e instanceof O))throw new s("The map provided to the Core is not a valid map.");this.mapWrapper=e}this.processInitOptions(i),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?p(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(p(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!p(i))throw new l("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new l("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,n=this.findChildren(r,i);if(this.validateElements(s,n,t),0===n.length)return null;if(n.length>1)throw new a(`${this.constructor.name}: More than one element was found for the "${s}" child. Selector used: "${r}".`);const o=n[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>c(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof d&&!e.required)return console.warn(`${i.message} Skipping instantiation of the "${t}" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new g;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new g;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new o("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new n("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(p(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new l("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new r("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new l("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,e){const i=e.selector,r=e.required;if(!i&&r)throw new s(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,e){if(e.required)throw new s(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(t,e,s){if(0===e.length&&s.required)throw new i(`${this.constructor.name}: Couldn't find a node for the wraplet "${t}". Selector used: "${s.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(p(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}const A=Symbol("Wraplet"),S=Symbol("Groupable");function z(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const i=t.status||this.status;await async function(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}(i,t.core)&&(e&&await e(),await async function(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}(i,t.destroyCallback))}}function W(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const i=t.status||this.status;await async function(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await async function(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}(i))}}class L{core;[A]=!0;[S]=!0;[m]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!c(t,y))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new d(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=(t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign((t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||W({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||z({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})})(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})})({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new I(t,e)}static createWraplets(t,e,i,s=[]){if(this===L)throw new Error("You cannot instantiate an abstract class.");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}function x(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}const P=Symbol("KeyValueStorage");class T extends Error{}class j{storage;defaults;validators;[P]=!0;constructor(t,e,i){this.storage=t,this.defaults=e,this.validators=i}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const i of t)void 0===e[i]&&(e[i]=this.defaults[i]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new T(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new T(`Attempted to set an invalid value for the key ${String(t)}.`)}}class G{isPartial;defaults;validators;[P]=!0;data=null;options;constructor(t,e,i,s={}){this.isPartial=t,this.defaults=e,this.validators=i,this.validateValidators(i),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new T(`Attempted to set an invalid value for the key ${String(t)}.`);const i=await this.getValue(),s=JSON.parse(i);s[t]=e,await this.setAll(s)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const i of t)delete e[i];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if("{"!==t.charAt(0))throw new T("Data has to be defined as an object.");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new T(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new T(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if("function"!=typeof t[e])throw new T(`Validator for ${e} is not a function.`)}}class k extends G{element;attribute;defaults;validators;constructor(t,e,i,s,r,n={}){super(t,s,r,n),this.element=e,this.attribute=i,this.defaults=s,this.validators=r}async getValue(){return this.element.getAttribute(this.attribute)||"{}"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class N extends L{alterers=[];currentBlobUrl=null;options;constructor(t,e={},i){super(t);const s={updateHeight:!0,updateHeightCallback:async t=>{setTimeout(()=>{t.updateHeight()},100)}},r=i||new k(!0,t.node,"data-js-options",{},{});this.options=new j(r,{...s,...e},{updateHeight:t=>"boolean"==typeof t,updateHeightCallback:t=>"function"==typeof t})}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLIFrameElement])}addDocumentAlterer(t,e=0){this.hasDocumentAlterer(t)||this.alterers.push({callback:t,priority:e})}hasDocumentAlterer(t){return this.alterers.some(e=>e.callback===t)}removeDocumentAlterer(t){this.alterers=this.alterers.filter(e=>e.callback!==t)}async update(){const t=document.implementation.createHTMLDocument();this.alterers.sort((t,e)=>e.priority-t.priority);for(const e of this.alterers)await e.callback(t);this.currentBlobUrl&&URL.revokeObjectURL(this.currentBlobUrl);const e="<!DOCTYPE html>\n"+t.documentElement.outerHTML,i=new Blob([e],{type:"text/html;charset=utf-8"});this.currentBlobUrl=URL.createObjectURL(i),this.node.src=this.currentBlobUrl,this.node.onload=async()=>{await this.options.get("updateHeight")||await(await this.options.get("updateHeightCallback"))(this),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),s=parseFloat(i.marginTop)+parseFloat(i.marginBottom),r=Math.ceil(e.offsetHeight+s);this.node.height=r+"px"}getIFrameDocument(){const t=this.node.contentDocument;if(!t)throw new Error("IFrame document is not available.");return t}getIFrameWindow(){const t=this.node.contentWindow;if(!t)throw new Error("IFrame window is not available.");return t}}const V={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function $(t){for(const[e,i]of Object.entries(V))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function q(t){return V[t].tag}function F(t){return Boolean(q(t))}class H extends L{monaco=null;editor=null;options;status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};priority=0;monacoEditorOptions=null;constructor(t,e,i){super(t),this.alterDocument=this.alterDocument.bind(this);const s={location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={location:t=>"string"==typeof t&&["head","body"].includes(t),priority:t=>Number.isInteger(t),tagAttributes:t=>"object"==typeof t,trimDefaultValue:t=>"boolean"==typeof t,monacoEditorCreator:t=>"function"==typeof t,monaco:t=>"object"==typeof t,monacoEditorOptions:()=>!0};e.monacoEditorOptions={...s.monacoEditorOptions,...e.monacoEditorOptions};const n=i||new k(!0,t.node,"data-js-options",{},{},{elementOptionsMerger:(t,i)=>(i.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions,...i.monacoEditorOptions},{...t,...e,...i})});this.options=new j(n,{...s,...e},r),this.wraplet=x({status:this.status,initialize:this.initialize.bind(this),destroy:this.destroy.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return z({core:this.core,destroyCallback:this.destroy,status:this.status},async()=>{if(this.status.isInitialized)throw new Error("ExhibitionMonacoEditor is already initialized");if(this.priority=await this.options.get("priority"),this.monacoEditorOptions=await this.options.get("monacoEditorOptions"),await this.options.get("trimDefaultValue")){const t=await this.options.get("monacoEditorOptions");t.value&&(t.value=H.trimDefaultValue(t.value),await this.options.set("monacoEditorOptions",t))}await this.validateOptions(),this.monaco=await this.getMonacoInstance();const t=await this.options.get("monacoEditorCreator")||(async(t,e,i)=>H.createMonacoEditor(t,e,i));this.editor=await t(await this.options.get("monacoEditorOptions"),this.node,this.monaco)})()}getPriority(){return this.priority}async getMonacoInstance(){const t=await this.options.get("monaco");if(!t)throw new Error("Monaco instance is not available");return t}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.monaco;if(!e)throw new Error("Monaco instance is not available. Is wraplet initialized?");const i=this.getLanguage(),s="typescript"===i?await this.getTSValueAsJS(e):this.getValue(),r=await this.options.get("location"),n=$(i);if(F(n)){const e=q(n),i=await this.options.get("tagAttributes")??{},a=t.createElement(e);for(const[t,e]of Object.entries(i))a.setAttribute(t,e);return a.innerHTML=s,void t[r].appendChild(a)}t[r].innerHTML+=s}getDocumentAlterer(){return this.alterDocument}async validateOptions(){if(!(await this.options.get("monacoEditorOptions")).language)throw new Error("Missing language in monacoOptions");if(!F($(this.getLanguage()))&&await this.options.get("tagAttributes"))throw new Error("'tagAttributes' option is only allowed for single tag types")}getEditor(){if(!this.editor)throw new Error("Editor is not initialized");return this.editor}async getTSValueAsJS(t){const e=this.getEditor().getModel();if(!e)throw new Error("Model is not available");t.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const i=e.uri;if("file"!==i.scheme)throw new Error(`Model must use file:// URI, got: ${i.toString()}`);const s=async(e=10)=>{try{return await t.languages.typescript.getTypeScriptWorker()}catch(t){if("TypeScript not registered!"!==t)throw t;return e<=0?null:(await new Promise(t=>setTimeout(t,200)),s(e-1))}},r=await s();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(i);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(i.toString());break}catch(t){if(/Could not find source file/.test(String(t))){await new Promise(t=>setTimeout(t,250));continue}throw t}const{outputFiles:a}=await n.getEmitOutput(i.toString());if(!a.length)throw new Error("No JS output produced");return a[0].text}getLanguage(){const t=this.monacoEditorOptions;if(!t)throw new Error("Monaco options are not available. Is wraplet initialized?");if(!t.language)throw new Error("Missing language in monacoOptions");return t.language}static trimDefaultValue(t){const e=t.split("\n"),i=e.find(t=>t.trim().length>0);if(!i)return t.trim();const s=i.search(/\S|$/);return e.map(t=>t.length>=s&&""===t.substring(0,s).trim()?t.substring(s):t).join("\n").trim()}async destroy(){return W({core:this.core,wraplet:this,destroyListeners:this.destroyListeners,status:this.status},async()=>{this.editor?.dispose()})()}static createMonacoEditor(t={},e,i){const s=t.language;if(!s)throw new Error("Missing language in editorOptions");const r=this.createMonacoModel(i,s,t.value||"");return i.editor.create(e,{...t,model:r})}static createMonacoModel(t,e,i){const s=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${s}.ts`))}static create(t,e){const i=new I(t,{});return new H(i,e)}}const U="data-js-exhibition",B={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:H,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:N,args:[]}};class _ extends L{status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};options;constructor(t,e={},i){super(t);const s=i??new k(!0,this.node,"data-js-options",{},{updaterSelector:t=>"string"==typeof t});this.options=new j(s,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t}),this.wraplet=x({status:this.status,initialize:this.initialize.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return z({core:this.core,status:this.status,destroyCallback:this.wraplet.destroy},async()=>{if(this.status.isInitialized)throw new Error("Exhibition is already initialized");for(const t of this.children.editors)t.wraplet.status.isInitialized||t.wraplet.status.isGettingInitialized||await t.wraplet.initialize(),this.children.preview.hasDocumentAlterer(t.getDocumentAlterer())||this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority());const t=this.node.querySelectorAll(await this.options.get("updaterSelector"));for(const e of t)this.core.addEventListener(e,"click",()=>{this.updatePreview()})})()}addEditor(t){this.children.editors.add(t),this.children.preview.addDocumentAlterer(t.getDocumentAlterer())}removeEditor(t){this.children.editors.delete(t),this.children.preview.removeDocumentAlterer(t.getDocumentAlterer())}hasEditor(t){return this.children.editors.has(t)}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}static async createMultiple(t,e,i={},s={},r=U){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const n=this.createWraplets(t,e,r,[i]);for(const t of n)await this.applyCreateOptions(t,s);return n}static async create(t,e,i={},s={}){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const r=new I(t,e),n=new _(r,i);return await this.applyCreateOptions(n,s),n}static fillCreateOptionsWithDefaults(t){return{init:!0,updatePreview:!1,...t}}static validateInitOptions(t,e){if(t.init&&void 0===e.editors.selector)throw new Error("Cannot initialize exhibition with undefined editors.selector");if(!t.init&&t.updatePreview)throw new Error("Cannot update preview without initializing exhibitions first")}static async applyCreateOptions(t,e={}){if(!e.init&&e.updatePreview)throw new Error("'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.");e.init&&await t.initialize(),e.updatePreview&&await t.updatePreview()}static getMap(t){const e=B,i={selectEditors:!0,Class:void 0,editorsOptions:{},previewOptions:{},...t};if(i.Class&&(e.editors.Class=i.Class),i.selectEditors&&e.editors.Class instanceof H&&(!i.editorsOptions||!i.editorsOptions.monaco))throw new Error("When selecting ExhibitionMonacoEditor instances, you must provide the 'monaco' option in the editors options. To avoid this error, disable 'selectEditors' or provide the 'monaco' option.");return i.selectEditors||(e.editors.selector=void 0),i.previewOptions&&e.preview.args.push(i.previewOptions),i.editorsOptions&&e.editors.args.push(i.editorsOptions),e}}var R=exports;for(var J in e)R[J]=e[J];e.__esModule&&Object.defineProperty(R,"__esModule",{value:!0});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAA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ACT,E","sources":["webpack://exhibitionjs/webpack/bootstrap","webpack://exhibitionjs/webpack/runtime/define property getters","webpack://exhibitionjs/webpack/runtime/hasOwnProperty shorthand","webpack://exhibitionjs/webpack/runtime/make namespace object","webpack://exhibitionjs/./node_modules/wraplet/dist/index.js","webpack://exhibitionjs/./node_modules/wraplet/dist/storage.js","webpack://exhibitionjs/./src/ExhibitionPreview.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/selectors.ts","webpack://exhibitionjs/./src/Exhibition.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}function h(t){return Object.getPrototypeOf(t)===Object.prototype}const d=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],c=Symbol(\"WrapletSet\");function u(t){return d(t,c)}class p extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const f=Symbol(\"WrapletSetReadonly\");class w extends p{[f]=!0;[c]=!0}function y(t){const e=t.wraplets;return u(e)&&0!==e.size?e:new w}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function g(t,e){await e(t);const i=t.childNodes;for(const t of i)await g(t,e)}async function m(t){await g(t,async t=>{const e=y(t);for(const i of e)i.wraplet.status.isGettingDestroyed||i.wraplet.status.isDestroyed||await i.wraplet.destroy(),C(i,t)})}const b=Symbol(\"Core\"),v=Symbol(\"NodeTreeParent\");function I(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function W(t){const e={};for(const i in t){const s=t[i];e[i]=I(s);const r=s.map;r&&h(r)&&(e[i].map=W(r))}return e}const E=Symbol(\"DynamicMap\");function D(t){return d(t,E)}class z{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=W(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);const s=e[i].map;if(h(s))e=s;else{if(!D(s))throw new Error(\"Invalid map type.\");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error(\"Map doesn't exist.\");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(D(t))return!0;if(!h(t))throw new Error(\"Invalid map type.\");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error(\"At the root already.\");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new z(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol(\"ArgCreator\");function L(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class G{node;[b]=!0;[v]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=L;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error(\"The node provided to the Core is not a valid node.\");if(h(i))this.mapWrapper=new z(i);else{if(!(i instanceof z))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?u(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!u(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new o(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,a=this.findChildren(r,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${s}\" child. Selector used: \"${r}\".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>d(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof l&&!e.required)return console.warn(`${i.message} Skipping instantiation of the \"${t}\" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new a(\"Children are already destroyed.\");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}removeChild(t,e){if(u(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i(\"Required child has been destroyed.\");if(null===this.instantiatedChildren[e])throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency \"${t}\" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${s.selector}\".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class x{creator;[M]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new x(t)}}const S=Symbol(\"Wraplet\");function O(t){return d(t,S)}const A=Symbol(\"Groupable\");async function N(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function j(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function P(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot initialize without status available.\");const i=t.status||this.status;await N(i,t.core)&&(e&&await e(),await $(i,t.destroyCallback))}}function T(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot destroy without status available.\");const i=t.status||this.status;await j(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(i))}}const k=t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||T({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||P({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]});return Object.assign(k(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class R{core;[S]=!0;[A]=!0;[v]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!d(t,b))throw new Error(\"AbstractWraplet requires a Core instance.\");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new l(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new G(t,e)}static createWraplets(t,e,i,s=[]){if(this===R)throw new Error(\"You cannot instantiate an abstract class.\");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}class Y{levels;[E]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error(\"There have to be more than 0 repeated levels.\")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new Y(t)}}class _ extends p{[f]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");return Object.assign(e,t)}export{R as AbstractWraplet,a as ChildrenAreAlreadyDestroyedError,s as ChildrenAreNotAvailableError,n as ChildrenTooManyFoundError,x as DefaultArgCreator,G as DefaultCore,w as DefaultWrapletSet,_ as DefaultWrapletSetReadonly,o as InternalLogicError,e as MapError,Y as MapRepeat,t as MissingRequiredChildError,i as RequiredChildDestroyedError,r as StorageValidationError,l as UnsupportedNodeTypeError,S as WrapletSymbol,T as createDefaultDestroyCallback,P as createDefaultInitializeCallback,F as createRichWrapletApi,k as createWrapletApi,B as customizeDefaultWrapletApi,L as defaultWrapletCreator,m as destroyWrapletsRecursively,q as destructionCompleted,j as destructionStarted,y as getWrapletsFromNode,$ as initializationCompleted,N as initializationStarted,O as isWraplet};\n//# sourceMappingURL=index.js.map","const t=Symbol(\"KeyValueStorage\");function e(e){return(e=>\"object\"==typeof e&&null!==e&&!0===e[t])(e)}class a extends Error{}class s{storage;defaults;validators;[t]=!0;constructor(t,e,a){this.storage=t,this.defaults=e,this.validators=a}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const a of t)void 0===e[a]&&(e[a]=this.defaults[a]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new a(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`)}}class i{isPartial;defaults;validators;[t]=!0;data=null;options;constructor(t,e,a,s={}){this.isPartial=t,this.defaults=e,this.validators=a,this.validateValidators(a),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,a)=>(t[a]=e[a],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`);const s=await this.getValue(),i=JSON.parse(s);i[t]=e,await this.setAll(i)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const a of t)delete e[a];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if(\"{\"!==t.charAt(0))throw new a(\"Data has to be defined as an object.\");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new a(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new a(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if(\"function\"!=typeof t[e])throw new a(`Validator for ${e} is not a function.`)}}class l extends i{element;attribute;defaults;validators;constructor(t,e,a,s,i,l={}){super(t,s,i,l),this.element=e,this.attribute=a,this.defaults=s,this.validators=i}async getValue(){return this.element.getAttribute(this.attribute)||\"{}\"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class r extends i{element;defaults;validators;constructor(t,e,a,s,i={}){super(t,a,s,i),this.element=e,this.defaults=a,this.validators=s}async getValue(){return this.element.textContent||\"{}\"}async setValue(t){this.element.textContent=JSON.stringify(t)}async deleteAllValues(){this.element.textContent=\"{}\"}}export{i as AbstractNongranularKeyValueStorage,l as ElementAttributeStorage,r as ElementStorage,t as KeyValueStorageSymbol,s as StorageWrapper,e as isKeyValueStorage};\n//# sourceMappingURL=storage.js.map","import { AbstractWraplet, Constructable, Core } from \"wraplet\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\ntype AltererData = {\n callback: DocumentAlterer;\n priority: number;\n};\n\nexport type ExhibitionPreviewOptions = {\n updateHeight?: boolean;\n updateHeightCallback?: (preview: ExhibitionPreview) => Promise<void>;\n};\n\nexport class ExhibitionPreview\n extends AbstractWraplet<HTMLIFrameElement>\n implements PreviewWraplet\n{\n private alterers: AltererData[] = [];\n private currentBlobUrl: string | null = null;\n\n private options: KeyValueStorage<Required<ExhibitionPreviewOptions>>;\n\n constructor(\n core: Core<HTMLIFrameElement>,\n options: ExhibitionPreviewOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionPreviewOptions>>,\n ) {\n super(core);\n\n const validators: StorageValidators<ExhibitionPreviewOptions> = {\n updateHeight: (data: unknown) => typeof data === \"boolean\",\n updateHeightCallback: (data: unknown) => typeof data === \"function\",\n };\n\n const defaultOptions: Required<ExhibitionPreviewOptions> = {\n updateHeight: true,\n updateHeightCallback: async (preview) => {\n setTimeout(() => {\n preview.updateHeight();\n }, 100);\n },\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionPreviewOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionPreviewOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n );\n\n this.options = new StorageWrapper<Required<ExhibitionPreviewOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLIFrameElement>[] {\n return super.supportedNodeTypesGuard([HTMLIFrameElement]);\n }\n\n /**\n * Adds a DocumentAlterer to the preview.\n * @param alterer\n * @param priority\n * Priority of the alterer. Higher priority alterers are executed first.\n */\n public addDocumentAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n if (this.hasDocumentAlterer(alterer)) {\n return;\n }\n\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n\n /**\n * Checks if alterer is already registered.\n * @param alterer\n */\n public hasDocumentAlterer(alterer: DocumentAlterer): boolean {\n return this.alterers.some(\n (altererData) => altererData.callback === alterer,\n );\n }\n\n public removeDocumentAlterer(alterer: DocumentAlterer): void {\n this.alterers = this.alterers.filter(\n (altererData) => altererData.callback !== alterer,\n );\n }\n\n public async update(): Promise<void> {\n const doc = document.implementation.createHTMLDocument();\n this.alterers.sort((a, b) => b.priority - a.priority);\n for (const alterer of this.alterers) {\n await alterer.callback(doc);\n }\n\n // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\n }\n\n const htmlContent = \"<!DOCTYPE html>\\n\" + doc.documentElement.outerHTML;\n const blob = new Blob([htmlContent], { type: \"text/html;charset=utf-8\" });\n this.currentBlobUrl = URL.createObjectURL(blob);\n this.node.src = this.currentBlobUrl;\n\n this.node.onload = async () => {\n if (!(await this.options.get(\"updateHeight\"))) {\n await (\n await this.options.get(\"updateHeightCallback\")\n )(this);\n }\n this.node.onload = null;\n };\n }\n\n /**\n * Updates preview's height to match its content.\n */\n public updateHeight(): void {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n\n const styles = iframeWindow.getComputedStyle(el);\n const margin =\n parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n\n private getIFrameDocument(): Document {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n\n return iframeDocument;\n }\n\n private getIFrameWindow(): Window {\n const window = this.node.contentWindow;\n if (!window) {\n throw new Error(\"IFrame window is not available.\");\n }\n return window;\n }\n}\n","import { IsSingleTag, PreviewValue } from \"./types/PreviewValue\";\n\nexport const typeMap = {\n html: {\n languages: [\"html\"],\n tag: undefined,\n },\n js: {\n languages: [\"javascript\", \"typescript\"],\n tag: \"script\",\n },\n css: {\n languages: [\"css\"],\n tag: \"style\",\n },\n} as const;\n\nexport type TypeFromLanguage<L extends MonacoEditorLanguages> = {\n [K in ValueTypes]: L extends (typeof typeMap)[K][\"languages\"][number]\n ? K\n : never;\n}[ValueTypes];\n\nexport type ValueTypes = keyof typeof typeMap;\n\nexport type MonacoEditorLanguages =\n (typeof typeMap)[ValueTypes][\"languages\"][number];\n\nexport function getTypeFromLanguage<T extends MonacoEditorLanguages>(\n language: T,\n): TypeFromLanguage<T> {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language as never)) {\n return key as TypeFromLanguage<T>;\n }\n }\n\n throw new Error(\"Unknown language\");\n}\n\nexport function getTagFromType<T extends ValueTypes>(\n type: T,\n): (typeof typeMap)[T][\"tag\"] {\n return typeMap[type].tag;\n}\n\nexport function isSingleTagType(\n type: ValueTypes,\n): type is Extract<PreviewValue, IsSingleTag>[\"type\"] {\n return Boolean(getTagFromType(type));\n}\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultDestroyCallback,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n} from \"wraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\n\nimport type * as monaco from \"monaco-editor\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n getTagFromType,\n getTypeFromLanguage,\n isSingleTagType,\n MonacoEditorLanguages,\n} from \"./TypeMap\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\n\nexport type EditorCreator = (\n options: monaco.editor.IStandaloneEditorConstructionOptions,\n node: HTMLElement,\n monaco: MonacoInstance,\n) => Promise<monaco.editor.IStandaloneCodeEditor>;\n\nexport type ExhibitionMonacoEditorOptions = {\n /**\n * Monaco instance.\n */\n monaco: MonacoInstance;\n /**\n * Instead of depending on this class for editor instantiation, you can provide your own editor instance here.\n */\n monacoEditorCreator?: EditorCreator;\n\n /**\n * Monaco options for the editor.\n */\n monacoEditorOptions?: monaco.editor.IStandaloneEditorConstructionOptions;\n\n /**\n * Location where the editor should be inserted.\n */\n location?: \"head\" | \"body\";\n\n /**\n * Priority of the editor's document alterer. Higher priority means it will be executed first.\n */\n priority?: number;\n\n /**\n * Trim the default value of the editor.\n */\n trimDefaultValue?: boolean;\n\n /**\n * This option applies to single tag languages only (typescript, javascript and css). It\n * determines the attributes that will be added to the generated tag.\n */\n tagAttributes?: Record<string, string>;\n};\n\ntype RequiredMonacoEditorOptions = Required<\n Omit<ExhibitionMonacoEditorOptions, \"tagAttributes\" | \"monacoEditorCreator\">\n> & {\n tagAttributes?: ExhibitionMonacoEditorOptions[\"tagAttributes\"];\n monacoEditorCreator?: EditorCreator;\n};\n\nexport type MonacoInstance = typeof monaco;\n\nexport class ExhibitionMonacoEditor\n extends AbstractWraplet<HTMLElement>\n implements DocumentAltererProviderWraplet\n{\n private monaco: MonacoInstance | null = null;\n private editor: monaco.editor.IStandaloneCodeEditor | null = null;\n private options: KeyValueStorage<RequiredMonacoEditorOptions>;\n\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private priority: number = 0;\n private monacoEditorOptions:\n | RequiredMonacoEditorOptions[\"monacoEditorOptions\"]\n | null = null;\n\n constructor(\n core: Core<HTMLElement>,\n options: ExhibitionMonacoEditorOptions,\n optionsStorage?: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>>,\n ) {\n super(core);\n\n this.alterDocument = this.alterDocument.bind(this);\n\n const defaultOptions: Omit<\n RequiredMonacoEditorOptions,\n \"monacoEditorCreator\" | \"monaco\"\n > = {\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n\n const validators: StorageValidators<ExhibitionMonacoEditorOptions> = {\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data: unknown) =>\n typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data: unknown) => Number.isInteger(data),\n tagAttributes: (data: unknown) => typeof data === \"object\",\n trimDefaultValue: (data: unknown) => typeof data === \"boolean\",\n monacoEditorCreator: (data: unknown) => typeof data === \"function\",\n monaco: (data: unknown) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionMonacoEditorOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n {\n elementOptionsMerger: (defaults, attributeOptions) => {\n attributeOptions.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n ...attributeOptions.monacoEditorOptions,\n };\n return { ...defaults, ...options, ...attributeOptions };\n },\n },\n );\n\n this.options = new StorageWrapper<RequiredMonacoEditorOptions>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n destroy: this.destroy.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n destroyCallback: this.destroy,\n status: this.status,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"ExhibitionMonacoEditor is already initialized\");\n }\n this.priority = await this.options.get(\"priority\");\n this.monacoEditorOptions = await this.options.get(\n \"monacoEditorOptions\",\n );\n\n if (await this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = await this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(\n monacoOptions.value,\n );\n await this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n\n await this.validateOptions();\n\n this.monaco = await this.getMonacoInstance();\n\n const editorCreator: EditorCreator =\n (await this.options.get(\"monacoEditorCreator\")) ||\n (async (options, element, monaco) =>\n ExhibitionMonacoEditor.createMonacoEditor(\n options,\n element,\n monaco,\n ));\n\n this.editor = await editorCreator(\n await this.options.get(\"monacoEditorOptions\"),\n this.node,\n this.monaco,\n );\n },\n )();\n }\n\n public getPriority(): number {\n return this.priority;\n }\n\n private async getMonacoInstance(): Promise<MonacoInstance> {\n const monaco = await this.options.get(\"monaco\");\n if (!monaco) throw new Error(\"Monaco instance is not available\");\n return monaco;\n }\n\n /**\n * Returns the current value of the editor.\n */\n private getValue(): string {\n return this.getEditor().getValue();\n }\n\n private async alterDocument(document: Document): Promise<void> {\n const monaco = this.monaco;\n if (!monaco) {\n throw new Error(\n \"Monaco instance is not available. Is wraplet initialized?\",\n );\n }\n\n const language = this.getLanguage();\n const content =\n language === \"typescript\"\n ? await this.getTSValueAsJS(monaco)\n : this.getValue();\n\n const location = await this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = (await this.options.get(\"tagAttributes\")) ?? {};\n const tagElement = document.createElement(tag);\n for (const [key, value] of Object.entries(tagAttributes)) {\n tagElement.setAttribute(key, value);\n }\n tagElement.innerHTML = content;\n document[location].appendChild(tagElement);\n return;\n }\n document[location].innerHTML += content;\n }\n\n public getDocumentAlterer(): DocumentAlterer {\n return this.alterDocument;\n }\n\n /**\n * Additional validation.\n */\n private async validateOptions() {\n if (!(await this.options.get(\"monacoEditorOptions\")).language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (await this.options.get(\"tagAttributes\")) {\n throw new Error(\n \"'tagAttributes' option is only allowed for single tag types\",\n );\n }\n }\n }\n\n private getEditor(): monaco.editor.IStandaloneCodeEditor {\n if (!this.editor) throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n\n private async getTSValueAsJS(monaco: MonacoInstance) {\n const model = this.getEditor().getModel();\n if (!model) throw new Error(\"Model is not available\");\n\n // Make sure TypeScript eager sync is enabled\n monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\n\n // Ensure we're using file:/// URI\n const uri = model.uri;\n if (uri.scheme !== \"file\") {\n throw new Error(`Model must use file:// URI, got: ${uri.toString()}`);\n }\n\n // Get worker getter\n const getWorker = async (\n attempts: number = 10,\n ): Promise<\n | ((\n ...uris: monaco.Uri[]\n ) => Promise<monaco.languages.typescript.TypeScriptWorker>)\n | null\n > => {\n try {\n return await monaco.languages.typescript.getTypeScriptWorker();\n } catch (error) {\n if (error !== \"TypeScript not registered!\") throw error;\n if (attempts <= 0) return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n\n const worker = await workerGetter(uri);\n\n // 🔸 Wait until the worker actually knows this file\n // Call something lightweight to force registration\n for (let i = 0; i < 20; i++) {\n try {\n await worker.getSemanticDiagnostics(uri.toString());\n break; // success — worker now recognizes the file\n } catch (err) {\n if (/Could not find source file/.test(String(err))) {\n await new Promise((r) => setTimeout(r, 250));\n continue;\n }\n throw err;\n }\n }\n\n // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length) throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n\n private getLanguage(): MonacoEditorLanguages {\n const monacoOptions = this.monacoEditorOptions;\n if (!monacoOptions) {\n throw new Error(\n \"Monaco options are not available. Is wraplet initialized?\",\n );\n }\n\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n return monacoOptions[\"language\"] as MonacoEditorLanguages;\n }\n\n public static trimDefaultValue(content: string): string {\n const lines = content.split(\"\\n\");\n\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\n\n // Trim the same number of spaces from each line\n const trimmedLines = lines.map((line) => {\n // Only trim if the line has at least that many leading spaces\n if (\n line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\"\n ) {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n\n public async destroy() {\n return createDefaultDestroyCallback(\n {\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n status: this.status,\n },\n async () => {\n this.editor?.dispose();\n },\n )();\n }\n\n /**\n * Helper method creating a new monaco editor instance.\n */\n public static createMonacoEditor(\n editorOptions: monaco.editor.IStandaloneEditorConstructionOptions = {},\n node: HTMLElement,\n monaco: MonacoInstance,\n ): monaco.editor.IStandaloneCodeEditor {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n\n const model = this.createMonacoModel(\n monaco,\n language,\n editorOptions.value || \"\",\n );\n\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n\n /**\n * Helper method creating a new monaco model instance.\n */\n public static createMonacoModel(\n monaco: MonacoInstance,\n language: string,\n value: string,\n ): monaco.editor.ITextModel {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(\n value,\n language,\n monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`),\n );\n }\n\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n public static create(\n element: HTMLElement,\n options: ExhibitionMonacoEditorOptions,\n ): ExhibitionMonacoEditor {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n WrapletChildrenMap,\n} from \"wraplet\";\nimport {\n ExhibitionPreview,\n ExhibitionPreviewOptions,\n} from \"./ExhibitionPreview\";\nimport {\n ExhibitionMonacoEditor,\n ExhibitionMonacoEditorOptions,\n} from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\nexport type ExhibitionOptions = {\n /**\n * Selector for the element that triggers the update of the preview.\n */\n updaterSelector?: string;\n};\n\nexport type ExhibitionInitOptions = {\n init?: boolean;\n updatePreview?: boolean;\n};\n\nexport type PreviewOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n previewOptions: O;\n }\n : { previewOptions?: O };\n\nexport type EditorsOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n editorsOptions: O;\n }\n : { editorsOptions?: O };\n\nexport type ExhibitionMapOptions<\n EO extends EditorsOptionsWrapper<unknown, boolean> | undefined =\n EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>,\n PO extends PreviewOptionsWrapper<unknown, boolean> | undefined =\n PreviewOptionsWrapper<ExhibitionPreviewOptions>,\n> = {\n Class?: Constructable<DocumentAltererProviderWraplet>;\n selectEditors?: boolean;\n} & (EO extends undefined\n ? EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>\n : EO) &\n (PO extends undefined ? PreviewOptionsWrapper<ExhibitionPreviewOptions> : PO);\n\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\" as string | undefined,\n multiple: true,\n required: false,\n Class:\n ExhibitionMonacoEditor as Constructable<DocumentAltererProviderWraplet>,\n args: [] as unknown[],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview as Constructable<PreviewWraplet>,\n args: [] as unknown[],\n },\n} satisfies WrapletChildrenMap;\n\nexport class Exhibition extends AbstractWraplet<\n HTMLElement,\n typeof ExhibitionMap\n> {\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private options: KeyValueStorage<Required<ExhibitionOptions>>;\n constructor(\n core: Core<HTMLElement, typeof ExhibitionMap>,\n options: ExhibitionOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionOptions>>,\n ) {\n super(core);\n const defaultOptions: Required<ExhibitionOptions> = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n const optsStorage =\n optionsStorage ??\n new ElementAttributeStorage<Partial<ExhibitionOptions>, true>(\n true,\n this.node,\n \"data-js-options\",\n {},\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n this.options = new StorageWrapper<Required<ExhibitionOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n status: this.status,\n destroyCallback: this.wraplet.destroy,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"Exhibition is already initialized\");\n }\n\n for (const editor of this.children.editors) {\n if (\n !editor.wraplet.status.isInitialized &&\n !editor.wraplet.status.isGettingInitialized\n ) {\n await editor.wraplet.initialize();\n }\n\n if (\n !this.children.preview.hasDocumentAlterer(\n editor.getDocumentAlterer(),\n )\n ) {\n this.addPreviewAlterer(\n editor.getDocumentAlterer(),\n editor.getPriority(),\n );\n }\n }\n\n const updaterElements = this.node.querySelectorAll(\n await this.options.get(\"updaterSelector\"),\n );\n\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n },\n )();\n }\n\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n public addEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.add(editor);\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Removes DocumentAltererProviderWraplet instance from the list of editors.\n */\n public removeEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.delete(editor);\n this.children.preview.removeDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Checks if the given editor is present in the list of editors.\n */\n public hasEditor(editor: DocumentAltererProviderWraplet): boolean {\n return this.children.editors.has(editor);\n }\n\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n private addPreviewAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n\n public getPreview(): PreviewWraplet {\n return this.children.preview;\n }\n\n public async updatePreview(): Promise<void> {\n await this.children.preview.update();\n }\n\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param initOptions Options related to the creation process of the Exhibitions.\n * @param attribute Attribute to use for Exhibition instances.\n *\n * @returns Array of Exhibition instances.\n */\n public static async createMultiple<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n node: ParentNode,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n attribute: string = exhibitionDefaultAttribute,\n ): Promise<Exhibition[]> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n\n const exhibitions = this.createWraplets<HTMLElement, Exhibition>(\n node,\n map,\n attribute,\n [options],\n );\n\n for (const exhibition of exhibitions) {\n await this.applyCreateOptions(exhibition, initOptions);\n }\n\n return exhibitions;\n }\n\n /**\n * Create a single Exhibition instance wrapping a given element.\n *\n * @param element Element to wrap.\n * @param map Map of dependencies for the Exhibition instance.\n * @param options Options for the Exhibition instance.\n * @param initOptions Options related to the creation process of the Exhibitions.\n */\n public static async create<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n element: HTMLElement,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n ): Promise<Exhibition> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n const core = new DefaultCore<HTMLElement, typeof ExhibitionMap>(\n element,\n map,\n );\n const exhibition = new Exhibition(core, options);\n await this.applyCreateOptions(exhibition, initOptions);\n return exhibition;\n }\n\n private static fillCreateOptionsWithDefaults(\n createOptions: ExhibitionInitOptions,\n ) {\n return {\n init: true,\n updatePreview: false,\n ...createOptions,\n };\n }\n\n /**\n * Validate create options.\n */\n private static validateInitOptions(\n initOptions: ExhibitionInitOptions,\n map: typeof ExhibitionMap,\n ) {\n if (initOptions.init && map.editors.selector === undefined) {\n throw new Error(\n \"Cannot initialize exhibition with undefined editors.selector\",\n );\n }\n\n if (!initOptions.init && initOptions.updatePreview) {\n throw new Error(\n \"Cannot update preview without initializing exhibitions first\",\n );\n }\n }\n\n /**\n * Create options.\n */\n private static async applyCreateOptions(\n exhibition: Exhibition,\n options: ExhibitionInitOptions = {},\n ): Promise<void> {\n if (!options.init && options.updatePreview) {\n throw new Error(\n \"'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.\",\n );\n }\n\n if (options.init) {\n await exhibition.initialize();\n }\n\n if (options.updatePreview) {\n await exhibition.updatePreview();\n }\n }\n\n /**\n * Returns a generic dependecy map with an undefined editor class that has to be provided through\n * the options.\n *\n * @param mapOptions\n * Map options.\n */\n public static getMap<\n O extends ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n > = ExhibitionMapOptions,\n >(mapOptions?: NoInfer<O>): typeof ExhibitionMap {\n const map: typeof ExhibitionMap = ExhibitionMap;\n const allOptions: Required<\n ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n >\n > = {\n ...{\n selectEditors: true,\n Class: undefined as any,\n editorsOptions: {},\n previewOptions: {},\n },\n ...mapOptions,\n };\n\n if (allOptions.Class) {\n map[\"editors\"][\"Class\"] = allOptions.Class;\n }\n\n if (\n map[\"editors\"][\"Class\"] instanceof ExhibitionMonacoEditor &&\n allOptions.editorsOptions &&\n !(allOptions.editorsOptions as { monaco?: unknown })[\"monaco\"]\n ) {\n throw new Error(\n \"When using ExhibitionMonacoEditor as editors class, you must provide the 'monaco' option in the editors options.\",\n );\n }\n\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n\n if (allOptions.previewOptions) {\n map[\"preview\"][\"args\"].push(allOptions.previewOptions);\n }\n\n if (allOptions.editorsOptions) {\n map[\"editors\"][\"args\"].push(allOptions.editorsOptions);\n }\n\n return map;\n }\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","t","Error","e","i","s","n","a","l","h","getPrototypeOf","d","c","u","p","Set","find","this","push","findOne","getOrdered","Array","from","sort","f","w","b","v","I","args","destructible","map","coreOptions","W","r","E","D","z","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","L","element","initOptions","Class","G","node","childrenAreInstantiated","statusWritable","isDestroyed","isGettingDestroyed","isInitialized","isGettingInitialized","status","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","values","flatMap","Promise","all","wraplet","initialize","destroy","instantiateChildren","querySelectorAll","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","createArg","required","console","warn","message","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","delete","Proxy","defaultInitOptions","assign","entries","S","A","P","async","N","core","$","destroyCallback","T","j","destroyListeners","q","R","supportedNodeTypes","onChildDestroy","bind","onChildInstantiate","groupExtractor","Element","getAttribute","split","initializeCallback","__nodeAccessors","k","setGroupsExtractor","getGroups","F","supportedNodeTypesGuard","isChildInstance","createCore","createWraplets","hasAttribute","B","storage","defaults","validators","has","validateGetValue","getMultiple","getAll","keys","set","validateSetValue","setMultiple","setAll","deleteMultiple","deleteAll","String","isPartial","data","validateValidators","keepFresh","elementOptionsMerger","reduce","refresh","getValue","JSON","parse","setValue","deleteAllValues","fetchFreshData","charAt","validateData","attribute","super","setAttribute","stringify","removeAttribute","ExhibitionPreview","alterers","currentBlobUrl","optionsStorage","defaultOptions","updateHeight","updateHeightCallback","preview","setTimeout","optsStorage","HTMLIFrameElement","addDocumentAlterer","alterer","priority","hasDocumentAlterer","some","altererData","removeDocumentAlterer","update","doc","document","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","type","createObjectURL","src","onload","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","Math","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","includes","getTagFromType","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","monacoEditorOptions","alterDocument","location","trimDefaultValue","Number","isInteger","tagAttributes","monacoEditorCreator","attributeOptions","HTMLElement","monacoOptions","validateOptions","getMonacoInstance","editorCreator","createMonacoEditor","getPriority","getEditor","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","attempts","getTypeScriptWorker","error","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","random","createModel","Uri","exhibitionDefaultAttribute","ExhibitionMap","editors","Exhibition","updaterSelector","addPreviewAlterer","updaterElements","updatePreview","addEditor","removeEditor","hasEditor","getPreview","createMultiple","fillCreateOptionsWithDefaults","validateInitOptions","exhibitions","exhibition","applyCreateOptions","createOptions","init","getMap","mapOptions","allOptions","selectEditors","editorsOptions","previewOptions"],"ignoreList":[],"sourceRoot":""}
1
+ {"version":3,"file":"index.cjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,4HCLvD,MAAMC,UAAUC,OAAO,MAAMC,UAAUD,OAAO,MAAME,UAAUF,OAAO,MAAMG,UAAUH,OAA8B,MAAMI,UAAUJ,OAAO,MAAMK,UAAUL,OAAO,MAAMd,UAAUc,OAAO,MAAMM,UAAUN,OAAO,SAASO,EAAER,GAAG,OAAOZ,OAAOqB,eAAeT,KAAKZ,OAAOM,SAAS,CAAC,MAAMgB,EAAE,CAACV,EAAEE,IAAI,iBAAiBF,GAAG,OAAOA,IAAG,IAAKA,EAAEE,GAAGS,EAAEd,OAAO,cAAc,SAASe,EAAEZ,GAAG,OAAOU,EAAEV,EAAEW,EAAE,CAAC,MAAME,UAAUC,IAAI,IAA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AIpG,MACR,gEAIJ,IAAK0D,EAAY4R,MAAQ5R,EAAYgR,cACnC,MAAM,IAAI1U,MACR,+DAGN,CAKQ,+BAAaoV,CACnBD,EACA3N,EAAiC,CAAC,GAElC,IAAKA,EAAQ8N,MAAQ9N,EAAQkN,cAC3B,MAAM,IAAI1U,MACR,qHAIAwH,EAAQ8N,YACJH,EAAWhQ,aAGfqC,EAAQkN,qBACJS,EAAWT,eAErB,CASO,aAAOa,CAKZC,GACA,MAAM3T,EAA4BuS,EAC5BqB,EAKF,CAEAC,eAAe,EACf/R,WAAOiM,EACP+F,eAAgB,CAAC,EACjBC,eAAgB,CAAC,KAEhBJ,GAOL,GAJIC,EAAW9R,QACb9B,EAAa,QAAS,MAAI4T,EAAW9R,OAIrC8R,EAAWC,eACX7T,EAAa,QAAS,iBAAawO,KACjCoF,EAAWE,iBACTF,EAAWE,eAAgD,QAE/D,MAAM,IAAI3V,MACR,8LAgBJ,OAZKyV,EAAWC,gBACd7T,EAAa,QAAY,cAAI+N,GAG3B6F,EAAWG,gBACb/T,EAAa,QAAQ,KAAEb,KAAKyU,EAAWG,gBAGrCH,EAAWE,gBACb9T,EAAa,QAAQ,KAAEb,KAAKyU,EAAWE,gBAGlC9T,CACT,E","sources":["webpack://exhibitionjs/webpack/bootstrap","webpack://exhibitionjs/webpack/runtime/define property getters","webpack://exhibitionjs/webpack/runtime/hasOwnProperty shorthand","webpack://exhibitionjs/webpack/runtime/make namespace object","webpack://exhibitionjs/./node_modules/wraplet/dist/index.js","webpack://exhibitionjs/./node_modules/wraplet/dist/storage.js","webpack://exhibitionjs/./src/ExhibitionPreview.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/selectors.ts","webpack://exhibitionjs/./src/Exhibition.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}function h(t){return Object.getPrototypeOf(t)===Object.prototype}const d=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],c=Symbol(\"WrapletSet\");function u(t){return d(t,c)}class p extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const f=Symbol(\"WrapletSetReadonly\");class w extends p{[f]=!0;[c]=!0}function y(t){const e=t.wraplets;return u(e)&&0!==e.size?e:new w}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function g(t,e){await e(t);const i=t.childNodes;for(const t of i)await g(t,e)}async function m(t){await g(t,async t=>{const e=y(t);for(const i of e)i.wraplet.status.isGettingDestroyed||i.wraplet.status.isDestroyed||await i.wraplet.destroy(),C(i,t)})}const b=Symbol(\"Core\"),v=Symbol(\"NodeTreeParent\");function I(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function W(t){const e={};for(const i in t){const s=t[i];e[i]=I(s);const r=s.map;r&&h(r)&&(e[i].map=W(r))}return e}const E=Symbol(\"DynamicMap\");function D(t){return d(t,E)}class z{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=W(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);const s=e[i].map;if(h(s))e=s;else{if(!D(s))throw new Error(\"Invalid map type.\");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error(\"Map doesn't exist.\");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(D(t))return!0;if(!h(t))throw new Error(\"Invalid map type.\");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error(\"At the root already.\");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new z(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol(\"ArgCreator\");function L(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class G{node;[b]=!0;[v]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=L;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error(\"The node provided to the Core is not a valid node.\");if(h(i))this.mapWrapper=new z(i);else{if(!(i instanceof z))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?u(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!u(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new o(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,a=this.findChildren(r,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${s}\" child. Selector used: \"${r}\".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>d(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof l&&!e.required)return console.warn(`${i.message} Skipping instantiation of the \"${t}\" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new a(\"Children are already destroyed.\");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}removeChild(t,e){if(u(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i(\"Required child has been destroyed.\");if(null===this.instantiatedChildren[e])throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency \"${t}\" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${s.selector}\".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class x{creator;[M]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new x(t)}}const S=Symbol(\"Wraplet\");function O(t){return d(t,S)}const A=Symbol(\"Groupable\");async function N(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function j(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function P(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot initialize without status available.\");const i=t.status||this.status;await N(i,t.core)&&(e&&await e(),await $(i,t.destroyCallback))}}function T(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot destroy without status available.\");const i=t.status||this.status;await j(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(i))}}const k=t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||T({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||P({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]});return Object.assign(k(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class R{core;[S]=!0;[A]=!0;[v]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!d(t,b))throw new Error(\"AbstractWraplet requires a Core instance.\");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new l(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new G(t,e)}static createWraplets(t,e,i,s=[]){if(this===R)throw new Error(\"You cannot instantiate an abstract class.\");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}class Y{levels;[E]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error(\"There have to be more than 0 repeated levels.\")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new Y(t)}}class _ extends p{[f]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");return Object.assign(e,t)}export{R as AbstractWraplet,a as ChildrenAreAlreadyDestroyedError,s as ChildrenAreNotAvailableError,n as ChildrenTooManyFoundError,x as DefaultArgCreator,G as DefaultCore,w as DefaultWrapletSet,_ as DefaultWrapletSetReadonly,o as InternalLogicError,e as MapError,Y as MapRepeat,t as MissingRequiredChildError,i as RequiredChildDestroyedError,r as StorageValidationError,l as UnsupportedNodeTypeError,S as WrapletSymbol,T as createDefaultDestroyCallback,P as createDefaultInitializeCallback,F as createRichWrapletApi,k as createWrapletApi,B as customizeDefaultWrapletApi,L as defaultWrapletCreator,m as destroyWrapletsRecursively,q as destructionCompleted,j as destructionStarted,y as getWrapletsFromNode,$ as initializationCompleted,N as initializationStarted,O as isWraplet};\n//# sourceMappingURL=index.js.map","const t=Symbol(\"KeyValueStorage\");function e(e){return(e=>\"object\"==typeof e&&null!==e&&!0===e[t])(e)}class a extends Error{}class s{storage;defaults;validators;[t]=!0;constructor(t,e,a){this.storage=t,this.defaults=e,this.validators=a}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const a of t)void 0===e[a]&&(e[a]=this.defaults[a]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new a(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`)}}class i{isPartial;defaults;validators;[t]=!0;data=null;options;constructor(t,e,a,s={}){this.isPartial=t,this.defaults=e,this.validators=a,this.validateValidators(a),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,a)=>(t[a]=e[a],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`);const s=await this.getValue(),i=JSON.parse(s);i[t]=e,await this.setAll(i)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const a of t)delete e[a];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if(\"{\"!==t.charAt(0))throw new a(\"Data has to be defined as an object.\");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new a(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new a(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if(\"function\"!=typeof t[e])throw new a(`Validator for ${e} is not a function.`)}}class l extends i{element;attribute;defaults;validators;constructor(t,e,a,s,i,l={}){super(t,s,i,l),this.element=e,this.attribute=a,this.defaults=s,this.validators=i}async getValue(){return this.element.getAttribute(this.attribute)||\"{}\"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class r extends i{element;defaults;validators;constructor(t,e,a,s,i={}){super(t,a,s,i),this.element=e,this.defaults=a,this.validators=s}async getValue(){return this.element.textContent||\"{}\"}async setValue(t){this.element.textContent=JSON.stringify(t)}async deleteAllValues(){this.element.textContent=\"{}\"}}export{i as AbstractNongranularKeyValueStorage,l as ElementAttributeStorage,r as ElementStorage,t as KeyValueStorageSymbol,s as StorageWrapper,e as isKeyValueStorage};\n//# sourceMappingURL=storage.js.map","import { AbstractWraplet, Constructable, Core } from \"wraplet\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\ntype AltererData = {\n callback: DocumentAlterer;\n priority: number;\n};\n\nexport type ExhibitionPreviewOptions = {\n updateHeight?: boolean;\n updateHeightCallback?: (preview: ExhibitionPreview) => Promise<void>;\n};\n\nexport class ExhibitionPreview\n extends AbstractWraplet<HTMLIFrameElement>\n implements PreviewWraplet\n{\n private alterers: AltererData[] = [];\n private currentBlobUrl: string | null = null;\n\n private options: KeyValueStorage<Required<ExhibitionPreviewOptions>>;\n\n constructor(\n core: Core<HTMLIFrameElement>,\n options: ExhibitionPreviewOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionPreviewOptions>>,\n ) {\n super(core);\n\n const validators: StorageValidators<ExhibitionPreviewOptions> = {\n updateHeight: (data: unknown) => typeof data === \"boolean\",\n updateHeightCallback: (data: unknown) => typeof data === \"function\",\n };\n\n const defaultOptions: Required<ExhibitionPreviewOptions> = {\n updateHeight: true,\n updateHeightCallback: async (preview) => {\n setTimeout(() => {\n preview.updateHeight();\n }, 100);\n },\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionPreviewOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionPreviewOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n );\n\n this.options = new StorageWrapper<Required<ExhibitionPreviewOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLIFrameElement>[] {\n return super.supportedNodeTypesGuard([HTMLIFrameElement]);\n }\n\n /**\n * Adds a DocumentAlterer to the preview.\n * @param alterer\n * @param priority\n * Priority of the alterer. Higher priority alterers are executed first.\n */\n public addDocumentAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n if (this.hasDocumentAlterer(alterer)) {\n return;\n }\n\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n\n /**\n * Checks if alterer is already registered.\n * @param alterer\n */\n public hasDocumentAlterer(alterer: DocumentAlterer): boolean {\n return this.alterers.some(\n (altererData) => altererData.callback === alterer,\n );\n }\n\n public removeDocumentAlterer(alterer: DocumentAlterer): void {\n this.alterers = this.alterers.filter(\n (altererData) => altererData.callback !== alterer,\n );\n }\n\n public async update(): Promise<void> {\n const doc = document.implementation.createHTMLDocument();\n this.alterers.sort((a, b) => b.priority - a.priority);\n for (const alterer of this.alterers) {\n await alterer.callback(doc);\n }\n\n // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\n }\n\n const htmlContent = \"<!DOCTYPE html>\\n\" + doc.documentElement.outerHTML;\n const blob = new Blob([htmlContent], { type: \"text/html;charset=utf-8\" });\n this.currentBlobUrl = URL.createObjectURL(blob);\n this.node.src = this.currentBlobUrl;\n\n this.node.onload = async () => {\n if (!(await this.options.get(\"updateHeight\"))) {\n await (\n await this.options.get(\"updateHeightCallback\")\n )(this);\n }\n this.node.onload = null;\n };\n }\n\n /**\n * Updates preview's height to match its content.\n */\n public updateHeight(): void {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n\n const styles = iframeWindow.getComputedStyle(el);\n const margin =\n parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n\n private getIFrameDocument(): Document {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n\n return iframeDocument;\n }\n\n private getIFrameWindow(): Window {\n const window = this.node.contentWindow;\n if (!window) {\n throw new Error(\"IFrame window is not available.\");\n }\n return window;\n }\n}\n","import { IsSingleTag, PreviewValue } from \"./types/PreviewValue\";\n\nexport const typeMap = {\n html: {\n languages: [\"html\"],\n tag: undefined,\n },\n js: {\n languages: [\"javascript\", \"typescript\"],\n tag: \"script\",\n },\n css: {\n languages: [\"css\"],\n tag: \"style\",\n },\n} as const;\n\nexport type TypeFromLanguage<L extends MonacoEditorLanguages> = {\n [K in ValueTypes]: L extends (typeof typeMap)[K][\"languages\"][number]\n ? K\n : never;\n}[ValueTypes];\n\nexport type ValueTypes = keyof typeof typeMap;\n\nexport type MonacoEditorLanguages =\n (typeof typeMap)[ValueTypes][\"languages\"][number];\n\nexport function getTypeFromLanguage<T extends MonacoEditorLanguages>(\n language: T,\n): TypeFromLanguage<T> {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language as never)) {\n return key as TypeFromLanguage<T>;\n }\n }\n\n throw new Error(\"Unknown language\");\n}\n\nexport function getTagFromType<T extends ValueTypes>(\n type: T,\n): (typeof typeMap)[T][\"tag\"] {\n return typeMap[type].tag;\n}\n\nexport function isSingleTagType(\n type: ValueTypes,\n): type is Extract<PreviewValue, IsSingleTag>[\"type\"] {\n return Boolean(getTagFromType(type));\n}\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultDestroyCallback,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n} from \"wraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\n\nimport type * as monaco from \"monaco-editor\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n getTagFromType,\n getTypeFromLanguage,\n isSingleTagType,\n MonacoEditorLanguages,\n} from \"./TypeMap\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\n\nexport type EditorCreator = (\n options: monaco.editor.IStandaloneEditorConstructionOptions,\n node: HTMLElement,\n monaco: MonacoInstance,\n) => Promise<monaco.editor.IStandaloneCodeEditor>;\n\nexport type ExhibitionMonacoEditorOptions = {\n /**\n * Monaco instance.\n */\n monaco: MonacoInstance;\n /**\n * Instead of depending on this class for editor instantiation, you can provide your own editor instance here.\n */\n monacoEditorCreator?: EditorCreator;\n\n /**\n * Monaco options for the editor.\n */\n monacoEditorOptions?: monaco.editor.IStandaloneEditorConstructionOptions;\n\n /**\n * Location where the editor should be inserted.\n */\n location?: \"head\" | \"body\";\n\n /**\n * Priority of the editor's document alterer. Higher priority means it will be executed first.\n */\n priority?: number;\n\n /**\n * Trim the default value of the editor.\n */\n trimDefaultValue?: boolean;\n\n /**\n * This option applies to single tag languages only (typescript, javascript and css). It\n * determines the attributes that will be added to the generated tag.\n */\n tagAttributes?: Record<string, string>;\n};\n\ntype RequiredMonacoEditorOptions = Required<\n Omit<ExhibitionMonacoEditorOptions, \"tagAttributes\" | \"monacoEditorCreator\">\n> & {\n tagAttributes?: ExhibitionMonacoEditorOptions[\"tagAttributes\"];\n monacoEditorCreator?: EditorCreator;\n};\n\nexport type MonacoInstance = typeof monaco;\n\nexport class ExhibitionMonacoEditor\n extends AbstractWraplet<HTMLElement>\n implements DocumentAltererProviderWraplet\n{\n private monaco: MonacoInstance | null = null;\n private editor: monaco.editor.IStandaloneCodeEditor | null = null;\n private options: KeyValueStorage<RequiredMonacoEditorOptions>;\n\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private priority: number = 0;\n private monacoEditorOptions:\n | RequiredMonacoEditorOptions[\"monacoEditorOptions\"]\n | null = null;\n\n constructor(\n core: Core<HTMLElement>,\n options: ExhibitionMonacoEditorOptions,\n optionsStorage?: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>>,\n ) {\n super(core);\n\n this.alterDocument = this.alterDocument.bind(this);\n\n const defaultOptions: Omit<\n RequiredMonacoEditorOptions,\n \"monacoEditorCreator\" | \"monaco\"\n > = {\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n\n const validators: StorageValidators<ExhibitionMonacoEditorOptions> = {\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data: unknown) =>\n typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data: unknown) => Number.isInteger(data),\n tagAttributes: (data: unknown) => typeof data === \"object\",\n trimDefaultValue: (data: unknown) => typeof data === \"boolean\",\n monacoEditorCreator: (data: unknown) => typeof data === \"function\",\n monaco: (data: unknown) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionMonacoEditorOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n {\n elementOptionsMerger: (defaults, attributeOptions) => {\n attributeOptions.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n ...attributeOptions.monacoEditorOptions,\n };\n return { ...defaults, ...options, ...attributeOptions };\n },\n },\n );\n\n this.options = new StorageWrapper<RequiredMonacoEditorOptions>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n destroy: this.destroy.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n destroyCallback: this.destroy,\n status: this.status,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"ExhibitionMonacoEditor is already initialized\");\n }\n this.priority = await this.options.get(\"priority\");\n this.monacoEditorOptions = await this.options.get(\n \"monacoEditorOptions\",\n );\n\n if (await this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = await this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(\n monacoOptions.value,\n );\n await this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n\n await this.validateOptions();\n\n this.monaco = await this.getMonacoInstance();\n\n const editorCreator: EditorCreator =\n (await this.options.get(\"monacoEditorCreator\")) ||\n (async (options, element, monaco) =>\n ExhibitionMonacoEditor.createMonacoEditor(\n options,\n element,\n monaco,\n ));\n\n this.editor = await editorCreator(\n await this.options.get(\"monacoEditorOptions\"),\n this.node,\n this.monaco,\n );\n },\n )();\n }\n\n public getPriority(): number {\n return this.priority;\n }\n\n private async getMonacoInstance(): Promise<MonacoInstance> {\n const monaco = await this.options.get(\"monaco\");\n if (!monaco) throw new Error(\"Monaco instance is not available\");\n return monaco;\n }\n\n /**\n * Returns the current value of the editor.\n */\n private getValue(): string {\n return this.getEditor().getValue();\n }\n\n private async alterDocument(document: Document): Promise<void> {\n const monaco = this.monaco;\n if (!monaco) {\n throw new Error(\n \"Monaco instance is not available. Is wraplet initialized?\",\n );\n }\n\n const language = this.getLanguage();\n const content =\n language === \"typescript\"\n ? await this.getTSValueAsJS(monaco)\n : this.getValue();\n\n const location = await this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = (await this.options.get(\"tagAttributes\")) ?? {};\n const tagElement = document.createElement(tag);\n for (const [key, value] of Object.entries(tagAttributes)) {\n tagElement.setAttribute(key, value);\n }\n tagElement.innerHTML = content;\n document[location].appendChild(tagElement);\n return;\n }\n document[location].innerHTML += content;\n }\n\n public getDocumentAlterer(): DocumentAlterer {\n return this.alterDocument;\n }\n\n /**\n * Additional validation.\n */\n private async validateOptions() {\n if (!(await this.options.get(\"monacoEditorOptions\")).language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (await this.options.get(\"tagAttributes\")) {\n throw new Error(\n \"'tagAttributes' option is only allowed for single tag types\",\n );\n }\n }\n }\n\n private getEditor(): monaco.editor.IStandaloneCodeEditor {\n if (!this.editor) throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n\n private async getTSValueAsJS(monaco: MonacoInstance) {\n const model = this.getEditor().getModel();\n if (!model) throw new Error(\"Model is not available\");\n\n // Make sure TypeScript eager sync is enabled\n monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\n\n // Ensure we're using file:/// URI\n const uri = model.uri;\n if (uri.scheme !== \"file\") {\n throw new Error(`Model must use file:// URI, got: ${uri.toString()}`);\n }\n\n // Get worker getter\n const getWorker = async (\n attempts: number = 10,\n ): Promise<\n | ((\n ...uris: monaco.Uri[]\n ) => Promise<monaco.languages.typescript.TypeScriptWorker>)\n | null\n > => {\n try {\n return await monaco.languages.typescript.getTypeScriptWorker();\n } catch (error) {\n if (error !== \"TypeScript not registered!\") throw error;\n if (attempts <= 0) return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n\n const worker = await workerGetter(uri);\n\n // 🔸 Wait until the worker actually knows this file\n // Call something lightweight to force registration\n for (let i = 0; i < 20; i++) {\n try {\n await worker.getSemanticDiagnostics(uri.toString());\n break; // success — worker now recognizes the file\n } catch (err) {\n if (/Could not find source file/.test(String(err))) {\n await new Promise((r) => setTimeout(r, 250));\n continue;\n }\n throw err;\n }\n }\n\n // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length) throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n\n private getLanguage(): MonacoEditorLanguages {\n const monacoOptions = this.monacoEditorOptions;\n if (!monacoOptions) {\n throw new Error(\n \"Monaco options are not available. Is wraplet initialized?\",\n );\n }\n\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n return monacoOptions[\"language\"] as MonacoEditorLanguages;\n }\n\n public static trimDefaultValue(content: string): string {\n const lines = content.split(\"\\n\");\n\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\n\n // Trim the same number of spaces from each line\n const trimmedLines = lines.map((line) => {\n // Only trim if the line has at least that many leading spaces\n if (\n line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\"\n ) {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n\n public async destroy() {\n return createDefaultDestroyCallback(\n {\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n status: this.status,\n },\n async () => {\n this.editor?.dispose();\n },\n )();\n }\n\n /**\n * Helper method creating a new monaco editor instance.\n */\n public static createMonacoEditor(\n editorOptions: monaco.editor.IStandaloneEditorConstructionOptions = {},\n node: HTMLElement,\n monaco: MonacoInstance,\n ): monaco.editor.IStandaloneCodeEditor {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n\n const model = this.createMonacoModel(\n monaco,\n language,\n editorOptions.value || \"\",\n );\n\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n\n /**\n * Helper method creating a new monaco model instance.\n */\n public static createMonacoModel(\n monaco: MonacoInstance,\n language: string,\n value: string,\n ): monaco.editor.ITextModel {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(\n value,\n language,\n monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`),\n );\n }\n\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n public static create(\n element: HTMLElement,\n options: ExhibitionMonacoEditorOptions,\n ): ExhibitionMonacoEditor {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n WrapletChildrenMap,\n} from \"wraplet\";\nimport {\n ExhibitionPreview,\n ExhibitionPreviewOptions,\n} from \"./ExhibitionPreview\";\nimport {\n ExhibitionMonacoEditor,\n ExhibitionMonacoEditorOptions,\n} from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\nexport type ExhibitionOptions = {\n /**\n * Selector for the element that triggers the update of the preview.\n */\n updaterSelector?: string;\n};\n\nexport type ExhibitionInitOptions = {\n init?: boolean;\n updatePreview?: boolean;\n};\n\nexport type PreviewOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n previewOptions: O;\n }\n : { previewOptions?: O };\n\nexport type EditorsOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n editorsOptions: O;\n }\n : { editorsOptions?: O };\n\nexport type ExhibitionMapOptions<\n EO extends EditorsOptionsWrapper<unknown, boolean> | undefined =\n EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>,\n PO extends PreviewOptionsWrapper<unknown, boolean> | undefined =\n PreviewOptionsWrapper<ExhibitionPreviewOptions>,\n> = {\n Class?: Constructable<DocumentAltererProviderWraplet>;\n selectEditors?: boolean;\n} & (EO extends undefined\n ? EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>\n : EO) &\n (PO extends undefined ? PreviewOptionsWrapper<ExhibitionPreviewOptions> : PO);\n\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\" as string | undefined,\n multiple: true,\n required: false,\n Class:\n ExhibitionMonacoEditor as Constructable<DocumentAltererProviderWraplet>,\n args: [] as unknown[],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview as Constructable<PreviewWraplet>,\n args: [] as unknown[],\n },\n} satisfies WrapletChildrenMap;\n\nexport class Exhibition extends AbstractWraplet<\n HTMLElement,\n typeof ExhibitionMap\n> {\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private options: KeyValueStorage<Required<ExhibitionOptions>>;\n constructor(\n core: Core<HTMLElement, typeof ExhibitionMap>,\n options: ExhibitionOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionOptions>>,\n ) {\n super(core);\n const defaultOptions: Required<ExhibitionOptions> = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n const optsStorage =\n optionsStorage ??\n new ElementAttributeStorage<Partial<ExhibitionOptions>, true>(\n true,\n this.node,\n \"data-js-options\",\n {},\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n this.options = new StorageWrapper<Required<ExhibitionOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n status: this.status,\n destroyCallback: this.wraplet.destroy,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"Exhibition is already initialized\");\n }\n\n for (const editor of this.children.editors) {\n if (\n !editor.wraplet.status.isInitialized &&\n !editor.wraplet.status.isGettingInitialized\n ) {\n await editor.wraplet.initialize();\n }\n\n if (\n !this.children.preview.hasDocumentAlterer(\n editor.getDocumentAlterer(),\n )\n ) {\n this.addPreviewAlterer(\n editor.getDocumentAlterer(),\n editor.getPriority(),\n );\n }\n }\n\n const updaterElements = this.node.querySelectorAll(\n await this.options.get(\"updaterSelector\"),\n );\n\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n },\n )();\n }\n\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n public addEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.add(editor);\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Removes DocumentAltererProviderWraplet instance from the list of editors.\n */\n public removeEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.delete(editor);\n this.children.preview.removeDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Checks if the given editor is present in the list of editors.\n */\n public hasEditor(editor: DocumentAltererProviderWraplet): boolean {\n return this.children.editors.has(editor);\n }\n\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n private addPreviewAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n\n public getPreview(): PreviewWraplet {\n return this.children.preview;\n }\n\n public async updatePreview(): Promise<void> {\n await this.children.preview.update();\n }\n\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param initOptions Options related to the creation process of the Exhibitions.\n * @param attribute Attribute to use for Exhibition instances.\n *\n * @returns Array of Exhibition instances.\n */\n public static async createMultiple<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n node: ParentNode,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n attribute: string = exhibitionDefaultAttribute,\n ): Promise<Exhibition[]> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n\n const exhibitions = this.createWraplets<HTMLElement, Exhibition>(\n node,\n map,\n attribute,\n [options],\n );\n\n for (const exhibition of exhibitions) {\n await this.applyCreateOptions(exhibition, initOptions);\n }\n\n return exhibitions;\n }\n\n /**\n * Create a single Exhibition instance wrapping a given element.\n *\n * @param element Element to wrap.\n * @param map Map of dependencies for the Exhibition instance.\n * @param options Options for the Exhibition instance.\n * @param initOptions Options related to the creation process of the Exhibitions.\n */\n public static async create<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n element: HTMLElement,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n ): Promise<Exhibition> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n const core = new DefaultCore<HTMLElement, typeof ExhibitionMap>(\n element,\n map,\n );\n const exhibition = new Exhibition(core, options);\n await this.applyCreateOptions(exhibition, initOptions);\n return exhibition;\n }\n\n private static fillCreateOptionsWithDefaults(\n createOptions: ExhibitionInitOptions,\n ) {\n return {\n init: true,\n updatePreview: false,\n ...createOptions,\n };\n }\n\n /**\n * Validate create options.\n */\n private static validateInitOptions(\n initOptions: ExhibitionInitOptions,\n map: typeof ExhibitionMap,\n ) {\n if (initOptions.init && map.editors.selector === undefined) {\n throw new Error(\n \"Cannot initialize exhibition with undefined editors.selector\",\n );\n }\n\n if (!initOptions.init && initOptions.updatePreview) {\n throw new Error(\n \"Cannot update preview without initializing exhibitions first\",\n );\n }\n }\n\n /**\n * Create options.\n */\n private static async applyCreateOptions(\n exhibition: Exhibition,\n options: ExhibitionInitOptions = {},\n ): Promise<void> {\n if (!options.init && options.updatePreview) {\n throw new Error(\n \"'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.\",\n );\n }\n\n if (options.init) {\n await exhibition.initialize();\n }\n\n if (options.updatePreview) {\n await exhibition.updatePreview();\n }\n }\n\n /**\n * Returns a generic dependecy map with an undefined editor class that has to be provided through\n * the options.\n *\n * @param mapOptions\n * Map options.\n */\n public static getMap<\n O extends ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n > = ExhibitionMapOptions,\n >(mapOptions?: NoInfer<O>): typeof ExhibitionMap {\n const map: typeof ExhibitionMap = ExhibitionMap;\n const allOptions: Required<\n ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n >\n > = {\n ...{\n selectEditors: true,\n Class: undefined as any,\n editorsOptions: {},\n previewOptions: {},\n },\n ...mapOptions,\n };\n\n if (allOptions.Class) {\n map[\"editors\"][\"Class\"] = allOptions.Class;\n }\n\n if (\n allOptions.selectEditors &&\n map[\"editors\"][\"Class\"] instanceof ExhibitionMonacoEditor &&\n (!allOptions.editorsOptions ||\n !(allOptions.editorsOptions as { monaco?: unknown })[\"monaco\"])\n ) {\n throw new Error(\n \"When selecting ExhibitionMonacoEditor instances, you must provide the 'monaco' option in the editors options. To avoid this error, disable 'selectEditors' or provide the 'monaco' option.\",\n );\n }\n\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n\n if (allOptions.previewOptions) {\n map[\"preview\"][\"args\"].push(allOptions.previewOptions);\n }\n\n if (allOptions.editorsOptions) {\n map[\"editors\"][\"args\"].push(allOptions.editorsOptions);\n }\n\n return map;\n }\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","t","Error","e","i","s","n","a","l","h","getPrototypeOf","d","c","u","p","Set","find","this","push","findOne","getOrdered","Array","from","sort","f","w","b","v","I","args","destructible","map","coreOptions","W","r","E","D","z","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","L","element","initOptions","Class","G","node","childrenAreInstantiated","statusWritable","isDestroyed","isGettingDestroyed","isInitialized","isGettingInitialized","status","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","values","flatMap","Promise","all","wraplet","initialize","destroy","instantiateChildren","querySelectorAll","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","createArg","required","console","warn","message","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","delete","Proxy","defaultInitOptions","assign","entries","S","A","P","async","N","core","$","destroyCallback","T","j","destroyListeners","q","R","supportedNodeTypes","onChildDestroy","bind","onChildInstantiate","groupExtractor","Element","getAttribute","split","initializeCallback","__nodeAccessors","k","setGroupsExtractor","getGroups","F","supportedNodeTypesGuard","isChildInstance","createCore","createWraplets","hasAttribute","B","storage","defaults","validators","has","validateGetValue","getMultiple","getAll","keys","set","validateSetValue","setMultiple","setAll","deleteMultiple","deleteAll","String","isPartial","data","validateValidators","keepFresh","elementOptionsMerger","reduce","refresh","getValue","JSON","parse","setValue","deleteAllValues","fetchFreshData","charAt","validateData","attribute","super","setAttribute","stringify","removeAttribute","ExhibitionPreview","alterers","currentBlobUrl","optionsStorage","defaultOptions","updateHeight","updateHeightCallback","preview","setTimeout","optsStorage","HTMLIFrameElement","addDocumentAlterer","alterer","priority","hasDocumentAlterer","some","altererData","removeDocumentAlterer","update","doc","document","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","type","createObjectURL","src","onload","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","Math","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","includes","getTagFromType","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","monacoEditorOptions","alterDocument","location","trimDefaultValue","Number","isInteger","tagAttributes","monacoEditorCreator","attributeOptions","HTMLElement","monacoOptions","validateOptions","getMonacoInstance","editorCreator","createMonacoEditor","getPriority","getEditor","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","attempts","getTypeScriptWorker","error","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","random","createModel","Uri","exhibitionDefaultAttribute","ExhibitionMap","editors","Exhibition","updaterSelector","addPreviewAlterer","updaterElements","updatePreview","addEditor","removeEditor","hasEditor","getPreview","createMultiple","fillCreateOptionsWithDefaults","validateInitOptions","exhibitions","exhibition","applyCreateOptions","createOptions","init","getMap","mapOptions","allOptions","selectEditors","editorsOptions","previewOptions"],"ignoreList":[],"sourceRoot":""}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}function l(t){return Object.getPrototypeOf(t)===Object.prototype}const h=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],d=Symbol("WrapletSet");function c(t){return h(t,d)}class u extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const p=Symbol("WrapletSetReadonly");class w extends u{[p]=!0;[d]=!0}const f=Symbol("Core"),g=Symbol("NodeTreeParent");function y(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function m(t){const e={};for(const i in t){const s=t[i];e[i]=y(s);const r=s.map;r&&l(r)&&(e[i].map=m(r))}return e}const b=Symbol("DynamicMap");function v(t){return h(t,b)}class C{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=m(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const s=e[i].map;if(l(s))e=s;else{if(!v(s))throw new Error("Invalid map type.");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(v(t))return!0;if(!l(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new C(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const E=Symbol("ArgCreator");function O(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class M{node;[f]=!0;[g]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=O;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(l(i))this.mapWrapper=new C(i);else{if(!(i instanceof C))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?c(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(c(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!c(i))throw new a("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new a("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const n=t.selector,a=this.findChildren(n,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new r(`${this.constructor.name}: More than one element was found for the "${s}" child. Selector used: "${n}".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>h(t,E)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof o&&!e.required)return console.warn(`${i.message} Skipping instantiation of the "${t}" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new n("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(c(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new a("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new a("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet "${e}". Selector used: "${s.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(c(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}const I=Symbol("Wraplet"),D=Symbol("Groupable");function A(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const i=t.status||this.status;await async function(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}(i,t.core)&&(e&&await e(),await async function(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}(i,t.destroyCallback))}}function S(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const i=t.status||this.status;await async function(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await async function(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}(i))}}class z{core;[I]=!0;[D]=!0;[g]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!h(t,f))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new o(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=(t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign((t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||S({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||A({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})})(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})})({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new M(t,e)}static createWraplets(t,e,i,s=[]){if(this===z)throw new Error("You cannot instantiate an abstract class.");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}function W(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}const L=Symbol("KeyValueStorage");class x extends Error{}class G{storage;defaults;validators;[L]=!0;constructor(t,e,i){this.storage=t,this.defaults=e,this.validators=i}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const i of t)void 0===e[i]&&(e[i]=this.defaults[i]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new x(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new x(`Attempted to set an invalid value for the key ${String(t)}.`)}}class T{isPartial;defaults;validators;[L]=!0;data=null;options;constructor(t,e,i,s={}){this.isPartial=t,this.defaults=e,this.validators=i,this.validateValidators(i),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new x(`Attempted to set an invalid value for the key ${String(t)}.`);const i=await this.getValue(),s=JSON.parse(i);s[t]=e,await this.setAll(s)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const i of t)delete e[i];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if("{"!==t.charAt(0))throw new x("Data has to be defined as an object.");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new x(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new x(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if("function"!=typeof t[e])throw new x(`Validator for ${e} is not a function.`)}}class j extends T{element;attribute;defaults;validators;constructor(t,e,i,s,r,n={}){super(t,s,r,n),this.element=e,this.attribute=i,this.defaults=s,this.validators=r}async getValue(){return this.element.getAttribute(this.attribute)||"{}"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class P extends z{alterers=[];currentBlobUrl=null;options;constructor(t,e={},i){super(t);const s={updateHeight:!0,updateHeightCallback:async t=>{setTimeout(()=>{t.updateHeight()},100)}},r=i||new j(!0,t.node,"data-js-options",{},{});this.options=new G(r,{...s,...e},{updateHeight:t=>"boolean"==typeof t,updateHeightCallback:t=>"function"==typeof t})}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLIFrameElement])}addDocumentAlterer(t,e=0){this.hasDocumentAlterer(t)||this.alterers.push({callback:t,priority:e})}hasDocumentAlterer(t){return this.alterers.some(e=>e.callback===t)}removeDocumentAlterer(t){this.alterers=this.alterers.filter(e=>e.callback!==t)}async update(){const t=document.implementation.createHTMLDocument();this.alterers.sort((t,e)=>e.priority-t.priority);for(const e of this.alterers)await e.callback(t);this.currentBlobUrl&&URL.revokeObjectURL(this.currentBlobUrl);const e="<!DOCTYPE html>\n"+t.documentElement.outerHTML,i=new Blob([e],{type:"text/html;charset=utf-8"});this.currentBlobUrl=URL.createObjectURL(i),this.node.src=this.currentBlobUrl,this.node.onload=async()=>{await this.options.get("updateHeight")||await(await this.options.get("updateHeightCallback"))(this),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),s=parseFloat(i.marginTop)+parseFloat(i.marginBottom),r=Math.ceil(e.offsetHeight+s);this.node.height=r+"px"}getIFrameDocument(){const t=this.node.contentDocument;if(!t)throw new Error("IFrame document is not available.");return t}getIFrameWindow(){const t=this.node.contentWindow;if(!t)throw new Error("IFrame window is not available.");return t}}const k={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function N(t){for(const[e,i]of Object.entries(k))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function V(t){return k[t].tag}function $(t){return Boolean(V(t))}class q extends z{monaco=null;editor=null;options;status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};priority=0;monacoEditorOptions=null;constructor(t,e,i){super(t),this.alterDocument=this.alterDocument.bind(this);const s={location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={location:t=>"string"==typeof t&&["head","body"].includes(t),priority:t=>Number.isInteger(t),tagAttributes:t=>"object"==typeof t,trimDefaultValue:t=>"boolean"==typeof t,monacoEditorCreator:t=>"function"==typeof t,monaco:t=>"object"==typeof t,monacoEditorOptions:()=>!0};e.monacoEditorOptions={...s.monacoEditorOptions,...e.monacoEditorOptions};const n=i||new j(!0,t.node,"data-js-options",{},{},{elementOptionsMerger:(t,i)=>(i.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions,...i.monacoEditorOptions},{...t,...e,...i})});this.options=new G(n,{...s,...e},r),this.wraplet=W({status:this.status,initialize:this.initialize.bind(this),destroy:this.destroy.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return A({core:this.core,destroyCallback:this.destroy,status:this.status},async()=>{if(this.status.isInitialized)throw new Error("ExhibitionMonacoEditor is already initialized");if(this.priority=await this.options.get("priority"),this.monacoEditorOptions=await this.options.get("monacoEditorOptions"),await this.options.get("trimDefaultValue")){const t=await this.options.get("monacoEditorOptions");t.value&&(t.value=q.trimDefaultValue(t.value),await this.options.set("monacoEditorOptions",t))}await this.validateOptions(),this.monaco=await this.getMonacoInstance();const t=await this.options.get("monacoEditorCreator")||(async(t,e,i)=>q.createMonacoEditor(t,e,i));this.editor=await t(await this.options.get("monacoEditorOptions"),this.node,this.monaco)})()}getPriority(){return this.priority}async getMonacoInstance(){const t=await this.options.get("monaco");if(!t)throw new Error("Monaco instance is not available");return t}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.monaco;if(!e)throw new Error("Monaco instance is not available. Is wraplet initialized?");const i=this.getLanguage(),s="typescript"===i?await this.getTSValueAsJS(e):this.getValue(),r=await this.options.get("location"),n=N(i);if($(n)){const e=V(n),i=await this.options.get("tagAttributes")??{},a=t.createElement(e);for(const[t,e]of Object.entries(i))a.setAttribute(t,e);return a.innerHTML=s,void t[r].appendChild(a)}t[r].innerHTML+=s}getDocumentAlterer(){return this.alterDocument}async validateOptions(){if(!(await this.options.get("monacoEditorOptions")).language)throw new Error("Missing language in monacoOptions");if(!$(N(this.getLanguage()))&&await this.options.get("tagAttributes"))throw new Error("'tagAttributes' option is only allowed for single tag types")}getEditor(){if(!this.editor)throw new Error("Editor is not initialized");return this.editor}async getTSValueAsJS(t){const e=this.getEditor().getModel();if(!e)throw new Error("Model is not available");t.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const i=e.uri;if("file"!==i.scheme)throw new Error(`Model must use file:// URI, got: ${i.toString()}`);const s=async(e=10)=>{try{return await t.languages.typescript.getTypeScriptWorker()}catch(t){if("TypeScript not registered!"!==t)throw t;return e<=0?null:(await new Promise(t=>setTimeout(t,200)),s(e-1))}},r=await s();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(i);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(i.toString());break}catch(t){if(/Could not find source file/.test(String(t))){await new Promise(t=>setTimeout(t,250));continue}throw t}const{outputFiles:a}=await n.getEmitOutput(i.toString());if(!a.length)throw new Error("No JS output produced");return a[0].text}getLanguage(){const t=this.monacoEditorOptions;if(!t)throw new Error("Monaco options are not available. Is wraplet initialized?");if(!t.language)throw new Error("Missing language in monacoOptions");return t.language}static trimDefaultValue(t){const e=t.split("\n"),i=e.find(t=>t.trim().length>0);if(!i)return t.trim();const s=i.search(/\S|$/);return e.map(t=>t.length>=s&&""===t.substring(0,s).trim()?t.substring(s):t).join("\n").trim()}async destroy(){return S({core:this.core,wraplet:this,destroyListeners:this.destroyListeners,status:this.status},async()=>{this.editor?.dispose()})()}static createMonacoEditor(t={},e,i){const s=t.language;if(!s)throw new Error("Missing language in editorOptions");const r=this.createMonacoModel(i,s,t.value||"");return i.editor.create(e,{...t,model:r})}static createMonacoModel(t,e,i){const s=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${s}.ts`))}static create(t,e){const i=new M(t,{});return new q(i,e)}}const F="data-js-exhibition",H={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:q,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:P,args:[]}};class U extends z{status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};options;constructor(t,e={},i){super(t);const s=i??new j(!0,this.node,"data-js-options",{},{updaterSelector:t=>"string"==typeof t});this.options=new G(s,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t}),this.wraplet=W({status:this.status,initialize:this.initialize.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return A({core:this.core,status:this.status,destroyCallback:this.wraplet.destroy},async()=>{if(this.status.isInitialized)throw new Error("Exhibition is already initialized");for(const t of this.children.editors)t.wraplet.status.isInitialized||t.wraplet.status.isGettingInitialized||await t.wraplet.initialize(),this.children.preview.hasDocumentAlterer(t.getDocumentAlterer())||this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority());const t=this.node.querySelectorAll(await this.options.get("updaterSelector"));for(const e of t)this.core.addEventListener(e,"click",()=>{this.updatePreview()})})()}addEditor(t){this.children.editors.add(t),this.children.preview.addDocumentAlterer(t.getDocumentAlterer())}removeEditor(t){this.children.editors.delete(t),this.children.preview.removeDocumentAlterer(t.getDocumentAlterer())}hasEditor(t){return this.children.editors.has(t)}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}static async createMultiple(t,e,i={},s={},r=F){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const n=this.createWraplets(t,e,r,[i]);for(const t of n)await this.applyCreateOptions(t,s);return n}static async create(t,e,i={},s={}){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const r=new M(t,e),n=new U(r,i);return await this.applyCreateOptions(n,s),n}static fillCreateOptionsWithDefaults(t){return{init:!0,updatePreview:!1,...t}}static validateInitOptions(t,e){if(t.init&&void 0===e.editors.selector)throw new Error("Cannot initialize exhibition with undefined editors.selector");if(!t.init&&t.updatePreview)throw new Error("Cannot update preview without initializing exhibitions first")}static async applyCreateOptions(t,e={}){if(!e.init&&e.updatePreview)throw new Error("'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.");e.init&&await t.initialize(),e.updatePreview&&await t.updatePreview()}static getMap(t){const e=H,i={selectEditors:!0,Class:void 0,editorsOptions:{},previewOptions:{},...t};if(i.Class&&(e.editors.Class=i.Class),e.editors.Class instanceof q&&i.editorsOptions&&!i.editorsOptions.monaco)throw new Error("When using ExhibitionMonacoEditor as editors class, you must provide the 'monaco' option in the editors options.");return i.selectEditors||(e.editors.selector=void 0),i.previewOptions&&e.preview.args.push(i.previewOptions),i.editorsOptions&&e.editors.args.push(i.editorsOptions),e}}export{U as Exhibition,q as ExhibitionMonacoEditor,P as ExhibitionPreview,F as exhibitionDefaultAttribute};
1
+ class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}function l(t){return Object.getPrototypeOf(t)===Object.prototype}const h=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],d=Symbol("WrapletSet");function c(t){return h(t,d)}class u extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const p=Symbol("WrapletSetReadonly");class w extends u{[p]=!0;[d]=!0}const f=Symbol("Core"),g=Symbol("NodeTreeParent");function y(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function m(t){const e={};for(const i in t){const s=t[i];e[i]=y(s);const r=s.map;r&&l(r)&&(e[i].map=m(r))}return e}const b=Symbol("DynamicMap");function v(t){return h(t,b)}class C{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=m(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const s=e[i].map;if(l(s))e=s;else{if(!v(s))throw new Error("Invalid map type.");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(v(t))return!0;if(!l(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new C(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const E=Symbol("ArgCreator");function O(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class M{node;[f]=!0;[g]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=O;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(l(i))this.mapWrapper=new C(i);else{if(!(i instanceof C))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?c(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(c(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!c(i))throw new a("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new a("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const n=t.selector,a=this.findChildren(n,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new r(`${this.constructor.name}: More than one element was found for the "${s}" child. Selector used: "${n}".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>h(t,E)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof o&&!e.required)return console.warn(`${i.message} Skipping instantiation of the "${t}" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new n("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(c(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new a("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new a("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet "${e}". Selector used: "${s.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(c(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}const I=Symbol("Wraplet"),D=Symbol("Groupable");function A(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const i=t.status||this.status;await async function(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}(i,t.core)&&(e&&await e(),await async function(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}(i,t.destroyCallback))}}function S(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const i=t.status||this.status;await async function(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await async function(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}(i))}}class z{core;[I]=!0;[D]=!0;[g]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!h(t,f))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new o(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=(t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign((t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||S({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||A({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})})(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})})({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new M(t,e)}static createWraplets(t,e,i,s=[]){if(this===z)throw new Error("You cannot instantiate an abstract class.");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}function W(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}const L=Symbol("KeyValueStorage");class x extends Error{}class T{storage;defaults;validators;[L]=!0;constructor(t,e,i){this.storage=t,this.defaults=e,this.validators=i}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const i of t)void 0===e[i]&&(e[i]=this.defaults[i]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new x(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new x(`Attempted to set an invalid value for the key ${String(t)}.`)}}class G{isPartial;defaults;validators;[L]=!0;data=null;options;constructor(t,e,i,s={}){this.isPartial=t,this.defaults=e,this.validators=i,this.validateValidators(i),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new x(`Attempted to set an invalid value for the key ${String(t)}.`);const i=await this.getValue(),s=JSON.parse(i);s[t]=e,await this.setAll(s)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const i of t)delete e[i];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if("{"!==t.charAt(0))throw new x("Data has to be defined as an object.");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new x(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new x(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if("function"!=typeof t[e])throw new x(`Validator for ${e} is not a function.`)}}class j extends G{element;attribute;defaults;validators;constructor(t,e,i,s,r,n={}){super(t,s,r,n),this.element=e,this.attribute=i,this.defaults=s,this.validators=r}async getValue(){return this.element.getAttribute(this.attribute)||"{}"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class P extends z{alterers=[];currentBlobUrl=null;options;constructor(t,e={},i){super(t);const s={updateHeight:!0,updateHeightCallback:async t=>{setTimeout(()=>{t.updateHeight()},100)}},r=i||new j(!0,t.node,"data-js-options",{},{});this.options=new T(r,{...s,...e},{updateHeight:t=>"boolean"==typeof t,updateHeightCallback:t=>"function"==typeof t})}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLIFrameElement])}addDocumentAlterer(t,e=0){this.hasDocumentAlterer(t)||this.alterers.push({callback:t,priority:e})}hasDocumentAlterer(t){return this.alterers.some(e=>e.callback===t)}removeDocumentAlterer(t){this.alterers=this.alterers.filter(e=>e.callback!==t)}async update(){const t=document.implementation.createHTMLDocument();this.alterers.sort((t,e)=>e.priority-t.priority);for(const e of this.alterers)await e.callback(t);this.currentBlobUrl&&URL.revokeObjectURL(this.currentBlobUrl);const e="<!DOCTYPE html>\n"+t.documentElement.outerHTML,i=new Blob([e],{type:"text/html;charset=utf-8"});this.currentBlobUrl=URL.createObjectURL(i),this.node.src=this.currentBlobUrl,this.node.onload=async()=>{await this.options.get("updateHeight")||await(await this.options.get("updateHeightCallback"))(this),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),s=parseFloat(i.marginTop)+parseFloat(i.marginBottom),r=Math.ceil(e.offsetHeight+s);this.node.height=r+"px"}getIFrameDocument(){const t=this.node.contentDocument;if(!t)throw new Error("IFrame document is not available.");return t}getIFrameWindow(){const t=this.node.contentWindow;if(!t)throw new Error("IFrame window is not available.");return t}}const k={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function N(t){for(const[e,i]of Object.entries(k))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function V(t){return k[t].tag}function $(t){return Boolean(V(t))}class q extends z{monaco=null;editor=null;options;status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};priority=0;monacoEditorOptions=null;constructor(t,e,i){super(t),this.alterDocument=this.alterDocument.bind(this);const s={location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={location:t=>"string"==typeof t&&["head","body"].includes(t),priority:t=>Number.isInteger(t),tagAttributes:t=>"object"==typeof t,trimDefaultValue:t=>"boolean"==typeof t,monacoEditorCreator:t=>"function"==typeof t,monaco:t=>"object"==typeof t,monacoEditorOptions:()=>!0};e.monacoEditorOptions={...s.monacoEditorOptions,...e.monacoEditorOptions};const n=i||new j(!0,t.node,"data-js-options",{},{},{elementOptionsMerger:(t,i)=>(i.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions,...i.monacoEditorOptions},{...t,...e,...i})});this.options=new T(n,{...s,...e},r),this.wraplet=W({status:this.status,initialize:this.initialize.bind(this),destroy:this.destroy.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return A({core:this.core,destroyCallback:this.destroy,status:this.status},async()=>{if(this.status.isInitialized)throw new Error("ExhibitionMonacoEditor is already initialized");if(this.priority=await this.options.get("priority"),this.monacoEditorOptions=await this.options.get("monacoEditorOptions"),await this.options.get("trimDefaultValue")){const t=await this.options.get("monacoEditorOptions");t.value&&(t.value=q.trimDefaultValue(t.value),await this.options.set("monacoEditorOptions",t))}await this.validateOptions(),this.monaco=await this.getMonacoInstance();const t=await this.options.get("monacoEditorCreator")||(async(t,e,i)=>q.createMonacoEditor(t,e,i));this.editor=await t(await this.options.get("monacoEditorOptions"),this.node,this.monaco)})()}getPriority(){return this.priority}async getMonacoInstance(){const t=await this.options.get("monaco");if(!t)throw new Error("Monaco instance is not available");return t}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.monaco;if(!e)throw new Error("Monaco instance is not available. Is wraplet initialized?");const i=this.getLanguage(),s="typescript"===i?await this.getTSValueAsJS(e):this.getValue(),r=await this.options.get("location"),n=N(i);if($(n)){const e=V(n),i=await this.options.get("tagAttributes")??{},a=t.createElement(e);for(const[t,e]of Object.entries(i))a.setAttribute(t,e);return a.innerHTML=s,void t[r].appendChild(a)}t[r].innerHTML+=s}getDocumentAlterer(){return this.alterDocument}async validateOptions(){if(!(await this.options.get("monacoEditorOptions")).language)throw new Error("Missing language in monacoOptions");if(!$(N(this.getLanguage()))&&await this.options.get("tagAttributes"))throw new Error("'tagAttributes' option is only allowed for single tag types")}getEditor(){if(!this.editor)throw new Error("Editor is not initialized");return this.editor}async getTSValueAsJS(t){const e=this.getEditor().getModel();if(!e)throw new Error("Model is not available");t.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const i=e.uri;if("file"!==i.scheme)throw new Error(`Model must use file:// URI, got: ${i.toString()}`);const s=async(e=10)=>{try{return await t.languages.typescript.getTypeScriptWorker()}catch(t){if("TypeScript not registered!"!==t)throw t;return e<=0?null:(await new Promise(t=>setTimeout(t,200)),s(e-1))}},r=await s();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(i);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(i.toString());break}catch(t){if(/Could not find source file/.test(String(t))){await new Promise(t=>setTimeout(t,250));continue}throw t}const{outputFiles:a}=await n.getEmitOutput(i.toString());if(!a.length)throw new Error("No JS output produced");return a[0].text}getLanguage(){const t=this.monacoEditorOptions;if(!t)throw new Error("Monaco options are not available. Is wraplet initialized?");if(!t.language)throw new Error("Missing language in monacoOptions");return t.language}static trimDefaultValue(t){const e=t.split("\n"),i=e.find(t=>t.trim().length>0);if(!i)return t.trim();const s=i.search(/\S|$/);return e.map(t=>t.length>=s&&""===t.substring(0,s).trim()?t.substring(s):t).join("\n").trim()}async destroy(){return S({core:this.core,wraplet:this,destroyListeners:this.destroyListeners,status:this.status},async()=>{this.editor?.dispose()})()}static createMonacoEditor(t={},e,i){const s=t.language;if(!s)throw new Error("Missing language in editorOptions");const r=this.createMonacoModel(i,s,t.value||"");return i.editor.create(e,{...t,model:r})}static createMonacoModel(t,e,i){const s=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${s}.ts`))}static create(t,e){const i=new M(t,{});return new q(i,e)}}const F="data-js-exhibition",H={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:q,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:P,args:[]}};class U extends z{status={isInitialized:!1,isDestroyed:!1,isGettingInitialized:!1,isGettingDestroyed:!1};options;constructor(t,e={},i){super(t);const s=i??new j(!0,this.node,"data-js-options",{},{updaterSelector:t=>"string"==typeof t});this.options=new T(s,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t}),this.wraplet=W({status:this.status,initialize:this.initialize.bind(this)},this.wraplet)}supportedNodeTypes(){return super.supportedNodeTypesGuard([HTMLElement])}async initialize(){return A({core:this.core,status:this.status,destroyCallback:this.wraplet.destroy},async()=>{if(this.status.isInitialized)throw new Error("Exhibition is already initialized");for(const t of this.children.editors)t.wraplet.status.isInitialized||t.wraplet.status.isGettingInitialized||await t.wraplet.initialize(),this.children.preview.hasDocumentAlterer(t.getDocumentAlterer())||this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority());const t=this.node.querySelectorAll(await this.options.get("updaterSelector"));for(const e of t)this.core.addEventListener(e,"click",()=>{this.updatePreview()})})()}addEditor(t){this.children.editors.add(t),this.children.preview.addDocumentAlterer(t.getDocumentAlterer())}removeEditor(t){this.children.editors.delete(t),this.children.preview.removeDocumentAlterer(t.getDocumentAlterer())}hasEditor(t){return this.children.editors.has(t)}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}static async createMultiple(t,e,i={},s={},r=F){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const n=this.createWraplets(t,e,r,[i]);for(const t of n)await this.applyCreateOptions(t,s);return n}static async create(t,e,i={},s={}){s=this.fillCreateOptionsWithDefaults(s),this.validateInitOptions(s,e);const r=new M(t,e),n=new U(r,i);return await this.applyCreateOptions(n,s),n}static fillCreateOptionsWithDefaults(t){return{init:!0,updatePreview:!1,...t}}static validateInitOptions(t,e){if(t.init&&void 0===e.editors.selector)throw new Error("Cannot initialize exhibition with undefined editors.selector");if(!t.init&&t.updatePreview)throw new Error("Cannot update preview without initializing exhibitions first")}static async applyCreateOptions(t,e={}){if(!e.init&&e.updatePreview)throw new Error("'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.");e.init&&await t.initialize(),e.updatePreview&&await t.updatePreview()}static getMap(t){const e=H,i={selectEditors:!0,Class:void 0,editorsOptions:{},previewOptions:{},...t};if(i.Class&&(e.editors.Class=i.Class),i.selectEditors&&e.editors.Class instanceof q&&(!i.editorsOptions||!i.editorsOptions.monaco))throw new Error("When selecting ExhibitionMonacoEditor instances, you must provide the 'monaco' option in the editors options. To avoid this error, disable 'selectEditors' or provide the 'monaco' option.");return i.selectEditors||(e.editors.selector=void 0),i.previewOptions&&e.preview.args.push(i.previewOptions),i.editorsOptions&&e.editors.args.push(i.editorsOptions),e}}export{U as Exhibition,q as ExhibitionMonacoEditor,P as ExhibitionPreview,F as exhibitionDefaultAttribute};
2
2
  //# sourceMappingURL=index.js.map
package/dist/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,KAAEb,KAAK4U,EAAWE,gBAGlCjU,CACT,S","sources":["webpack://exhibitionjs/./node_modules/wraplet/dist/index.js","webpack://exhibitionjs/./node_modules/wraplet/dist/storage.js","webpack://exhibitionjs/./src/ExhibitionPreview.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/selectors.ts","webpack://exhibitionjs/./src/Exhibition.ts"],"sourcesContent":["class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}function h(t){return Object.getPrototypeOf(t)===Object.prototype}const d=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],c=Symbol(\"WrapletSet\");function u(t){return d(t,c)}class p extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const f=Symbol(\"WrapletSetReadonly\");class w extends p{[f]=!0;[c]=!0}function y(t){const e=t.wraplets;return u(e)&&0!==e.size?e:new w}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function g(t,e){await e(t);const i=t.childNodes;for(const t of i)await g(t,e)}async function m(t){await g(t,async t=>{const e=y(t);for(const i of e)i.wraplet.status.isGettingDestroyed||i.wraplet.status.isDestroyed||await i.wraplet.destroy(),C(i,t)})}const b=Symbol(\"Core\"),v=Symbol(\"NodeTreeParent\");function I(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function W(t){const e={};for(const i in t){const s=t[i];e[i]=I(s);const r=s.map;r&&h(r)&&(e[i].map=W(r))}return e}const E=Symbol(\"DynamicMap\");function D(t){return d(t,E)}class z{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=W(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);const s=e[i].map;if(h(s))e=s;else{if(!D(s))throw new Error(\"Invalid map type.\");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error(\"Map doesn't exist.\");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(D(t))return!0;if(!h(t))throw new Error(\"Invalid map type.\");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error(\"At the root already.\");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new z(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol(\"ArgCreator\");function L(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class G{node;[b]=!0;[v]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=L;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error(\"The node provided to the Core is not a valid node.\");if(h(i))this.mapWrapper=new z(i);else{if(!(i instanceof z))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?u(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!u(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new o(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,a=this.findChildren(r,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${s}\" child. Selector used: \"${r}\".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>d(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof l&&!e.required)return console.warn(`${i.message} Skipping instantiation of the \"${t}\" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new a(\"Children are already destroyed.\");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}removeChild(t,e){if(u(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i(\"Required child has been destroyed.\");if(null===this.instantiatedChildren[e])throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency \"${t}\" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${s.selector}\".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class x{creator;[M]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new x(t)}}const S=Symbol(\"Wraplet\");function O(t){return d(t,S)}const A=Symbol(\"Groupable\");async function N(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function j(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function P(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot initialize without status available.\");const i=t.status||this.status;await N(i,t.core)&&(e&&await e(),await $(i,t.destroyCallback))}}function T(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot destroy without status available.\");const i=t.status||this.status;await j(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(i))}}const k=t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||T({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||P({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]});return Object.assign(k(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class R{core;[S]=!0;[A]=!0;[v]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!d(t,b))throw new Error(\"AbstractWraplet requires a Core instance.\");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new l(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new G(t,e)}static createWraplets(t,e,i,s=[]){if(this===R)throw new Error(\"You cannot instantiate an abstract class.\");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}class Y{levels;[E]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error(\"There have to be more than 0 repeated levels.\")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new Y(t)}}class _ extends p{[f]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");return Object.assign(e,t)}export{R as AbstractWraplet,a as ChildrenAreAlreadyDestroyedError,s as ChildrenAreNotAvailableError,n as ChildrenTooManyFoundError,x as DefaultArgCreator,G as DefaultCore,w as DefaultWrapletSet,_ as DefaultWrapletSetReadonly,o as InternalLogicError,e as MapError,Y as MapRepeat,t as MissingRequiredChildError,i as RequiredChildDestroyedError,r as StorageValidationError,l as UnsupportedNodeTypeError,S as WrapletSymbol,T as createDefaultDestroyCallback,P as createDefaultInitializeCallback,F as createRichWrapletApi,k as createWrapletApi,B as customizeDefaultWrapletApi,L as defaultWrapletCreator,m as destroyWrapletsRecursively,q as destructionCompleted,j as destructionStarted,y as getWrapletsFromNode,$ as initializationCompleted,N as initializationStarted,O as isWraplet};\n//# sourceMappingURL=index.js.map","const t=Symbol(\"KeyValueStorage\");function e(e){return(e=>\"object\"==typeof e&&null!==e&&!0===e[t])(e)}class a extends Error{}class s{storage;defaults;validators;[t]=!0;constructor(t,e,a){this.storage=t,this.defaults=e,this.validators=a}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const a of t)void 0===e[a]&&(e[a]=this.defaults[a]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new a(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`)}}class i{isPartial;defaults;validators;[t]=!0;data=null;options;constructor(t,e,a,s={}){this.isPartial=t,this.defaults=e,this.validators=a,this.validateValidators(a),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,a)=>(t[a]=e[a],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`);const s=await this.getValue(),i=JSON.parse(s);i[t]=e,await this.setAll(i)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const a of t)delete e[a];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if(\"{\"!==t.charAt(0))throw new a(\"Data has to be defined as an object.\");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new a(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new a(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if(\"function\"!=typeof t[e])throw new a(`Validator for ${e} is not a function.`)}}class l extends i{element;attribute;defaults;validators;constructor(t,e,a,s,i,l={}){super(t,s,i,l),this.element=e,this.attribute=a,this.defaults=s,this.validators=i}async getValue(){return this.element.getAttribute(this.attribute)||\"{}\"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class r extends i{element;defaults;validators;constructor(t,e,a,s,i={}){super(t,a,s,i),this.element=e,this.defaults=a,this.validators=s}async getValue(){return this.element.textContent||\"{}\"}async setValue(t){this.element.textContent=JSON.stringify(t)}async deleteAllValues(){this.element.textContent=\"{}\"}}export{i as AbstractNongranularKeyValueStorage,l as ElementAttributeStorage,r as ElementStorage,t as KeyValueStorageSymbol,s as StorageWrapper,e as isKeyValueStorage};\n//# sourceMappingURL=storage.js.map","import { AbstractWraplet, Constructable, Core } from \"wraplet\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\ntype AltererData = {\n callback: DocumentAlterer;\n priority: number;\n};\n\nexport type ExhibitionPreviewOptions = {\n updateHeight?: boolean;\n updateHeightCallback?: (preview: ExhibitionPreview) => Promise<void>;\n};\n\nexport class ExhibitionPreview\n extends AbstractWraplet<HTMLIFrameElement>\n implements PreviewWraplet\n{\n private alterers: AltererData[] = [];\n private currentBlobUrl: string | null = null;\n\n private options: KeyValueStorage<Required<ExhibitionPreviewOptions>>;\n\n constructor(\n core: Core<HTMLIFrameElement>,\n options: ExhibitionPreviewOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionPreviewOptions>>,\n ) {\n super(core);\n\n const validators: StorageValidators<ExhibitionPreviewOptions> = {\n updateHeight: (data: unknown) => typeof data === \"boolean\",\n updateHeightCallback: (data: unknown) => typeof data === \"function\",\n };\n\n const defaultOptions: Required<ExhibitionPreviewOptions> = {\n updateHeight: true,\n updateHeightCallback: async (preview) => {\n setTimeout(() => {\n preview.updateHeight();\n }, 100);\n },\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionPreviewOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionPreviewOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n );\n\n this.options = new StorageWrapper<Required<ExhibitionPreviewOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLIFrameElement>[] {\n return super.supportedNodeTypesGuard([HTMLIFrameElement]);\n }\n\n /**\n * Adds a DocumentAlterer to the preview.\n * @param alterer\n * @param priority\n * Priority of the alterer. Higher priority alterers are executed first.\n */\n public addDocumentAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n if (this.hasDocumentAlterer(alterer)) {\n return;\n }\n\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n\n /**\n * Checks if alterer is already registered.\n * @param alterer\n */\n public hasDocumentAlterer(alterer: DocumentAlterer): boolean {\n return this.alterers.some(\n (altererData) => altererData.callback === alterer,\n );\n }\n\n public removeDocumentAlterer(alterer: DocumentAlterer): void {\n this.alterers = this.alterers.filter(\n (altererData) => altererData.callback !== alterer,\n );\n }\n\n public async update(): Promise<void> {\n const doc = document.implementation.createHTMLDocument();\n this.alterers.sort((a, b) => b.priority - a.priority);\n for (const alterer of this.alterers) {\n await alterer.callback(doc);\n }\n\n // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\n }\n\n const htmlContent = \"<!DOCTYPE html>\\n\" + doc.documentElement.outerHTML;\n const blob = new Blob([htmlContent], { type: \"text/html;charset=utf-8\" });\n this.currentBlobUrl = URL.createObjectURL(blob);\n this.node.src = this.currentBlobUrl;\n\n this.node.onload = async () => {\n if (!(await this.options.get(\"updateHeight\"))) {\n await (\n await this.options.get(\"updateHeightCallback\")\n )(this);\n }\n this.node.onload = null;\n };\n }\n\n /**\n * Updates preview's height to match its content.\n */\n public updateHeight(): void {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n\n const styles = iframeWindow.getComputedStyle(el);\n const margin =\n parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n\n private getIFrameDocument(): Document {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n\n return iframeDocument;\n }\n\n private getIFrameWindow(): Window {\n const window = this.node.contentWindow;\n if (!window) {\n throw new Error(\"IFrame window is not available.\");\n }\n return window;\n }\n}\n","import { IsSingleTag, PreviewValue } from \"./types/PreviewValue\";\n\nexport const typeMap = {\n html: {\n languages: [\"html\"],\n tag: undefined,\n },\n js: {\n languages: [\"javascript\", \"typescript\"],\n tag: \"script\",\n },\n css: {\n languages: [\"css\"],\n tag: \"style\",\n },\n} as const;\n\nexport type TypeFromLanguage<L extends MonacoEditorLanguages> = {\n [K in ValueTypes]: L extends (typeof typeMap)[K][\"languages\"][number]\n ? K\n : never;\n}[ValueTypes];\n\nexport type ValueTypes = keyof typeof typeMap;\n\nexport type MonacoEditorLanguages =\n (typeof typeMap)[ValueTypes][\"languages\"][number];\n\nexport function getTypeFromLanguage<T extends MonacoEditorLanguages>(\n language: T,\n): TypeFromLanguage<T> {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language as never)) {\n return key as TypeFromLanguage<T>;\n }\n }\n\n throw new Error(\"Unknown language\");\n}\n\nexport function getTagFromType<T extends ValueTypes>(\n type: T,\n): (typeof typeMap)[T][\"tag\"] {\n return typeMap[type].tag;\n}\n\nexport function isSingleTagType(\n type: ValueTypes,\n): type is Extract<PreviewValue, IsSingleTag>[\"type\"] {\n return Boolean(getTagFromType(type));\n}\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultDestroyCallback,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n} from \"wraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\n\nimport type * as monaco from \"monaco-editor\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n getTagFromType,\n getTypeFromLanguage,\n isSingleTagType,\n MonacoEditorLanguages,\n} from \"./TypeMap\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\n\nexport type EditorCreator = (\n options: monaco.editor.IStandaloneEditorConstructionOptions,\n node: HTMLElement,\n monaco: MonacoInstance,\n) => Promise<monaco.editor.IStandaloneCodeEditor>;\n\nexport type ExhibitionMonacoEditorOptions = {\n /**\n * Monaco instance.\n */\n monaco: MonacoInstance;\n /**\n * Instead of depending on this class for editor instantiation, you can provide your own editor instance here.\n */\n monacoEditorCreator?: EditorCreator;\n\n /**\n * Monaco options for the editor.\n */\n monacoEditorOptions?: monaco.editor.IStandaloneEditorConstructionOptions;\n\n /**\n * Location where the editor should be inserted.\n */\n location?: \"head\" | \"body\";\n\n /**\n * Priority of the editor's document alterer. Higher priority means it will be executed first.\n */\n priority?: number;\n\n /**\n * Trim the default value of the editor.\n */\n trimDefaultValue?: boolean;\n\n /**\n * This option applies to single tag languages only (typescript, javascript and css). It\n * determines the attributes that will be added to the generated tag.\n */\n tagAttributes?: Record<string, string>;\n};\n\ntype RequiredMonacoEditorOptions = Required<\n Omit<ExhibitionMonacoEditorOptions, \"tagAttributes\" | \"monacoEditorCreator\">\n> & {\n tagAttributes?: ExhibitionMonacoEditorOptions[\"tagAttributes\"];\n monacoEditorCreator?: EditorCreator;\n};\n\nexport type MonacoInstance = typeof monaco;\n\nexport class ExhibitionMonacoEditor\n extends AbstractWraplet<HTMLElement>\n implements DocumentAltererProviderWraplet\n{\n private monaco: MonacoInstance | null = null;\n private editor: monaco.editor.IStandaloneCodeEditor | null = null;\n private options: KeyValueStorage<RequiredMonacoEditorOptions>;\n\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private priority: number = 0;\n private monacoEditorOptions:\n | RequiredMonacoEditorOptions[\"monacoEditorOptions\"]\n | null = null;\n\n constructor(\n core: Core<HTMLElement>,\n options: ExhibitionMonacoEditorOptions,\n optionsStorage?: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>>,\n ) {\n super(core);\n\n this.alterDocument = this.alterDocument.bind(this);\n\n const defaultOptions: Omit<\n RequiredMonacoEditorOptions,\n \"monacoEditorCreator\" | \"monaco\"\n > = {\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n\n const validators: StorageValidators<ExhibitionMonacoEditorOptions> = {\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data: unknown) =>\n typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data: unknown) => Number.isInteger(data),\n tagAttributes: (data: unknown) => typeof data === \"object\",\n trimDefaultValue: (data: unknown) => typeof data === \"boolean\",\n monacoEditorCreator: (data: unknown) => typeof data === \"function\",\n monaco: (data: unknown) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionMonacoEditorOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n {\n elementOptionsMerger: (defaults, attributeOptions) => {\n attributeOptions.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n ...attributeOptions.monacoEditorOptions,\n };\n return { ...defaults, ...options, ...attributeOptions };\n },\n },\n );\n\n this.options = new StorageWrapper<RequiredMonacoEditorOptions>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n destroy: this.destroy.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n destroyCallback: this.destroy,\n status: this.status,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"ExhibitionMonacoEditor is already initialized\");\n }\n this.priority = await this.options.get(\"priority\");\n this.monacoEditorOptions = await this.options.get(\n \"monacoEditorOptions\",\n );\n\n if (await this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = await this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(\n monacoOptions.value,\n );\n await this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n\n await this.validateOptions();\n\n this.monaco = await this.getMonacoInstance();\n\n const editorCreator: EditorCreator =\n (await this.options.get(\"monacoEditorCreator\")) ||\n (async (options, element, monaco) =>\n ExhibitionMonacoEditor.createMonacoEditor(\n options,\n element,\n monaco,\n ));\n\n this.editor = await editorCreator(\n await this.options.get(\"monacoEditorOptions\"),\n this.node,\n this.monaco,\n );\n },\n )();\n }\n\n public getPriority(): number {\n return this.priority;\n }\n\n private async getMonacoInstance(): Promise<MonacoInstance> {\n const monaco = await this.options.get(\"monaco\");\n if (!monaco) throw new Error(\"Monaco instance is not available\");\n return monaco;\n }\n\n /**\n * Returns the current value of the editor.\n */\n private getValue(): string {\n return this.getEditor().getValue();\n }\n\n private async alterDocument(document: Document): Promise<void> {\n const monaco = this.monaco;\n if (!monaco) {\n throw new Error(\n \"Monaco instance is not available. Is wraplet initialized?\",\n );\n }\n\n const language = this.getLanguage();\n const content =\n language === \"typescript\"\n ? await this.getTSValueAsJS(monaco)\n : this.getValue();\n\n const location = await this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = (await this.options.get(\"tagAttributes\")) ?? {};\n const tagElement = document.createElement(tag);\n for (const [key, value] of Object.entries(tagAttributes)) {\n tagElement.setAttribute(key, value);\n }\n tagElement.innerHTML = content;\n document[location].appendChild(tagElement);\n return;\n }\n document[location].innerHTML += content;\n }\n\n public getDocumentAlterer(): DocumentAlterer {\n return this.alterDocument;\n }\n\n /**\n * Additional validation.\n */\n private async validateOptions() {\n if (!(await this.options.get(\"monacoEditorOptions\")).language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (await this.options.get(\"tagAttributes\")) {\n throw new Error(\n \"'tagAttributes' option is only allowed for single tag types\",\n );\n }\n }\n }\n\n private getEditor(): monaco.editor.IStandaloneCodeEditor {\n if (!this.editor) throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n\n private async getTSValueAsJS(monaco: MonacoInstance) {\n const model = this.getEditor().getModel();\n if (!model) throw new Error(\"Model is not available\");\n\n // Make sure TypeScript eager sync is enabled\n monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\n\n // Ensure we're using file:/// URI\n const uri = model.uri;\n if (uri.scheme !== \"file\") {\n throw new Error(`Model must use file:// URI, got: ${uri.toString()}`);\n }\n\n // Get worker getter\n const getWorker = async (\n attempts: number = 10,\n ): Promise<\n | ((\n ...uris: monaco.Uri[]\n ) => Promise<monaco.languages.typescript.TypeScriptWorker>)\n | null\n > => {\n try {\n return await monaco.languages.typescript.getTypeScriptWorker();\n } catch (error) {\n if (error !== \"TypeScript not registered!\") throw error;\n if (attempts <= 0) return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n\n const worker = await workerGetter(uri);\n\n // 🔸 Wait until the worker actually knows this file\n // Call something lightweight to force registration\n for (let i = 0; i < 20; i++) {\n try {\n await worker.getSemanticDiagnostics(uri.toString());\n break; // success — worker now recognizes the file\n } catch (err) {\n if (/Could not find source file/.test(String(err))) {\n await new Promise((r) => setTimeout(r, 250));\n continue;\n }\n throw err;\n }\n }\n\n // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length) throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n\n private getLanguage(): MonacoEditorLanguages {\n const monacoOptions = this.monacoEditorOptions;\n if (!monacoOptions) {\n throw new Error(\n \"Monaco options are not available. Is wraplet initialized?\",\n );\n }\n\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n return monacoOptions[\"language\"] as MonacoEditorLanguages;\n }\n\n public static trimDefaultValue(content: string): string {\n const lines = content.split(\"\\n\");\n\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\n\n // Trim the same number of spaces from each line\n const trimmedLines = lines.map((line) => {\n // Only trim if the line has at least that many leading spaces\n if (\n line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\"\n ) {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n\n public async destroy() {\n return createDefaultDestroyCallback(\n {\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n status: this.status,\n },\n async () => {\n this.editor?.dispose();\n },\n )();\n }\n\n /**\n * Helper method creating a new monaco editor instance.\n */\n public static createMonacoEditor(\n editorOptions: monaco.editor.IStandaloneEditorConstructionOptions = {},\n node: HTMLElement,\n monaco: MonacoInstance,\n ): monaco.editor.IStandaloneCodeEditor {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n\n const model = this.createMonacoModel(\n monaco,\n language,\n editorOptions.value || \"\",\n );\n\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n\n /**\n * Helper method creating a new monaco model instance.\n */\n public static createMonacoModel(\n monaco: MonacoInstance,\n language: string,\n value: string,\n ): monaco.editor.ITextModel {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(\n value,\n language,\n monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`),\n );\n }\n\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n public static create(\n element: HTMLElement,\n options: ExhibitionMonacoEditorOptions,\n ): ExhibitionMonacoEditor {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n WrapletChildrenMap,\n} from \"wraplet\";\nimport {\n ExhibitionPreview,\n ExhibitionPreviewOptions,\n} from \"./ExhibitionPreview\";\nimport {\n ExhibitionMonacoEditor,\n ExhibitionMonacoEditorOptions,\n} from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\nexport type ExhibitionOptions = {\n /**\n * Selector for the element that triggers the update of the preview.\n */\n updaterSelector?: string;\n};\n\nexport type ExhibitionInitOptions = {\n init?: boolean;\n updatePreview?: boolean;\n};\n\nexport type PreviewOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n previewOptions: O;\n }\n : { previewOptions?: O };\n\nexport type EditorsOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n editorsOptions: O;\n }\n : { editorsOptions?: O };\n\nexport type ExhibitionMapOptions<\n EO extends EditorsOptionsWrapper<unknown, boolean> | undefined =\n EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>,\n PO extends PreviewOptionsWrapper<unknown, boolean> | undefined =\n PreviewOptionsWrapper<ExhibitionPreviewOptions>,\n> = {\n Class?: Constructable<DocumentAltererProviderWraplet>;\n selectEditors?: boolean;\n} & (EO extends undefined\n ? EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>\n : EO) &\n (PO extends undefined ? PreviewOptionsWrapper<ExhibitionPreviewOptions> : PO);\n\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\" as string | undefined,\n multiple: true,\n required: false,\n Class:\n ExhibitionMonacoEditor as Constructable<DocumentAltererProviderWraplet>,\n args: [] as unknown[],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview as Constructable<PreviewWraplet>,\n args: [] as unknown[],\n },\n} satisfies WrapletChildrenMap;\n\nexport class Exhibition extends AbstractWraplet<\n HTMLElement,\n typeof ExhibitionMap\n> {\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private options: KeyValueStorage<Required<ExhibitionOptions>>;\n constructor(\n core: Core<HTMLElement, typeof ExhibitionMap>,\n options: ExhibitionOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionOptions>>,\n ) {\n super(core);\n const defaultOptions: Required<ExhibitionOptions> = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n const optsStorage =\n optionsStorage ??\n new ElementAttributeStorage<Partial<ExhibitionOptions>, true>(\n true,\n this.node,\n \"data-js-options\",\n {},\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n this.options = new StorageWrapper<Required<ExhibitionOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n status: this.status,\n destroyCallback: this.wraplet.destroy,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"Exhibition is already initialized\");\n }\n\n for (const editor of this.children.editors) {\n if (\n !editor.wraplet.status.isInitialized &&\n !editor.wraplet.status.isGettingInitialized\n ) {\n await editor.wraplet.initialize();\n }\n\n if (\n !this.children.preview.hasDocumentAlterer(\n editor.getDocumentAlterer(),\n )\n ) {\n this.addPreviewAlterer(\n editor.getDocumentAlterer(),\n editor.getPriority(),\n );\n }\n }\n\n const updaterElements = this.node.querySelectorAll(\n await this.options.get(\"updaterSelector\"),\n );\n\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n },\n )();\n }\n\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n public addEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.add(editor);\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Removes DocumentAltererProviderWraplet instance from the list of editors.\n */\n public removeEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.delete(editor);\n this.children.preview.removeDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Checks if the given editor is present in the list of editors.\n */\n public hasEditor(editor: DocumentAltererProviderWraplet): boolean {\n return this.children.editors.has(editor);\n }\n\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n private addPreviewAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n\n public getPreview(): PreviewWraplet {\n return this.children.preview;\n }\n\n public async updatePreview(): Promise<void> {\n await this.children.preview.update();\n }\n\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param initOptions Options related to the creation process of the Exhibitions.\n * @param attribute Attribute to use for Exhibition instances.\n *\n * @returns Array of Exhibition instances.\n */\n public static async createMultiple<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n node: ParentNode,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n attribute: string = exhibitionDefaultAttribute,\n ): Promise<Exhibition[]> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n\n const exhibitions = this.createWraplets<HTMLElement, Exhibition>(\n node,\n map,\n attribute,\n [options],\n );\n\n for (const exhibition of exhibitions) {\n await this.applyCreateOptions(exhibition, initOptions);\n }\n\n return exhibitions;\n }\n\n /**\n * Create a single Exhibition instance wrapping a given element.\n *\n * @param element Element to wrap.\n * @param map Map of dependencies for the Exhibition instance.\n * @param options Options for the Exhibition instance.\n * @param initOptions Options related to the creation process of the Exhibitions.\n */\n public static async create<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n element: HTMLElement,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n ): Promise<Exhibition> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n const core = new DefaultCore<HTMLElement, typeof ExhibitionMap>(\n element,\n map,\n );\n const exhibition = new Exhibition(core, options);\n await this.applyCreateOptions(exhibition, initOptions);\n return exhibition;\n }\n\n private static fillCreateOptionsWithDefaults(\n createOptions: ExhibitionInitOptions,\n ) {\n return {\n init: true,\n updatePreview: false,\n ...createOptions,\n };\n }\n\n /**\n * Validate create options.\n */\n private static validateInitOptions(\n initOptions: ExhibitionInitOptions,\n map: typeof ExhibitionMap,\n ) {\n if (initOptions.init && map.editors.selector === undefined) {\n throw new Error(\n \"Cannot initialize exhibition with undefined editors.selector\",\n );\n }\n\n if (!initOptions.init && initOptions.updatePreview) {\n throw new Error(\n \"Cannot update preview without initializing exhibitions first\",\n );\n }\n }\n\n /**\n * Create options.\n */\n private static async applyCreateOptions(\n exhibition: Exhibition,\n options: ExhibitionInitOptions = {},\n ): Promise<void> {\n if (!options.init && options.updatePreview) {\n throw new Error(\n \"'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.\",\n );\n }\n\n if (options.init) {\n await exhibition.initialize();\n }\n\n if (options.updatePreview) {\n await exhibition.updatePreview();\n }\n }\n\n /**\n * Returns a generic dependecy map with an undefined editor class that has to be provided through\n * the options.\n *\n * @param mapOptions\n * Map options.\n */\n public static getMap<\n O extends ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n > = ExhibitionMapOptions,\n >(mapOptions?: NoInfer<O>): typeof ExhibitionMap {\n const map: typeof ExhibitionMap = ExhibitionMap;\n const allOptions: Required<\n ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n >\n > = {\n ...{\n selectEditors: true,\n Class: undefined as any,\n editorsOptions: {},\n previewOptions: {},\n },\n ...mapOptions,\n };\n\n if (allOptions.Class) {\n map[\"editors\"][\"Class\"] = allOptions.Class;\n }\n\n if (\n map[\"editors\"][\"Class\"] instanceof ExhibitionMonacoEditor &&\n allOptions.editorsOptions &&\n !(allOptions.editorsOptions as { monaco?: unknown })[\"monaco\"]\n ) {\n throw new Error(\n \"When using ExhibitionMonacoEditor as editors class, you must provide the 'monaco' option in the editors options.\",\n );\n }\n\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n\n if (allOptions.previewOptions) {\n map[\"preview\"][\"args\"].push(allOptions.previewOptions);\n }\n\n if (allOptions.editorsOptions) {\n map[\"editors\"][\"args\"].push(allOptions.editorsOptions);\n }\n\n return map;\n }\n}\n"],"names":["t","Error","e","i","s","n","a","o","l","h","Object","getPrototypeOf","prototype","d","c","Symbol","u","p","Set","find","this","push","findOne","getOrdered","Array","from","sort","f","w","b","v","I","args","destructible","map","coreOptions","W","r","E","D","z","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","L","element","initOptions","Class","G","node","childrenAreInstantiated","statusWritable","isDestroyed","isGettingDestroyed","isInitialized","isGettingInitialized","status","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","values","flatMap","Promise","all","wraplet","initialize","destroy","instantiateChildren","querySelectorAll","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","createArg","required","console","warn","message","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","delete","Proxy","get","defaultInitOptions","assign","entries","S","A","P","async","N","core","$","destroyCallback","T","j","destroyListeners","q","R","supportedNodeTypes","onChildDestroy","bind","onChildInstantiate","groupExtractor","Element","getAttribute","split","initializeCallback","__nodeAccessors","k","setGroupsExtractor","getGroups","F","supportedNodeTypesGuard","isChildInstance","createCore","createWraplets","hasAttribute","B","storage","defaults","validators","has","validateGetValue","getMultiple","getAll","keys","set","validateSetValue","setMultiple","setAll","deleteMultiple","deleteAll","String","isPartial","data","validateValidators","keepFresh","elementOptionsMerger","reduce","refresh","getValue","JSON","parse","setValue","deleteAllValues","fetchFreshData","charAt","validateData","attribute","super","setAttribute","stringify","removeAttribute","ExhibitionPreview","alterers","currentBlobUrl","optionsStorage","defaultOptions","updateHeight","updateHeightCallback","preview","setTimeout","optsStorage","HTMLIFrameElement","addDocumentAlterer","alterer","priority","hasDocumentAlterer","some","altererData","removeDocumentAlterer","update","doc","document","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","type","createObjectURL","src","onload","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","Math","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","key","value","includes","getTagFromType","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","monacoEditorOptions","alterDocument","location","trimDefaultValue","Number","isInteger","tagAttributes","monacoEditorCreator","attributeOptions","HTMLElement","monacoOptions","validateOptions","getMonacoInstance","editorCreator","createMonacoEditor","getPriority","getEditor","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","attempts","getTypeScriptWorker","error","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","random","createModel","Uri","exhibitionDefaultAttribute","ExhibitionMap","editors","Exhibition","updaterSelector","addPreviewAlterer","updaterElements","updatePreview","addEditor","removeEditor","hasEditor","getPreview","createMultiple","fillCreateOptionsWithDefaults","validateInitOptions","exhibitions","exhibition","applyCreateOptions","createOptions","init","getMap","mapOptions","allOptions","selectEditors","editorsOptions","previewOptions"],"ignoreList":[],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":"AAAA,MAAMA,UAAUC,OAAO,MAAMC,UAAUD,OAAO,MAAME,UAAUF,OAAO,MAAMG,UAAUH,OAA8B,MAAMI,UAAUJ,OAAO,MAAMK,UAAUL,OAAO,MAAMM,UAAUN,OAAO,MAAMO,UAAUP,OAAO,SAASQ,EAAET,G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AAI,EACf9E,EACA5B,GAEIyT,EAAa,IAAIb,EAAWlM,EAAMf,GAExC,aADMzG,KAAKwU,mBAAmBD,EAAY5R,GACnC4R,CACT,CAEQ,oCAAOH,CACbK,GAEA,MAAO,CACLC,MAAM,EACNZ,eAAe,KACZW,EAEP,CAKQ,0BAAOJ,CACb1R,EACA7B,GAEA,GAAI6B,EAAY+R,WAAiC5F,IAAzBhO,EAAI2S,QAAQpO,SAClC,MAAM,IAAIxG,MACR,gEAIJ,IAAK8D,EAAY+R,MAAQ/R,EAAYmR,cACnC,MAAM,IAAIjV,MACR,+DAGN,CAKQ,+BAAa2V,CACnBD,EACA9N,EAAiC,CAAC,GAElC,IAAKA,EAAQiO,MAAQjO,EAAQqN,cAC3B,MAAM,IAAIjV,MACR,qHAIA4H,EAAQiO,YACJH,EAAWnQ,aAGfqC,EAAQqN,qBACJS,EAAWT,eAErB,CASO,aAAOa,CAKZC,GACA,MAAM9T,EAA4B0S,EAC5BqB,EAKF,CAEAC,eAAe,EACflS,WAAOkM,EACPiG,eAAgB,CAAC,EACjBC,eAAgB,CAAC,KAEhBJ,GAOL,GAJIC,EAAWjS,QACb9B,EAAa,QAAS,MAAI+T,EAAWjS,OAIrCiS,EAAWC,eACXhU,EAAa,QAAS,iBAAa2O,KACjCoF,EAAWE,iBACTF,EAAWE,eAAgD,QAE/D,MAAM,IAAIlW,MACR,8LAgBJ,OAZKgW,EAAWC,gBACdhU,EAAa,QAAY,cAAIgO,GAG3B+F,EAAWG,gBACblU,EAAa,QAAQ,KAAEb,KAAK4U,EAAWG,gBAGrCH,EAAWE,gBACbjU,EAAa,QAAQ,KAAEb,KAAK4U,EAAWE,gBAGlCjU,CACT,S","sources":["webpack://exhibitionjs/./node_modules/wraplet/dist/index.js","webpack://exhibitionjs/./node_modules/wraplet/dist/storage.js","webpack://exhibitionjs/./src/ExhibitionPreview.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/selectors.ts","webpack://exhibitionjs/./src/Exhibition.ts"],"sourcesContent":["class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}function h(t){return Object.getPrototypeOf(t)===Object.prototype}const d=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],c=Symbol(\"WrapletSet\");function u(t){return d(t,c)}class p extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const f=Symbol(\"WrapletSetReadonly\");class w extends p{[f]=!0;[c]=!0}function y(t){const e=t.wraplets;return u(e)&&0!==e.size?e:new w}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function g(t,e){await e(t);const i=t.childNodes;for(const t of i)await g(t,e)}async function m(t){await g(t,async t=>{const e=y(t);for(const i of e)i.wraplet.status.isGettingDestroyed||i.wraplet.status.isDestroyed||await i.wraplet.destroy(),C(i,t)})}const b=Symbol(\"Core\"),v=Symbol(\"NodeTreeParent\");function I(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function W(t){const e={};for(const i in t){const s=t[i];e[i]=I(s);const r=s.map;r&&h(r)&&(e[i].map=W(r))}return e}const E=Symbol(\"DynamicMap\");function D(t){return d(t,E)}class z{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=W(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);const s=e[i].map;if(h(s))e=s;else{if(!D(s))throw new Error(\"Invalid map type.\");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error(\"Map doesn't exist.\");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(D(t))return!0;if(!h(t))throw new Error(\"Invalid map type.\");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error(\"At the root already.\");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new z(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol(\"ArgCreator\");function L(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class G{node;[b]=!0;[v]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=L;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error(\"The node provided to the Core is not a valid node.\");if(h(i))this.mapWrapper=new z(i);else{if(!(i instanceof z))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?u(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!u(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new o(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,a=this.findChildren(r,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${s}\" child. Selector used: \"${r}\".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>d(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof l&&!e.required)return console.warn(`${i.message} Skipping instantiation of the \"${t}\" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new a(\"Children are already destroyed.\");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}removeChild(t,e){if(u(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i(\"Required child has been destroyed.\");if(null===this.instantiatedChildren[e])throw new o(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency \"${t}\" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${s.selector}\".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class x{creator;[M]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new x(t)}}const S=Symbol(\"Wraplet\");function O(t){return d(t,S)}const A=Symbol(\"Groupable\");async function N(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function j(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function P(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot initialize without status available.\");const i=t.status||this.status;await N(i,t.core)&&(e&&await e(),await $(i,t.destroyCallback))}}function T(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error(\"Cannot destroy without status available.\");const i=t.status||this.status;await j(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(i))}}const k=t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||T({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||P({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]});return Object.assign(k(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class R{core;[S]=!0;[A]=!0;[v]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!d(t,b))throw new Error(\"AbstractWraplet requires a Core instance.\");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new l(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new G(t,e)}static createWraplets(t,e,i,s=[]){if(this===R)throw new Error(\"You cannot instantiate an abstract class.\");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}class Y{levels;[E]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error(\"There have to be more than 0 repeated levels.\")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new Y(t)}}class _ extends p{[f]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");return Object.assign(e,t)}export{R as AbstractWraplet,a as ChildrenAreAlreadyDestroyedError,s as ChildrenAreNotAvailableError,n as ChildrenTooManyFoundError,x as DefaultArgCreator,G as DefaultCore,w as DefaultWrapletSet,_ as DefaultWrapletSetReadonly,o as InternalLogicError,e as MapError,Y as MapRepeat,t as MissingRequiredChildError,i as RequiredChildDestroyedError,r as StorageValidationError,l as UnsupportedNodeTypeError,S as WrapletSymbol,T as createDefaultDestroyCallback,P as createDefaultInitializeCallback,F as createRichWrapletApi,k as createWrapletApi,B as customizeDefaultWrapletApi,L as defaultWrapletCreator,m as destroyWrapletsRecursively,q as destructionCompleted,j as destructionStarted,y as getWrapletsFromNode,$ as initializationCompleted,N as initializationStarted,O as isWraplet};\n//# sourceMappingURL=index.js.map","const t=Symbol(\"KeyValueStorage\");function e(e){return(e=>\"object\"==typeof e&&null!==e&&!0===e[t])(e)}class a extends Error{}class s{storage;defaults;validators;[t]=!0;constructor(t,e,a){this.storage=t,this.defaults=e,this.validators=a}async has(t){return await this.storage.has(t)}async get(t){const e=await this.storage.get(t);return void 0!==e?(this.validateGetValue(t,e),e):this.defaults[t]}async getMultiple(t){const e={...await this.storage.getMultiple(t)};for(const a of t)void 0===e[a]&&(e[a]=this.defaults[a]);return e}async getAll(){const t={...await this.storage.getAll()};for(const e of Object.keys(this.defaults))void 0===t[e]&&(t[e]=this.defaults[e]);return t}async set(t,e){this.validateSetValue(t,e),await this.storage.set(t,e)}async setMultiple(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setMultiple(t)}async setAll(t){for(const e in t)this.validateSetValue(e,t[e]);await this.storage.setAll(t)}async delete(t){await this.storage.delete(t)}async deleteMultiple(t){await this.storage.deleteMultiple(t)}async deleteAll(){await this.storage.deleteAll()}validateGetValue(t,e){if(!this.validators[t](e))throw new a(`Got an invalid value for the key ${String(t)}.`)}validateSetValue(t,e){if(!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`)}}class i{isPartial;defaults;validators;[t]=!0;data=null;options;constructor(t,e,a,s={}){this.isPartial=t,this.defaults=e,this.validators=a,this.validateValidators(a),this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...s}}async has(t){return t in await this.getAll()}async get(t){return(await this.getAll())[t]}async getMultiple(t){const e=await this.getAll();return t.reduce((t,a)=>(t[a]=e[a],t),{})}async getAll(){return this.options.keepFresh&&await this.refresh(),this.data||await this.refresh(),this.data}async set(t,e){if(this.validators[t]&&!this.validators[t](e))throw new a(`Attempted to set an invalid value for the key ${String(t)}.`);const s=await this.getValue(),i=JSON.parse(s);i[t]=e,await this.setAll(i)}async setMultiple(t){const e=await this.getAll();await this.setAll({...e,...t})}async setAll(t){await this.setValue(t)}async delete(t){const e=await this.getAll();t in e&&(delete e[t],await this.setValue(e))}async deleteMultiple(t){const e=await this.getAll();for(const a of t)delete e[a];await this.setAll(e)}async deleteAll(){await this.deleteAllValues(),await this.refresh()}async refresh(){this.data=await this.fetchFreshData()}async fetchFreshData(){const t=await this.getValue();if(\"{\"!==t.charAt(0))throw new a(\"Data has to be defined as an object.\");const e=JSON.parse(t);return this.validateData(e),this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!this.isPartial&&!this.validators[e])throw new a(`No validator found for the value: ${e}`);if(this.validators[e]&&!this.validators[e](t[e]))throw new a(`Value for '${e}' has been discarded by the validator.`)}}validateValidators(t){for(const e in t)if(\"function\"!=typeof t[e])throw new a(`Validator for ${e} is not a function.`)}}class l extends i{element;attribute;defaults;validators;constructor(t,e,a,s,i,l={}){super(t,s,i,l),this.element=e,this.attribute=a,this.defaults=s,this.validators=i}async getValue(){return this.element.getAttribute(this.attribute)||\"{}\"}async setValue(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}async deleteAllValues(){this.element.removeAttribute(this.attribute)}}class r extends i{element;defaults;validators;constructor(t,e,a,s,i={}){super(t,a,s,i),this.element=e,this.defaults=a,this.validators=s}async getValue(){return this.element.textContent||\"{}\"}async setValue(t){this.element.textContent=JSON.stringify(t)}async deleteAllValues(){this.element.textContent=\"{}\"}}export{i as AbstractNongranularKeyValueStorage,l as ElementAttributeStorage,r as ElementStorage,t as KeyValueStorageSymbol,s as StorageWrapper,e as isKeyValueStorage};\n//# sourceMappingURL=storage.js.map","import { AbstractWraplet, Constructable, Core } from \"wraplet\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\ntype AltererData = {\n callback: DocumentAlterer;\n priority: number;\n};\n\nexport type ExhibitionPreviewOptions = {\n updateHeight?: boolean;\n updateHeightCallback?: (preview: ExhibitionPreview) => Promise<void>;\n};\n\nexport class ExhibitionPreview\n extends AbstractWraplet<HTMLIFrameElement>\n implements PreviewWraplet\n{\n private alterers: AltererData[] = [];\n private currentBlobUrl: string | null = null;\n\n private options: KeyValueStorage<Required<ExhibitionPreviewOptions>>;\n\n constructor(\n core: Core<HTMLIFrameElement>,\n options: ExhibitionPreviewOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionPreviewOptions>>,\n ) {\n super(core);\n\n const validators: StorageValidators<ExhibitionPreviewOptions> = {\n updateHeight: (data: unknown) => typeof data === \"boolean\",\n updateHeightCallback: (data: unknown) => typeof data === \"function\",\n };\n\n const defaultOptions: Required<ExhibitionPreviewOptions> = {\n updateHeight: true,\n updateHeightCallback: async (preview) => {\n setTimeout(() => {\n preview.updateHeight();\n }, 100);\n },\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionPreviewOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionPreviewOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n );\n\n this.options = new StorageWrapper<Required<ExhibitionPreviewOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLIFrameElement>[] {\n return super.supportedNodeTypesGuard([HTMLIFrameElement]);\n }\n\n /**\n * Adds a DocumentAlterer to the preview.\n * @param alterer\n * @param priority\n * Priority of the alterer. Higher priority alterers are executed first.\n */\n public addDocumentAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n if (this.hasDocumentAlterer(alterer)) {\n return;\n }\n\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n\n /**\n * Checks if alterer is already registered.\n * @param alterer\n */\n public hasDocumentAlterer(alterer: DocumentAlterer): boolean {\n return this.alterers.some(\n (altererData) => altererData.callback === alterer,\n );\n }\n\n public removeDocumentAlterer(alterer: DocumentAlterer): void {\n this.alterers = this.alterers.filter(\n (altererData) => altererData.callback !== alterer,\n );\n }\n\n public async update(): Promise<void> {\n const doc = document.implementation.createHTMLDocument();\n this.alterers.sort((a, b) => b.priority - a.priority);\n for (const alterer of this.alterers) {\n await alterer.callback(doc);\n }\n\n // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\n }\n\n const htmlContent = \"<!DOCTYPE html>\\n\" + doc.documentElement.outerHTML;\n const blob = new Blob([htmlContent], { type: \"text/html;charset=utf-8\" });\n this.currentBlobUrl = URL.createObjectURL(blob);\n this.node.src = this.currentBlobUrl;\n\n this.node.onload = async () => {\n if (!(await this.options.get(\"updateHeight\"))) {\n await (\n await this.options.get(\"updateHeightCallback\")\n )(this);\n }\n this.node.onload = null;\n };\n }\n\n /**\n * Updates preview's height to match its content.\n */\n public updateHeight(): void {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n\n const styles = iframeWindow.getComputedStyle(el);\n const margin =\n parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n\n private getIFrameDocument(): Document {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n\n return iframeDocument;\n }\n\n private getIFrameWindow(): Window {\n const window = this.node.contentWindow;\n if (!window) {\n throw new Error(\"IFrame window is not available.\");\n }\n return window;\n }\n}\n","import { IsSingleTag, PreviewValue } from \"./types/PreviewValue\";\n\nexport const typeMap = {\n html: {\n languages: [\"html\"],\n tag: undefined,\n },\n js: {\n languages: [\"javascript\", \"typescript\"],\n tag: \"script\",\n },\n css: {\n languages: [\"css\"],\n tag: \"style\",\n },\n} as const;\n\nexport type TypeFromLanguage<L extends MonacoEditorLanguages> = {\n [K in ValueTypes]: L extends (typeof typeMap)[K][\"languages\"][number]\n ? K\n : never;\n}[ValueTypes];\n\nexport type ValueTypes = keyof typeof typeMap;\n\nexport type MonacoEditorLanguages =\n (typeof typeMap)[ValueTypes][\"languages\"][number];\n\nexport function getTypeFromLanguage<T extends MonacoEditorLanguages>(\n language: T,\n): TypeFromLanguage<T> {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language as never)) {\n return key as TypeFromLanguage<T>;\n }\n }\n\n throw new Error(\"Unknown language\");\n}\n\nexport function getTagFromType<T extends ValueTypes>(\n type: T,\n): (typeof typeMap)[T][\"tag\"] {\n return typeMap[type].tag;\n}\n\nexport function isSingleTagType(\n type: ValueTypes,\n): type is Extract<PreviewValue, IsSingleTag>[\"type\"] {\n return Boolean(getTagFromType(type));\n}\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultDestroyCallback,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n} from \"wraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageValidators,\n StorageWrapper,\n} from \"wraplet/storage\";\n\nimport type * as monaco from \"monaco-editor\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n getTagFromType,\n getTypeFromLanguage,\n isSingleTagType,\n MonacoEditorLanguages,\n} from \"./TypeMap\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\n\nexport type EditorCreator = (\n options: monaco.editor.IStandaloneEditorConstructionOptions,\n node: HTMLElement,\n monaco: MonacoInstance,\n) => Promise<monaco.editor.IStandaloneCodeEditor>;\n\nexport type ExhibitionMonacoEditorOptions = {\n /**\n * Monaco instance.\n */\n monaco: MonacoInstance;\n /**\n * Instead of depending on this class for editor instantiation, you can provide your own editor instance here.\n */\n monacoEditorCreator?: EditorCreator;\n\n /**\n * Monaco options for the editor.\n */\n monacoEditorOptions?: monaco.editor.IStandaloneEditorConstructionOptions;\n\n /**\n * Location where the editor should be inserted.\n */\n location?: \"head\" | \"body\";\n\n /**\n * Priority of the editor's document alterer. Higher priority means it will be executed first.\n */\n priority?: number;\n\n /**\n * Trim the default value of the editor.\n */\n trimDefaultValue?: boolean;\n\n /**\n * This option applies to single tag languages only (typescript, javascript and css). It\n * determines the attributes that will be added to the generated tag.\n */\n tagAttributes?: Record<string, string>;\n};\n\ntype RequiredMonacoEditorOptions = Required<\n Omit<ExhibitionMonacoEditorOptions, \"tagAttributes\" | \"monacoEditorCreator\">\n> & {\n tagAttributes?: ExhibitionMonacoEditorOptions[\"tagAttributes\"];\n monacoEditorCreator?: EditorCreator;\n};\n\nexport type MonacoInstance = typeof monaco;\n\nexport class ExhibitionMonacoEditor\n extends AbstractWraplet<HTMLElement>\n implements DocumentAltererProviderWraplet\n{\n private monaco: MonacoInstance | null = null;\n private editor: monaco.editor.IStandaloneCodeEditor | null = null;\n private options: KeyValueStorage<RequiredMonacoEditorOptions>;\n\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private priority: number = 0;\n private monacoEditorOptions:\n | RequiredMonacoEditorOptions[\"monacoEditorOptions\"]\n | null = null;\n\n constructor(\n core: Core<HTMLElement>,\n options: ExhibitionMonacoEditorOptions,\n optionsStorage?: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>>,\n ) {\n super(core);\n\n this.alterDocument = this.alterDocument.bind(this);\n\n const defaultOptions: Omit<\n RequiredMonacoEditorOptions,\n \"monacoEditorCreator\" | \"monaco\"\n > = {\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n\n const validators: StorageValidators<ExhibitionMonacoEditorOptions> = {\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data: unknown) =>\n typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data: unknown) => Number.isInteger(data),\n tagAttributes: (data: unknown) => typeof data === \"object\",\n trimDefaultValue: (data: unknown) => typeof data === \"boolean\",\n monacoEditorCreator: (data: unknown) => typeof data === \"function\",\n monaco: (data: unknown) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n\n const optsStorage: KeyValueStorage<Partial<ExhibitionMonacoEditorOptions>> =\n optionsStorage ||\n new ElementAttributeStorage<Partial<ExhibitionMonacoEditorOptions>, true>(\n true,\n core.node,\n \"data-js-options\",\n {},\n {},\n {\n elementOptionsMerger: (defaults, attributeOptions) => {\n attributeOptions.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n ...attributeOptions.monacoEditorOptions,\n };\n return { ...defaults, ...options, ...attributeOptions };\n },\n },\n );\n\n this.options = new StorageWrapper<RequiredMonacoEditorOptions>(\n optsStorage,\n { ...defaultOptions, ...options },\n validators,\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n destroy: this.destroy.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n destroyCallback: this.destroy,\n status: this.status,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"ExhibitionMonacoEditor is already initialized\");\n }\n this.priority = await this.options.get(\"priority\");\n this.monacoEditorOptions = await this.options.get(\n \"monacoEditorOptions\",\n );\n\n if (await this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = await this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(\n monacoOptions.value,\n );\n await this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n\n await this.validateOptions();\n\n this.monaco = await this.getMonacoInstance();\n\n const editorCreator: EditorCreator =\n (await this.options.get(\"monacoEditorCreator\")) ||\n (async (options, element, monaco) =>\n ExhibitionMonacoEditor.createMonacoEditor(\n options,\n element,\n monaco,\n ));\n\n this.editor = await editorCreator(\n await this.options.get(\"monacoEditorOptions\"),\n this.node,\n this.monaco,\n );\n },\n )();\n }\n\n public getPriority(): number {\n return this.priority;\n }\n\n private async getMonacoInstance(): Promise<MonacoInstance> {\n const monaco = await this.options.get(\"monaco\");\n if (!monaco) throw new Error(\"Monaco instance is not available\");\n return monaco;\n }\n\n /**\n * Returns the current value of the editor.\n */\n private getValue(): string {\n return this.getEditor().getValue();\n }\n\n private async alterDocument(document: Document): Promise<void> {\n const monaco = this.monaco;\n if (!monaco) {\n throw new Error(\n \"Monaco instance is not available. Is wraplet initialized?\",\n );\n }\n\n const language = this.getLanguage();\n const content =\n language === \"typescript\"\n ? await this.getTSValueAsJS(monaco)\n : this.getValue();\n\n const location = await this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = (await this.options.get(\"tagAttributes\")) ?? {};\n const tagElement = document.createElement(tag);\n for (const [key, value] of Object.entries(tagAttributes)) {\n tagElement.setAttribute(key, value);\n }\n tagElement.innerHTML = content;\n document[location].appendChild(tagElement);\n return;\n }\n document[location].innerHTML += content;\n }\n\n public getDocumentAlterer(): DocumentAlterer {\n return this.alterDocument;\n }\n\n /**\n * Additional validation.\n */\n private async validateOptions() {\n if (!(await this.options.get(\"monacoEditorOptions\")).language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (await this.options.get(\"tagAttributes\")) {\n throw new Error(\n \"'tagAttributes' option is only allowed for single tag types\",\n );\n }\n }\n }\n\n private getEditor(): monaco.editor.IStandaloneCodeEditor {\n if (!this.editor) throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n\n private async getTSValueAsJS(monaco: MonacoInstance) {\n const model = this.getEditor().getModel();\n if (!model) throw new Error(\"Model is not available\");\n\n // Make sure TypeScript eager sync is enabled\n monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\n\n // Ensure we're using file:/// URI\n const uri = model.uri;\n if (uri.scheme !== \"file\") {\n throw new Error(`Model must use file:// URI, got: ${uri.toString()}`);\n }\n\n // Get worker getter\n const getWorker = async (\n attempts: number = 10,\n ): Promise<\n | ((\n ...uris: monaco.Uri[]\n ) => Promise<monaco.languages.typescript.TypeScriptWorker>)\n | null\n > => {\n try {\n return await monaco.languages.typescript.getTypeScriptWorker();\n } catch (error) {\n if (error !== \"TypeScript not registered!\") throw error;\n if (attempts <= 0) return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n\n const worker = await workerGetter(uri);\n\n // 🔸 Wait until the worker actually knows this file\n // Call something lightweight to force registration\n for (let i = 0; i < 20; i++) {\n try {\n await worker.getSemanticDiagnostics(uri.toString());\n break; // success — worker now recognizes the file\n } catch (err) {\n if (/Could not find source file/.test(String(err))) {\n await new Promise((r) => setTimeout(r, 250));\n continue;\n }\n throw err;\n }\n }\n\n // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length) throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n\n private getLanguage(): MonacoEditorLanguages {\n const monacoOptions = this.monacoEditorOptions;\n if (!monacoOptions) {\n throw new Error(\n \"Monaco options are not available. Is wraplet initialized?\",\n );\n }\n\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n\n return monacoOptions[\"language\"] as MonacoEditorLanguages;\n }\n\n public static trimDefaultValue(content: string): string {\n const lines = content.split(\"\\n\");\n\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\n\n // Trim the same number of spaces from each line\n const trimmedLines = lines.map((line) => {\n // Only trim if the line has at least that many leading spaces\n if (\n line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\"\n ) {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n\n public async destroy() {\n return createDefaultDestroyCallback(\n {\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n status: this.status,\n },\n async () => {\n this.editor?.dispose();\n },\n )();\n }\n\n /**\n * Helper method creating a new monaco editor instance.\n */\n public static createMonacoEditor(\n editorOptions: monaco.editor.IStandaloneEditorConstructionOptions = {},\n node: HTMLElement,\n monaco: MonacoInstance,\n ): monaco.editor.IStandaloneCodeEditor {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n\n const model = this.createMonacoModel(\n monaco,\n language,\n editorOptions.value || \"\",\n );\n\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n\n /**\n * Helper method creating a new monaco model instance.\n */\n public static createMonacoModel(\n monaco: MonacoInstance,\n language: string,\n value: string,\n ): monaco.editor.ITextModel {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(\n value,\n language,\n monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`),\n );\n }\n\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n public static create(\n element: HTMLElement,\n options: ExhibitionMonacoEditorOptions,\n ): ExhibitionMonacoEditor {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\n","import {\n AbstractWraplet,\n Constructable,\n Core,\n createDefaultInitializeCallback,\n customizeDefaultWrapletApi,\n DefaultCore,\n Status,\n WrapletChildrenMap,\n} from \"wraplet\";\nimport {\n ExhibitionPreview,\n ExhibitionPreviewOptions,\n} from \"./ExhibitionPreview\";\nimport {\n ExhibitionMonacoEditor,\n ExhibitionMonacoEditorOptions,\n} from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { DocumentAltererProviderWraplet } from \"./types/DocumentAltererProviderWraplet\";\nimport {\n ElementAttributeStorage,\n KeyValueStorage,\n StorageWrapper,\n} from \"wraplet/storage\";\nimport { DocumentAlterer } from \"./types/DocumentAlterer\";\nimport { PreviewWraplet } from \"./types/PreviewWraplet\";\n\nexport type ExhibitionOptions = {\n /**\n * Selector for the element that triggers the update of the preview.\n */\n updaterSelector?: string;\n};\n\nexport type ExhibitionInitOptions = {\n init?: boolean;\n updatePreview?: boolean;\n};\n\nexport type PreviewOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n previewOptions: O;\n }\n : { previewOptions?: O };\n\nexport type EditorsOptionsWrapper<\n O,\n IS_REQUIRED extends boolean = false,\n> = IS_REQUIRED extends true\n ? {\n editorsOptions: O;\n }\n : { editorsOptions?: O };\n\nexport type ExhibitionMapOptions<\n EO extends EditorsOptionsWrapper<unknown, boolean> | undefined =\n EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>,\n PO extends PreviewOptionsWrapper<unknown, boolean> | undefined =\n PreviewOptionsWrapper<ExhibitionPreviewOptions>,\n> = {\n Class?: Constructable<DocumentAltererProviderWraplet>;\n selectEditors?: boolean;\n} & (EO extends undefined\n ? EditorsOptionsWrapper<ExhibitionMonacoEditorOptions, true>\n : EO) &\n (PO extends undefined ? PreviewOptionsWrapper<ExhibitionPreviewOptions> : PO);\n\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\" as string | undefined,\n multiple: true,\n required: false,\n Class:\n ExhibitionMonacoEditor as Constructable<DocumentAltererProviderWraplet>,\n args: [] as unknown[],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview as Constructable<PreviewWraplet>,\n args: [] as unknown[],\n },\n} satisfies WrapletChildrenMap;\n\nexport class Exhibition extends AbstractWraplet<\n HTMLElement,\n typeof ExhibitionMap\n> {\n private status: Status = {\n isInitialized: false,\n isDestroyed: false,\n isGettingInitialized: false,\n isGettingDestroyed: false,\n };\n\n private options: KeyValueStorage<Required<ExhibitionOptions>>;\n constructor(\n core: Core<HTMLElement, typeof ExhibitionMap>,\n options: ExhibitionOptions = {},\n optionsStorage?: KeyValueStorage<Partial<ExhibitionOptions>>,\n ) {\n super(core);\n const defaultOptions: Required<ExhibitionOptions> = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n const optsStorage =\n optionsStorage ??\n new ElementAttributeStorage<Partial<ExhibitionOptions>, true>(\n true,\n this.node,\n \"data-js-options\",\n {},\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n this.options = new StorageWrapper<Required<ExhibitionOptions>>(\n optsStorage,\n { ...defaultOptions, ...options },\n {\n updaterSelector: (data: unknown) => typeof data === \"string\",\n },\n );\n\n this.wraplet = customizeDefaultWrapletApi(\n {\n status: this.status,\n initialize: this.initialize.bind(this),\n },\n this.wraplet,\n );\n }\n\n protected supportedNodeTypes(): readonly Constructable<HTMLElement>[] {\n return super.supportedNodeTypesGuard([HTMLElement]);\n }\n\n public async initialize() {\n return createDefaultInitializeCallback(\n {\n core: this.core,\n status: this.status,\n destroyCallback: this.wraplet.destroy,\n },\n async () => {\n if (this.status.isInitialized) {\n throw new Error(\"Exhibition is already initialized\");\n }\n\n for (const editor of this.children.editors) {\n if (\n !editor.wraplet.status.isInitialized &&\n !editor.wraplet.status.isGettingInitialized\n ) {\n await editor.wraplet.initialize();\n }\n\n if (\n !this.children.preview.hasDocumentAlterer(\n editor.getDocumentAlterer(),\n )\n ) {\n this.addPreviewAlterer(\n editor.getDocumentAlterer(),\n editor.getPriority(),\n );\n }\n }\n\n const updaterElements = this.node.querySelectorAll(\n await this.options.get(\"updaterSelector\"),\n );\n\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n },\n )();\n }\n\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n public addEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.add(editor);\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Removes DocumentAltererProviderWraplet instance from the list of editors.\n */\n public removeEditor(editor: DocumentAltererProviderWraplet): void {\n this.children.editors.delete(editor);\n this.children.preview.removeDocumentAlterer(editor.getDocumentAlterer());\n }\n\n /**\n * Checks if the given editor is present in the list of editors.\n */\n public hasEditor(editor: DocumentAltererProviderWraplet): boolean {\n return this.children.editors.has(editor);\n }\n\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n private addPreviewAlterer(\n alterer: DocumentAlterer,\n priority: number = 0,\n ): void {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n\n public getPreview(): PreviewWraplet {\n return this.children.preview;\n }\n\n public async updatePreview(): Promise<void> {\n await this.children.preview.update();\n }\n\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param initOptions Options related to the creation process of the Exhibitions.\n * @param attribute Attribute to use for Exhibition instances.\n *\n * @returns Array of Exhibition instances.\n */\n public static async createMultiple<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n node: ParentNode,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n attribute: string = exhibitionDefaultAttribute,\n ): Promise<Exhibition[]> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n\n const exhibitions = this.createWraplets<HTMLElement, Exhibition>(\n node,\n map,\n attribute,\n [options],\n );\n\n for (const exhibition of exhibitions) {\n await this.applyCreateOptions(exhibition, initOptions);\n }\n\n return exhibitions;\n }\n\n /**\n * Create a single Exhibition instance wrapping a given element.\n *\n * @param element Element to wrap.\n * @param map Map of dependencies for the Exhibition instance.\n * @param options Options for the Exhibition instance.\n * @param initOptions Options related to the creation process of the Exhibitions.\n */\n public static async create<\n M extends typeof ExhibitionMap = typeof ExhibitionMap,\n >(\n element: HTMLElement,\n map: M,\n options: ExhibitionOptions = {},\n initOptions: ExhibitionInitOptions = {},\n ): Promise<Exhibition> {\n initOptions = this.fillCreateOptionsWithDefaults(initOptions);\n this.validateInitOptions(initOptions, map);\n const core = new DefaultCore<HTMLElement, typeof ExhibitionMap>(\n element,\n map,\n );\n const exhibition = new Exhibition(core, options);\n await this.applyCreateOptions(exhibition, initOptions);\n return exhibition;\n }\n\n private static fillCreateOptionsWithDefaults(\n createOptions: ExhibitionInitOptions,\n ) {\n return {\n init: true,\n updatePreview: false,\n ...createOptions,\n };\n }\n\n /**\n * Validate create options.\n */\n private static validateInitOptions(\n initOptions: ExhibitionInitOptions,\n map: typeof ExhibitionMap,\n ) {\n if (initOptions.init && map.editors.selector === undefined) {\n throw new Error(\n \"Cannot initialize exhibition with undefined editors.selector\",\n );\n }\n\n if (!initOptions.init && initOptions.updatePreview) {\n throw new Error(\n \"Cannot update preview without initializing exhibitions first\",\n );\n }\n }\n\n /**\n * Create options.\n */\n private static async applyCreateOptions(\n exhibition: Exhibition,\n options: ExhibitionInitOptions = {},\n ): Promise<void> {\n if (!options.init && options.updatePreview) {\n throw new Error(\n \"'updatePreview' option cannot be enabled without the 'init' one because updating preview requires initialization.\",\n );\n }\n\n if (options.init) {\n await exhibition.initialize();\n }\n\n if (options.updatePreview) {\n await exhibition.updatePreview();\n }\n }\n\n /**\n * Returns a generic dependecy map with an undefined editor class that has to be provided through\n * the options.\n *\n * @param mapOptions\n * Map options.\n */\n public static getMap<\n O extends ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n > = ExhibitionMapOptions,\n >(mapOptions?: NoInfer<O>): typeof ExhibitionMap {\n const map: typeof ExhibitionMap = ExhibitionMap;\n const allOptions: Required<\n ExhibitionMapOptions<\n EditorsOptionsWrapper<unknown, boolean>,\n PreviewOptionsWrapper<unknown, boolean>\n >\n > = {\n ...{\n selectEditors: true,\n Class: undefined as any,\n editorsOptions: {},\n previewOptions: {},\n },\n ...mapOptions,\n };\n\n if (allOptions.Class) {\n map[\"editors\"][\"Class\"] = allOptions.Class;\n }\n\n if (\n allOptions.selectEditors &&\n map[\"editors\"][\"Class\"] instanceof ExhibitionMonacoEditor &&\n (!allOptions.editorsOptions ||\n !(allOptions.editorsOptions as { monaco?: unknown })[\"monaco\"])\n ) {\n throw new Error(\n \"When selecting ExhibitionMonacoEditor instances, you must provide the 'monaco' option in the editors options. To avoid this error, disable 'selectEditors' or provide the 'monaco' option.\",\n );\n }\n\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n\n if (allOptions.previewOptions) {\n map[\"preview\"][\"args\"].push(allOptions.previewOptions);\n }\n\n if (allOptions.editorsOptions) {\n map[\"editors\"][\"args\"].push(allOptions.editorsOptions);\n }\n\n return map;\n }\n}\n"],"names":["t","Error","e","i","s","n","a","o","l","h","Object","getPrototypeOf","prototype","d","c","Symbol","u","p","Set","find","this","push","findOne","getOrdered","Array","from","sort","f","w","b","v","I","args","destructible","map","coreOptions","W","r","E","D","z","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","L","element","initOptions","Class","G","node","childrenAreInstantiated","statusWritable","isDestroyed","isGettingDestroyed","isInitialized","isGettingInitialized","status","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","values","flatMap","Promise","all","wraplet","initialize","destroy","instantiateChildren","querySelectorAll","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","createArg","required","console","warn","message","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","delete","Proxy","get","defaultInitOptions","assign","entries","S","A","P","async","N","core","$","destroyCallback","T","j","destroyListeners","q","R","supportedNodeTypes","onChildDestroy","bind","onChildInstantiate","groupExtractor","Element","getAttribute","split","initializeCallback","__nodeAccessors","k","setGroupsExtractor","getGroups","F","supportedNodeTypesGuard","isChildInstance","createCore","createWraplets","hasAttribute","B","storage","defaults","validators","has","validateGetValue","getMultiple","getAll","keys","set","validateSetValue","setMultiple","setAll","deleteMultiple","deleteAll","String","isPartial","data","validateValidators","keepFresh","elementOptionsMerger","reduce","refresh","getValue","JSON","parse","setValue","deleteAllValues","fetchFreshData","charAt","validateData","attribute","super","setAttribute","stringify","removeAttribute","ExhibitionPreview","alterers","currentBlobUrl","optionsStorage","defaultOptions","updateHeight","updateHeightCallback","preview","setTimeout","optsStorage","HTMLIFrameElement","addDocumentAlterer","alterer","priority","hasDocumentAlterer","some","altererData","removeDocumentAlterer","update","doc","document","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","type","createObjectURL","src","onload","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","Math","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","key","value","includes","getTagFromType","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","monacoEditorOptions","alterDocument","location","trimDefaultValue","Number","isInteger","tagAttributes","monacoEditorCreator","attributeOptions","HTMLElement","monacoOptions","validateOptions","getMonacoInstance","editorCreator","createMonacoEditor","getPriority","getEditor","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","attempts","getTypeScriptWorker","error","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","random","createModel","Uri","exhibitionDefaultAttribute","ExhibitionMap","editors","Exhibition","updaterSelector","addPreviewAlterer","updaterElements","updatePreview","addEditor","removeEditor","hasEditor","getPreview","createMultiple","fillCreateOptionsWithDefaults","validateInitOptions","exhibitions","exhibition","applyCreateOptions","createOptions","init","getMap","mapOptions","allOptions","selectEditors","editorsOptions","previewOptions"],"ignoreList":[],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exhibitionjs",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Library for showcasing your js/ts code snippets.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",