@wix/dev-machine-monitor 1.0.4 → 1.0.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 CHANGED
@@ -10,4 +10,7 @@ monitor \
10
10
  --proxy-from http://0.0.0.0:$TASK_PORT \
11
11
  --proxy-to http://localhost:4321 \
12
12
  -- wix dev --port 4321 --base-url $BASE_URL
13
- ```
13
+ ```
14
+
15
+ [ ] - publish
16
+ [ ] - add to picasso project
@@ -0,0 +1,5 @@
1
+ import { AstroIntegration } from 'astro';
2
+
3
+ declare function clientErrorMonitor(): AstroIntegration;
4
+
5
+ export { clientErrorMonitor };
@@ -0,0 +1,259 @@
1
+ // lib/integration.ts
2
+ var ErrorOverlay = class _ErrorOverlay {
3
+ static getOverlayHTML() {
4
+ const html = `
5
+ <style>
6
+ :root {
7
+ --bg: #0f1724;
8
+ --card: #0b1220;
9
+ --accent: #7dd3fc;
10
+ --muted: #94a3b8;
11
+ --glass: rgba(255, 255, 255, 0.04);
12
+ --radius: 16px;
13
+ color-scheme: light dark;
14
+ }
15
+ * {
16
+ box-sizing: border-box;
17
+ }
18
+ html,
19
+ body {
20
+ height: 100%;
21
+ }
22
+ body {
23
+ margin: 0;
24
+ font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI",
25
+ Roboto, "Helvetica Neue", Arial;
26
+ background: radial-gradient(
27
+ 1200px 600px at 10% 10%,
28
+ rgba(125, 211, 252, 0.06),
29
+ transparent
30
+ ),
31
+ linear-gradient(180deg, var(--bg), #071025 80%);
32
+ color: #e6eef8;
33
+ -webkit-font-smoothing: antialiased;
34
+ -moz-osx-font-smoothing: grayscale;
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ padding: 32px;
39
+ }
40
+ .card {
41
+ width: min(980px, 100%);
42
+ background: linear-gradient(
43
+ 180deg,
44
+ rgba(255, 255, 255, 0.02),
45
+ rgba(255, 255, 255, 0.01)
46
+ );
47
+ border: 1px solid rgba(255, 255, 255, 0.04);
48
+ border-radius: var(--radius);
49
+ padding: 32px;
50
+ display: grid;
51
+ grid-template-columns: 300px 1fr;
52
+ gap: 24px;
53
+ align-items: center;
54
+ box-shadow: 0 8px 40px rgba(2, 6, 23, 0.6);
55
+ }
56
+ .illustration {
57
+ display: flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+ }
61
+ .badge {
62
+ background: var(--glass);
63
+ padding: 14px;
64
+ border-radius: 14px;
65
+ text-align: center;
66
+ }
67
+ .code {
68
+ font-weight: 700;
69
+ font-size: 48px;
70
+ letter-spacing: -2px;
71
+ color: var(--accent);
72
+ display: block;
73
+ }
74
+ h1 {
75
+ margin: 0 0 6px 0;
76
+ font-size: 20px;
77
+ }
78
+ p.lead {
79
+ margin: 0;
80
+ color: var(--muted);
81
+ }
82
+ .actions {
83
+ margin-top: 18px;
84
+ display: flex;
85
+ gap: 12px;
86
+ flex-wrap: wrap;
87
+ }
88
+ .btn {
89
+ background: linear-gradient(
90
+ 180deg,
91
+ rgba(255, 255, 255, 0.03),
92
+ rgba(255, 255, 255, 0.01)
93
+ );
94
+ border: 1px solid rgba(255, 255, 255, 0.05);
95
+ padding: 10px 14px;
96
+ border-radius: 12px;
97
+ cursor: pointer;
98
+ font-weight: 600;
99
+ color: inherit;
100
+ text-decoration: none;
101
+ display: inline-flex;
102
+ align-items: center;
103
+ gap: 10px;
104
+ }
105
+ .btn.primary {
106
+ background: linear-gradient(180deg, var(--accent), #4ecfe8);
107
+ color: #032;
108
+ box-shadow: 0 6px 18px rgba(125, 211, 252, 0.08);
109
+ }
110
+ @media (max-width: 720px) {
111
+ .card {
112
+ grid-template-columns: 1fr;
113
+ padding: 20px;
114
+ }
115
+ .illustration {
116
+ order: -1;
117
+ }
118
+ }
119
+ .wobble {
120
+ transform-origin: center;
121
+ animation: wob 6s ease-in-out infinite;
122
+ }
123
+ @keyframes wob {
124
+ 0% {
125
+ transform: rotate(-3deg);
126
+ }
127
+ 50% {
128
+ transform: rotate(3deg);
129
+ }
130
+ 100% {
131
+ transform: rotate(-3deg);
132
+ }
133
+ }
134
+ </style>
135
+ <main class="card">
136
+ <div class="illustration">
137
+ <div class="badge">
138
+ <svg
139
+ width="160"
140
+ height="160"
141
+ viewBox="0 0 64 64"
142
+ fill="none"
143
+ xmlns="http://www.w3.org/2000/svg"
144
+ class="wobble"
145
+ role="img"
146
+ aria-hidden="true"
147
+ >
148
+ <rect
149
+ x="6"
150
+ y="10"
151
+ width="52"
152
+ height="36"
153
+ rx="6"
154
+ fill="rgba(125,211,252,0.06)"
155
+ stroke="rgba(125,211,252,0.12)"
156
+ />
157
+ <circle cx="20" cy="28" r="4" fill="rgba(125,211,252,0.18)" />
158
+ <rect
159
+ x="32"
160
+ y="24"
161
+ width="16"
162
+ height="6"
163
+ rx="2"
164
+ fill="rgba(125,211,252,0.22)"
165
+ />
166
+ <path
167
+ d="M18 46c2-3 6-5 10-5s8 2 10 5"
168
+ stroke="rgba(255,255,255,0.06)"
169
+ stroke-width="1.5"
170
+ stroke-linecap="round"
171
+ />
172
+ <path
173
+ d="M42 20l6-6"
174
+ stroke="rgba(255,255,255,0.06)"
175
+ stroke-width="2"
176
+ stroke-linecap="round"
177
+ />
178
+ </svg>
179
+ </div>
180
+ </div>
181
+
182
+ <section>
183
+ <span class="code" id="err-code">Build Error Occurred</span>
184
+ <h1 id="err-title">We failed to build Your project</h1>
185
+ <p class="lead">
186
+ We hit an unexpected error while trying to build your project.
187
+ Use an AI to get it fixed automatically.
188
+ </p>
189
+ <div class="actions">
190
+ <a class="btn primary" id="homeBtn" onClick="fixWithAI()">Fix with AI</a>
191
+ </div>
192
+ </section>
193
+ </main>
194
+ `;
195
+ return html;
196
+ }
197
+ constructor(error) {
198
+ console.error("monitor:error", error);
199
+ const overlay = document.createElement("div");
200
+ overlay.innerHTML = _ErrorOverlay.getOverlayHTML();
201
+ window.fixWithAI = function() {
202
+ window.parent?.postMessage(
203
+ {
204
+ type: "clientError",
205
+ clientErrorData: {
206
+ errorType: "build",
207
+ message: error.message || "Build/Runtime error occured",
208
+ stack: error.stack || error.message || "No error details available"
209
+ }
210
+ },
211
+ "*"
212
+ );
213
+ };
214
+ return overlay;
215
+ }
216
+ };
217
+ function clientErrorMonitor() {
218
+ return {
219
+ name: "@wix/dev-machine-monitor",
220
+ hooks: {
221
+ async "astro:config:setup"({ command, updateConfig }) {
222
+ if (command != "dev") {
223
+ return;
224
+ }
225
+ updateConfig({
226
+ vite: {
227
+ plugins: [
228
+ customErrorOverlayPlugin()
229
+ ]
230
+ }
231
+ });
232
+ }
233
+ }
234
+ };
235
+ }
236
+ function customErrorOverlayPlugin() {
237
+ return {
238
+ name: "custom-error-overlay",
239
+ transform(code, id, opts = {}) {
240
+ if (opts?.ssr) {
241
+ return;
242
+ }
243
+ if (!id.includes("vite/dist/client/client.mjs")) {
244
+ return;
245
+ }
246
+ return patchOverlay(code);
247
+ }
248
+ };
249
+ }
250
+ function patchOverlay(code) {
251
+ return code.replace("class ErrorOverlay", getOverlayCode() + "\nclass OldErrorOverlay");
252
+ }
253
+ function getOverlayCode() {
254
+ return `${ErrorOverlay.toString()}
255
+ var ErrorOverlay = _ErrorOverlay;`;
256
+ }
257
+ export {
258
+ clientErrorMonitor
259
+ };