wepost 1.0.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/LICENSE +21 -0
- package/README.md +508 -0
- package/dist/engine.d.ts +15 -0
- package/dist/history.d.ts +8 -0
- package/dist/index.d.ts +11 -0
- package/dist/styles.d.ts +1 -0
- package/dist/ui.d.ts +19 -0
- package/dist/wepost.es.js +462 -0
- package/dist/wepost.umd.js +299 -0
- package/package.json +35 -0
- package/proxy/server.js +38 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var v = (o, t, e) => t in o ? y(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var h = (o, t, e) => (v(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
async function E(o) {
|
|
5
|
+
let t = o.url, e = { ...o.headers };
|
|
6
|
+
o.proxyUrl && (e["x-wepost-target"] = t, t = o.proxyUrl);
|
|
7
|
+
const a = {
|
|
8
|
+
method: o.method,
|
|
9
|
+
headers: e
|
|
10
|
+
};
|
|
11
|
+
!["GET", "HEAD"].includes(o.method) && o.body && (a.body = JSON.stringify(o.body), e["Content-Type"] || (e["Content-Type"] = "application/json"));
|
|
12
|
+
const i = await fetch(t, a), r = await i.text();
|
|
13
|
+
return {
|
|
14
|
+
status: i.status,
|
|
15
|
+
statusText: i.statusText,
|
|
16
|
+
data: r,
|
|
17
|
+
headers: Object.fromEntries(i.headers.entries())
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const b = "wepost_history";
|
|
21
|
+
function B(o) {
|
|
22
|
+
const t = f();
|
|
23
|
+
t.length > 0 && t[0].url === o.url && t[0].method === o.method ? t[0] = o : t.unshift(o), t.length > 10 && t.pop(), localStorage.setItem(b, JSON.stringify(t));
|
|
24
|
+
}
|
|
25
|
+
function f() {
|
|
26
|
+
try {
|
|
27
|
+
const o = localStorage.getItem(b);
|
|
28
|
+
return o ? JSON.parse(o) : [];
|
|
29
|
+
} catch {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function L() {
|
|
34
|
+
return `
|
|
35
|
+
:host {
|
|
36
|
+
/* Default: Dark Theme */
|
|
37
|
+
--bg: #1e1e1e;
|
|
38
|
+
--bg-light: #2d2d2d;
|
|
39
|
+
--border: #3c3c3c;
|
|
40
|
+
--text: #d4d4d4;
|
|
41
|
+
--text-muted: #858585;
|
|
42
|
+
--accent: #007acc;
|
|
43
|
+
--accent-hover: #005f9e;
|
|
44
|
+
--success: #89d185;
|
|
45
|
+
--error: #f48771;
|
|
46
|
+
--font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Light Theme Overrides */
|
|
50
|
+
.light-theme {
|
|
51
|
+
--bg: #ffffff;
|
|
52
|
+
--bg-light: #f3f3f3;
|
|
53
|
+
--border: #e0e0e0;
|
|
54
|
+
--text: #333333;
|
|
55
|
+
--text-muted: #666666;
|
|
56
|
+
--accent: #007acc;
|
|
57
|
+
--accent-hover: #005f9e;
|
|
58
|
+
--success: #2ea44f;
|
|
59
|
+
--error: #cf222e;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
* { box-sizing: border-box; }
|
|
63
|
+
|
|
64
|
+
/* Floating Button (FAB) */
|
|
65
|
+
.wp-fab {
|
|
66
|
+
position: fixed;
|
|
67
|
+
bottom: 20px;
|
|
68
|
+
right: 20px;
|
|
69
|
+
width: 50px;
|
|
70
|
+
height: 50px;
|
|
71
|
+
background: var(--accent);
|
|
72
|
+
color: white;
|
|
73
|
+
border-radius: 50%;
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
font-family: var(--font);
|
|
78
|
+
font-weight: bold;
|
|
79
|
+
cursor: move;
|
|
80
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
81
|
+
z-index: 999999;
|
|
82
|
+
user-select: none;
|
|
83
|
+
touch-action: none;
|
|
84
|
+
}
|
|
85
|
+
.wp-fab:hover {
|
|
86
|
+
background: var(--accent-hover);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Panel UI */
|
|
90
|
+
.wp-panel {
|
|
91
|
+
position: fixed;
|
|
92
|
+
bottom: 80px;
|
|
93
|
+
right: 20px;
|
|
94
|
+
width: 450px;
|
|
95
|
+
max-width: calc(100vw - 40px);
|
|
96
|
+
background: var(--bg);
|
|
97
|
+
color: var(--text);
|
|
98
|
+
border: 1px solid var(--border);
|
|
99
|
+
border-radius: 8px;
|
|
100
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
|
101
|
+
font-family: var(--font);
|
|
102
|
+
font-size: 13px;
|
|
103
|
+
z-index: 999998;
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
opacity: 0;
|
|
107
|
+
pointer-events: none;
|
|
108
|
+
transform: translateY(10px);
|
|
109
|
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
110
|
+
max-height: calc(100vh - 100px);
|
|
111
|
+
touch-action: none;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.wp-panel.open {
|
|
115
|
+
opacity: 1;
|
|
116
|
+
pointer-events: all;
|
|
117
|
+
transform: translateY(0);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.wp-header {
|
|
121
|
+
display: flex;
|
|
122
|
+
justify-content: space-between;
|
|
123
|
+
align-items: center;
|
|
124
|
+
padding: 10px 15px;
|
|
125
|
+
border-bottom: 1px solid var(--border);
|
|
126
|
+
background: var(--bg-light);
|
|
127
|
+
border-radius: 8px 8px 0 0;
|
|
128
|
+
cursor: move;
|
|
129
|
+
user-select: none;
|
|
130
|
+
}
|
|
131
|
+
.wp-header h3 {
|
|
132
|
+
margin: 0;
|
|
133
|
+
font-size: 14px;
|
|
134
|
+
font-weight: 600;
|
|
135
|
+
pointer-events: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.wp-actions {
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
gap: 12px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* Theme Toggle Button */
|
|
145
|
+
.wp-theme-toggle {
|
|
146
|
+
background: none;
|
|
147
|
+
border: none;
|
|
148
|
+
color: var(--text-muted);
|
|
149
|
+
font-size: 14px;
|
|
150
|
+
cursor: pointer;
|
|
151
|
+
padding: 2px 6px;
|
|
152
|
+
border-radius: 4px;
|
|
153
|
+
}
|
|
154
|
+
.wp-theme-toggle:hover {
|
|
155
|
+
color: var(--text);
|
|
156
|
+
background: var(--border);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.wp-header #wp-close {
|
|
160
|
+
background: none;
|
|
161
|
+
border: none;
|
|
162
|
+
color: var(--text-muted);
|
|
163
|
+
font-size: 20px;
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
}
|
|
166
|
+
.wp-header #wp-close:hover { color: var(--text); }
|
|
167
|
+
|
|
168
|
+
/* Layout Request Bar */
|
|
169
|
+
.wp-row {
|
|
170
|
+
display: flex;
|
|
171
|
+
gap: 8px;
|
|
172
|
+
padding: 15px;
|
|
173
|
+
border-bottom: 1px solid var(--border);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
input, select, textarea {
|
|
177
|
+
background: var(--bg-light);
|
|
178
|
+
color: var(--text);
|
|
179
|
+
border: 1px solid var(--border);
|
|
180
|
+
padding: 8px;
|
|
181
|
+
border-radius: 4px;
|
|
182
|
+
font-family: monospace;
|
|
183
|
+
outline: none;
|
|
184
|
+
font-size: 14px;
|
|
185
|
+
}
|
|
186
|
+
input:focus, select:focus, textarea:focus {
|
|
187
|
+
border-color: var(--accent);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#wp-method { width: 90px; }
|
|
191
|
+
#wp-url { flex: 1; min-width: 0; }
|
|
192
|
+
|
|
193
|
+
.btn-primary {
|
|
194
|
+
background: var(--accent);
|
|
195
|
+
color: white;
|
|
196
|
+
border: none;
|
|
197
|
+
padding: 8px 16px;
|
|
198
|
+
border-radius: 4px;
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
font-weight: 600;
|
|
201
|
+
}
|
|
202
|
+
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
|
|
203
|
+
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
204
|
+
|
|
205
|
+
.wp-section {
|
|
206
|
+
padding: 10px 15px;
|
|
207
|
+
border-bottom: 1px solid var(--border);
|
|
208
|
+
display: flex;
|
|
209
|
+
flex-direction: column;
|
|
210
|
+
gap: 5px;
|
|
211
|
+
}
|
|
212
|
+
.wp-section label {
|
|
213
|
+
font-size: 11px;
|
|
214
|
+
text-transform: uppercase;
|
|
215
|
+
color: var(--text-muted);
|
|
216
|
+
font-weight: bold;
|
|
217
|
+
display: flex;
|
|
218
|
+
justify-content: space-between;
|
|
219
|
+
align-items: center;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* Copy Button Style */
|
|
223
|
+
.btn-copy {
|
|
224
|
+
background: none;
|
|
225
|
+
border: none;
|
|
226
|
+
color: var(--accent);
|
|
227
|
+
font-size: 11px;
|
|
228
|
+
cursor: pointer;
|
|
229
|
+
padding: 2px 6px;
|
|
230
|
+
border-radius: 3px;
|
|
231
|
+
text-transform: none;
|
|
232
|
+
font-weight: 600;
|
|
233
|
+
}
|
|
234
|
+
.btn-copy:hover {
|
|
235
|
+
background: var(--bg-light);
|
|
236
|
+
text-decoration: underline;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
textarea {
|
|
240
|
+
height: 65px;
|
|
241
|
+
resize: vertical;
|
|
242
|
+
font-size: 12px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.wp-response-section {
|
|
246
|
+
flex: 1;
|
|
247
|
+
overflow: hidden;
|
|
248
|
+
border-bottom: none;
|
|
249
|
+
}
|
|
250
|
+
#wp-response {
|
|
251
|
+
margin: 0;
|
|
252
|
+
background: var(--bg-light);
|
|
253
|
+
padding: 10px;
|
|
254
|
+
border-radius: 4px;
|
|
255
|
+
overflow-y: auto;
|
|
256
|
+
max-height: 200px;
|
|
257
|
+
font-family: monospace;
|
|
258
|
+
font-size: 12px;
|
|
259
|
+
white-space: pre-wrap;
|
|
260
|
+
word-break: break-all;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.status-ok { color: var(--success); }
|
|
264
|
+
.status-err { color: var(--error); }
|
|
265
|
+
|
|
266
|
+
/* RESPONSIVE / MOBILE MODE (Screen < 500px) */
|
|
267
|
+
@media (max-width: 500px) {
|
|
268
|
+
.wp-panel {
|
|
269
|
+
width: 100% !important;
|
|
270
|
+
max-width: 100% !important;
|
|
271
|
+
left: 0 !important;
|
|
272
|
+
right: 0 !important;
|
|
273
|
+
bottom: 0 !important;
|
|
274
|
+
top: 0 !important;
|
|
275
|
+
max-height: 100vh !important;
|
|
276
|
+
border-radius: 0;
|
|
277
|
+
transform: translateY(100%);
|
|
278
|
+
}
|
|
279
|
+
.wp-panel.open {
|
|
280
|
+
transform: translateY(0);
|
|
281
|
+
}
|
|
282
|
+
.wp-header {
|
|
283
|
+
border-radius: 0;
|
|
284
|
+
cursor: default;
|
|
285
|
+
}
|
|
286
|
+
.wp-row {
|
|
287
|
+
flex-direction: column;
|
|
288
|
+
gap: 10px;
|
|
289
|
+
}
|
|
290
|
+
#wp-method { width: 100%; }
|
|
291
|
+
#wp-url { width: 100%; }
|
|
292
|
+
.btn-primary { width: 100%; }
|
|
293
|
+
#wp-response {
|
|
294
|
+
max-height: calc(100vh - 380px);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
`;
|
|
298
|
+
}
|
|
299
|
+
class I {
|
|
300
|
+
constructor(t) {
|
|
301
|
+
h(this, "container");
|
|
302
|
+
h(this, "shadow");
|
|
303
|
+
h(this, "config");
|
|
304
|
+
h(this, "isOpen", !1);
|
|
305
|
+
h(this, "isLightMode", !1);
|
|
306
|
+
this.config = t, this.container = document.createElement("div"), this.container.id = "wepost-container", this.shadow = this.container.attachShadow({ mode: "closed" }), this.isLightMode = localStorage.getItem("wepost_theme") === "light", this.render(), this.applyTheme();
|
|
307
|
+
}
|
|
308
|
+
mount() {
|
|
309
|
+
document.getElementById("wepost-container") || (document.body.appendChild(this.container), this.attachEvents(), this.loadLastRequest());
|
|
310
|
+
}
|
|
311
|
+
unmount() {
|
|
312
|
+
this.container.remove();
|
|
313
|
+
}
|
|
314
|
+
render() {
|
|
315
|
+
this.shadow.innerHTML = `
|
|
316
|
+
<style>${L()}</style>
|
|
317
|
+
<div class="wp-fab" id="wp-btn">WP</div>
|
|
318
|
+
<div class="wp-panel" id="wp-panel">
|
|
319
|
+
<div class="wp-header" id="wp-header">
|
|
320
|
+
<h3>WEPOST DevTools</h3>
|
|
321
|
+
<div class="wp-actions">
|
|
322
|
+
<button id="wp-theme-btn" class="wp-theme-toggle">☀️ Light</button>
|
|
323
|
+
<button id="wp-close">×</button>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
<div class="wp-row">
|
|
327
|
+
<select id="wp-method">
|
|
328
|
+
<option>GET</option><option>POST</option><option>PUT</option>
|
|
329
|
+
<option>PATCH</option><option>DELETE</option>
|
|
330
|
+
</select>
|
|
331
|
+
<input type="text" id="wp-url" placeholder="https://api.example.com/v1/data" value="${this.config.defaultUrl || ""}" />
|
|
332
|
+
<button id="wp-send" class="btn-primary">Send</button>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="wp-section">
|
|
335
|
+
<label>Headers (JSON)</label>
|
|
336
|
+
<textarea id="wp-headers" placeholder='{"Authorization": "Bearer token", "Content-Type": "application/json"}'></textarea>
|
|
337
|
+
</div>
|
|
338
|
+
<div class="wp-section">
|
|
339
|
+
<label>Body (JSON)</label>
|
|
340
|
+
<textarea id="wp-body" placeholder='{"key": "value"}'></textarea>
|
|
341
|
+
</div>
|
|
342
|
+
<div class="wp-section wp-response-section">
|
|
343
|
+
<label>
|
|
344
|
+
<span>Response <span id="wp-status"></span></span>
|
|
345
|
+
<button id="wp-copy-btn" class="btn-copy">📋 Copy</button>
|
|
346
|
+
</label>
|
|
347
|
+
<pre id="wp-response">Awaiting request...</pre>
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
`;
|
|
351
|
+
}
|
|
352
|
+
attachEvents() {
|
|
353
|
+
const t = this.shadow.getElementById("wp-btn"), e = this.shadow.getElementById("wp-close"), a = this.shadow.getElementById("wp-theme-btn"), i = this.shadow.getElementById("wp-copy-btn"), r = this.shadow.getElementById("wp-send"), s = this.shadow.getElementById("wp-panel"), c = this.shadow.getElementById("wp-header");
|
|
354
|
+
this.makeElementDraggable(t, t, !0), this.makeElementDraggable(s, c, !1), t.addEventListener("click", () => {
|
|
355
|
+
if (t.getAttribute("data-dragged") === "true") {
|
|
356
|
+
t.removeAttribute("data-dragged");
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
this.isOpen = !this.isOpen, this.isOpen ? (s.classList.add("open"), this.syncPanelPosition()) : s.classList.remove("open");
|
|
360
|
+
}), a.addEventListener("click", (l) => {
|
|
361
|
+
l.stopPropagation(), this.isLightMode = !this.isLightMode, localStorage.setItem("wepost_theme", this.isLightMode ? "light" : "dark"), this.applyTheme();
|
|
362
|
+
}), i.addEventListener("click", () => {
|
|
363
|
+
const p = this.shadow.getElementById("wp-response").textContent || "";
|
|
364
|
+
p && p !== "Awaiting request..." && p !== "Loading..." && navigator.clipboard.writeText(p).then(() => {
|
|
365
|
+
i.textContent = "✅ Copied!", setTimeout(() => {
|
|
366
|
+
i.textContent = "📋 Copy";
|
|
367
|
+
}, 2e3);
|
|
368
|
+
}).catch((d) => {
|
|
369
|
+
console.error("Failed to copy text: ", d);
|
|
370
|
+
});
|
|
371
|
+
}), e.addEventListener("click", (l) => {
|
|
372
|
+
l.stopPropagation(), this.isOpen = !1, s.classList.remove("open");
|
|
373
|
+
}), r.addEventListener("click", () => this.handleRequest());
|
|
374
|
+
}
|
|
375
|
+
applyTheme() {
|
|
376
|
+
const t = this.shadow.getElementById("wp-panel"), e = this.shadow.getElementById("wp-theme-btn");
|
|
377
|
+
!t || !e || (this.isLightMode ? (t.classList.add("light-theme"), e.textContent = "🌙 Dark") : (t.classList.remove("light-theme"), e.textContent = "☀️ Light"));
|
|
378
|
+
}
|
|
379
|
+
syncPanelPosition() {
|
|
380
|
+
if (window.innerWidth <= 500)
|
|
381
|
+
return;
|
|
382
|
+
const t = this.shadow.getElementById("wp-btn"), e = this.shadow.getElementById("wp-panel"), a = t.getBoundingClientRect();
|
|
383
|
+
e.style.top = "auto", e.style.left = "auto", e.style.right = `${window.innerWidth - a.right}px`, e.style.bottom = `${window.innerHeight - a.top + 10}px`;
|
|
384
|
+
}
|
|
385
|
+
makeElementDraggable(t, e, a) {
|
|
386
|
+
let i = 0, r = 0, s = !1, c = 0, l = 0;
|
|
387
|
+
const p = (n) => {
|
|
388
|
+
if (!a && window.innerWidth <= 500)
|
|
389
|
+
return;
|
|
390
|
+
const m = n.target.tagName.toLowerCase();
|
|
391
|
+
if (n.target.id === "wp-close" || n.target.id === "wp-theme-btn" || n.target.id === "wp-copy-btn" || m === "input" || m === "select" || m === "textarea")
|
|
392
|
+
return;
|
|
393
|
+
s = !1;
|
|
394
|
+
const g = "touches" in n ? n.touches[0].clientX : n.clientX, w = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
395
|
+
c = g, l = w;
|
|
396
|
+
const x = t.getBoundingClientRect();
|
|
397
|
+
i = g - x.left, r = w - x.top, document.addEventListener("mousemove", d, { passive: !1 }), document.addEventListener("mouseup", u), document.addEventListener("touchmove", d, { passive: !1 }), document.addEventListener("touchend", u);
|
|
398
|
+
}, d = (n) => {
|
|
399
|
+
const m = "touches" in n ? n.touches[0].clientX : n.clientX, g = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
400
|
+
if (!s && (Math.abs(m - c) > 5 || Math.abs(g - l) > 5) && (s = !0, a && t.setAttribute("data-dragged", "true")), s) {
|
|
401
|
+
n.cancelable && n.preventDefault();
|
|
402
|
+
let w = m - i, x = g - r;
|
|
403
|
+
t.style.position = "fixed", t.style.left = `${w}px`, t.style.top = `${x}px`, t.style.right = "auto", t.style.bottom = "auto", a && this.isOpen && this.syncPanelPosition();
|
|
404
|
+
}
|
|
405
|
+
}, u = () => {
|
|
406
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", u), document.removeEventListener("touchmove", d), document.removeEventListener("touchend", u), s && setTimeout(() => {
|
|
407
|
+
s || t.removeAttribute("data-dragged");
|
|
408
|
+
}, 50);
|
|
409
|
+
};
|
|
410
|
+
e.addEventListener("mousedown", p), e.addEventListener("touchstart", p, { passive: !0 });
|
|
411
|
+
}
|
|
412
|
+
async handleRequest() {
|
|
413
|
+
const t = this.shadow.getElementById("wp-url").value, e = this.shadow.getElementById("wp-method").value, a = this.shadow.getElementById("wp-headers").value, i = this.shadow.getElementById("wp-body").value, r = this.shadow.getElementById("wp-status"), s = this.shadow.getElementById("wp-response"), c = this.shadow.getElementById("wp-send");
|
|
414
|
+
try {
|
|
415
|
+
c.disabled = !0, c.textContent = "Sending...", s.textContent = "Loading...", r.textContent = "", r.className = "";
|
|
416
|
+
let l = {}, p = null;
|
|
417
|
+
a && (l = JSON.parse(a)), i && (p = JSON.parse(i)), B({ url: t, method: e, headers: a, body: i });
|
|
418
|
+
const d = await E({ url: t, method: e, headers: l, body: p, proxyUrl: this.config.proxyUrl });
|
|
419
|
+
r.textContent = `${d.status} ${d.statusText}`, r.className = d.status >= 200 && d.status < 300 ? "status-ok" : "status-err";
|
|
420
|
+
try {
|
|
421
|
+
const u = JSON.parse(d.data);
|
|
422
|
+
s.textContent = JSON.stringify(u, null, 2);
|
|
423
|
+
} catch {
|
|
424
|
+
s.textContent = d.data;
|
|
425
|
+
}
|
|
426
|
+
} catch (l) {
|
|
427
|
+
r.textContent = "ERROR", r.className = "status-err", s.textContent = l.message;
|
|
428
|
+
} finally {
|
|
429
|
+
c.disabled = !1, c.textContent = "Send";
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
loadLastRequest() {
|
|
433
|
+
const t = f();
|
|
434
|
+
if (t.length > 0) {
|
|
435
|
+
const e = t[0];
|
|
436
|
+
this.shadow.getElementById("wp-url").value = e.url, this.shadow.getElementById("wp-method").value = e.method, this.shadow.getElementById("wp-headers").value = e.headers || "", this.shadow.getElementById("wp-body").value = e.body || "";
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
class k {
|
|
441
|
+
constructor(t = {}) {
|
|
442
|
+
h(this, "ui");
|
|
443
|
+
this.ui = new I(t);
|
|
444
|
+
}
|
|
445
|
+
mount() {
|
|
446
|
+
this.ui.mount();
|
|
447
|
+
}
|
|
448
|
+
unmount() {
|
|
449
|
+
this.ui.unmount();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (typeof window < "u") {
|
|
453
|
+
const o = document.currentScript || document.querySelector('script[src*="wepost"]');
|
|
454
|
+
if (o && o.getAttribute("data-auto-init") === "true") {
|
|
455
|
+
const t = o.getAttribute("data-proxy") || void 0, e = new k({ proxyUrl: t });
|
|
456
|
+
e.mount(), window.WePostInstance = e;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
export {
|
|
460
|
+
k as WePost,
|
|
461
|
+
k as default
|
|
462
|
+
};
|