@myop/sdk 0.2.4 → 0.2.6
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 +365 -208
- package/dist/cjs/{_IframeSDK.b80455bf.js → _IframeSDK.2793f0c2.js} +1 -1
- package/dist/cjs/{_IframeSDK.b80455bf.js.map → _IframeSDK.2793f0c2.js.map} +1 -1
- package/dist/cjs/{_IframeSDK.2f50c32c.min.js → _IframeSDK.fb84c8eb.min.js} +1 -1
- package/dist/cjs/{_WebComponentSDK.37374c87.min.js → _WebComponentSDK.0fee50b6.min.js} +1 -1
- package/dist/cjs/{_WebComponentSDK.687ea8cb.js → _WebComponentSDK.ba6c3d1b.js} +1 -1
- package/dist/cjs/{_WebComponentSDK.687ea8cb.js.map → _WebComponentSDK.ba6c3d1b.js.map} +1 -1
- package/dist/cjs/{_hostSDK.48a55f66.min.js → _hostSDK.159c1adb.min.js} +1 -1
- package/dist/cjs/{_hostSDK.e09022f6.js → _hostSDK.71e17cf2.js} +1 -1
- package/dist/cjs/{_hostSDK.e09022f6.js.map → _hostSDK.71e17cf2.js.map} +1 -1
- package/dist/cjs/myop_sdk.js +11 -11
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +2 -2
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +2 -2
- package/dist/module/Iframe/index.js.map +1 -1
- package/dist/module/SDK.js +2 -2
- package/dist/module/SDK.js.map +1 -1
- package/dist/module/host/index.js +2 -2
- package/dist/module/host/index.js.map +1 -1
- package/dist/module/webcomponent/index.js +2 -2
- package/dist/module/webcomponent/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,288 +1,445 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
7. [Why Choose Myop SDKs?](#why-choose-myop-sdks)
|
|
25
|
-
8. [Get Started with Myop SDKs Today!](#get-started-with-myop-sdks-today)
|
|
26
|
-
9. [Related Resources](#related-resources)
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://myop.dev">
|
|
3
|
+
<img src="https://docs.myop.dev/img/logo.svg" alt="Myop Logo" width="200" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Myop SDK</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>Dynamic UI component management for modern web applications</strong>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://www.npmjs.com/package/@myop/sdk"><img src="https://img.shields.io/npm/v/@myop/sdk.svg?style=flat-square" alt="npm version"></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@myop/sdk"><img src="https://img.shields.io/npm/dm/@myop/sdk.svg?style=flat-square" alt="npm downloads"></a>
|
|
16
|
+
<a href="https://myop.dev/discord"><img src="https://img.shields.io/badge/Discord-Join%20Us-7289da?style=flat-square&logo=discord&logoColor=white" alt="Discord"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://docs.myop.dev">Documentation</a> |
|
|
21
|
+
<a href="https://myop.dev">Website</a> |
|
|
22
|
+
<a href="https://myop.dev/discord">Discord</a>
|
|
23
|
+
</p>
|
|
27
24
|
|
|
28
25
|
---
|
|
29
26
|
|
|
30
|
-
##
|
|
31
|
-
The **Root SDK** is the starting point for using Myop’s powerful UI components. It enables you to dynamically load, control, and interact with Myop components inside your web application, offering full control over UI modifications with minimal setup.
|
|
27
|
+
## What is Myop?
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
Myop is an open-source SDK that enables **real-time UI modifications without deployments**. It bridges your application logic with dynamically swappable user interfaces, allowing developers to:
|
|
30
|
+
|
|
31
|
+
- Experiment with UI/UX changes instantly
|
|
32
|
+
- Refactor component appearance without touching core functionality
|
|
33
|
+
- Maintain typed communication between components and host applications
|
|
34
|
+
- Load and manage UI components dynamically at runtime
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install @myop/sdk
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or via CDN:
|
|
35
43
|
|
|
36
|
-
1. **Via CDN (Script Tag):**
|
|
37
44
|
```html
|
|
38
45
|
<script src="https://cdn.myop.dev/sdk/next/myop_sdk.min.js"></script>
|
|
39
|
-
<script>
|
|
40
|
-
// Initialize the SDK
|
|
41
|
-
const { hostSDK } = await window.myop.rootSDK.getHostModule();
|
|
42
|
-
const { MyopMessages } = await window.myop.rootSDK.getMyopMessages();
|
|
43
|
-
</script>
|
|
44
46
|
```
|
|
45
|
-
2 **Via NPM (Import into TypeScript/JavaScript Application):**
|
|
46
47
|
|
|
48
|
+
## Quick Start
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
### Using npm/ESM
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
49
53
|
import { getHostModule } from '@myop/sdk';
|
|
50
54
|
|
|
55
|
+
// Initialize the SDK
|
|
51
56
|
const { hostSDK } = await getHostModule();
|
|
52
|
-
|
|
57
|
+
hostSDK.init();
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
// Load a component
|
|
60
|
+
const component = await hostSDK.loadComponent(componentConfig, containerElement);
|
|
61
|
+
await component.initiated();
|
|
62
|
+
```
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
// Initialize hostSDK instance
|
|
59
|
-
hostSDK.init();
|
|
64
|
+
### Using CDN
|
|
60
65
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
```html
|
|
67
|
+
<script src="https://cdn.myop.dev/sdk/next/myop_sdk.min.js"></script>
|
|
68
|
+
<script>
|
|
69
|
+
const { hostSDK } = await window.myop.rootSDK.getHostModule();
|
|
70
|
+
hostSDK.init();
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
const component = await hostSDK.loadComponent(config, document.getElementById('app'));
|
|
73
|
+
await component.initiated();
|
|
74
|
+
</script>
|
|
68
75
|
```
|
|
69
|
-
Host SDK - Integrate Myop Components into Your App
|
|
70
|
-
The Host SDK is designed for applications that act as containers for Myop components. It provides core functionalities for embedding and managing Myop components within your web app, enabling smooth communication and integration.
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
## Architecture
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
Ensure seamless integration and maintain consistent UX across multiple components.
|
|
76
|
-
Communicate with the embedded Myop components using event-driven APIs.
|
|
77
|
-
### 📕 Host SDK Documentation
|
|
78
|
-
Explore the full documentation for the Host SDK to unlock the full potential of Myop's component-based UI management.
|
|
79
|
+
The Myop SDK is modular, consisting of several specialized packages:
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
| Module | Description | Import |
|
|
82
|
+
|--------|-------------|--------|
|
|
83
|
+
| **Host SDK** | Core module for embedding and managing Myop components | `@myop/sdk` or `@myop/sdk/host` |
|
|
84
|
+
| **Iframe SDK** | Secure isolation for components in iframes | `@myop/sdk/iframe` |
|
|
85
|
+
| **WebComponent SDK** | Support for self-contained web components | `@myop/sdk/webcomponent` |
|
|
86
|
+
| **Messages** | Type-safe communication between host and components | `@myop/sdk/messages` |
|
|
87
|
+
| **Helpers** | Utility functions and configuration builders | `@myop/sdk/helpers` |
|
|
82
88
|
|
|
83
|
-
|
|
89
|
+
## Framework Integration
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
Benefit from the overall structure and management capabilities of the host app, without sacrificing security or performance.
|
|
87
|
-
Easily load and manage iframe-based components within your web app.
|
|
88
|
-
How to Load the Iframe SDK
|
|
89
|
-
You can load the Iframe SDK after loading the Root SDK in two simple steps:
|
|
91
|
+
Myop provides official framework packages for seamless integration:
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
| Package | Install |
|
|
94
|
+
|---------|---------|
|
|
95
|
+
| React | `npm install @myop/react` |
|
|
96
|
+
| Vue.js | `npm install @myop/vue` |
|
|
97
|
+
| Angular | `npm install @myop/angular` |
|
|
95
98
|
|
|
96
|
-
|
|
99
|
+
<details>
|
|
100
|
+
<summary><strong>React</strong></summary>
|
|
97
101
|
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
const { IframeSDK } = await getIframeModule();
|
|
102
|
+
```bash
|
|
103
|
+
npm install @myop/react
|
|
101
104
|
```
|
|
102
105
|
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
```tsx
|
|
107
|
+
import { MyopComponent } from '@myop/react';
|
|
108
|
+
|
|
109
|
+
function App() {
|
|
110
|
+
return (
|
|
111
|
+
<MyopComponent
|
|
112
|
+
componentId="your-component-id"
|
|
113
|
+
environment="production"
|
|
114
|
+
data={{ user: 'John' }}
|
|
115
|
+
onLoad={(component) => console.log('Component loaded', component)}
|
|
116
|
+
onError={(error) => console.error('Error:', error)}
|
|
117
|
+
on={(action, payload) => {
|
|
118
|
+
// Handle CTA actions from the component
|
|
119
|
+
console.log('Action:', action, payload);
|
|
120
|
+
}}
|
|
121
|
+
loader={<div>Loading...</div>}
|
|
122
|
+
fallback={<div>Failed to load</div>}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
105
127
|
|
|
106
|
-
|
|
107
|
-
The WebComponent SDK is built to support the use of Myop components packaged as self-contained web components. It simplifies lifecycle management, event handling, and communication, ensuring smooth integration with the host application.
|
|
128
|
+
**Props:**
|
|
108
129
|
|
|
109
|
-
|
|
130
|
+
| Prop | Type | Description |
|
|
131
|
+
|------|------|-------------|
|
|
132
|
+
| `componentId` | `string` | Component ID from Myop Cloud |
|
|
133
|
+
| `environment` | `string` | Environment identifier (default: `"production"`) |
|
|
134
|
+
| `data` | `any` | Data passed to `myop_init_interface` |
|
|
135
|
+
| `onLoad` | `(component) => void` | Called when component loads |
|
|
136
|
+
| `onError` | `(error) => void` | Called on error |
|
|
137
|
+
| `on` | `(action, payload) => void` | Handler for `myop_cta_handler` calls |
|
|
138
|
+
| `loader` | `ReactNode` | Custom loading indicator |
|
|
139
|
+
| `fallback` | `ReactNode` | Custom error fallback |
|
|
140
|
+
| `fadeDuration` | `number` | Loader fade duration in ms |
|
|
110
141
|
|
|
111
|
-
|
|
112
|
-
Benefit from lifecycle management tools to handle component states, initialization, and teardown.
|
|
113
|
-
Enable communication between the host application and the web components for dynamic, real-time changes.
|
|
114
|
-
How to Load the WebComponent SDK
|
|
115
|
-
Once the Root SDK is loaded, you can seamlessly load the WebComponent SDK:
|
|
142
|
+
**Preloading:**
|
|
116
143
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const { WebComponentSDK } = await window.myop.rootSDK.getWebcomponentModule();
|
|
120
|
-
```
|
|
144
|
+
```tsx
|
|
145
|
+
import { preload, isPreloaded } from '@myop/react';
|
|
121
146
|
|
|
122
|
-
|
|
147
|
+
// Preload components for faster rendering
|
|
148
|
+
await preload(['component-1', 'component-2'], 'production');
|
|
123
149
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
// Check if already loaded
|
|
151
|
+
if (isPreloaded('component-1')) {
|
|
152
|
+
// Component will render instantly
|
|
153
|
+
}
|
|
127
154
|
```
|
|
128
155
|
|
|
129
|
-
|
|
130
|
-
Learn more about the WebComponent SDK and how it can enhance your application development in the full documentation.
|
|
156
|
+
**Local Development:**
|
|
131
157
|
|
|
132
|
-
|
|
133
|
-
|
|
158
|
+
```tsx
|
|
159
|
+
import { enableLocalDev } from '@myop/react';
|
|
134
160
|
|
|
135
|
-
|
|
136
|
-
|
|
161
|
+
// Point to local server
|
|
162
|
+
enableLocalDev();
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
</details>
|
|
137
166
|
|
|
138
|
-
|
|
167
|
+
<details>
|
|
168
|
+
<summary><strong>Vue.js</strong></summary>
|
|
139
169
|
|
|
140
170
|
```bash
|
|
141
|
-
npm install @myop/
|
|
171
|
+
npm install @myop/vue
|
|
142
172
|
```
|
|
143
|
-
Create a React Component that Loads Myop Components:
|
|
144
|
-
|
|
145
|
-
```jsx
|
|
146
|
-
import React, { useEffect, useRef } from 'react';
|
|
147
|
-
import { getHostModule } from '@myop/sdk';
|
|
148
173
|
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
```vue
|
|
175
|
+
<template>
|
|
176
|
+
<MyopContainer
|
|
177
|
+
:componentId="componentId"
|
|
178
|
+
:flowId="flowId"
|
|
179
|
+
@ready="onReady"
|
|
180
|
+
v-bind="$attrs"
|
|
181
|
+
>
|
|
182
|
+
<template #loading>
|
|
183
|
+
<div>Loading...</div>
|
|
184
|
+
</template>
|
|
185
|
+
</MyopContainer>
|
|
186
|
+
</template>
|
|
151
187
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const myopComponent = await hostSDK.loadComponent(config.components['myExternalComponent1'], containerRef.current);
|
|
156
|
-
await myopComponent.initiated();
|
|
157
|
-
};
|
|
188
|
+
<script setup lang="ts">
|
|
189
|
+
import { MyopContainer } from '@myop/vue';
|
|
190
|
+
import type { IMyopComponent } from '@myop/sdk/host';
|
|
158
191
|
|
|
159
|
-
|
|
160
|
-
|
|
192
|
+
const componentId = 'your-component-id';
|
|
193
|
+
const flowId = 'optional-flow-id';
|
|
161
194
|
|
|
162
|
-
|
|
195
|
+
const onReady = (component: IMyopComponent, innerRef?: any) => {
|
|
196
|
+
console.log('Component loaded', component);
|
|
163
197
|
};
|
|
164
|
-
|
|
165
|
-
export default MyopComponent;
|
|
198
|
+
</script>
|
|
166
199
|
```
|
|
167
200
|
|
|
168
|
-
|
|
201
|
+
**Props:**
|
|
169
202
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
203
|
+
| Prop | Type | Description |
|
|
204
|
+
|------|------|-------------|
|
|
205
|
+
| `componentId` | `string` | Component ID from Myop Cloud |
|
|
206
|
+
| `flowId` | `string?` | Optional flow ID |
|
|
207
|
+
| `onReady` | `(component, innerRef?) => void` | Called when component loads |
|
|
173
208
|
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<div>
|
|
177
|
-
<h1>Myop + React</h1>
|
|
178
|
-
<MyopComponent />
|
|
179
|
-
</div>
|
|
180
|
-
);
|
|
181
|
-
};
|
|
209
|
+
**Slots:**
|
|
182
210
|
|
|
183
|
-
|
|
184
|
-
|
|
211
|
+
| Slot | Description |
|
|
212
|
+
|------|-------------|
|
|
213
|
+
| `loading` | Shown while component loads |
|
|
185
214
|
|
|
186
|
-
|
|
187
|
-
For Angular applications, you can integrate Myop SDKs by following these steps:
|
|
215
|
+
</details>
|
|
188
216
|
|
|
189
|
-
|
|
217
|
+
<details>
|
|
218
|
+
<summary><strong>Angular</strong></summary>
|
|
190
219
|
|
|
191
220
|
```bash
|
|
192
|
-
npm install @myop/
|
|
221
|
+
npm install @myop/angular
|
|
193
222
|
```
|
|
194
223
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
import {
|
|
199
|
-
import { getHostModule } from '@myop/sdk';
|
|
224
|
+
```typescript
|
|
225
|
+
import { Component } from '@angular/core';
|
|
226
|
+
import { MyopContainerComponent } from '@myop/angular';
|
|
227
|
+
import type { IMyopComponent } from '@myop/sdk/host';
|
|
200
228
|
|
|
201
229
|
@Component({
|
|
202
|
-
|
|
203
|
-
|
|
230
|
+
selector: 'app-root',
|
|
231
|
+
standalone: true,
|
|
232
|
+
imports: [MyopContainerComponent],
|
|
233
|
+
template: `
|
|
234
|
+
<myop-container
|
|
235
|
+
[componentId]="componentId"
|
|
236
|
+
[flowId]="flowId"
|
|
237
|
+
[inputs]="inputs"
|
|
238
|
+
(componentReady)="onComponentReady($event)"
|
|
239
|
+
>
|
|
240
|
+
<!-- Content shown while loading -->
|
|
241
|
+
<div>Loading...</div>
|
|
242
|
+
</myop-container>
|
|
243
|
+
`
|
|
204
244
|
})
|
|
205
|
-
export class
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
245
|
+
export class AppComponent {
|
|
246
|
+
componentId = 'your-component-id';
|
|
247
|
+
flowId?: string;
|
|
248
|
+
inputs = { theme: 'dark' };
|
|
249
|
+
|
|
250
|
+
onComponentReady(component: IMyopComponent) {
|
|
251
|
+
console.log('Component loaded', component);
|
|
252
|
+
}
|
|
213
253
|
}
|
|
214
254
|
```
|
|
215
|
-
|
|
255
|
+
|
|
256
|
+
**Inputs:**
|
|
257
|
+
|
|
258
|
+
| Input | Type | Description |
|
|
259
|
+
|-------|------|-------------|
|
|
260
|
+
| `componentId` | `string` | Component ID from Myop Cloud |
|
|
261
|
+
| `flowId` | `string?` | Optional flow ID |
|
|
262
|
+
| `inputs` | `object` | Data passed to the component |
|
|
263
|
+
|
|
264
|
+
**Outputs:**
|
|
265
|
+
|
|
266
|
+
| Output | Type | Description |
|
|
267
|
+
|--------|------|-------------|
|
|
268
|
+
| `componentReady` | `IMyopComponent` | Emitted when component loads |
|
|
269
|
+
|
|
270
|
+
</details>
|
|
271
|
+
|
|
272
|
+
<details>
|
|
273
|
+
<summary><strong>Vanilla JavaScript / CDN</strong></summary>
|
|
216
274
|
|
|
217
275
|
```html
|
|
218
|
-
<
|
|
219
|
-
```
|
|
276
|
+
<div id="myop-container"></div>
|
|
220
277
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
278
|
+
<script src="https://cdn.myop.dev/sdk/next/myop_sdk.min.js"></script>
|
|
279
|
+
<script>
|
|
280
|
+
async function init() {
|
|
281
|
+
const { hostSDK } = await window.myop.rootSDK.getHostModule();
|
|
282
|
+
const { CloudRepository } = await window.myop.rootSDK.getMyopHelpers();
|
|
224
283
|
|
|
225
|
-
|
|
226
|
-
|
|
284
|
+
const container = document.getElementById('myop-container');
|
|
285
|
+
|
|
286
|
+
// ============ V1: User Flows ============
|
|
287
|
+
// Fetch from auto-generated flow
|
|
288
|
+
const configV1 = await CloudRepository.Main.fetchComponentV1('component-id');
|
|
289
|
+
await hostSDK.loadComponent(configV1, container);
|
|
290
|
+
|
|
291
|
+
// Or fetch from a specific flow
|
|
292
|
+
const configFromFlow = await CloudRepository.Main.fetchComponentV1('component-id', 'flow-id');
|
|
293
|
+
|
|
294
|
+
// ============ V2: Direct Variant Loading ============
|
|
295
|
+
// Fetch variant directly by component ID and environment
|
|
296
|
+
const variantV2 = await CloudRepository.Main.fetchComponentV2('component-id', 'production');
|
|
297
|
+
await hostSDK.loadComponent(variantV2, container);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
init();
|
|
301
|
+
</script>
|
|
227
302
|
```
|
|
228
303
|
|
|
229
|
-
|
|
304
|
+
</details>
|
|
230
305
|
|
|
231
|
-
|
|
232
|
-
<template>
|
|
233
|
-
<div ref="container"></div>
|
|
234
|
-
</template>
|
|
306
|
+
## API Reference
|
|
235
307
|
|
|
236
|
-
|
|
308
|
+
### CloudRepository
|
|
309
|
+
|
|
310
|
+
Fetch component configurations from Myop Cloud:
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
import { CloudRepository } from '@myop/sdk/helpers';
|
|
314
|
+
|
|
315
|
+
// Fetch a component (v1 - from user flows)
|
|
316
|
+
const componentConfig = await CloudRepository.Main.fetchComponent('component-id');
|
|
317
|
+
|
|
318
|
+
// Fetch a component from a specific flow
|
|
319
|
+
const componentConfig = await CloudRepository.Main.fetchComponent('component-id', 'flow-id');
|
|
320
|
+
|
|
321
|
+
// Fetch a v2 component variant
|
|
322
|
+
const variantConfig = await CloudRepository.Main.fetchComponentV2('component-id', 'environment');
|
|
323
|
+
|
|
324
|
+
// Fetch a complete user flow
|
|
325
|
+
const flow = await CloudRepository.Main.fetchFlow('flow-id');
|
|
326
|
+
|
|
327
|
+
// Check if a component is preloaded
|
|
328
|
+
const isLoaded = CloudRepository.Main.isPreloaded('component-id');
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Host SDK
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
237
334
|
import { getHostModule } from '@myop/sdk';
|
|
238
335
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
336
|
+
const { hostSDK } = await getHostModule();
|
|
337
|
+
|
|
338
|
+
// Load a component into a container
|
|
339
|
+
const component = await hostSDK.loadComponent(componentConfig, containerElement);
|
|
340
|
+
|
|
341
|
+
// Load with options
|
|
342
|
+
const component = await hostSDK.loadComponent(componentConfig, container, {
|
|
343
|
+
hidden: false, // Start hidden
|
|
344
|
+
connectProps: true, // Auto-connect props (default: true)
|
|
345
|
+
timeout: 5000, // Initialization timeout
|
|
346
|
+
hooks: { // Lifecycle hooks
|
|
347
|
+
afterSkinSelected: async (skin) => skin
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// Navigate to a different component
|
|
352
|
+
const newComponent = await hostSDK.navigate(currentComponent, newConfig, {
|
|
353
|
+
staged: true, // Load new component before disposing old one
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// Send messages to component
|
|
357
|
+
component.send(message);
|
|
358
|
+
|
|
359
|
+
// Dispose component
|
|
360
|
+
component.dispose();
|
|
252
361
|
```
|
|
253
362
|
|
|
254
|
-
|
|
363
|
+
### ComponentConfig Builder
|
|
255
364
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
365
|
+
Build component configurations programmatically:
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
import { ComponentConfig, SkinConfig } from '@myop/sdk/helpers';
|
|
369
|
+
|
|
370
|
+
const skin = SkinConfig.create()
|
|
371
|
+
.withHTMLLoader({
|
|
372
|
+
HTML: '<div>My Component</div>',
|
|
373
|
+
shadowRootMode: 'open'
|
|
374
|
+
})
|
|
375
|
+
.build();
|
|
376
|
+
|
|
377
|
+
const config = ComponentConfig.create()
|
|
378
|
+
.withName('my-component')
|
|
379
|
+
.withDefaultSkin(skin)
|
|
380
|
+
.withBasicRef('header')
|
|
381
|
+
.withBasicRef('content')
|
|
382
|
+
.build();
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Iframe SDK
|
|
386
|
+
|
|
387
|
+
For components running inside iframes:
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
import { getIframeModule } from '@myop/sdk';
|
|
391
|
+
|
|
392
|
+
const { IframeSDK } = await getIframeModule();
|
|
260
393
|
```
|
|
261
394
|
|
|
262
|
-
###
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
-
|
|
277
|
-
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
395
|
+
### WebComponent SDK
|
|
396
|
+
|
|
397
|
+
For self-contained web components:
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
import { getWebcomponentModule } from '@myop/sdk';
|
|
401
|
+
|
|
402
|
+
const { WebComponentSDK } = await getWebcomponentModule();
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## Documentation
|
|
406
|
+
|
|
407
|
+
For comprehensive documentation, guides, and examples, visit **[docs.myop.dev](https://docs.myop.dev)**.
|
|
408
|
+
|
|
409
|
+
- [Getting Started Guide](https://docs.myop.dev/docs/quickstart)
|
|
410
|
+
- [SDK Reference](https://docs.myop.dev/docs/sdk)
|
|
411
|
+
|
|
412
|
+
## Development
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# Install dependencies
|
|
416
|
+
npm install
|
|
417
|
+
|
|
418
|
+
# Start development server
|
|
419
|
+
npm run dev
|
|
420
|
+
|
|
421
|
+
# Run tests
|
|
422
|
+
npm test
|
|
423
|
+
|
|
424
|
+
# Build for production
|
|
425
|
+
npm run build
|
|
426
|
+
|
|
427
|
+
# Generate documentation
|
|
428
|
+
npm run build:docs
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## Related Resources
|
|
432
|
+
|
|
285
433
|
- [Read more about Myop](https://myop.dev)
|
|
286
434
|
- [Myop Documentation](https://docs.myop.dev)
|
|
287
|
-
- [
|
|
288
|
-
|
|
435
|
+
- [Discord Community](https://myop.dev/discord)
|
|
436
|
+
|
|
437
|
+
## License
|
|
438
|
+
|
|
439
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
<p align="center">
|
|
444
|
+
Made with care by the <a href="https://myop.dev">Myop</a> team
|
|
445
|
+
</p>
|
|
@@ -1731,7 +1731,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
1731
1731
|
};
|
|
1732
1732
|
|
|
1733
1733
|
// version:myop-sdk-version
|
|
1734
|
-
var myop_sdk_version_default = "0.2.
|
|
1734
|
+
var myop_sdk_version_default = "0.2.6";
|
|
1735
1735
|
|
|
1736
1736
|
// src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
|
|
1737
1737
|
var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
|