exhibitionjs 0.9.0 → 0.11.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.
@@ -9,6 +9,10 @@ export type ExhibitionOptions = {
9
9
  */
10
10
  updaterSelector?: string;
11
11
  };
12
+ export type ExhibitionCreateOptions = {
13
+ init?: boolean;
14
+ updatePreview?: boolean;
15
+ };
12
16
  export type ExhibitionMapOptions = {
13
17
  Class: Constructable<DocumentAltererProviderWraplet>;
14
18
  selectEditors?: boolean;
@@ -50,19 +54,28 @@ export declare class Exhibition extends AbstractWraplet<HTMLElement, typeof Exhi
50
54
  * @param attribute Attribute to use for Exhibition instances.
51
55
  * @param map Map of dependencies for each Exhibition instance.
52
56
  * @param options Options for Exhibition instances.
53
- * @param init Initialize exhibitions after they're created.
54
- * @param updatePreview Update preview of each exhibition after it's initialized.
57
+ * @param createOptions Options related to the creation process of the Exhibitions.
58
+ *
55
59
  * @returns Array of Exhibition instances.
56
60
  */
57
- static createMultiple(node: ParentNode, attribute: string | undefined, map: typeof ExhibitionMap, options?: ExhibitionOptions, init?: boolean, updatePreview?: boolean): Promise<Exhibition[]>;
61
+ static createMultiple(node: ParentNode, attribute: string | undefined, map: typeof ExhibitionMap, options?: ExhibitionOptions, createOptions?: ExhibitionCreateOptions): Promise<Exhibition[]>;
58
62
  /**
59
63
  * Create a single Exhibition instance wrapping a given element.
60
64
  *
61
65
  * @param element Element to wrap.
62
66
  * @param map Map of dependencies for the Exhibition instance.
63
67
  * @param options Options for the Exhibition instance.
68
+ * @param createOptions Options related to the creation process of the Exhibitions.
69
+ */
70
+ static create(element: HTMLElement, map: typeof ExhibitionMap, options?: ExhibitionOptions, createOptions?: ExhibitionCreateOptions): Promise<Exhibition>;
71
+ /**
72
+ * Validate create options.
73
+ */
74
+ private static validateCreateOptions;
75
+ /**
76
+ * Create options.
64
77
  */
65
- static create(element: HTMLElement, map: typeof ExhibitionMap, options?: ExhibitionOptions): Promise<Exhibition>;
78
+ private static applyCreateOptions;
66
79
  /**
67
80
  * Returns a dependency map with editors being instances of ExhibitionMonacoEditor.
68
81
  *
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var t={d:(e,i)=>{for(var r in i)t.o(i,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:i[r]})},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:()=>T,defaultOptionsAttribute:()=>x});class i extends Error{}class r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}class a 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 g extends p{[f]=!0;[c]=!0}const m=Symbol("NodeTreeParent"),w=Symbol("ChildrenManager");function y(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function b(t){const e={};for(const i in t){const r=t[i];e[i]=y(r);const n=r.map;n&&h(n)&&(e[i].map=b(n))}return e}const C=Symbol("DynamicMap");function E(t){return d(t,C)}class v{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=b(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 r=e[i].map;if(h(r))e=r;else{if(!E(r))throw new Error("Invalid map type.");e=r.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 v(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class M{node;[w]=!0;[m]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,e,i={}){if(this.node=t,h(e))this.mapWrapper=new v(e);else{if(!(e instanceof v))throw new r("The map provided to the Core is not a valid map.");this.mapWrapper=e}this.processInitOptions(i),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new r("If the node provided cannot have children, the children map should be empty.");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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 l("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const n=t.selector,s=this.findChildren(n,i);if(this.validateElements(r,s,t),0===s.length)return null;if(s.length>1)throw new o(`${this.constructor.name}: More than one element was found for the "${r}" child. Selector used: "${n}".`);const a=s[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new g;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new g;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new a("Children are already destroyed.");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new s("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new s("Wraplet is already initialized. Fetch children with 'children' property instead.");return this.instantiatedChildren}removeChild(t,e){if(u(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.isGettingDestroyed)throw new n("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,n=e.required;if(!i&&n)throw new r(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateElements(t,e,r){if(0===e.length&&r.required)throw new i(`${this.constructor.name}: Couldn't find a node for the wraplet "${t}". Selector used: "${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)t.destroy();else e.destroy()}}const O=Symbol("Wraplet"),S=Symbol("Groupable");class A{core;[O]=!0;[S]=!0;[m]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!d(t,w))throw new Error("AbstractWraplet requires a Core instance.");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}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,r=[]){if(this===A)throw new Error("You cannot instantiate an abstract class.");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=A.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=A.createCore(t,e);n.push(new this(i,...r))}return n}}class D extends Error{}class I{element;attribute;defaults;validators;data;options;constructor(t,e,i,r,n={}){this.element=t,this.attribute=e,this.defaults=i,this.validators=r,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...n},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(t,e){if(!this.validators[t](e))throw new D(`Attempted to set an invalid value for the key ${String(t)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[t]=e,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const i of t)delete e[i];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const t=this.getAttributeValue(this.attribute);if("{"!==t.charAt(0))throw new D("Data has to be defined as an object.");const e=JSON.parse(t);if(!this.validateData(e))throw new D("Invalid storage value.");return this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if("function"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||"{}"}}const L="data-js-exhibition",x="data-js-options",W={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function j(t){for(const[e,i]of Object.entries(W))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function P(t){return W[t].tag}function z(t){return Boolean(P(t))}class T extends A{monaco;editor=null;options;constructor(t,e){super(t);const i={optionsAttribute:"data-js-options",location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={optionsAttribute:t=>"string"==typeof t,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};if(e.monacoEditorOptions={...i.monacoEditorOptions,...e.monacoEditorOptions},this.options=new I(this.node,x,{...i,...e},r,{elementOptionsMerger:(t,e)=>(e.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions},{...t,...e})}),this.monaco=this.options.get("monaco"),this.options.get("trimDefaultValue")){const t=this.options.get("monacoEditorOptions");t.value&&(t.value=T.trimDefaultValue(t.value),this.options.set("monacoEditorOptions",t))}this.validateOptions()}isEditorInitialized(){return null!==this.editor}async init(){const t=this.options.get("monacoEditorCreator")||(async(t,e,i)=>T.createMonacoEditor(t,e,i));this.editor=await t(this.options.get("monacoEditorOptions"),this.node,this.monaco)}getPriority(){return this.options.get("priority")}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.getLanguage(),i="typescript"===e?await this.getTSValueAsJS():this.getValue(),r=this.options.get("location"),n=j(e);if(z(n)){const e=P(n),s=this.options.get("tagAttributes")??{},o=t.createElement(e);for(const[t,e]of Object.entries(s))o.setAttribute(t,e);return o.innerHTML=i,void t[r].appendChild(o)}t[r].innerHTML+=i}getDocumentAlterer(){return this.alterDocument.bind(this)}validateOptions(){if(!this.options.get("monacoEditorOptions").language)throw new Error("Missing language in monacoOptions");if(!z(j(this.getLanguage()))&&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(){const t=this.getEditor().getModel();if(!t)throw new Error("Model is not available");this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const e=t.uri;if("file"!==e.scheme)throw new Error(`Model must use file:// URI, got: ${e.toString()}`);const i=async(t=10)=>{try{return await this.monaco.languages.typescript.getTypeScriptWorker()}catch(e){if("TypeScript not registered!"!==e)throw e;return t<=0?null:(await new Promise(t=>setTimeout(t,200)),i(t-1))}},r=await i();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(e);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(e.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:s}=await n.getEmitOutput(e.toString());if(!s.length)throw new Error("No JS output produced");return s[0].text}getLanguage(){const t=this.options.get("monacoEditorOptions");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 r=i.search(/\S|$/);return e.map(t=>t.length>=r&&""===t.substring(0,r).trim()?t.substring(r):t).join("\n").trim()}destroy(){this.editor?.dispose(),super.destroy()}static createMonacoEditor(t={},e,i){const r=t.language;if(!r)throw new Error("Missing language in editorOptions");const n=this.createMonacoModel(i,r,t.value||"");return i.editor.create(e,{...t,model:n})}static createMonacoModel(t,e,i){const r=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${r}.ts`))}static create(t,e){const i=new M(t,{});return new T(i,e)}}const N={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:T,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:class extends A{alterers=[];currentBlobUrl=null;addDocumentAlterer(t,e=0){this.alterers.push({callback:t,priority:e})}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=()=>{setTimeout(()=>{this.updateHeight()},100),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),r=parseFloat(i.marginTop)+parseFloat(i.marginBottom),n=Math.ceil(e.offsetHeight+r);this.node.height=n+"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}}}};class $ extends A{options;constructor(t,e={}){super(t),this.options=new I(this.node,L,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t});for(const t of this.children.editors)this.children.preview.addDocumentAlterer(t.getDocumentAlterer(),t.getPriority());const i=this.node.querySelectorAll(this.options.get("updaterSelector"));for(const t of i)this.core.addEventListener(t,"click",()=>{this.updatePreview()})}async init(){await this.initalizeMonacoEditors()}addEditor(t){this.children.editors.add(t),this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority())}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}async initalizeMonacoEditors(){for(const t of this.children.editors)if(t instanceof T){if(t.isEditorInitialized())continue;await t.init()}}static async createMultiple(t,e=L,i,r={},n=!0,s=!0){if(!n&&s)throw new Error("Cannot update preview without initializing exhibitions first");const o=this.createWraplets(t,i,e,[r]);return n&&await Promise.all(o.map(t=>t.init())),s&&await Promise.all(o.map(t=>t.updatePreview())),o}static async create(t,e,i={}){const r=new M(t,e);return new $(r,i)}static getMapWithMonacoEditor(t,e={}){const i={...e,Class:T},r=this.getMap(i);return r.editors.args=[t],r}static getMap(t){const e=N,i={selectEditors:!0,...t};return e.editors.Class=i.Class,i.selectEditors||(e.editors.selector=void 0),e}}var G=exports;for(var F in e)G[F]=e[F];e.__esModule&&Object.defineProperty(G,"__esModule",{value:!0});
1
+ var t={d:(e,i)=>{for(var r in i)t.o(i,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:i[r]})},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:()=>T,defaultOptionsAttribute:()=>x});class i extends Error{}class r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}class a 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 g extends p{[f]=!0;[c]=!0}const m=Symbol("NodeTreeParent"),w=Symbol("ChildrenManager");function y(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function b(t){const e={};for(const i in t){const r=t[i];e[i]=y(r);const n=r.map;n&&h(n)&&(e[i].map=b(n))}return e}const C=Symbol("DynamicMap");function v(t){return d(t,C)}class E{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=b(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 r=e[i].map;if(h(r))e=r;else{if(!v(r))throw new Error("Invalid map type.");e=r.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(!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 E(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class M{node;[w]=!0;[m]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,e,i={}){if(this.node=t,h(e))this.mapWrapper=new E(e);else{if(!(e instanceof E))throw new r("The map provided to the Core is not a valid map.");this.mapWrapper=e}this.processInitOptions(i),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new r("If the node provided cannot have children, the children map should be empty.");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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 l("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const n=t.selector,s=this.findChildren(n,i);if(this.validateElements(r,s,t),0===s.length)return null;if(s.length>1)throw new o(`${this.constructor.name}: More than one element was found for the "${r}" child. Selector used: "${n}".`);const a=s[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new g;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new g;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new a("Children are already destroyed.");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new s("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new s("Wraplet is already initialized. Fetch children with 'children' property instead.");return this.instantiatedChildren}removeChild(t,e){if(u(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.isGettingDestroyed)throw new n("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,n=e.required;if(!i&&n)throw new r(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateElements(t,e,r){if(0===e.length&&r.required)throw new i(`${this.constructor.name}: Couldn't find a node for the wraplet "${t}". Selector used: "${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)t.destroy();else e.destroy()}}const O=Symbol("Wraplet"),S=Symbol("Groupable");class A{core;[O]=!0;[S]=!0;[m]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!d(t,w))throw new Error("AbstractWraplet requires a Core instance.");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}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,r=[]){if(this===A)throw new Error("You cannot instantiate an abstract class.");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=A.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=A.createCore(t,e);n.push(new this(i,...r))}return n}}class D extends Error{}class I{element;attribute;defaults;validators;data;options;constructor(t,e,i,r,n={}){this.element=t,this.attribute=e,this.defaults=i,this.validators=r,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...n},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(t,e){if(!this.validators[t](e))throw new D(`Attempted to set an invalid value for the key ${String(t)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[t]=e,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const i of t)delete e[i];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const t=this.getAttributeValue(this.attribute);if("{"!==t.charAt(0))throw new D("Data has to be defined as an object.");const e=JSON.parse(t);if(!this.validateData(e))throw new D("Invalid storage value.");return this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if("function"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||"{}"}}const L="data-js-exhibition",x="data-js-options",W={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function j(t){for(const[e,i]of Object.entries(W))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function P(t){return W[t].tag}function z(t){return Boolean(P(t))}class T extends A{monaco;editor=null;options;constructor(t,e){super(t);const i={optionsAttribute:"data-js-options",location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={optionsAttribute:t=>"string"==typeof t,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};if(e.monacoEditorOptions={...i.monacoEditorOptions,...e.monacoEditorOptions},this.options=new I(this.node,x,{...i,...e},r,{elementOptionsMerger:(t,e)=>(e.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions},{...t,...e})}),this.monaco=this.options.get("monaco"),this.options.get("trimDefaultValue")){const t=this.options.get("monacoEditorOptions");t.value&&(t.value=T.trimDefaultValue(t.value),this.options.set("monacoEditorOptions",t))}this.validateOptions()}isEditorInitialized(){return null!==this.editor}async init(){const t=this.options.get("monacoEditorCreator")||(async(t,e,i)=>T.createMonacoEditor(t,e,i));this.editor=await t(this.options.get("monacoEditorOptions"),this.node,this.monaco)}getPriority(){return this.options.get("priority")}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.getLanguage(),i="typescript"===e?await this.getTSValueAsJS():this.getValue(),r=this.options.get("location"),n=j(e);if(z(n)){const e=P(n),s=this.options.get("tagAttributes")??{},o=t.createElement(e);for(const[t,e]of Object.entries(s))o.setAttribute(t,e);return o.innerHTML=i,void t[r].appendChild(o)}t[r].innerHTML+=i}getDocumentAlterer(){return this.alterDocument.bind(this)}validateOptions(){if(!this.options.get("monacoEditorOptions").language)throw new Error("Missing language in monacoOptions");if(!z(j(this.getLanguage()))&&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(){const t=this.getEditor().getModel();if(!t)throw new Error("Model is not available");this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const e=t.uri;if("file"!==e.scheme)throw new Error(`Model must use file:// URI, got: ${e.toString()}`);const i=async(t=10)=>{try{return await this.monaco.languages.typescript.getTypeScriptWorker()}catch(e){if("TypeScript not registered!"!==e)throw e;return t<=0?null:(await new Promise(t=>setTimeout(t,200)),i(t-1))}},r=await i();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(e);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(e.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:s}=await n.getEmitOutput(e.toString());if(!s.length)throw new Error("No JS output produced");return s[0].text}getLanguage(){const t=this.options.get("monacoEditorOptions");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 r=i.search(/\S|$/);return e.map(t=>t.length>=r&&""===t.substring(0,r).trim()?t.substring(r):t).join("\n").trim()}destroy(){this.editor?.dispose(),super.destroy()}static createMonacoEditor(t={},e,i){const r=t.language;if(!r)throw new Error("Missing language in editorOptions");const n=this.createMonacoModel(i,r,t.value||"");return i.editor.create(e,{...t,model:n})}static createMonacoModel(t,e,i){const r=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${r}.ts`))}static create(t,e){const i=new M(t,{});return new T(i,e)}}const N={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:T,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:class extends A{alterers=[];currentBlobUrl=null;addDocumentAlterer(t,e=0){this.alterers.push({callback:t,priority:e})}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=()=>{setTimeout(()=>{this.updateHeight()},100),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),r=parseFloat(i.marginTop)+parseFloat(i.marginBottom),n=Math.ceil(e.offsetHeight+r);this.node.height=n+"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}}}};class $ extends A{options;constructor(t,e={}){super(t),this.options=new I(this.node,L,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t});for(const t of this.children.editors)this.children.preview.addDocumentAlterer(t.getDocumentAlterer(),t.getPriority());const i=this.node.querySelectorAll(this.options.get("updaterSelector"));for(const t of i)this.core.addEventListener(t,"click",()=>{this.updatePreview()})}async init(){await this.initalizeMonacoEditors()}addEditor(t){this.children.editors.add(t),this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority())}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}async initalizeMonacoEditors(){for(const t of this.children.editors)if(t instanceof T){if(t.isEditorInitialized())continue;await t.init()}}static async createMultiple(t,e=L,i,r={},n={}){this.validateCreateOptions(n);const s=this.createWraplets(t,i,e,[r]);for(const t of s)await this.applyCreateOptions(t,n);return s}static async create(t,e,i={},r={}){this.validateCreateOptions(r);const n=new M(t,e),s=new $(n,i);return await this.applyCreateOptions(s,r),s}static validateCreateOptions(t){if(!t.init&&t.updatePreview)throw new Error("Cannot update preview without initializing exhibitions first")}static async applyCreateOptions(t,e={}){const i={init:!0,updatePreview:!0,...e};i.init&&await t.init(),i.updatePreview&&await t.updatePreview()}static getMapWithMonacoEditor(t,e={}){const i={...e,Class:T},r=this.getMap(i);return r.editors.args=[t],r}static getMap(t){const e=N,i={selectEditors:!0,...t};return e.editors.Class=i.Class,i.selectEditors||(e.editors.selector=void 0),e}}var G=exports;for(var F in e)G[F]=e[F];e.__esModule&&Object.defineProperty(G,"__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,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,iGCLvD,MAAMC,UAAUC,OAAO,MAAMC,UAAUD,OAAO,MAAME,UAAUF,OAAO,MAAMG,UAAUH,OAAO,MAAMI,UAAUJ,OAAO,MAAMK,UAAUL,OAAO,MAAMd,UAAUc,OAAO,SAASM,EAAEP,GAAG,OAAOZ,OAAOoB,eAAeR,KAAKZ,OAAOM,SAAS,CAAC,MAAMe,EAAE,CAACT,EAAEE,IAAI,iBAAiBF,GAAG,OAAOA,IAAG,IAAKA,EAAEE,GAAGQ,EAAEb,OAAO,cAAc,SAASc,EAAEX,GAAG,OAAOS,EAAET,EAAEU,EAAE,CAAC,MAAME,UAAUC,IAAI,IAAAC,CAAKd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ACpE,MAAMqM,EAAO,IACNrM,EACHrC,MAAOgH,GAELvJ,EAAMd,KAAKgS,OAAOD,GAExB,OADAjR,EAAa,QAAQ,KAAI,CAACgR,GACnBhR,CACX,CAQA,aAAOkR,CAAOtM,GACV,MAAM5E,EAAM6N,EACNsD,EAAa,CAEXC,eAAe,KAEhBxM,GAMP,OAJA5E,EAAa,QAAS,MAAImR,EAAW5O,MAChC4O,EAAWC,gBACZpR,EAAa,QAAY,cAAI6I,GAE1B7I,CACX,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/selectors.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/Exhibition.ts","webpack://exhibitionjs/./src/ExhibitionPreview.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 r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}function a(t){return Object.getPrototypeOf(t)===Object.prototype}const h=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],l=Symbol(\"WrapletSet\");function d(t){return h(t,l)}class c 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 u extends c{[p]=!0;[l]=!0}function f(t){const e=t.wraplets;return d(e)&&0!==e.size?e:new u}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}function y(t,e){e(t);const i=t.childNodes;for(const t of i)y(t,e)}function w(t){y(t,t=>{const e=f(t);for(const i of e)i.isGettingDestroyed||i.isDestroyed||i.destroy(),C(i,t)})}const g=Symbol(\"NodeTreeParent\"),m=Symbol(\"ChildrenManager\");function b(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function v(t){const e={};for(const i in t){const r=t[i];e[i]=b(r);const n=r.map;n&&a(n)&&(e[i].map=v(n))}return e}const I=Symbol(\"DynamicMap\");function E(t){return h(t,I)}class W{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 r=e[i].map;if(a(r))e=r;else{if(!E(r))throw new Error(\"Invalid map type.\");e=r.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(!a(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 W(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class M{node;[m]=!0;[g]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,i,r={}){if(this.node=t,a(i))this.mapWrapper=new W(i);else{if(!(i instanceof W))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(r),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new e(\"If the node provided cannot have children, the children map should be empty.\");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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(!d(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const s=t.selector,o=this.findChildren(s,i);if(this.validateElements(r,o,t),0===o.length)return null;if(o.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${r}\" child. Selector used: \"${s}\".`);const a=o[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new u;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new u;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new s(\"Children are already destroyed.\");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new r(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new r(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");return this.instantiatedChildren}removeChild(t,e){if(d(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.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 r=i.selector,n=i.required;if(!r&&n)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateElements(e,i,r){if(0===i.length&&r.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(d(e))for(const t of e)t.destroy();else e.destroy()}}const L=Symbol(\"Wraplet\");function D(t){return h(t,L)}const x=Symbol(\"Groupable\");class S{core;[L]=!0;[x]=!0;[g]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!h(t,m))throw new Error(\"AbstractWraplet requires a Core instance.\");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}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,r=[]){if(this===S)throw new Error(\"You cannot instantiate an abstract class.\");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=S.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=S.createCore(t,e);n.push(new this(i,...r))}return n}}class z{levels;[I]=!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 z(t)}}class O extends c{[p]=!0}export{S as AbstractWraplet,M as DefaultCore,u as DefaultWrapletSet,O as DefaultWrapletSetReadonly,z as MapRepeat,w as destroyWrapletsRecursively,f as getWrapletsFromNode,D as isWraplet};\n//# sourceMappingURL=index.js.map","class t extends Error{}class e{element;attribute;defaults;validators;data;options;constructor(t,e,s,i,r={}){this.element=t,this.attribute=e,this.defaults=s,this.validators=i,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...r},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,s)=>(t[s]=e[s],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(e,s){if(!this.validators[e](s))throw new t(`Attempted to set an invalid value for the key ${String(e)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[e]=s,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const s of t)delete e[s];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const e=this.getAttributeValue(this.attribute);if(\"{\"!==e.charAt(0))throw new t(\"Data has to be defined as an object.\");const s=JSON.parse(e);if(!this.validateData(s))throw new t(\"Invalid storage value.\");return this.options.elementOptionsMerger(this.defaults,s)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if(\"function\"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||\"{}\"}}export{e as ElementStorage};\n//# sourceMappingURL=storage.js.map","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\nexport const defaultOptionsAttribute = \"data-js-options\";\n","export 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};\nexport function getTypeFromLanguage(language) {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language)) {\n return key;\n }\n }\n throw new Error(\"Unknown language\");\n}\nexport function getTagFromType(type) {\n return typeMap[type].tag;\n}\nexport function isSingleTagValue(item) {\n return Boolean(getTagFromType(item.type));\n}\nexport function isSingleTagType(type) {\n return Boolean(getTagFromType(type));\n}\n","import { AbstractWraplet, DefaultCore } from \"wraplet\";\nimport { ElementStorage } from \"wraplet/storage\";\nimport { defaultOptionsAttribute } from \"./selectors\";\nimport { getTagFromType, getTypeFromLanguage, isSingleTagType, } from \"./TypeMap\";\nexport class ExhibitionMonacoEditor extends AbstractWraplet {\n monaco;\n editor = null;\n options;\n constructor(core, options) {\n super(core);\n const defaultOptions = {\n optionsAttribute: \"data-js-options\",\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n const validators = {\n optionsAttribute: (data) => typeof data === \"string\",\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data) => typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data) => Number.isInteger(data),\n tagAttributes: (data) => typeof data === \"object\",\n trimDefaultValue: (data) => typeof data === \"boolean\",\n monacoEditorCreator: (data) => typeof data === \"function\",\n monaco: (data) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n this.options = new ElementStorage(this.node, defaultOptionsAttribute, { ...defaultOptions, ...options }, validators, {\n elementOptionsMerger: (defaults, options) => {\n options.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n return { ...defaults, ...options };\n },\n });\n this.monaco = this.options.get(\"monaco\");\n if (this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(monacoOptions.value);\n this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n this.validateOptions();\n }\n isEditorInitialized() {\n return this.editor !== null;\n }\n async init() {\n const editorCreator = this.options.get(\"monacoEditorCreator\") ||\n (async (options, element, monaco) => ExhibitionMonacoEditor.createMonacoEditor(options, element, monaco));\n this.editor = await editorCreator(this.options.get(\"monacoEditorOptions\"), this.node, this.monaco);\n }\n getPriority() {\n return this.options.get(\"priority\");\n }\n /**\n * Returns the current value of the editor.\n */\n getValue() {\n return this.getEditor().getValue();\n }\n async alterDocument(document) {\n const language = this.getLanguage();\n const content = language === \"typescript\" ? await this.getTSValueAsJS() : this.getValue();\n const location = this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = 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 getDocumentAlterer() {\n return this.alterDocument.bind(this);\n }\n /**\n * Additional validation.\n */\n validateOptions() {\n if (!this.options.get(\"monacoEditorOptions\").language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (this.options.get(\"tagAttributes\")) {\n throw new Error(\"'tagAttributes' option is only allowed for single tag types\");\n }\n }\n }\n getEditor() {\n if (!this.editor)\n throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n async getTSValueAsJS() {\n const model = this.getEditor().getModel();\n if (!model)\n throw new Error(\"Model is not available\");\n // Make sure TypeScript eager sync is enabled\n this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\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 // Get worker getter\n const getWorker = async (attempts = 10) => {\n try {\n return await this.monaco.languages.typescript.getTypeScriptWorker();\n }\n catch (error) {\n if (error !== \"TypeScript not registered!\")\n throw error;\n if (attempts <= 0)\n return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n const worker = await workerGetter(uri);\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 }\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 // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length)\n throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n getLanguage() {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n return monacoOptions[\"language\"];\n }\n static trimDefaultValue(content) {\n const lines = content.split(\"\\n\");\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\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 (line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\") {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n destroy() {\n this.editor?.dispose();\n super.destroy();\n }\n /**\n * Helper method creating a new monaco editor instance.\n */\n static createMonacoEditor(editorOptions = {}, node, monaco) {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n const model = this.createMonacoModel(monaco, language, editorOptions.value || \"\");\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n /**\n * Helper method creating a new monaco model instance.\n */\n static createMonacoModel(monaco, language, value) {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(value, language, monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`));\n }\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n static create(element, options) {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","import { AbstractWraplet, DefaultCore, } from \"wraplet\";\nimport { ExhibitionPreview } from \"./ExhibitionPreview\";\nimport { ExhibitionMonacoEditor, } from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { ElementStorage } from \"wraplet/storage\";\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\",\n multiple: true,\n required: false,\n Class: ExhibitionMonacoEditor,\n args: [],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview,\n },\n};\nexport class Exhibition extends AbstractWraplet {\n options;\n constructor(core, options = {}) {\n super(core);\n const defaultOptions = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n this.options = new ElementStorage(this.node, exhibitionDefaultAttribute, { ...defaultOptions, ...options }, {\n updaterSelector: (data) => typeof data === \"string\",\n });\n for (const editor of this.children.editors) {\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n const updaterElements = this.node.querySelectorAll(this.options.get(\"updaterSelector\"));\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n }\n async init() {\n await this.initalizeMonacoEditors();\n }\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n addEditor(editor) {\n this.children.editors.add(editor);\n this.addPreviewAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n addPreviewAlterer(alterer, priority = 0) {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n getPreview() {\n return this.children.preview;\n }\n async updatePreview() {\n await this.children.preview.update();\n }\n async initalizeMonacoEditors() {\n for (const editor of this.children.editors) {\n if (editor instanceof ExhibitionMonacoEditor) {\n if (editor.isEditorInitialized()) {\n continue;\n }\n await editor.init();\n }\n }\n }\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param attribute Attribute to use for Exhibition instances.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param init Initialize exhibitions after they're created.\n * @param updatePreview Update preview of each exhibition after it's initialized.\n * @returns Array of Exhibition instances.\n */\n static async createMultiple(node, attribute = exhibitionDefaultAttribute, map, options = {}, init = true, updatePreview = true) {\n if (!init && updatePreview) {\n throw new Error(\"Cannot update preview without initializing exhibitions first\");\n }\n const exhibitions = this.createWraplets(node, map, attribute, [options]);\n if (init) {\n await Promise.all(exhibitions.map((exhibition) => exhibition.init()));\n }\n if (updatePreview) {\n await Promise.all(exhibitions.map((exhibition) => exhibition.updatePreview()));\n }\n return exhibitions;\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 */\n static async create(element, map, options = {}) {\n const core = new DefaultCore(element, map);\n return new Exhibition(core, options);\n }\n /**\n * Returns a dependency map with editors being instances of ExhibitionMonacoEditor.\n *\n * @param exhibitionMonacoEditorOptions\n * MonacoEditorOptions to pass to the ExhibitionMonacoEditor.\n * @param options\n * Map options.\n */\n static getMapWithMonacoEditor(exhibitionMonacoEditorOptions, options = {}) {\n const opts = {\n ...options,\n Class: ExhibitionMonacoEditor,\n };\n const map = this.getMap(opts);\n map[\"editors\"][\"args\"] = [exhibitionMonacoEditorOptions];\n return map;\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 options\n * Map options.\n */\n static getMap(options) {\n const map = ExhibitionMap;\n const allOptions = {\n ...{\n selectEditors: true,\n },\n ...options,\n };\n map[\"editors\"][\"Class\"] = allOptions.Class;\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n return map;\n }\n}\n","import { AbstractWraplet } from \"wraplet\";\nexport class ExhibitionPreview extends AbstractWraplet {\n alterers = [];\n currentBlobUrl = null;\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 addDocumentAlterer(alterer, priority = 0) {\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n async update() {\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 // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\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 this.node.onload = () => {\n // Wait for the document to render before calculating the height.\n // @todo This should be configurable.\n setTimeout(() => {\n this.updateHeight();\n }, 100);\n this.node.onload = null;\n };\n }\n /**\n * Updates preview's height to match its content.\n */\n updateHeight() {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n const styles = iframeWindow.getComputedStyle(el);\n const margin = parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n getIFrameDocument() {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n return iframeDocument;\n }\n getIFrameWindow() {\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"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","t","Error","e","i","r","n","s","a","getPrototypeOf","h","l","d","c","Set","find","this","push","findOne","getOrdered","Array","from","sort","p","u","g","m","b","args","destructible","map","coreOptions","v","I","E","W","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","node","isDestroyed","isGettingDestroyed","isGettingInitialized","isInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","defaultWrapletCreator","element","initOptions","Class","wrapletCreator","processInitOptions","init","instantiateChildren","wrapChildren","querySelectorAll","keys","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","values","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","defaultCreator","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","destroy","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","uninitializedChildren","delete","required","Proxy","defaultInitOptions","assign","entries","L","x","S","core","groupsExtractor","Element","getAttribute","split","destroyListeners","__debugNodeAccessors","onChildDestroyed","bind","onChildInstantiated","initialize","setGroupsExtractor","getGroups","isChildInstance","createCore","createWraplets","hasAttribute","attribute","defaults","validators","data","keepFresh","elementOptionsMerger","fetchFreshData","has","getAll","getMultiple","reduce","refresh","set","String","getAttributeValue","JSON","parse","setAll","setMultiple","setAttribute","stringify","deleteMultiple","deleteAll","removeAttribute","charAt","validateData","console","warn","exhibitionDefaultAttribute","defaultOptionsAttribute","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","includes","getTagFromType","type","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","super","defaultOptions","optionsAttribute","location","priority","trimDefaultValue","monacoEditorOptions","Number","isInteger","tagAttributes","monacoEditorCreator","monacoOptions","validateOptions","isEditorInitialized","editorCreator","createMonacoEditor","getPriority","getValue","getEditor","alterDocument","document","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","async","attempts","getTypeScriptWorker","error","Promise","setTimeout","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","Math","random","createModel","Uri","ExhibitionMap","editors","preview","alterers","currentBlobUrl","addDocumentAlterer","alterer","update","doc","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","createObjectURL","src","onload","updateHeight","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","Exhibition","updaterSelector","updaterElements","updatePreview","initalizeMonacoEditors","addEditor","addPreviewAlterer","getPreview","createMultiple","exhibitions","all","exhibition","getMapWithMonacoEditor","exhibitionMonacoEditorOptions","opts","getMap","allOptions","selectEditors"],"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,iGCLvD,MAAMC,UAAUC,OAAO,MAAMC,UAAUD,OAAO,MAAME,UAAUF,OAAO,MAAMG,UAAUH,OAAO,MAAMI,UAAUJ,OAAO,MAAMK,UAAUL,OAAO,MAAMd,UAAUc,OAAO,SAASM,EAAEP,GAAG,OAAOZ,OAAOoB,eAAeR,KAAKZ,OAAOM,SAAS,CAAC,MAAMe,EAAE,CAACT,EAAEE,IAAI,iBAAiBF,GAAG,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AChC+Q,EAAa,IAAIZ,EAAWzK,EAAMd,GAExC,aADM1F,KAAK8R,mBAAmBD,EAAYH,GACnCG,CACX,CAIA,4BAAOF,CAAsBD,GACzB,IAAKA,EAAclO,MAAQkO,EAAcN,cACrC,MAAM,IAAIlS,MAAM,+DAExB,CAIA,+BAAa4S,CAAmBD,EAAYH,EAAgB,CAAC,GACzD,MAAMhM,EAAU,CACZlC,MAAM,EACN4N,eAAe,KACZM,GAEHhM,EAAQlC,YACFqO,EAAWrO,OAEjBkC,EAAQ0L,qBACFS,EAAWT,eAEzB,CASA,6BAAOW,CAAuBC,EAA+BtM,EAAU,CAAC,GACpE,MAAMuM,EAAO,IACNvM,EACHrC,MAAOgH,GAELvJ,EAAMd,KAAKkS,OAAOD,GAExB,OADAnR,EAAa,QAAQ,KAAI,CAACkR,GACnBlR,CACX,CAQA,aAAOoR,CAAOxM,GACV,MAAM5E,EAAM6N,EACNwD,EAAa,CAEXC,eAAe,KAEhB1M,GAMP,OAJA5E,EAAa,QAAS,MAAIqR,EAAW9O,MAChC8O,EAAWC,gBACZtR,EAAa,QAAY,cAAI6I,GAE1B7I,CACX,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/selectors.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/Exhibition.ts","webpack://exhibitionjs/./src/ExhibitionPreview.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 r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}function a(t){return Object.getPrototypeOf(t)===Object.prototype}const h=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],l=Symbol(\"WrapletSet\");function d(t){return h(t,l)}class c 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 u extends c{[p]=!0;[l]=!0}function f(t){const e=t.wraplets;return d(e)&&0!==e.size?e:new u}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}function y(t,e){e(t);const i=t.childNodes;for(const t of i)y(t,e)}function w(t){y(t,t=>{const e=f(t);for(const i of e)i.isGettingDestroyed||i.isDestroyed||i.destroy(),C(i,t)})}const g=Symbol(\"NodeTreeParent\"),m=Symbol(\"ChildrenManager\");function b(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function v(t){const e={};for(const i in t){const r=t[i];e[i]=b(r);const n=r.map;n&&a(n)&&(e[i].map=v(n))}return e}const I=Symbol(\"DynamicMap\");function E(t){return h(t,I)}class W{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 r=e[i].map;if(a(r))e=r;else{if(!E(r))throw new Error(\"Invalid map type.\");e=r.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(!a(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 W(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class M{node;[m]=!0;[g]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,i,r={}){if(this.node=t,a(i))this.mapWrapper=new W(i);else{if(!(i instanceof W))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(r),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new e(\"If the node provided cannot have children, the children map should be empty.\");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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(!d(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const s=t.selector,o=this.findChildren(s,i);if(this.validateElements(r,o,t),0===o.length)return null;if(o.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${r}\" child. Selector used: \"${s}\".`);const a=o[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new u;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new u;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new s(\"Children are already destroyed.\");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new r(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new r(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");return this.instantiatedChildren}removeChild(t,e){if(d(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.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 r=i.selector,n=i.required;if(!r&&n)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateElements(e,i,r){if(0===i.length&&r.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(d(e))for(const t of e)t.destroy();else e.destroy()}}const L=Symbol(\"Wraplet\");function D(t){return h(t,L)}const x=Symbol(\"Groupable\");class S{core;[L]=!0;[x]=!0;[g]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!h(t,m))throw new Error(\"AbstractWraplet requires a Core instance.\");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}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,r=[]){if(this===S)throw new Error(\"You cannot instantiate an abstract class.\");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=S.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=S.createCore(t,e);n.push(new this(i,...r))}return n}}class z{levels;[I]=!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 z(t)}}class O extends c{[p]=!0}export{S as AbstractWraplet,M as DefaultCore,u as DefaultWrapletSet,O as DefaultWrapletSetReadonly,z as MapRepeat,w as destroyWrapletsRecursively,f as getWrapletsFromNode,D as isWraplet};\n//# sourceMappingURL=index.js.map","class t extends Error{}class e{element;attribute;defaults;validators;data;options;constructor(t,e,s,i,r={}){this.element=t,this.attribute=e,this.defaults=s,this.validators=i,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...r},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,s)=>(t[s]=e[s],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(e,s){if(!this.validators[e](s))throw new t(`Attempted to set an invalid value for the key ${String(e)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[e]=s,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const s of t)delete e[s];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const e=this.getAttributeValue(this.attribute);if(\"{\"!==e.charAt(0))throw new t(\"Data has to be defined as an object.\");const s=JSON.parse(e);if(!this.validateData(s))throw new t(\"Invalid storage value.\");return this.options.elementOptionsMerger(this.defaults,s)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if(\"function\"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||\"{}\"}}export{e as ElementStorage};\n//# sourceMappingURL=storage.js.map","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\nexport const defaultOptionsAttribute = \"data-js-options\";\n","export 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};\nexport function getTypeFromLanguage(language) {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language)) {\n return key;\n }\n }\n throw new Error(\"Unknown language\");\n}\nexport function getTagFromType(type) {\n return typeMap[type].tag;\n}\nexport function isSingleTagValue(item) {\n return Boolean(getTagFromType(item.type));\n}\nexport function isSingleTagType(type) {\n return Boolean(getTagFromType(type));\n}\n","import { AbstractWraplet, DefaultCore } from \"wraplet\";\nimport { ElementStorage } from \"wraplet/storage\";\nimport { defaultOptionsAttribute } from \"./selectors\";\nimport { getTagFromType, getTypeFromLanguage, isSingleTagType, } from \"./TypeMap\";\nexport class ExhibitionMonacoEditor extends AbstractWraplet {\n monaco;\n editor = null;\n options;\n constructor(core, options) {\n super(core);\n const defaultOptions = {\n optionsAttribute: \"data-js-options\",\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n const validators = {\n optionsAttribute: (data) => typeof data === \"string\",\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data) => typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data) => Number.isInteger(data),\n tagAttributes: (data) => typeof data === \"object\",\n trimDefaultValue: (data) => typeof data === \"boolean\",\n monacoEditorCreator: (data) => typeof data === \"function\",\n monaco: (data) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n this.options = new ElementStorage(this.node, defaultOptionsAttribute, { ...defaultOptions, ...options }, validators, {\n elementOptionsMerger: (defaults, options) => {\n options.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n return { ...defaults, ...options };\n },\n });\n this.monaco = this.options.get(\"monaco\");\n if (this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(monacoOptions.value);\n this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n this.validateOptions();\n }\n isEditorInitialized() {\n return this.editor !== null;\n }\n async init() {\n const editorCreator = this.options.get(\"monacoEditorCreator\") ||\n (async (options, element, monaco) => ExhibitionMonacoEditor.createMonacoEditor(options, element, monaco));\n this.editor = await editorCreator(this.options.get(\"monacoEditorOptions\"), this.node, this.monaco);\n }\n getPriority() {\n return this.options.get(\"priority\");\n }\n /**\n * Returns the current value of the editor.\n */\n getValue() {\n return this.getEditor().getValue();\n }\n async alterDocument(document) {\n const language = this.getLanguage();\n const content = language === \"typescript\" ? await this.getTSValueAsJS() : this.getValue();\n const location = this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = 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 getDocumentAlterer() {\n return this.alterDocument.bind(this);\n }\n /**\n * Additional validation.\n */\n validateOptions() {\n if (!this.options.get(\"monacoEditorOptions\").language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (this.options.get(\"tagAttributes\")) {\n throw new Error(\"'tagAttributes' option is only allowed for single tag types\");\n }\n }\n }\n getEditor() {\n if (!this.editor)\n throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n async getTSValueAsJS() {\n const model = this.getEditor().getModel();\n if (!model)\n throw new Error(\"Model is not available\");\n // Make sure TypeScript eager sync is enabled\n this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\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 // Get worker getter\n const getWorker = async (attempts = 10) => {\n try {\n return await this.monaco.languages.typescript.getTypeScriptWorker();\n }\n catch (error) {\n if (error !== \"TypeScript not registered!\")\n throw error;\n if (attempts <= 0)\n return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n const worker = await workerGetter(uri);\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 }\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 // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length)\n throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n getLanguage() {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n return monacoOptions[\"language\"];\n }\n static trimDefaultValue(content) {\n const lines = content.split(\"\\n\");\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\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 (line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\") {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n destroy() {\n this.editor?.dispose();\n super.destroy();\n }\n /**\n * Helper method creating a new monaco editor instance.\n */\n static createMonacoEditor(editorOptions = {}, node, monaco) {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n const model = this.createMonacoModel(monaco, language, editorOptions.value || \"\");\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n /**\n * Helper method creating a new monaco model instance.\n */\n static createMonacoModel(monaco, language, value) {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(value, language, monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`));\n }\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n static create(element, options) {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","import { AbstractWraplet, DefaultCore, } from \"wraplet\";\nimport { ExhibitionPreview } from \"./ExhibitionPreview\";\nimport { ExhibitionMonacoEditor, } from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { ElementStorage } from \"wraplet/storage\";\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\",\n multiple: true,\n required: false,\n Class: ExhibitionMonacoEditor,\n args: [],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview,\n },\n};\nexport class Exhibition extends AbstractWraplet {\n options;\n constructor(core, options = {}) {\n super(core);\n const defaultOptions = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n this.options = new ElementStorage(this.node, exhibitionDefaultAttribute, { ...defaultOptions, ...options }, {\n updaterSelector: (data) => typeof data === \"string\",\n });\n for (const editor of this.children.editors) {\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n const updaterElements = this.node.querySelectorAll(this.options.get(\"updaterSelector\"));\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n }\n async init() {\n await this.initalizeMonacoEditors();\n }\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n addEditor(editor) {\n this.children.editors.add(editor);\n this.addPreviewAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n addPreviewAlterer(alterer, priority = 0) {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n getPreview() {\n return this.children.preview;\n }\n async updatePreview() {\n await this.children.preview.update();\n }\n async initalizeMonacoEditors() {\n for (const editor of this.children.editors) {\n if (editor instanceof ExhibitionMonacoEditor) {\n if (editor.isEditorInitialized()) {\n continue;\n }\n await editor.init();\n }\n }\n }\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param attribute Attribute to use for Exhibition instances.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param createOptions Options related to the creation process of the Exhibitions.\n *\n * @returns Array of Exhibition instances.\n */\n static async createMultiple(node, attribute = exhibitionDefaultAttribute, map, options = {}, createOptions = {}) {\n this.validateCreateOptions(createOptions);\n const exhibitions = this.createWraplets(node, map, attribute, [options]);\n for (const exhibition of exhibitions) {\n await this.applyCreateOptions(exhibition, createOptions);\n }\n return exhibitions;\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 createOptions Options related to the creation process of the Exhibitions.\n */\n static async create(element, map, options = {}, createOptions = {}) {\n this.validateCreateOptions(createOptions);\n const core = new DefaultCore(element, map);\n const exhibition = new Exhibition(core, options);\n await this.applyCreateOptions(exhibition, createOptions);\n return exhibition;\n }\n /**\n * Validate create options.\n */\n static validateCreateOptions(createOptions) {\n if (!createOptions.init && createOptions.updatePreview) {\n throw new Error(\"Cannot update preview without initializing exhibitions first\");\n }\n }\n /**\n * Create options.\n */\n static async applyCreateOptions(exhibition, createOptions = {}) {\n const options = {\n init: true,\n updatePreview: true,\n ...createOptions,\n };\n if (options.init) {\n await exhibition.init();\n }\n if (options.updatePreview) {\n await exhibition.updatePreview();\n }\n }\n /**\n * Returns a dependency map with editors being instances of ExhibitionMonacoEditor.\n *\n * @param exhibitionMonacoEditorOptions\n * MonacoEditorOptions to pass to the ExhibitionMonacoEditor.\n * @param options\n * Map options.\n */\n static getMapWithMonacoEditor(exhibitionMonacoEditorOptions, options = {}) {\n const opts = {\n ...options,\n Class: ExhibitionMonacoEditor,\n };\n const map = this.getMap(opts);\n map[\"editors\"][\"args\"] = [exhibitionMonacoEditorOptions];\n return map;\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 options\n * Map options.\n */\n static getMap(options) {\n const map = ExhibitionMap;\n const allOptions = {\n ...{\n selectEditors: true,\n },\n ...options,\n };\n map[\"editors\"][\"Class\"] = allOptions.Class;\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n return map;\n }\n}\n","import { AbstractWraplet } from \"wraplet\";\nexport class ExhibitionPreview extends AbstractWraplet {\n alterers = [];\n currentBlobUrl = null;\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 addDocumentAlterer(alterer, priority = 0) {\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n async update() {\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 // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\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 this.node.onload = () => {\n // Wait for the document to render before calculating the height.\n // @todo This should be configurable.\n setTimeout(() => {\n this.updateHeight();\n }, 100);\n this.node.onload = null;\n };\n }\n /**\n * Updates preview's height to match its content.\n */\n updateHeight() {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n const styles = iframeWindow.getComputedStyle(el);\n const margin = parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n getIFrameDocument() {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n return iframeDocument;\n }\n getIFrameWindow() {\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"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","t","Error","e","i","r","n","s","a","getPrototypeOf","h","l","d","c","Set","find","this","push","findOne","getOrdered","Array","from","sort","p","u","g","m","b","args","destructible","map","coreOptions","v","I","E","W","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","node","isDestroyed","isGettingDestroyed","isGettingInitialized","isInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","defaultWrapletCreator","element","initOptions","Class","wrapletCreator","processInitOptions","init","instantiateChildren","wrapChildren","querySelectorAll","keys","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","values","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","defaultCreator","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","destroy","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","uninitializedChildren","delete","required","Proxy","defaultInitOptions","assign","entries","L","x","S","core","groupsExtractor","Element","getAttribute","split","destroyListeners","__debugNodeAccessors","onChildDestroyed","bind","onChildInstantiated","initialize","setGroupsExtractor","getGroups","isChildInstance","createCore","createWraplets","hasAttribute","attribute","defaults","validators","data","keepFresh","elementOptionsMerger","fetchFreshData","has","getAll","getMultiple","reduce","refresh","set","String","getAttributeValue","JSON","parse","setAll","setMultiple","setAttribute","stringify","deleteMultiple","deleteAll","removeAttribute","charAt","validateData","console","warn","exhibitionDefaultAttribute","defaultOptionsAttribute","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","includes","getTagFromType","type","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","super","defaultOptions","optionsAttribute","location","priority","trimDefaultValue","monacoEditorOptions","Number","isInteger","tagAttributes","monacoEditorCreator","monacoOptions","validateOptions","isEditorInitialized","editorCreator","createMonacoEditor","getPriority","getValue","getEditor","alterDocument","document","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","async","attempts","getTypeScriptWorker","error","Promise","setTimeout","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","Math","random","createModel","Uri","ExhibitionMap","editors","preview","alterers","currentBlobUrl","addDocumentAlterer","alterer","update","doc","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","createObjectURL","src","onload","updateHeight","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","Exhibition","updaterSelector","updaterElements","updatePreview","initalizeMonacoEditors","addEditor","addPreviewAlterer","getPreview","createMultiple","createOptions","validateCreateOptions","exhibitions","exhibition","applyCreateOptions","getMapWithMonacoEditor","exhibitionMonacoEditorOptions","opts","getMap","allOptions","selectEditors"],"sourceRoot":""}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- class t extends Error{}class e extends Error{}class i extends Error{}class r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}function a(t){return Object.getPrototypeOf(t)===Object.prototype}const l=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],h=Symbol("WrapletSet");function d(t){return l(t,h)}class c 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 u=Symbol("WrapletSetReadonly");class p extends c{[u]=!0;[h]=!0}const f=Symbol("NodeTreeParent"),g=Symbol("ChildrenManager");function m(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function w(t){const e={};for(const i in t){const r=t[i];e[i]=m(r);const n=r.map;n&&a(n)&&(e[i].map=w(n))}return e}const y=Symbol("DynamicMap");function C(t){return l(t,y)}class b{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 r=e[i].map;if(a(r))e=r;else{if(!C(r))throw new Error("Invalid map type.");e=r.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(C(t))return!0;if(!a(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 b(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class E{node;[g]=!0;[f]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,i,r={}){if(this.node=t,a(i))this.mapWrapper=new b(i);else{if(!(i instanceof b))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(r),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new e("If the node provided cannot have children, the children map should be empty.");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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(!d(i))throw new o("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const s=t.selector,o=this.findChildren(s,i);if(this.validateElements(r,o,t),0===o.length)return null;if(o.length>1)throw new n(`${this.constructor.name}: More than one element was found for the "${r}" child. Selector used: "${s}".`);const a=o[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new p;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new p;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new s("Children are already destroyed.");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new r("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new r("Wraplet is already initialized. Fetch children with 'children' property instead.");return this.instantiatedChildren}removeChild(t,e){if(d(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.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 r=i.selector,n=i.required;if(!r&&n)throw new e(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateElements(e,i,r){if(0===i.length&&r.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet "${e}". Selector used: "${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(d(e))for(const t of e)t.destroy();else e.destroy()}}const v=Symbol("Wraplet"),M=Symbol("Groupable");class O{core;[v]=!0;[M]=!0;[f]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!l(t,g))throw new Error("AbstractWraplet requires a Core instance.");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new E(t,e)}static createWraplets(t,e,i,r=[]){if(this===O)throw new Error("You cannot instantiate an abstract class.");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=O.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=O.createCore(t,e);n.push(new this(i,...r))}return n}}class A extends Error{}class D{element;attribute;defaults;validators;data;options;constructor(t,e,i,r,n={}){this.element=t,this.attribute=e,this.defaults=i,this.validators=r,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...n},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(t,e){if(!this.validators[t](e))throw new A(`Attempted to set an invalid value for the key ${String(t)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[t]=e,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const i of t)delete e[i];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const t=this.getAttributeValue(this.attribute);if("{"!==t.charAt(0))throw new A("Data has to be defined as an object.");const e=JSON.parse(t);if(!this.validateData(e))throw new A("Invalid storage value.");return this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if("function"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||"{}"}}const I="data-js-exhibition",S="data-js-options",L={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function W(t){for(const[e,i]of Object.entries(L))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function x(t){return L[t].tag}function j(t){return Boolean(x(t))}class z extends O{monaco;editor=null;options;constructor(t,e){super(t);const i={optionsAttribute:"data-js-options",location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={optionsAttribute:t=>"string"==typeof t,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};if(e.monacoEditorOptions={...i.monacoEditorOptions,...e.monacoEditorOptions},this.options=new D(this.node,S,{...i,...e},r,{elementOptionsMerger:(t,e)=>(e.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions},{...t,...e})}),this.monaco=this.options.get("monaco"),this.options.get("trimDefaultValue")){const t=this.options.get("monacoEditorOptions");t.value&&(t.value=z.trimDefaultValue(t.value),this.options.set("monacoEditorOptions",t))}this.validateOptions()}isEditorInitialized(){return null!==this.editor}async init(){const t=this.options.get("monacoEditorCreator")||(async(t,e,i)=>z.createMonacoEditor(t,e,i));this.editor=await t(this.options.get("monacoEditorOptions"),this.node,this.monaco)}getPriority(){return this.options.get("priority")}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.getLanguage(),i="typescript"===e?await this.getTSValueAsJS():this.getValue(),r=this.options.get("location"),n=W(e);if(j(n)){const e=x(n),s=this.options.get("tagAttributes")??{},o=t.createElement(e);for(const[t,e]of Object.entries(s))o.setAttribute(t,e);return o.innerHTML=i,void t[r].appendChild(o)}t[r].innerHTML+=i}getDocumentAlterer(){return this.alterDocument.bind(this)}validateOptions(){if(!this.options.get("monacoEditorOptions").language)throw new Error("Missing language in monacoOptions");if(!j(W(this.getLanguage()))&&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(){const t=this.getEditor().getModel();if(!t)throw new Error("Model is not available");this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const e=t.uri;if("file"!==e.scheme)throw new Error(`Model must use file:// URI, got: ${e.toString()}`);const i=async(t=10)=>{try{return await this.monaco.languages.typescript.getTypeScriptWorker()}catch(e){if("TypeScript not registered!"!==e)throw e;return t<=0?null:(await new Promise(t=>setTimeout(t,200)),i(t-1))}},r=await i();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(e);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(e.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:s}=await n.getEmitOutput(e.toString());if(!s.length)throw new Error("No JS output produced");return s[0].text}getLanguage(){const t=this.options.get("monacoEditorOptions");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 r=i.search(/\S|$/);return e.map(t=>t.length>=r&&""===t.substring(0,r).trim()?t.substring(r):t).join("\n").trim()}destroy(){this.editor?.dispose(),super.destroy()}static createMonacoEditor(t={},e,i){const r=t.language;if(!r)throw new Error("Missing language in editorOptions");const n=this.createMonacoModel(i,r,t.value||"");return i.editor.create(e,{...t,model:n})}static createMonacoModel(t,e,i){const r=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${r}.ts`))}static create(t,e){const i=new E(t,{});return new z(i,e)}}const P={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:z,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:class extends O{alterers=[];currentBlobUrl=null;addDocumentAlterer(t,e=0){this.alterers.push({callback:t,priority:e})}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=()=>{setTimeout(()=>{this.updateHeight()},100),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),r=parseFloat(i.marginTop)+parseFloat(i.marginBottom),n=Math.ceil(e.offsetHeight+r);this.node.height=n+"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}}}};class T extends O{options;constructor(t,e={}){super(t),this.options=new D(this.node,I,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t});for(const t of this.children.editors)this.children.preview.addDocumentAlterer(t.getDocumentAlterer(),t.getPriority());const i=this.node.querySelectorAll(this.options.get("updaterSelector"));for(const t of i)this.core.addEventListener(t,"click",()=>{this.updatePreview()})}async init(){await this.initalizeMonacoEditors()}addEditor(t){this.children.editors.add(t),this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority())}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}async initalizeMonacoEditors(){for(const t of this.children.editors)if(t instanceof z){if(t.isEditorInitialized())continue;await t.init()}}static async createMultiple(t,e=I,i,r={},n=!0,s=!0){if(!n&&s)throw new Error("Cannot update preview without initializing exhibitions first");const o=this.createWraplets(t,i,e,[r]);return n&&await Promise.all(o.map(t=>t.init())),s&&await Promise.all(o.map(t=>t.updatePreview())),o}static async create(t,e,i={}){const r=new E(t,e);return new T(r,i)}static getMapWithMonacoEditor(t,e={}){const i={...e,Class:z},r=this.getMap(i);return r.editors.args=[t],r}static getMap(t){const e=P,i={selectEditors:!0,...t};return e.editors.Class=i.Class,i.selectEditors||(e.editors.selector=void 0),e}}export{T as Exhibition,z as ExhibitionMonacoEditor,S as defaultOptionsAttribute};
1
+ class t extends Error{}class e extends Error{}class i extends Error{}class r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}function a(t){return Object.getPrototypeOf(t)===Object.prototype}const l=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],h=Symbol("WrapletSet");function d(t){return l(t,h)}class c 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 u=Symbol("WrapletSetReadonly");class p extends c{[u]=!0;[h]=!0}const f=Symbol("NodeTreeParent"),g=Symbol("ChildrenManager");function m(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function w(t){const e={};for(const i in t){const r=t[i];e[i]=m(r);const n=r.map;n&&a(n)&&(e[i].map=w(n))}return e}const y=Symbol("DynamicMap");function C(t){return l(t,y)}class b{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 r=e[i].map;if(a(r))e=r;else{if(!C(r))throw new Error("Invalid map type.");e=r.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(C(t))return!0;if(!a(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 b(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class v{node;[g]=!0;[f]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,i,r={}){if(this.node=t,a(i))this.mapWrapper=new b(i);else{if(!(i instanceof b))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(r),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new e("If the node provided cannot have children, the children map should be empty.");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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(!d(i))throw new o("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const s=t.selector,o=this.findChildren(s,i);if(this.validateElements(r,o,t),0===o.length)return null;if(o.length>1)throw new n(`${this.constructor.name}: More than one element was found for the "${r}" child. Selector used: "${s}".`);const a=o[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new p;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new p;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new s("Children are already destroyed.");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new r("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new r("Wraplet is already initialized. Fetch children with 'children' property instead.");return this.instantiatedChildren}removeChild(t,e){if(d(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.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 r=i.selector,n=i.required;if(!r&&n)throw new e(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateElements(e,i,r){if(0===i.length&&r.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet "${e}". Selector used: "${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(d(e))for(const t of e)t.destroy();else e.destroy()}}const E=Symbol("Wraplet"),M=Symbol("Groupable");class O{core;[E]=!0;[M]=!0;[f]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!l(t,g))throw new Error("AbstractWraplet requires a Core instance.");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new v(t,e)}static createWraplets(t,e,i,r=[]){if(this===O)throw new Error("You cannot instantiate an abstract class.");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=O.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=O.createCore(t,e);n.push(new this(i,...r))}return n}}class A extends Error{}class D{element;attribute;defaults;validators;data;options;constructor(t,e,i,r,n={}){this.element=t,this.attribute=e,this.defaults=i,this.validators=r,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...n},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,i)=>(t[i]=e[i],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(t,e){if(!this.validators[t](e))throw new A(`Attempted to set an invalid value for the key ${String(t)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[t]=e,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const i of t)delete e[i];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const t=this.getAttributeValue(this.attribute);if("{"!==t.charAt(0))throw new A("Data has to be defined as an object.");const e=JSON.parse(t);if(!this.validateData(e))throw new A("Invalid storage value.");return this.options.elementOptionsMerger(this.defaults,e)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if("function"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||"{}"}}const I="data-js-exhibition",S="data-js-options",L={html:{languages:["html"],tag:void 0},js:{languages:["javascript","typescript"],tag:"script"},css:{languages:["css"],tag:"style"}};function W(t){for(const[e,i]of Object.entries(L))if(i.languages.includes(t))return e;throw new Error("Unknown language")}function x(t){return L[t].tag}function j(t){return Boolean(x(t))}class z extends O{monaco;editor=null;options;constructor(t,e){super(t);const i={optionsAttribute:"data-js-options",location:"body",priority:0,trimDefaultValue:!0,monacoEditorOptions:{}},r={optionsAttribute:t=>"string"==typeof t,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};if(e.monacoEditorOptions={...i.monacoEditorOptions,...e.monacoEditorOptions},this.options=new D(this.node,S,{...i,...e},r,{elementOptionsMerger:(t,e)=>(e.monacoEditorOptions={...t.monacoEditorOptions,...e.monacoEditorOptions},{...t,...e})}),this.monaco=this.options.get("monaco"),this.options.get("trimDefaultValue")){const t=this.options.get("monacoEditorOptions");t.value&&(t.value=z.trimDefaultValue(t.value),this.options.set("monacoEditorOptions",t))}this.validateOptions()}isEditorInitialized(){return null!==this.editor}async init(){const t=this.options.get("monacoEditorCreator")||(async(t,e,i)=>z.createMonacoEditor(t,e,i));this.editor=await t(this.options.get("monacoEditorOptions"),this.node,this.monaco)}getPriority(){return this.options.get("priority")}getValue(){return this.getEditor().getValue()}async alterDocument(t){const e=this.getLanguage(),i="typescript"===e?await this.getTSValueAsJS():this.getValue(),r=this.options.get("location"),n=W(e);if(j(n)){const e=x(n),s=this.options.get("tagAttributes")??{},o=t.createElement(e);for(const[t,e]of Object.entries(s))o.setAttribute(t,e);return o.innerHTML=i,void t[r].appendChild(o)}t[r].innerHTML+=i}getDocumentAlterer(){return this.alterDocument.bind(this)}validateOptions(){if(!this.options.get("monacoEditorOptions").language)throw new Error("Missing language in monacoOptions");if(!j(W(this.getLanguage()))&&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(){const t=this.getEditor().getModel();if(!t)throw new Error("Model is not available");this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(!0);const e=t.uri;if("file"!==e.scheme)throw new Error(`Model must use file:// URI, got: ${e.toString()}`);const i=async(t=10)=>{try{return await this.monaco.languages.typescript.getTypeScriptWorker()}catch(e){if("TypeScript not registered!"!==e)throw e;return t<=0?null:(await new Promise(t=>setTimeout(t,200)),i(t-1))}},r=await i();if(!r)throw new Error("Timeout: Could not get TypeScript worker");const n=await r(e);for(let t=0;t<20;t++)try{await n.getSemanticDiagnostics(e.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:s}=await n.getEmitOutput(e.toString());if(!s.length)throw new Error("No JS output produced");return s[0].text}getLanguage(){const t=this.options.get("monacoEditorOptions");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 r=i.search(/\S|$/);return e.map(t=>t.length>=r&&""===t.substring(0,r).trim()?t.substring(r):t).join("\n").trim()}destroy(){this.editor?.dispose(),super.destroy()}static createMonacoEditor(t={},e,i){const r=t.language;if(!r)throw new Error("Missing language in editorOptions");const n=this.createMonacoModel(i,r,t.value||"");return i.editor.create(e,{...t,model:n})}static createMonacoModel(t,e,i){const r=Math.random().toString(36).substring(2,15);return t.editor.createModel(i,e,t.Uri.parse(`file:///${e}-${r}.ts`))}static create(t,e){const i=new v(t,{});return new z(i,e)}}const P={editors:{selector:"[data-js-exhibition-editor]",multiple:!0,required:!1,Class:z,args:[]},preview:{selector:"iframe[data-js-exhibition-preview]",multiple:!1,required:!0,Class:class extends O{alterers=[];currentBlobUrl=null;addDocumentAlterer(t,e=0){this.alterers.push({callback:t,priority:e})}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=()=>{setTimeout(()=>{this.updateHeight()},100),this.node.onload=null}}updateHeight(){const t=this.getIFrameWindow(),e=this.getIFrameDocument().querySelector("html");if(!e)return;const i=t.getComputedStyle(e),r=parseFloat(i.marginTop)+parseFloat(i.marginBottom),n=Math.ceil(e.offsetHeight+r);this.node.height=n+"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}}}};class T extends O{options;constructor(t,e={}){super(t),this.options=new D(this.node,I,{updaterSelector:"[data-js-exhibition-updater]",...e},{updaterSelector:t=>"string"==typeof t});for(const t of this.children.editors)this.children.preview.addDocumentAlterer(t.getDocumentAlterer(),t.getPriority());const i=this.node.querySelectorAll(this.options.get("updaterSelector"));for(const t of i)this.core.addEventListener(t,"click",()=>{this.updatePreview()})}async init(){await this.initalizeMonacoEditors()}addEditor(t){this.children.editors.add(t),this.addPreviewAlterer(t.getDocumentAlterer(),t.getPriority())}addPreviewAlterer(t,e=0){this.children.preview.addDocumentAlterer(t,e)}getPreview(){return this.children.preview}async updatePreview(){await this.children.preview.update()}async initalizeMonacoEditors(){for(const t of this.children.editors)if(t instanceof z){if(t.isEditorInitialized())continue;await t.init()}}static async createMultiple(t,e=I,i,r={},n={}){this.validateCreateOptions(n);const s=this.createWraplets(t,i,e,[r]);for(const t of s)await this.applyCreateOptions(t,n);return s}static async create(t,e,i={},r={}){this.validateCreateOptions(r);const n=new v(t,e),s=new T(n,i);return await this.applyCreateOptions(s,r),s}static validateCreateOptions(t){if(!t.init&&t.updatePreview)throw new Error("Cannot update preview without initializing exhibitions first")}static async applyCreateOptions(t,e={}){const i={init:!0,updatePreview:!0,...e};i.init&&await t.init(),i.updatePreview&&await t.updatePreview()}static getMapWithMonacoEditor(t,e={}){const i={...e,Class:z},r=this.getMap(i);return r.editors.args=[t],r}static getMap(t){const e=P,i={selectEditors:!0,...t};return e.editors.Class=i.Class,i.selectEditors||(e.editors.selector=void 0),e}}export{T as Exhibition,z as ExhibitionMonacoEditor,S as defaultOptionsAttribute};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":"AAAA,MAAMA,UAAUC,OAAO,MAAMC,UAAUD,OAAO,MAAME,UAAUF,OAAO,MAAMG,UAAUH,OAAO,MAAMI,UAAUJ,OAAO,MAAMK,UAAUL,OAAO,MAAMM,UAAUN,OAAO,SAASO,EAAER,GAAG,OAAOS,OAAOC,eAAeV,KAAKS,OAAOE,SAAS,CAAC,MAAMC,EAAE,CAACZ,EAAEE,IAAI,iBAAiBF,GAAG,OAAOA,IAAG,IAAKA,EAAEE,GAAGW,EAAEC,OAAO,cAAc,SAASC,EAAEf,GAAG,OAAOY,EAAEZ,EAAEa,E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GACzC,MAAMe,EAAO,IAAI,EAAYtD,EAASrC,GACtC,OAAO,IAAIsQ,EAAW3K,EAAMf,EAChC,CASA,6BAAOsM,CAAuBC,EAA+BvM,EAAU,CAAC,GACpE,MAAMwM,EAAO,IACNxM,EACHrC,MAAOmH,GAEL1J,EAAMd,KAAKmS,OAAOD,GAExB,OADApR,EAAa,QAAQ,KAAI,CAACmR,GACnBnR,CACX,CAQA,aAAOqR,CAAOzM,GACV,MAAM5E,EAAMgO,EACNsD,EAAa,CAEXC,eAAe,KAEhB3M,GAMP,OAJA5E,EAAa,QAAS,MAAIsR,EAAW/O,MAChC+O,EAAWC,gBACZvR,EAAa,QAAY,cAAI8I,GAE1B9I,CACX,S","sources":["webpack://exhibitionjs/./node_modules/wraplet/dist/index.js","webpack://exhibitionjs/./node_modules/wraplet/dist/storage.js","webpack://exhibitionjs/./src/selectors.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/Exhibition.ts","webpack://exhibitionjs/./src/ExhibitionPreview.ts"],"sourcesContent":["class t extends Error{}class e extends Error{}class i extends Error{}class r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}function a(t){return Object.getPrototypeOf(t)===Object.prototype}const h=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],l=Symbol(\"WrapletSet\");function d(t){return h(t,l)}class c 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 u extends c{[p]=!0;[l]=!0}function f(t){const e=t.wraplets;return d(e)&&0!==e.size?e:new u}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}function y(t,e){e(t);const i=t.childNodes;for(const t of i)y(t,e)}function w(t){y(t,t=>{const e=f(t);for(const i of e)i.isGettingDestroyed||i.isDestroyed||i.destroy(),C(i,t)})}const g=Symbol(\"NodeTreeParent\"),m=Symbol(\"ChildrenManager\");function b(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function v(t){const e={};for(const i in t){const r=t[i];e[i]=b(r);const n=r.map;n&&a(n)&&(e[i].map=v(n))}return e}const I=Symbol(\"DynamicMap\");function E(t){return h(t,I)}class W{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 r=e[i].map;if(a(r))e=r;else{if(!E(r))throw new Error(\"Invalid map type.\");e=r.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(!a(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 W(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class M{node;[m]=!0;[g]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,i,r={}){if(this.node=t,a(i))this.mapWrapper=new W(i);else{if(!(i instanceof W))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(r),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new e(\"If the node provided cannot have children, the children map should be empty.\");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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(!d(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const s=t.selector,o=this.findChildren(s,i);if(this.validateElements(r,o,t),0===o.length)return null;if(o.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${r}\" child. Selector used: \"${s}\".`);const a=o[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new u;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new u;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new s(\"Children are already destroyed.\");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new r(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new r(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");return this.instantiatedChildren}removeChild(t,e){if(d(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.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 r=i.selector,n=i.required;if(!r&&n)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateElements(e,i,r){if(0===i.length&&r.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(d(e))for(const t of e)t.destroy();else e.destroy()}}const L=Symbol(\"Wraplet\");function D(t){return h(t,L)}const x=Symbol(\"Groupable\");class S{core;[L]=!0;[x]=!0;[g]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!h(t,m))throw new Error(\"AbstractWraplet requires a Core instance.\");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}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,r=[]){if(this===S)throw new Error(\"You cannot instantiate an abstract class.\");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=S.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=S.createCore(t,e);n.push(new this(i,...r))}return n}}class z{levels;[I]=!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 z(t)}}class O extends c{[p]=!0}export{S as AbstractWraplet,M as DefaultCore,u as DefaultWrapletSet,O as DefaultWrapletSetReadonly,z as MapRepeat,w as destroyWrapletsRecursively,f as getWrapletsFromNode,D as isWraplet};\n//# sourceMappingURL=index.js.map","class t extends Error{}class e{element;attribute;defaults;validators;data;options;constructor(t,e,s,i,r={}){this.element=t,this.attribute=e,this.defaults=s,this.validators=i,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...r},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,s)=>(t[s]=e[s],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(e,s){if(!this.validators[e](s))throw new t(`Attempted to set an invalid value for the key ${String(e)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[e]=s,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const s of t)delete e[s];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const e=this.getAttributeValue(this.attribute);if(\"{\"!==e.charAt(0))throw new t(\"Data has to be defined as an object.\");const s=JSON.parse(e);if(!this.validateData(s))throw new t(\"Invalid storage value.\");return this.options.elementOptionsMerger(this.defaults,s)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if(\"function\"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||\"{}\"}}export{e as ElementStorage};\n//# sourceMappingURL=storage.js.map","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\nexport const defaultOptionsAttribute = \"data-js-options\";\n","export 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};\nexport function getTypeFromLanguage(language) {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language)) {\n return key;\n }\n }\n throw new Error(\"Unknown language\");\n}\nexport function getTagFromType(type) {\n return typeMap[type].tag;\n}\nexport function isSingleTagValue(item) {\n return Boolean(getTagFromType(item.type));\n}\nexport function isSingleTagType(type) {\n return Boolean(getTagFromType(type));\n}\n","import { AbstractWraplet, DefaultCore } from \"wraplet\";\nimport { ElementStorage } from \"wraplet/storage\";\nimport { defaultOptionsAttribute } from \"./selectors\";\nimport { getTagFromType, getTypeFromLanguage, isSingleTagType, } from \"./TypeMap\";\nexport class ExhibitionMonacoEditor extends AbstractWraplet {\n monaco;\n editor = null;\n options;\n constructor(core, options) {\n super(core);\n const defaultOptions = {\n optionsAttribute: \"data-js-options\",\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n const validators = {\n optionsAttribute: (data) => typeof data === \"string\",\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data) => typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data) => Number.isInteger(data),\n tagAttributes: (data) => typeof data === \"object\",\n trimDefaultValue: (data) => typeof data === \"boolean\",\n monacoEditorCreator: (data) => typeof data === \"function\",\n monaco: (data) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n this.options = new ElementStorage(this.node, defaultOptionsAttribute, { ...defaultOptions, ...options }, validators, {\n elementOptionsMerger: (defaults, options) => {\n options.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n return { ...defaults, ...options };\n },\n });\n this.monaco = this.options.get(\"monaco\");\n if (this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(monacoOptions.value);\n this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n this.validateOptions();\n }\n isEditorInitialized() {\n return this.editor !== null;\n }\n async init() {\n const editorCreator = this.options.get(\"monacoEditorCreator\") ||\n (async (options, element, monaco) => ExhibitionMonacoEditor.createMonacoEditor(options, element, monaco));\n this.editor = await editorCreator(this.options.get(\"monacoEditorOptions\"), this.node, this.monaco);\n }\n getPriority() {\n return this.options.get(\"priority\");\n }\n /**\n * Returns the current value of the editor.\n */\n getValue() {\n return this.getEditor().getValue();\n }\n async alterDocument(document) {\n const language = this.getLanguage();\n const content = language === \"typescript\" ? await this.getTSValueAsJS() : this.getValue();\n const location = this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = 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 getDocumentAlterer() {\n return this.alterDocument.bind(this);\n }\n /**\n * Additional validation.\n */\n validateOptions() {\n if (!this.options.get(\"monacoEditorOptions\").language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (this.options.get(\"tagAttributes\")) {\n throw new Error(\"'tagAttributes' option is only allowed for single tag types\");\n }\n }\n }\n getEditor() {\n if (!this.editor)\n throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n async getTSValueAsJS() {\n const model = this.getEditor().getModel();\n if (!model)\n throw new Error(\"Model is not available\");\n // Make sure TypeScript eager sync is enabled\n this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\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 // Get worker getter\n const getWorker = async (attempts = 10) => {\n try {\n return await this.monaco.languages.typescript.getTypeScriptWorker();\n }\n catch (error) {\n if (error !== \"TypeScript not registered!\")\n throw error;\n if (attempts <= 0)\n return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n const worker = await workerGetter(uri);\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 }\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 // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length)\n throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n getLanguage() {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n return monacoOptions[\"language\"];\n }\n static trimDefaultValue(content) {\n const lines = content.split(\"\\n\");\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\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 (line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\") {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n destroy() {\n this.editor?.dispose();\n super.destroy();\n }\n /**\n * Helper method creating a new monaco editor instance.\n */\n static createMonacoEditor(editorOptions = {}, node, monaco) {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n const model = this.createMonacoModel(monaco, language, editorOptions.value || \"\");\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n /**\n * Helper method creating a new monaco model instance.\n */\n static createMonacoModel(monaco, language, value) {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(value, language, monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`));\n }\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n static create(element, options) {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","import { AbstractWraplet, DefaultCore, } from \"wraplet\";\nimport { ExhibitionPreview } from \"./ExhibitionPreview\";\nimport { ExhibitionMonacoEditor, } from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { ElementStorage } from \"wraplet/storage\";\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\",\n multiple: true,\n required: false,\n Class: ExhibitionMonacoEditor,\n args: [],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview,\n },\n};\nexport class Exhibition extends AbstractWraplet {\n options;\n constructor(core, options = {}) {\n super(core);\n const defaultOptions = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n this.options = new ElementStorage(this.node, exhibitionDefaultAttribute, { ...defaultOptions, ...options }, {\n updaterSelector: (data) => typeof data === \"string\",\n });\n for (const editor of this.children.editors) {\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n const updaterElements = this.node.querySelectorAll(this.options.get(\"updaterSelector\"));\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n }\n async init() {\n await this.initalizeMonacoEditors();\n }\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n addEditor(editor) {\n this.children.editors.add(editor);\n this.addPreviewAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n addPreviewAlterer(alterer, priority = 0) {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n getPreview() {\n return this.children.preview;\n }\n async updatePreview() {\n await this.children.preview.update();\n }\n async initalizeMonacoEditors() {\n for (const editor of this.children.editors) {\n if (editor instanceof ExhibitionMonacoEditor) {\n if (editor.isEditorInitialized()) {\n continue;\n }\n await editor.init();\n }\n }\n }\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param attribute Attribute to use for Exhibition instances.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param init Initialize exhibitions after they're created.\n * @param updatePreview Update preview of each exhibition after it's initialized.\n * @returns Array of Exhibition instances.\n */\n static async createMultiple(node, attribute = exhibitionDefaultAttribute, map, options = {}, init = true, updatePreview = true) {\n if (!init && updatePreview) {\n throw new Error(\"Cannot update preview without initializing exhibitions first\");\n }\n const exhibitions = this.createWraplets(node, map, attribute, [options]);\n if (init) {\n await Promise.all(exhibitions.map((exhibition) => exhibition.init()));\n }\n if (updatePreview) {\n await Promise.all(exhibitions.map((exhibition) => exhibition.updatePreview()));\n }\n return exhibitions;\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 */\n static async create(element, map, options = {}) {\n const core = new DefaultCore(element, map);\n return new Exhibition(core, options);\n }\n /**\n * Returns a dependency map with editors being instances of ExhibitionMonacoEditor.\n *\n * @param exhibitionMonacoEditorOptions\n * MonacoEditorOptions to pass to the ExhibitionMonacoEditor.\n * @param options\n * Map options.\n */\n static getMapWithMonacoEditor(exhibitionMonacoEditorOptions, options = {}) {\n const opts = {\n ...options,\n Class: ExhibitionMonacoEditor,\n };\n const map = this.getMap(opts);\n map[\"editors\"][\"args\"] = [exhibitionMonacoEditorOptions];\n return map;\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 options\n * Map options.\n */\n static getMap(options) {\n const map = ExhibitionMap;\n const allOptions = {\n ...{\n selectEditors: true,\n },\n ...options,\n };\n map[\"editors\"][\"Class\"] = allOptions.Class;\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n return map;\n }\n}\n","import { AbstractWraplet } from \"wraplet\";\nexport class ExhibitionPreview extends AbstractWraplet {\n alterers = [];\n currentBlobUrl = null;\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 addDocumentAlterer(alterer, priority = 0) {\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n async update() {\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 // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\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 this.node.onload = () => {\n // Wait for the document to render before calculating the height.\n // @todo This should be configurable.\n setTimeout(() => {\n this.updateHeight();\n }, 100);\n this.node.onload = null;\n };\n }\n /**\n * Updates preview's height to match its content.\n */\n updateHeight() {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n const styles = iframeWindow.getComputedStyle(el);\n const margin = parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n getIFrameDocument() {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n return iframeDocument;\n }\n getIFrameWindow() {\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"],"names":["t","Error","e","i","r","n","s","o","a","Object","getPrototypeOf","prototype","h","l","Symbol","d","c","Set","find","this","push","findOne","getOrdered","Array","from","sort","p","u","g","m","b","args","destructible","map","coreOptions","v","I","E","W","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","node","isDestroyed","isGettingDestroyed","isGettingInitialized","isInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","defaultWrapletCreator","element","initOptions","Class","wrapletCreator","processInitOptions","init","instantiateChildren","wrapChildren","querySelectorAll","keys","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","values","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","defaultCreator","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","destroy","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","uninitializedChildren","delete","required","Proxy","get","defaultInitOptions","assign","entries","L","x","S","core","groupsExtractor","Element","getAttribute","split","destroyListeners","__debugNodeAccessors","onChildDestroyed","bind","onChildInstantiated","initialize","setGroupsExtractor","getGroups","isChildInstance","createCore","createWraplets","hasAttribute","attribute","defaults","validators","data","keepFresh","elementOptionsMerger","fetchFreshData","has","getAll","getMultiple","reduce","refresh","set","String","getAttributeValue","JSON","parse","setAll","setMultiple","setAttribute","stringify","deleteMultiple","deleteAll","removeAttribute","charAt","validateData","console","warn","exhibitionDefaultAttribute","defaultOptionsAttribute","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","key","value","includes","getTagFromType","type","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","super","defaultOptions","optionsAttribute","location","priority","trimDefaultValue","monacoEditorOptions","Number","isInteger","tagAttributes","monacoEditorCreator","monacoOptions","validateOptions","isEditorInitialized","editorCreator","createMonacoEditor","getPriority","getValue","getEditor","alterDocument","document","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","async","attempts","getTypeScriptWorker","error","Promise","setTimeout","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","Math","random","createModel","Uri","ExhibitionMap","editors","preview","alterers","currentBlobUrl","addDocumentAlterer","alterer","update","doc","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","createObjectURL","src","onload","updateHeight","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","Exhibition","updaterSelector","updaterElements","updatePreview","initalizeMonacoEditors","addEditor","addPreviewAlterer","getPreview","createMultiple","exhibitions","all","exhibition","getMapWithMonacoEditor","exhibitionMonacoEditorOptions","opts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AER,CAYA,2BAAaoO,CAAepP,EAAMkF,EAAY4B,EAA4BxI,EAAK4E,EAAU,CAAC,EAAGmM,EAAgB,CAAC,GAC1G7R,KAAK8R,sBAAsBD,GAC3B,MAAME,EAAc/R,KAAKwH,eAAehF,EAAM1B,EAAK4G,EAAW,CAAChC,IAC/D,IAAK,MAAMsM,KAAcD,QACf/R,KAAKiS,mBAAmBD,EAAYH,GAE9C,OAAOE,CACX,CASA,mBAAahQ,CAAOoB,EAASrC,EAAK4E,EAAU,CAAC,EAAGmM,EAAgB,CAAC,GAC7D7R,KAAK8R,sBAAsBD,GAC3B,MAAMpL,EAAO,IAAI,EAAYtD,EAASrC,GAChCkR,EAAa,IAAIZ,EAAW3K,EAAMf,GAExC,aADM1F,KAAKiS,mBAAmBD,EAAYH,GACnCG,CACX,CAIA,4BAAOF,CAAsBD,GACzB,IAAKA,EAAcrO,MAAQqO,EAAcN,cACrC,MAAM,IAAIzS,MAAM,+DAExB,CAIA,+BAAamT,CAAmBD,EAAYH,EAAgB,CAAC,GACzD,MAAMnM,EAAU,CACZlC,MAAM,EACN+N,eAAe,KACZM,GAEHnM,EAAQlC,YACFwO,EAAWxO,OAEjBkC,EAAQ6L,qBACFS,EAAWT,eAEzB,CASA,6BAAOW,CAAuBC,EAA+BzM,EAAU,CAAC,GACpE,MAAM0M,EAAO,IACN1M,EACHrC,MAAOmH,GAEL1J,EAAMd,KAAKqS,OAAOD,GAExB,OADAtR,EAAa,QAAQ,KAAI,CAACqR,GACnBrR,CACX,CAQA,aAAOuR,CAAO3M,GACV,MAAM5E,EAAMgO,EACNwD,EAAa,CAEXC,eAAe,KAEhB7M,GAMP,OAJA5E,EAAa,QAAS,MAAIwR,EAAWjP,MAChCiP,EAAWC,gBACZzR,EAAa,QAAY,cAAI8I,GAE1B9I,CACX,S","sources":["webpack://exhibitionjs/./node_modules/wraplet/dist/index.js","webpack://exhibitionjs/./node_modules/wraplet/dist/storage.js","webpack://exhibitionjs/./src/selectors.ts","webpack://exhibitionjs/./src/TypeMap.ts","webpack://exhibitionjs/./src/ExhibitionMonacoEditor.ts","webpack://exhibitionjs/./src/Exhibition.ts","webpack://exhibitionjs/./src/ExhibitionPreview.ts"],"sourcesContent":["class t extends Error{}class e extends Error{}class i extends Error{}class r extends Error{}class n extends Error{}class s extends Error{}class o extends Error{}function a(t){return Object.getPrototypeOf(t)===Object.prototype}const h=(t,e)=>\"object\"==typeof t&&null!==t&&!0===t[e],l=Symbol(\"WrapletSet\");function d(t){return h(t,l)}class c 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 u extends c{[p]=!0;[l]=!0}function f(t){const e=t.wraplets;return d(e)&&0!==e.size?e:new u}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}function y(t,e){e(t);const i=t.childNodes;for(const t of i)y(t,e)}function w(t){y(t,t=>{const e=f(t);for(const i of e)i.isGettingDestroyed||i.isDestroyed||i.destroy(),C(i,t)})}const g=Symbol(\"NodeTreeParent\"),m=Symbol(\"ChildrenManager\");function b(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function v(t){const e={};for(const i in t){const r=t[i];e[i]=b(r);const n=r.map;n&&a(n)&&(e[i].map=v(n))}return e}const I=Symbol(\"DynamicMap\");function E(t){return h(t,I)}class W{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 r=e[i].map;if(a(r))e=r;else{if(!E(r))throw new Error(\"Invalid map type.\");e=r.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(!a(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 W(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class M{node;[m]=!0;[g]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,i,r={}){if(this.node=t,a(i))this.mapWrapper=new W(i);else{if(!(i instanceof W))throw new e(\"The map provided to the Core is not a valid map.\");this.mapWrapper=i}this.processInitOptions(r),this.instantiatedChildren={}}init(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if(\"function\"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new e(\"If the node provided cannot have children, the children map should be empty.\");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,n=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,n,this.node,e):this.instantiateSingleWrapletChild(i,n,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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(!d(i))throw new o(\"Internal logic error. Expected a WrapletSet.\");const t=i.find(t=>{let i=!1;return t.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,r){if(!t.selector)return null;const s=t.selector,o=this.findChildren(s,i);if(this.validateElements(r,o,t),0===o.length)return null;if(o.length>1)throw new n(`${this.constructor.name}: More than one element was found for the \"${r}\" child. Selector used: \"${s}\".`);const a=o[0];return this.instantiateWrapletItem(r,t,e,a)}instantiateWrapletItem(t,e,i,r){const n=this.findExistingWraplet(t,r);if(n)return n;const s=e.Class,o=e.args,a=this.wrapletCreator({id:t,Class:s,element:r,map:i,initOptions:e.coreOptions,args:o,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,r){const n=t.selector;if(!n)return new u;const s=this.findChildren(n,i);this.validateElements(r,s,t);const o=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new u;for(const i of s){if(this.findExistingWraplet(r,i))continue;const n=this.instantiateWrapletItem(r,t,e,i);o.add(n)}return o}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}destroy(){if(this.isDestroyed)throw new s(\"Children are already destroyed.\");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,n=t.options;e.removeEventListener(i,r,n)}this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return\"string\"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new r(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new r(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");return this.instantiatedChildren}removeChild(t,e){if(d(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.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 r=i.selector,n=i.required;if(!r&&n)throw new e(`${this.constructor.name}: Child \"${t}\" cannot at the same be required and have no selector.`)}validateElements(e,i,r){if(0===i.length&&r.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet \"${e}\". Selector used: \"${r.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)}destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(d(e))for(const t of e)t.destroy();else e.destroy()}}const L=Symbol(\"Wraplet\");function D(t){return h(t,L)}const x=Symbol(\"Groupable\");class S{core;[L]=!0;[x]=!0;[g]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute(\"data-js-wraplet-groupable\");if(e)return e.split(\",\")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!h(t,m))throw new Error(\"AbstractWraplet requires a Core instance.\");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this)),this.initialize()}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}destroy(){this.isGettingDestroyed=!0;for(const t of this.destroyListeners)t(this);this.destroyListeners.length=0,this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}initialize(){this.isGettingInitialized=!0,this.core.init(),this.isInitialized=!0,this.isGettingInitialized=!1}get node(){return this.core.node}onChildInstantiated(t,e){}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,r=[]){if(this===S)throw new Error(\"You cannot instantiate an abstract class.\");const n=[];if(t instanceof Element&&t.hasAttribute(i)){const i=S.createCore(t,e);n.push(new this(i,...r))}const s=t.querySelectorAll(`[${i}]`);for(const t of s){const i=S.createCore(t,e);n.push(new this(i,...r))}return n}}class z{levels;[I]=!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 z(t)}}class O extends c{[p]=!0}export{S as AbstractWraplet,M as DefaultCore,u as DefaultWrapletSet,O as DefaultWrapletSetReadonly,z as MapRepeat,w as destroyWrapletsRecursively,f as getWrapletsFromNode,D as isWraplet};\n//# sourceMappingURL=index.js.map","class t extends Error{}class e{element;attribute;defaults;validators;data;options;constructor(t,e,s,i,r={}){this.element=t,this.attribute=e,this.defaults=s,this.validators=i,this.options={keepFresh:!0,elementOptionsMerger:(t,e)=>({...t,...e}),...r},this.data=this.fetchFreshData()}has(t){return t in this.getAll()}get(t){return this.getAll()[t]}getMultiple(t){const e=this.getAll();return t.reduce((t,s)=>(t[s]=e[s],t),{})}getAll(){return this.options.keepFresh&&this.refresh(),this.data}set(e,s){if(!this.validators[e](s))throw new t(`Attempted to set an invalid value for the key ${String(e)}.`);const i=this.getAttributeValue(this.attribute),r=JSON.parse(i);r[e]=s,this.setAll(r)}setMultiple(t){const e=this.getAll();this.setAll({...e,...t})}setAll(t){this.element.setAttribute(this.attribute,JSON.stringify(t))}delete(t){const e=this.getAll();t in e&&(delete e[t],this.element.setAttribute(this.attribute,JSON.stringify(e)))}deleteMultiple(t){const e=this.getAll();for(const s of t)delete e[s];this.setAll(e)}deleteAll(){this.element.removeAttribute(this.attribute),this.refresh()}refresh(){this.data=this.fetchFreshData()}fetchFreshData(){const e=this.getAttributeValue(this.attribute);if(\"{\"!==e.charAt(0))throw new t(\"Data has to be defined as an object.\");const s=JSON.parse(e);if(!this.validateData(s))throw new t(\"Invalid storage value.\");return this.options.elementOptionsMerger(this.defaults,s)}validateData(t){for(const e in t){if(!(e in this.validators))return console.warn(`Option ${e} doesn't have a validator.`),!1;if(\"function\"!=typeof this.validators[e])return console.warn(`Validator for option ${e} is not a function.`),!1;if(!this.validators[e](t[e]))return!1}return!0}getAttributeValue(t){return this.element.getAttribute(t)||\"{}\"}}export{e as ElementStorage};\n//# sourceMappingURL=storage.js.map","export const exhibitionDefaultAttribute = \"data-js-exhibition\";\nexport const defaultOptionsAttribute = \"data-js-options\";\n","export 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};\nexport function getTypeFromLanguage(language) {\n for (const [key, value] of Object.entries(typeMap)) {\n if (value.languages.includes(language)) {\n return key;\n }\n }\n throw new Error(\"Unknown language\");\n}\nexport function getTagFromType(type) {\n return typeMap[type].tag;\n}\nexport function isSingleTagValue(item) {\n return Boolean(getTagFromType(item.type));\n}\nexport function isSingleTagType(type) {\n return Boolean(getTagFromType(type));\n}\n","import { AbstractWraplet, DefaultCore } from \"wraplet\";\nimport { ElementStorage } from \"wraplet/storage\";\nimport { defaultOptionsAttribute } from \"./selectors\";\nimport { getTagFromType, getTypeFromLanguage, isSingleTagType, } from \"./TypeMap\";\nexport class ExhibitionMonacoEditor extends AbstractWraplet {\n monaco;\n editor = null;\n options;\n constructor(core, options) {\n super(core);\n const defaultOptions = {\n optionsAttribute: \"data-js-options\",\n location: \"body\",\n priority: 0,\n trimDefaultValue: true,\n monacoEditorOptions: {},\n };\n const validators = {\n optionsAttribute: (data) => typeof data === \"string\",\n // We generally don't validate monacoOptions, leaving it to the monaco editor.\n location: (data) => typeof data === \"string\" && [\"head\", \"body\"].includes(data),\n priority: (data) => Number.isInteger(data),\n tagAttributes: (data) => typeof data === \"object\",\n trimDefaultValue: (data) => typeof data === \"boolean\",\n monacoEditorCreator: (data) => typeof data === \"function\",\n monaco: (data) => typeof data === \"object\",\n monacoEditorOptions: () => true,\n };\n options.monacoEditorOptions = {\n ...defaultOptions.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n this.options = new ElementStorage(this.node, defaultOptionsAttribute, { ...defaultOptions, ...options }, validators, {\n elementOptionsMerger: (defaults, options) => {\n options.monacoEditorOptions = {\n ...defaults.monacoEditorOptions,\n ...options.monacoEditorOptions,\n };\n return { ...defaults, ...options };\n },\n });\n this.monaco = this.options.get(\"monaco\");\n if (this.options.get(\"trimDefaultValue\")) {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (monacoOptions.value) {\n monacoOptions.value = ExhibitionMonacoEditor.trimDefaultValue(monacoOptions.value);\n this.options.set(\"monacoEditorOptions\", monacoOptions);\n }\n }\n this.validateOptions();\n }\n isEditorInitialized() {\n return this.editor !== null;\n }\n async init() {\n const editorCreator = this.options.get(\"monacoEditorCreator\") ||\n (async (options, element, monaco) => ExhibitionMonacoEditor.createMonacoEditor(options, element, monaco));\n this.editor = await editorCreator(this.options.get(\"monacoEditorOptions\"), this.node, this.monaco);\n }\n getPriority() {\n return this.options.get(\"priority\");\n }\n /**\n * Returns the current value of the editor.\n */\n getValue() {\n return this.getEditor().getValue();\n }\n async alterDocument(document) {\n const language = this.getLanguage();\n const content = language === \"typescript\" ? await this.getTSValueAsJS() : this.getValue();\n const location = this.options.get(\"location\");\n const type = getTypeFromLanguage(language);\n if (isSingleTagType(type)) {\n const tag = getTagFromType(type);\n const tagAttributes = 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 getDocumentAlterer() {\n return this.alterDocument.bind(this);\n }\n /**\n * Additional validation.\n */\n validateOptions() {\n if (!this.options.get(\"monacoEditorOptions\").language) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n const type = getTypeFromLanguage(this.getLanguage());\n if (!isSingleTagType(type)) {\n if (this.options.get(\"tagAttributes\")) {\n throw new Error(\"'tagAttributes' option is only allowed for single tag types\");\n }\n }\n }\n getEditor() {\n if (!this.editor)\n throw new Error(\"Editor is not initialized\");\n return this.editor;\n }\n async getTSValueAsJS() {\n const model = this.getEditor().getModel();\n if (!model)\n throw new Error(\"Model is not available\");\n // Make sure TypeScript eager sync is enabled\n this.monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);\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 // Get worker getter\n const getWorker = async (attempts = 10) => {\n try {\n return await this.monaco.languages.typescript.getTypeScriptWorker();\n }\n catch (error) {\n if (error !== \"TypeScript not registered!\")\n throw error;\n if (attempts <= 0)\n return null;\n await new Promise((r) => setTimeout(r, 200));\n return getWorker(attempts - 1);\n }\n };\n const workerGetter = await getWorker();\n if (!workerGetter)\n throw new Error(\"Timeout: Could not get TypeScript worker\");\n const worker = await workerGetter(uri);\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 }\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 // Now it's safe to call getEmitOutput\n const { outputFiles } = await worker.getEmitOutput(uri.toString());\n if (!outputFiles.length)\n throw new Error(\"No JS output produced\");\n return outputFiles[0].text;\n }\n getLanguage() {\n const monacoOptions = this.options.get(\"monacoEditorOptions\");\n if (!monacoOptions[\"language\"]) {\n throw new Error(\"Missing language in monacoOptions\");\n }\n return monacoOptions[\"language\"];\n }\n static trimDefaultValue(content) {\n const lines = content.split(\"\\n\");\n // Find the first non-empty line to determine base indentation\n const firstNonEmptyLine = lines.find((line) => line.trim().length > 0);\n if (!firstNonEmptyLine) {\n return content.trim();\n }\n // Count leading spaces on the first non-empty line\n const leadingSpaces = firstNonEmptyLine.search(/\\S|$/);\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 (line.length >= leadingSpaces &&\n line.substring(0, leadingSpaces).trim() === \"\") {\n return line.substring(leadingSpaces);\n }\n return line;\n });\n // Join back and trim any leading/trailing empty lines\n return trimmedLines.join(\"\\n\").trim();\n }\n destroy() {\n this.editor?.dispose();\n super.destroy();\n }\n /**\n * Helper method creating a new monaco editor instance.\n */\n static createMonacoEditor(editorOptions = {}, node, monaco) {\n const language = editorOptions.language;\n if (!language) {\n throw new Error(\"Missing language in editorOptions\");\n }\n const model = this.createMonacoModel(monaco, language, editorOptions.value || \"\");\n return monaco.editor.create(node, {\n ...editorOptions,\n ...{ model: model },\n });\n }\n /**\n * Helper method creating a new monaco model instance.\n */\n static createMonacoModel(monaco, language, value) {\n // Generate a unique URI for each model instance\n const uniqueId = Math.random().toString(36).substring(2, 15);\n return monaco.editor.createModel(value, language, monaco.Uri.parse(`file:///${language}-${uniqueId}.ts`));\n }\n /**\n * Create a single ExhibitionMonacoEditor instance wrapping a given element.\n */\n static create(element, options) {\n const core = new DefaultCore(element, {});\n return new ExhibitionMonacoEditor(core, options);\n }\n}\n","import { AbstractWraplet, DefaultCore, } from \"wraplet\";\nimport { ExhibitionPreview } from \"./ExhibitionPreview\";\nimport { ExhibitionMonacoEditor, } from \"./ExhibitionMonacoEditor\";\nimport { exhibitionDefaultAttribute } from \"./selectors\";\nimport { ElementStorage } from \"wraplet/storage\";\nconst ExhibitionMap = {\n editors: {\n selector: \"[data-js-exhibition-editor]\",\n multiple: true,\n required: false,\n Class: ExhibitionMonacoEditor,\n args: [],\n },\n preview: {\n selector: \"iframe[data-js-exhibition-preview]\",\n multiple: false,\n required: true,\n Class: ExhibitionPreview,\n },\n};\nexport class Exhibition extends AbstractWraplet {\n options;\n constructor(core, options = {}) {\n super(core);\n const defaultOptions = {\n updaterSelector: \"[data-js-exhibition-updater]\",\n };\n this.options = new ElementStorage(this.node, exhibitionDefaultAttribute, { ...defaultOptions, ...options }, {\n updaterSelector: (data) => typeof data === \"string\",\n });\n for (const editor of this.children.editors) {\n this.children.preview.addDocumentAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n const updaterElements = this.node.querySelectorAll(this.options.get(\"updaterSelector\"));\n for (const element of updaterElements) {\n this.core.addEventListener(element, \"click\", () => {\n this.updatePreview();\n });\n }\n }\n async init() {\n await this.initalizeMonacoEditors();\n }\n /**\n * Adds DocumentAltererProviderWraplet instance to the list of editors.\n */\n addEditor(editor) {\n this.children.editors.add(editor);\n this.addPreviewAlterer(editor.getDocumentAlterer(), editor.getPriority());\n }\n /**\n * Adds a simple DocumentAlterer to the preview.\n */\n addPreviewAlterer(alterer, priority = 0) {\n this.children.preview.addDocumentAlterer(alterer, priority);\n }\n getPreview() {\n return this.children.preview;\n }\n async updatePreview() {\n await this.children.preview.update();\n }\n async initalizeMonacoEditors() {\n for (const editor of this.children.editors) {\n if (editor instanceof ExhibitionMonacoEditor) {\n if (editor.isEditorInitialized()) {\n continue;\n }\n await editor.init();\n }\n }\n }\n /**\n * Create multiple Exhibitions.\n *\n * @param node Node to create Exhibitions on.\n * @param attribute Attribute to use for Exhibition instances.\n * @param map Map of dependencies for each Exhibition instance.\n * @param options Options for Exhibition instances.\n * @param createOptions Options related to the creation process of the Exhibitions.\n *\n * @returns Array of Exhibition instances.\n */\n static async createMultiple(node, attribute = exhibitionDefaultAttribute, map, options = {}, createOptions = {}) {\n this.validateCreateOptions(createOptions);\n const exhibitions = this.createWraplets(node, map, attribute, [options]);\n for (const exhibition of exhibitions) {\n await this.applyCreateOptions(exhibition, createOptions);\n }\n return exhibitions;\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 createOptions Options related to the creation process of the Exhibitions.\n */\n static async create(element, map, options = {}, createOptions = {}) {\n this.validateCreateOptions(createOptions);\n const core = new DefaultCore(element, map);\n const exhibition = new Exhibition(core, options);\n await this.applyCreateOptions(exhibition, createOptions);\n return exhibition;\n }\n /**\n * Validate create options.\n */\n static validateCreateOptions(createOptions) {\n if (!createOptions.init && createOptions.updatePreview) {\n throw new Error(\"Cannot update preview without initializing exhibitions first\");\n }\n }\n /**\n * Create options.\n */\n static async applyCreateOptions(exhibition, createOptions = {}) {\n const options = {\n init: true,\n updatePreview: true,\n ...createOptions,\n };\n if (options.init) {\n await exhibition.init();\n }\n if (options.updatePreview) {\n await exhibition.updatePreview();\n }\n }\n /**\n * Returns a dependency map with editors being instances of ExhibitionMonacoEditor.\n *\n * @param exhibitionMonacoEditorOptions\n * MonacoEditorOptions to pass to the ExhibitionMonacoEditor.\n * @param options\n * Map options.\n */\n static getMapWithMonacoEditor(exhibitionMonacoEditorOptions, options = {}) {\n const opts = {\n ...options,\n Class: ExhibitionMonacoEditor,\n };\n const map = this.getMap(opts);\n map[\"editors\"][\"args\"] = [exhibitionMonacoEditorOptions];\n return map;\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 options\n * Map options.\n */\n static getMap(options) {\n const map = ExhibitionMap;\n const allOptions = {\n ...{\n selectEditors: true,\n },\n ...options,\n };\n map[\"editors\"][\"Class\"] = allOptions.Class;\n if (!allOptions.selectEditors) {\n map[\"editors\"][\"selector\"] = undefined;\n }\n return map;\n }\n}\n","import { AbstractWraplet } from \"wraplet\";\nexport class ExhibitionPreview extends AbstractWraplet {\n alterers = [];\n currentBlobUrl = null;\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 addDocumentAlterer(alterer, priority = 0) {\n this.alterers.push({\n callback: alterer,\n priority: priority,\n });\n }\n async update() {\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 // Revoke previous blob URL\n if (this.currentBlobUrl) {\n URL.revokeObjectURL(this.currentBlobUrl);\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 this.node.onload = () => {\n // Wait for the document to render before calculating the height.\n // @todo This should be configurable.\n setTimeout(() => {\n this.updateHeight();\n }, 100);\n this.node.onload = null;\n };\n }\n /**\n * Updates preview's height to match its content.\n */\n updateHeight() {\n const iframeWindow = this.getIFrameWindow();\n const iframeDocument = this.getIFrameDocument();\n const el = iframeDocument.querySelector(\"html\");\n if (!el) {\n return;\n }\n const styles = iframeWindow.getComputedStyle(el);\n const margin = parseFloat(styles[\"marginTop\"]) + parseFloat(styles[\"marginBottom\"]);\n const height = Math.ceil(el.offsetHeight + margin);\n this.node.height = height + \"px\";\n }\n getIFrameDocument() {\n const iframeDocument = this.node.contentDocument;\n if (!iframeDocument) {\n throw new Error(\"IFrame document is not available.\");\n }\n return iframeDocument;\n }\n getIFrameWindow() {\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"],"names":["t","Error","e","i","r","n","s","o","a","Object","getPrototypeOf","prototype","h","l","Symbol","d","c","Set","find","this","push","findOne","getOrdered","Array","from","sort","p","u","g","m","b","args","destructible","map","coreOptions","v","I","E","W","fullMap","startingPath","currentMap","path","currentPath","constructor","resolve","getStartingMap","getCurrentMap","findMap","join","create","clone","up","pathExists","hasOwn","down","length","pop","M","node","isDestroyed","isGettingDestroyed","isGettingInitialized","isInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","defaultWrapletCreator","element","initOptions","Class","wrapletCreator","processInitOptions","init","instantiateChildren","wrapChildren","querySelectorAll","keys","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","values","children","filter","accessNode","contains","findExistingWraplet","selector","findChildren","validateElements","name","instantiateWrapletItem","id","defaultCreator","prepareIndividualWraplet","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","destroy","eventName","callback","options","removeEventListener","destroyChildren","addEventListener","uninitializedChildren","delete","required","Proxy","get","defaultInitOptions","assign","entries","L","x","S","core","groupsExtractor","Element","getAttribute","split","destroyListeners","__debugNodeAccessors","onChildDestroyed","bind","onChildInstantiated","initialize","setGroupsExtractor","getGroups","isChildInstance","createCore","createWraplets","hasAttribute","attribute","defaults","validators","data","keepFresh","elementOptionsMerger","fetchFreshData","has","getAll","getMultiple","reduce","refresh","set","String","getAttributeValue","JSON","parse","setAll","setMultiple","setAttribute","stringify","deleteMultiple","deleteAll","removeAttribute","charAt","validateData","console","warn","exhibitionDefaultAttribute","defaultOptionsAttribute","typeMap","html","languages","tag","undefined","js","css","getTypeFromLanguage","language","key","value","includes","getTagFromType","type","isSingleTagType","Boolean","ExhibitionMonacoEditor","monaco","editor","super","defaultOptions","optionsAttribute","location","priority","trimDefaultValue","monacoEditorOptions","Number","isInteger","tagAttributes","monacoEditorCreator","monacoOptions","validateOptions","isEditorInitialized","editorCreator","createMonacoEditor","getPriority","getValue","getEditor","alterDocument","document","getLanguage","content","getTSValueAsJS","tagElement","createElement","innerHTML","appendChild","getDocumentAlterer","model","getModel","typescript","typescriptDefaults","setEagerModelSync","uri","scheme","toString","getWorker","async","attempts","getTypeScriptWorker","error","Promise","setTimeout","workerGetter","worker","getSemanticDiagnostics","err","test","outputFiles","getEmitOutput","text","lines","firstNonEmptyLine","line","trim","leadingSpaces","search","substring","dispose","editorOptions","createMonacoModel","uniqueId","Math","random","createModel","Uri","ExhibitionMap","editors","preview","alterers","currentBlobUrl","addDocumentAlterer","alterer","update","doc","implementation","createHTMLDocument","URL","revokeObjectURL","htmlContent","documentElement","outerHTML","blob","Blob","createObjectURL","src","onload","updateHeight","iframeWindow","getIFrameWindow","el","getIFrameDocument","querySelector","styles","getComputedStyle","margin","parseFloat","height","ceil","offsetHeight","iframeDocument","contentDocument","window","contentWindow","Exhibition","updaterSelector","updaterElements","updatePreview","initalizeMonacoEditors","addEditor","addPreviewAlterer","getPreview","createMultiple","createOptions","validateCreateOptions","exhibitions","exhibition","applyCreateOptions","getMapWithMonacoEditor","exhibitionMonacoEditorOptions","opts","getMap","allOptions","selectEditors"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exhibitionjs",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Library for showcasing your js/ts code snippets.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",