@merkur/plugin-component 0.46.0-rc.5 → 0.47.2
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/lib/index.cjs +15 -1
- package/lib/index.es9.cjs +15 -1
- package/lib/index.es9.mjs +15 -1
- package/lib/index.js +15 -1
- package/lib/index.mjs +15 -1
- package/lib/index.umd.js +1 -1
- package/package.json +3 -3
package/lib/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ function componentPlugin() {
|
|
|
26
26
|
lifeCycle,
|
|
27
27
|
isMounted: false,
|
|
28
28
|
isHydrated: false,
|
|
29
|
+
loadingPromise: null,
|
|
29
30
|
suspendedTasks: [],
|
|
30
31
|
resolvedViews: new Map()
|
|
31
32
|
};
|
|
@@ -98,7 +99,17 @@ function componentAPI() {
|
|
|
98
99
|
$in.component.isHydrated = true;
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
+
const loadingPromise = callLifeCycleMethod(widget, 'load', args).then(state => {
|
|
103
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
104
|
+
widget.state = state;
|
|
105
|
+
}
|
|
106
|
+
}).finally(() => {
|
|
107
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
108
|
+
$in.component.loadingPromise = null;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
$in.component.loadingPromise = loadingPromise;
|
|
112
|
+
await loadingPromise;
|
|
102
113
|
},
|
|
103
114
|
async update(widget, ...args) {
|
|
104
115
|
if (!widget.$in.component.isMounted) {
|
|
@@ -108,6 +119,9 @@ function componentAPI() {
|
|
|
108
119
|
return callLifeCycleMethod(widget, 'update', args);
|
|
109
120
|
},
|
|
110
121
|
async setState(widget, stateSetter) {
|
|
122
|
+
while (widget.$in.component.loadingPromise) {
|
|
123
|
+
await widget.$in.component.loadingPromise;
|
|
124
|
+
}
|
|
111
125
|
widget.state = {
|
|
112
126
|
...widget.state,
|
|
113
127
|
...(typeof stateSetter === 'function' ? stateSetter(widget.state) : stateSetter)
|
package/lib/index.es9.cjs
CHANGED
|
@@ -25,6 +25,7 @@ function componentPlugin() {
|
|
|
25
25
|
lifeCycle,
|
|
26
26
|
isMounted: false,
|
|
27
27
|
isHydrated: false,
|
|
28
|
+
loadingPromise: null,
|
|
28
29
|
suspendedTasks: [],
|
|
29
30
|
resolvedViews: new Map()
|
|
30
31
|
};
|
|
@@ -97,7 +98,17 @@ function componentAPI() {
|
|
|
97
98
|
$in.component.isHydrated = true;
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
+
const loadingPromise = callLifeCycleMethod(widget, 'load', args).then(state => {
|
|
102
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
103
|
+
widget.state = state;
|
|
104
|
+
}
|
|
105
|
+
}).finally(() => {
|
|
106
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
107
|
+
$in.component.loadingPromise = null;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
$in.component.loadingPromise = loadingPromise;
|
|
111
|
+
await loadingPromise;
|
|
101
112
|
},
|
|
102
113
|
async update(widget, ...args) {
|
|
103
114
|
if (!widget.$in.component.isMounted) {
|
|
@@ -107,6 +118,9 @@ function componentAPI() {
|
|
|
107
118
|
return callLifeCycleMethod(widget, 'update', args);
|
|
108
119
|
},
|
|
109
120
|
async setState(widget, stateSetter) {
|
|
121
|
+
while (widget.$in.component.loadingPromise) {
|
|
122
|
+
await widget.$in.component.loadingPromise;
|
|
123
|
+
}
|
|
110
124
|
widget.state = {
|
|
111
125
|
...widget.state,
|
|
112
126
|
...(typeof stateSetter === 'function' ? stateSetter(widget.state) : stateSetter)
|
package/lib/index.es9.mjs
CHANGED
|
@@ -23,6 +23,7 @@ function componentPlugin() {
|
|
|
23
23
|
lifeCycle,
|
|
24
24
|
isMounted: false,
|
|
25
25
|
isHydrated: false,
|
|
26
|
+
loadingPromise: null,
|
|
26
27
|
suspendedTasks: [],
|
|
27
28
|
resolvedViews: new Map()
|
|
28
29
|
};
|
|
@@ -95,7 +96,17 @@ function componentAPI() {
|
|
|
95
96
|
$in.component.isHydrated = true;
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
const loadingPromise = callLifeCycleMethod(widget, 'load', args).then(state => {
|
|
100
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
101
|
+
widget.state = state;
|
|
102
|
+
}
|
|
103
|
+
}).finally(() => {
|
|
104
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
105
|
+
$in.component.loadingPromise = null;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
$in.component.loadingPromise = loadingPromise;
|
|
109
|
+
await loadingPromise;
|
|
99
110
|
},
|
|
100
111
|
async update(widget, ...args) {
|
|
101
112
|
if (!widget.$in.component.isMounted) {
|
|
@@ -105,6 +116,9 @@ function componentAPI() {
|
|
|
105
116
|
return callLifeCycleMethod(widget, 'update', args);
|
|
106
117
|
},
|
|
107
118
|
async setState(widget, stateSetter) {
|
|
119
|
+
while (widget.$in.component.loadingPromise) {
|
|
120
|
+
await widget.$in.component.loadingPromise;
|
|
121
|
+
}
|
|
108
122
|
widget.state = {
|
|
109
123
|
...widget.state,
|
|
110
124
|
...(typeof stateSetter === 'function' ? stateSetter(widget.state) : stateSetter)
|
package/lib/index.js
CHANGED
|
@@ -26,6 +26,7 @@ function componentPlugin() {
|
|
|
26
26
|
lifeCycle,
|
|
27
27
|
isMounted: false,
|
|
28
28
|
isHydrated: false,
|
|
29
|
+
loadingPromise: null,
|
|
29
30
|
suspendedTasks: [],
|
|
30
31
|
resolvedViews: new Map()
|
|
31
32
|
};
|
|
@@ -98,7 +99,17 @@ function componentAPI() {
|
|
|
98
99
|
$in.component.isHydrated = true;
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
+
const loadingPromise = callLifeCycleMethod(widget, 'load', args).then(state => {
|
|
103
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
104
|
+
widget.state = state;
|
|
105
|
+
}
|
|
106
|
+
}).finally(() => {
|
|
107
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
108
|
+
$in.component.loadingPromise = null;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
$in.component.loadingPromise = loadingPromise;
|
|
112
|
+
await loadingPromise;
|
|
102
113
|
},
|
|
103
114
|
async update(widget, ...args) {
|
|
104
115
|
if (!widget.$in.component.isMounted) {
|
|
@@ -108,6 +119,9 @@ function componentAPI() {
|
|
|
108
119
|
return callLifeCycleMethod(widget, 'update', args);
|
|
109
120
|
},
|
|
110
121
|
async setState(widget, stateSetter) {
|
|
122
|
+
while (widget.$in.component.loadingPromise) {
|
|
123
|
+
await widget.$in.component.loadingPromise;
|
|
124
|
+
}
|
|
111
125
|
widget.state = {
|
|
112
126
|
...widget.state,
|
|
113
127
|
...(typeof stateSetter === 'function' ? stateSetter(widget.state) : stateSetter)
|
package/lib/index.mjs
CHANGED
|
@@ -24,6 +24,7 @@ function componentPlugin() {
|
|
|
24
24
|
lifeCycle,
|
|
25
25
|
isMounted: false,
|
|
26
26
|
isHydrated: false,
|
|
27
|
+
loadingPromise: null,
|
|
27
28
|
suspendedTasks: [],
|
|
28
29
|
resolvedViews: new Map()
|
|
29
30
|
};
|
|
@@ -96,7 +97,17 @@ function componentAPI() {
|
|
|
96
97
|
$in.component.isHydrated = true;
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
+
const loadingPromise = callLifeCycleMethod(widget, 'load', args).then(state => {
|
|
101
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
102
|
+
widget.state = state;
|
|
103
|
+
}
|
|
104
|
+
}).finally(() => {
|
|
105
|
+
if ($in.component.loadingPromise === loadingPromise) {
|
|
106
|
+
$in.component.loadingPromise = null;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
$in.component.loadingPromise = loadingPromise;
|
|
110
|
+
await loadingPromise;
|
|
100
111
|
},
|
|
101
112
|
async update(widget, ...args) {
|
|
102
113
|
if (!widget.$in.component.isMounted) {
|
|
@@ -106,6 +117,9 @@ function componentAPI() {
|
|
|
106
117
|
return callLifeCycleMethod(widget, 'update', args);
|
|
107
118
|
},
|
|
108
119
|
async setState(widget, stateSetter) {
|
|
120
|
+
while (widget.$in.component.loadingPromise) {
|
|
121
|
+
await widget.$in.component.loadingPromise;
|
|
122
|
+
}
|
|
109
123
|
widget.state = {
|
|
110
124
|
...widget.state,
|
|
111
125
|
...(typeof stateSetter === 'function' ? stateSetter(widget.state) : stateSetter)
|
package/lib/index.umd.js
CHANGED
|
@@ -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 y((function*(){var o=t.info,
|
|
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 y((function*(){var o=t.info,i=t.bootstrap,a=t.load,f=t.mount,l=t.unmount,p=t.update,m=s(t,r),v={info:o,bootstrap:i,load:a,mount:f,unmount:l,update:p};return n.$in.component={lifeCycle:v,isMounted:!1,isHydrated:!1,loadingPromise:null,suspendedTasks:[],resolvedViews:new Map},(0,e.assignMissingKeys)(n,{info:function(n){var t=arguments;return y((function*(){for(var e=n.name,r=n.version,o=n.props,i=n.state,u=n.assets,a=n.containerSelector,f=t.length,l=new Array(f>1?f-1:0),s=1;s<f;s++)l[s-1]=t[s];return c({name:e,version:r,props:o,state:i,assets:u,containerSelector:a},(yield d(n,"info",l))||{})}))()},mount:function(n){var t=arguments;return y((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 d(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 y((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 d(n,"unmount",r)}))()},bootstrap:function(n){var t=arguments;return y((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 d(n,"bootstrap",r)}))()},load:function(n){var t=arguments;return y((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,i=new Array(o>1?o-1:0),u=1;u<o;u++)i[u-1]=t[u];var a=d(n,"load",i).then((function(t){e.component.loadingPromise===a&&(n.state=t)})).finally((function(){e.component.loadingPromise===a&&(e.component.loadingPromise=null)}));e.component.loadingPromise=a,yield a}}))()},update:function(n){var t=arguments;return y((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 d(n,"update",r);n.$in.component.suspendedTasks.push((function(){return n.update.apply(n,r)}))}))()},setState:function(n,t){return y((function*(){for(;n.$in.component.loadingPromise;)yield n.$in.component.loadingPromise;return n.state=c(c({},n.state),"function"==typeof t?t(n.state):t),n.update()}))()},setProps:function(n,t){return y((function*(){if(n.$in.component.isMounted)return n.props=c(c({},n.props),"function"==typeof t?t(n.props):t),yield n.load(),n.update();n.$in.component.suspendedTasks.push((function(){return n.setProps(t)}))}))()}},m),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}}},t.createSlotFactory=function(n){return function(){var t=y((function*(t){return n(t)}));return function(n){return t.apply(this,arguments)}}()},t.createViewFactory=function(n){return function(){var t=y((function*(t){var e=yield n(t),r=e.slotFactories,i=s(e,o);if(!r)return c({},i);var u=(yield Promise.all(r.map((function(n){return n(t)})))).reduce((function(n,t){return n[t.name]=t,n}),{});return c(c({},i),{},{slot:u})}));return function(n){return t.apply(this,arguments)}}()};var r=["info","bootstrap","load","mount","unmount","update"],o=["slotFactories"];function i(n){return function(n){if(Array.isArray(n))return a(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 a(n,t);var e={}.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)?a(n,t):void 0}}function a(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,r=Array(t);e<t;e++)r[e]=n[e];return r}function f(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 c(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?f(Object(e),!0).forEach((function(t){l(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):f(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function l(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=n(t)||!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:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(n,t){if(null==n)return{};var e,r,o=function(n,t){if(null==n)return{};var e={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(-1!==t.indexOf(r))continue;e[r]=n[r]}return e}(n,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);for(r=0;r<i.length;r++)e=i[r],-1===t.indexOf(e)&&{}.propertyIsEnumerable.call(n,e)&&(o[e]=n[e])}return o}function p(n,t,e,r,o,i,u){try{var a=n[i](u),f=a.value}catch(n){return void e(n)}a.done?t(f):Promise.resolve(f).then(r,o)}function y(n){return function(){var t=this,e=arguments;return new Promise((function(r,o){var i=n.apply(t,e);function u(n){p(i,r,o,u,a,"next",n)}function a(n){p(i,r,o,u,a,"throw",n)}u(void 0)}))}}function d(n,t,e){return m.apply(this,arguments)}function m(){return(m=y((function*(n,t,e){var r=n.$in.component.lifeCycle;if("function"==typeof r[t])return r[t].apply(r,[n].concat(i(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.47.2",
|
|
4
4
|
"description": "Merkur component plugin.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
},
|
|
62
62
|
"homepage": "https://merkur.js.org/",
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@merkur/core": "0.
|
|
64
|
+
"@merkur/core": "^0.47.2"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@merkur/core": "*"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "1f8dd906f352a28828785d33791a8a4129836f35"
|
|
70
70
|
}
|