@merkur/plugin-component 0.34.0 → 0.35.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/lib/helpers.cjs +50 -0
- package/lib/helpers.d.ts +20 -0
- package/lib/helpers.es9.cjs +52 -0
- package/lib/helpers.es9.js +52 -0
- package/lib/helpers.es9.mjs +50 -0
- package/lib/helpers.js +50 -0
- package/lib/helpers.mjs +48 -0
- package/lib/index.cjs +42 -0
- package/lib/index.es9.cjs +40 -2
- package/lib/index.es9.mjs +39 -3
- package/lib/index.js +42 -0
- package/lib/index.mjs +41 -1
- package/lib/index.umd.js +1 -1
- package/package.json +18 -5
- package/rollup.config.mjs +13 -1
- package/tsconfig.json +19 -0
- package/types.d.ts +108 -0
package/lib/helpers.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to iterate thorugh views returned from
|
|
5
|
+
* view factory and call callback function with view arguments
|
|
6
|
+
* on each them.
|
|
7
|
+
*/
|
|
8
|
+
async function mapViews(widget, viewFactory, callback) {
|
|
9
|
+
if (widget.$in.component.resolvedViews.has(viewFactory)) {
|
|
10
|
+
return mapResolvedViews(widget.$in.component.resolvedViews.get(viewFactory) ?? [], callback);
|
|
11
|
+
}
|
|
12
|
+
const { containerSelector } = widget;
|
|
13
|
+
const { View, ErrorView, slot = {} } = await viewFactory(widget);
|
|
14
|
+
// Add additional slot information to slot views
|
|
15
|
+
const slots = Object.keys(widget.slot ?? {}).reduce((acc, cur) => {
|
|
16
|
+
acc[cur] = {
|
|
17
|
+
...slot[cur],
|
|
18
|
+
isSlot: true,
|
|
19
|
+
containerSelector: widget.slot[cur]?.containerSelector,
|
|
20
|
+
container: widget.slot[cur]?.container,
|
|
21
|
+
};
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
const views = [
|
|
25
|
+
{
|
|
26
|
+
View,
|
|
27
|
+
ErrorView,
|
|
28
|
+
containerSelector,
|
|
29
|
+
isSlot: false,
|
|
30
|
+
container: widget.container,
|
|
31
|
+
},
|
|
32
|
+
...Object.values(slots),
|
|
33
|
+
];
|
|
34
|
+
widget.$in.component.resolvedViews.set(viewFactory, views);
|
|
35
|
+
return mapResolvedViews(views, callback);
|
|
36
|
+
}
|
|
37
|
+
function mapResolvedViews(views, callback) {
|
|
38
|
+
return views.map(({ View, containerSelector, isSlot, container }) => {
|
|
39
|
+
callback({
|
|
40
|
+
View,
|
|
41
|
+
isSlot,
|
|
42
|
+
containerSelector,
|
|
43
|
+
container: (containerSelector && document?.querySelector(containerSelector)) ||
|
|
44
|
+
container ||
|
|
45
|
+
null,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.mapViews = mapViews;
|
package/lib/helpers.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Widget } from '@merkur/core';
|
|
2
|
+
import { ViewFactory, ViewFactorySlotType, ViewType } from '@merkur/plugin-component';
|
|
3
|
+
export type MapViewArgs = {
|
|
4
|
+
View: ViewType;
|
|
5
|
+
ErrorView?: ViewType;
|
|
6
|
+
containerSelector: string;
|
|
7
|
+
container: Element | null;
|
|
8
|
+
isSlot: boolean;
|
|
9
|
+
slot?: Record<string, {
|
|
10
|
+
isSlot: boolean;
|
|
11
|
+
containerSelector?: string;
|
|
12
|
+
container?: Element;
|
|
13
|
+
} & ViewFactorySlotType>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Utility function to iterate thorugh views returned from
|
|
17
|
+
* view factory and call callback function with view arguments
|
|
18
|
+
* on each them.
|
|
19
|
+
*/
|
|
20
|
+
export declare function mapViews<T>(widget: Widget, viewFactory: ViewFactory, callback: (viewArgs: MapViewArgs) => T): Promise<void[]>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to iterate thorugh views returned from
|
|
5
|
+
* view factory and call callback function with view arguments
|
|
6
|
+
* on each them.
|
|
7
|
+
*/
|
|
8
|
+
async function mapViews(widget, viewFactory, callback) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (widget.$in.component.resolvedViews.has(viewFactory)) {
|
|
11
|
+
return mapResolvedViews((_a = widget.$in.component.resolvedViews.get(viewFactory)) !== null && _a !== void 0 ? _a : [], callback);
|
|
12
|
+
}
|
|
13
|
+
const { containerSelector } = widget;
|
|
14
|
+
const { View, ErrorView, slot = {} } = await viewFactory(widget);
|
|
15
|
+
// Add additional slot information to slot views
|
|
16
|
+
const slots = Object.keys((_b = widget.slot) !== null && _b !== void 0 ? _b : {}).reduce((acc, cur) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
acc[cur] = {
|
|
19
|
+
...slot[cur],
|
|
20
|
+
isSlot: true,
|
|
21
|
+
containerSelector: (_a = widget.slot[cur]) === null || _a === void 0 ? void 0 : _a.containerSelector,
|
|
22
|
+
container: (_b = widget.slot[cur]) === null || _b === void 0 ? void 0 : _b.container,
|
|
23
|
+
};
|
|
24
|
+
return acc;
|
|
25
|
+
}, {});
|
|
26
|
+
const views = [
|
|
27
|
+
{
|
|
28
|
+
View,
|
|
29
|
+
ErrorView,
|
|
30
|
+
containerSelector,
|
|
31
|
+
isSlot: false,
|
|
32
|
+
container: widget.container,
|
|
33
|
+
},
|
|
34
|
+
...Object.values(slots),
|
|
35
|
+
];
|
|
36
|
+
widget.$in.component.resolvedViews.set(viewFactory, views);
|
|
37
|
+
return mapResolvedViews(views, callback);
|
|
38
|
+
}
|
|
39
|
+
function mapResolvedViews(views, callback) {
|
|
40
|
+
return views.map(({ View, containerSelector, isSlot, container }) => {
|
|
41
|
+
callback({
|
|
42
|
+
View,
|
|
43
|
+
isSlot,
|
|
44
|
+
containerSelector,
|
|
45
|
+
container: (containerSelector && (document === null || document === void 0 ? void 0 : document.querySelector(containerSelector))) ||
|
|
46
|
+
container ||
|
|
47
|
+
null,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.mapViews = mapViews;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to iterate thorugh views returned from
|
|
5
|
+
* view factory and call callback function with view arguments
|
|
6
|
+
* on each them.
|
|
7
|
+
*/
|
|
8
|
+
async function mapViews(widget, viewFactory, callback) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (widget.$in.component.resolvedViews.has(viewFactory)) {
|
|
11
|
+
return mapResolvedViews((_a = widget.$in.component.resolvedViews.get(viewFactory)) !== null && _a !== void 0 ? _a : [], callback);
|
|
12
|
+
}
|
|
13
|
+
const { containerSelector } = widget;
|
|
14
|
+
const { View, ErrorView, slot = {} } = await viewFactory(widget);
|
|
15
|
+
// Add additional slot information to slot views
|
|
16
|
+
const slots = Object.keys((_b = widget.slot) !== null && _b !== void 0 ? _b : {}).reduce((acc, cur) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
acc[cur] = {
|
|
19
|
+
...slot[cur],
|
|
20
|
+
isSlot: true,
|
|
21
|
+
containerSelector: (_a = widget.slot[cur]) === null || _a === void 0 ? void 0 : _a.containerSelector,
|
|
22
|
+
container: (_b = widget.slot[cur]) === null || _b === void 0 ? void 0 : _b.container,
|
|
23
|
+
};
|
|
24
|
+
return acc;
|
|
25
|
+
}, {});
|
|
26
|
+
const views = [
|
|
27
|
+
{
|
|
28
|
+
View,
|
|
29
|
+
ErrorView,
|
|
30
|
+
containerSelector,
|
|
31
|
+
isSlot: false,
|
|
32
|
+
container: widget.container,
|
|
33
|
+
},
|
|
34
|
+
...Object.values(slots),
|
|
35
|
+
];
|
|
36
|
+
widget.$in.component.resolvedViews.set(viewFactory, views);
|
|
37
|
+
return mapResolvedViews(views, callback);
|
|
38
|
+
}
|
|
39
|
+
function mapResolvedViews(views, callback) {
|
|
40
|
+
return views.map(({ View, containerSelector, isSlot, container }) => {
|
|
41
|
+
callback({
|
|
42
|
+
View,
|
|
43
|
+
isSlot,
|
|
44
|
+
containerSelector,
|
|
45
|
+
container: (containerSelector && (document === null || document === void 0 ? void 0 : document.querySelector(containerSelector))) ||
|
|
46
|
+
container ||
|
|
47
|
+
null,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.mapViews = mapViews;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to iterate thorugh views returned from
|
|
3
|
+
* view factory and call callback function with view arguments
|
|
4
|
+
* on each them.
|
|
5
|
+
*/
|
|
6
|
+
async function mapViews(widget, viewFactory, callback) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
if (widget.$in.component.resolvedViews.has(viewFactory)) {
|
|
9
|
+
return mapResolvedViews((_a = widget.$in.component.resolvedViews.get(viewFactory)) !== null && _a !== void 0 ? _a : [], callback);
|
|
10
|
+
}
|
|
11
|
+
const { containerSelector } = widget;
|
|
12
|
+
const { View, ErrorView, slot = {} } = await viewFactory(widget);
|
|
13
|
+
// Add additional slot information to slot views
|
|
14
|
+
const slots = Object.keys((_b = widget.slot) !== null && _b !== void 0 ? _b : {}).reduce((acc, cur) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
acc[cur] = {
|
|
17
|
+
...slot[cur],
|
|
18
|
+
isSlot: true,
|
|
19
|
+
containerSelector: (_a = widget.slot[cur]) === null || _a === void 0 ? void 0 : _a.containerSelector,
|
|
20
|
+
container: (_b = widget.slot[cur]) === null || _b === void 0 ? void 0 : _b.container,
|
|
21
|
+
};
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
const views = [
|
|
25
|
+
{
|
|
26
|
+
View,
|
|
27
|
+
ErrorView,
|
|
28
|
+
containerSelector,
|
|
29
|
+
isSlot: false,
|
|
30
|
+
container: widget.container,
|
|
31
|
+
},
|
|
32
|
+
...Object.values(slots),
|
|
33
|
+
];
|
|
34
|
+
widget.$in.component.resolvedViews.set(viewFactory, views);
|
|
35
|
+
return mapResolvedViews(views, callback);
|
|
36
|
+
}
|
|
37
|
+
function mapResolvedViews(views, callback) {
|
|
38
|
+
return views.map(({ View, containerSelector, isSlot, container }) => {
|
|
39
|
+
callback({
|
|
40
|
+
View,
|
|
41
|
+
isSlot,
|
|
42
|
+
containerSelector,
|
|
43
|
+
container: (containerSelector && (document === null || document === void 0 ? void 0 : document.querySelector(containerSelector))) ||
|
|
44
|
+
container ||
|
|
45
|
+
null,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { mapViews };
|
package/lib/helpers.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to iterate thorugh views returned from
|
|
5
|
+
* view factory and call callback function with view arguments
|
|
6
|
+
* on each them.
|
|
7
|
+
*/
|
|
8
|
+
async function mapViews(widget, viewFactory, callback) {
|
|
9
|
+
if (widget.$in.component.resolvedViews.has(viewFactory)) {
|
|
10
|
+
return mapResolvedViews(widget.$in.component.resolvedViews.get(viewFactory) ?? [], callback);
|
|
11
|
+
}
|
|
12
|
+
const { containerSelector } = widget;
|
|
13
|
+
const { View, ErrorView, slot = {} } = await viewFactory(widget);
|
|
14
|
+
// Add additional slot information to slot views
|
|
15
|
+
const slots = Object.keys(widget.slot ?? {}).reduce((acc, cur) => {
|
|
16
|
+
acc[cur] = {
|
|
17
|
+
...slot[cur],
|
|
18
|
+
isSlot: true,
|
|
19
|
+
containerSelector: widget.slot[cur]?.containerSelector,
|
|
20
|
+
container: widget.slot[cur]?.container,
|
|
21
|
+
};
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
const views = [
|
|
25
|
+
{
|
|
26
|
+
View,
|
|
27
|
+
ErrorView,
|
|
28
|
+
containerSelector,
|
|
29
|
+
isSlot: false,
|
|
30
|
+
container: widget.container,
|
|
31
|
+
},
|
|
32
|
+
...Object.values(slots),
|
|
33
|
+
];
|
|
34
|
+
widget.$in.component.resolvedViews.set(viewFactory, views);
|
|
35
|
+
return mapResolvedViews(views, callback);
|
|
36
|
+
}
|
|
37
|
+
function mapResolvedViews(views, callback) {
|
|
38
|
+
return views.map(({ View, containerSelector, isSlot, container }) => {
|
|
39
|
+
callback({
|
|
40
|
+
View,
|
|
41
|
+
isSlot,
|
|
42
|
+
containerSelector,
|
|
43
|
+
container: (containerSelector && document?.querySelector(containerSelector)) ||
|
|
44
|
+
container ||
|
|
45
|
+
null,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.mapViews = mapViews;
|
package/lib/helpers.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to iterate thorugh views returned from
|
|
3
|
+
* view factory and call callback function with view arguments
|
|
4
|
+
* on each them.
|
|
5
|
+
*/
|
|
6
|
+
async function mapViews(widget, viewFactory, callback) {
|
|
7
|
+
if (widget.$in.component.resolvedViews.has(viewFactory)) {
|
|
8
|
+
return mapResolvedViews(widget.$in.component.resolvedViews.get(viewFactory) ?? [], callback);
|
|
9
|
+
}
|
|
10
|
+
const { containerSelector } = widget;
|
|
11
|
+
const { View, ErrorView, slot = {} } = await viewFactory(widget);
|
|
12
|
+
// Add additional slot information to slot views
|
|
13
|
+
const slots = Object.keys(widget.slot ?? {}).reduce((acc, cur) => {
|
|
14
|
+
acc[cur] = {
|
|
15
|
+
...slot[cur],
|
|
16
|
+
isSlot: true,
|
|
17
|
+
containerSelector: widget.slot[cur]?.containerSelector,
|
|
18
|
+
container: widget.slot[cur]?.container,
|
|
19
|
+
};
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
const views = [
|
|
23
|
+
{
|
|
24
|
+
View,
|
|
25
|
+
ErrorView,
|
|
26
|
+
containerSelector,
|
|
27
|
+
isSlot: false,
|
|
28
|
+
container: widget.container,
|
|
29
|
+
},
|
|
30
|
+
...Object.values(slots),
|
|
31
|
+
];
|
|
32
|
+
widget.$in.component.resolvedViews.set(viewFactory, views);
|
|
33
|
+
return mapResolvedViews(views, callback);
|
|
34
|
+
}
|
|
35
|
+
function mapResolvedViews(views, callback) {
|
|
36
|
+
return views.map(({ View, containerSelector, isSlot, container }) => {
|
|
37
|
+
callback({
|
|
38
|
+
View,
|
|
39
|
+
isSlot,
|
|
40
|
+
containerSelector,
|
|
41
|
+
container: (containerSelector && document?.querySelector(containerSelector)) ||
|
|
42
|
+
container ||
|
|
43
|
+
null,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { mapViews };
|
package/lib/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ function componentPlugin() {
|
|
|
29
29
|
isMounted: false,
|
|
30
30
|
isHydrated: false,
|
|
31
31
|
suspendedTasks: [],
|
|
32
|
+
resolvedViews: new Map(),
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
core.assignMissingKeys(widget, componentAPI(), widgetProperties);
|
|
@@ -147,4 +148,45 @@ function componentAPI() {
|
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Typed helper to make it easier to define widget properties.
|
|
153
|
+
*
|
|
154
|
+
* @type import('@merkur/plugin-component').createSlotFactory
|
|
155
|
+
*/
|
|
156
|
+
function createSlotFactory(creator) {
|
|
157
|
+
return async (widget) => creator(widget);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Typed helper to make it easier to define widget properties.
|
|
162
|
+
*
|
|
163
|
+
* @type import('@merkur/plugin-component').createViewFactory
|
|
164
|
+
*/
|
|
165
|
+
function createViewFactory(creator) {
|
|
166
|
+
return async (widget) => {
|
|
167
|
+
const { slotFactories, ...restParams } = await creator(widget);
|
|
168
|
+
|
|
169
|
+
if (!slotFactories) {
|
|
170
|
+
return {
|
|
171
|
+
...restParams,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const slot = (
|
|
176
|
+
await Promise.all(slotFactories.map((creator) => creator(widget)))
|
|
177
|
+
).reduce((acc, cur) => {
|
|
178
|
+
acc[cur.name] = cur;
|
|
179
|
+
|
|
180
|
+
return acc;
|
|
181
|
+
}, {});
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
...restParams,
|
|
185
|
+
slot,
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
150
190
|
exports.componentPlugin = componentPlugin;
|
|
191
|
+
exports.createSlotFactory = createSlotFactory;
|
|
192
|
+
exports.createViewFactory = createViewFactory;
|
package/lib/index.es9.cjs
CHANGED
|
@@ -25,7 +25,8 @@ function componentPlugin() {
|
|
|
25
25
|
lifeCycle,
|
|
26
26
|
isMounted: false,
|
|
27
27
|
isHydrated: false,
|
|
28
|
-
suspendedTasks: []
|
|
28
|
+
suspendedTasks: [],
|
|
29
|
+
resolvedViews: new Map()
|
|
29
30
|
};
|
|
30
31
|
core.assignMissingKeys(widget, componentAPI(), widgetProperties);
|
|
31
32
|
widget = core.setDefaultValueForUndefined(widget, ['props', 'state']);
|
|
@@ -39,7 +40,6 @@ function componentPlugin() {
|
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
|
|
43
43
|
async function callLifeCycleMethod(widget, methodName, args) {
|
|
44
44
|
const {
|
|
45
45
|
lifeCycle
|
|
@@ -127,4 +127,42 @@ function componentAPI() {
|
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Typed helper to make it easier to define widget properties.
|
|
133
|
+
*
|
|
134
|
+
* @type import('@merkur/plugin-component').createSlotFactory
|
|
135
|
+
*/
|
|
136
|
+
function createSlotFactory(creator) {
|
|
137
|
+
return async widget => creator(widget);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Typed helper to make it easier to define widget properties.
|
|
142
|
+
*
|
|
143
|
+
* @type import('@merkur/plugin-component').createViewFactory
|
|
144
|
+
*/
|
|
145
|
+
function createViewFactory(creator) {
|
|
146
|
+
return async widget => {
|
|
147
|
+
const {
|
|
148
|
+
slotFactories,
|
|
149
|
+
...restParams
|
|
150
|
+
} = await creator(widget);
|
|
151
|
+
if (!slotFactories) {
|
|
152
|
+
return {
|
|
153
|
+
...restParams
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const slot = (await Promise.all(slotFactories.map(creator => creator(widget)))).reduce((acc, cur) => {
|
|
157
|
+
acc[cur.name] = cur;
|
|
158
|
+
return acc;
|
|
159
|
+
}, {});
|
|
160
|
+
return {
|
|
161
|
+
...restParams,
|
|
162
|
+
slot
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
}
|
|
130
166
|
exports.componentPlugin = componentPlugin;
|
|
167
|
+
exports.createSlotFactory = createSlotFactory;
|
|
168
|
+
exports.createViewFactory = createViewFactory;
|
package/lib/index.es9.mjs
CHANGED
|
@@ -23,7 +23,8 @@ function componentPlugin() {
|
|
|
23
23
|
lifeCycle,
|
|
24
24
|
isMounted: false,
|
|
25
25
|
isHydrated: false,
|
|
26
|
-
suspendedTasks: []
|
|
26
|
+
suspendedTasks: [],
|
|
27
|
+
resolvedViews: new Map()
|
|
27
28
|
};
|
|
28
29
|
assignMissingKeys(widget, componentAPI(), widgetProperties);
|
|
29
30
|
widget = setDefaultValueForUndefined(widget, ['props', 'state']);
|
|
@@ -37,7 +38,6 @@ function componentPlugin() {
|
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
|
|
41
41
|
async function callLifeCycleMethod(widget, methodName, args) {
|
|
42
42
|
const {
|
|
43
43
|
lifeCycle
|
|
@@ -125,4 +125,40 @@ function componentAPI() {
|
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Typed helper to make it easier to define widget properties.
|
|
131
|
+
*
|
|
132
|
+
* @type import('@merkur/plugin-component').createSlotFactory
|
|
133
|
+
*/
|
|
134
|
+
function createSlotFactory(creator) {
|
|
135
|
+
return async widget => creator(widget);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Typed helper to make it easier to define widget properties.
|
|
140
|
+
*
|
|
141
|
+
* @type import('@merkur/plugin-component').createViewFactory
|
|
142
|
+
*/
|
|
143
|
+
function createViewFactory(creator) {
|
|
144
|
+
return async widget => {
|
|
145
|
+
const {
|
|
146
|
+
slotFactories,
|
|
147
|
+
...restParams
|
|
148
|
+
} = await creator(widget);
|
|
149
|
+
if (!slotFactories) {
|
|
150
|
+
return {
|
|
151
|
+
...restParams
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const slot = (await Promise.all(slotFactories.map(creator => creator(widget)))).reduce((acc, cur) => {
|
|
155
|
+
acc[cur.name] = cur;
|
|
156
|
+
return acc;
|
|
157
|
+
}, {});
|
|
158
|
+
return {
|
|
159
|
+
...restParams,
|
|
160
|
+
slot
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export { componentPlugin, createSlotFactory, createViewFactory };
|
package/lib/index.js
CHANGED
|
@@ -29,6 +29,7 @@ function componentPlugin() {
|
|
|
29
29
|
isMounted: false,
|
|
30
30
|
isHydrated: false,
|
|
31
31
|
suspendedTasks: [],
|
|
32
|
+
resolvedViews: new Map(),
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
core.assignMissingKeys(widget, componentAPI(), widgetProperties);
|
|
@@ -147,4 +148,45 @@ function componentAPI() {
|
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Typed helper to make it easier to define widget properties.
|
|
153
|
+
*
|
|
154
|
+
* @type import('@merkur/plugin-component').createSlotFactory
|
|
155
|
+
*/
|
|
156
|
+
function createSlotFactory(creator) {
|
|
157
|
+
return async (widget) => creator(widget);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Typed helper to make it easier to define widget properties.
|
|
162
|
+
*
|
|
163
|
+
* @type import('@merkur/plugin-component').createViewFactory
|
|
164
|
+
*/
|
|
165
|
+
function createViewFactory(creator) {
|
|
166
|
+
return async (widget) => {
|
|
167
|
+
const { slotFactories, ...restParams } = await creator(widget);
|
|
168
|
+
|
|
169
|
+
if (!slotFactories) {
|
|
170
|
+
return {
|
|
171
|
+
...restParams,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const slot = (
|
|
176
|
+
await Promise.all(slotFactories.map((creator) => creator(widget)))
|
|
177
|
+
).reduce((acc, cur) => {
|
|
178
|
+
acc[cur.name] = cur;
|
|
179
|
+
|
|
180
|
+
return acc;
|
|
181
|
+
}, {});
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
...restParams,
|
|
185
|
+
slot,
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
150
190
|
exports.componentPlugin = componentPlugin;
|
|
191
|
+
exports.createSlotFactory = createSlotFactory;
|
|
192
|
+
exports.createViewFactory = createViewFactory;
|
package/lib/index.mjs
CHANGED
|
@@ -27,6 +27,7 @@ function componentPlugin() {
|
|
|
27
27
|
isMounted: false,
|
|
28
28
|
isHydrated: false,
|
|
29
29
|
suspendedTasks: [],
|
|
30
|
+
resolvedViews: new Map(),
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
assignMissingKeys(widget, componentAPI(), widgetProperties);
|
|
@@ -145,4 +146,43 @@ function componentAPI() {
|
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Typed helper to make it easier to define widget properties.
|
|
151
|
+
*
|
|
152
|
+
* @type import('@merkur/plugin-component').createSlotFactory
|
|
153
|
+
*/
|
|
154
|
+
function createSlotFactory(creator) {
|
|
155
|
+
return async (widget) => creator(widget);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Typed helper to make it easier to define widget properties.
|
|
160
|
+
*
|
|
161
|
+
* @type import('@merkur/plugin-component').createViewFactory
|
|
162
|
+
*/
|
|
163
|
+
function createViewFactory(creator) {
|
|
164
|
+
return async (widget) => {
|
|
165
|
+
const { slotFactories, ...restParams } = await creator(widget);
|
|
166
|
+
|
|
167
|
+
if (!slotFactories) {
|
|
168
|
+
return {
|
|
169
|
+
...restParams,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const slot = (
|
|
174
|
+
await Promise.all(slotFactories.map((creator) => creator(widget)))
|
|
175
|
+
).reduce((acc, cur) => {
|
|
176
|
+
acc[cur.name] = cur;
|
|
177
|
+
|
|
178
|
+
return acc;
|
|
179
|
+
}, {});
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
...restParams,
|
|
183
|
+
slot,
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { componentPlugin, createSlotFactory, createViewFactory };
|
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
|
|
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,u=t.bootstrap,a=t.load,f=t.mount,s=t.unmount,p=t.update,m=l(t,r),b={info:o,bootstrap:u,load:a,mount:f,unmount:s,update:p};return n.$in.component={lifeCycle:b,isMounted:!1,isHydrated:!1,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,u=n.state,i=n.assets,a=n.containerSelector,f=t.length,s=new Array(f>1?f-1:0),l=1;l<f;l++)s[l-1]=t[l];return c({name:e,version:r,props:o,state:u,assets:i,containerSelector:a},(yield d(n,"info",s))||{})}))()},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 u=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=i(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 u,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,u=n},f:function(){try{a||null==e.return||e.return()}finally{if(f)throw u}}}}(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 u}))()},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,u=new Array(o>1?o-1:0),i=1;i<o;i++)u[i-1]=t[i];n.state=yield d(n,"load",u)}}))()},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*(){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,u=l(e,o);if(!r)return c({},u);var i=(yield Promise.all(r.map((function(n){return n(t)})))).reduce((function(n,t){return n[t.name]=t,n}),{});return c(c({},u),{},{slot:i})}));return function(n){return t.apply(this,arguments)}}()};var r=["info","bootstrap","load","mount","unmount","update"],o=["slotFactories"];function u(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)||i(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 i(n,t){if(n){if("string"==typeof n)return a(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)?a(n,t):void 0}}function a(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 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){s(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 s(t,e,r){var o;return o=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)}(e,"string"),(e="symbol"==n(o)?o:o+"")in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(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}function p(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 y(n){return function(){var t=this,e=arguments;return new Promise((function(r,o){var u=n.apply(t,e);function i(n){p(u,r,o,i,a,"next",n)}function a(n){p(u,r,o,i,a,"throw",n)}i(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(u(e)))}))).apply(this,arguments)}}));
|
package/package.json
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/plugin-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Merkur component plugin.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
7
|
+
"types": "./types.d.ts",
|
|
7
8
|
"unpkg": "lib/index.umd.js",
|
|
8
9
|
"sideEffects": false,
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
12
|
+
"types": "./types.d.ts",
|
|
11
13
|
"import": "./lib/index.mjs",
|
|
12
14
|
"require": "./lib/index.cjs"
|
|
13
15
|
},
|
|
16
|
+
"./helpers": {
|
|
17
|
+
"types": "./lib/helpers.d.ts",
|
|
18
|
+
"import": "./lib/helpers.mjs",
|
|
19
|
+
"require": "./lib/helpers.cjs"
|
|
20
|
+
},
|
|
14
21
|
"./lib/index.es9.mjs": "./lib/index.es9.mjs",
|
|
15
|
-
"./lib/index.es9.cjs": "./lib/index.es9.cjs"
|
|
22
|
+
"./lib/index.es9.cjs": "./lib/index.es9.cjs",
|
|
23
|
+
"./lib/helpers.es9.mjs": "./lib/helpers.es9.mjs",
|
|
24
|
+
"./lib/helpers.es9.cjs": "./lib/helpers.es9.cjs"
|
|
16
25
|
},
|
|
17
26
|
"browser": {
|
|
18
27
|
"./lib/index.js": "./lib/index.js",
|
|
19
28
|
"./lib/index.cjs": "./lib/index.cjs",
|
|
20
29
|
"./lib/index.mjs": "./lib/index.mjs",
|
|
21
|
-
"./lib/index.es9.mjs": "./lib/index.es9.mjs"
|
|
30
|
+
"./lib/index.es9.mjs": "./lib/index.es9.mjs",
|
|
31
|
+
"./lib/helpers.js": "./lib/helpers.js",
|
|
32
|
+
"./lib/helpers.cjs": "./lib/helpers.cjs",
|
|
33
|
+
"./lib/helpers.mjs": "./lib/helpers.mjs",
|
|
34
|
+
"./lib/helpers.es9.mjs": "./lib/helpers.es9.mjs"
|
|
22
35
|
},
|
|
23
36
|
"scripts": {
|
|
24
37
|
"preversion": "npm test",
|
|
@@ -48,10 +61,10 @@
|
|
|
48
61
|
},
|
|
49
62
|
"homepage": "https://merkur.js.org/",
|
|
50
63
|
"devDependencies": {
|
|
51
|
-
"@merkur/core": "^0.
|
|
64
|
+
"@merkur/core": "^0.35.0"
|
|
52
65
|
},
|
|
53
66
|
"peerDependencies": {
|
|
54
67
|
"@merkur/core": "*"
|
|
55
68
|
},
|
|
56
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "383f29bdf67a7f4252876867687371a8d26f53f2"
|
|
57
70
|
}
|
package/rollup.config.mjs
CHANGED
|
@@ -2,10 +2,22 @@ import {
|
|
|
2
2
|
createRollupESConfig,
|
|
3
3
|
createRollupES9Config,
|
|
4
4
|
createRollupUMDConfig,
|
|
5
|
+
createRollupTypescriptES9Config,
|
|
6
|
+
createRollupTypescriptConfig,
|
|
5
7
|
} from '../../createRollupConfig.mjs';
|
|
6
8
|
|
|
7
9
|
let esConfig = createRollupESConfig();
|
|
8
10
|
let es9Config = createRollupES9Config();
|
|
9
11
|
let umdConfig = createRollupUMDConfig();
|
|
10
12
|
|
|
11
|
-
export default [
|
|
13
|
+
export default [
|
|
14
|
+
esConfig,
|
|
15
|
+
es9Config,
|
|
16
|
+
umdConfig,
|
|
17
|
+
createRollupTypescriptConfig({
|
|
18
|
+
input: './src/helpers.ts',
|
|
19
|
+
}),
|
|
20
|
+
createRollupTypescriptES9Config({
|
|
21
|
+
input: './src/helpers.ts',
|
|
22
|
+
}),
|
|
23
|
+
];
|
package/tsconfig.json
ADDED
package/types.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Widget } from '@merkur/core';
|
|
2
|
+
|
|
3
|
+
export interface ViewType {
|
|
4
|
+
(widget: Widget): any;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type MapViewArgs = {
|
|
8
|
+
View: ViewType;
|
|
9
|
+
ErrorView?: ViewType;
|
|
10
|
+
containerSelector: string;
|
|
11
|
+
container: Element | null;
|
|
12
|
+
isSlot: boolean;
|
|
13
|
+
slot?: Record<
|
|
14
|
+
string,
|
|
15
|
+
{
|
|
16
|
+
isSlot: boolean;
|
|
17
|
+
containerSelector?: string;
|
|
18
|
+
container?: Element;
|
|
19
|
+
} & ViewFactorySlotType
|
|
20
|
+
>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type SSRMountResult = {
|
|
24
|
+
html: string;
|
|
25
|
+
slot: Record<string, { name: string; html: string }>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export interface WidgetState {}
|
|
29
|
+
export interface WidgetProps {}
|
|
30
|
+
|
|
31
|
+
declare module '@merkur/core' {
|
|
32
|
+
interface DefineWidgetArgs {
|
|
33
|
+
viewFactory: ViewFactory;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface Widget {
|
|
37
|
+
container?: Element;
|
|
38
|
+
shouldHydrate: (viewArgs: MapViewArgs) => boolean;
|
|
39
|
+
mount: () => Promise<void | SSRMountResult>;
|
|
40
|
+
update: () => Promise<void>;
|
|
41
|
+
unmount: () => Promise<void>;
|
|
42
|
+
slot: Record<
|
|
43
|
+
string,
|
|
44
|
+
| {
|
|
45
|
+
name: string;
|
|
46
|
+
html: string;
|
|
47
|
+
containerSelector: string;
|
|
48
|
+
container?: Element;
|
|
49
|
+
}
|
|
50
|
+
| undefined
|
|
51
|
+
>;
|
|
52
|
+
state: WidgetState;
|
|
53
|
+
props: WidgetProps;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface WidgetDefinition {
|
|
57
|
+
shouldHydrate: (widget: Widget, viewArgs: MapViewArgs) => boolean;
|
|
58
|
+
mount: (widget: Widget) => Promise<void | SSRMountResult>;
|
|
59
|
+
update: (widget: Widget) => Promise<void>;
|
|
60
|
+
unmount: (widget: Widget) => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
interface WidgetInternal {
|
|
63
|
+
component: {
|
|
64
|
+
lifeCycle: Record<string, function>;
|
|
65
|
+
isMounted: boolean;
|
|
66
|
+
isHydrated: boolean;
|
|
67
|
+
suspendedTasks: Array<function>;
|
|
68
|
+
resolvedViews: Map<ViewFactory, MapViewArgs[]>;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SlotDefinition {
|
|
74
|
+
name: string;
|
|
75
|
+
View: ViewType;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ViewDefinition {
|
|
79
|
+
View: ViewType;
|
|
80
|
+
ErrorView?: ViewType;
|
|
81
|
+
slotFactories: ((
|
|
82
|
+
widget: Widget,
|
|
83
|
+
) => SlotDefinition | Promise<SlotDefinition>)[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ViewFactoryResult {
|
|
87
|
+
View: ViewType;
|
|
88
|
+
ErrorView?: ViewType;
|
|
89
|
+
slot?: Record<string, ViewFactorySlotType>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ViewFactorySlotType {
|
|
93
|
+
name: string;
|
|
94
|
+
View: ViewType;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type ViewFactory = (widget: Widget) => Promise<ViewFactoryResult>;
|
|
98
|
+
export type SlotFactory = (widget: Widget) => Promise<SlotDefinition>;
|
|
99
|
+
|
|
100
|
+
export declare function createSlotFactory(
|
|
101
|
+
creator: (widget: Widget) => SlotDefinition | Promise<SlotDefinition>,
|
|
102
|
+
): SlotFactory;
|
|
103
|
+
|
|
104
|
+
export declare function createViewFactory(
|
|
105
|
+
creator: (widget: Widget) => ViewDefinition | Promise<ViewDefinition>,
|
|
106
|
+
): ViewFactory;
|
|
107
|
+
|
|
108
|
+
export declare function componentPlugin();
|