Socket
Socket
Sign inDemoInstall

view-launcher

Package Overview
Dependencies
3
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

1

dist/ElementIndicator.d.ts

@@ -21,2 +21,3 @@ import { Editor } from './editorUrl';

};
export declare const defaultOptions: Options;
export declare class ElementIndicator {

@@ -23,0 +24,0 @@ private readonly options;

@@ -354,3 +354,4 @@ 'use strict';

exports.ElementIndicator = ElementIndicator;
exports.defaultOptions = defaultOptions;
exports.viewLauncher = viewLauncher;
//# sourceMappingURL=view-launcher.cjs.development.js.map

2

dist/view-launcher.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("mousetrap"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("@popperjs/core");function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var o={sublime:"subl://open?url=file://{path}&line={line}&column={column}",textmate:"txmt://open?url=file://{path}&line={line}&column={column}",emacs:"emacs://open?url=file://{path}&line={line}&column={column}",macvim:"mvim://open/?url=file://{path}&line={line}&column={column}",phpstorm:"phpstorm://open?file={path}&line={line}&column={column}",idea:"idea://open?file={path}&line={line}&column={column}",vscode:"vscode://file/{path}:{line}:{column}","vscode-insiders":"vscode-insiders://file/{path}:{line}:{column}",atom:"atom://core/open/file?filename={path}&line={line}&column={column}"};function l(e){return function e(t,n){return t.parentElement?n(t)?t:e(t.parentElement,n):null}(e,(function(e){return e.hasOwnProperty("tagInfo")}))}function r(e){var t=document.createElement("div");if(t.innerHTML=e,0===t.childElementCount)throw new Error("Couldn't create elements from '"+e+"'");return 1===t.childElementCount?t.firstElementChild:Array.from(t.children)}var a={theme:"light",editor:"vscode",shortcuts:{open:"d",inspect:"a a",inspectComponent:"c c",inspectParent:"up"}},s=function(){function e(e){this._enabled=!1,this.options=i({},a,e),this.createElements(),this.addEventListeners(),this.registerHotkeys(),this.keepUpdatingOnEvents()}var s,c=e.prototype;return c.createElements=function(){var e=this.options.theme,t=document.body,i=r('<div id="view-launcher-indicator" class="--'+e+'"></div>'),o=r('<div id="view-launcher-tooltip" class="--'+e+'">\n<div class="__tag-info"></div>\n<div class="__view-name"></div>\n</div>'),l=o.querySelector(".__tag-info"),a=o.querySelector(".__view-name");t.appendChild(i),t.appendChild(o),this.popper=n.createPopper(i,o,{placement:"top-start",modifiers:[{name:"offset",options:{offset:[0,5]}}]}),this.indicator=i,this.tooltip=o,this.tagInfo=l,this.viewName=a},c.addEventListeners=function(){var e=this;Array.from(document.querySelectorAll("[data-tag-info]")).filter((function(e){e.tagInfo=JSON.parse(e.dataset.tagInfo),e.removeAttribute("data-tag-info");var t=getComputedStyle(e);return!(["HTML","HEAD","BODY","SCRIPT","NOSCRIPT","META","LINK","STYLE","TITLE","BASE"].includes(e.tagName)||"none"===t.display||"hidden"===t.visibility)})).forEach((function(t){t.addEventListener("mouseenter",(function(){e.disabled||e.setElement(t)})),t.addEventListener("mouseleave",(function(t){var n=t.relatedTarget;if(!e.disabled&&n instanceof Element){var i=l(n);i&&e.setElement(i)}}))}))},c.registerHotkeys=function(){var e=this,n=this.options,i=n.shortcuts,r=n.editor;t.bind(i.inspect,(function(){e.toggleEnable(),document.body.classList.toggle("view-launcher-inspecting")})),t.bind(i.open,(function(){if(e.enabled&&e.element){var t,n,i,l=e.element.tagInfo;window.location.href=(n=(t={editor:r,viewPath:l.view,line:l.line,column:l.column}).line,i=t.column,function(e,t){return t?e.replace("{column}",t.toString()):e.replace("&column={column}","").replace(":{column}","")}(function(e,t){return t?e.replace("{line}",t.toString()):e.replace("&line={line}&column={column}","").replace(":{line}:{column}","")}(o[t.editor].replace("{path}",encodeURIComponent(t.viewPath)),n),i))}})),t.bind(i.inspectParent,(function(){var t;if(null!=(t=e.element)&&t.parentElement){var n=l(e.element.parentElement);n&&e.setElement(n)}})),t.bind("esc",(function(){e.disable(),document.body.classList.contains("view-launcher-inspecting")&&document.body.classList.remove("view-launcher-inspecting")}))},c.keepUpdatingOnEvents=function(){var e=this;window.addEventListener("scroll",this.update),window.addEventListener("resize",this.update);var t=document.body;new MutationObserver((function(){e.addEventListeners()})).observe(t,{attributes:!1,childList:!0,subtree:!0})},e.create=function(t){if(void 0===t&&(t={}),e.instance)return e.instance;var n=new e(t);return e.instance=n},c.setElement=function(e){this.element=e,this.show(),this.update()},c.update=function(){if(this.element&&!this.disabled){var e=this.indicator.style,t=this.element.getBoundingClientRect(),n=document.documentElement.clientHeight,i=t.top+t.height>n,o=t.top>0?i?n-t.top:t.height:i?n:t.height+t.top;e.width=t.width+"px",e.height=o+"px",e.left=t.left+"px",e.top=(t.top>0?t.top:0)+"px";var l=this.element,r=Array.from(l.classList).join("."),a=l.tagName.toLowerCase(),s=l.tagInfo.view.match(/[^/\\]+?$/)[0];this.tagInfo.innerHTML=(l.tagInfo.component?'<i class="__is-component"></i>':"")+(l.tagInfo.component||a+(r?"."+r:"")),this.viewName.innerText=s,this.popper.setOptions({modifiers:[{name:"offset",options:{offset:i&&t.top<0?[6,-(this.tooltip.clientHeight+5)]:[0,5]}}]}),this.popper.update()}},c.hide=function(){[this.indicator,this.tooltip].forEach((function(e){e.style.visibility="hidden"}))},c.show=function(){[this.indicator,this.tooltip].forEach((function(e){e.style.visibility="visible"}))},c.enable=function(){this._enabled=!0,this.update(),this.show()},c.disable=function(){this._enabled=!1,this.hide()},c.toggleEnable=function(){this._enabled?this.disable():this.enable()},(s=[{key:"enabled",get:function(){return this._enabled}},{key:"disabled",get:function(){return!this._enabled}}])&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,s),e}();exports.ElementIndicator=s,exports.viewLauncher=function(e){void 0===e&&(e={}),s.create(e)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("mousetrap"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("@popperjs/core");function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var o={sublime:"subl://open?url=file://{path}&line={line}&column={column}",textmate:"txmt://open?url=file://{path}&line={line}&column={column}",emacs:"emacs://open?url=file://{path}&line={line}&column={column}",macvim:"mvim://open/?url=file://{path}&line={line}&column={column}",phpstorm:"phpstorm://open?file={path}&line={line}&column={column}",idea:"idea://open?file={path}&line={line}&column={column}",vscode:"vscode://file/{path}:{line}:{column}","vscode-insiders":"vscode-insiders://file/{path}:{line}:{column}",atom:"atom://core/open/file?filename={path}&line={line}&column={column}"};function l(e){return function e(t,n){return t.parentElement?n(t)?t:e(t.parentElement,n):null}(e,(function(e){return e.hasOwnProperty("tagInfo")}))}function r(e){var t=document.createElement("div");if(t.innerHTML=e,0===t.childElementCount)throw new Error("Couldn't create elements from '"+e+"'");return 1===t.childElementCount?t.firstElementChild:Array.from(t.children)}var a={theme:"light",editor:"vscode",shortcuts:{open:"d",inspect:"a a",inspectComponent:"c c",inspectParent:"up"}},s=function(){function e(e){this._enabled=!1,this.options=i({},a,e),this.createElements(),this.addEventListeners(),this.registerHotkeys(),this.keepUpdatingOnEvents()}var s,c=e.prototype;return c.createElements=function(){var e=this.options.theme,t=document.body,i=r('<div id="view-launcher-indicator" class="--'+e+'"></div>'),o=r('<div id="view-launcher-tooltip" class="--'+e+'">\n<div class="__tag-info"></div>\n<div class="__view-name"></div>\n</div>'),l=o.querySelector(".__tag-info"),a=o.querySelector(".__view-name");t.appendChild(i),t.appendChild(o),this.popper=n.createPopper(i,o,{placement:"top-start",modifiers:[{name:"offset",options:{offset:[0,5]}}]}),this.indicator=i,this.tooltip=o,this.tagInfo=l,this.viewName=a},c.addEventListeners=function(){var e=this;Array.from(document.querySelectorAll("[data-tag-info]")).filter((function(e){e.tagInfo=JSON.parse(e.dataset.tagInfo),e.removeAttribute("data-tag-info");var t=getComputedStyle(e);return!(["HTML","HEAD","BODY","SCRIPT","NOSCRIPT","META","LINK","STYLE","TITLE","BASE"].includes(e.tagName)||"none"===t.display||"hidden"===t.visibility)})).forEach((function(t){t.addEventListener("mouseenter",(function(){e.disabled||e.setElement(t)})),t.addEventListener("mouseleave",(function(t){var n=t.relatedTarget;if(!e.disabled&&n instanceof Element){var i=l(n);i&&e.setElement(i)}}))}))},c.registerHotkeys=function(){var e=this,n=this.options,i=n.shortcuts,r=n.editor;t.bind(i.inspect,(function(){e.toggleEnable(),document.body.classList.toggle("view-launcher-inspecting")})),t.bind(i.open,(function(){if(e.enabled&&e.element){var t,n,i,l=e.element.tagInfo;window.location.href=(n=(t={editor:r,viewPath:l.view,line:l.line,column:l.column}).line,i=t.column,function(e,t){return t?e.replace("{column}",t.toString()):e.replace("&column={column}","").replace(":{column}","")}(function(e,t){return t?e.replace("{line}",t.toString()):e.replace("&line={line}&column={column}","").replace(":{line}:{column}","")}(o[t.editor].replace("{path}",encodeURIComponent(t.viewPath)),n),i))}})),t.bind(i.inspectParent,(function(){var t;if(null!=(t=e.element)&&t.parentElement){var n=l(e.element.parentElement);n&&e.setElement(n)}})),t.bind("esc",(function(){e.disable(),document.body.classList.contains("view-launcher-inspecting")&&document.body.classList.remove("view-launcher-inspecting")}))},c.keepUpdatingOnEvents=function(){var e=this;window.addEventListener("scroll",this.update),window.addEventListener("resize",this.update);var t=document.body;new MutationObserver((function(){e.addEventListeners()})).observe(t,{attributes:!1,childList:!0,subtree:!0})},e.create=function(t){if(void 0===t&&(t={}),e.instance)return e.instance;var n=new e(t);return e.instance=n},c.setElement=function(e){this.element=e,this.show(),this.update()},c.update=function(){if(this.element&&!this.disabled){var e=this.indicator.style,t=this.element.getBoundingClientRect(),n=document.documentElement.clientHeight,i=t.top+t.height>n,o=t.top>0?i?n-t.top:t.height:i?n:t.height+t.top;e.width=t.width+"px",e.height=o+"px",e.left=t.left+"px",e.top=(t.top>0?t.top:0)+"px";var l=this.element,r=Array.from(l.classList).join("."),a=l.tagName.toLowerCase(),s=l.tagInfo.view.match(/[^/\\]+?$/)[0];this.tagInfo.innerHTML=(l.tagInfo.component?'<i class="__is-component"></i>':"")+(l.tagInfo.component||a+(r?"."+r:"")),this.viewName.innerText=s,this.popper.setOptions({modifiers:[{name:"offset",options:{offset:i&&t.top<0?[6,-(this.tooltip.clientHeight+5)]:[0,5]}}]}),this.popper.update()}},c.hide=function(){[this.indicator,this.tooltip].forEach((function(e){e.style.visibility="hidden"}))},c.show=function(){[this.indicator,this.tooltip].forEach((function(e){e.style.visibility="visible"}))},c.enable=function(){this._enabled=!0,this.update(),this.show()},c.disable=function(){this._enabled=!1,this.hide()},c.toggleEnable=function(){this._enabled?this.disable():this.enable()},(s=[{key:"enabled",get:function(){return this._enabled}},{key:"disabled",get:function(){return!this._enabled}}])&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,s),e}();exports.ElementIndicator=s,exports.defaultOptions=a,exports.viewLauncher=function(e){void 0===e&&(e={}),s.create(e)};
//# sourceMappingURL=view-launcher.cjs.production.min.js.map

@@ -347,3 +347,3 @@ import Mousetrap from 'mousetrap';

export { ElementIndicator, viewLauncher };
export { ElementIndicator, defaultOptions, viewLauncher };
//# sourceMappingURL=view-launcher.esm.js.map
{
"name": "view-launcher",
"author": "yaquawa",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",

@@ -6,0 +6,0 @@ "main": "dist/index.js",

@@ -26,3 +26,3 @@ import Mousetrap from 'mousetrap'

const defaultOptions: Options = {
export const defaultOptions: Options = {
theme: 'light',

@@ -29,0 +29,0 @@ editor: 'vscode',

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