@myop/cli 0.1.46 → 0.1.47

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.
@@ -1,12 +1,144 @@
1
1
  ---
2
2
  name: myop-react-host
3
- description: "Integrate Myop components into React applications using @myop/react. This skill covers MyopComponent props, typed event handlers, data binding, preloading, auto-generated packages, and local dev setup. Activate when the user is building a React app that hosts Myop components, or when you see @myop/react in package.json."
3
+ description: "Integrate Myop components into React applications using @myop/react. ALWAYS use the MyopComponent React component or auto-generated packages — NEVER create iframes manually. This skill covers MyopComponent props, typed event handlers, data binding, preloading, auto-generated packages, and local dev setup. Activate when the user is building a React app that hosts Myop components, or when you see @myop/react in package.json."
4
4
  ---
5
5
 
6
6
  # Myop React Host Integration
7
7
 
8
8
  Embed Myop components in React applications using `@myop/react`.
9
9
 
10
+ ## CRITICAL: Always Use the SDK
11
+
12
+ **NEVER create `<iframe>` elements manually. NEVER call `myop_init_interface()` or wire `myop_cta_handler()` directly.**
13
+
14
+ The `@myop/react` SDK handles all iframe management, communication, loading, error handling, sizing, and caching. Always use `<MyopComponent>` or an auto-generated package.
15
+
16
+ ```tsx
17
+ // WRONG — never do this
18
+ <iframe ref={ref} src="/component.html" />
19
+ ref.current.contentWindow.myop_init_interface(data)
20
+
21
+ // CORRECT — always use the SDK
22
+ <MyopComponent componentId="abc-123" data={data} on={handler} />
23
+ ```
24
+
25
+ ## End-to-End Workflow: React App with Myop Components
26
+
27
+ Each Myop component is a **separate project** in its own directory. You create them, develop them, push them to get a `componentId`, then reference that ID in your React host app.
28
+
29
+ ### Step 1: Create component projects
30
+
31
+ Each component needs its own directory with `myop.config.json` + `index.html`:
32
+
33
+ ```bash
34
+ # Create first component
35
+ mkdir components/sidebar && cd components/sidebar
36
+ npx myop create # Scaffolds index.html + myop.config.json, starts dev server
37
+ # Build the component UI (see myop-component skill)
38
+ # Ctrl+C to stop dev server when done
39
+
40
+ # Create second component
41
+ cd ../
42
+ mkdir chart && cd chart
43
+ npx myop create
44
+ # Build this component too
45
+ ```
46
+
47
+ ### Step 2: Push components to get IDs
48
+
49
+ Each component must be pushed to the Myop platform to get a `componentId`:
50
+
51
+ ```bash
52
+ cd components/sidebar
53
+ npx myop push # Uploads and assigns a componentId (UUID)
54
+ # Output: componentId is now in myop.config.json
55
+
56
+ cd ../chart
57
+ npx myop push
58
+ ```
59
+
60
+ After push, each `myop.config.json` has a real `componentId` (UUID).
61
+
62
+ ### Step 3: Set up the React host app
63
+
64
+ ```bash
65
+ cd my-react-app
66
+ npm install @myop/react @myop/sdk
67
+ ```
68
+
69
+ ### Step 4: Use components in React
70
+
71
+ ```tsx
72
+ import { MyopComponent } from "@myop/react";
73
+
74
+ function App() {
75
+ return (
76
+ <div style={{ display: "flex", gap: 16 }}>
77
+ <MyopComponent
78
+ componentId="<sidebar-componentId-from-step-2>"
79
+ data={{ items: ["Home", "Settings"] }}
80
+ onItemSelected={({ itemId }) => console.log(itemId)}
81
+ style={{ width: 300, height: "100%" }}
82
+ />
83
+ <MyopComponent
84
+ componentId="<chart-componentId-from-step-2>"
85
+ data={{ values: [10, 20, 30] }}
86
+ style={{ flex: 1 }}
87
+ />
88
+ </div>
89
+ );
90
+ }
91
+ ```
92
+
93
+ ### Working locally on existing components (componentId already in code)
94
+
95
+ When you find `componentId` values already used in the codebase and the developer wants to modify those components locally:
96
+
97
+ **Step A: Pull the component source**
98
+
99
+ ```bash
100
+ # Create a directory for the component and pull it by ID
101
+ mkdir components/sidebar && cd components/sidebar
102
+ npx myop pull <componentId>
103
+ # Downloads index.html + creates myop.config.json with the componentId
104
+ ```
105
+
106
+ **Step B: Start the local dev server**
107
+
108
+ ```bash
109
+ npx myop dev # Serves component on port 9292 with HMR
110
+ ```
111
+
112
+ **Step C: Point the React app to local dev server**
113
+
114
+ ```tsx
115
+ import { enableLocalDev } from "@myop/react";
116
+ enableLocalDev(); // All <MyopComponent> instances load from localhost:9292 instead of cloud
117
+ ```
118
+
119
+ Now edits to `index.html` in the component directory are reflected instantly in the React app.
120
+
121
+ **Step D: Push changes when done**
122
+
123
+ ```bash
124
+ cd components/sidebar
125
+ npx myop push # Uploads updated component to the same componentId
126
+ ```
127
+
128
+ Remove or comment out `enableLocalDev()` to go back to loading from the Myop cloud.
129
+
130
+ **Full local dev flow (multiple components):**
131
+
132
+ ```bash
133
+ # Pull all components you need to work on
134
+ mkdir -p components && cd components
135
+ npx myop pull <sidebar-id> -o sidebar/index.html
136
+ npx myop pull <chart-id> -o chart/index.html
137
+
138
+ # Start dev server (serves all components in subdirectories)
139
+ npx myop dev -m # Monorepo mode — select which components to serve
140
+ ```
141
+
10
142
  ## When This Skill Activates
