New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-scooter

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-scooter - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

demo/src/vue-scooter.js

2

demo/src/index.js
import router from './router.js';
import store from './store/index.js';
let App = () => VueScooter.load('app.vue');

@@ -7,4 +6,3 @@ new Vue({

router,
store,
render: (h) => h(App),
});

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

import 'https://cdn.jsdelivr.net/npm/vue-router';
import 'https://cdn.jsdelivr.net/npm/vue-router@3';

@@ -3,0 +3,0 @@ const Page = () => VueScooter.load('./views/page/index.vue');

@@ -1,550 +0,5 @@

var VueScooter = (function () {
'use strict';
var c="comm";var n="rule";var t="decl";var i="@import";var k=Math.abs;var d=String.fromCharCode;function g(e){return e.trim()}function y(e,r,a){return e.replace(r,a)}function z(e,r){return e.charCodeAt(r)|0}function C(e,r,a){return e.slice(r,a)}function A(e){return e.length}function M(e){return e.length}function O(e,r){return r.push(e),e}var q=1;var B=1;var D=0;var E=0;var F=0;var G="";function H(e,r,a,c,n,t,s){return {value:e,root:r,parent:a,type:c,props:n,children:t,line:q,column:B,length:s,return:""}}function J(){return F}function K(){F=E<D?z(G,E++):0;if(B++,F===10)B=1,q++;return F}function L(){return z(G,E)}function N(){return E}function P(e,r){return C(G,e,r)}function Q(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function R(e){return q=B=1,D=A(G=e),E=0,[]}function T(e){return G="",e}function U(e){return g(P(E-1,Y(e===91?e+2:e===40?e+1:e)))}function W(e){while(F=L())if(F<33)K();else break;return Q(e)>2||Q(F)>3?"":" "}function Y(e){while(K())switch(F){case e:return E;case 34:case 39:return Y(e===34||e===39?e:F);case 40:if(e===41)Y(e);break;case 92:K();break}return E}function Z(e,r){while(K())if(e+F===47+10)break;else if(e+F===42+42&&L()===47)break;return "/*"+P(r,E-1)+"*"+d(e===47?e:K())}function _(e){while(!Q(L()))K();return P(e,E)}function ee(e){return T(re("",null,null,null,[""],e=R(e),0,[0],e))}function re(e,r,a,c,n,t,s,u,i){var f=0;var o=0;var l=s;var v=0;var h=0;var p=0;var w=1;var b=1;var $=1;var k=0;var m="";var g=n;var x=t;var j=c;var z=m;while(b)switch(p=k,k=K()){case 34:case 39:case 91:case 40:z+=U(k);break;case 9:case 10:case 13:case 32:z+=W(p);break;case 47:switch(L()){case 42:case 47:O(ce(Z(K(),N()),r,a),i);break;default:z+="/";}break;case 123*w:u[f++]=A(z)*$;case 125*w:case 59:case 0:switch(k){case 0:case 125:b=0;case 59+o:if(h>0)O(h>32?ne(z+";",c,a,l-1):ne(y(z," ","")+";",c,a,l-2),i);break;case 59:z+=";";default:O(j=ae(z,r,a,f,o,n,u,m,g=[],x=[],l),t);if(k===123)if(o===0)re(z,r,j,j,g,t,l,u,x);else switch(v){case 100:case 109:case 115:re(e,j,j,c&&O(ae(e,j,j,0,0,n,u,m,n,g=[],l),x),n,x,l,u,c?g:x);break;default:re(z,j,j,j,[""],x,l,u,x);}}f=o=h=0,w=$=1,m=z="",l=s;break;case 58:l=1+A(z),h=p;default:switch(z+=d(k),k*w){case 38:$=o>0?1:(z+="\f",-1);break;case 44:u[f++]=(A(z)-1)*$,$=1;break;case 64:if(L()===45)z+=U(K());v=L(),o=A(m=z+=_(N())),k++;break;case 45:if(p===45&&A(z)==2)w=0;}}return t}function ae(e,r,a,c,t,s,u,i,f,o,l){var v=t-1;var h=t===0?s:[""];var p=M(h);for(var w=0,b=0,$=0;w<c;++w)for(var d=0,m=C(e,v+1,v=k(b=u[w])),x=e;d<p;++d)if(x=g(b>0?h[d]+" "+m:y(m,/&\f/g,h[d])))f[$++]=x;return H(e,r,a,t===0?n:i,f,o,l)}function ce(e,r,a){return H(e,r,a,c,d(J()),C(e,2,-2),0)}function ne(e,r,a,c){return H(e,r,a,t,C(e,0,c),C(e,c+1,-1),c)}function se(e,r){var a="";var c=M(e);for(var n=0;n<c;n++)a+=r(e[n],n,e,r)||"";return a}function ue(e,r,a,s){switch(e.type){case i:case t:return e.return=e.return||e.value;case c:return "";case n:e.value=e.props.join(",");}return A(a=se(e.children,s))?e.return=e.value+"{"+a+"}":""}function ie(e){var r=M(e);return function(a,c,n,t){var s="";for(var u=0;u<r;u++)s+=e[u](a,c,n,t)||"";return s}}
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var dist = createCommonjsModule(function (module, exports) {
var Vue; // late bind
var version;
var map = Object.create(null);
if (typeof window !== 'undefined') {
window.__VUE_HOT_MAP__ = map;
}
var installed = false;
var initHookName = 'beforeCreate';
exports.install = function (vue, browserify) {
if (installed) { return }
installed = true;
Vue = vue.__esModule ? vue.default : vue;
version = Vue.version.split('.').map(Number);
// compat with < 2.0.0-alpha.7
if (Vue.config._lifecycleHooks.indexOf('init') > -1) {
initHookName = 'init';
}
exports.compatible = version[0] >= 2;
if (!exports.compatible) {
console.warn(
'[HMR] You are using a version of vue-hot-reload-api that is ' +
'only compatible with Vue.js core ^2.0.0.'
);
return
}
};
/**
* Create a record for a hot module, which keeps track of its constructor
* and instances
*
* @param {String} id
* @param {Object} options
*/
exports.createRecord = function (id, options) {
if(map[id]) { return }
var Ctor = null;
if (typeof options === 'function') {
Ctor = options;
options = Ctor.options;
}
makeOptionsHot(id, options);
map[id] = {
Ctor: Ctor,
options: options,
instances: []
};
};
/**
* Check if module is recorded
*
* @param {String} id
*/
exports.isRecorded = function (id) {
return typeof map[id] !== 'undefined'
};
/**
* Make a Component options object hot.
*
* @param {String} id
* @param {Object} options
*/
function makeOptionsHot(id, options) {
if (options.functional) {
var render = options.render;
options.render = function (h, ctx) {
var instances = map[id].instances;
if (ctx && instances.indexOf(ctx.parent) < 0) {
instances.push(ctx.parent);
}
return render(h, ctx)
};
} else {
injectHook(options, initHookName, function() {
var record = map[id];
if (!record.Ctor) {
record.Ctor = this.constructor;
}
record.instances.push(this);
});
injectHook(options, 'beforeDestroy', function() {
var instances = map[id].instances;
instances.splice(instances.indexOf(this), 1);
});
}
}
/**
* Inject a hook to a hot reloadable component so that
* we can keep track of it.
*
* @param {Object} options
* @param {String} name
* @param {Function} hook
*/
function injectHook(options, name, hook) {
var existing = options[name];
options[name] = existing
? Array.isArray(existing) ? existing.concat(hook) : [existing, hook]
: [hook];
}
function tryWrap(fn) {
return function (id, arg) {
try {
fn(id, arg);
} catch (e) {
console.error(e);
console.warn(
'Something went wrong during Vue component hot-reload. Full reload required.'
);
}
}
}
function updateOptions (oldOptions, newOptions) {
for (var key in oldOptions) {
if (!(key in newOptions)) {
delete oldOptions[key];
}
}
for (var key$1 in newOptions) {
oldOptions[key$1] = newOptions[key$1];
}
}
exports.rerender = tryWrap(function (id, options) {
var record = map[id];
if (!options) {
record.instances.slice().forEach(function (instance) {
instance.$forceUpdate();
});
return
}
if (typeof options === 'function') {
options = options.options;
}
if (record.Ctor) {
record.Ctor.options.render = options.render;
record.Ctor.options.staticRenderFns = options.staticRenderFns;
record.instances.slice().forEach(function (instance) {
instance.$options.render = options.render;
instance.$options.staticRenderFns = options.staticRenderFns;
// reset static trees
// pre 2.5, all static trees are cached together on the instance
if (instance._staticTrees) {
instance._staticTrees = [];
}
// 2.5.0
if (Array.isArray(record.Ctor.options.cached)) {
record.Ctor.options.cached = [];
}
// 2.5.3
if (Array.isArray(instance.$options.cached)) {
instance.$options.cached = [];
}
// post 2.5.4: v-once trees are cached on instance._staticTrees.
// Pure static trees are cached on the staticRenderFns array
// (both already reset above)
// 2.6: temporarily mark rendered scoped slots as unstable so that
// child components can be forced to update
var restore = patchScopedSlots(instance);
instance.$forceUpdate();
instance.$nextTick(restore);
});
} else {
// functional or no instance created yet
record.options.render = options.render;
record.options.staticRenderFns = options.staticRenderFns;
// handle functional component re-render
if (record.options.functional) {
// rerender with full options
if (Object.keys(options).length > 2) {
updateOptions(record.options, options);
} else {
// template-only rerender.
// need to inject the style injection code for CSS modules
// to work properly.
var injectStyles = record.options._injectStyles;
if (injectStyles) {
var render = options.render;
record.options.render = function (h, ctx) {
injectStyles.call(ctx);
return render(h, ctx)
};
}
}
record.options._Ctor = null;
// 2.5.3
if (Array.isArray(record.options.cached)) {
record.options.cached = [];
}
record.instances.slice().forEach(function (instance) {
instance.$forceUpdate();
});
}
}
});
exports.reload = tryWrap(function (id, options) {
var record = map[id];
if (options) {
if (typeof options === 'function') {
options = options.options;
}
makeOptionsHot(id, options);
if (record.Ctor) {
if (version[1] < 2) {
// preserve pre 2.2 behavior for global mixin handling
record.Ctor.extendOptions = options;
}
var newCtor = record.Ctor.super.extend(options);
// prevent record.options._Ctor from being overwritten accidentally
newCtor.options._Ctor = record.options._Ctor;
record.Ctor.options = newCtor.options;
record.Ctor.cid = newCtor.cid;
record.Ctor.prototype = newCtor.prototype;
if (newCtor.release) {
// temporary global mixin strategy used in < 2.0.0-alpha.6
newCtor.release();
}
} else {
updateOptions(record.options, options);
}
}
record.instances.slice().forEach(function (instance) {
if (instance.$vnode && instance.$vnode.context) {
instance.$vnode.context.$forceUpdate();
} else {
console.warn(
'Root or manually mounted instance modified. Full reload required.'
);
}
});
});
// 2.6 optimizes template-compiled scoped slots and skips updates if child
// only uses scoped slots. We need to patch the scoped slots resolving helper
// to temporarily mark all scoped slots as unstable in order to force child
// updates.
function patchScopedSlots (instance) {
if (!instance._u) { return }
// https://github.com/vuejs/vue/blob/dev/src/core/instance/render-helpers/resolve-scoped-slots.js
var original = instance._u;
instance._u = function (slots) {
try {
// 2.6.4 ~ 2.6.6
return original(slots, true)
} catch (e) {
// 2.5 / >= 2.6.7
return original(slots, null, true)
}
};
return function () {
instance._u = original;
}
}
});
var hotReloadApi = unwrapExports(dist);
var dist_1 = dist.install;
var dist_2 = dist.compatible;
var dist_3 = dist.createRecord;
var dist_4 = dist.isRecorded;
var dist_5 = dist.rerender;
var dist_6 = dist.reload;
/**
* https://github.com/thiled/vue-scooter
* Released under the MIT License.
*/
hotReloadApi.install(Vue);
//
const defaultRoot = location.origin + location.pathname;
let rootPath = defaultRoot;
let vueComponents = (window.vueComponents = {}); //vue组件存储
let vueFileLoadCount = 0;
/**
* 更改默认前缀,部署用
* @param {*} path
*/
const setRoot = (path) => {
rootPath = path;
};
/**
* 相对路径转换
* @param {*} currentPath
* @param {*} relativePath
*/
const _resolvePath = (currentPath, relativePath) => {
// relativePath
// 如果是url,取消处理
if (relativePath.match(/^((https?:)?\/\/)/)) {
return relativePath;
}
// remove ./
relativePath = relativePath.replace(/^\.\//, '');
// 拆分'../'
let match = relativePath.match(/\.\.\//g);
let count = (match && match.length) || 0;
// 去掉相对路径后的剩余路径
let cleanPath = relativePath.replace(/\.\.\//g, '');
// currentPath
// 拆分'.+/'
let currentPathArr = currentPath.match(/.+?\/+/g);
// 移除相对路径层级
currentPathArr.splice(currentPathArr.length - count, count);
return currentPathArr.join('') + cleanPath;
};
/**
* 从vue文件读取template/script/style tag
* @param {*} data
* @param {*} tag
*/
const _getBlock = (data, tag) => {
let regx = new RegExp(`<${tag}(.*?)>([\\w\\W]*)<\\/${tag}>`);
let templateStr = data.match(regx);
return templateStr
? {
value: templateStr[2].replace(/\s*(.*)/, '$1'),
attrs: templateStr[1],
}
: {};
};
/**
* 处理script
* @param {*} vueFileUrl
* @param {*} script
*/
const _handleScript = (vueFileUrl, script) => {
return new Promise(async (resolve) => {
let vueImports = [];
// 清除注释
script = script.replace(/(?:^|\s)(\/\/.*)|(\/\*[\w\W]*?\*\/)/g, '');
// 识别import,转换路径,提取vue import
script = script.replace(
/(import\s+(.*?)\s+from\s+['"])(.*?)(['"])/gs,
($0, $1, $2, $3, $4) => {
// import相对路径转换
let fullPath = _resolvePath(vueFileUrl, $3);
let importStatement = $1 + fullPath + $4;
if ($3.match(/\.vue$/)) {
// 识别import vue语句
vueImports.push({
importStatement: importStatement,
name: $2,
path: fullPath,
});
}
return importStatement;
}
);
// 遍历vue文件, 递归解析
while (vueImports.length > 0) {
let element = vueImports.shift();
let componentName = element.name;
let componentPath = element.path;
await _load(componentPath, true);
// 替换import vue文件的语句
script = script.replace(
element.importStatement,
`const ${componentName}= window.vueComponents['${componentPath}']`
);
}
resolve(script);
});
};
/**
* 处理template
* @param {*} vueFileUrl
* @param {*} template
* @param {*} scopedDataAttr
*/
const _handleTemplate = (vueFileUrl, template, scopedDataAttr) => {
// 替换tempate中src的相对路径
template = template.replace(/(\ssrc=['"])(.*?)(?=['"])/g, ($0, $1, $2) => {
return $1 + _resolvePath(vueFileUrl, $2);
});
if (scopedDataAttr) {
// template中所有tag加scoped相关data属性
template = template.replace(/(<[\w-]+)/g, `$1 ${scopedDataAttr}`);
}
return template;
};
/**
* 处理style
* @param {*} vueFileUrl
* @param {*} style
* @param {*} scopedDataAttr
*/
const _handleStyle = (vueFileUrl, style, scopedDataAttr) => {
if (!style) return;
// 替换style中的url路径
style = style.replace(/(url\(['"])(.*?)(?=["']\))/g, ($0, $1, $2) => {
return $1 + _resolvePath(vueFileUrl, $2);
});
// 嵌套解析
if (scopedDataAttr) {
// style中所有选择器添加scoped相关data属性匹配
style = se(
ee(style),
ie([
(element) => {
if (element.type === 'rule') {
let prop = element.props[0];
if (prop.match(/::v-deep/)) {
prop = prop.replace(/\s?::v-deep/, '');
} else if (prop.match(/::/)) {
prop = prop.replace(/::/, `[${scopedDataAttr}]::`);
} else if (prop !== 'from' && prop !== 'to') {
prop += `[${scopedDataAttr}]`;
}
element.props[0] = prop;
}
},
ue,
])
);
} else {
style = se(ee(style), ue);
}
// 应用style
let styleElement = document.createElement('style');
styleElement.setAttribute('file', vueFileUrl);
styleElement.append(style);
document.head.appendChild(styleElement);
};
/**
* vue文件加载
* @param {*} vueFileUrl
* @param {*} isFullPath
*/
const _load = (vueFileUrl, isFullPath = false, isReload = false) => {
let scopedDataAttr;
if (!isFullPath) {
vueFileUrl = _resolvePath(rootPath, vueFileUrl);
}
return new Promise((resolve, reject) => {
if (vueComponents[vueFileUrl] && !isReload) {
// 读取缓存的组件对象
resolve(vueComponents[vueFileUrl]);
return;
}
var xhr = new XMLHttpRequest();
xhr.onload = async (e) => {
vueFileLoadCount++;
let data = xhr.responseText;
// 解析vue文件
let template = _getBlock(data, 'template').value;
let script = _getBlock(data, 'script').value;
let styleObj = _getBlock(data, 'style');
let style = styleObj.value;
if (/scoped/.test(styleObj.attrs)) {
scopedDataAttr = `data-v-${vueFileLoadCount}`;
}
script = await _handleScript(vueFileUrl, script);
// 字符串js转脚本, 编码处理特殊字符
script = encodeURIComponent(script);
const dataUri =
'data:text/javascript;charset=utf-8,' + script + vueFileLoadCount;
import(dataUri).then((res) => {
let component = res.default;
template = _handleTemplate(vueFileUrl, template, scopedDataAttr);
component.template = template;
if (!vueComponents[vueFileUrl]) {
// 组件对象存储, 相同路径组件只加载一次
vueComponents[vueFileUrl] = component;
//
hotReloadApi.createRecord(vueFileUrl, component);
} else if (isReload) {
// 移除旧样式
let lastStyleDom = document.querySelector(
`style[file="${vueFileUrl}"]`
);
lastStyleDom && lastStyleDom.remove();
// 组件重载
hotReloadApi.reload(vueFileUrl, component);
}
_handleStyle(vueFileUrl, style, scopedDataAttr);
//
resolve(component);
});
};
xhr.open('GET', vueFileUrl);
xhr.send();
});
};
/**
* load vue file
* @param {*} vueFileUrl
* @param {*} isFullPath
*/
const load = (vueFileUrl, isFullPath = false) => {
return _load(vueFileUrl, isFullPath);
};
/**
* hot reload vue file
* @param {*} vueFileUrl
*/
const reload = (vueFileUrl) => {
_load(vueFileUrl, false, true);
};
var index = {
load,
setRoot,
reload,
};
return index;
}());
/**
* vue-scooter v1.2.4
* https://github.com/thiled/vue-scooter
*/
var VueScooter=function(){"use strict";var e="comm",t="rule",n="decl",r=Math.abs,o=String.fromCharCode;function c(e){return e.trim()}function a(e,t,n){return e.replace(t,n)}function s(e,t){return e.indexOf(t)}function i(e,t){return 0|e.charCodeAt(t)}function u(e,t,n){return e.slice(t,n)}function l(e){return e.length}function f(e){return e.length}function p(e,t){return t.push(e),e}var d=1,h=1,v=0,m=0,y=0,w="";function b(e,t,n,r,o,c,a){return{value:e,root:t,parent:n,type:r,props:o,children:c,line:d,column:h,length:a,return:""}}function g(){return y=m<v?i(w,m++):0,h++,10===y&&(h=1,d++),y}function C(){return i(w,m)}function $(){return m}function _(e,t){return u(w,e,t)}function k(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function R(e){return c(_(m-1,O(91===e?e+2:40===e?e+1:e)))}function x(e){for(;(y=C())&&y<33;)g();return k(e)>2||k(y)>3?"":" "}function A(e,t){for(;--t&&g()&&!(y<48||y>102||y>57&&y<65||y>70&&y<97););return _(e,$()+(t<6&&32==C()&&32==g()))}function O(e){for(;g();)switch(y){case e:return m;case 34:case 39:34!==e&&39!==e&&O(y);break;case 40:41===e&&O(e);break;case 92:g()}return m}function j(e,t){for(;g()&&e+y!==57&&(e+y!==84||47!==C()););return"/*"+_(t,m-1)+"*"+o(47===e?e:g())}function E(e){for(;!k(C());)g();return _(e,m)}function F(e){return function(e){return w="",e}(S("",null,null,null,[""],e=function(e){return d=h=1,v=l(w=e),m=0,[]}(e),0,[0],e))}function S(e,t,n,r,c,u,f,v,b){for(var _=0,k=0,O=f,F=0,V=0,q=0,H=1,P=1,W=1,D=0,G="",I=c,L=u,N=r,X=G;P;)switch(q=D,D=g()){case 40:if(108!=q&&58==i(X,O-1)){-1!=s(X+=a(R(D),"&","&\f"),"&\f")&&(W=-1);break}case 34:case 39:case 91:X+=R(D);break;case 9:case 10:case 13:case 32:X+=x(q);break;case 92:X+=A($()-1,7);continue;case 47:switch(C()){case 42:case 47:p(T(j(g(),$()),t,n),b);break;default:X+="/"}break;case 123*H:v[_++]=l(X)*W;case 125*H:case 59:case 0:switch(D){case 0:case 125:P=0;case 59+k:-1==W&&(X=a(X,/\f/g,"")),V>0&&l(X)-O&&p(V>32?U(X+";",r,n,O-1):U(a(X," ","")+";",r,n,O-2),b);break;case 59:X+=";";default:if(p(N=M(X,t,n,_,k,c,v,G,I=[],L=[],O),u),123===D)if(0===k)S(X,t,N,N,I,u,O,v,L);else switch(99===F&&110===i(X,3)?100:F){case 100:case 109:case 115:S(e,N,N,r&&p(M(e,N,N,0,0,c,v,G,c,I=[],O),L),c,L,O,v,r?I:L);break;default:S(X,N,N,N,[""],L,0,v,L)}}_=k=V=0,H=W=1,G=X="",O=f;break;case 58:O=1+l(X),V=q;default:if(H<1)if(123==D)--H;else if(125==D&&0==H++&&125==(y=m>0?i(w,--m):0,h--,10===y&&(h=1,d--),y))continue;switch(X+=o(D),D*H){case 38:W=k>0?1:(X+="\f",-1);break;case 44:v[_++]=(l(X)-1)*W,W=1;break;case 64:45===C()&&(X+=R(g())),F=C(),k=O=l(G=X+=E($())),D++;break;case 45:45===q&&2==l(X)&&(H=0)}}return u}function M(e,n,o,s,i,l,p,d,h,v,m){for(var y=i-1,w=0===i?l:[""],g=f(w),C=0,$=0,_=0;C<s;++C)for(var k=0,R=u(e,y+1,y=r($=p[C])),x=e;k<g;++k)(x=c($>0?w[k]+" "+R:a(R,/&\f/g,w[k])))&&(h[_++]=x);return b(e,n,o,0===i?t:d,h,v,m)}function T(t,n,r){return b(t,n,r,e,o(y),u(t,2,-2),0)}function U(e,t,r,o){return b(e,t,r,n,u(e,0,o),u(e,o+1,-1),o)}function V(e,t){for(var n="",r=f(e),o=0;o<r;o++)n+=t(e[o],o,e,t)||"";return n}function q(r,o,c,a){switch(r.type){case"@import":case n:return r.return=r.return||r.value;case e:return"";case"@keyframes":return r.return=r.value+"{"+V(r.children,a)+"}";case t:r.value=r.props.join(",")}return l(c=V(r.children,a))?r.return=r.value+"{"+c+"}":""}var H,P,W=(H=function(e,t){var n,r,o=Object.create(null);"undefined"!=typeof window&&(window.__VUE_HOT_MAP__=o);var c=!1,a="beforeCreate";function s(e,t){if(t.functional){var n=t.render;t.render=function(t,r){var c=o[e].instances;return r&&c.indexOf(r.parent)<0&&c.push(r.parent),n(t,r)}}else i(t,a,(function(){var t=o[e];t.Ctor||(t.Ctor=this.constructor),t.instances.push(this)})),i(t,"beforeDestroy",(function(){var t=o[e].instances;t.splice(t.indexOf(this),1)}))}function i(e,t,n){var r=e[t];e[t]=r?Array.isArray(r)?r.concat(n):[r,n]:[n]}function u(e){return function(t,n){try{e(t,n)}catch(e){console.error(e),console.warn("Something went wrong during Vue component hot-reload. Full reload required.")}}}function l(e,t){for(var n in e)n in t||delete e[n];for(var r in t)e[r]=t[r]}t.install=function(e,o){c||(c=!0,n=e.__esModule?e.default:e,r=n.version.split(".").map(Number),n.config._lifecycleHooks.indexOf("init")>-1&&(a="init"),t.compatible=r[0]>=2,t.compatible||console.warn("[HMR] You are using a version of vue-hot-reload-api that is only compatible with Vue.js core ^2.0.0."))},t.createRecord=function(e,t){if(!o[e]){var n=null;"function"==typeof t&&(t=(n=t).options),s(e,t),o[e]={Ctor:n,options:t,instances:[]}}},t.isRecorded=function(e){return void 0!==o[e]},t.rerender=u((function(e,t){var n=o[e];if(t){if("function"==typeof t&&(t=t.options),n.Ctor)n.Ctor.options.render=t.render,n.Ctor.options.staticRenderFns=t.staticRenderFns,n.instances.slice().forEach((function(e){e.$options.render=t.render,e.$options.staticRenderFns=t.staticRenderFns,e._staticTrees&&(e._staticTrees=[]),Array.isArray(n.Ctor.options.cached)&&(n.Ctor.options.cached=[]),Array.isArray(e.$options.cached)&&(e.$options.cached=[]);var r=function(e){if(e._u){var t=e._u;return e._u=function(e){try{return t(e,!0)}catch(n){return t(e,null,!0)}},function(){e._u=t}}}(e);e.$forceUpdate(),e.$nextTick(r)}));else if(n.options.render=t.render,n.options.staticRenderFns=t.staticRenderFns,n.options.functional){if(Object.keys(t).length>2)l(n.options,t);else{var r=n.options._injectStyles;if(r){var c=t.render;n.options.render=function(e,t){return r.call(t),c(e,t)}}}n.options._Ctor=null,Array.isArray(n.options.cached)&&(n.options.cached=[]),n.instances.slice().forEach((function(e){e.$forceUpdate()}))}}else n.instances.slice().forEach((function(e){e.$forceUpdate()}))})),t.reload=u((function(e,t){var n=o[e];if(t)if("function"==typeof t&&(t=t.options),s(e,t),n.Ctor){r[1]<2&&(n.Ctor.extendOptions=t);var c=n.Ctor.super.extend(t);c.options._Ctor=n.options._Ctor,n.Ctor.options=c.options,n.Ctor.cid=c.cid,n.Ctor.prototype=c.prototype,c.release&&c.release()}else l(n.options,t);n.instances.slice().forEach((function(e){e.$vnode&&e.$vnode.context?e.$vnode.context.$forceUpdate():console.warn("Root or manually mounted instance modified. Full reload required.")}))}))},H(P={exports:{}},P.exports),P.exports),D=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(W);W.install,W.compatible,W.createRecord,W.isRecorded,W.rerender,W.reload,D.install(Vue);let G=location.origin+location.pathname,I=window.vueComponents={},L=0;const N=(e,t)=>{if(t.match(/^((https?:)?\/\/)/))return t;let n=(t=t.replace(/^\.\//,"")).match(/\.\.\//g),r=n&&n.length||0,o=t.replace(/\.\.\//g,""),c=e.match(/.+?\/+/g);return c.splice(c.length-r,r),c.join("")+o},X=(e,t)=>{let n=new RegExp(`<${t}(.*?)>([\\w\\W]*)<\\/${t}>`),r=e.match(n);return r?{value:r[2].replace(/\s*(.*)/,"$1"),attrs:r[1]}:{}},Y=(e,t,n)=>{if(!t)return;var r,o;t=V(F(t=t.replace(/(url\(['"])(.*?)(?=["']\))/g,((t,n,r)=>n+N(e,r)))),n?(o=f(r=[e=>{if("rule"===e.type){let t=e.props[0];t.match(/::v-deep/)?t=t.replace(/\s?::v-deep/,`[${n}]`):t.match(/::/)?t=t.replace(/::/,`[${n}]::`):"from"!==t&&"to"!==t&&(t+=`[${n}]`),e.props[0]=t}},q]),function(e,t,n,c){for(var a="",s=0;s<o;s++)a+=r[s](e,t,n,c)||"";return a}):q);let c=document.createElement("style");c.setAttribute("file",e),c.append(t),document.head.appendChild(c)},z=(e,t=!1,n=!1)=>{let r;return t||(e=N(G,e)),new Promise(((t,o)=>{if(!I[e]||n){var c=new XMLHttpRequest;c.onload=async o=>{L++;let a=c.responseText,s=X(a,"template").value,i=X(a,"script").value,u=X(a,"style"),l=u.value;/scoped/.test(u.attrs)&&(r=`data-v-${L}`),i=await((e,t)=>new Promise((async n=>{let r=[];for(t=(t=t.replace(/(?:^|\s)(\/\/.*)|(\/\*[\w\W]*?\*\/)/g,"")).replace(/(import\s+(.*?)\s+from\s+['"])(.*?)(['"])/gs,((t,n,o,c,a)=>{let s=N(e,c),i=n+s+a;return c.match(/\.vue$/)&&r.push({importStatement:i,name:o,path:s}),i}));r.length>0;){let e=r.shift(),n=e.name,o=e.path;await z(o,!0),t=t.replace(e.importStatement,`const ${n}= window.vueComponents['${o}']`)}n(t)})))(e,i),i=encodeURIComponent(i);import("data:text/javascript;charset=utf-8,"+i+L).then((o=>{let c=o.default;if(s=((e,t,n)=>(t=t.replace(/(\ssrc=['"])(.*?)(?=['"])/g,((t,n,r)=>n+N(e,r))),n&&(t=t.replace(/(<[\w-]+)/g,`$1 ${n}`)),t))(e,s,r),c.template=s,I[e]){if(n){let t=document.querySelector(`style[file="${e}"]`);t&&t.remove(),D.reload(e,c)}}else I[e]=c,D.createRecord(e,c);Y(e,l,r),t(c)}))},c.open("GET",e),c.send()}else t(I[e])}))};return{load:(e,t=!1)=>z(e,t),setRoot:e=>{G=e},reload:e=>{z(e,!1,!0)}}}();
{
"name": "vue-scooter",
"version": "1.2.3",
"version": "1.2.4",
"description": "A lightweight vue loader for browser",

@@ -9,3 +9,3 @@ "main": "index.js",

"dev": "node dev.js & npm run dev:demo",
"dev:demo":"cd ./demo && npm run dev",
"dev:demo": "cd ./demo && npm run dev",
"dev:build": "rollup -c rollup.dev.config.js",

@@ -27,3 +27,4 @@ "prepublishOnly": "npm run build"

"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0"
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2"
},

@@ -30,0 +31,0 @@ "dependencies": {

@@ -1,4 +0,7 @@

## Introduction
**vue-scooter** parses single vue file components directly in the browser. It is designed for those projects with low browser compatibility requirements, for people who need to start modular static pages development quickly with good development and maintainance experience.
# vue-scooter
<img src="https://user-images.githubusercontent.com/28561045/126886028-2c3916a8-1543-4683-ae5e-04475a7bf703.png" width="100px"/>
## Introduction
**vue-scooter** parses single vue file components directly in the browser. It is designed to start modular static pages development quickly without any module bundler, for the pages with low browser compatibility requirements.
## Features

@@ -5,0 +8,0 @@ scripts in .vue

import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
const version = require('./package.json').version;
const banner = `/**
* vue-scooter v${version}
* https://github.com/thiled/vue-scooter
*/`;
export default {

@@ -9,4 +16,13 @@ input: 'src/index.js',

name: 'VueScooter',
banner,
},
plugins: [nodeResolve(), commonjs()],
plugins: [
nodeResolve(),
commonjs(),
terser({
format: {
comments: /vue-scooter v\d/,
},
}),
],
};

@@ -150,3 +150,3 @@ /**

if (prop.match(/::v-deep/)) {
prop = prop.replace(/\s?::v-deep/, '');
prop = prop.replace(/\s?::v-deep/, `[${scopedDataAttr}]`);
} else if (prop.match(/::/)) {

@@ -153,0 +153,0 @@ prop = prop.replace(/::/, `[${scopedDataAttr}]::`);

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc