@webqit/subscript
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -1,2 +0,2 @@ | ||
(()=>{"use strict";var t={829:(t,e,n)=>{n.d(e,{Z:()=>s});const s=t=>class extends t{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach((t=>{if(t.includes("{")&&t.includes(":")&&t.includes(";"))this.shadowRoot.appendChild(document.createElement("style")).textContent=t;else{let e=this.shadowRoot.appendChild(document.createElement("link"));e.setAttribute("rel","stylesheet"),e.setAttribute("href",t)}}))}get css(){return[]}}}},e={};function n(s){var o=e[s];if(void 0!==o)return o.exports;var i=e[s]={exports:{}};return t[s](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t=n(829);class e extends((0,t.Z)(HTMLElement)){connectedCallback(){this._contentSlot=document.createElement("slot"),this.shadowRoot.append(this._contentSlot),super.connectedCallback(),this._contentSlot.addEventListener("slotchange",(()=>{setTimeout((()=>{let t=this._contentSlot.assignedNodes().reduce(((t,e)=>t||(e.subscripts instanceof Map?e:null)),null);if(t){this.inspectElement(t);let e=this.getAttribute("active");e&&this.inspectFunction(e)}}),0)}))}inspectElement(t){this.consoleElement&&(this.consoleElement.remove(),this.controlsElement.remove()),this.consoleElement=document.createElement("subscript-console"),this.controlsElement=document.createElement("div"),this.controlsElement.classList.add("controls-element"),this.shadowRoot.append(this.consoleElement,this.controlsElement),this.buttons={},t.subscripts.forEach(((t,e)=>{let n="number"==typeof e?`script:${e}`:`${e}()`;this.buttons[e]=this.controlsElement.appendChild(document.createElement("button")),this.buttons[e].setAttribute("script-id",e),this.buttons[e].setAttribute("title",n),this.buttons[e].appendChild(document.createElement("span")).append(" ",n);let s=this.buttons[e].appendChild(document.createElement("i"));(this.getAttribute("data-icons")||"bi bi-"+("number"==typeof e?"code":"braces")).split(" ").map((t=>t.trim())).forEach((t=>s.classList.add(t))),this.buttons[e].addEventListener("click",(n=>{this.active&&this.active.classList.remove("active"),this.active=this.buttons[e],this.active.classList.add("active"),this.inspectFunction(t)}))}))}inspectFunction(t){if(t&&"string"!=typeof t)this.consoleElement.bind(t);else{let e=t;if(t||(e=Object.keys(this.buttons)[0]),e){let t=this.buttons[e],n=new MouseEvent("click",{view:window});t.dispatchEvent(n)}}}get css(){return["https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css","\n * {\n -webkit-box-sizing: border-box;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n }\n :host {\n position: relative;\n display: block;\n background-color: rgb(75, 75, 75);\n }\n .controls-element {\n position: relative;\n z-index: 10;\n }\n .controls-element button {\n display: inline-flex;\n align-items: center;\n background-color: transparent;\n padding: 0.5rem 1rem;\n border: none;\n color: silver;\n }\n .controls-element button:is(:hover, .active) {\n background-color: dimgray;\n color: gainsboro;\n }\n .controls-element button .bi {\n margin-left: 0.5rem;\n }\n "]}}customElements.define("subscript-inspector",e)})()})(); | ||
(()=>{"use strict";var t={829:(t,e,n)=>{n.d(e,{Z:()=>s});const s=t=>class extends t{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach((t=>{if(t.includes("{")&&t.includes(":")&&t.includes(";"))this.shadowRoot.appendChild(document.createElement("style")).textContent=t;else{let e=this.shadowRoot.appendChild(document.createElement("link"));e.setAttribute("rel","stylesheet"),e.setAttribute("href",t)}}))}get css(){return[]}}}},e={};function n(s){var o=e[s];if(void 0!==o)return o.exports;var i=e[s]={exports:{}};return t[s](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t=n(829);class e extends((0,t.Z)(HTMLElement)){connectedCallback(){this._contentSlot=document.createElement("slot"),this.shadowRoot.append(this._contentSlot),super.connectedCallback(),this._contentSlot.addEventListener("slotchange",(()=>{setTimeout((()=>{let t=this._contentSlot.assignedNodes().reduce(((t,e)=>t||(e.subscript instanceof Map?e:null)),null);if(t){this.inspectElement(t);let e=this.getAttribute("active");e&&this.inspectFunction(e)}}),0)}))}inspectElement(t){this.consoleElement&&(this.consoleElement.remove(),this.controlsElement.remove()),this.consoleElement=document.createElement("subscript-console"),this.controlsElement=document.createElement("div"),this.controlsElement.classList.add("controls-element"),this.shadowRoot.append(this.consoleElement,this.controlsElement),this.buttons={},t.subscript.forEach(((t,e)=>{let n="number"==typeof e?`script:${e}`:`${e}()`;this.buttons[e]=this.controlsElement.appendChild(document.createElement("button")),this.buttons[e].setAttribute("script-id",e),this.buttons[e].setAttribute("title",n),this.buttons[e].appendChild(document.createElement("span")).append(" ",n);let s=this.buttons[e].appendChild(document.createElement("i"));(this.getAttribute("data-icons")||"bi bi-"+("number"==typeof e?"code":"braces")).split(" ").map((t=>t.trim())).forEach((t=>s.classList.add(t))),this.buttons[e].addEventListener("click",(n=>{this.active&&this.active.classList.remove("active"),this.active=this.buttons[e],this.active.classList.add("active"),this.inspectFunction(t)}))}))}inspectFunction(t){if(t&&"string"!=typeof t)this.consoleElement.bind(t);else{let e=t;if(t||(e=Object.keys(this.buttons)[0]),e){let t=this.buttons[e],n=new MouseEvent("click",{view:window});t.dispatchEvent(n)}}}get css(){return["https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css","\n * {\n -webkit-box-sizing: border-box;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n }\n :host {\n position: relative;\n display: block;\n background-color: rgb(75, 75, 75);\n }\n .controls-element {\n position: relative;\n z-index: 10;\n }\n .controls-element button {\n display: inline-flex;\n align-items: center;\n background-color: transparent;\n padding: 0.5rem 1rem;\n border: none;\n color: silver;\n }\n .controls-element button:is(:hover, .active) {\n background-color: dimgray;\n color: gainsboro;\n }\n .controls-element button .bi {\n margin-left: 0.5rem;\n }\n "]}}customElements.define("subscript-inspector",e)})()})(); | ||
//# sourceMappingURL=inspector-element.js.map |
@@ -11,3 +11,3 @@ { | ||
"homepage": "https://webqit.io/tooling/subscript", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "repository": { |
@@ -19,4 +19,4 @@ | ||
this._contentSlot.addEventListener( 'slotchange', () => { | ||
setTimeout( () => { // Allow embedded subscripts in slotted elements to manifest | ||
let subscriptElement = this._contentSlot.assignedNodes().reduce( ( _subscriptElement, node ) => _subscriptElement || ( node.subscripts instanceof Map ? node : null), null ); | ||
setTimeout( () => { // Allow embedded subscript instances in slotted elements to manifest | ||
let subscriptElement = this._contentSlot.assignedNodes().reduce( ( _subscriptElement, node ) => _subscriptElement || ( node.subscript instanceof Map ? node : null), null ); | ||
if ( subscriptElement ) { | ||
@@ -45,3 +45,3 @@ this.inspectElement( subscriptElement ); | ||
this.buttons = {}; | ||
subscriptElement.subscripts.forEach( ( subscriptFunction, id ) => { | ||
subscriptElement.subscript.forEach( ( subscriptFunction, id ) => { | ||
let title = typeof id === 'number' ? `script:${ id }` : `${ id }()`; | ||
@@ -48,0 +48,0 @@ this.buttons[ id ] = this.controlsElement.appendChild( document.createElement( 'button' ) ); |
@@ -15,2 +15,10 @@ | ||
static get compilerParams() { | ||
return {}; | ||
} | ||
static get runtimeParams() { | ||
return {}; | ||
} | ||
static get subscriptMethods() { | ||
@@ -20,4 +28,4 @@ return []; | ||
static implementMethod( method, thisBinding = undefined ) { | ||
return SubscriptFunction.clone( method, thisBinding ); | ||
static implementMethod( method, thisBinding = null ) { | ||
return SubscriptFunction.clone( method, thisBinding, this.compilerParams, this.runtimeParams ); | ||
} | ||
@@ -24,0 +32,0 @@ |
@@ -12,7 +12,7 @@ /** | ||
let params = typeof args[ args.length - 1 ] === 'object' ? args.pop() : {}; | ||
params.compiler = { ...SubscriptFunction.compilerParams, ...( params.compiler || {} ) }; | ||
params.runtime = { ...SubscriptFunction.runtimeParams, ...( params.runtime || {} ) }; | ||
params.compilerParams = { ...SubscriptFunction.compilerParams, ...( params.compilerParams || {} ) }; | ||
params.runtimeParams = { ...SubscriptFunction.runtimeParams, ...( params.runtimeParams || {} ) }; | ||
let source = normalizeTabs( args.pop() || '' ); | ||
let compilation, parameters = args; | ||
if ( SubscriptFunction.cache[ source ] && !params.compiler.devMode && compare( parameters, SubscriptFunction.cache[ source ][ 1 ] ) && deepEql( params.compiler, SubscriptFunction.cache[ source ][ 2 ] ) ) { | ||
if ( SubscriptFunction.cache[ source ] && !params.compilerParams.devMode && compare( parameters, SubscriptFunction.cache[ source ][ 1 ] ) && deepEql( params.compilerParams, SubscriptFunction.cache[ source ][ 2 ] ) ) { | ||
// ---------------- | ||
@@ -23,9 +23,9 @@ [ compilation, parameters ] = SubscriptFunction.cache[ source ]; | ||
let ast = parse( source ); | ||
let compiler = new Compiler( params.compiler ); | ||
let compiler = new Compiler( params.compilerParams ); | ||
compilation = compiler.generate( ast ); | ||
// ---------------- | ||
SubscriptFunction.cache[ source ] = [ compilation, parameters, params.compiler ]; | ||
SubscriptFunction.cache[ source ] = [ compilation, parameters, params.compilerParams ]; | ||
// ---------------- | ||
} | ||
return create( this, compilation, args, params.runtime, source ); | ||
return create( this, compilation, args, params.runtimeParams, source ); | ||
} | ||
@@ -32,0 +32,0 @@ SubscriptFunction.cache = {}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3660257
6897