Socket
Socket
Sign inDemoInstall

@webqit/subscript

Package Overview
Dependencies
2
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.13 to 2.0.14

2

dist/inspector-element.js

@@ -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.subscriptConsole instanceof Map?e:null)),null);t&&this.inspectElement(t)}),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.subscriptConsole.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)this.consoleElement.bind(t);else{let t=Object.keys(this.buttons);if(t.length){let e=this.buttons[t[0]],n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});e.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.subscripts instanceof Map?e:null)),null);t&&this.inspectElement(t)}),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.subscriptConsole.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)this.consoleElement.bind(t);else{let t=Object.keys(this.buttons);if(t.length){let e=this.buttons[t[0]],n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});e.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.0.13",
"version": "2.0.14",
"license": "MIT",

@@ -14,0 +14,0 @@ "repository": {

@@ -277,3 +277,3 @@

this.setLocation( memo, node.test );
return unit.generate( Node.ifStmt( $test, consequent, alternate ) );
return unit.generate( Node.ifStmt( $test, consequent, alternate ) );
} );

@@ -552,5 +552,2 @@ }

generateExpressionStatement( context, node ) {
if ( node.expression.type === 'SequenceExpression' ) {
return Node.exprStmt( this.generateSequenceExpression( context, node.expression ) );
}
let def = { type: node.type };

@@ -575,9 +572,9 @@ return context.defineUnit( def, unit => {

let def = { type: expr.type, inSequence: true };
if ( i === node.expressions.length - 1 ) {
[ expr ] = context.currentUnit.chainableReference( def, () => this.generateNodes( context, [ expr ] ) );
return expr;
}
return context.defineUnit( def, unit => {
this.setLocation( unit, expr );
if ( i === node.expressions.length - 1 ) {
[ expr ] = unit.chainableReference( def, () => this.generateNodes( context, [ expr ] ) );
} else {
[ expr ] = unit.signalReference( def, () => this.generateNodes( context, [ expr ] ) );
}
[ expr ] = unit.signalReference( def, () => this.generateNodes( context, [ expr ] ) );
return expr.type === 'Identifier' ? expr : unit.generate( expr );

@@ -781,3 +778,3 @@ } );

// The ongoing reference must be used for callee
let [ callee ] = context.currentUnit.currentReference.with( { isCallee: true, callType: node.type }, () => this.generateNodes( context, [ node.callee ] ) );
let [ callee ] = context.currentUnit.signalReference( { type: node.callee.type }, () => this.generateNodes( context, [ node.callee ] ) );
let args = node.arguments.map( argument => context.currentUnit.signalReference( { type: argument.type }, () => this.generateNodes( context, [ argument ] )[ 0 ] ) );

@@ -784,0 +781,0 @@ return generate.call( Node, callee, args, node.optional );

@@ -178,5 +178,5 @@

chainableReference( def, callback ) {
return this.currentReference && this.currentReference.refs.size && !this.currentReference.propertyStack.length
? this.signalReference( def, callback )
: callback();
return this.currentReference && this.currentReference.propertyStack.length
? callback()
: this.signalReference( def, callback );
}

@@ -229,3 +229,3 @@

this.entryStack.shift();
if ( ( entry instanceof Unit ) && !entry.references.length && !entry.isIteration ) {
if ( ( entry instanceof Unit ) && !entry.generatable() ) {
this.entries = this.entries.filter( _entry => _entry !== entry );

@@ -313,3 +313,3 @@ }

generatable() {
return this.references.length || ( this instanceof Context ) || this.isIteration;
return this.references.length || ( this instanceof Context );
}

@@ -429,3 +429,3 @@

this.entries.slice( 0 ).reverse().forEach( entry => {
if ( entry instanceof Unit ) {
if ( ( entry instanceof Unit ) && entry.generated ) {
let target = find( entry.lineage.split( '/' ).slice( offset, -1 ) );

@@ -432,0 +432,0 @@ target.subUnits[ entry.id ] = entry.toJson( filter );

@@ -20,3 +20,3 @@

setTimeout( () => { // Allow embedded script in slotted elements to manifest
let subscriptElement = this._contentSlot.assignedNodes().reduce( ( _subscriptElement, node ) => _subscriptElement || ( node.subscriptConsole instanceof Map ? node : null), null );
let subscriptElement = this._contentSlot.assignedNodes().reduce( ( _subscriptElement, node ) => _subscriptElement || ( node.subscripts instanceof Map ? node : null), null );
if ( subscriptElement ) {

@@ -23,0 +23,0 @@ this.inspectElement( subscriptElement );

@@ -14,3 +14,3 @@

this.exits = exits || new Map;
this.$thread = $thread || { entries: new Map, sequence: [], ownerUnit: this.graph.lineage };
this.$thread = $thread || { entries: new Map, sequence: [], ownerUnit: this };
this.subUnits = new Map;

@@ -117,3 +117,3 @@ this.unit = function( unitId, arg1, arg2 = null, arg3 = null ) {

if ( this.disposed ) {
throw new Error( `Instance not runable after disposal.` );
throw new Error( `[${ this.graph.type }:${ this.graph.lineage }]: Instance not runable after having been disposed.` );
}

@@ -382,3 +382,5 @@ let returnValue = this.callee.call( $this, this.unit, ...$arguments );

}
return subUnit.locate( unitUrl );
if ( subUnit ) {
return subUnit.locate( unitUrl );
}
}

@@ -403,10 +405,10 @@ return subUnit;

let memo = this.unit.memo;
if ( typeof conditionDef.parent !== 'undefined' && !this.assert( conditionDef.parent ) ) return false;
if ( typeof conditionDef.switch !== 'undefined' ) {
if ( typeof conditionDef.parent !== 'undefined' && !this.assert( conditionDef.parent ) ) return false;
if ( typeof conditionDef.switch !== 'undefined' ) {
return conditionDef.cases.some( _case => memo[ _case ] === memo[ conditionDef.switch ] );
}
if ( typeof conditionDef.whenNot !== 'undefined' ) {
return memo[ conditionDef.whenNot ];
if ( typeof conditionDef.whenNot !== 'undefined' ) {
return !memo[ conditionDef.whenNot ];
}
if ( typeof conditionDef.when !== 'undefined' ) {
if ( typeof conditionDef.when !== 'undefined' ) {
return memo[ conditionDef.when ];

@@ -418,2 +420,3 @@ }

dispose() {
if ( this.params.isFunctionUnit ) return;
this.subUnits.forEach( ( subUnit, unitId ) => {

@@ -429,3 +432,2 @@ if ( subUnit instanceof Map ) {

delete this.ownerUnit;
delete this.graph;
delete this.callee;

@@ -432,0 +434,0 @@ delete this.params;

@@ -15,7 +15,18 @@ /**

let source = normalizeTabs( args.pop() || '' );
let ast = parse( source );
let compiler = new Compiler( params.compiler );
let compilation = compiler.generate( ast );
let compilation, parameters = args;
if ( Subscript.cache[ source ] && !params.compiler.devMode && compare( parameters, Subscript.cache[ source ][ 1 ] ) && deepEql( params.compiler, Subscript.cache[ source ][ 2 ] ) ) {
// ----------------
[ compilation, parameters ] = Subscript.cache[ source ];
// ----------------
} else {
let ast = parse( source );
let compiler = new Compiler( params.compiler );
compilation = compiler.generate( ast );
// ----------------
Subscript.cache[ source ] = [ compilation, parameters, params.compiler ];
// ----------------
}
return create( this, compilation, args, params.runtime, source );
}
Subscript.cache = {};

@@ -39,2 +50,3 @@ /**

*/
Subscript.cloneCache = {};
Subscript.clone = function( _function, defaultThis = null, _compilerParams = {}, _runtimeParams = {} ) {

@@ -66,15 +78,25 @@ if ( typeof _function !== 'function' ) {

source = 'function ' + source;
}
let ast = parse( source ).body[ 0 ];
let bodyStart = ast.body.start + 1/* the opening brace */;
if ( source.substr( bodyStart, 1 ) === "\n" ) {
bodyStart += 1;
}
let compiler = new Compiler( { ..._compilerParams, ...Subscript.compilerParams, locStart: - bodyStart } );
let parameters = ast.params.map( paramExpr => compiler.serialize( paramExpr ) );
let compilation = compiler.generate( { type: 'Program', body: ast.body.body } );
if ( !compilation.graph.hoistedAwaitKeyword && isAsync ) {
compilation.graph.hoistedAwaitKeyword = true;
let compilation, parameters, originalSource;
if ( Subscript.cloneCache[ source ] && !_compilerParams.devMode && deepEql( _compilerParams, Subscript.cloneCache[ source ][ 3 ] ) ) {
// ----------------
[ compilation, parameters, originalSource ] = Subscript.cloneCache[ source ];
// ----------------
} else {
let ast = parse( source ).body[ 0 ];
let bodyStart = ast.body.start + 1/* the opening brace */;
if ( source.substr( bodyStart, 1 ) === "\n" ) {
bodyStart += 1;
}
let compiler = new Compiler( { ..._compilerParams, ...Subscript.compilerParams, locStart: - bodyStart } );
parameters = ast.params.map( paramExpr => compiler.serialize( paramExpr ) );
compilation = compiler.generate( { type: 'Program', body: ast.body.body } );
if ( !compilation.graph.hoistedAwaitKeyword && isAsync ) {
compilation.graph.hoistedAwaitKeyword = true;
}
originalSource = source.substring( bodyStart, ast.body.end - 1 );
// ----------------
Subscript.cloneCache[ source ] = [ compilation, parameters, originalSource, _compilerParams ];
// ----------------
}
let originalSource = source.substring( bodyStart, ast.body.end - 1 );
return create( defaultThis, compilation, parameters, _runtimeParams, originalSource, _function.name );

@@ -123,2 +145,17 @@ }

return ast;
};
/**
* @deepEql
*/
const compare = ( a, b ) => {
if ( typeof a === 'object' && a && typeof b === 'object' && b ) return deepEql( a, b );
if ( Array.isArray( a ) && Array.isArray( b ) && a.length === b.length ) return a.every( valueA => b.some( valueB => compare( valueA, valueB ) ) );
return a === b;
}
const deepEql = function( a, b ) {
for ( let key in a ) {
if ( !compare( a[ key ], b[ key ] ) ) return false;
}
return true;
};

@@ -55,2 +55,12 @@

globalThis.a = '';
let source4 = `
let scrollSpyActive = this.state.scrollSpy?.active;
let documentUrl = document.state.url?.href;
let match = this._matchQueryHash(scrollSpyActive) || this._matchQueryParams(documentUrl) || this._matchQueryPath(documentUrl) || {};
this.state.active = match.active;
this.state.hasActive = match.hasActive;
this.state.expanded = match.expanded;
`;
globalThis.d = undefined;

@@ -60,3 +70,3 @@

Subscript.compilerParams.globalsNoObserve.push( 'console' );
let subscriptFunction = new Subscript( 'param1', 'param2', 'param3', source3 );
let subscriptFunction = new Subscript( 'param1', 'param2', 'param3', source4 );
console.log( '.....................sideEffects', subscriptFunction.sideEffects );

@@ -100,3 +110,3 @@ // -----------

let result = subscriptFunction( '55', '55', 'sum' );
let result;// = subscriptFunction( '55', '55', 'sum' );
console.log( '------->', result );

@@ -103,0 +113,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc