@aegis-framework/pandora 0.1.7 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +746 -27
- package/dist/pandora.browser.js +10 -0
- package/dist/pandora.browser.js.map +14 -0
- package/dist/pandora.js +10 -806
- package/dist/pandora.js.map +13 -1
- package/dist/types/Component.d.ts +266 -0
- package/dist/types/Component.d.ts.map +1 -0
- package/dist/types/Registry.d.ts +276 -0
- package/dist/types/Registry.d.ts.map +1 -0
- package/dist/types/ShadowComponent.d.ts +35 -0
- package/dist/types/ShadowComponent.d.ts.map +1 -0
- package/dist/types/Types.d.ts +9 -0
- package/dist/types/Types.d.ts.map +1 -0
- package/dist/types/Util.d.ts +16 -0
- package/dist/types/Util.d.ts.map +1 -0
- package/dist/types/browser.d.ts +7 -0
- package/dist/types/browser.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +41 -22
- package/dist/pandora.min.js +0 -10
- package/dist/pandora.min.js.map +0 -1
- package/index.js +0 -3
- package/src/Component.js +0 -502
- package/src/Registry.js +0 -74
- package/src/ShadowComponent.js +0 -47
- package/src/Util.js +0 -66
package/dist/pandora.js.map
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
{"version":3,"sources":["src/Util.js","src/Component.js","src/ShadowComponent.js","index.js"],"names":["callAsync","callable","context","args","result","apply","Promise","resolve","e","reject","deserializeCSS","object","encapsulation","level","keys","Object","css","key","indexOf","replace","properties","property","repeat","temp","Component","HTMLElement","tag","_tag","name","matches","match","toLowerCase","slice","value","template","html","_template","document","querySelectorAll","forEach","instance","_isReady","forceRender","call","constructor","_children","innerHTML","trim","_state","_props","_ready","_connected","_style","_styleElement","width","parseInt","getComputedStyle","style","height","static","Proxy","Error","props","get","target","hasAttribute","getAttribute","isNaN","parseFloat","set","assign","state","dom","register","window","customElements","define","_createStyleElement","sharedStyle","body","querySelector","HTMLStyleElement","createElement","id","prepend","setStyle","reset","setState","oldState","updateCallback","TypeError","setProps","oldProps","_setPropAttributes","update","_explicitPropTypes","setAttribute","willUpdate","origin","oldValue","newValue","oldObject","newObject","didUpdate","onStateUpdate","onPropsUpdate","willMount","didMount","willUnmount","unmount","didUnmount","_render","render","then","slot","replaceWith","connectedCallback","dataset","component","callback","ready","push","disconnectedCallback","promise","catch","console","error","attributeChangedCallback","undefined","ShadowComponent","_shadowDOM","attachShadow","mode","appendChild"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAMO,SAASA,SAAT,CAAoBC,QAApB,EAA8BC,OAA9B,EAAuC,GAAGC,IAA1C,EAAgD;AACtD,MAAI;AACH;AACA,UAAMC,MAAM,GAAGH,QAAQ,CAACI,KAAT,CAAgBH,OAAhB,EAAyBC,IAAzB,CAAf,CAFG,CAIH;;AACA,QAAIC,MAAM,YAAYE,OAAtB,EAA+B;AAC9B,aAAOF,MAAP;AACA,KAFD,MAEO;AACN,aAAOE,OAAO,CAACC,OAAR,CAAiBH,MAAjB,CAAP;AACA;AACD,GAVD,CAUE,OAAOI,CAAP,EAAU;AACX,WAAOF,OAAO,CAACG,MAAR,CAAgBD,CAAhB,CAAP;AACA;AACD;AAED;;;;;;;;AAMO,SAASE,cAAT,CAAyBC,MAAzB,EAAiCC,aAAa,GAAG,EAAjD,EAAqDC,KAAK,GAAG,CAA7D,EAAkE;AACxE,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAaH,MAAb,CAAb;AAEA,MAAIK,GAAG,GAAG,EAAV;;AAEA,OAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;AACvB,QAAI,OAAOH,MAAM,CAACM,GAAD,CAAb,KAAuB,QAA3B,EAAqC;AACpC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AACA,WAAO,qBAAW8E,MAAX,EAAmB,IAAnB,EAAyBC,IAAzB,CAAgC9E,IAAD,IAAU;AAC/C,WAAK+F,UAAL,CAAgBpF,SAAhB,GAA4B,EAA5B;;AACA,UAAI,KAAKO,aAAL,YAA8B4B,gBAAlC,EAAoD;AACnD,aAAKiD,UAAL,CAAgBG,WAAhB,CAA6B,KAAKhF,aAAlC;AACA;;AACD,WAAK6E,UAAL,CAAgBpF,SAAhB,IAA6BX,IAA7B;AACA,KANM,CAAP;AAOA;;AAED,MAAIqC,GAAJ,GAAW;AACV,WAAO,KAAK0D,UAAZ;AACA;;AArC6C;;;;;;;;;;ACN/C;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","file":"pandora.js","sourceRoot":"..","sourcesContent":["/**\n *\n * @param {*} callable\n * @param {*} context\n * @param {...any} args\n */\nexport function callAsync (callable, context, ...args) {\n\ttry {\n\t\t// Call the provided function using the context and arguments given\n\t\tconst result = callable.apply (context, args);\n\n\t\t// Check if the function returned a simple value or a Promise\n\t\tif (result instanceof Promise) {\n\t\t\treturn result;\n\t\t} else {\n\t\t\treturn Promise.resolve (result);\n\t\t}\n\t} catch (e) {\n\t\treturn Promise.reject (e);\n\t}\n}\n\n/**\n *\n * @param {*} object\n * @param {*} encapsulation\n * @param {*} level\n */\nexport function deserializeCSS (object, encapsulation = '', level = 0, ) {\n\tconst keys = Object.keys (object);\n\n\tlet css = '';\n\n\tfor (const key of keys) {\n\t\tif (typeof object[key] === 'object') {\n\t\t\tif (encapsulation) {\n\t\t\t\tif (key.indexOf ('&') === 0) {\n\t\t\t\t\tcss += `${key.replace(/&/g, encapsulation)} {\\n`;\n\t\t\t\t} else {\n\t\t\t\t\tcss += `${encapsulation} ${key} {\\n`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcss += `${key} {\\n`;\n\t\t\t}\n\n\t\t\tconst properties = Object.keys (object[key]);\n\t\t\tfor (const property of properties) {\n\t\t\t\tcss += '\\t'.repeat (level);\n\t\t\t\tif (typeof object[key][property] === 'object') {\n\t\t\t\t\tconst temp = {};\n\t\t\t\t\ttemp[property] = object[key][property];\n\n\t\t\t\t\tcss += deserializeCSS (temp, encapsulation, level + 1);\n\t\t\t\t} else {\n\t\t\t\t\tcss += `\\t${property}: ${object[key][property]};\\n`;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcss += '}\\n';\n\t\t} else {\n\t\t\tcss += '\\t'.repeat (level);\n\t\t\tcss += `\\t${key}: ${object[key]};\\n`;\n\t\t}\n\t}\n\n\treturn css;\n}\n","/* eslint-disable no-unused-vars */\nimport { callAsync, deserializeCSS } from './Util';\n\n/**\n * A component represents a custom HTML element, and has all of its functionality\n * as well as its general structure and representation self contained on it.\n *\n * @class Component\n */\nexport class Component extends HTMLElement {\n\n\t/**\n\t * _tag {String} - The tag name for the component\n\t *\n\t * @static\n\t */\n\tstatic _tag;\n\n\tstatic get tag () {\n\t\tif (typeof this._tag === 'undefined') {\n\t\t\tlet tag = this.name;\n\t\t\tconst matches = tag.match (/([A-Z])/g);\n\t\t\tif (matches !== null) {\n\t\t\t\tfor (const match of matches) {\n\t\t\t\t\ttag = tag.replace (match, `-${match}`.toLowerCase ());\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._tag = tag.slice (1);\n\t\t}\n\t\treturn this._tag;\n\t}\n\n\tstatic set tag (value) {\n\t\tthis._tag = value;\n\t}\n\n\t/**\n\t * These are the types that can be set as properties on the HTML code of the\n\t * element.\n\t */\n\tstatic _explicitPropTypes = ['boolean', 'string', 'number'];\n\n\t/**\n\t *\n\t *\n\t * @static\n\t */\n\tstatic _template = undefined;\n\n\tstatic template (html = null, context = null) {\n\t\tif (html !== null) {\n\t\t\tthis._template = html;\n\t\t\tdocument.querySelectorAll(this.tag).forEach((instance) => {\n\t\t\t\tif (instance._isReady) {\n\t\t\t\t\tinstance.forceRender ();\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\n\t\t\t// Check if no parameters were set but the HTML is still a function to be called\n\t\t\tif (typeof this._template === 'function') {\n\t\t\t\treturn this._template.call (context);\n\t\t\t}\n\n\t\t\t// If this is reached, the HTML was just a string\n\t\t\treturn this._template;\n\t\t}\n\t}\n\n\tconstructor () {\n\t\tsuper ();\n\t\tthis._children = this.innerHTML.trim ();\n\n\t\t// State Object for the component\n\t\tthis._state = {};\n\n\t\t// Props Object for the component\n\t\tthis._props = {};\n\n\t\t// List of callbacks to run once the component has been mounted successfully\n\t\tthis._ready = [];\n\n\t\tthis._connected = false;\n\t\tthis._isReady = false;\n\n\t\tthis._style = {};\n\n\t\tthis._styleElement = null;\n\t}\n\n\t/**\n\t * width - Determines the real (computed) width of the element\n\t *\n\t * @return {int} - Computed Width of the element on pixels\n\t */\n\tget width () {\n\t\treturn parseInt (getComputedStyle (this).width.replace ('px', ''));\n\t}\n\n\tset width (value) {\n\t\tthis.style.width = value;\n\t}\n\n\t/**\n\t * height - Determines the real (computed) height of the element\n\t *\n\t * @return {int} - Computed height of the element on pixels\n\t */\n\tget height () {\n\t\treturn parseInt (getComputedStyle(this).height.replace ('px', ''));\n\t}\n\n\tset height (value) {\n\t\tthis.style.height = value;\n\t}\n\n\tget static () {\n\t\treturn new Proxy (this.constructor, {});\n\t}\n\n\tset static (value) {\n\t\tthrow new Error ('Component static properties cannot be reassigned.');\n\t}\n\n\tget props () {\n\t\treturn new Proxy (this, {\n\t\t\tget: (target, key) => {\n\t\t\t\tif (this.hasAttribute (key)) {\n\t\t\t\t\tlet value = this.getAttribute (key);\n\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\tif (value === 'false') {\n\t\t\t\t\t\t\tvalue = false;\n\t\t\t\t\t\t} else if (value === 'true' || value === '') {\n\t\t\t\t\t\t\tvalue = true;\n\t\t\t\t\t\t} else if (!isNaN (value)) {\n\t\t\t\t\t\t\tif (value.indexOf ('.') > 0) {\n\t\t\t\t\t\t\t\tvalue = parseFloat (value);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvalue = parseInt (value);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn value;\n\t\t\t\t} else if (key in this._props) {\n\t\t\t\t\treturn this._props[key];\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tset: (target, key, value) => {\n\t\t\t\tthrow new Error ('Component props should be set using the `setProps` function.');\n\t\t\t}\n\t\t});\n\t}\n\n\tset props (value) {\n\t\tif (this._connected === false) {\n\t\t\tthis._props = Object.assign ({}, this._props, value);\n\t\t} else {\n\t\t\tthrow new Error ('Component props cannot be directly assigned. Use the `setProps` function instead.');\n\t\t}\n\t}\n\n\tget state () {\n\t\treturn new Proxy (this._state, {\n\t\t\tget: (target, key) => {\n\t\t\t\treturn target[key];\n\t\t\t},\n\t\t\tset: (target, key, value) => {\n\t\t\t\tif (this._connected === false) {\n\t\t\t\t\treturn target[key] = value;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error ('Component state should be set using the `setState` function instead.');\n\t\t\t\t}\n\n\t\t\t}\n\t\t});\n\t}\n\n\tset state (value) {\n\t\tif (this._connected === false) {\n\t\t\tthis._state = Object.assign ({}, this._state, value);\n\t\t} else {\n\t\t\tthrow new Error ('Component state should be set using the `setState` function instead.');\n\t\t}\n\t}\n\n\tget dom () {\n\t\treturn this;\n\t}\n\n\tset dom (value) {\n\t\tthrow new Error ('Component DOM can not be overwritten.');\n\t}\n\n\t/**\n\t * register - Register the component as a custom HTML element\n\t * using the component's tag as the actual element tag.\n\t *\n\t * This action cannot be reverted nor the controller class for\n\t * the element can be changed.\n\t */\n\tstatic register () {\n\t\twindow.customElements.define (this.tag, this);\n\t}\n\n\t/**\n\t * template - A simple function providing access to the basic HTML\n\t * structure of the component.\n\t *\n\t * @param {function|string} html - A string or function that renders the\n\t * component into a valid HTML structure.\n\t *\n\t * @returns {void|string} - Void or the HTML structure in a string\n\t */\n\ttemplate (html = null) {\n\t\treturn this.static.template (html, this);\n\t}\n\n\t_createStyleElement () {\n\t\tconst sharedStyle = document.body.querySelector (`style#${this.static.tag}`);\n\n\t\tif (sharedStyle !== null) {\n\t\t\tthis._styleElement = sharedStyle;\n\t\t}\n\n\t\tif (!(this._styleElement instanceof HTMLStyleElement)) {\n\t\t\tthis._styleElement = document.createElement ('style');\n\t\t\tthis._styleElement.id = this.static.tag;\n\t\t\tdocument.body.prepend (this._styleElement);\n\t\t}\n\t}\n\n\tsetStyle (style, reset = false) {\n\t\tthis._createStyleElement ();\n\n\t\tif (typeof style === 'object') {\n\t\t\tif (reset === false) {\n\t\t\t\tthis._style = Object.assign ({}, this._style, style);\n\t\t\t} else {\n\t\t\t\tthis._style = Object.assign ({}, style);\n\t\t\t}\n\t\t\tthis._styleElement.innerHTML = deserializeCSS (this._style, this.static.tag);\n\t\t} else if (typeof style === 'string') {\n\t\t\tif (reset === false) {\n\t\t\t\tthis._styleElement.innerHTML += style;\n\t\t\t} else {\n\t\t\t\tthis._styleElement.innerHTML = style;\n\t\t\t}\n\t\t}\n\n\t\treturn this._style;\n\t}\n\n\tsetState (state) {\n\t\tif (typeof state === 'object') {\n\t\t\tconst oldState = Object.assign ({}, this._state);\n\n\t\t\tthis._state = Object.assign ({}, this._state, state);\n\n\t\t\tfor (const key of Object.keys (state)) {\n\t\t\t\tthis.updateCallback (key, oldState[key], this._state[key], 'state', oldState, this._state);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError(`A state must be an object. Received ${typeof state}.`);\n\t\t}\n\t}\n\n\tsetProps (props) {\n\t\tif (typeof props === 'object') {\n\t\t\tconst oldProps = Object.assign ({}, this._props);\n\n\t\t\tthis._props = Object.assign ({}, this._props, props);\n\n\t\t\tfor (const key of Object.keys (props)) {\n\t\t\t\tthis.updateCallback (key, oldProps[key], this._props[key], 'props', oldProps, this._props);\n\t\t\t}\n\t\t\tthis._setPropAttributes (true);\n\t\t} else {\n\t\t\tthrow new TypeError(`Props must be an object. Received ${typeof state}.`);\n\t\t}\n\t}\n\n\t_setPropAttributes (update = false) {\n\t\tfor (const key of Object.keys (this._props)) {\n\t\t\tconst value = this._props[key];\n\t\t\tif (this.static._explicitPropTypes.indexOf (typeof value) > -1) {\n\t\t\t\tif (update === true) {\n\t\t\t\t\tthis.setAttribute (key, this._props[key]);\n\t\t\t\t} else {\n\t\t\t\t\tthis._props[key] = this.props[key];\n\t\t\t\t\tthis.setAttribute (key, this.props[key]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * =========================\n\t * Update Cycle\n\t * =========================\n */\n\n\twillUpdate (origin, property, oldValue, newValue, oldObject, newObject) {\n\t\treturn Promise.resolve ();\n\t}\n\n\tupdate (origin, property, oldValue, newValue, oldObject, newObject) {\n\t\treturn Promise.resolve ();\n\t}\n\n\tdidUpdate (origin, property, oldValue, newValue, oldObject, newObject) {\n\t\treturn Promise.resolve ();\n\t}\n\n\tonStateUpdate (property, oldValue, newValue, oldObject, newObject) {\n\t\treturn Promise.resolve ();\n\t}\n\n\tonPropsUpdate (property, oldValue, newValue, oldObject, newObject) {\n\t\treturn Promise.resolve ();\n\t}\n\n\t/*\n\t * =========================\n\t * Mount Cycle\n\t * =========================\n */\n\n\twillMount () {\n\t\treturn Promise.resolve ();\n\t}\n\n\tdidMount () {\n\t\treturn Promise.resolve ();\n\t}\n\n\t/*\n\t * =========================\n\t * Unmount Cycle\n\t * =========================\n */\n\n\twillUnmount () {\n\t\treturn Promise.resolve ();\n\t}\n\n\tunmount () {\n\t\treturn Promise.resolve ();\n\t}\n\n\tdidUnmount () {\n\t\treturn Promise.resolve ();\n\t}\n\n\t/*\n\t * =========================\n\t * Render Cycle\n\t * =========================\n */\n\n\t/**\n\t * Forces the component to be rendered again.\n\t *\n\t * @returns {string|Promise<string>} - The HTML to render on the component\n\t */\n\tforceRender () {\n\t\treturn this._render ();\n\t}\n\n\t/**\n\t * This function is the one that defines the HTML that will be rendered\n\t * inside the component. Since some content may need to be loaded before the\n\t * component is rendered, this function can also return a promise.\n\t *\n\t * @returns {string|Promise<string>} - The HTML to render on the component\n\t */\n\trender () {\n\t\treturn '';\n\t}\n\n\t_render () {\n\t\tlet render = this.render;\n\n\t\t// Check if a template has been set to this component, and if that's the\n\t\t// case, use that instead of the render function to render the component's\n\t\t// HTML code.\n\t\tif (this.static._template !== null) {\n\t\t\trender = this.template;\n\t\t}\n\n\t\t// Call the render function asynchronously and set the HTML from it to the\n\t\t// component.\n\t\treturn callAsync (render, this).then ((html) => {\n\t\t\tconst slot = this.dom.querySelector ('slot');\n\n\t\t\tif (typeof html === 'string') {\n\t\t\t\thtml = html.trim ();\n\n\t\t\t\tif (html === '') {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (html === null || typeof html === 'undefined') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (slot !== null) {\n\t\t\t\tslot.replaceWith (html);\n\t\t\t} else {\n\t\t\t\tthis.innerHTML = html;\n\n\t\t\t\tif (this._children !== '' && html.indexOf(this._children) === -1) {\n\t\t\t\t\tthis.innerHTML += this._children;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tconnectedCallback () {\n\t\t// Set the state as connected\n\t\tthis._connected = true;\n\n\t\t// Add a data property with the tag of the component\n\t\tthis.dataset.component = this.static.tag;\n\n\t\t// Check if a template for this component was set. The contents on this\n\t\t// if block will only be run once.\n\t\tif (typeof this.static._template === 'undefined') {\n\n\t\t\t// Check if there is an HTML template for this component\n\t\t\tconst template = document.querySelector (`template#${this.static.tag}`);\n\n\t\t\tif (template !== null) {\n\t\t\t\t// If there is, set is as the template for the component\n\t\t\t\tthis.template (template.innerHTML);\n\t\t\t} else {\n\t\t\t\t// If not, set is as null\n\t\t\t\tthis.static._template = null;\n\t\t\t}\n\t\t}\n\n\t\t// Set the initial prop attributes for the component using the given\n\t\t// props\n\t\tthis._setPropAttributes ();\n\n\t\t// Start the Mount Cycle\n\t\treturn this.willMount ().then (() => {\n\n\t\t\treturn this._render ().then (() => {\n\t\t\t\treturn this.didMount ().then (() => {\n\n\t\t\t\t\tthis._isReady = true;\n\t\t\t\t\tfor (const callback of this._ready) {\n\t\t\t\t\t\tcallback.call (this);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Adds a callback to be run once the component has been mounted successfully\n\t *\n\t * @param {function} callback - Callback to run once the component is ready\n\t */\n\tready (callback) {\n\t\tthis._ready.push (callback);\n\t}\n\n\n\tdisconnectedCallback () {\n\t\treturn this.willUnmount ().then (() => {\n\t\t\treturn this.unmount ().then (() => {\n\t\t\t\treturn this.didUnmount ();\n\t\t\t});\n\t\t});\n\t}\n\n\tupdateCallback (property, oldValue, newValue, origin = 'props', oldObject = {}, newObject = {}) {\n\t\treturn this.willUpdate (origin, property, oldValue, newValue, oldObject, newObject).then (() => {\n\t\t\treturn this.update (origin, property, oldValue, newValue, oldObject, newObject).then (() => {\n\t\t\t\tlet promise;\n\t\t\t\tif (origin === 'state') {\n\t\t\t\t\tpromise = this.onStateUpdate (property, oldValue, newValue, oldObject, newObject);\n\t\t\t\t} else {\n\t\t\t\t\tpromise = this.onPropsUpdate (property, oldValue, newValue, oldObject, newObject);\n\t\t\t\t}\n\t\t\t\treturn promise.then (() => {\n\t\t\t\t\treturn this.didUpdate (origin, property, oldValue, newValue, oldObject, newObject);\n\t\t\t\t});\n\t\t\t});\n\t\t}).catch ((e) => {\n\t\t\tconsole.error (e);\n\t\t\t// Component should not update\n\t\t});\n\t}\n\n\tattributeChangedCallback (property, oldValue, newValue) {\n\n\t}\n}\n","import { Component } from './Component';\nimport { callAsync } from './Util';\n\n/**\n * @class ShadowComponent\n */\nexport class ShadowComponent extends Component {\n\tconstructor (...props) {\n\t\tsuper (...props);\n\n\t\tthis._shadowDOM = this.attachShadow ({ mode: 'open' });\n\t}\n\n\t_createStyleElement () {\n\t\tif (!(this._styleElement instanceof HTMLStyleElement)) {\n\t\t\tthis._styleElement = document.createElement ('style');\n\t\t\tthis.dom.prepend (this._styleElement);\n\t\t}\n\t}\n\n\t_render () {\n\t\tlet render = this.render;\n\n\t\t// Check if a template has been set to this component, and if that's the\n\t\t// case, use that instead of the render function to render the component's\n\t\t// HTML code.\n\t\tif (this.static._template !== null) {\n\t\t\trender = this.template;\n\t\t}\n\n\t\t// Call the render function asynchronously and set the HTML from it to the\n\t\t// component.\n\t\treturn callAsync (render, this).then ((html) => {\n\t\t\tthis._shadowDOM.innerHTML = '';\n\t\t\tif (this._styleElement instanceof HTMLStyleElement) {\n\t\t\t\tthis._shadowDOM.appendChild (this._styleElement);\n\t\t\t}\n\t\t\tthis._shadowDOM.innerHTML += html;\n\t\t});\n\t}\n\n\tget dom () {\n\t\treturn this._shadowDOM;\n\t}\n\n\n}\n","export * from './src/Component';\nexport * from './src/ShadowComponent';\nexport * from './src/Util';"]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/Util.ts", "../src/Component.ts", "../src/ShadowComponent.ts", "../src/Registry.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { CSSObject } from './Types';\n\n/**\n * Calls a function asynchronously and returns a Promise with its result\n * @param callable - The function to call\n * @param context - The context (this) to use when calling the function\n * @param args - Additional arguments to pass to the function\n */\nexport function callAsync<T>(callable: (...args: any[]) => T, context: any, ...args: any[]): Promise<T> {\n try {\n const result = callable.apply(context, args);\n return result instanceof Promise ? result : Promise.resolve(result);\n } catch (e) {\n return Promise.reject(e);\n }\n}\n\n/**\n * Converts a CSS object to a CSS string\n * @param object - The CSS object to convert\n * @param encapsulation - Optional selector to encapsulate the CSS\n * @param level - Current nesting level for indentation\n */\nexport function deserializeCSS(object: CSSObject, encapsulation: string = '', level: number = 0): string {\n const keys = Object.keys(object);\n let css = '';\n\n for (const key of keys) {\n const value = object[key];\n\n if (typeof value === 'object' && value !== null) {\n if (encapsulation && !key.startsWith('@')) {\n if (key.startsWith('&')) {\n css += `${key.replace(/&/g, encapsulation)} {\\n`;\n } else {\n css += `${encapsulation} ${key} {\\n`;\n }\n } else {\n css += `${key} {\\n`;\n }\n\n const properties = Object.keys(value);\n for (const property of properties) {\n css += '\\t'.repeat(level);\n const propValue = value[property];\n\n if (typeof propValue === 'object' && propValue !== null) {\n const temp: CSSObject = {};\n temp[property] = propValue;\n css += deserializeCSS(temp, encapsulation, level + 1);\n } else {\n css += `\\t${property}: ${propValue};\\n`;\n }\n }\n css += '}\\n';\n } else {\n css += '\\t'.repeat(level);\n css += `\\t${key}: ${value};\\n`;\n }\n }\n\n return css;\n}",
|
|
6
|
+
"import { callAsync, deserializeCSS } from './Util';\nimport { Properties, Style, ReadyCallback } from './Types';\n\n/**\n * A component represents a custom HTML element, and has all of its functionality\n * as well as its general structure and representation self contained on it.\n *\n * @template P - The type of the component's props (defaults to Properties)\n * @template S - The type of the component's state (defaults to Properties)\n */\nclass Component<P extends Properties = Properties, S extends Properties = Properties> extends HTMLElement {\n protected _children: string;\n protected _state: S;\n protected _props: P;\n protected _ready: ReadyCallback[];\n protected _connected: boolean;\n protected _isReady: boolean;\n protected _style: Style;\n protected _styleElement: HTMLStyleElement | null;\n\n // This is the tag name for the component\n static _tag?: string;\n\n static _template?: string | ((context: any) => string);\n\n // List of attributes to observe for changes\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes\n static _observedAttributes: string[] = [];\n\n // Registry integration hooks. These are set by the Registry.\n static _onMount?: (component: Component, tag: string) => void;\n static _onUnmount?: (component: Component, tag: string) => void;\n static _onError?: (error: Error, component: Component, tag: string, lifecycle: string) => void;\n static _applyMiddleware?: (type: string, component: Component, value: any) => any;\n static _hasMiddleware?: (type: string) => boolean;\n\n /**\n * Returns the list of attributes to observe for changes.\n * Override this in subclasses to specify which attributes should trigger attributeChangedCallback.\n *\n * @returns {string[]} - Array of attribute names to observe\n */\n static get observedAttributes(): string[] {\n return this._observedAttributes;\n }\n\n /**\n * Sets the list of attributes to observe for changes.\n *\n * @param value - The new list of attributes to observe\n */\n static set observedAttributes(value: string[]) {\n this._observedAttributes = value;\n }\n\n static get tag(): string {\n if (typeof this._tag === 'undefined') {\n let tag = this.name;\n\n const matches = tag.match(/([A-Z])/g);\n\n if (matches !== null) {\n for (const match of matches) {\n tag = tag.replace(match, `-${match}`.toLowerCase());\n }\n }\n\n this._tag = tag.slice(1);\n }\n\n return this._tag;\n }\n\n static set tag(value: string) {\n this._tag = value;\n }\n\n static template(html: string | ((context: any) => string) | null = null, context: any = null): string | undefined | void {\n if (html !== null) {\n this._template = html;\n\n document.querySelectorAll(this.tag).forEach((instance) => {\n if (instance instanceof Component && instance._isReady) {\n instance.forceRender();\n }\n });\n } else {\n // Check if no parameters were set but the HTML is still a function to be called\n if (typeof this._template === 'function') {\n return this._template.call(context, context);\n }\n\n // If this is reached, the HTML was just a string\n return this._template;\n }\n }\n\n constructor() {\n super();\n\n this._children = this.innerHTML.trim();\n\n // State Object for the component\n this._state = {} as S;\n\n // Props Object for the component\n this._props = {} as P;\n\n // List of callbacks to run once the component has been mounted successfully\n this._ready = [];\n\n // Whether the component is connected to the DOM\n this._connected = false;\n this._isReady = false;\n\n // Style Object for the component\n this._style = {};\n this._styleElement = null;\n }\n\n // Determines the real (computed) width of the element\n get width(): number {\n return parseInt(getComputedStyle(this).width.replace('px', ''));\n }\n\n set width(value: number | string) {\n this.style.width = typeof value === 'number' ? `${value}px` : value;\n }\n\n // Determines the real (computed) height of the element\n get height(): number {\n return parseInt(getComputedStyle(this).height.replace('px', ''));\n }\n\n set height(value: number | string) {\n this.style.height = typeof value === 'number' ? `${value}px` : value;\n }\n\n get static(): typeof Component {\n return this.constructor as typeof Component;\n }\n\n set static(value: typeof Component) {\n throw new Error('Component static properties cannot be reassigned.');\n }\n\n get props(): P {\n return new Proxy(this._props, {\n get: (target, key: string) => {\n if (this.hasAttribute(key)) {\n let value: any = this.getAttribute(key);\n\n if (typeof value === 'string') {\n if (value === 'false') {\n value = false;\n } else if (value === 'true' || value === '') {\n value = true;\n } else if (!isNaN(Number(value))) {\n value = value.includes('.') ? parseFloat(value) : parseInt(value);\n }\n }\n\n return value;\n } else if (key in target) {\n return target[key as keyof P];\n }\n\n return null;\n },\n set: () => {\n throw new Error('Component props should be set using the `setProps` function.');\n }\n }) as P;\n }\n\n set props(value: P) {\n if (!this._connected) {\n this._props = { ...this._props, ...value };\n } else {\n throw new Error('Component props cannot be directly assigned. Use the `setProps` function instead.');\n }\n }\n\n get state(): S {\n return new Proxy(this._state, {\n get: (target, key: string) => target[key as keyof S],\n set: (target, key: string, value) => {\n if (!this._connected) {\n (target as any)[key] = value;\n return true;\n } else {\n throw new Error('Component state should be set using the `setState` function instead.');\n }\n }\n }) as S;\n }\n\n set state(value: S) {\n if (!this._connected) {\n this._state = { ...this._state, ...value };\n } else {\n throw new Error('Component state should be set using the `setState` function instead.');\n }\n }\n\n get dom(): HTMLElement {\n return this;\n }\n\n set dom(value: HTMLElement) {\n throw new Error('Component DOM can not be overwritten.');\n }\n\n /**\n * Returns whether the component is currently connected to the DOM.\n */\n get isConnected(): boolean {\n return this._connected;\n }\n\n /**\n * Returns whether the component has completed its initial mount cycle.\n */\n get isReady(): boolean {\n return this._isReady;\n }\n\n /**\n\t * register - Register the component as a custom HTML element\n\t * using the component's tag as the actual element tag.\n\t *\n\t * This action cannot be reverted nor the controller class for\n\t * the element can be changed.\n\t */\n static register(): void {\n window.customElements.define(this.tag, this);\n }\n\n /**\n\t * template - A simple function providing access to the basic HTML\n\t * structure of the component.\n\t *\n\t * @param {function|string} html - A string or function that renders the\n\t * component into a valid HTML structure.\n\t *\n\t * @returns {void|string} - Void or the HTML structure in a string\n\t */\n template(html: string | ((context: any) => string) | null = null): string | undefined | void {\n return (this.constructor as typeof Component).template(html, this);\n }\n\n protected _createStyleElement(): void {\n // Check if there is a shared style element for the component\n const sharedStyle = document.body.querySelector(`style#${(this.constructor as typeof Component).tag}`);\n\n // If there is, use it\n if (sharedStyle instanceof HTMLStyleElement) {\n this._styleElement = sharedStyle;\n }\n\n if (this._styleElement instanceof HTMLStyleElement) {\n return;\n }\n\n // If there is no shared style element, create a new one\n this._styleElement = document.createElement('style');\n this._styleElement.id = (this.constructor as typeof Component).tag;\n\n // For normal components, the style element is added to the body\n document.body.prepend(this._styleElement);\n }\n\n setStyle(style: Style | string, reset: boolean = false): Style {\n this._createStyleElement();\n\n if (typeof style === 'object') {\n if (!reset) {\n this._style = { ...this._style, ...style };\n } else {\n this._style = { ...style };\n }\n\n this._styleElement!.innerHTML = deserializeCSS(this._style, (this.constructor as typeof Component).tag);\n } else if (typeof style === 'string') {\n if (!reset) {\n this._styleElement!.innerHTML += style;\n } else {\n this._styleElement!.innerHTML = style;\n }\n }\n\n return this._style;\n }\n\n setState(state: Partial<S>): void {\n // Apply middleware if available\n let processedState = state;\n\n if (Component._hasMiddleware?.('state') && Component._applyMiddleware) {\n processedState = Component._applyMiddleware('state', this, state);\n }\n\n const oldState = { ...this._state };\n this._state = { ...this._state, ...processedState };\n\n for (const key of Object.keys(processedState)) {\n this.updateCallback(key, oldState[key as keyof S], this._state[key as keyof S], 'state', oldState, this._state);\n }\n }\n\n setProps(props: Partial<P>): void {\n // Apply middleware if available\n let processedProps = props;\n\n if (Component._hasMiddleware?.('props') && Component._applyMiddleware) {\n processedProps = Component._applyMiddleware('props', this, props);\n }\n\n const oldProps = { ...this._props };\n this._props = { ...this._props, ...processedProps };\n\n for (const key of Object.keys(processedProps)) {\n this.updateCallback(key, oldProps[key as keyof P], this._props[key as keyof P], 'props', oldProps, this._props);\n }\n\n this._setPropAttributes(true);\n }\n\n protected _setPropAttributes(update: boolean = false): void {\n for (const [key, value] of Object.entries(this._props)) {\n const valueType = typeof value;\n\n if (valueType === 'string' || valueType === 'number' || valueType === 'boolean') {\n if (update) {\n this.setAttribute(key, String(value));\n } else {\n (this._props as Record<string, unknown>)[key] = this.props[key as keyof P];\n this.setAttribute(key, String(this.props[key as keyof P]));\n }\n }\n }\n }\n\n /*\n * =========================\n * Event Helpers\n * =========================\n */\n\n /**\n * Adds an event listener to the component.\n *\n * @param event - The event type to listen for\n * @param callback - The callback function to execute when the event occurs\n * @param options - Optional event listener options\n * @returns The component instance for chaining\n */\n on<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): this;\n on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;\n on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this {\n this.addEventListener(event, callback, options);\n return this;\n }\n\n /**\n * Removes an event listener from the component.\n *\n * @param event - The event type to remove the listener for\n * @param callback - The callback function to remove\n * @param options - Optional event listener options\n * @returns The component instance for chaining\n */\n off<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | EventListenerOptions\n ): this;\n off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this;\n off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this {\n this.removeEventListener(event, callback, options);\n return this;\n }\n\n /**\n * Adds a one-time event listener that removes itself after the first trigger.\n *\n * @param event - The event type to listen for\n * @param callback - The callback function to execute when the event occurs\n * @param options - Optional event listener options\n * @returns The component instance for chaining\n */\n once<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): this;\n once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;\n once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this {\n const opts = typeof options === 'boolean' ? { capture: options, once: true } : { ...options, once: true };\n this.addEventListener(event, callback, opts);\n return this;\n }\n\n /**\n * Emits a custom event from the component.\n *\n * @param event - The event name to emit\n * @param detail - Optional data to include with the event\n * @param options - Optional CustomEvent init options (bubbles, cancelable, composed)\n * @returns Whether the event was not cancelled\n */\n emit<T = unknown>(event: string, detail?: T, options?: Omit<CustomEventInit<T>, 'detail'>): boolean {\n const customEvent = new CustomEvent(event, {\n detail,\n bubbles: true,\n cancelable: true,\n composed: true,\n ...options\n });\n return this.dispatchEvent(customEvent);\n }\n\n /*\n * =========================\n * Query Helpers\n * =========================\n */\n\n /**\n * Queries for a single element within the component's DOM.\n *\n * @param selector - CSS selector to query for\n * @returns The first matching element or null\n */\n query<E extends Element = Element>(selector: string): E | null {\n return this.dom.querySelector<E>(selector);\n }\n\n /**\n * Queries for all matching elements within the component's DOM.\n *\n * @param selector - CSS selector to query for\n * @returns A NodeList of all matching elements\n */\n queryAll<E extends Element = Element>(selector: string): NodeListOf<E> {\n return this.dom.querySelectorAll<E>(selector);\n }\n\n /*\n * =========================\n * Update Cycle\n * =========================\n */\n\n /**\n * Called before the component updates due to state or props changes.\n * Override this method to perform actions before an update occurs.\n *\n * @param origin - Whether the update was triggered by 'state' or 'props'\n * @param property - The name of the property that changed\n * @param oldValue - The previous value of the property\n * @param newValue - The new value of the property\n * @param oldObject - The previous state/props object\n * @param newObject - The new state/props object\n * @returns A promise that resolves when the pre-update logic completes\n */\n protected willUpdate(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called when the component updates due to state or props changes.\n * Override this method to perform actions during an update.\n *\n * @param origin - Whether the update was triggered by 'state' or 'props'\n * @param property - The name of the property that changed\n * @param oldValue - The previous value of the property\n * @param newValue - The new value of the property\n * @param oldObject - The previous state/props object\n * @param newObject - The new state/props object\n * @returns A promise that resolves when the update logic completes\n */\n protected update(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the component updates due to state or props changes.\n * Override this method to perform actions after an update completes.\n *\n * @param origin - Whether the update was triggered by 'state' or 'props'\n * @param property - The name of the property that changed\n * @param oldValue - The previous value of the property\n * @param newValue - The new value of the property\n * @param oldObject - The previous state/props object\n * @param newObject - The new state/props object\n * @returns A promise that resolves when the post-update logic completes\n */\n protected didUpdate(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called when the component's state updates.\n * Override this method to react specifically to state changes.\n *\n * @param property - The name of the state property that changed\n * @param oldValue - The previous value of the property\n * @param newValue - The new value of the property\n * @param oldObject - The previous state object\n * @param newObject - The new state object\n * @returns A promise that resolves when the state update logic completes\n */\n protected onStateUpdate(property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called when the component's props update.\n * Override this method to react specifically to props changes.\n *\n * @param property - The name of the prop that changed\n * @param oldValue - The previous value of the property\n * @param newValue - The new value of the property\n * @param oldObject - The previous props object\n * @param newObject - The new props object\n * @returns A promise that resolves when the props update logic completes\n */\n protected onPropsUpdate(property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void> {\n return Promise.resolve();\n }\n\n /*\n * =========================\n * Mount Cycle\n * =========================\n */\n\n /**\n * Called before the component is mounted to the DOM.\n * Override this method to perform setup before rendering.\n *\n * @returns A promise that resolves when the pre-mount logic completes\n */\n protected willMount(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the component is mounted to the DOM.\n * Override this method to perform actions after the component is rendered.\n *\n * @returns A promise that resolves when the post-mount logic completes\n */\n protected didMount(): Promise<void> {\n return Promise.resolve();\n }\n\n /*\n * =========================\n * Unmount Cycle\n * =========================\n */\n\n /**\n * Called before the component is removed from the DOM.\n * Override this method to perform cleanup before unmounting.\n *\n * @returns A promise that resolves when the pre-unmount logic completes\n */\n protected willUnmount(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called when the component is being removed from the DOM.\n * Override this method to perform cleanup during unmounting.\n *\n * @returns A promise that resolves when the unmount logic completes\n */\n protected unmount(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the component is removed from the DOM.\n * Override this method to perform final cleanup after unmounting.\n *\n * @returns A promise that resolves when the post-unmount logic completes\n */\n protected didUnmount(): Promise<void> {\n return Promise.resolve();\n }\n\n /*\n * =========================\n * Render Cycle\n * =========================\n */\n\n /**\n * Forces the component to be rendered again.\n *\n * @returns A promise that resolves with the rendered HTML string\n */\n forceRender(): string | Promise<string> {\n return this._render();\n }\n\n /**\n * Returns the HTML content for the component.\n * Override this method to define the component's template.\n *\n * @returns The HTML string to render\n */\n render(): string {\n return '';\n }\n\n protected async _render(): Promise<string> {\n let render = this.render;\n\n if ((this.constructor as typeof Component)._template !== undefined) {\n render = this.template as () => string;\n }\n\n let html = await callAsync<string>(render, this);\n\n html = html.trim();\n\n // Apply render middleware if available\n if (Component._hasMiddleware?.('render') && Component._applyMiddleware) {\n html = Component._applyMiddleware('render', this, html);\n }\n\n if (html === '') {\n return '';\n }\n\n const slot = this.dom.querySelector('slot');\n\n if (slot !== null) {\n slot.replaceWith(html);\n } else {\n this.innerHTML = html;\n\n if (this._children !== '' && html.indexOf(this._children) === -1) {\n this.innerHTML += this._children;\n }\n }\n\n return html;\n }\n\n async connectedCallback(): Promise<void> {\n const tag = this.static.tag;\n\n try {\n // Set the state as connected\n this._connected = true;\n\n // Add a data property with the tag of the component\n this.dataset.component = tag;\n\n // Check if a template for this component was set. The contents on this\n // if block will only be run once.\n if (typeof this.static._template === 'undefined') {\n\n // Check if there is an HTML template for this component\n const template = document.querySelector(`template#${tag}`);\n\n if (template !== null) {\n // If there is, set is as the template for the component\n this.template(template.innerHTML);\n } else {\n // If not, set is as null\n this.static._template = undefined;\n }\n }\n\n // Set the initial prop attributes for the component using the given props\n this._setPropAttributes(false);\n\n // Run the Mount Cycle\n await this.willMount();\n await this._render();\n await this.didMount();\n\n // Set the component as ready\n this._isReady = true;\n\n // Execute and clear ready callbacks\n const callbacks = [...this._ready];\n this._ready = [];\n\n for (const callback of callbacks) {\n callback.call(this);\n }\n\n // Notify Registry of mount\n if (Component._onMount) {\n Component._onMount(this, tag);\n }\n\n } catch (error) {\n if (Component._onError) {\n Component._onError(error as Error, this, tag, 'connectedCallback');\n } else {\n throw error;\n }\n }\n }\n\n ready(callback: ReadyCallback): void {\n this._ready.push(callback);\n\n if (this._isReady) {\n callback.call(this);\n }\n }\n\n async disconnectedCallback(): Promise<void> {\n const tag = this.static.tag;\n\n try {\n // Run the Unmount Cycle\n await this.willUnmount();\n await this.unmount();\n await this.didUnmount();\n\n // Set the state as disconnected\n this._connected = false;\n\n // Notify Registry of unmount\n if (Component._onUnmount) {\n Component._onUnmount(this, tag);\n }\n\n } catch (error) {\n if (Component._onError) {\n Component._onError(error as Error, this, tag, 'disconnectedCallback');\n } else {\n throw error;\n }\n }\n }\n\n protected async updateCallback(\n property: string,\n oldValue: unknown,\n newValue: unknown,\n origin: 'props' | 'state' | 'attribute' = 'props',\n oldObject: P | S = {} as P | S,\n newObject: P | S = {} as P | S\n ): Promise<void> {\n await this.willUpdate(origin, property, oldValue, newValue, oldObject, newObject);\n await this.update(origin, property, oldValue, newValue, oldObject, newObject);\n\n if (origin === 'state') {\n await this.onStateUpdate(property, oldValue, newValue, oldObject, newObject);\n } else if (origin === 'props' || origin === 'attribute') {\n await this.onPropsUpdate(property, oldValue, newValue, oldObject, newObject);\n }\n\n await this.didUpdate(origin, property, oldValue, newValue, oldObject, newObject);\n }\n\n /**\n * Called when an observed attribute changes.\n * This is a Web Components lifecycle callback.\n *\n * @param property - The name of the attribute that changed\n * @param oldValue - The previous value of the attribute\n * @param newValue - The new value of the attribute\n */\n attributeChangedCallback(property: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue !== newValue) {\n this.updateCallback(property, oldValue, newValue, 'attribute');\n }\n }\n}\n\nexport default Component;",
|
|
7
|
+
"import Component from './Component';\nimport { callAsync, deserializeCSS } from './Util';\nimport { Properties, Style } from './Types';\n\n/**\n * A component that uses Shadow DOM for encapsulation\n *\n * @template P - The type of the component's props (defaults to Properties)\n * @template S - The type of the component's state (defaults to Properties)\n */\nclass ShadowComponent<P extends Properties = Properties, S extends Properties = Properties> extends Component<P, S> {\n protected _shadowDOM: ShadowRoot;\n\n constructor() {\n super();\n\n // Create the shadow DOM for the component\n this._shadowDOM = this.attachShadow({ mode: 'open' });\n }\n\n setStyle(style: Style | string, reset: boolean = false): Style {\n this._createStyleElement();\n\n if (typeof style === 'object') {\n if (!reset) {\n this._style = { ...this._style, ...style };\n } else {\n this._style = { ...style };\n }\n\n this._styleElement!.innerHTML = deserializeCSS(this._style);\n } else if (typeof style === 'string') {\n if (!reset) {\n this._styleElement!.innerHTML += style;\n } else {\n this._styleElement!.innerHTML = style;\n }\n }\n\n return this._style;\n }\n\n protected _createStyleElement(): void {\n if (this._styleElement instanceof HTMLStyleElement) {\n return;\n }\n\n this._styleElement = document.createElement('style');\n this._shadowDOM.prepend(this._styleElement);\n }\n\n protected async _render(): Promise<string> {\n let render = this.render;\n\n // Check if a template has been set to this component, and if that's the\n // case, use that instead of the render function to render the component's\n // HTML code.\n if ((this.constructor as typeof Component)._template !== undefined) {\n render = this.template as () => string;\n }\n\n // Call the render function asynchronously and set the HTML from it to the\n // component.\n const html = await callAsync(render, this);\n\n // Remove all children except the style element\n const children = Array.from(this._shadowDOM.childNodes);\n for (const child of children) {\n if (child !== this._styleElement) {\n child.remove();\n }\n }\n\n // Create a template to parse the HTML and append the content\n const template = document.createElement('template');\n template.innerHTML = html;\n\n this._shadowDOM.appendChild(template.content);\n\n return html;\n }\n\n get dom(): HTMLElement {\n throw new Error('ShadowComponent DOM can not be accessed. Use the `shadowRoot` property instead.');\n }\n\n set dom(value: HTMLElement) {\n throw new Error('ShadowComponent DOM can not be overwritten.');\n }\n\n get shadowRoot(): ShadowRoot {\n return this._shadowDOM;\n }\n\n set shadowRoot(value: ShadowRoot) {\n throw new Error('ShadowComponent shadowRoot can not be overwritten.');\n }\n\n /**\n * Queries for a single element within the shadow DOM.\n *\n * @param selector - CSS selector to query for\n * @returns The first matching element or null\n */\n override query<E extends Element = Element>(selector: string): E | null {\n return this._shadowDOM.querySelector<E>(selector);\n }\n\n /**\n * Queries for all matching elements within the shadow DOM.\n *\n * @param selector - CSS selector to query for\n * @returns A NodeList of all matching elements\n */\n override queryAll<E extends Element = Element>(selector: string): NodeListOf<E> {\n return this._shadowDOM.querySelectorAll<E>(selector);\n }\n}\n\nexport default ShadowComponent;",
|
|
8
|
+
"import Component from './Component';\n\ntype ComponentClass = typeof Component & {\n tag: string;\n _registered?: boolean;\n};\n\ntype StateSubscriber<T = unknown> = (newValue: T, oldValue: T | undefined) => void;\ntype LifecycleCallback = (component: Component, tag: string) => void;\ntype ErrorCallback = (error: Error, component: Component, tag: string, lifecycle: string) => void;\ntype MiddlewareType = 'props' | 'state' | 'render';\ntype Middleware = (component: Component, value: any) => any;\ntype ComponentLoader = () => Promise<ComponentClass | { default: ComponentClass }>;\n\ninterface ComponentStats {\n tag: string;\n instanceCount: number;\n isRegistered: boolean;\n isLazy: boolean;\n}\n\n/**\n * Registry for managing web components and global state\n */\nclass Registry {\n // We won't show logs by default\n private static _debug: boolean = false;\n\n private static components: Record<string, ComponentClass> = {};\n\n private static implementations: Record<string, ComponentClass> = {};\n\n private static state: Record<string, unknown> = {};\n private static subscribers: Record<string, Set<StateSubscriber>> = {};\n\n private static mountCallbacks: Set<LifecycleCallback> = new Set();\n private static unmountCallbacks: Set<LifecycleCallback> = new Set();\n private static errorCallbacks: Set<ErrorCallback> = new Set();\n private static aliases: Record<string, string> = {};\n private static lazyLoaders: Record<string, ComponentLoader> = {};\n\n private static middleware: Record<MiddlewareType, Set<Middleware>> = {\n props: new Set(),\n state: new Set(),\n render: new Set()\n };\n\n private static _initialized = false;\n\n /**\n * Initialize Registry hooks on the Component class. Called automatically on first use\n */\n private static _init(): void {\n if (this._initialized) return;\n this._initialized = true;\n\n // Set up Component hooks\n Component._onMount = (component, tag) => this._notifyMount(component, tag);\n Component._onUnmount = (component, tag) => this._notifyUnmount(component, tag);\n Component._onError = (error, component, tag, lifecycle) => this._notifyError(error, component, tag, lifecycle);\n Component._applyMiddleware = (type, component, value) => this._applyMiddleware(type as MiddlewareType, component, value);\n Component._hasMiddleware = (type) => this._hasMiddleware(type as MiddlewareType);\n }\n\n /**\n * Register a new component with a specific tag name\n *\n * @param tag - The tag name for the component\n * @param component - The component constructor\n */\n static register(tag: string, component: ComponentClass): void {\n this._init();\n\n if (typeof this.components[tag] === 'undefined') {\n this.components[tag] = component;\n this.implementations[tag] = component;\n component._tag = tag;\n\n window.customElements.define(tag, component);\n\n this.components[tag]._registered = true;\n this.log(`Registered: <${tag}>`);\n } else {\n throw new Error('A component with this tag has already been registered. Use the evolve() function to modify the component.');\n }\n }\n\n /**\n * Get the current implementation for a tag\n *\n * @internal\n */\n static getImplementation(tag: string): ComponentClass | undefined {\n return this.implementations[tag] || this.components[tag];\n }\n\n /**\n * Update an existing component with a new implementation\n *\n * @param tag - The tag name of the component to update\n * @param component - The new component constructor\n * @param rerender - Whether to re-render all existing instances (default: false)\n */\n static evolve(tag: string, component: ComponentClass, rerender: boolean = false): void {\n if (typeof this.components[tag] === 'undefined') {\n throw new Error('No component with this tag has been registered. Cannot Evolve.');\n }\n\n // Store the new implementation\n this.implementations[tag] = component;\n component._registered = true;\n\n this.log(`Evolved: <${tag}>`);\n\n // Update all existing instances with the new implementation\n if (rerender) {\n const proto = component.prototype as unknown as Record<string, unknown>;\n const protoMethods = Object.getOwnPropertyNames(proto);\n\n // Create a temporary instance to get default state/props. This avoids calling\n // the constructor's side effects\n const tempInstance = Object.create(proto);\n\n try {\n component.call(tempInstance);\n } catch {\n // Just skip state/props merging if the constructor fails\n }\n\n document.querySelectorAll(tag).forEach((instance) => {\n if (instance instanceof Component && (instance as Component).isReady) {\n const inst = instance as unknown as Record<string, unknown>;\n\n // Copy all prototype methods from the new component to the instance\n for (const method of protoMethods) {\n if (method !== 'constructor' && typeof proto[method] === 'function') {\n const fn = proto[method] as (...args: unknown[]) => unknown;\n inst[method] = fn.bind(instance);\n }\n }\n\n // Merge new default state properties\n if (tempInstance._state) {\n const existingState = inst._state as Record<string, unknown> || {};\n const newDefaults = tempInstance._state as Record<string, unknown>;\n for (const key of Object.keys(newDefaults)) {\n if (!(key in existingState)) {\n existingState[key] = newDefaults[key];\n }\n }\n inst._state = existingState;\n }\n\n // Merge new default props properties\n if (tempInstance._props) {\n const existingProps = inst._props as Record<string, unknown> || {};\n const newDefaults = tempInstance._props as Record<string, unknown>;\n for (const key of Object.keys(newDefaults)) {\n if (!(key in existingProps)) {\n existingProps[key] = newDefaults[key];\n }\n }\n inst._props = existingProps;\n }\n\n // _connected, _isReady, _ready are preserved as we do want to keep\n // the state of the component on those.\n\n (instance as Component).forceRender();\n }\n });\n }\n }\n\n /**\n * Get all instances of a component or execute a callback on them\n *\n * @param tag - The tag name of the component\n * @param callback - Optional callback to execute on each instance\n */\n static instances(tag: string, callback?: (instance: Element) => void): NodeListOf<Element> | void {\n if (typeof this.components[tag] !== 'undefined') {\n if (typeof callback === 'function') {\n document.querySelectorAll(tag).forEach(callback);\n } else {\n return document.querySelectorAll(tag);\n }\n } else {\n throw new Error('No component with the provided tag has been registered.');\n }\n }\n\n /**\n * Create a new instance of a component\n *\n * @param tag - The tag name of the component\n * @param props - Properties to set on the component\n * @returns The created component instance\n */\n static instantiate(tag: string, props: Record<string, any>): Component {\n if (!this.has(tag)) {\n throw new Error(`No component with tag \"${tag}\" has been registered.`);\n }\n\n if (!this.components[tag]._registered) {\n this.register(tag, this.components[tag]);\n }\n\n const element = document.createElement(this.components[tag].tag) as Component;\n\n element.setProps(props);\n\n return element;\n }\n\n /**\n * Check if a component is registered with the given tag\n *\n * @param tag - The tag name to check\n * @returns True if a component is registered with the tag\n */\n static has(tag: string): boolean {\n return typeof this.components[tag] !== 'undefined';\n }\n\n /**\n * Get the component class registered with the given tag\n *\n * @param tag - The tag name of the component\n * @returns The component class or undefined if not registered\n */\n static get(tag: string): ComponentClass | undefined {\n return this.components[tag];\n }\n\n /*\n * =========================\n * Global State Management\n * =========================\n */\n\n /**\n * Set a global state value\n *\n * @param key - The state key\n * @param value - The value to set\n */\n static setState<T>(key: string, value: T): void {\n const oldValue = this.state[key] as T | undefined;\n this.state[key] = value;\n\n // Notify subscribers\n if (this.subscribers[key]) {\n this.subscribers[key].forEach((callback) => {\n callback(value, oldValue);\n });\n }\n }\n\n /**\n * Get a global state value\n *\n * @param key - The state key\n * @returns The state value or undefined if not set\n */\n static getState<T>(key: string): T | undefined {\n return this.state[key] as T | undefined;\n }\n\n /**\n * Check if a global state key exists\n *\n * @param key - The state key to check\n * @returns True if the state key exists\n */\n static hasState(key: string): boolean {\n return key in this.state;\n }\n\n /**\n * Delete a global state value\n *\n * @param key - The state key to delete\n * @returns True if the key existed and was deleted\n */\n static deleteState(key: string): boolean {\n if (key in this.state) {\n const oldValue = this.state[key];\n delete this.state[key];\n\n // Notify subscribers with undefined as new value\n if (this.subscribers[key]) {\n this.subscribers[key].forEach((callback) => {\n callback(undefined, oldValue);\n });\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Subscribe to changes on a global state key\n *\n * @param key - The state key to subscribe to\n * @param callback - Function called when the state changes\n * @returns An unsubscribe function\n */\n static subscribe<T>(key: string, callback: StateSubscriber<T>): () => void {\n if (!this.subscribers[key]) {\n this.subscribers[key] = new Set();\n }\n\n this.subscribers[key].add(callback as StateSubscriber);\n\n // Return unsubscribe function\n return () => {\n this.unsubscribe(key, callback);\n };\n }\n\n /**\n * Unsubscribe from changes on a global state key\n *\n * @param key - The state key to unsubscribe from\n * @param callback - The callback function to remove\n */\n static unsubscribe<T>(key: string, callback: StateSubscriber<T>): void {\n if (this.subscribers[key]) {\n this.subscribers[key].delete(callback as StateSubscriber);\n }\n }\n\n /**\n * Get all global state as an object\n *\n * @returns A copy of the global state object\n */\n static getAllState(): Record<string, unknown> {\n return { ...this.state };\n }\n\n /**\n * Clear all global state and notify subscribers\n */\n static clearState(): void {\n const keys = Object.keys(this.state);\n\n for (const key of keys) {\n this.deleteState(key);\n }\n }\n\n /*\n * =========================\n * Debugging Tools\n * =========================\n */\n\n /**\n * Enable or disable debug mode.\n * When enabled, lifecycle events are logged to the console.\n */\n static get debug(): boolean {\n return this._debug;\n }\n\n static set debug(value: boolean) {\n this._debug = value;\n }\n\n /**\n * Log a debug message if debug mode is enabled\n *\n * @param message - The message to log\n * @param data - Optional data to include\n */\n static log(message: string, data?: unknown): void {\n if (this._debug) {\n if (data !== undefined) {\n console.log(`[Pandora] ${message}`, data);\n } else {\n console.log(`[Pandora] ${message}`);\n }\n }\n }\n\n /**\n * List all registered component tags\n *\n * @returns Array of registered component tag names\n */\n static list(): string[] {\n return Object.keys(this.components);\n }\n\n /**\n * Get statistics for a specific component or all components\n *\n * @param tag - Optional tag to get stats for a specific component\n * @returns Component stats or array of all component stats\n */\n static stats(tag?: string): ComponentStats | ComponentStats[] {\n if (tag) {\n if (!this.has(tag)) {\n throw new Error(`No component with tag \"${tag}\" has been registered.`);\n }\n\n return {\n tag,\n instanceCount: document.querySelectorAll(tag).length,\n isRegistered: this.components[tag]?._registered ?? false,\n isLazy: tag in this.lazyLoaders\n };\n }\n\n return this.list().map((tag) => ({\n tag: tag,\n instanceCount: document.querySelectorAll(tag).length,\n isRegistered: this.components[tag]?._registered ?? false,\n isLazy: tag in this.lazyLoaders\n }));\n }\n\n /*\n * =========================\n * Global Lifecycle Hooks\n * =========================\n */\n\n /**\n * Register a callback to be called when any component mounts\n *\n * @param callback - Function called with (component, tag) when a component mounts\n * @returns Unsubscribe function\n */\n static onMount(callback: LifecycleCallback): () => void {\n this._init();\n this.mountCallbacks.add(callback);\n\n return () => this.mountCallbacks.delete(callback);\n }\n\n /**\n * Register a callback to be called when any component unmounts\n *\n * @param callback - Function called with (component, tag) when a component unmounts\n * @returns Unsubscribe function\n */\n static onUnmount(callback: LifecycleCallback): () => void {\n this._init();\n this.unmountCallbacks.add(callback);\n\n return () => this.unmountCallbacks.delete(callback);\n }\n\n /**\n * Notify Registry that a component has mounted\n * @internal\n */\n static _notifyMount(component: Component, tag: string): void {\n this.log(`Mounted: <${tag}>`);\n this.mountCallbacks.forEach((callback) => {\n try {\n callback(component, tag);\n } catch (error) {\n console.error('[Pandora] Error in onMount callback:', error);\n }\n });\n }\n\n /**\n * Notify Registry that a component has unmounted\n *\n * @internal\n */\n static _notifyUnmount(component: Component, tag: string): void {\n this.log(`Unmounted: <${tag}>`);\n this.unmountCallbacks.forEach((callback) => {\n try {\n callback(component, tag);\n } catch (error) {\n console.error('[Pandora] Error in onUnmount callback:', error);\n }\n });\n }\n\n /*\n * =========================\n * Error Boundaries\n * =========================\n */\n\n /**\n * Register a global error handler for component errors\n *\n * @param callback - Function called with (error, component, tag, lifecycle) when an error occurs\n * @returns Unsubscribe function\n */\n static onError(callback: ErrorCallback): () => void {\n this._init();\n this.errorCallbacks.add(callback);\n\n return () => this.errorCallbacks.delete(callback);\n }\n\n /**\n * Notify Registry that an error occurred in a component\n *\n * @internal\n */\n static _notifyError(error: Error, component: Component, tag: string, lifecycle: string): void {\n this.log(`Error in <${tag}> during ${lifecycle}:`, error);\n\n if (this.errorCallbacks.size === 0) {\n // No error handlers registered, re-throw\n throw error;\n }\n\n this.errorCallbacks.forEach((callback) => {\n try {\n callback(error, component, tag, lifecycle);\n } catch (callbackError) {\n console.error('[Pandora] Error in onError callback:', callbackError);\n }\n });\n }\n\n /*\n * =========================\n * Component Aliases\n * =========================\n */\n\n /**\n * Create an alias for an existing component tag\n *\n * @param aliasTag - The new tag name to use as an alias\n * @param originalTag - The original component tag name\n */\n static alias(aliasTag: string, originalTag: string): void {\n if (!this.has(originalTag)) {\n throw new Error(`Cannot create alias: no component with tag \"${originalTag}\" has been registered.`);\n }\n\n if (this.has(aliasTag)) {\n throw new Error(`Cannot create alias: a component with tag \"${aliasTag}\" already exists.`);\n }\n\n this.aliases[aliasTag] = originalTag;\n\n // Create a subclass that inherits from the original component\n const OriginalClass = this.components[originalTag];\n\n // Create a subclass with a different tag\n const AliasClass = class extends (OriginalClass as typeof Component) {\n static _tag = aliasTag;\n };\n\n this.components[aliasTag] = AliasClass as unknown as ComponentClass;\n window.customElements.define(aliasTag, AliasClass);\n\n this.log(`Created alias: <${aliasTag}> -> <${originalTag}>`);\n }\n\n /**\n * Get the original tag for an alias\n *\n * @param aliasTag - The alias tag name\n * @returns The original tag name or undefined if not an alias\n */\n static getOriginalTag(aliasTag: string): string | undefined {\n return this.aliases[aliasTag];\n }\n\n /**\n * Check if a tag is an alias\n *\n * @param tag - The tag name to check\n * @returns True if the tag is an alias\n */\n static isAlias(tag: string): boolean {\n return tag in this.aliases;\n }\n\n /*\n * =========================\n * Lazy Loading\n * =========================\n */\n\n /**\n * Register a component to be lazily loaded on first use\n *\n * @param tag - The tag name for the component\n * @param loader - Async function that returns the component class\n */\n static lazy(tag: string, loader: ComponentLoader): void {\n this._init();\n\n if (this.has(tag)) {\n throw new Error(`Cannot register lazy component: a component with tag \"${tag}\" already exists.`);\n }\n\n this.lazyLoaders[tag] = loader;\n\n // Store reference to Registry for use in the class\n const registry = Registry;\n\n // Create a placeholder class that will load and delegate to the real component\n class LazyComponent extends Component {\n static _tag = tag;\n private _lazyLoaded = false;\n\n async connectedCallback(): Promise<void> {\n // Load the real component on first mount\n await registry._loadLazyComponent(tag);\n\n // Get the loaded implementation\n const RealComponent = registry.getImplementation(tag);\n if (RealComponent && RealComponent !== LazyComponent) {\n const proto = RealComponent.prototype as unknown as Record<string, unknown>;\n const protoMethods = Object.getOwnPropertyNames(proto);\n const inst = this as unknown as Record<string, unknown>;\n\n // Copy prototype methods from the real component to this instance\n for (const method of protoMethods) {\n if (method !== 'constructor' && typeof proto[method] === 'function') {\n const fn = proto[method] as (...args: unknown[]) => unknown;\n inst[method] = fn.bind(this);\n }\n }\n\n // Get default state/props from the real component\n const tempInstance = Object.create(proto);\n\n try {\n RealComponent.call(tempInstance);\n } catch {\n // If constructor fails, skip state/props initialization\n }\n\n // Apply default state from real component\n if (tempInstance._state) {\n inst._state = { ...(tempInstance._state as object) };\n }\n\n // Apply default props from real component\n if (tempInstance._props) {\n inst._props = { ...(tempInstance._props as object) };\n }\n\n this._lazyLoaded = true;\n }\n\n // Now run the normal connected callback\n await super.connectedCallback();\n }\n }\n\n this.components[tag] = LazyComponent as unknown as ComponentClass;\n window.customElements.define(tag, LazyComponent);\n this.log(`Registered lazy component: <${tag}>`);\n }\n\n /**\n * Load a lazy component\n *\n * @internal\n */\n static async _loadLazyComponent(tag: string): Promise<void> {\n if (!(tag in this.lazyLoaders)) {\n return;\n }\n\n const loader = this.lazyLoaders[tag];\n this.log(`Loading lazy component: <${tag}>`);\n\n try {\n const result = await loader();\n const componentClass = 'default' in result ? result.default : result;\n\n // Remove from lazy loaders\n delete this.lazyLoaders[tag];\n\n // Store as the implementation\n this.implementations[tag] = componentClass;\n componentClass._registered = true;\n\n this.log(`Loaded lazy component: <${tag}>`);\n } catch (error) {\n console.error(`[Pandora] Failed to load lazy component <${tag}>:`, error);\n throw error;\n }\n }\n\n /**\n * Check if a component is lazy (not yet loaded)\n *\n * @param tag - The tag name to check\n * @returns True if the component is registered as lazy and not yet loaded\n */\n static isLazy(tag: string): boolean {\n return tag in this.lazyLoaders;\n }\n\n /**\n * Preload a lazy component without mounting it\n *\n * @param tag - The tag name of the lazy component to preload\n */\n static async preload(tag: string): Promise<void> {\n if (this.isLazy(tag)) {\n await this._loadLazyComponent(tag);\n }\n }\n\n /*\n * =========================\n * Middleware\n * =========================\n */\n\n /**\n * Register middleware to intercept props, state, or render operations\n *\n * @param type - The type of middleware: 'props', 'state', or 'render'\n * @param middleware - Function that receives (component, value) and returns the modified value\n * @returns Unsubscribe function\n */\n static use(type: MiddlewareType, middleware: Middleware): () => void {\n this._init();\n this.middleware[type].add(middleware);\n\n return () => this.middleware[type].delete(middleware);\n }\n\n /**\n * Apply middleware to a value\n *\n * @internal\n */\n static _applyMiddleware(type: MiddlewareType, component: Component, value: any): any {\n let result = value;\n\n this.middleware[type].forEach((middleware) => {\n try {\n result = middleware(component, result);\n } catch (error) {\n console.error(`[Pandora] Error in ${type} middleware:`, error);\n }\n });\n\n return result;\n }\n\n /**\n * Check if there are any middleware registered for a type\n *\n * @internal\n */\n static _hasMiddleware(type: MiddlewareType): boolean {\n return this.middleware[type].size > 0;\n }\n}\n\nexport default Registry;"
|
|
9
|
+
],
|
|
10
|
+
"mappings": "mLAQO,SAAS,CAAY,CAAC,EAAiC,KAAiB,EAAyB,CACtG,GAAI,CACF,IAAM,EAAS,EAAS,MAAM,EAAS,CAAI,EAC3C,OAAO,aAAkB,QAAU,EAAS,QAAQ,QAAQ,CAAM,EAClE,MAAO,EAAG,CACV,OAAO,QAAQ,OAAO,CAAC,GAUpB,SAAS,CAAc,CAAC,EAAmB,EAAwB,GAAI,EAAgB,EAAW,CACvG,IAAM,EAAO,OAAO,KAAK,CAAM,EAC3B,EAAM,GAEV,QAAW,KAAO,EAAM,CACtB,IAAM,EAAQ,EAAO,GAErB,GAAI,OAAO,IAAU,UAAY,IAAU,KAAM,CAC/C,GAAI,GAAiB,CAAC,EAAI,WAAW,GAAG,EACtC,GAAI,EAAI,WAAW,GAAG,EACpB,GAAO,GAAG,EAAI,QAAQ,KAAM,CAAa;AAAA,EAEzC,QAAO,GAAG,KAAiB;AAAA,EAG7B,QAAO,GAAG;AAAA,EAGZ,IAAM,EAAa,OAAO,KAAK,CAAK,EACpC,QAAW,KAAY,EAAY,CACjC,GAAO,KAAK,OAAO,CAAK,EACxB,IAAM,EAAY,EAAM,GAExB,GAAI,OAAO,IAAc,UAAY,IAAc,KAAM,CACvD,IAAM,EAAkB,CAAC,EACzB,EAAK,GAAY,EACjB,GAAO,EAAe,EAAM,EAAe,EAAQ,CAAC,EAEpD,QAAO,IAAK,MAAa;AAAA,EAG7B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iB,YAAa,EAAS,EAAO,QAAU,EAG9D,OAAO,KAAK,YAAY,GAGxB,KAAK,gBAAgB,GAAO,EAC5B,EAAe,YAAc,GAE7B,KAAK,IAAI,2BAA2B,IAAM,EAC1C,MAAO,EAAO,CAEd,MADA,QAAQ,MAAM,4CAA4C,MAAS,CAAK,EAClE,SAUH,OAAM,CAAC,EAAsB,CAClC,OAAO,KAAO,KAAK,wBAQR,QAAO,CAAC,EAA4B,CAC/C,GAAI,KAAK,OAAO,CAAG,EACjB,MAAM,KAAK,mBAAmB,CAAG,QAiB9B,IAAG,CAAC,EAAsB,EAAoC,CAInE,OAHA,KAAK,MAAM,EACX,KAAK,WAAW,GAAM,IAAI,CAAU,EAE7B,IAAM,KAAK,WAAW,GAAM,OAAO,CAAU,QAQ/C,iBAAgB,CAAC,EAAsB,EAAsB,EAAiB,CACnF,IAAI,EAAS,EAUb,OARA,KAAK,WAAW,GAAM,QAAQ,CAAC,IAAe,CAC5C,GAAI,CACF,EAAS,EAAW,EAAW,CAAM,EACrC,MAAO,EAAO,CACd,QAAQ,MAAM,sBAAsB,gBAAoB,CAAK,GAEhE,EAEM,QAQF,eAAc,CAAC,EAA+B,CACnD,OAAO,KAAK,WAAW,GAAM,KAAO,EAExC,CAEA,IAAe",
|
|
11
|
+
"debugId": "60D38C89B54E5C0D64756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { Properties, Style, ReadyCallback } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* A component represents a custom HTML element, and has all of its functionality
|
|
4
|
+
* as well as its general structure and representation self contained on it.
|
|
5
|
+
*
|
|
6
|
+
* @template P - The type of the component's props (defaults to Properties)
|
|
7
|
+
* @template S - The type of the component's state (defaults to Properties)
|
|
8
|
+
*/
|
|
9
|
+
declare class Component<P extends Properties = Properties, S extends Properties = Properties> extends HTMLElement {
|
|
10
|
+
protected _children: string;
|
|
11
|
+
protected _state: S;
|
|
12
|
+
protected _props: P;
|
|
13
|
+
protected _ready: ReadyCallback[];
|
|
14
|
+
protected _connected: boolean;
|
|
15
|
+
protected _isReady: boolean;
|
|
16
|
+
protected _style: Style;
|
|
17
|
+
protected _styleElement: HTMLStyleElement | null;
|
|
18
|
+
static _tag?: string;
|
|
19
|
+
static _template?: string | ((context: any) => string);
|
|
20
|
+
static _observedAttributes: string[];
|
|
21
|
+
static _onMount?: (component: Component, tag: string) => void;
|
|
22
|
+
static _onUnmount?: (component: Component, tag: string) => void;
|
|
23
|
+
static _onError?: (error: Error, component: Component, tag: string, lifecycle: string) => void;
|
|
24
|
+
static _applyMiddleware?: (type: string, component: Component, value: any) => any;
|
|
25
|
+
static _hasMiddleware?: (type: string) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the list of attributes to observe for changes.
|
|
28
|
+
* Override this in subclasses to specify which attributes should trigger attributeChangedCallback.
|
|
29
|
+
*
|
|
30
|
+
* @returns {string[]} - Array of attribute names to observe
|
|
31
|
+
*/
|
|
32
|
+
static get observedAttributes(): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Sets the list of attributes to observe for changes.
|
|
35
|
+
*
|
|
36
|
+
* @param value - The new list of attributes to observe
|
|
37
|
+
*/
|
|
38
|
+
static set observedAttributes(value: string[]);
|
|
39
|
+
static get tag(): string;
|
|
40
|
+
static set tag(value: string);
|
|
41
|
+
static template(html?: string | ((context: any) => string) | null, context?: any): string | undefined | void;
|
|
42
|
+
constructor();
|
|
43
|
+
get width(): number;
|
|
44
|
+
set width(value: number | string);
|
|
45
|
+
get height(): number;
|
|
46
|
+
set height(value: number | string);
|
|
47
|
+
get static(): typeof Component;
|
|
48
|
+
set static(value: typeof Component);
|
|
49
|
+
get props(): P;
|
|
50
|
+
set props(value: P);
|
|
51
|
+
get state(): S;
|
|
52
|
+
set state(value: S);
|
|
53
|
+
get dom(): HTMLElement;
|
|
54
|
+
set dom(value: HTMLElement);
|
|
55
|
+
/**
|
|
56
|
+
* Returns whether the component is currently connected to the DOM.
|
|
57
|
+
*/
|
|
58
|
+
get isConnected(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Returns whether the component has completed its initial mount cycle.
|
|
61
|
+
*/
|
|
62
|
+
get isReady(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* register - Register the component as a custom HTML element
|
|
65
|
+
* using the component's tag as the actual element tag.
|
|
66
|
+
*
|
|
67
|
+
* This action cannot be reverted nor the controller class for
|
|
68
|
+
* the element can be changed.
|
|
69
|
+
*/
|
|
70
|
+
static register(): void;
|
|
71
|
+
/**
|
|
72
|
+
* template - A simple function providing access to the basic HTML
|
|
73
|
+
* structure of the component.
|
|
74
|
+
*
|
|
75
|
+
* @param {function|string} html - A string or function that renders the
|
|
76
|
+
* component into a valid HTML structure.
|
|
77
|
+
*
|
|
78
|
+
* @returns {void|string} - Void or the HTML structure in a string
|
|
79
|
+
*/
|
|
80
|
+
template(html?: string | ((context: any) => string) | null): string | undefined | void;
|
|
81
|
+
protected _createStyleElement(): void;
|
|
82
|
+
setStyle(style: Style | string, reset?: boolean): Style;
|
|
83
|
+
setState(state: Partial<S>): void;
|
|
84
|
+
setProps(props: Partial<P>): void;
|
|
85
|
+
protected _setPropAttributes(update?: boolean): void;
|
|
86
|
+
/**
|
|
87
|
+
* Adds an event listener to the component.
|
|
88
|
+
*
|
|
89
|
+
* @param event - The event type to listen for
|
|
90
|
+
* @param callback - The callback function to execute when the event occurs
|
|
91
|
+
* @param options - Optional event listener options
|
|
92
|
+
* @returns The component instance for chaining
|
|
93
|
+
*/
|
|
94
|
+
on<K extends keyof HTMLElementEventMap>(event: K, callback: (this: this, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): this;
|
|
95
|
+
on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
|
|
96
|
+
/**
|
|
97
|
+
* Removes an event listener from the component.
|
|
98
|
+
*
|
|
99
|
+
* @param event - The event type to remove the listener for
|
|
100
|
+
* @param callback - The callback function to remove
|
|
101
|
+
* @param options - Optional event listener options
|
|
102
|
+
* @returns The component instance for chaining
|
|
103
|
+
*/
|
|
104
|
+
off<K extends keyof HTMLElementEventMap>(event: K, callback: (this: this, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
|
|
105
|
+
off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this;
|
|
106
|
+
/**
|
|
107
|
+
* Adds a one-time event listener that removes itself after the first trigger.
|
|
108
|
+
*
|
|
109
|
+
* @param event - The event type to listen for
|
|
110
|
+
* @param callback - The callback function to execute when the event occurs
|
|
111
|
+
* @param options - Optional event listener options
|
|
112
|
+
* @returns The component instance for chaining
|
|
113
|
+
*/
|
|
114
|
+
once<K extends keyof HTMLElementEventMap>(event: K, callback: (this: this, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): this;
|
|
115
|
+
once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
|
|
116
|
+
/**
|
|
117
|
+
* Emits a custom event from the component.
|
|
118
|
+
*
|
|
119
|
+
* @param event - The event name to emit
|
|
120
|
+
* @param detail - Optional data to include with the event
|
|
121
|
+
* @param options - Optional CustomEvent init options (bubbles, cancelable, composed)
|
|
122
|
+
* @returns Whether the event was not cancelled
|
|
123
|
+
*/
|
|
124
|
+
emit<T = unknown>(event: string, detail?: T, options?: Omit<CustomEventInit<T>, 'detail'>): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Queries for a single element within the component's DOM.
|
|
127
|
+
*
|
|
128
|
+
* @param selector - CSS selector to query for
|
|
129
|
+
* @returns The first matching element or null
|
|
130
|
+
*/
|
|
131
|
+
query<E extends Element = Element>(selector: string): E | null;
|
|
132
|
+
/**
|
|
133
|
+
* Queries for all matching elements within the component's DOM.
|
|
134
|
+
*
|
|
135
|
+
* @param selector - CSS selector to query for
|
|
136
|
+
* @returns A NodeList of all matching elements
|
|
137
|
+
*/
|
|
138
|
+
queryAll<E extends Element = Element>(selector: string): NodeListOf<E>;
|
|
139
|
+
/**
|
|
140
|
+
* Called before the component updates due to state or props changes.
|
|
141
|
+
* Override this method to perform actions before an update occurs.
|
|
142
|
+
*
|
|
143
|
+
* @param origin - Whether the update was triggered by 'state' or 'props'
|
|
144
|
+
* @param property - The name of the property that changed
|
|
145
|
+
* @param oldValue - The previous value of the property
|
|
146
|
+
* @param newValue - The new value of the property
|
|
147
|
+
* @param oldObject - The previous state/props object
|
|
148
|
+
* @param newObject - The new state/props object
|
|
149
|
+
* @returns A promise that resolves when the pre-update logic completes
|
|
150
|
+
*/
|
|
151
|
+
protected willUpdate(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Called when the component updates due to state or props changes.
|
|
154
|
+
* Override this method to perform actions during an update.
|
|
155
|
+
*
|
|
156
|
+
* @param origin - Whether the update was triggered by 'state' or 'props'
|
|
157
|
+
* @param property - The name of the property that changed
|
|
158
|
+
* @param oldValue - The previous value of the property
|
|
159
|
+
* @param newValue - The new value of the property
|
|
160
|
+
* @param oldObject - The previous state/props object
|
|
161
|
+
* @param newObject - The new state/props object
|
|
162
|
+
* @returns A promise that resolves when the update logic completes
|
|
163
|
+
*/
|
|
164
|
+
protected update(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Called after the component updates due to state or props changes.
|
|
167
|
+
* Override this method to perform actions after an update completes.
|
|
168
|
+
*
|
|
169
|
+
* @param origin - Whether the update was triggered by 'state' or 'props'
|
|
170
|
+
* @param property - The name of the property that changed
|
|
171
|
+
* @param oldValue - The previous value of the property
|
|
172
|
+
* @param newValue - The new value of the property
|
|
173
|
+
* @param oldObject - The previous state/props object
|
|
174
|
+
* @param newObject - The new state/props object
|
|
175
|
+
* @returns A promise that resolves when the post-update logic completes
|
|
176
|
+
*/
|
|
177
|
+
protected didUpdate(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Called when the component's state updates.
|
|
180
|
+
* Override this method to react specifically to state changes.
|
|
181
|
+
*
|
|
182
|
+
* @param property - The name of the state property that changed
|
|
183
|
+
* @param oldValue - The previous value of the property
|
|
184
|
+
* @param newValue - The new value of the property
|
|
185
|
+
* @param oldObject - The previous state object
|
|
186
|
+
* @param newObject - The new state object
|
|
187
|
+
* @returns A promise that resolves when the state update logic completes
|
|
188
|
+
*/
|
|
189
|
+
protected onStateUpdate(property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
190
|
+
/**
|
|
191
|
+
* Called when the component's props update.
|
|
192
|
+
* Override this method to react specifically to props changes.
|
|
193
|
+
*
|
|
194
|
+
* @param property - The name of the prop that changed
|
|
195
|
+
* @param oldValue - The previous value of the property
|
|
196
|
+
* @param newValue - The new value of the property
|
|
197
|
+
* @param oldObject - The previous props object
|
|
198
|
+
* @param newObject - The new props object
|
|
199
|
+
* @returns A promise that resolves when the props update logic completes
|
|
200
|
+
*/
|
|
201
|
+
protected onPropsUpdate(property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Called before the component is mounted to the DOM.
|
|
204
|
+
* Override this method to perform setup before rendering.
|
|
205
|
+
*
|
|
206
|
+
* @returns A promise that resolves when the pre-mount logic completes
|
|
207
|
+
*/
|
|
208
|
+
protected willMount(): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Called after the component is mounted to the DOM.
|
|
211
|
+
* Override this method to perform actions after the component is rendered.
|
|
212
|
+
*
|
|
213
|
+
* @returns A promise that resolves when the post-mount logic completes
|
|
214
|
+
*/
|
|
215
|
+
protected didMount(): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Called before the component is removed from the DOM.
|
|
218
|
+
* Override this method to perform cleanup before unmounting.
|
|
219
|
+
*
|
|
220
|
+
* @returns A promise that resolves when the pre-unmount logic completes
|
|
221
|
+
*/
|
|
222
|
+
protected willUnmount(): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Called when the component is being removed from the DOM.
|
|
225
|
+
* Override this method to perform cleanup during unmounting.
|
|
226
|
+
*
|
|
227
|
+
* @returns A promise that resolves when the unmount logic completes
|
|
228
|
+
*/
|
|
229
|
+
protected unmount(): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Called after the component is removed from the DOM.
|
|
232
|
+
* Override this method to perform final cleanup after unmounting.
|
|
233
|
+
*
|
|
234
|
+
* @returns A promise that resolves when the post-unmount logic completes
|
|
235
|
+
*/
|
|
236
|
+
protected didUnmount(): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Forces the component to be rendered again.
|
|
239
|
+
*
|
|
240
|
+
* @returns A promise that resolves with the rendered HTML string
|
|
241
|
+
*/
|
|
242
|
+
forceRender(): string | Promise<string>;
|
|
243
|
+
/**
|
|
244
|
+
* Returns the HTML content for the component.
|
|
245
|
+
* Override this method to define the component's template.
|
|
246
|
+
*
|
|
247
|
+
* @returns The HTML string to render
|
|
248
|
+
*/
|
|
249
|
+
render(): string;
|
|
250
|
+
protected _render(): Promise<string>;
|
|
251
|
+
connectedCallback(): Promise<void>;
|
|
252
|
+
ready(callback: ReadyCallback): void;
|
|
253
|
+
disconnectedCallback(): Promise<void>;
|
|
254
|
+
protected updateCallback(property: string, oldValue: unknown, newValue: unknown, origin?: 'props' | 'state' | 'attribute', oldObject?: P | S, newObject?: P | S): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Called when an observed attribute changes.
|
|
257
|
+
* This is a Web Components lifecycle callback.
|
|
258
|
+
*
|
|
259
|
+
* @param property - The name of the attribute that changed
|
|
260
|
+
* @param oldValue - The previous value of the attribute
|
|
261
|
+
* @param newValue - The new value of the attribute
|
|
262
|
+
*/
|
|
263
|
+
attributeChangedCallback(property: string, oldValue: string | null, newValue: string | null): void;
|
|
264
|
+
}
|
|
265
|
+
export default Component;
|
|
266
|
+
//# sourceMappingURL=Component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/Component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;;;GAMG;AACH,cAAM,SAAS,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,WAAW;IACvG,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACpB,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACpB,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC;IAClC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC;IAC9B,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;IACxB,SAAS,CAAC,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAGjD,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAErB,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IAIvD,MAAM,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAM;IAG1C,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SA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