@retailcrm/embed-ui-v1-endpoint 0.9.11-alpha.1
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 +3 -0
- package/dist/common/extension.d.ts +11 -0
- package/dist/common/pages.d.ts +3 -0
- package/dist/common/targets.cjs +142 -0
- package/dist/common/targets.d.ts +34 -0
- package/dist/common/targets.js +142 -0
- package/dist/common/widgets.d.ts +7 -0
- package/dist/common.cjs +5 -0
- package/dist/common.d.ts +1 -0
- package/dist/common.js +5 -0
- package/dist/remote/endpoint.d.ts +14 -0
- package/dist/remote/pages.cjs +47 -0
- package/dist/remote/pages.d.ts +17 -0
- package/dist/remote/pages.js +47 -0
- package/dist/remote/widgets.cjs +47 -0
- package/dist/remote/widgets.d.ts +21 -0
- package/dist/remote/widgets.js +47 -0
- package/dist/remote/worker.d.ts +4 -0
- package/dist/remote.cjs +2900 -0
- package/dist/remote.d.ts +6 -0
- package/dist/remote.js +2900 -0
- package/package.json +106 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Channel } from '@omnicajs/vue-remote/remote';
|
|
2
|
+
import { ContextAccessor, ContextSchemaList, CustomContextAccessor } from '@retailcrm/embed-ui-v1-types/context';
|
|
3
|
+
import { HostApi } from '@retailcrm/embed-ui-v1-types/host';
|
|
4
|
+
import { RunIdentity as PageRunIdentity } from './pages';
|
|
5
|
+
import { RunConfig as WidgetRunConfig, RunIdentity as WidgetRunIdentity } from './widgets';
|
|
6
|
+
export interface RemoteApi {
|
|
7
|
+
run(channel: Channel, config: WidgetRunConfig | PageRunIdentity): Promise<void>;
|
|
8
|
+
release(config: WidgetRunIdentity | PageRunIdentity): void;
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
|
11
|
+
export type EndpointApi<M extends ContextSchemaList = ContextSchemaList> = ContextAccessor<M> & CustomContextAccessor & HostApi & RemoteApi;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const defineTarget = (id, contexts) => ({
|
|
4
|
+
id,
|
|
5
|
+
contexts
|
|
6
|
+
});
|
|
7
|
+
const targets = {
|
|
8
|
+
"customer/card:phone": defineTarget("customer/card:phone", [
|
|
9
|
+
"customer/card",
|
|
10
|
+
"customer/card:phone",
|
|
11
|
+
"user/current",
|
|
12
|
+
"settings"
|
|
13
|
+
]),
|
|
14
|
+
"customer/card:communications.after": defineTarget("customer/card:communications.after", [
|
|
15
|
+
"customer/card",
|
|
16
|
+
"user/current",
|
|
17
|
+
"settings"
|
|
18
|
+
]),
|
|
19
|
+
"customer/card:inWork.before": defineTarget("customer/card:inWork.before", [
|
|
20
|
+
"customer/card",
|
|
21
|
+
"user/current",
|
|
22
|
+
"settings"
|
|
23
|
+
]),
|
|
24
|
+
"customer/card:inWork.after": defineTarget("customer/card:inWork.after", [
|
|
25
|
+
"customer/card",
|
|
26
|
+
"user/current",
|
|
27
|
+
"settings"
|
|
28
|
+
]),
|
|
29
|
+
"order/card:common.before": defineTarget("order/card:common.before", [
|
|
30
|
+
"order/card",
|
|
31
|
+
"user/current",
|
|
32
|
+
"settings"
|
|
33
|
+
]),
|
|
34
|
+
"order/card:common.after": defineTarget("order/card:common.after", [
|
|
35
|
+
"order/card",
|
|
36
|
+
"user/current",
|
|
37
|
+
"settings"
|
|
38
|
+
]),
|
|
39
|
+
"order/card:customer.before": defineTarget("order/card:customer.before", [
|
|
40
|
+
"order/card",
|
|
41
|
+
"user/current",
|
|
42
|
+
"settings"
|
|
43
|
+
]),
|
|
44
|
+
"order/card:customer.after": defineTarget("order/card:customer.after", [
|
|
45
|
+
"order/card",
|
|
46
|
+
"user/current",
|
|
47
|
+
"settings"
|
|
48
|
+
]),
|
|
49
|
+
"order/card:customer.email": defineTarget("order/card:customer.email", [
|
|
50
|
+
"order/card",
|
|
51
|
+
"user/current",
|
|
52
|
+
"settings"
|
|
53
|
+
]),
|
|
54
|
+
"order/card:customer.phone": defineTarget("order/card:customer.phone", [
|
|
55
|
+
"order/card",
|
|
56
|
+
"user/current",
|
|
57
|
+
"settings"
|
|
58
|
+
]),
|
|
59
|
+
"order/card:list.before": defineTarget("order/card:list.before", [
|
|
60
|
+
"order/card",
|
|
61
|
+
"user/current",
|
|
62
|
+
"settings"
|
|
63
|
+
]),
|
|
64
|
+
"order/card:list.after": defineTarget("order/card:list.after", [
|
|
65
|
+
"order/card",
|
|
66
|
+
"user/current",
|
|
67
|
+
"settings"
|
|
68
|
+
]),
|
|
69
|
+
"order/card:store.before": defineTarget("order/card:store.before", [
|
|
70
|
+
"order/card",
|
|
71
|
+
"user/current",
|
|
72
|
+
"settings"
|
|
73
|
+
]),
|
|
74
|
+
"order/card:dimensions.before": defineTarget("order/card:dimensions.before", [
|
|
75
|
+
"order/card",
|
|
76
|
+
"user/current",
|
|
77
|
+
"settings"
|
|
78
|
+
]),
|
|
79
|
+
"order/card:delivery.before": defineTarget("order/card:delivery.before", [
|
|
80
|
+
"order/card",
|
|
81
|
+
"user/current",
|
|
82
|
+
"settings"
|
|
83
|
+
]),
|
|
84
|
+
"order/card:delivery.after": defineTarget("order/card:delivery.after", [
|
|
85
|
+
"order/card",
|
|
86
|
+
"user/current",
|
|
87
|
+
"settings"
|
|
88
|
+
]),
|
|
89
|
+
"order/card:delivery.address": defineTarget("order/card:delivery.address", [
|
|
90
|
+
"order/card",
|
|
91
|
+
"user/current",
|
|
92
|
+
"settings"
|
|
93
|
+
]),
|
|
94
|
+
"order/card:payment.before": defineTarget("order/card:payment.before", [
|
|
95
|
+
"order/card",
|
|
96
|
+
"user/current",
|
|
97
|
+
"settings"
|
|
98
|
+
]),
|
|
99
|
+
"order/card:comment.manager.before": defineTarget("order/card:comment.manager.before", [
|
|
100
|
+
"order/card",
|
|
101
|
+
"user/current",
|
|
102
|
+
"settings"
|
|
103
|
+
]),
|
|
104
|
+
"order/mg:list.before": defineTarget("order/mg:list.before", [
|
|
105
|
+
"order/card",
|
|
106
|
+
"order/card:settings",
|
|
107
|
+
"user/current",
|
|
108
|
+
"settings"
|
|
109
|
+
]),
|
|
110
|
+
"order/mg:list.after": defineTarget("order/mg:list.after", [
|
|
111
|
+
"order/card",
|
|
112
|
+
"order/card:settings",
|
|
113
|
+
"user/current",
|
|
114
|
+
"settings"
|
|
115
|
+
]),
|
|
116
|
+
"order/mg:delivery.before": defineTarget("order/mg:delivery.before", [
|
|
117
|
+
"order/card",
|
|
118
|
+
"order/card:settings",
|
|
119
|
+
"user/current",
|
|
120
|
+
"settings"
|
|
121
|
+
]),
|
|
122
|
+
"order/mg:delivery.after": defineTarget("order/mg:delivery.after", [
|
|
123
|
+
"order/card",
|
|
124
|
+
"order/card:settings",
|
|
125
|
+
"user/current",
|
|
126
|
+
"settings"
|
|
127
|
+
]),
|
|
128
|
+
"order/mg:payment.before": defineTarget("order/mg:payment.before", [
|
|
129
|
+
"order/card",
|
|
130
|
+
"order/card:settings",
|
|
131
|
+
"user/current",
|
|
132
|
+
"settings"
|
|
133
|
+
]),
|
|
134
|
+
"order/mg:payment.after": defineTarget("order/mg:payment.after", [
|
|
135
|
+
"order/card",
|
|
136
|
+
"order/card:settings",
|
|
137
|
+
"user/current",
|
|
138
|
+
"settings"
|
|
139
|
+
])
|
|
140
|
+
};
|
|
141
|
+
exports.defineTarget = defineTarget;
|
|
142
|
+
exports.targets = targets;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SchemaList } from '@retailcrm/embed-ui-v1-contexts/types';
|
|
2
|
+
export type TargetDefinition<TId extends string = string, TContexts extends readonly (keyof SchemaList)[] = readonly (keyof SchemaList)[]> = {
|
|
3
|
+
id: TId;
|
|
4
|
+
contexts: TContexts;
|
|
5
|
+
};
|
|
6
|
+
export declare const defineTarget: <const TId extends string, const TContexts extends readonly (keyof SchemaList)[]>(id: TId, contexts: TContexts) => TargetDefinition<TId, TContexts>;
|
|
7
|
+
export declare const targets: {
|
|
8
|
+
readonly 'customer/card:phone': TargetDefinition<"customer/card:phone", readonly ["customer/card", "customer/card:phone", "user/current", "settings"]>;
|
|
9
|
+
readonly 'customer/card:communications.after': TargetDefinition<"customer/card:communications.after", readonly ["customer/card", "user/current", "settings"]>;
|
|
10
|
+
readonly 'customer/card:inWork.before': TargetDefinition<"customer/card:inWork.before", readonly ["customer/card", "user/current", "settings"]>;
|
|
11
|
+
readonly 'customer/card:inWork.after': TargetDefinition<"customer/card:inWork.after", readonly ["customer/card", "user/current", "settings"]>;
|
|
12
|
+
readonly 'order/card:common.before': TargetDefinition<"order/card:common.before", readonly ["order/card", "user/current", "settings"]>;
|
|
13
|
+
readonly 'order/card:common.after': TargetDefinition<"order/card:common.after", readonly ["order/card", "user/current", "settings"]>;
|
|
14
|
+
readonly 'order/card:customer.before': TargetDefinition<"order/card:customer.before", readonly ["order/card", "user/current", "settings"]>;
|
|
15
|
+
readonly 'order/card:customer.after': TargetDefinition<"order/card:customer.after", readonly ["order/card", "user/current", "settings"]>;
|
|
16
|
+
readonly 'order/card:customer.email': TargetDefinition<"order/card:customer.email", readonly ["order/card", "user/current", "settings"]>;
|
|
17
|
+
readonly 'order/card:customer.phone': TargetDefinition<"order/card:customer.phone", readonly ["order/card", "user/current", "settings"]>;
|
|
18
|
+
readonly 'order/card:list.before': TargetDefinition<"order/card:list.before", readonly ["order/card", "user/current", "settings"]>;
|
|
19
|
+
readonly 'order/card:list.after': TargetDefinition<"order/card:list.after", readonly ["order/card", "user/current", "settings"]>;
|
|
20
|
+
readonly 'order/card:store.before': TargetDefinition<"order/card:store.before", readonly ["order/card", "user/current", "settings"]>;
|
|
21
|
+
readonly 'order/card:dimensions.before': TargetDefinition<"order/card:dimensions.before", readonly ["order/card", "user/current", "settings"]>;
|
|
22
|
+
readonly 'order/card:delivery.before': TargetDefinition<"order/card:delivery.before", readonly ["order/card", "user/current", "settings"]>;
|
|
23
|
+
readonly 'order/card:delivery.after': TargetDefinition<"order/card:delivery.after", readonly ["order/card", "user/current", "settings"]>;
|
|
24
|
+
readonly 'order/card:delivery.address': TargetDefinition<"order/card:delivery.address", readonly ["order/card", "user/current", "settings"]>;
|
|
25
|
+
readonly 'order/card:payment.before': TargetDefinition<"order/card:payment.before", readonly ["order/card", "user/current", "settings"]>;
|
|
26
|
+
readonly 'order/card:comment.manager.before': TargetDefinition<"order/card:comment.manager.before", readonly ["order/card", "user/current", "settings"]>;
|
|
27
|
+
readonly 'order/mg:list.before': TargetDefinition<"order/mg:list.before", readonly ["order/card", "order/card:settings", "user/current", "settings"]>;
|
|
28
|
+
readonly 'order/mg:list.after': TargetDefinition<"order/mg:list.after", readonly ["order/card", "order/card:settings", "user/current", "settings"]>;
|
|
29
|
+
readonly 'order/mg:delivery.before': TargetDefinition<"order/mg:delivery.before", readonly ["order/card", "order/card:settings", "user/current", "settings"]>;
|
|
30
|
+
readonly 'order/mg:delivery.after': TargetDefinition<"order/mg:delivery.after", readonly ["order/card", "order/card:settings", "user/current", "settings"]>;
|
|
31
|
+
readonly 'order/mg:payment.before': TargetDefinition<"order/mg:payment.before", readonly ["order/card", "order/card:settings", "user/current", "settings"]>;
|
|
32
|
+
readonly 'order/mg:payment.after': TargetDefinition<"order/mg:payment.after", readonly ["order/card", "order/card:settings", "user/current", "settings"]>;
|
|
33
|
+
};
|
|
34
|
+
export type TargetName = keyof typeof targets;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const defineTarget = (id, contexts) => ({
|
|
2
|
+
id,
|
|
3
|
+
contexts
|
|
4
|
+
});
|
|
5
|
+
const targets = {
|
|
6
|
+
"customer/card:phone": defineTarget("customer/card:phone", [
|
|
7
|
+
"customer/card",
|
|
8
|
+
"customer/card:phone",
|
|
9
|
+
"user/current",
|
|
10
|
+
"settings"
|
|
11
|
+
]),
|
|
12
|
+
"customer/card:communications.after": defineTarget("customer/card:communications.after", [
|
|
13
|
+
"customer/card",
|
|
14
|
+
"user/current",
|
|
15
|
+
"settings"
|
|
16
|
+
]),
|
|
17
|
+
"customer/card:inWork.before": defineTarget("customer/card:inWork.before", [
|
|
18
|
+
"customer/card",
|
|
19
|
+
"user/current",
|
|
20
|
+
"settings"
|
|
21
|
+
]),
|
|
22
|
+
"customer/card:inWork.after": defineTarget("customer/card:inWork.after", [
|
|
23
|
+
"customer/card",
|
|
24
|
+
"user/current",
|
|
25
|
+
"settings"
|
|
26
|
+
]),
|
|
27
|
+
"order/card:common.before": defineTarget("order/card:common.before", [
|
|
28
|
+
"order/card",
|
|
29
|
+
"user/current",
|
|
30
|
+
"settings"
|
|
31
|
+
]),
|
|
32
|
+
"order/card:common.after": defineTarget("order/card:common.after", [
|
|
33
|
+
"order/card",
|
|
34
|
+
"user/current",
|
|
35
|
+
"settings"
|
|
36
|
+
]),
|
|
37
|
+
"order/card:customer.before": defineTarget("order/card:customer.before", [
|
|
38
|
+
"order/card",
|
|
39
|
+
"user/current",
|
|
40
|
+
"settings"
|
|
41
|
+
]),
|
|
42
|
+
"order/card:customer.after": defineTarget("order/card:customer.after", [
|
|
43
|
+
"order/card",
|
|
44
|
+
"user/current",
|
|
45
|
+
"settings"
|
|
46
|
+
]),
|
|
47
|
+
"order/card:customer.email": defineTarget("order/card:customer.email", [
|
|
48
|
+
"order/card",
|
|
49
|
+
"user/current",
|
|
50
|
+
"settings"
|
|
51
|
+
]),
|
|
52
|
+
"order/card:customer.phone": defineTarget("order/card:customer.phone", [
|
|
53
|
+
"order/card",
|
|
54
|
+
"user/current",
|
|
55
|
+
"settings"
|
|
56
|
+
]),
|
|
57
|
+
"order/card:list.before": defineTarget("order/card:list.before", [
|
|
58
|
+
"order/card",
|
|
59
|
+
"user/current",
|
|
60
|
+
"settings"
|
|
61
|
+
]),
|
|
62
|
+
"order/card:list.after": defineTarget("order/card:list.after", [
|
|
63
|
+
"order/card",
|
|
64
|
+
"user/current",
|
|
65
|
+
"settings"
|
|
66
|
+
]),
|
|
67
|
+
"order/card:store.before": defineTarget("order/card:store.before", [
|
|
68
|
+
"order/card",
|
|
69
|
+
"user/current",
|
|
70
|
+
"settings"
|
|
71
|
+
]),
|
|
72
|
+
"order/card:dimensions.before": defineTarget("order/card:dimensions.before", [
|
|
73
|
+
"order/card",
|
|
74
|
+
"user/current",
|
|
75
|
+
"settings"
|
|
76
|
+
]),
|
|
77
|
+
"order/card:delivery.before": defineTarget("order/card:delivery.before", [
|
|
78
|
+
"order/card",
|
|
79
|
+
"user/current",
|
|
80
|
+
"settings"
|
|
81
|
+
]),
|
|
82
|
+
"order/card:delivery.after": defineTarget("order/card:delivery.after", [
|
|
83
|
+
"order/card",
|
|
84
|
+
"user/current",
|
|
85
|
+
"settings"
|
|
86
|
+
]),
|
|
87
|
+
"order/card:delivery.address": defineTarget("order/card:delivery.address", [
|
|
88
|
+
"order/card",
|
|
89
|
+
"user/current",
|
|
90
|
+
"settings"
|
|
91
|
+
]),
|
|
92
|
+
"order/card:payment.before": defineTarget("order/card:payment.before", [
|
|
93
|
+
"order/card",
|
|
94
|
+
"user/current",
|
|
95
|
+
"settings"
|
|
96
|
+
]),
|
|
97
|
+
"order/card:comment.manager.before": defineTarget("order/card:comment.manager.before", [
|
|
98
|
+
"order/card",
|
|
99
|
+
"user/current",
|
|
100
|
+
"settings"
|
|
101
|
+
]),
|
|
102
|
+
"order/mg:list.before": defineTarget("order/mg:list.before", [
|
|
103
|
+
"order/card",
|
|
104
|
+
"order/card:settings",
|
|
105
|
+
"user/current",
|
|
106
|
+
"settings"
|
|
107
|
+
]),
|
|
108
|
+
"order/mg:list.after": defineTarget("order/mg:list.after", [
|
|
109
|
+
"order/card",
|
|
110
|
+
"order/card:settings",
|
|
111
|
+
"user/current",
|
|
112
|
+
"settings"
|
|
113
|
+
]),
|
|
114
|
+
"order/mg:delivery.before": defineTarget("order/mg:delivery.before", [
|
|
115
|
+
"order/card",
|
|
116
|
+
"order/card:settings",
|
|
117
|
+
"user/current",
|
|
118
|
+
"settings"
|
|
119
|
+
]),
|
|
120
|
+
"order/mg:delivery.after": defineTarget("order/mg:delivery.after", [
|
|
121
|
+
"order/card",
|
|
122
|
+
"order/card:settings",
|
|
123
|
+
"user/current",
|
|
124
|
+
"settings"
|
|
125
|
+
]),
|
|
126
|
+
"order/mg:payment.before": defineTarget("order/mg:payment.before", [
|
|
127
|
+
"order/card",
|
|
128
|
+
"order/card:settings",
|
|
129
|
+
"user/current",
|
|
130
|
+
"settings"
|
|
131
|
+
]),
|
|
132
|
+
"order/mg:payment.after": defineTarget("order/mg:payment.after", [
|
|
133
|
+
"order/card",
|
|
134
|
+
"order/card:settings",
|
|
135
|
+
"user/current",
|
|
136
|
+
"settings"
|
|
137
|
+
])
|
|
138
|
+
};
|
|
139
|
+
export {
|
|
140
|
+
defineTarget,
|
|
141
|
+
targets
|
|
142
|
+
};
|
package/dist/common.cjs
ADDED
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common/targets';
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Endpoint, MessageEndpoint } from '@remote-ui/rpc';
|
|
2
|
+
import { RemoteApi } from '../common/extension';
|
|
3
|
+
import { Runner as PageRunner, defineRunner as definePageRunner } from './pages';
|
|
4
|
+
import { Runner as WidgetRunner, defineRunner as defineWidgetRunner } from './widgets';
|
|
5
|
+
export type Runner = {
|
|
6
|
+
widget: WidgetRunner;
|
|
7
|
+
page: PageRunner;
|
|
8
|
+
};
|
|
9
|
+
export type { RemoteApi };
|
|
10
|
+
export declare const defineRunner: (config: {
|
|
11
|
+
pages: Parameters<typeof definePageRunner>;
|
|
12
|
+
widgets: Parameters<typeof defineWidgetRunner>;
|
|
13
|
+
}) => Runner;
|
|
14
|
+
export declare const createEndpoint: (runner: Runner, messenger: MessageEndpoint) => Endpoint<RemoteApi>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const defineSingleRunner = (component, beforeMount) => ({
|
|
5
|
+
async run(createApp, root, pinia, code) {
|
|
6
|
+
const app = createApp({
|
|
7
|
+
setup() {
|
|
8
|
+
return () => vue.h(component, { code });
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
app.use(pinia);
|
|
12
|
+
await beforeMount?.();
|
|
13
|
+
app.mount(root);
|
|
14
|
+
return () => app.unmount();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const log = {
|
|
18
|
+
warn: (text) => console.warn(`[Remote] ${text}`)
|
|
19
|
+
};
|
|
20
|
+
const defineMultiRunner = (runners) => ({
|
|
21
|
+
async run(createApp, root, pinia, code) {
|
|
22
|
+
const runner = runners[code];
|
|
23
|
+
if (!runner) {
|
|
24
|
+
log.warn(`No runner for code "${code}"`);
|
|
25
|
+
return () => {
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return runner.run(createApp, root, pinia, code);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function isRunnersMap(value) {
|
|
32
|
+
if (typeof value === "function") return false;
|
|
33
|
+
const entries = Object.values(value);
|
|
34
|
+
return entries.length > 0 && entries.every(
|
|
35
|
+
(entry) => typeof entry === "object" && entry !== null && "run" in entry
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function defineRunner(input, beforeMount) {
|
|
39
|
+
if (isRunnersMap(input)) {
|
|
40
|
+
return defineMultiRunner(input);
|
|
41
|
+
}
|
|
42
|
+
return defineSingleRunner(input, beforeMount);
|
|
43
|
+
}
|
|
44
|
+
exports.defineMultiRunner = defineMultiRunner;
|
|
45
|
+
exports.defineRunner = defineRunner;
|
|
46
|
+
exports.defineSingleRunner = defineSingleRunner;
|
|
47
|
+
exports.log = log;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Component, CreateAppFunction } from 'vue';
|
|
2
|
+
import { Pinia } from 'pinia';
|
|
3
|
+
import { RunIdentity } from '../common/pages';
|
|
4
|
+
import { createRemoteRenderer } from '@omnicajs/vue-remote/remote';
|
|
5
|
+
type RemoteRoot = Parameters<typeof createRemoteRenderer>[0];
|
|
6
|
+
export type { RunIdentity };
|
|
7
|
+
export interface Runner {
|
|
8
|
+
run(createApp: CreateAppFunction<Component<RemoteRoot> | RemoteRoot>, root: RemoteRoot, pinia: Pinia, code: string): Promise<() => void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const defineSingleRunner: (component: Component, beforeMount?: () => Promise<void>) => Runner;
|
|
11
|
+
export declare const log: {
|
|
12
|
+
warn: (text: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const defineMultiRunner: (runners: Partial<Record<string, Runner>>) => Runner;
|
|
15
|
+
type RunnersMap = Record<string, Runner>;
|
|
16
|
+
export declare function defineRunner(component: Component, beforeMount?: () => Promise<void>): Runner;
|
|
17
|
+
export declare function defineRunner(runners: RunnersMap): Runner;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
const defineSingleRunner = (component, beforeMount) => ({
|
|
3
|
+
async run(createApp, root, pinia, code) {
|
|
4
|
+
const app = createApp({
|
|
5
|
+
setup() {
|
|
6
|
+
return () => h(component, { code });
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
app.use(pinia);
|
|
10
|
+
await beforeMount?.();
|
|
11
|
+
app.mount(root);
|
|
12
|
+
return () => app.unmount();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const log = {
|
|
16
|
+
warn: (text) => console.warn(`[Remote] ${text}`)
|
|
17
|
+
};
|
|
18
|
+
const defineMultiRunner = (runners) => ({
|
|
19
|
+
async run(createApp, root, pinia, code) {
|
|
20
|
+
const runner = runners[code];
|
|
21
|
+
if (!runner) {
|
|
22
|
+
log.warn(`No runner for code "${code}"`);
|
|
23
|
+
return () => {
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return runner.run(createApp, root, pinia, code);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
function isRunnersMap(value) {
|
|
30
|
+
if (typeof value === "function") return false;
|
|
31
|
+
const entries = Object.values(value);
|
|
32
|
+
return entries.length > 0 && entries.every(
|
|
33
|
+
(entry) => typeof entry === "object" && entry !== null && "run" in entry
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function defineRunner(input, beforeMount) {
|
|
37
|
+
if (isRunnersMap(input)) {
|
|
38
|
+
return defineMultiRunner(input);
|
|
39
|
+
}
|
|
40
|
+
return defineSingleRunner(input, beforeMount);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
defineMultiRunner,
|
|
44
|
+
defineRunner,
|
|
45
|
+
defineSingleRunner,
|
|
46
|
+
log
|
|
47
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const defineSingleRunner = (component, beforeMount) => ({
|
|
5
|
+
async run(createApp, root, pinia, target) {
|
|
6
|
+
const app = createApp({
|
|
7
|
+
setup() {
|
|
8
|
+
return () => vue.h(component, { target });
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
app.use(pinia);
|
|
12
|
+
await beforeMount?.();
|
|
13
|
+
app.mount(root);
|
|
14
|
+
return () => app.unmount();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const log = {
|
|
18
|
+
warn: (text) => console.warn(`[Remote] ${text}`)
|
|
19
|
+
};
|
|
20
|
+
const defineMultiRunner = (runners) => ({
|
|
21
|
+
async run(createApp, root, pinia, target) {
|
|
22
|
+
const runner = runners[target];
|
|
23
|
+
if (!runner) {
|
|
24
|
+
log.warn(`No runner for target "${target}"`);
|
|
25
|
+
return () => {
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return runner.run(createApp, root, pinia, target);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function isRunnersMap(value) {
|
|
32
|
+
if (typeof value === "function") return false;
|
|
33
|
+
const entries = Object.values(value);
|
|
34
|
+
return entries.length > 0 && entries.every(
|
|
35
|
+
(entry) => typeof entry === "object" && entry !== null && "run" in entry
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function defineRunner(input, beforeMount) {
|
|
39
|
+
if (isRunnersMap(input)) {
|
|
40
|
+
return defineMultiRunner(input);
|
|
41
|
+
}
|
|
42
|
+
return defineSingleRunner(input, beforeMount);
|
|
43
|
+
}
|
|
44
|
+
exports.defineMultiRunner = defineMultiRunner;
|
|
45
|
+
exports.defineRunner = defineRunner;
|
|
46
|
+
exports.defineSingleRunner = defineSingleRunner;
|
|
47
|
+
exports.log = log;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Component, CreateAppFunction } from 'vue';
|
|
2
|
+
import { Pinia } from 'pinia';
|
|
3
|
+
import { RunConfig, RunIdentity } from '../common/widgets';
|
|
4
|
+
import { TargetName } from '../common/targets';
|
|
5
|
+
import { createRemoteRenderer } from '@omnicajs/vue-remote/remote';
|
|
6
|
+
type RemoteRoot = Parameters<typeof createRemoteRenderer>[0];
|
|
7
|
+
export type { RunConfig };
|
|
8
|
+
export type { RunIdentity };
|
|
9
|
+
export interface Runner {
|
|
10
|
+
run(createApp: CreateAppFunction<Component<RemoteRoot> | RemoteRoot>, root: RemoteRoot, pinia: Pinia, target: TargetName): Promise<() => void>;
|
|
11
|
+
}
|
|
12
|
+
export declare const defineSingleRunner: (component: Component, beforeMount?: () => Promise<void>) => Runner;
|
|
13
|
+
export declare const log: {
|
|
14
|
+
warn: (text: string) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const defineMultiRunner: (runners: Partial<Record<TargetName, Runner>>) => Runner;
|
|
17
|
+
type RunnersMap = {
|
|
18
|
+
[key in TargetName]?: Runner;
|
|
19
|
+
};
|
|
20
|
+
export declare function defineRunner(component: Component, beforeMount?: () => Promise<void>): Runner;
|
|
21
|
+
export declare function defineRunner(runners: RunnersMap): Runner;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
const defineSingleRunner = (component, beforeMount) => ({
|
|
3
|
+
async run(createApp, root, pinia, target) {
|
|
4
|
+
const app = createApp({
|
|
5
|
+
setup() {
|
|
6
|
+
return () => h(component, { target });
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
app.use(pinia);
|
|
10
|
+
await beforeMount?.();
|
|
11
|
+
app.mount(root);
|
|
12
|
+
return () => app.unmount();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const log = {
|
|
16
|
+
warn: (text) => console.warn(`[Remote] ${text}`)
|
|
17
|
+
};
|
|
18
|
+
const defineMultiRunner = (runners) => ({
|
|
19
|
+
async run(createApp, root, pinia, target) {
|
|
20
|
+
const runner = runners[target];
|
|
21
|
+
if (!runner) {
|
|
22
|
+
log.warn(`No runner for target "${target}"`);
|
|
23
|
+
return () => {
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return runner.run(createApp, root, pinia, target);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
function isRunnersMap(value) {
|
|
30
|
+
if (typeof value === "function") return false;
|
|
31
|
+
const entries = Object.values(value);
|
|
32
|
+
return entries.length > 0 && entries.every(
|
|
33
|
+
(entry) => typeof entry === "object" && entry !== null && "run" in entry
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function defineRunner(input, beforeMount) {
|
|
37
|
+
if (isRunnersMap(input)) {
|
|
38
|
+
return defineMultiRunner(input);
|
|
39
|
+
}
|
|
40
|
+
return defineSingleRunner(input, beforeMount);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
defineMultiRunner,
|
|
44
|
+
defineRunner,
|
|
45
|
+
defineSingleRunner,
|
|
46
|
+
log
|
|
47
|
+
};
|