🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

jdwl-widget

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jdwl-widget - npm Package Compare versions

Comparing version
1.0.0
to
1.0.1
+30
build/rollup.config.dev.js
import serve from "rollup-plugin-serve";
import vue from "rollup-plugin-vue";
import commonjs from "@rollup/plugin-commonjs";
import pkg from "../package.json";
const PORT = 3001;
module.exports = {
input: "example/main.js",
output: {
file: "example/dist/example.jdwl-widget.js",
format: "umd",
name: "JdwlWidget",
globals: {
vue: "Vue",
},
sourcemap: false,
},
external: Object.keys(pkg.dependencies),
plugins: [
commonjs(),
vue(),
serve({
port: PORT,
contentBase: 'example',
open: true,
openPage: "/",
}),
],
};
// rollup.config.js
import vue from 'rollup-plugin-vue';
import commonjs from '@rollup/plugin-commonjs';
import pkg from '../package.json';
module.exports = {
input: 'src/main.js',
output: {
file: 'dist/jdwl-widget.js',
format: 'umd',
name: 'jdwl-widget',
globals: {
vue: 'Vue',
},
sourcemap: true
},
external: Object.keys(pkg.dependencies),
plugins: [
commonjs(),
vue(),
]
};
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jdwl-widget'] = factory());
}(this, (function () { 'use strict';
//
//
//
//
//
//
var script = {
name: 'JdwlWidget'
};
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
if (typeof shadowMode !== 'boolean') {
createInjectorSSR = createInjector;
createInjector = shadowMode;
shadowMode = false;
}
// Vue.extend constructor export interop.
const options = typeof script === 'function' ? script.options : script;
// render functions
if (template && template.render) {
options.render = template.render;
options.staticRenderFns = template.staticRenderFns;
options._compiled = true;
// functional template
if (isFunctionalTemplate) {
options.functional = true;
}
}
// scopedId
if (scopeId) {
options._scopeId = scopeId;
}
let hook;
if (moduleIdentifier) {
// server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__;
}
// inject component styles
if (style) {
style.call(this, createInjectorSSR(context));
}
// register component module identifier for async chunk inference
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier);
}
};
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook;
}
else if (style) {
hook = shadowMode
? function (context) {
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
}
: function (context) {
style.call(this, createInjector(context));
};
}
if (hook) {
if (options.functional) {
// register for functional component in vue file
const originalRender = options.render;
options.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
}
else {
// inject component registration as beforeCreate hook
const existing = options.beforeCreate;
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return script;
}
const isOldIE = typeof navigator !== 'undefined' &&
/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
function createInjector(context) {
return (id, style) => addStyle(id, style);
}
let HEAD;
const styles = {};
function addStyle(id, css) {
const group = isOldIE ? css.media || 'default' : id;
const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
if (!style.ids.has(id)) {
style.ids.add(id);
let code = css.source;
if (css.map) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
code +=
'\n/*# sourceMappingURL=data:application/json;base64,' +
btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
' */';
}
if (!style.element) {
style.element = document.createElement('style');
style.element.type = 'text/css';
if (css.media)
style.element.setAttribute('media', css.media);
if (HEAD === undefined) {
HEAD = document.head || document.getElementsByTagName('head')[0];
}
HEAD.appendChild(style.element);
}
if ('styleSheet' in style.element) {
style.styles.push(code);
style.element.styleSheet.cssText = style.styles
.filter(Boolean)
.join('\n');
}
else {
const index = style.ids.size - 1;
const textNode = document.createTextNode(code);
const nodes = style.element.childNodes;
if (nodes[index])
style.element.removeChild(nodes[index]);
if (nodes.length)
style.element.insertBefore(textNode, nodes[index]);
else
style.element.appendChild(textNode);
}
}
}
/* script */
const __vue_script__ = script;
/* template */
var __vue_render__ = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c("div", [_vm._v("\n JdwlWidget text\n")])
};
var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */
const __vue_inject_styles__ = function (inject) {
if (!inject) return
inject("data-v-0f97b0f1_0", { source: "\n\n/*# sourceMappingURL=JdwlWidget.vue.map */", map: {"version":3,"sources":["JdwlWidget.vue"],"names":[],"mappings":";;AAEA,yCAAyC","file":"JdwlWidget.vue"}, media: undefined });
};
/* scoped */
const __vue_scope_id__ = "data-v-0f97b0f1";
/* module identifier */
const __vue_module_identifier__ = undefined;
/* functional template */
const __vue_is_functional_template__ = false;
/* style inject SSR */
/* style inject shadow dom */
const __vue_component__ = /*#__PURE__*/normalizeComponent(
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
__vue_inject_styles__,
__vue_script__,
__vue_scope_id__,
__vue_is_functional_template__,
__vue_module_identifier__,
false,
createInjector,
undefined,
undefined
);
const tian = {
install: function(Vue) {
Vue.component(__vue_component__.name, __vue_component__);
},
log: function() {
console.log(999999999);
}
};
// 自动注册组件
if(typeof window !== null && window.Vue) {
tian.install(window.Vue);
}
return tian;
})));
//# sourceMappingURL=jdwl-widget.js.map
{"version":3,"file":"jdwl-widget.js","sources":["../src/JdwlWidget.vue","../node_modules/vue-runtime-helpers/dist/normalize-component.mjs","../node_modules/vue-runtime-helpers/dist/inject-style/browser.mjs","../src/main.js"],"sourcesContent":["<template>\r\n <div>\r\n JdwlWidget text\r\n </div>\r\n</template>\r\n\r\n<script>\r\n export default {\r\n name: 'JdwlWidget'\r\n }\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n\r\n</style>","function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {\r\n if (typeof shadowMode !== 'boolean') {\r\n createInjectorSSR = createInjector;\r\n createInjector = shadowMode;\r\n shadowMode = false;\r\n }\r\n // Vue.extend constructor export interop.\r\n const options = typeof script === 'function' ? script.options : script;\r\n // render functions\r\n if (template && template.render) {\r\n options.render = template.render;\r\n options.staticRenderFns = template.staticRenderFns;\r\n options._compiled = true;\r\n // functional template\r\n if (isFunctionalTemplate) {\r\n options.functional = true;\r\n }\r\n }\r\n // scopedId\r\n if (scopeId) {\r\n options._scopeId = scopeId;\r\n }\r\n let hook;\r\n if (moduleIdentifier) {\r\n // server build\r\n hook = function (context) {\r\n // 2.3 injection\r\n context =\r\n context || // cached call\r\n (this.$vnode && this.$vnode.ssrContext) || // stateful\r\n (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional\r\n // 2.2 with runInNewContext: true\r\n if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {\r\n context = __VUE_SSR_CONTEXT__;\r\n }\r\n // inject component styles\r\n if (style) {\r\n style.call(this, createInjectorSSR(context));\r\n }\r\n // register component module identifier for async chunk inference\r\n if (context && context._registeredComponents) {\r\n context._registeredComponents.add(moduleIdentifier);\r\n }\r\n };\r\n // used by ssr in case component is cached and beforeCreate\r\n // never gets called\r\n options._ssrRegister = hook;\r\n }\r\n else if (style) {\r\n hook = shadowMode\r\n ? function (context) {\r\n style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));\r\n }\r\n : function (context) {\r\n style.call(this, createInjector(context));\r\n };\r\n }\r\n if (hook) {\r\n if (options.functional) {\r\n // register for functional component in vue file\r\n const originalRender = options.render;\r\n options.render = function renderWithStyleInjection(h, context) {\r\n hook.call(context);\r\n return originalRender(h, context);\r\n };\r\n }\r\n else {\r\n // inject component registration as beforeCreate hook\r\n const existing = options.beforeCreate;\r\n options.beforeCreate = existing ? [].concat(existing, hook) : [hook];\r\n }\r\n }\r\n return script;\r\n}\n\nexport default normalizeComponent;\n//# sourceMappingURL=normalize-component.mjs.map\n","const isOldIE = typeof navigator !== 'undefined' &&\r\n /msie [6-9]\\\\b/.test(navigator.userAgent.toLowerCase());\r\nfunction createInjector(context) {\r\n return (id, style) => addStyle(id, style);\r\n}\r\nlet HEAD;\r\nconst styles = {};\r\nfunction addStyle(id, css) {\r\n const group = isOldIE ? css.media || 'default' : id;\r\n const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });\r\n if (!style.ids.has(id)) {\r\n style.ids.add(id);\r\n let code = css.source;\r\n if (css.map) {\r\n // https://developer.chrome.com/devtools/docs/javascript-debugging\r\n // this makes source maps inside style tags work properly in Chrome\r\n code += '\\n/*# sourceURL=' + css.map.sources[0] + ' */';\r\n // http://stackoverflow.com/a/26603875\r\n code +=\r\n '\\n/*# sourceMappingURL=data:application/json;base64,' +\r\n btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +\r\n ' */';\r\n }\r\n if (!style.element) {\r\n style.element = document.createElement('style');\r\n style.element.type = 'text/css';\r\n if (css.media)\r\n style.element.setAttribute('media', css.media);\r\n if (HEAD === undefined) {\r\n HEAD = document.head || document.getElementsByTagName('head')[0];\r\n }\r\n HEAD.appendChild(style.element);\r\n }\r\n if ('styleSheet' in style.element) {\r\n style.styles.push(code);\r\n style.element.styleSheet.cssText = style.styles\r\n .filter(Boolean)\r\n .join('\\n');\r\n }\r\n else {\r\n const index = style.ids.size - 1;\r\n const textNode = document.createTextNode(code);\r\n const nodes = style.element.childNodes;\r\n if (nodes[index])\r\n style.element.removeChild(nodes[index]);\r\n if (nodes.length)\r\n style.element.insertBefore(textNode, nodes[index]);\r\n else\r\n style.element.appendChild(textNode);\r\n }\r\n }\r\n}\n\nexport default createInjector;\n//# sourceMappingURL=browser.mjs.map\n","import JdwlWidget from './JdwlWidget.vue'\r\n\r\nconst tian = {\r\n install: function(Vue) {\r\n Vue.component(JdwlWidget.name, JdwlWidget)\r\n },\r\n log: function() {\r\n console.log(999999999)\r\n }\r\n}\r\n\r\n// 自动注册组件\r\nif(typeof window !== null && window.Vue) {\r\n tian.install(window.Vue)\r\n}\r\n\r\nexport default tian"],"names":["JdwlWidget"],"mappings":";;;;;;;;;;;;;AAOA;EACA;EACA;;ECTA,SAAS,kBAAkB,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,oBAAoB,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;EAC7L,IAAI,IAAI,OAAO,UAAU,KAAK,SAAS,EAAE;EACzC,QAAQ,iBAAiB,GAAG,cAAc,CAAC;EAC3C,QAAQ,cAAc,GAAG,UAAU,CAAC;EACpC,QAAQ,UAAU,GAAG,KAAK,CAAC;EAC3B,KAAK;EACL;EACA,IAAI,MAAM,OAAO,GAAG,OAAO,MAAM,KAAK,UAAU,GAAG,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;EAC3E;EACA,IAAI,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE;EACrC,QAAQ,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;EACzC,QAAQ,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;EAC3D,QAAQ,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;EACjC;EACA,QAAQ,IAAI,oBAAoB,EAAE;EAClC,YAAY,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;EACtC,SAAS;EACT,KAAK;EACL;EACA,IAAI,IAAI,OAAO,EAAE;EACjB,QAAQ,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC;EACnC,KA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;EACzC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAC;EAC1B;;;;;;;;"}
### 包结构
build: 打包配置
dist|lib: 打包后的产物
doc: 文档
example: 示例
src: 源码
test: 单元测试
### 场景
> 前端项目的开发中,往往会根据业务需求,沉淀出一些项目内的UI组件/功能模块(以下通称组件) 等;这些组件初期只在同一个项目中被维护,并被该项目中的不同页面或模块复用,此时的组件逐步被完善。但是还不能很好的跨项目复用,@jdwl/widget 就是为了让组件具有跨项目使用的一种解决方案。
### 什么样的组件是通用的?
- 足够抽象,不包含业务逻辑,或扩展性足够好
- 尽量不包含 $t、$router 等和项目环境有关的依赖
- 有覆盖率足够高的单元测试
- 有必要的文档,或通过单元测试描述了足够完整的功能
- 最好也提供可运行的例子
### @jdwl/widget 能力
### 使用方式
### 维护
<template>
<div id="app">
this is test
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style lang="scss" scoped>
</style>
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('vue')) :
typeof define === 'function' && define.amd ? define(['vue'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Vue));
}(this, (function (Vue) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
//
//
//
//
//
//
var script = {
name: 'App'
};
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
if (typeof shadowMode !== 'boolean') {
createInjectorSSR = createInjector;
createInjector = shadowMode;
shadowMode = false;
}
// Vue.extend constructor export interop.
const options = typeof script === 'function' ? script.options : script;
// render functions
if (template && template.render) {
options.render = template.render;
options.staticRenderFns = template.staticRenderFns;
options._compiled = true;
// functional template
if (isFunctionalTemplate) {
options.functional = true;
}
}
// scopedId
if (scopeId) {
options._scopeId = scopeId;
}
let hook;
if (moduleIdentifier) {
// server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__;
}
// inject component styles
if (style) {
style.call(this, createInjectorSSR(context));
}
// register component module identifier for async chunk inference
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier);
}
};
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook;
}
else if (style) {
hook = shadowMode
? function (context) {
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
}
: function (context) {
style.call(this, createInjector(context));
};
}
if (hook) {
if (options.functional) {
// register for functional component in vue file
const originalRender = options.render;
options.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
}
else {
// inject component registration as beforeCreate hook
const existing = options.beforeCreate;
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return script;
}
const isOldIE = typeof navigator !== 'undefined' &&
/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
function createInjector(context) {
return (id, style) => addStyle(id, style);
}
let HEAD;
const styles = {};
function addStyle(id, css) {
const group = isOldIE ? css.media || 'default' : id;
const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
if (!style.ids.has(id)) {
style.ids.add(id);
let code = css.source;
if (css.map) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
code +=
'\n/*# sourceMappingURL=data:application/json;base64,' +
btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
' */';
}
if (!style.element) {
style.element = document.createElement('style');
style.element.type = 'text/css';
if (css.media)
style.element.setAttribute('media', css.media);
if (HEAD === undefined) {
HEAD = document.head || document.getElementsByTagName('head')[0];
}
HEAD.appendChild(style.element);
}
if ('styleSheet' in style.element) {
style.styles.push(code);
style.element.styleSheet.cssText = style.styles
.filter(Boolean)
.join('\n');
}
else {
const index = style.ids.size - 1;
const textNode = document.createTextNode(code);
const nodes = style.element.childNodes;
if (nodes[index])
style.element.removeChild(nodes[index]);
if (nodes.length)
style.element.insertBefore(textNode, nodes[index]);
else
style.element.appendChild(textNode);
}
}
}
/* script */
const __vue_script__ = script;
/* template */
var __vue_render__ = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c("div", { attrs: { id: "app" } }, [_vm._v("\n this is test\n")])
};
var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */
const __vue_inject_styles__ = function (inject) {
if (!inject) return
inject("data-v-252c3d70_0", { source: "\n\n/*# sourceMappingURL=App.vue.map */", map: {"version":3,"sources":["App.vue"],"names":[],"mappings":";;AAEA,kCAAkC","file":"App.vue"}, media: undefined });
};
/* scoped */
const __vue_scope_id__ = "data-v-252c3d70";
/* module identifier */
const __vue_module_identifier__ = undefined;
/* functional template */
const __vue_is_functional_template__ = false;
/* style inject SSR */
/* style inject shadow dom */
const __vue_component__ = /*#__PURE__*/normalizeComponent(
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
__vue_inject_styles__,
__vue_script__,
__vue_scope_id__,
__vue_is_functional_template__,
__vue_module_identifier__,
false,
createInjector,
undefined,
undefined
);
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function (path, base) {
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
}
var jdwlWidget = createCommonjsModule(function (module, exports) {
(function (global, factory) {
module.exports = factory() ;
}(commonjsGlobal, (function () {
//
//
//
//
//
//
var script = {
name: 'JdwlWidget'
};
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
if (typeof shadowMode !== 'boolean') {
createInjectorSSR = createInjector;
createInjector = shadowMode;
shadowMode = false;
}
// Vue.extend constructor export interop.
const options = typeof script === 'function' ? script.options : script;
// render functions
if (template && template.render) {
options.render = template.render;
options.staticRenderFns = template.staticRenderFns;
options._compiled = true;
// functional template
if (isFunctionalTemplate) {
options.functional = true;
}
}
// scopedId
if (scopeId) {
options._scopeId = scopeId;
}
let hook;
if (moduleIdentifier) {
// server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__;
}
// inject component styles
if (style) {
style.call(this, createInjectorSSR(context));
}
// register component module identifier for async chunk inference
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier);
}
};
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook;
}
else if (style) {
hook = shadowMode
? function (context) {
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
}
: function (context) {
style.call(this, createInjector(context));
};
}
if (hook) {
if (options.functional) {
// register for functional component in vue file
const originalRender = options.render;
options.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
}
else {
// inject component registration as beforeCreate hook
const existing = options.beforeCreate;
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return script;
}
const isOldIE = typeof navigator !== 'undefined' &&
/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
function createInjector(context) {
return (id, style) => addStyle(id, style);
}
let HEAD;
const styles = {};
function addStyle(id, css) {
const group = isOldIE ? css.media || 'default' : id;
const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
if (!style.ids.has(id)) {
style.ids.add(id);
let code = css.source;
if (css.map) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
code +=
'\n/*# sourceMappingURL=data:application/json;base64,' +
btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
' */';
}
if (!style.element) {
style.element = document.createElement('style');
style.element.type = 'text/css';
if (css.media)
style.element.setAttribute('media', css.media);
if (HEAD === undefined) {
HEAD = document.head || document.getElementsByTagName('head')[0];
}
HEAD.appendChild(style.element);
}
if ('styleSheet' in style.element) {
style.styles.push(code);
style.element.styleSheet.cssText = style.styles
.filter(Boolean)
.join('\n');
}
else {
const index = style.ids.size - 1;
const textNode = document.createTextNode(code);
const nodes = style.element.childNodes;
if (nodes[index])
style.element.removeChild(nodes[index]);
if (nodes.length)
style.element.insertBefore(textNode, nodes[index]);
else
style.element.appendChild(textNode);
}
}
}
/* script */
const __vue_script__ = script;
/* template */
var __vue_render__ = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c("div", [_vm._v("\n JdwlWidget text\n")])
};
var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */
const __vue_inject_styles__ = function (inject) {
if (!inject) return
inject("data-v-0f97b0f1_0", { source: "\n\n/*# sourceMappingURL=JdwlWidget.vue.map */", map: {"version":3,"sources":["JdwlWidget.vue"],"names":[],"mappings":";;AAEA,yCAAyC","file":"JdwlWidget.vue"}, media: undefined });
};
/* scoped */
const __vue_scope_id__ = "data-v-0f97b0f1";
/* module identifier */
const __vue_module_identifier__ = undefined;
/* functional template */
const __vue_is_functional_template__ = false;
/* style inject SSR */
/* style inject shadow dom */
const __vue_component__ = /*#__PURE__*/normalizeComponent(
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
__vue_inject_styles__,
__vue_script__,
__vue_scope_id__,
__vue_is_functional_template__,
__vue_module_identifier__,
false,
createInjector,
undefined,
undefined
);
const tian = {
install: function(Vue) {
Vue.component(__vue_component__.name, __vue_component__);
},
log: function() {
console.log(999999999);
}
};
// 自动注册组件
if(typeof window !== null && window.Vue) {
tian.install(window.Vue);
}
return tian;
})));
});
Vue__default['default'].use(jdwlWidget);
new Vue__default['default']({
el: '#app',
render: (h) => h(__vue_component__)
});
})));
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test app</title>
</head>
<body>
<div id="app"></div>
</body>
</html>
import App from './App.vue'
import Vue from 'vue'
import WD from '../dist/jdwl-widget'
Vue.use(WD)
new Vue({
el: '#app',
render: (h) => h(App)
})
<template>
<div>
JdwlWidget text
</div>
</template>
<script>
export default {
name: 'JdwlWidget'
}
</script>
<style lang="scss" scoped>
</style>
+16
-14
{
"name": "jdwl-widget",
"version": "1.0.0",
"description": "",
"version": "1.0.1",
"description": "test",
"main": "rollup.config.js",
"directories": {
"doc": "doc"
},
"dependencies": {},
"devDependencies": {
"@rollup/plugin-commonjs": "^15.1.0",
"rollup-plugin-serve": "^1.0.4",
"rollup-plugin-vue": "^5.1.1",
"vue-template-compiler": "^2.6.12"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c rollup.config.js"
"build": "rollup -c build/rollup.config.js",
"dev": "rollup --watch --config build/rollup.config.dev.js",
"dev:a": "rollup --watch --config build/rollup.config.dev.js --environment PROJ_ENV:A"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-vue": "^6.0.0-beta.10"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.0.0",
"vue-template-compiler": "^2.6.12"
}
"license": "ISC"
}