11
143
 
12
144
  - `@myop/react` is in `package.json` dependencies
@@ -260,6 +392,16 @@ import type {
260
392
  } from "@myop/react";
261
393
  ```
262
394
 
395
+ ## Common Mistakes — WRONG vs CORRECT
396
+
397
+ | WRONG | CORRECT |
398
+ |-------|---------|
399
+ | Creating `<iframe>` elements manually | Using `<MyopComponent>` from `@myop/react` |
400
+ | Calling `myop_init_interface()` on iframe contentWindow | Passing `data` prop to `<MyopComponent>` |
401
+ | Wiring `myop_cta_handler` via refs | Using `on` or `onActionName` props |
402
+ | Loading component HTML from local file | Using `componentId` — SDK fetches from Myop cloud |
403
+ | Managing iframe lifecycle with useEffect | SDK handles load, error, cleanup automatically |
404
+
263
405
  ## Reference
264
406
 
265
407
  - [Auto-Generated Packages](references/auto-generated-packages.md)
@@ -1,12 +1,130 @@
1
1
  ---
2
2
  name: myop-react-native-host
3
- description: "Integrate Myop components into React Native applications using @myop/react-native. This skill covers MyopComponent props, CTA event handling, data binding, preloading, auto-generated packages, native-specific features (scroll, zoom, selection control), and local dev setup. Activate when the user is building a React Native app that hosts Myop components, or when you see @myop/react-native in package.json."
3
+ description: "Integrate Myop components into React Native applications using @myop/react-native. ALWAYS use the MyopComponent component or auto-generated packages — NEVER create WebViews manually. Covers MyopComponent props, CTA event handling, data binding, preloading, auto-generated packages, native-specific features (scroll, zoom, selection control), and local dev setup. Activate when the user is building a React Native app that hosts Myop components, or when you see @myop/react-native in package.json."
4
4
  ---
5
5
 
6
6
  # Myop React Native Host Integration
7
7
 
8
8
  Embed Myop components in React Native applications using `@myop/react-native`. Components render inside a WebView with a native bridge for CTA communication.
9
9
 
10
+ ## CRITICAL: Always Use the SDK
11
+
12
+ **NEVER create `<WebView>` elements manually. NEVER call `myop_init_interface()` or wire `myop_cta_handler()` directly.**
13
+
14
+ The `@myop/react-native` SDK handles all WebView management, native bridge communication, loading, error handling, and caching. Always use `<MyopComponent>` or an auto-generated package.
15
+
16
+ ```tsx
17
+ // WRONG — never do this
18
+ <WebView source={{ uri: componentUrl }} />
19
+
20
+ // CORRECT — always use the SDK
21
+ <MyopComponent componentId="abc-123" data={data} on={handler} />
22
+ ```
23
+
24
+ ## End-to-End Workflow: React Native App with Myop Components
25
+
26
+ Each Myop component is a **separate project** in its own directory. You create them, develop them, push them to get a `componentId`, then reference that ID in your React Native host app.
27
+
28
+ ### Step 1: Create component projects
29
+
30
+ ```bash
31
+ # Each component gets its own directory
32
+ mkdir components/sidebar && cd components/sidebar
33
+ npx myop create # Scaffolds index.html + myop.config.json
34
+ # Build the component UI (see myop-component skill), then Ctrl+C
35
+
36
+ cd ../ && mkdir chart && cd chart
37
+ npx myop create
38
+ ```
39
+
40
+ ### Step 2: Push components to get IDs
41
+
42
+ ```bash
43
+ cd components/sidebar
44
+ npx myop push # Uploads → componentId written to myop.config.json
45
+
46
+ cd ../chart
47
+ npx myop push
48
+ ```
49
+
50
+ ### Step 3: Use in your React Native app
51
+
52
+ ```bash
53
+ cd my-rn-app
54
+ npm install @myop/react-native react-native-webview
55
+ ```
56
+
57
+ ```tsx
58
+ import { MyopComponent } from "@myop/react-native";
59
+
60
+ function App() {
61
+ return (
62
+ <View style={{ flex: 1 }}>
63
+ <MyopComponent
64
+ componentId="<sidebar-componentId-from-step-2>"
65
+ data={{ items: ["Home", "Settings"] }}
66
+ on={(action, payload) => console.log(action, payload)}
67
+ style={{ height: 300 }}
68
+ />
69
+ <MyopComponent
70
+ componentId="<chart-componentId-from-step-2>"
71
+ data={{ values: [10, 20, 30] }}
72
+ style={{ flex: 1 }}
73
+ />
74
+ </View>
75
+ );
76
+ }
77
+ ```
78
+
79
+ ### Working locally on existing components (componentId already in code)
80
+
81
+ When you find `componentId` values already used in the codebase and the developer wants to modify those components locally:
82
+
83
+ **Step A: Pull the component source**
84
+
85
+ ```bash
86
+ mkdir components/sidebar && cd components/sidebar
87
+ npx myop pull <componentId>
88
+ # Downloads index.html + creates myop.config.json with the componentId
89
+ ```
90
+
91
+ **Step B: Start the local dev server**
92
+
93
+ ```bash
94
+ npx myop dev # Serves component on port 9292 with HMR
95
+ ```
96
+
97
+ **Step C: Point the React Native app to local dev server**
98
+
99
+ ```tsx
100
+ import { enableLocalDev, setCloudRepositoryUrl } from "@myop/react-native";
101
+ enableLocalDev(); // All <MyopComponent> instances load from localhost:9292
102
+
103
+ // Android emulator requires explicit IP:
104
+ // setCloudRepositoryUrl("http://10.0.2.2:9292");
105
+ // Physical device — use your machine's IP:
106
+ // setCloudRepositoryUrl("http://192.168.1.100:9292");
107
+ ```
108
+
109
+ Now edits to `index.html` are reflected instantly in the React Native app.
110
+
111
+ **Step D: Push changes when done**
112
+
113
+ ```bash
114
+ npx myop push # Uploads updated component to the same componentId
115
+ ```
116
+
117
+ Remove or comment out `enableLocalDev()` to go back to loading from the Myop cloud.
118
+
119
+ **Multiple components:**
120
+
121
+ ```bash
122
+ mkdir -p components && cd components
123
+ npx myop pull <sidebar-id> -o sidebar/index.html
124
+ npx myop pull <chart-id> -o chart/index.html
125
+ npx myop dev -m # Monorepo mode — select which components to serve
126
+ ```
127
+
10
128
  ## When This Skill Activates
11
129
 
12
130
  - `@myop/react-native` is in `package.json` dependencies
@@ -1,12 +1,123 @@
1
1
  ---
2
2
  name: myop-vue-host
3
- description: "Integrate Myop components into Vue 3 applications using @myop/vue. This skill covers MyopComponent props, events, slots, data binding, preloading, auto-generated packages, and local dev setup. Activate when the user is building a Vue app that hosts Myop components, or when you see @myop/vue in package.json."
3
+ description: "Integrate Myop components into Vue 3 applications using @myop/vue. ALWAYS use the MyopComponent Vue component or auto-generated packages — NEVER create iframes manually. Covers MyopComponent props, events, slots, data binding, preloading, auto-generated packages, and local dev setup. Activate when the user is building a Vue app that hosts Myop components, or when you see @myop/vue in package.json."
4
4
  ---
5
5
 
6
6
  # Myop Vue Host Integration
7
7
 
8
8
  Embed Myop components in Vue 3 applications using `@myop/vue`.
9
9
 
10
+ ## CRITICAL: Always Use the SDK
11
+
12
+ **NEVER create `<iframe>` elements manually. NEVER call `myop_init_interface()` or wire `myop_cta_handler()` directly.**
13
+
14
+ The `@myop/vue` SDK handles all iframe management, communication, loading, error handling, and caching. Always use `<MyopComponent>` or an auto-generated package.
15
+
16
+ ```vue
17
+ <!-- WRONG — never do this -->
18
+ <iframe ref="myIframe" src="/component.html" />
19
+
20
+ <!-- CORRECT — always use the SDK -->
21
+ <MyopComponent component-id="abc-123" :data="data" @cta="handleCta" />
22
+ ```
23
+
24
+ ## End-to-End Workflow: Vue App with Myop Components
25
+
26
+ Each Myop component is a **separate project** in its own directory. You create them, develop them, push them to get a `componentId`, then reference that ID in your Vue host app.
27
+
28
+ ### Step 1: Create component projects
29
+
30
+ ```bash
31
+ # Each component gets its own directory
32
+ mkdir components/sidebar && cd components/sidebar
33
+ npx myop create # Scaffolds index.html + myop.config.json
34
+ # Build the component UI (see myop-component skill), then Ctrl+C
35
+
36
+ cd ../ && mkdir chart && cd chart
37
+ npx myop create
38
+ ```
39
+
40
+ ### Step 2: Push components to get IDs
41
+
42
+ ```bash
43
+ cd components/sidebar
44
+ npx myop push # Uploads → componentId written to myop.config.json
45
+
46
+ cd ../chart
47
+ npx myop push
48
+ ```
49
+
50
+ ### Step 3: Use in your Vue app
51
+
52
+ ```bash
53
+ cd my-vue-app
54
+ npm install @myop/vue @myop/sdk
55
+ ```
56
+
57
+ ```vue
58
+ <script setup>
59
+ import { MyopComponent } from "@myop/vue";
60
+ </script>
61
+
62
+ <template>
63
+ <MyopComponent
64
+ component-id="<sidebar-componentId-from-step-2>"
65
+ :data="{ items: ['Home', 'Settings'] }"
66
+ @cta="(action, payload) => console.log(action, payload)"
67
+ style="width: 300px"
68
+ />
69
+ <MyopComponent
70
+ component-id="<chart-componentId-from-step-2>"
71
+ :data="{ values: [10, 20, 30] }"
72
+ style="flex: 1"
73
+ />
74
+ </template>
75
+ ```
76
+
77
+ ### Working locally on existing components (componentId already in code)
78
+
79
+ When you find `componentId` values already used in the codebase and the developer wants to modify those components locally:
80
+
81
+ **Step A: Pull the component source**
82
+
83
+ ```bash
84
+ mkdir components/sidebar && cd components/sidebar
85
+ npx myop pull <componentId>
86
+ # Downloads index.html + creates myop.config.json with the componentId
87
+ ```
88
+
89
+ **Step B: Start the local dev server**
90
+
91
+ ```bash
92
+ npx myop dev # Serves component on port 9292 with HMR
93
+ ```
94
+
95
+ **Step C: Point the Vue app to local dev server**
96
+
97
+ ```ts
98
+ import { enableLocalDev } from "@myop/vue";
99
+ enableLocalDev(); // All <MyopComponent> instances load from localhost:9292
100
+ ```
101
+
102
+ Now edits to `index.html` are reflected instantly in the Vue app.
103
+
104
+ **Step D: Push changes when done**
105
+
106
+ ```bash
107
+ npx myop push # Uploads updated component to the same componentId
108
+ ```
109
+
110
+ Remove or comment out `enableLocalDev()` to go back to loading from the Myop cloud.
111
+
112
+ **Multiple components:**
113
+
114
+ ```bash
115
+ mkdir -p components && cd components
116
+ npx myop pull <sidebar-id> -o sidebar/index.html
117
+ npx myop pull <chart-id> -o chart/index.html
118
+ npx myop dev -m # Monorepo mode — select which components to serve
119
+ ```
120
+
10
121
  ## When This Skill Activates
11
122
 
12
123
  - `@myop/vue` is in `package.json` dependencies
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myop/cli",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "Myop cli",
5
5
  "type": "module",
6
6
  "repository": {