@merkur/plugin-component 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/index.cjs +13 -6
- package/lib/index.es9.cjs +10 -7
- package/lib/index.es9.mjs +10 -4
- package/lib/index.js +13 -6
- package/lib/index.mjs +13 -4
- package/lib/index.umd.js +1 -1
- package/package.json +8 -9
- package/rollup.config.mjs +11 -0
- package/lib/index.es5.js +0 -1
package/README.md
CHANGED
|
@@ -11,4 +11,4 @@ The component plugin is one of the base Merkur plugins which adds base lifecycle
|
|
|
11
11
|
|
|
12
12
|
## About Merkur
|
|
13
13
|
|
|
14
|
-
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices. It allows by default server side rendering for loading performance boost. You can connect it with other frameworks or languages because merkur defines easy API. You can use one of four predefined template's library [
|
|
14
|
+
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices. It allows by default server side rendering for loading performance boost. You can connect it with other frameworks or languages because merkur defines easy API. You can use one of four predefined template's library [Preact](https://preactjs.com/), [µhtml](https://github.com/WebReflection/uhtml#readme), [Svelte](https://svelte.dev/) and [vanilla](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) but you can easily extend for others.
|
package/lib/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@merkur/core');
|
|
6
4
|
|
|
7
5
|
function componentPlugin() {
|
|
@@ -30,6 +28,7 @@ function componentPlugin() {
|
|
|
30
28
|
lifeCycle,
|
|
31
29
|
isMounted: false,
|
|
32
30
|
isHydrated: false,
|
|
31
|
+
suspendedTasks: [],
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
widget = {
|
|
@@ -83,6 +82,10 @@ function componentAPI() {
|
|
|
83
82
|
const html = await callLifeCycleMethod(widget, 'mount', args);
|
|
84
83
|
widget.$in.component.isMounted = true;
|
|
85
84
|
|
|
85
|
+
for (let task of widget.$in.component.suspendedTasks) {
|
|
86
|
+
await task();
|
|
87
|
+
}
|
|
88
|
+
|
|
86
89
|
return html;
|
|
87
90
|
},
|
|
88
91
|
async unmount(widget, ...args) {
|
|
@@ -111,6 +114,7 @@ function componentAPI() {
|
|
|
111
114
|
},
|
|
112
115
|
async update(widget, ...args) {
|
|
113
116
|
if (!widget.$in.component.isMounted) {
|
|
117
|
+
widget.$in.component.suspendedTasks.push(() => widget.update(...args));
|
|
114
118
|
return;
|
|
115
119
|
}
|
|
116
120
|
|
|
@@ -127,6 +131,13 @@ function componentAPI() {
|
|
|
127
131
|
return widget.update();
|
|
128
132
|
},
|
|
129
133
|
async setProps(widget, propsSetter) {
|
|
134
|
+
if (!widget.$in.component.isMounted) {
|
|
135
|
+
widget.$in.component.suspendedTasks.push(() =>
|
|
136
|
+
widget.setProps(propsSetter)
|
|
137
|
+
);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
130
141
|
widget.props = {
|
|
131
142
|
...widget.props,
|
|
132
143
|
...(typeof propsSetter === 'function'
|
|
@@ -134,10 +145,6 @@ function componentAPI() {
|
|
|
134
145
|
: propsSetter),
|
|
135
146
|
};
|
|
136
147
|
|
|
137
|
-
if (!widget.$in.component.isMounted) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
148
|
await widget.load();
|
|
142
149
|
return widget.update();
|
|
143
150
|
},
|
package/lib/index.es9.cjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
3
|
var core = require('@merkur/core');
|
|
7
4
|
function componentPlugin() {
|
|
8
5
|
return {
|
|
@@ -27,7 +24,8 @@ function componentPlugin() {
|
|
|
27
24
|
widget.$in.component = {
|
|
28
25
|
lifeCycle,
|
|
29
26
|
isMounted: false,
|
|
30
|
-
isHydrated: false
|
|
27
|
+
isHydrated: false,
|
|
28
|
+
suspendedTasks: []
|
|
31
29
|
};
|
|
32
30
|
widget = {
|
|
33
31
|
...widgetProperties,
|
|
@@ -81,6 +79,9 @@ function componentAPI() {
|
|
|
81
79
|
await widget.load(...args);
|
|
82
80
|
const html = await callLifeCycleMethod(widget, 'mount', args);
|
|
83
81
|
widget.$in.component.isMounted = true;
|
|
82
|
+
for (let task of widget.$in.component.suspendedTasks) {
|
|
83
|
+
await task();
|
|
84
|
+
}
|
|
84
85
|
return html;
|
|
85
86
|
},
|
|
86
87
|
async unmount(widget, ...args) {
|
|
@@ -104,6 +105,7 @@ function componentAPI() {
|
|
|
104
105
|
},
|
|
105
106
|
async update(widget, ...args) {
|
|
106
107
|
if (!widget.$in.component.isMounted) {
|
|
108
|
+
widget.$in.component.suspendedTasks.push(() => widget.update(...args));
|
|
107
109
|
return;
|
|
108
110
|
}
|
|
109
111
|
return callLifeCycleMethod(widget, 'update', args);
|
|
@@ -116,13 +118,14 @@ function componentAPI() {
|
|
|
116
118
|
return widget.update();
|
|
117
119
|
},
|
|
118
120
|
async setProps(widget, propsSetter) {
|
|
121
|
+
if (!widget.$in.component.isMounted) {
|
|
122
|
+
widget.$in.component.suspendedTasks.push(() => widget.setProps(propsSetter));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
119
125
|
widget.props = {
|
|
120
126
|
...widget.props,
|
|
121
127
|
...(typeof propsSetter === 'function' ? propsSetter(widget.props) : propsSetter)
|
|
122
128
|
};
|
|
123
|
-
if (!widget.$in.component.isMounted) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
129
|
await widget.load();
|
|
127
130
|
return widget.update();
|
|
128
131
|
}
|
package/lib/index.es9.mjs
CHANGED
|
@@ -22,7 +22,8 @@ function componentPlugin() {
|
|
|
22
22
|
widget.$in.component = {
|
|
23
23
|
lifeCycle,
|
|
24
24
|
isMounted: false,
|
|
25
|
-
isHydrated: false
|
|
25
|
+
isHydrated: false,
|
|
26
|
+
suspendedTasks: []
|
|
26
27
|
};
|
|
27
28
|
widget = {
|
|
28
29
|
...widgetProperties,
|
|
@@ -76,6 +77,9 @@ function componentAPI() {
|
|
|
76
77
|
await widget.load(...args);
|
|
77
78
|
const html = await callLifeCycleMethod(widget, 'mount', args);
|
|
78
79
|
widget.$in.component.isMounted = true;
|
|
80
|
+
for (let task of widget.$in.component.suspendedTasks) {
|
|
81
|
+
await task();
|
|
82
|
+
}
|
|
79
83
|
return html;
|
|
80
84
|
},
|
|
81
85
|
async unmount(widget, ...args) {
|
|
@@ -99,6 +103,7 @@ function componentAPI() {
|
|
|
99
103
|
},
|
|
100
104
|
async update(widget, ...args) {
|
|
101
105
|
if (!widget.$in.component.isMounted) {
|
|
106
|
+
widget.$in.component.suspendedTasks.push(() => widget.update(...args));
|
|
102
107
|
return;
|
|
103
108
|
}
|
|
104
109
|
return callLifeCycleMethod(widget, 'update', args);
|
|
@@ -111,13 +116,14 @@ function componentAPI() {
|
|
|
111
116
|
return widget.update();
|
|
112
117
|
},
|
|
113
118
|
async setProps(widget, propsSetter) {
|
|
119
|
+
if (!widget.$in.component.isMounted) {
|
|
120
|
+
widget.$in.component.suspendedTasks.push(() => widget.setProps(propsSetter));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
114
123
|
widget.props = {
|
|
115
124
|
...widget.props,
|
|
116
125
|
...(typeof propsSetter === 'function' ? propsSetter(widget.props) : propsSetter)
|
|
117
126
|
};
|
|
118
|
-
if (!widget.$in.component.isMounted) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
127
|
await widget.load();
|
|
122
128
|
return widget.update();
|
|
123
129
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@merkur/core');
|
|
6
4
|
|
|
7
5
|
function componentPlugin() {
|
|
@@ -30,6 +28,7 @@ function componentPlugin() {
|
|
|
30
28
|
lifeCycle,
|
|
31
29
|
isMounted: false,
|
|
32
30
|
isHydrated: false,
|
|
31
|
+
suspendedTasks: [],
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
widget = {
|
|
@@ -83,6 +82,10 @@ function componentAPI() {
|
|
|
83
82
|
const html = await callLifeCycleMethod(widget, 'mount', args);
|
|
84
83
|
widget.$in.component.isMounted = true;
|
|
85
84
|
|
|
85
|
+
for (let task of widget.$in.component.suspendedTasks) {
|
|
86
|
+
await task();
|
|
87
|
+
}
|
|
88
|
+
|
|
86
89
|
return html;
|
|
87
90
|
},
|
|
88
91
|
async unmount(widget, ...args) {
|
|
@@ -111,6 +114,7 @@ function componentAPI() {
|
|
|
111
114
|
},
|
|
112
115
|
async update(widget, ...args) {
|
|
113
116
|
if (!widget.$in.component.isMounted) {
|
|
117
|
+
widget.$in.component.suspendedTasks.push(() => widget.update(...args));
|
|
114
118
|
return;
|
|
115
119
|
}
|
|
116
120
|
|
|
@@ -127,6 +131,13 @@ function componentAPI() {
|
|
|
127
131
|
return widget.update();
|
|
128
132
|
},
|
|
129
133
|
async setProps(widget, propsSetter) {
|
|
134
|
+
if (!widget.$in.component.isMounted) {
|
|
135
|
+
widget.$in.component.suspendedTasks.push(() =>
|
|
136
|
+
widget.setProps(propsSetter)
|
|
137
|
+
);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
130
141
|
widget.props = {
|
|
131
142
|
...widget.props,
|
|
132
143
|
...(typeof propsSetter === 'function'
|
|
@@ -134,10 +145,6 @@ function componentAPI() {
|
|
|
134
145
|
: propsSetter),
|
|
135
146
|
};
|
|
136
147
|
|
|
137
|
-
if (!widget.$in.component.isMounted) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
148
|
await widget.load();
|
|
142
149
|
return widget.update();
|
|
143
150
|
},
|
package/lib/index.mjs
CHANGED
|
@@ -26,6 +26,7 @@ function componentPlugin() {
|
|
|
26
26
|
lifeCycle,
|
|
27
27
|
isMounted: false,
|
|
28
28
|
isHydrated: false,
|
|
29
|
+
suspendedTasks: [],
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
widget = {
|
|
@@ -79,6 +80,10 @@ function componentAPI() {
|
|
|
79
80
|
const html = await callLifeCycleMethod(widget, 'mount', args);
|
|
80
81
|
widget.$in.component.isMounted = true;
|
|
81
82
|
|
|
83
|
+
for (let task of widget.$in.component.suspendedTasks) {
|
|
84
|
+
await task();
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
return html;
|
|
83
88
|
},
|
|
84
89
|
async unmount(widget, ...args) {
|
|
@@ -107,6 +112,7 @@ function componentAPI() {
|
|
|
107
112
|
},
|
|
108
113
|
async update(widget, ...args) {
|
|
109
114
|
if (!widget.$in.component.isMounted) {
|
|
115
|
+
widget.$in.component.suspendedTasks.push(() => widget.update(...args));
|
|
110
116
|
return;
|
|
111
117
|
}
|
|
112
118
|
|
|
@@ -123,6 +129,13 @@ function componentAPI() {
|
|
|
123
129
|
return widget.update();
|
|
124
130
|
},
|
|
125
131
|
async setProps(widget, propsSetter) {
|
|
132
|
+
if (!widget.$in.component.isMounted) {
|
|
133
|
+
widget.$in.component.suspendedTasks.push(() =>
|
|
134
|
+
widget.setProps(propsSetter)
|
|
135
|
+
);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
126
139
|
widget.props = {
|
|
127
140
|
...widget.props,
|
|
128
141
|
...(typeof propsSetter === 'function'
|
|
@@ -130,10 +143,6 @@ function componentAPI() {
|
|
|
130
143
|
: propsSetter),
|
|
131
144
|
};
|
|
132
145
|
|
|
133
|
-
if (!widget.$in.component.isMounted) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
146
|
await widget.load();
|
|
138
147
|
return widget.update();
|
|
139
148
|
},
|
package/lib/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},n(t)}!function(n,t){if("function"==typeof define&&define.amd)define("@merkur/plugin-component",["exports","@merkur/core"],t);else if("undefined"!=typeof exports)t(exports,require("@merkur/core"));else{var e={exports:{}};t(e.exports,n.Merkur.Core),n.Merkur=n.Merkur||{},n.Merkur.Plugin=n.Merkur.Plugin||{},n.Merkur.Plugin.Component=e.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,e){Object.defineProperty(t,"__esModule",{value:!0}),t.componentPlugin=function(){return{setup:function(n,t){return s((function*(){var o=t.info,i=t.bootstrap,a=t.load,c=t.mount,l=t.unmount,y=t.update,d=function(n,t){if(null==n)return{};var e,r,o=function(n,t){if(null==n)return{};var e,r,o={},u=Object.keys(n);for(r=0;r<u.length;r++)e=u[r],t.indexOf(e)>=0||(o[e]=n[e]);return o}(n,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(n);for(r=0;r<u.length;r++)e=u[r],t.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(n,e)&&(o[e]=n[e])}return o}(t,r),m={info:o,bootstrap:i,load:a,mount:c,unmount:l,update:y};return n.$in.component={lifeCycle:m,isMounted:!1,isHydrated:!1,suspendedTasks:[]},n=f(f(f({},d),{info:function(n){var t=arguments;return s((function*(){for(var e=n.name,r=n.version,o=n.props,u=n.state,i=n.assets,a=n.containerSelector,c=t.length,l=new Array(c>1?c-1:0),s=1;s<c;s++)l[s-1]=t[s];return f({name:e,version:r,props:o,state:u,assets:i,containerSelector:a},(yield p(n,"info",l))||{})}))()},mount:function(n){var t=arguments;return s((function*(){for(var e=t.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=t[o];yield n.bootstrap.apply(n,r),yield n.load.apply(n,r);var i=yield p(n,"mount",r);n.$in.component.isMounted=!0;var a,f=function(n,t){var e="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!e){if(Array.isArray(n)||(e=u(n))||t&&n&&"number"==typeof n.length){e&&(n=e);var r=0,o=function(){};return{s:o,n:function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(n){throw n},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,f=!1;return{s:function(){e=e.call(n)},n:function(){var n=e.next();return a=n.done,n},e:function(n){f=!0,i=n},f:function(){try{a||null==e.return||e.return()}finally{if(f)throw i}}}}(n.$in.component.suspendedTasks);try{for(f.s();!(a=f.n()).done;){var c=a.value;yield c()}}catch(n){f.e(n)}finally{f.f()}return i}))()},unmount:function(n){var t=arguments;return s((function*(){n.$in.component.isMounted=!1,n.$in.component.isHydrated=!1;for(var e=t.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=t[o];return p(n,"unmount",r)}))()},bootstrap:function(n){var t=arguments;return s((function*(){for(var e=t.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=t[o];return p(n,"bootstrap",r)}))()},load:function(n){var t=arguments;return s((function*(){var e=n.$in,r=n.state;if(!1===e.component.isMounted&&!1===e.component.isHydrated&&r&&0!==Object.keys(r).length)e.component.isHydrated=!0;else{for(var o=t.length,u=new Array(o>1?o-1:0),i=1;i<o;i++)u[i-1]=t[i];n.state=yield p(n,"load",u)}}))()},update:function(n){var t=arguments;return s((function*(){for(var e=t.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=t[o];if(n.$in.component.isMounted)return p(n,"update",r);n.$in.component.suspendedTasks.push((function(){return n.update.apply(n,r)}))}))()},setState:function(n,t){return s((function*(){return n.state=f(f({},n.state),"function"==typeof t?t(n.state):t),n.update()}))()},setProps:function(n,t){return s((function*(){if(n.$in.component.isMounted)return n.props=f(f({},n.props),"function"==typeof t?t(n.props):t),yield n.load(),n.update();n.$in.component.suspendedTasks.push((function(){return n.setProps(t)}))}))()}}),n),n=(0,e.setDefaultValueForUndefined)(n,["props","state"]),n=(0,e.setDefaultValueForUndefined)(n,["assets"],[]),n=(0,e.setDefaultValueForUndefined)(n,["containerSelector"],null)}))()},create:function(n){return n}}};var r=["info","bootstrap","load","mount","unmount","update"];function o(n){return function(n){if(Array.isArray(n))return i(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||u(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(n,t){if(n){if("string"==typeof n)return i(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?i(n,t):void 0}}function i(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,r=new Array(t);e<t;e++)r[e]=n[e];return r}function a(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,r)}return e}function f(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?a(Object(e),!0).forEach((function(t){c(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):a(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function c(t,e,r){return(e=function(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(n,t,e,r,o,u,i){try{var a=n[u](i),f=a.value}catch(n){return void e(n)}a.done?t(f):Promise.resolve(f).then(r,o)}function s(n){return function(){var t=this,e=arguments;return new Promise((function(r,o){var u=n.apply(t,e);function i(n){l(u,r,o,i,a,"next",n)}function a(n){l(u,r,o,i,a,"throw",n)}i(void 0)}))}}function p(n,t,e){return y.apply(this,arguments)}function y(){return(y=s((function*(n,t,e){var r=n.$in.component.lifeCycle;if("function"==typeof r[t])return r[t].apply(r,[n].concat(o(e)))}))).apply(this,arguments)}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/plugin-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Merkur component plugin.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"./lib/index.es9.cjs": "./lib/index.es9.cjs"
|
|
16
16
|
},
|
|
17
17
|
"browser": {
|
|
18
|
-
"./lib/index.js": "./lib/index.
|
|
19
|
-
"./lib/index.cjs": "./lib/index.
|
|
18
|
+
"./lib/index.js": "./lib/index.js",
|
|
19
|
+
"./lib/index.cjs": "./lib/index.cjs",
|
|
20
20
|
"./lib/index.mjs": "./lib/index.mjs",
|
|
21
21
|
"./lib/index.es9.mjs": "./lib/index.es9.mjs"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"preversion": "npm test",
|
|
25
|
-
"test": "
|
|
26
|
-
"test:es:version": "
|
|
27
|
-
"build": "
|
|
25
|
+
"test": "jest --no-watchman -c ./jest.config.js",
|
|
26
|
+
"test:es:version": "es-check es11 ./lib/index.mjs --module && es-check es9 ./lib/index.es9.mjs --module && es-check es9 ./lib/index.es9.cjs --module",
|
|
27
|
+
"build": "rollup -c rollup.config.mjs",
|
|
28
28
|
"prepare": "npm run build"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
@@ -48,11 +48,10 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://merkur.js.org/",
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@merkur/core": "^0.
|
|
52
|
-
"rollup": "^2.70.2"
|
|
51
|
+
"@merkur/core": "^0.32.0"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
55
54
|
"@merkur/core": "*"
|
|
56
55
|
},
|
|
57
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "c45ffe12725e3c4afcf7f13869a25a96f6807055"
|
|
58
57
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRollupESConfig,
|
|
3
|
+
createRollupES9Config,
|
|
4
|
+
createRollupUMDConfig,
|
|
5
|
+
} from '../../createRollupConfig.mjs';
|
|
6
|
+
|
|
7
|
+
let esConfig = createRollupESConfig();
|
|
8
|
+
let es9Config = createRollupES9Config();
|
|
9
|
+
let umdConfig = createRollupUMDConfig();
|
|
10
|
+
|
|
11
|
+
export default [esConfig, es9Config, umdConfig];
|
package/lib/index.es5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(r){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(r)}require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.index-of.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),require("core-js/modules/es.array.for-each.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.get-own-property-descriptors.js"),require("core-js/modules/es.object.define-properties.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.symbol.async-iterator.js"),require("core-js/modules/es.symbol.to-string-tag.js"),require("core-js/modules/es.json.to-string-tag.js"),require("core-js/modules/es.math.to-string-tag.js"),require("core-js/modules/es.object.create.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.object.set-prototype-of.js"),require("core-js/modules/es.array.reverse.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.is-array.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.regexp.exec.js");var r=["info","bootstrap","load","mount","unmount","update"];function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(!e)return;if("string"==typeof e)return n(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return n(e,r)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function o(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */o=function(){return r};var r={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function f(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{f({},"")}catch(e){f=function(e,r,t){return e[r]=t}}function l(e,r,t,n){var o=r&&r.prototype instanceof h?r:h,a=Object.create(o.prototype),u=new E(n||[]);return i(a,"_invoke",{value:O(e,t,u)}),a}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var d={};function h(){}function y(){}function m(){}var v={};f(v,u,(function(){return this}));var b=Object.getPrototypeOf,j=b&&b(b(S([])));j&&j!==t&&n.call(j,u)&&(v=j);var g=m.prototype=h.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(r){f(e,r,(function(e){return this._invoke(r,e)}))}))}function x(r,t){function o(i,a,u,s){var c=p(r[i],r,a);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==e(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){o("next",e,u,s)}),(function(e){o("throw",e,u,s)})):t.resolve(l).then((function(e){f.value=e,u(f)}),(function(e){return o("throw",e,u,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function O(e,r,t){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(t.method=o,t.arg=i;;){var a=t.delegate;if(a){var u=q(a,t);if(u){if(u===d)continue;return u}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var s=p(e,r,t);if("normal"===s.type){if(n=t.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:t.done}}"throw"===s.type&&(n="completed",t.method="throw",t.arg=s.arg)}}}function q(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,q(e,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=p(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,d;var o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function L(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function S(e){if(e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,o=function r(){for(;++t<e.length;)if(n.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return y.prototype=m,i(g,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:y,configurable:!0}),y.displayName=f(m,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===y||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,f(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},r.awrap=function(e){return{__await:e}},w(x.prototype),f(x.prototype,s,(function(){return this})),r.AsyncIterator=x,r.async=function(e,t,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,t,n,o),i);return r.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},w(g),f(g,c,"Generator"),f(g,u,(function(){return this})),f(g,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=S,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function t(t,n){return a.type="throw",a.arg=e,r.next=t,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return t(i.catchLoc,!0);if(this.prev<i.finallyLoc)return t(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return t(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return t(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),d},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),L(t),d}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;L(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:S(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),d}},r}function i(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function a(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?i(Object(t),!0).forEach((function(r){u(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function u(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function s(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function c(e,r,t,n,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void t(e)}u.done?r(s):Promise.resolve(s).then(n,o)}function f(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var i=e.apply(r,t);function a(e){c(i,n,o,a,u,"next",e)}function u(e){c(i,n,o,a,u,"throw",e)}a(void 0)}))}}require("core-js/modules/es.object.define-property.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.array.concat.js"),Object.defineProperty(exports,"__esModule",{value:!0});var l=require("@merkur/core");function p(e,r,t){return d.apply(this,arguments)}function d(){return(d=f(o().mark((function e(r,n,i){var a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof(a=r.$in.component.lifeCycle)[n]){e.next=3;break}return e.abrupt("return",a[n].apply(a,[r].concat(t(i))));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}exports.componentPlugin=function(){return{setup:function(e,t){return f(o().mark((function n(){var i,u,c,d,h,y,m,v;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=t.info,u=t.bootstrap,c=t.load,d=t.mount,h=t.unmount,y=t.update,m=s(t,r),v={info:i,bootstrap:u,load:c,mount:d,unmount:h,update:y},e.$in.component={lifeCycle:v,isMounted:!1,isHydrated:!1},e=a(a(a({},m),{info:function(e){var r=arguments;return f(o().mark((function t(){var n,i,u,s,c,f,l,d,h,y;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=e.name,i=e.version,u=e.props,s=e.state,c=e.assets,f=e.containerSelector,l=r.length,d=new Array(l>1?l-1:0),h=1;h<l;h++)d[h-1]=r[h];return t.next=4,p(e,"info",d);case 4:if(t.t0=t.sent,t.t0){t.next=7;break}t.t0={};case 7:return y=t.t0,t.abrupt("return",a({name:n,version:i,props:u,state:s,assets:c,containerSelector:f},y));case 9:case"end":return t.stop()}}),t)})))()},mount:function(e){var r=arguments;return f(o().mark((function t(){var n,i,a,u;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=r.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=r[a];return t.next=3,e.bootstrap.apply(e,i);case 3:return t.next=5,e.load.apply(e,i);case 5:return t.next=7,p(e,"mount",i);case 7:return u=t.sent,e.$in.component.isMounted=!0,t.abrupt("return",u);case 10:case"end":return t.stop()}}),t)})))()},unmount:function(e){var r=arguments;return f(o().mark((function t(){var n,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e.$in.component.isMounted=!1,e.$in.component.isHydrated=!1,n=r.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=r[a];return t.abrupt("return",p(e,"unmount",i));case 4:case"end":return t.stop()}}),t)})))()},bootstrap:function(e){var r=arguments;return f(o().mark((function t(){var n,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=r.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=r[a];return t.abrupt("return",p(e,"bootstrap",i));case 2:case"end":return t.stop()}}),t)})))()},load:function(e){var r=arguments;return f(o().mark((function t(){var n,i,a,u,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.$in,i=e.state,!1!==n.component.isMounted||!1!==n.component.isHydrated||!i||0===Object.keys(i).length){t.next=4;break}return n.component.isHydrated=!0,t.abrupt("return");case 4:for(a=r.length,u=new Array(a>1?a-1:0),s=1;s<a;s++)u[s-1]=r[s];return t.next=7,p(e,"load",u);case 7:e.state=t.sent;case 8:case"end":return t.stop()}}),t)})))()},update:function(e){var r=arguments;return f(o().mark((function t(){var n,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.$in.component.isMounted){t.next=2;break}return t.abrupt("return");case 2:for(n=r.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=r[a];return t.abrupt("return",p(e,"update",i));case 4:case"end":return t.stop()}}),t)})))()},setState:function(e,r){return f(o().mark((function t(){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.state=a(a({},e.state),"function"==typeof r?r(e.state):r),t.abrupt("return",e.update());case 2:case"end":return t.stop()}}),t)})))()},setProps:function(e,r){return f(o().mark((function t(){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.props=a(a({},e.props),"function"==typeof r?r(e.props):r),e.$in.component.isMounted){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,e.load();case 5:return t.abrupt("return",e.update());case 6:case"end":return t.stop()}}),t)})))()}}),e),e=l.setDefaultValueForUndefined(e,["props","state"]),e=l.setDefaultValueForUndefined(e,["assets"],[]),e=l.setDefaultValueForUndefined(e,["containerSelector"],null),n.abrupt("return",e);case 8:case"end":return n.stop()}}),n)})))()},create:function(e){return e}}};
|