@@ -1,8 +0,17 @@

import Vue from 'vue'
import JdwlWidget from './jdwl-widget.vue'
import JdwlWidget from './JdwlWidget.vue'
JdwlWidget.install = function(Vue) {
Vue.components(JdwlWidget.name, JdwlWidget)
const tian = {
install: function(Vue) {
Vue.component(JdwlWidget.name, JdwlWidget)
},
log: function() {
console.log(999999999)
}
}
export default JdwlWidget
// 自动注册组件
if(typeof window !== null && window.Vue) {
tian.install(window.Vue)
}
export default tian
import { openBlock, createBlock, resolveDynamicComponent, mergeProps, toHandlers, renderSlot, withScopeId } from 'vue';
var script = {
name: "jdwl-widget",
props: {
url: {
type: String,
default: "",
},
},
inheritAttrs: true,
data() {
return {
componentName: ''
}
},
watch: {
url: {
handler(newVal) {
if(!newVal) return
this.asyncJs(newVal).then(() => {
// 根据url的路径动态计算组件名
this.componentName = 'wl-widget-app-header';
});
},
immediate: true
},
},
methods: {
asyncJs(url) {
return new Promise((resolve, reject) => {
const s = document.createElement("script");
s.type = "text/javascript";
s.src = url;
document.head.appendChild(s);
s.onload = function() {
resolve();
};
s.onerror = function() {
reject('widget onload error ...');
};
})
},
},
};
const _withId = /*#__PURE__*/withScopeId("data-v-0aa607f9");
const render = /*#__PURE__*/_withId(function render(_ctx, _cache, $props, $setup, $data, $options) {
return (openBlock(), createBlock(resolveDynamicComponent($data.componentName), mergeProps(_ctx.$attrs, toHandlers(_ctx.$listeners)), {
default: _withId(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 16 /* FULL_PROPS */))
});
script.render = render;
script.__scopeId = "data-v-0aa607f9";
script.__file = "src/jdwl-widget.vue";
script.install = function(Vue) {
Vue.components(script.name, script);
};
export default script;
import vue from 'rollup-plugin-vue'
import commonjs from 'rollup-plugin-commonjs'
export default {
input: "src/main.js",
output: {
format: "esm",
file: "dist/JdwlWidget.js",
},
plugins: [
commonjs(),
vue()
]
};
<template>
<component :is="componentName" v-bind="$attrs" v-on="$listeners">
<slot></slot>
</component>
</template>
<script>
export default {
name: "jdwl-widget",
props: {
url: {
type: String,
default: "",
},
},
inheritAttrs: true,
data() {
return {
componentName: ''
}
},
watch: {
url: {
handler(newVal) {
if(!newVal) return
this.asyncJs(newVal).then(() => {
// 根据url的路径动态计算组件名
this.componentName = 'wl-widget-app-header'
})
},
immediate: true
},
},
methods: {
asyncJs(url) {
return new Promise((resolve, reject) => {
const s = document.createElement("script");
s.type = "text/javascript";
s.src = url;
document.head.appendChild(s);
s.onload = function() {
resolve()
}
s.onerror = function() {
reject('widget onload error ...')
}
})
},
},
};
</script>
<style lang="scss" scoped>
</style>