@merkur/core 0.31.0 → 0.33.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 +19 -8
- package/lib/index.es9.cjs +11 -3
- package/lib/index.es9.mjs +11 -1
- package/lib/index.js +19 -8
- package/lib/index.mjs +19 -7
- package/lib/index.umd.js +1 -1
- package/package.json +7 -10
- package/rollup.config.mjs +11 -0
- package/lib/index.es5.js +0 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|

|
|
12
12
|
[](https://github.com/prettier/prettier)
|
|
13
13
|
|
|
14
|
-
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices(micro frontends). 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 six predefined template's library [
|
|
14
|
+
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices(micro frontends). 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 six 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.
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
- Flexible templating engine
|
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
|
function createBoundedFunction(widget, originalFunction) {
|
|
6
4
|
return (...rest) => {
|
|
7
5
|
return originalFunction(widget, ...rest);
|
|
@@ -47,7 +45,7 @@ function parsePath(widget, path = '') {
|
|
|
47
45
|
|
|
48
46
|
if (!isFunction(target[methodName])) {
|
|
49
47
|
throw new Error(
|
|
50
|
-
`Defined path '${path}' is incorrect. Check your widget structure
|
|
48
|
+
`Defined path '${path}' is incorrect. Check your widget structure.`,
|
|
51
49
|
);
|
|
52
50
|
}
|
|
53
51
|
|
|
@@ -58,6 +56,18 @@ function isFunction(value) {
|
|
|
58
56
|
return typeof value === 'function';
|
|
59
57
|
}
|
|
60
58
|
|
|
59
|
+
function assignMissingKeys(target, ...sources) {
|
|
60
|
+
sources.forEach((source) => {
|
|
61
|
+
Object.keys(source || {}).forEach((key) => {
|
|
62
|
+
if (!(key in target)) {
|
|
63
|
+
target[key] = source[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return target;
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
async function callPluginMethod(widget, method, args) {
|
|
62
72
|
for (const plugin of widget.$plugins) {
|
|
63
73
|
if (isFunction(plugin[method])) {
|
|
@@ -76,7 +86,7 @@ async function createMerkurWidget(widgetDefinition = {}) {
|
|
|
76
86
|
widgetDefinition = setDefaultValueForUndefined(
|
|
77
87
|
widgetDefinition,
|
|
78
88
|
['setup', 'create'],
|
|
79
|
-
(widget) => widget
|
|
89
|
+
(widget) => widget,
|
|
80
90
|
);
|
|
81
91
|
|
|
82
92
|
const { setup, create } = widgetDefinition;
|
|
@@ -93,7 +103,7 @@ async function createMerkurWidget(widgetDefinition = {}) {
|
|
|
93
103
|
return create(widget, ...rest);
|
|
94
104
|
},
|
|
95
105
|
$plugins: (widgetDefinition.$plugins || []).map((pluginFactory) =>
|
|
96
|
-
pluginFactory()
|
|
106
|
+
pluginFactory(),
|
|
97
107
|
),
|
|
98
108
|
};
|
|
99
109
|
|
|
@@ -137,7 +147,7 @@ function create(widgetProperties = {}) {
|
|
|
137
147
|
throw new Error(
|
|
138
148
|
`The widget with defined name and version "${
|
|
139
149
|
name + version
|
|
140
|
-
}" is not defined
|
|
150
|
+
}" is not defined.`,
|
|
141
151
|
);
|
|
142
152
|
}
|
|
143
153
|
|
|
@@ -187,8 +197,8 @@ function isRegistered(name) {
|
|
|
187
197
|
|
|
188
198
|
return Boolean(
|
|
189
199
|
Object.keys(merkur.$in.widgetFactory).find((key) =>
|
|
190
|
-
new RegExp(`^${name}`).test(key)
|
|
191
|
-
)
|
|
200
|
+
new RegExp(`^${name}`).test(key),
|
|
201
|
+
),
|
|
192
202
|
);
|
|
193
203
|
}
|
|
194
204
|
|
|
@@ -209,6 +219,7 @@ function getGlobalContext() {
|
|
|
209
219
|
return {};
|
|
210
220
|
}
|
|
211
221
|
|
|
222
|
+
exports.assignMissingKeys = assignMissingKeys;
|
|
212
223
|
exports.bindWidgetToFunctions = bindWidgetToFunctions;
|
|
213
224
|
exports.createMerkur = createMerkur;
|
|
214
225
|
exports.createMerkurWidget = createMerkurWidget;
|
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
|
function createBoundedFunction(widget, originalFunction) {
|
|
7
4
|
return (...rest) => {
|
|
8
5
|
return originalFunction(widget, ...rest);
|
|
@@ -52,6 +49,16 @@ function parsePath(widget, path = '') {
|
|
|
52
49
|
function isFunction(value) {
|
|
53
50
|
return typeof value === 'function';
|
|
54
51
|
}
|
|
52
|
+
function assignMissingKeys(target, ...sources) {
|
|
53
|
+
sources.forEach(source => {
|
|
54
|
+
Object.keys(source || {}).forEach(key => {
|
|
55
|
+
if (!(key in target)) {
|
|
56
|
+
target[key] = source[key];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
55
62
|
async function callPluginMethod(widget, method, args) {
|
|
56
63
|
for (const plugin of widget.$plugins) {
|
|
57
64
|
if (isFunction(plugin[method])) {
|
|
@@ -169,6 +176,7 @@ function getGlobalContext() {
|
|
|
169
176
|
}
|
|
170
177
|
return {};
|
|
171
178
|
}
|
|
179
|
+
exports.assignMissingKeys = assignMissingKeys;
|
|
172
180
|
exports.bindWidgetToFunctions = bindWidgetToFunctions;
|
|
173
181
|
exports.createMerkur = createMerkur;
|
|
174
182
|
exports.createMerkurWidget = createMerkurWidget;
|
package/lib/index.es9.mjs
CHANGED
|
@@ -47,6 +47,16 @@ function parsePath(widget, path = '') {
|
|
|
47
47
|
function isFunction(value) {
|
|
48
48
|
return typeof value === 'function';
|
|
49
49
|
}
|
|
50
|
+
function assignMissingKeys(target, ...sources) {
|
|
51
|
+
sources.forEach(source => {
|
|
52
|
+
Object.keys(source || {}).forEach(key => {
|
|
53
|
+
if (!(key in target)) {
|
|
54
|
+
target[key] = source[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
50
60
|
async function callPluginMethod(widget, method, args) {
|
|
51
61
|
for (const plugin of widget.$plugins) {
|
|
52
62
|
if (isFunction(plugin[method])) {
|
|
@@ -164,4 +174,4 @@ function getGlobalContext() {
|
|
|
164
174
|
}
|
|
165
175
|
return {};
|
|
166
176
|
}
|
|
167
|
-
export { bindWidgetToFunctions, createMerkur, createMerkurWidget, getMerkur, hookMethod, isFunction, removeMerkur, setDefaultValueForUndefined };
|
|
177
|
+
export { assignMissingKeys, bindWidgetToFunctions, createMerkur, createMerkurWidget, getMerkur, hookMethod, isFunction, removeMerkur, setDefaultValueForUndefined };
|
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
|
function createBoundedFunction(widget, originalFunction) {
|
|
6
4
|
return (...rest) => {
|
|
7
5
|
return originalFunction(widget, ...rest);
|
|
@@ -47,7 +45,7 @@ function parsePath(widget, path = '') {
|
|
|
47
45
|
|
|
48
46
|
if (!isFunction(target[methodName])) {
|
|
49
47
|
throw new Error(
|
|
50
|
-
`Defined path '${path}' is incorrect. Check your widget structure
|
|
48
|
+
`Defined path '${path}' is incorrect. Check your widget structure.`,
|
|
51
49
|
);
|
|
52
50
|
}
|
|
53
51
|
|
|
@@ -58,6 +56,18 @@ function isFunction(value) {
|
|
|
58
56
|
return typeof value === 'function';
|
|
59
57
|
}
|
|
60
58
|
|
|
59
|
+
function assignMissingKeys(target, ...sources) {
|
|
60
|
+
sources.forEach((source) => {
|
|
61
|
+
Object.keys(source || {}).forEach((key) => {
|
|
62
|
+
if (!(key in target)) {
|
|
63
|
+
target[key] = source[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return target;
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
async function callPluginMethod(widget, method, args) {
|
|
62
72
|
for (const plugin of widget.$plugins) {
|
|
63
73
|
if (isFunction(plugin[method])) {
|
|
@@ -76,7 +86,7 @@ async function createMerkurWidget(widgetDefinition = {}) {
|
|
|
76
86
|
widgetDefinition = setDefaultValueForUndefined(
|
|
77
87
|
widgetDefinition,
|
|
78
88
|
['setup', 'create'],
|
|
79
|
-
(widget) => widget
|
|
89
|
+
(widget) => widget,
|
|
80
90
|
);
|
|
81
91
|
|
|
82
92
|
const { setup, create } = widgetDefinition;
|
|
@@ -93,7 +103,7 @@ async function createMerkurWidget(widgetDefinition = {}) {
|
|
|
93
103
|
return create(widget, ...rest);
|
|
94
104
|
},
|
|
95
105
|
$plugins: (widgetDefinition.$plugins || []).map((pluginFactory) =>
|
|
96
|
-
pluginFactory()
|
|
106
|
+
pluginFactory(),
|
|
97
107
|
),
|
|
98
108
|
};
|
|
99
109
|
|
|
@@ -137,7 +147,7 @@ function create(widgetProperties = {}) {
|
|
|
137
147
|
throw new Error(
|
|
138
148
|
`The widget with defined name and version "${
|
|
139
149
|
name + version
|
|
140
|
-
}" is not defined
|
|
150
|
+
}" is not defined.`,
|
|
141
151
|
);
|
|
142
152
|
}
|
|
143
153
|
|
|
@@ -187,8 +197,8 @@ function isRegistered(name) {
|
|
|
187
197
|
|
|
188
198
|
return Boolean(
|
|
189
199
|
Object.keys(merkur.$in.widgetFactory).find((key) =>
|
|
190
|
-
new RegExp(`^${name}`).test(key)
|
|
191
|
-
)
|
|
200
|
+
new RegExp(`^${name}`).test(key),
|
|
201
|
+
),
|
|
192
202
|
);
|
|
193
203
|
}
|
|
194
204
|
|
|
@@ -209,6 +219,7 @@ function getGlobalContext() {
|
|
|
209
219
|
return {};
|
|
210
220
|
}
|
|
211
221
|
|
|
222
|
+
exports.assignMissingKeys = assignMissingKeys;
|
|
212
223
|
exports.bindWidgetToFunctions = bindWidgetToFunctions;
|
|
213
224
|
exports.createMerkur = createMerkur;
|
|
214
225
|
exports.createMerkurWidget = createMerkurWidget;
|
package/lib/index.mjs
CHANGED
|
@@ -43,7 +43,7 @@ function parsePath(widget, path = '') {
|
|
|
43
43
|
|
|
44
44
|
if (!isFunction(target[methodName])) {
|
|
45
45
|
throw new Error(
|
|
46
|
-
`Defined path '${path}' is incorrect. Check your widget structure
|
|
46
|
+
`Defined path '${path}' is incorrect. Check your widget structure.`,
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -54,6 +54,18 @@ function isFunction(value) {
|
|
|
54
54
|
return typeof value === 'function';
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
function assignMissingKeys(target, ...sources) {
|
|
58
|
+
sources.forEach((source) => {
|
|
59
|
+
Object.keys(source || {}).forEach((key) => {
|
|
60
|
+
if (!(key in target)) {
|
|
61
|
+
target[key] = source[key];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return target;
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
async function callPluginMethod(widget, method, args) {
|
|
58
70
|
for (const plugin of widget.$plugins) {
|
|
59
71
|
if (isFunction(plugin[method])) {
|
|
@@ -72,7 +84,7 @@ async function createMerkurWidget(widgetDefinition = {}) {
|
|
|
72
84
|
widgetDefinition = setDefaultValueForUndefined(
|
|
73
85
|
widgetDefinition,
|
|
74
86
|
['setup', 'create'],
|
|
75
|
-
(widget) => widget
|
|
87
|
+
(widget) => widget,
|
|
76
88
|
);
|
|
77
89
|
|
|
78
90
|
const { setup, create } = widgetDefinition;
|
|
@@ -89,7 +101,7 @@ async function createMerkurWidget(widgetDefinition = {}) {
|
|
|
89
101
|
return create(widget, ...rest);
|
|
90
102
|
},
|
|
91
103
|
$plugins: (widgetDefinition.$plugins || []).map((pluginFactory) =>
|
|
92
|
-
pluginFactory()
|
|
104
|
+
pluginFactory(),
|
|
93
105
|
),
|
|
94
106
|
};
|
|
95
107
|
|
|
@@ -133,7 +145,7 @@ function create(widgetProperties = {}) {
|
|
|
133
145
|
throw new Error(
|
|
134
146
|
`The widget with defined name and version "${
|
|
135
147
|
name + version
|
|
136
|
-
}" is not defined
|
|
148
|
+
}" is not defined.`,
|
|
137
149
|
);
|
|
138
150
|
}
|
|
139
151
|
|
|
@@ -183,8 +195,8 @@ function isRegistered(name) {
|
|
|
183
195
|
|
|
184
196
|
return Boolean(
|
|
185
197
|
Object.keys(merkur.$in.widgetFactory).find((key) =>
|
|
186
|
-
new RegExp(`^${name}`).test(key)
|
|
187
|
-
)
|
|
198
|
+
new RegExp(`^${name}`).test(key),
|
|
199
|
+
),
|
|
188
200
|
);
|
|
189
201
|
}
|
|
190
202
|
|
|
@@ -205,4 +217,4 @@ function getGlobalContext() {
|
|
|
205
217
|
return {};
|
|
206
218
|
}
|
|
207
219
|
|
|
208
|
-
export { bindWidgetToFunctions, createMerkur, createMerkurWidget, getMerkur, hookMethod, isFunction, removeMerkur, setDefaultValueForUndefined };
|
|
220
|
+
export { assignMissingKeys, bindWidgetToFunctions, createMerkur, createMerkurWidget, getMerkur, hookMethod, isFunction, removeMerkur, setDefaultValueForUndefined };
|
package/lib/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){if("function"==typeof define&&define.amd)define("@merkur/core",["exports"],n);else if("undefined"!=typeof exports)n(exports);else{var t={exports:{}};n(t.exports),e.Merkur=e.Merkur||{},e.Merkur.Core=t.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){function n(e){return function(e){if(Array.isArray(e))return
|
|
1
|
+
!function(e,n){if("function"==typeof define&&define.amd)define("@merkur/core",["exports"],n);else if("undefined"!=typeof exports)n(exports);else{var t={exports:{}};n(t.exports),e.Merkur=e.Merkur||{},e.Merkur.Core=t.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||t(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 t(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function o(e){return o="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},o(e)}function i(e,n,t,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){return void t(e)}a.done?n(c):Promise.resolve(c).then(r,o)}function u(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var u=e.apply(n,t);function a(e){i(u,r,o,a,c,"next",e)}function c(e){i(u,r,o,a,c,"throw",e)}a(void 0)}))}}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function c(e,n,t){return(n=function(e){var n=function(e,n){if("object"!==o(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!==o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"===o(n)?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function f(e,n){return function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return n.apply(void 0,[e].concat(r))}}function l(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){c(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},e);return n.forEach((function(e){r[e]=r[e]||t})),r}function s(e,n){n=n||e,Object.keys(n).forEach((function(t){if(d(n[t])){var r=n[t];n[t]=f(e,r)}}))}function d(e){return"function"==typeof e}function p(e,n,t){return y.apply(this,arguments)}function y(){return(y=u((function*(e,r,o){var i,u=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=t(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}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 u,a=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,u=e},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw u}}}}(e.$plugins);try{for(u.s();!(i=u.n()).done;){var a=i.value;d(a[r])&&(e=yield a[r].apply(a,[e].concat(n(o))))}}catch(e){u.e(e)}finally{u.f()}return e}))).apply(this,arguments)}function v(){return v=u((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=l(e,["$dependencies","$external"]),e=l(e,["setup","create"],(function(e){return e}));var n=e,t=n.setup,r=n.create,o={setup:function(e){var n=arguments;return u((function*(){for(var r=n.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=n[i];return e=yield p(e,"setup",o),t.apply(void 0,[e].concat(o))}))()},create:function(e){var n=arguments;return u((function*(){for(var t=n.length,o=new Array(t>1?t-1:0),i=1;i<t;i++)o[i-1]=n[i];return e=yield p(e,"create",o),r.apply(void 0,[e].concat(o))}))()},$plugins:(e.$plugins||[]).map((function(e){return e()}))};return o.name=e.name,o.version=e.version,o.$dependencies=e.$dependencies,o.$external=e.$external,o.$in={},delete e.name,delete e.version,delete e.$dependencies,delete e.$external,delete e.$plugins,delete e.setup,delete e.create,o=yield o.setup(o,e),s(o=yield o.create(o,e)),Object.seal(o),o})),v.apply(this,arguments)}function b(e){var n=e.name,t=e.version,r=e.createWidget;h().$in.widgetFactory[n+t]=r}function g(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=h(),t=e.name,r=e.version,o=n.$in.widgetFactory[t+r];if(!d(o))throw new Error('The widget with defined name and version "'.concat(t+r,'" is not defined.'));return o(e)}function h(){var e=w();return e.__merkur__||(e.__merkur__={$in:{widgets:[],widgetFactory:{}},$external:{},$dependencies:{},isRegistered:m,register:b,create:g}),e.__merkur__}function m(e){var n=h();return Boolean(Object.keys(n.$in.widgetFactory).find((function(n){return new RegExp("^".concat(e)).test(n)})))}function w(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}}Object.defineProperty(e,"__esModule",{value:!0}),e.assignMissingKeys=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];return t.forEach((function(n){Object.keys(n||{}).forEach((function(t){t in e||(e[t]=n[t])}))})),e},e.bindWidgetToFunctions=s,e.createMerkur=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.$plugins,t=void 0===n?[]:n,r=h();return t.forEach((function(e){e&&d(e.setup)&&e.setup(r)})),r},e.createMerkurWidget=function(){return v.apply(this,arguments)},e.getMerkur=h,e.hookMethod=function(e,n,t){var r=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=n.split("."),r=t.pop(),o=t.reduce((function(e,n){return e[n]||{}}),e);if(!d(o[r]))throw new Error("Defined path '".concat(n,"' is incorrect. Check your widget structure."));return{target:o,methodName:r}}(e,n),o=r.target,i=r.methodName,u=f(e,o[i]);return o[i]=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.apply(void 0,[e,u].concat(r))},u},e.isFunction=d,e.removeMerkur=function(){delete w().__merkur__},e.setDefaultValueForUndefined=l}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Merkur is tiny and extensible library for creating front-end microservices.",
|
|
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": {
|
|
@@ -51,8 +51,5 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://merkur.js.org/",
|
|
54
|
-
"
|
|
55
|
-
"rollup": "^2.70.2"
|
|
56
|
-
},
|
|
57
|
-
"gitHead": "ef1b38f23e43e2fd7ef6a2bec680fb40a2de3715"
|
|
54
|
+
"gitHead": "3e88b57abfad267ac3f3b20b2ae6bf50f93f5375"
|
|
58
55
|
}
|
|
@@ -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)}function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */r=function(){return t};var t={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(e){l=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var o=r&&r.prototype instanceof h?r:h,a=Object.create(o.prototype),u=new k(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}}}t.wrap=f;var d={};function h(){}function y(){}function v(){}var m={};l(m,u,(function(){return this}));var g=Object.getPrototypeOf,j=g&&g(g(L([])));j&&j!==n&&o.call(j,u)&&(m=j);var b=v.prototype=h.prototype=Object.create(m);function w(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function x(r,t){function n(i,a,u,c){var s=p(r[i],r,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==e(f)&&o.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,u,c)}),(function(e){n("throw",e,u,c)})):t.resolve(f).then((function(e){l.value=e,u(l)}),(function(e){return n("throw",e,u,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return a=a?a.then(o,o):o()}})}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 S()}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 c=p(e,r,t);if("normal"===c.type){if(n=t.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:t.done}}"throw"===c.type&&(n="completed",t.method="throw",t.arg=c.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 _(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 E(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function L(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,n=function r(){for(;++t<e.length;)if(o.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:S}}function S(){return{value:void 0,done:!0}}return y.prototype=v,i(b,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:y,configurable:!0}),y.displayName=l(v,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===y||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,l(e,s,"GeneratorFunction")),e.prototype=Object.create(b),e},t.awrap=function(e){return{__await:e}},w(x.prototype),l(x.prototype,c,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},w(b),l(b,s,"Generator"),l(b,u,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),t.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}},t.values=L,k.prototype={constructor:k,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(E),!e)for(var r in this)"t"===r.charAt(0)&&o.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 n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var u=o.call(i,"catchLoc"),c=o.call(i,"finallyLoc");if(u&&c){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(!c)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 n=this.tryEntries[t];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;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),E(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;E(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:L(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),d}},t}function t(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(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){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=o(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 a,u=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return u=e.done,e},e:function(e){c=!0,a=e},f:function(){try{u||null==t.return||t.return()}finally{if(c)throw a}}}}function o(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}function i(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 a(e,r,t,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function u(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var i=e.apply(r,t);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function c(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 s(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach((function(r){l(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function l(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function f(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return r.apply(void 0,[e].concat(n))}}function p(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=s({},e);return r.forEach((function(e){n[e]=n[e]||t})),n}function d(e,r){r=r||e,Object.keys(r).forEach((function(t){if(h(r[t])){var n=r[t];r[t]=f(e,n)}}))}function h(e){return"function"==typeof e}function y(e,r,t){return v.apply(this,arguments)}function v(){return(v=u(r().mark((function e(o,i,a){var u,c,s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=n(o.$plugins),e.prev=1,u.s();case 3:if((c=u.n()).done){e.next=11;break}if(!h((s=c.value)[i])){e.next=9;break}return e.next=8,s[i].apply(s,[o].concat(t(a)));case 8:o=e.sent;case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),u.e(e.t0);case 16:return e.prev=16,u.f(),e.finish(16);case 19:return e.abrupt("return",o);case 20:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))).apply(this,arguments)}function m(){return m=u(r().mark((function e(){var t,n,o,i,a,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=p(t=c.length>0&&void 0!==c[0]?c[0]:{},["$dependencies","$external"]),t=p(t,["setup","create"],(function(e){return e})),o=(n=t).setup,i=n.create,a={setup:function(e){var t=arguments;return u(r().mark((function n(){var i,a,u;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(i=t.length,a=new Array(i>1?i-1:0),u=1;u<i;u++)a[u-1]=t[u];return r.next=3,y(e,"setup",a);case 3:return e=r.sent,r.abrupt("return",o.apply(void 0,[e].concat(a)));case 5:case"end":return r.stop()}}),n)})))()},create:function(e){var t=arguments;return u(r().mark((function n(){var o,a,u;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(o=t.length,a=new Array(o>1?o-1:0),u=1;u<o;u++)a[u-1]=t[u];return r.next=3,y(e,"create",a);case 3:return e=r.sent,r.abrupt("return",i.apply(void 0,[e].concat(a)));case 5:case"end":return r.stop()}}),n)})))()},$plugins:(t.$plugins||[]).map((function(e){return e()}))},a.name=t.name,a.version=t.version,a.$dependencies=t.$dependencies,a.$external=t.$external,a.$in={},delete t.name,delete t.version,delete t.$dependencies,delete t.$external,delete t.$plugins,delete t.setup,delete t.create,e.next=19,a.setup(a,t);case 19:return a=e.sent,e.next=22,a.create(a,t);case 22:return d(a=e.sent),Object.seal(a),e.abrupt("return",a);case 26:case"end":return e.stop()}}),e)}))),m.apply(this,arguments)}function g(e){var r=e.name,t=e.version,n=e.createWidget;b().$in.widgetFactory[r+t]=n}function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=b(),t=e.name,n=e.version,o=r.$in.widgetFactory[t+n];if(!h(o))throw new Error('The widget with defined name and version "'.concat(t+n,'" is not defined.'));return o(e)}function b(){var e=x();return e.__merkur__||(e.__merkur__={$in:{widgets:[],widgetFactory:{}},$external:{},$dependencies:{},isRegistered:w,register:g,create:j}),e.__merkur__}function w(e){var r=b();return Boolean(Object.keys(r.$in.widgetFactory).find((function(r){return new RegExp("^".concat(e)).test(r)})))}function x(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}}require("core-js/modules/es.object.define-property.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.array.for-each.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.array.reduce.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/esnext.global-this.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.object.seal.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.object.get-own-property-descriptors.js"),require("core-js/modules/es.object.define-properties.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.string.iterator.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/web.dom-collections.iterator.js"),require("core-js/modules/es.array.is-array.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"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.bindWidgetToFunctions=d,exports.createMerkur=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.$plugins,t=void 0===r?[]:r,n=b();return t.forEach((function(e){e&&h(e.setup)&&e.setup(n)})),n},exports.createMerkurWidget=function(){return m.apply(this,arguments)},exports.getMerkur=b,exports.hookMethod=function(e,r,t){var n=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=r.split("."),n=t.pop(),o=t.reduce((function(e,r){return e[r]||{}}),e);if(!h(o[n]))throw new Error("Defined path '".concat(r,"' is incorrect. Check your widget structure."));return{target:o,methodName:n}}(e,r),o=n.target,i=n.methodName,a=f(e,o[i]);return o[i]=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return t.apply(void 0,[e,a].concat(n))},a},exports.isFunction=h,exports.removeMerkur=function(){delete x().__merkur__},exports.setDefaultValueForUndefined=p;
|