@appstrata/dev 0.1.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/README.md +164 -0
- package/dist/completion-notification.d.ts +22 -0
- package/dist/completion-notification.d.ts.map +1 -0
- package/dist/completion-notification.js +184 -0
- package/dist/completion-notification.js.map +1 -0
- package/dist/dev-overlay.css +450 -0
- package/dist/dev-overlay.d.ts +56 -0
- package/dist/dev-overlay.d.ts.map +1 -0
- package/dist/dev-overlay.js +371 -0
- package/dist/dev-overlay.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/intercepting-transport.d.ts +11 -0
- package/dist/intercepting-transport.d.ts.map +1 -0
- package/dist/intercepting-transport.js +31 -0
- package/dist/intercepting-transport.js.map +1 -0
- package/dist/load-config.d.ts +42 -0
- package/dist/load-config.d.ts.map +1 -0
- package/dist/load-config.js +87 -0
- package/dist/load-config.js.map +1 -0
- package/dist/logging-hmr.d.ts +20 -0
- package/dist/logging-hmr.d.ts.map +1 -0
- package/dist/logging-hmr.js +28 -0
- package/dist/logging-hmr.js.map +1 -0
- package/dist/mock-init.d.ts +9 -0
- package/dist/mock-init.d.ts.map +1 -0
- package/dist/mock-init.js +171 -0
- package/dist/mock-init.js.map +1 -0
- package/dist/mock-player.d.ts +117 -0
- package/dist/mock-player.d.ts.map +1 -0
- package/dist/mock-player.js +132 -0
- package/dist/mock-player.js.map +1 -0
- package/dist/mock-services.d.ts +32 -0
- package/dist/mock-services.d.ts.map +1 -0
- package/dist/mock-services.js +141 -0
- package/dist/mock-services.js.map +1 -0
- package/dist/player/index.html +22 -0
- package/dist/player/main.d.ts +10 -0
- package/dist/player/main.d.ts.map +1 -0
- package/dist/player/main.js +352 -0
- package/dist/player/main.js.map +1 -0
- package/dist/player/styles.css +80 -0
- package/dist/plugin.d.ts +103 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +292 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types.d.ts +376 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +75 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared dev overlay UI.
|
|
3
|
+
*
|
|
4
|
+
* Creates a hover-reveal drawer (status, title, mode, auto-zoom, resolution,
|
|
5
|
+
* message stats) and a messenger-style message popup. Used by both the
|
|
6
|
+
* standalone iframe player and the embedded Vite-plugin player.
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="vite/client" />
|
|
9
|
+
import overlayCSS from './dev-overlay.css?raw';
|
|
10
|
+
const ROOT_ID = '__appstrata-dev-root';
|
|
11
|
+
const STYLE_ID = '__appstrata-dev-overlay-styles';
|
|
12
|
+
const DEFAULT_WIDTH = 1920;
|
|
13
|
+
const DEFAULT_HEIGHT = 1080;
|
|
14
|
+
const MAX_MESSAGES = 200;
|
|
15
|
+
function formatModeText(ctx, relayUrl) {
|
|
16
|
+
const modeEnv = `Mode: ${ctx.mode || "development"} · Env: ${ctx.environment || "development"}`;
|
|
17
|
+
return relayUrl ? `Relay → ${relayUrl} · ${modeEnv}` : modeEnv;
|
|
18
|
+
}
|
|
19
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
20
|
+
// Clipboard text formatter
|
|
21
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
22
|
+
function formatMessageLine(entry) {
|
|
23
|
+
const msg = entry.message;
|
|
24
|
+
const dir = entry.direction === 'app-to-host' ? 'App → Host' : 'Host → App';
|
|
25
|
+
const parts = [
|
|
26
|
+
`${formatTime(entry.timestamp)} | ${dir}`,
|
|
27
|
+
`type=${msg?.type ?? ''}`,
|
|
28
|
+
];
|
|
29
|
+
if (msg?.requestId)
|
|
30
|
+
parts.push(`id=${msg.requestId}`);
|
|
31
|
+
if (msg?.op !== undefined)
|
|
32
|
+
parts.push(`op=${msg.op}`);
|
|
33
|
+
if (msg?.ok !== undefined)
|
|
34
|
+
parts.push(`ok=${msg.ok}`);
|
|
35
|
+
if (msg?.ok === false && msg?.error?.code)
|
|
36
|
+
parts.push(`error=${msg.error.code}`);
|
|
37
|
+
if (msg?.name !== undefined)
|
|
38
|
+
parts.push(`name=${msg.name}`);
|
|
39
|
+
return parts.join(' | ');
|
|
40
|
+
}
|
|
41
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
42
|
+
// JSON tree renderer
|
|
43
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
44
|
+
function formatTime(ts) {
|
|
45
|
+
const d = new Date(ts);
|
|
46
|
+
const hh = String(d.getHours()).padStart(2, "0");
|
|
47
|
+
const mm = String(d.getMinutes()).padStart(2, "0");
|
|
48
|
+
const ss = String(d.getSeconds()).padStart(2, "0");
|
|
49
|
+
const ms = String(d.getMilliseconds()).padStart(3, "0");
|
|
50
|
+
return `${hh}:${mm}:${ss}.${ms}`;
|
|
51
|
+
}
|
|
52
|
+
function escapeHtml(str) {
|
|
53
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
54
|
+
}
|
|
55
|
+
function renderJsonValue(value, depth) {
|
|
56
|
+
if (value === null)
|
|
57
|
+
return `<span class="json-null">null</span>`;
|
|
58
|
+
if (value === undefined)
|
|
59
|
+
return `<span class="json-null">undefined</span>`;
|
|
60
|
+
switch (typeof value) {
|
|
61
|
+
case "string":
|
|
62
|
+
return `<span class="json-string">"${escapeHtml(value)}"</span>`;
|
|
63
|
+
case "number":
|
|
64
|
+
return `<span class="json-number">${value}</span>`;
|
|
65
|
+
case "boolean":
|
|
66
|
+
return `<span class="json-boolean">${value}</span>`;
|
|
67
|
+
case "object":
|
|
68
|
+
if (Array.isArray(value))
|
|
69
|
+
return renderJsonArray(value, depth);
|
|
70
|
+
return renderJsonObject(value, depth);
|
|
71
|
+
default:
|
|
72
|
+
return `<span class="json-string">${escapeHtml(String(value))}</span>`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function renderJsonObject(obj, depth) {
|
|
76
|
+
const keys = Object.keys(obj);
|
|
77
|
+
if (keys.length === 0)
|
|
78
|
+
return `<span class="json-bracket">{}</span>`;
|
|
79
|
+
const indent = '<span class="json-indent"></span>'.repeat(depth + 1);
|
|
80
|
+
const closingIndent = '<span class="json-indent"></span>'.repeat(depth);
|
|
81
|
+
const collapsed = depth > 0 ? " json-collapsed" : "";
|
|
82
|
+
let html = `<span class="json-node${collapsed}">`;
|
|
83
|
+
html += `<span class="json-line"><span class="json-toggle">${depth > 0 ? "\u25B6" : "\u25BC"}</span><span class="json-bracket">{</span></span>`;
|
|
84
|
+
html += `<span class="json-children">`;
|
|
85
|
+
keys.forEach((key, i) => {
|
|
86
|
+
const comma = i < keys.length - 1 ? "," : "";
|
|
87
|
+
html += `<span class="json-line">${indent}<span class="json-key">"${escapeHtml(key)}"</span>: ${renderJsonValue(obj[key], depth + 1)}${comma}</span>`;
|
|
88
|
+
});
|
|
89
|
+
html += `<span class="json-line">${closingIndent}<span class="json-bracket">}</span></span>`;
|
|
90
|
+
html += `</span>`;
|
|
91
|
+
html += `<span class="json-summary">{${keys.length} keys}</span>`;
|
|
92
|
+
html += `</span>`;
|
|
93
|
+
return html;
|
|
94
|
+
}
|
|
95
|
+
function renderJsonArray(arr, depth) {
|
|
96
|
+
if (arr.length === 0)
|
|
97
|
+
return `<span class="json-bracket">[]</span>`;
|
|
98
|
+
const indent = '<span class="json-indent"></span>'.repeat(depth + 1);
|
|
99
|
+
const closingIndent = '<span class="json-indent"></span>'.repeat(depth);
|
|
100
|
+
const collapsed = depth > 0 ? " json-collapsed" : "";
|
|
101
|
+
let html = `<span class="json-node${collapsed}">`;
|
|
102
|
+
html += `<span class="json-line"><span class="json-toggle">${depth > 0 ? "\u25B6" : "\u25BC"}</span><span class="json-bracket">[</span></span>`;
|
|
103
|
+
html += `<span class="json-children">`;
|
|
104
|
+
arr.forEach((item, i) => {
|
|
105
|
+
const comma = i < arr.length - 1 ? "," : "";
|
|
106
|
+
html += `<span class="json-line">${indent}${renderJsonValue(item, depth + 1)}${comma}</span>`;
|
|
107
|
+
});
|
|
108
|
+
html += `<span class="json-line">${closingIndent}<span class="json-bracket">]</span></span>`;
|
|
109
|
+
html += `</span>`;
|
|
110
|
+
html += `<span class="json-summary">[${arr.length} items]</span>`;
|
|
111
|
+
html += `</span>`;
|
|
112
|
+
return html;
|
|
113
|
+
}
|
|
114
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
115
|
+
// Overlay factory
|
|
116
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
117
|
+
export function createDevOverlay(options) {
|
|
118
|
+
const { container, measureElement, context, injectStyles = true, relay, } = options;
|
|
119
|
+
let dropLogMessages = options.dropLogMessages ?? false;
|
|
120
|
+
let targetWidth = context.viewportWidth || DEFAULT_WIDTH;
|
|
121
|
+
let targetHeight = context.viewportHeight || DEFAULT_HEIGHT;
|
|
122
|
+
const relayUrl = relay?.playerUrl;
|
|
123
|
+
// ── CSS injection (embedded player) ────────────────────────────────
|
|
124
|
+
if (injectStyles && !document.getElementById(STYLE_ID)) {
|
|
125
|
+
const style = document.createElement('style');
|
|
126
|
+
style.id = STYLE_ID;
|
|
127
|
+
style.textContent = overlayCSS;
|
|
128
|
+
document.head.appendChild(style);
|
|
129
|
+
}
|
|
130
|
+
// ── DOM construction ───────────────────────────────────────────────
|
|
131
|
+
const root = document.createElement('div');
|
|
132
|
+
root.id = ROOT_ID;
|
|
133
|
+
const overlay = document.createElement('div');
|
|
134
|
+
overlay.className = 'player-overlay';
|
|
135
|
+
const header = document.createElement('div');
|
|
136
|
+
header.className = 'player-header';
|
|
137
|
+
const statusIndicator = document.createElement('div');
|
|
138
|
+
statusIndicator.className = 'status-indicator';
|
|
139
|
+
statusIndicator.title = 'Active';
|
|
140
|
+
const titleEl = document.createElement('span');
|
|
141
|
+
titleEl.className = 'player-title';
|
|
142
|
+
titleEl.textContent = 'AppStrata Dev Player';
|
|
143
|
+
const modeEl = document.createElement('span');
|
|
144
|
+
modeEl.className = 'player-mode';
|
|
145
|
+
modeEl.textContent = formatModeText(context, relayUrl);
|
|
146
|
+
const autoZoomEl = document.createElement('span');
|
|
147
|
+
autoZoomEl.className = 'header-auto-zoom';
|
|
148
|
+
const resolutionEl = document.createElement('span');
|
|
149
|
+
resolutionEl.className = 'header-resolution';
|
|
150
|
+
header.append(statusIndicator, titleEl, modeEl, autoZoomEl, resolutionEl);
|
|
151
|
+
overlay.appendChild(header);
|
|
152
|
+
// ── Message stats bar ─────────────────────────────────────────────
|
|
153
|
+
const messageLog = [];
|
|
154
|
+
let statsAppToHost = 0;
|
|
155
|
+
let statsHostToApp = 0;
|
|
156
|
+
const messageStats = document.createElement('div');
|
|
157
|
+
messageStats.className = 'message-stats';
|
|
158
|
+
if (relay) {
|
|
159
|
+
const relayIndicator = document.createElement('div');
|
|
160
|
+
relayIndicator.className = 'message-stat';
|
|
161
|
+
relayIndicator.innerHTML = `<div class="message-status-dot"></div><span class="message-stat-label">Relay Active</span>`;
|
|
162
|
+
messageStats.appendChild(relayIndicator);
|
|
163
|
+
}
|
|
164
|
+
const appToHostStat = document.createElement('div');
|
|
165
|
+
appToHostStat.className = 'message-stat clickable';
|
|
166
|
+
appToHostStat.innerHTML = `<span class="message-stat-label">App \u2192 Host:</span><span class="message-stat-value">0</span>`;
|
|
167
|
+
messageStats.appendChild(appToHostStat);
|
|
168
|
+
const hostToAppStat = document.createElement('div');
|
|
169
|
+
hostToAppStat.className = 'message-stat clickable';
|
|
170
|
+
hostToAppStat.innerHTML = `<span class="message-stat-label">Host \u2192 App:</span><span class="message-stat-value">0</span>`;
|
|
171
|
+
messageStats.appendChild(hostToAppStat);
|
|
172
|
+
let droppedValueEl = null;
|
|
173
|
+
if (relay) {
|
|
174
|
+
const droppedStat = document.createElement('div');
|
|
175
|
+
droppedStat.className = 'message-stat clickable';
|
|
176
|
+
droppedStat.innerHTML = `<span class="message-stat-label">Dropped:</span><span class="message-stat-value">0</span>`;
|
|
177
|
+
messageStats.appendChild(droppedStat);
|
|
178
|
+
droppedValueEl = droppedStat.querySelector('.message-stat-value');
|
|
179
|
+
droppedStat.addEventListener('click', showPopup);
|
|
180
|
+
}
|
|
181
|
+
appToHostStat.addEventListener('click', showPopup);
|
|
182
|
+
hostToAppStat.addEventListener('click', showPopup);
|
|
183
|
+
const appToHostValueEl = appToHostStat.querySelector('.message-stat-value');
|
|
184
|
+
const hostToAppValueEl = hostToAppStat.querySelector('.message-stat-value');
|
|
185
|
+
overlay.appendChild(messageStats);
|
|
186
|
+
// ── Message popup (dynamically created) ────────────────────────────
|
|
187
|
+
const popupOverlay = document.createElement('div');
|
|
188
|
+
popupOverlay.className = 'msg-popup-overlay';
|
|
189
|
+
popupOverlay.style.display = 'none';
|
|
190
|
+
const popup = document.createElement('div');
|
|
191
|
+
popup.className = 'msg-popup';
|
|
192
|
+
const popupHeader = document.createElement('div');
|
|
193
|
+
popupHeader.className = 'msg-popup-header';
|
|
194
|
+
const popupTitle = document.createElement('span');
|
|
195
|
+
popupTitle.className = 'msg-popup-title';
|
|
196
|
+
popupTitle.textContent = 'Protocol Messages';
|
|
197
|
+
const copyAllBtn = document.createElement('button');
|
|
198
|
+
copyAllBtn.className = 'msg-popup-copy-all';
|
|
199
|
+
copyAllBtn.textContent = 'Copy all';
|
|
200
|
+
const popupClose = document.createElement('button');
|
|
201
|
+
popupClose.className = 'msg-popup-close';
|
|
202
|
+
popupClose.innerHTML = '×';
|
|
203
|
+
popupHeader.append(popupTitle, copyAllBtn, popupClose);
|
|
204
|
+
const popupBody = document.createElement('div');
|
|
205
|
+
popupBody.className = 'msg-popup-body';
|
|
206
|
+
popup.append(popupHeader, popupBody);
|
|
207
|
+
popupOverlay.appendChild(popup);
|
|
208
|
+
copyAllBtn.addEventListener('click', () => {
|
|
209
|
+
if (messageLog.length === 0)
|
|
210
|
+
return;
|
|
211
|
+
const text = messageLog.map(formatMessageLine).join('\n');
|
|
212
|
+
navigator.clipboard.writeText(text);
|
|
213
|
+
copyAllBtn.textContent = 'Copied!';
|
|
214
|
+
setTimeout(() => { copyAllBtn.textContent = 'Copy all'; }, 1500);
|
|
215
|
+
});
|
|
216
|
+
popupOverlay.addEventListener('click', (e) => {
|
|
217
|
+
if (e.target === e.currentTarget)
|
|
218
|
+
hidePopup();
|
|
219
|
+
});
|
|
220
|
+
popupClose.addEventListener('click', hidePopup);
|
|
221
|
+
// ── Resize toast ──────────────────────────────────────────────────
|
|
222
|
+
const resizeInfo = document.createElement('div');
|
|
223
|
+
resizeInfo.className = 'resize-info';
|
|
224
|
+
root.append(overlay, resizeInfo, popupOverlay);
|
|
225
|
+
container.prepend(root);
|
|
226
|
+
// ── Helpers ────────────────────────────────────────────────────────
|
|
227
|
+
let resizeHideTimer = null;
|
|
228
|
+
function resolutionMarkup() {
|
|
229
|
+
const ew = Math.round(measureElement.offsetWidth);
|
|
230
|
+
const eh = Math.round(measureElement.offsetHeight);
|
|
231
|
+
return (`Target: <span class="res-value">${targetWidth} \u00d7 ${targetHeight}</span>` +
|
|
232
|
+
`<span class="res-separator">\u2502</span>` +
|
|
233
|
+
`Effective: <span class="res-value">${ew} \u00d7 ${eh}</span>`);
|
|
234
|
+
}
|
|
235
|
+
function updateResolution() {
|
|
236
|
+
const html = resolutionMarkup();
|
|
237
|
+
resolutionEl.innerHTML = html;
|
|
238
|
+
resizeInfo.innerHTML = html;
|
|
239
|
+
}
|
|
240
|
+
function updateAutoZoom(mode) {
|
|
241
|
+
const label = mode || 'none';
|
|
242
|
+
autoZoomEl.innerHTML = `Auto zoom: <span class="res-value">${label}</span>`;
|
|
243
|
+
}
|
|
244
|
+
function updateContext(ctx) {
|
|
245
|
+
modeEl.textContent = formatModeText(ctx, relayUrl);
|
|
246
|
+
targetWidth = ctx.viewportWidth || DEFAULT_WIDTH;
|
|
247
|
+
targetHeight = ctx.viewportHeight || DEFAULT_HEIGHT;
|
|
248
|
+
updateResolution();
|
|
249
|
+
updateAutoZoom(ctx.autoZoom);
|
|
250
|
+
}
|
|
251
|
+
function setCompleted() {
|
|
252
|
+
statusIndicator.classList.add('completed');
|
|
253
|
+
statusIndicator.title = 'Completed';
|
|
254
|
+
}
|
|
255
|
+
function logMessage(direction, message) {
|
|
256
|
+
const msg = message;
|
|
257
|
+
if (dropLogMessages && (msg?.type === 'REQUEST' || msg?.type === 'RESPONSE') && msg?.op === 'log')
|
|
258
|
+
return;
|
|
259
|
+
messageLog.push({
|
|
260
|
+
timestamp: Date.now(),
|
|
261
|
+
direction,
|
|
262
|
+
message: typeof message === 'object' && message !== null ? structuredClone(message) : message,
|
|
263
|
+
});
|
|
264
|
+
while (messageLog.length > MAX_MESSAGES)
|
|
265
|
+
messageLog.shift();
|
|
266
|
+
if (direction === 'app-to-host') {
|
|
267
|
+
statsAppToHost++;
|
|
268
|
+
appToHostValueEl.textContent = String(statsAppToHost);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
statsHostToApp++;
|
|
272
|
+
hostToAppValueEl.textContent = String(statsHostToApp);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function setDroppedCount(count) {
|
|
276
|
+
if (droppedValueEl)
|
|
277
|
+
droppedValueEl.textContent = String(count);
|
|
278
|
+
}
|
|
279
|
+
function setDropLogMessages(value) {
|
|
280
|
+
dropLogMessages = value;
|
|
281
|
+
}
|
|
282
|
+
// ── Popup show / hide ─────────────────────────────────────────────
|
|
283
|
+
function showPopup() {
|
|
284
|
+
if (messageLog.length === 0) {
|
|
285
|
+
popupBody.innerHTML = `<div class="msg-popup-empty">No messages yet</div>`;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
popupBody.innerHTML = messageLog
|
|
289
|
+
.map((entry) => {
|
|
290
|
+
const dirClass = entry.direction;
|
|
291
|
+
const dirLabel = entry.direction === "app-to-host" ? "App \u2192 Host" : "Host \u2192 App";
|
|
292
|
+
const msgType = entry.message?.type || "UNKNOWN";
|
|
293
|
+
return `
|
|
294
|
+
<div class="msg-row ${dirClass}">
|
|
295
|
+
<div class="msg-bubble">
|
|
296
|
+
<div class="msg-meta">
|
|
297
|
+
<span class="msg-direction">${dirLabel}</span>
|
|
298
|
+
<span class="msg-type">${escapeHtml(msgType)}</span>
|
|
299
|
+
<span class="msg-time">${formatTime(entry.timestamp)}</span>
|
|
300
|
+
</div>
|
|
301
|
+
<div class="msg-json">${renderJsonValue(entry.message, 0)}</div>
|
|
302
|
+
</div>
|
|
303
|
+
</div>`;
|
|
304
|
+
})
|
|
305
|
+
.join("");
|
|
306
|
+
}
|
|
307
|
+
popupOverlay.style.display = 'flex';
|
|
308
|
+
requestAnimationFrame(() => {
|
|
309
|
+
popupBody.scrollTop = popupBody.scrollHeight;
|
|
310
|
+
});
|
|
311
|
+
wireJsonToggles(popupBody);
|
|
312
|
+
}
|
|
313
|
+
function hidePopup() {
|
|
314
|
+
popupOverlay.style.display = 'none';
|
|
315
|
+
}
|
|
316
|
+
function wireJsonToggles(el) {
|
|
317
|
+
el.querySelectorAll('.json-toggle').forEach((toggle) => {
|
|
318
|
+
toggle.addEventListener('click', (e) => {
|
|
319
|
+
e.stopPropagation();
|
|
320
|
+
const node = toggle.closest('.json-node');
|
|
321
|
+
if (!node)
|
|
322
|
+
return;
|
|
323
|
+
const isCollapsed = node.classList.contains('json-collapsed');
|
|
324
|
+
node.classList.toggle('json-collapsed');
|
|
325
|
+
toggle.textContent = isCollapsed ? '\u25BC' : '\u25B6';
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
el.querySelectorAll('.json-summary').forEach((summary) => {
|
|
329
|
+
summary.addEventListener('click', (e) => {
|
|
330
|
+
e.stopPropagation();
|
|
331
|
+
const node = summary.closest('.json-node');
|
|
332
|
+
if (!node)
|
|
333
|
+
return;
|
|
334
|
+
node.classList.remove('json-collapsed');
|
|
335
|
+
const toggle = node.querySelector('.json-toggle');
|
|
336
|
+
if (toggle)
|
|
337
|
+
toggle.textContent = '\u25BC';
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
function flashResizeToast() {
|
|
342
|
+
updateResolution();
|
|
343
|
+
resizeInfo.classList.add('visible');
|
|
344
|
+
if (resizeHideTimer)
|
|
345
|
+
clearTimeout(resizeHideTimer);
|
|
346
|
+
resizeHideTimer = setTimeout(() => resizeInfo.classList.remove('visible'), 800);
|
|
347
|
+
}
|
|
348
|
+
function destroy() {
|
|
349
|
+
if (resizeHideTimer)
|
|
350
|
+
clearTimeout(resizeHideTimer);
|
|
351
|
+
root.remove();
|
|
352
|
+
const styleEl = document.getElementById(STYLE_ID);
|
|
353
|
+
if (styleEl)
|
|
354
|
+
styleEl.remove();
|
|
355
|
+
}
|
|
356
|
+
// ── Initial state ──────────────────────────────────────────────────
|
|
357
|
+
updateAutoZoom(context.autoZoom);
|
|
358
|
+
requestAnimationFrame(updateResolution);
|
|
359
|
+
return {
|
|
360
|
+
updateResolution,
|
|
361
|
+
updateContext,
|
|
362
|
+
setCompleted,
|
|
363
|
+
flashResizeToast,
|
|
364
|
+
logMessage,
|
|
365
|
+
setDroppedCount,
|
|
366
|
+
setDropLogMessages,
|
|
367
|
+
overlayContentEl: overlay,
|
|
368
|
+
destroy,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=dev-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-overlay.js","sourceRoot":"","sources":["../src/dev-overlay.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qCAAqC;AAErC,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAG/C,MAAM,OAAO,GAAG,sBAAsB,CAAC;AACvC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AAalD,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,SAAS,cAAc,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
1
|
+
/**
|
|
2
|
+
* @appstrata/dev - Development tools for AppStrata Digital Signage SDK.
|
|
3
|
+
*
|
|
4
|
+
* This package provides:
|
|
5
|
+
* - Vite plugin for mock player injection
|
|
6
|
+
* - Standalone mock player
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { appstrata, type AppStrataPluginOptions } from "./plugin.js";
|
|
11
|
+
export { defineConfig, DEFAULT_CONTEXT, DEFAULT_LIFECYCLE, type AppStrataConfig, type AppConfig, type AutoZoomMode, type DevConfig, type DevContextConfig, type LifecycleConfig, type ConfigurationConfig, type InputDefinition, type BaseInput, type TextInput, type ColorInput, type BooleanInput, type NumberInput, type SelectInput, type RangeInput, type FontInput, type ImageInput, } from "./types.js";
|
|
12
|
+
export { createMockPlayer, buildAppContext, buildDevice, buildCapabilityServices, resolveCapabilities, type MockPlayerConfig, } from "./mock-player.js";
|
|
13
|
+
export { loadConfig, type LoadConfigResult } from "./load-config.js";
|
|
14
|
+
export { createMockStorage, createMockProxy, createMockMediaCache, createMockStatic, } from "./mock-services.js";
|
|
15
|
+
export { showCompletionNotification } from "./completion-notification.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,SAAS,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @appstrata/dev - Development tools for AppStrata Digital Signage SDK.
|
|
3
|
+
*
|
|
4
|
+
* This package provides:
|
|
5
|
+
* - Vite plugin for mock player injection
|
|
6
|
+
* - Standalone mock player
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
// Main Vite plugin export
|
|
11
|
+
export { appstrata } from "./plugin.js";
|
|
12
|
+
// Configuration helpers and types
|
|
13
|
+
export { defineConfig, DEFAULT_CONTEXT, DEFAULT_LIFECYCLE, } from "./types.js";
|
|
14
|
+
// Mock player utilities (for programmatic use)
|
|
15
|
+
export { createMockPlayer, buildAppContext, buildDevice, buildCapabilityServices, resolveCapabilities, } from "./mock-player.js";
|
|
16
|
+
// Config loading
|
|
17
|
+
export { loadConfig } from "./load-config.js";
|
|
18
|
+
// Mock services (for custom setups)
|
|
19
|
+
export { createMockStorage, createMockProxy, createMockMediaCache, createMockStatic, } from "./mock-services.js";
|
|
20
|
+
// Completion notification (for custom integrations)
|
|
21
|
+
export { showCompletionNotification } from "./completion-notification.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0BAA0B;AAC1B,OAAO,EAAE,SAAS,EAA+B,MAAM,aAAa,CAAC;AAErE,kCAAkC;AAClC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,iBAAiB,GAkBlB,MAAM,YAAY,CAAC;AAEpB,+CAA+C;AAC/C,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,mBAAmB,GAEpB,MAAM,kBAAkB,CAAC;AAE1B,iBAAiB;AACjB,OAAO,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AAErE,oCAAoC;AACpC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,oDAAoD;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport interceptor for dev tooling.
|
|
3
|
+
*
|
|
4
|
+
* Wraps any Transport and calls a callback for every message flowing
|
|
5
|
+
* through it, without altering delivery. Used to feed the dev-overlay
|
|
6
|
+
* message stats in both embedded and iframe player modes.
|
|
7
|
+
*/
|
|
8
|
+
import type { Transport, ProtocolMessage } from "@appstrata/protocol";
|
|
9
|
+
export type MessageDirection = "app-to-host" | "host-to-app";
|
|
10
|
+
export declare function createInterceptingTransport(inner: Transport, onIntercept: (message: ProtocolMessage, direction: MessageDirection) => void): Transport;
|
|
11
|
+
//# sourceMappingURL=intercepting-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intercepting-transport.d.ts","sourceRoot":"","sources":["../src/intercepting-transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,CAAC;AAI7D,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,KAAK,IAAI,GAC3E,SAAS,CAqBX"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport interceptor for dev tooling.
|
|
3
|
+
*
|
|
4
|
+
* Wraps any Transport and calls a callback for every message flowing
|
|
5
|
+
* through it, without altering delivery. Used to feed the dev-overlay
|
|
6
|
+
* message stats in both embedded and iframe player modes.
|
|
7
|
+
*/
|
|
8
|
+
const HOST_TO_APP_TYPES = new Set(["READY", "RESPONSE", "EVENT"]);
|
|
9
|
+
export function createInterceptingTransport(inner, onIntercept) {
|
|
10
|
+
return {
|
|
11
|
+
send(message) {
|
|
12
|
+
onIntercept(message, "host-to-app");
|
|
13
|
+
inner.send(message);
|
|
14
|
+
},
|
|
15
|
+
onMessage(handler) {
|
|
16
|
+
return inner.onMessage((message) => {
|
|
17
|
+
// In same-window mode the host's own sends echo back through
|
|
18
|
+
// onMessage. Use the message type to distinguish: host-to-app
|
|
19
|
+
// types were already intercepted in send(), so skip them here.
|
|
20
|
+
if (!HOST_TO_APP_TYPES.has(message.type)) {
|
|
21
|
+
onIntercept(message, "app-to-host");
|
|
22
|
+
}
|
|
23
|
+
handler(message);
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
close() {
|
|
27
|
+
inner.close();
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=intercepting-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intercepting-transport.js","sourceRoot":"","sources":["../src/intercepting-transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvF,MAAM,UAAU,2BAA2B,CACzC,KAAgB,EAChB,WAA4E;IAE5E,OAAO;QACL,IAAI,CAAC,OAAO;YACV,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC;QACD,SAAS,CAAC,OAAO;YACf,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;gBACjC,6DAA6D;gBAC7D,8DAA8D;gBAC9D,+DAA+D;gBAC/D,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzC,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;gBACtC,CAAC;gBACD,OAAO,CAAC,OAAO,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,KAAK;YACH,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file loader for the AppStrata CLI.
|
|
3
|
+
*
|
|
4
|
+
* Supports two config formats:
|
|
5
|
+
*
|
|
6
|
+
* - `appstrata.config.ts` — TypeScript with `defineConfig()` for type checking
|
|
7
|
+
* and IDE autocomplete. Requires `@appstrata/dev` as a devDependency in the
|
|
8
|
+
* project, OR works without any dependencies (the CLI provides the import
|
|
9
|
+
* via a jiti alias).
|
|
10
|
+
*
|
|
11
|
+
* - `appstrata.config.json` — Plain JSON, no imports or dependencies needed.
|
|
12
|
+
* Works from any directory with zero setup.
|
|
13
|
+
*
|
|
14
|
+
* ## Why jiti + alias for .ts configs?
|
|
15
|
+
*
|
|
16
|
+
* Config files do `import { defineConfig } from "@appstrata/dev"`. When the
|
|
17
|
+
* user doesn't have `@appstrata/dev` installed in their project, jiti can't
|
|
18
|
+
* resolve it from the config file's directory. We alias `@appstrata/dev` to
|
|
19
|
+
* this module's own directory so the import resolves to the CLI's bundled
|
|
20
|
+
* copy. When the user DOES have it installed, the alias is harmless —
|
|
21
|
+
* `defineConfig` is just an identity function either way.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import type { AppStrataConfig } from "./types.js";
|
|
26
|
+
export interface LoadConfigResult {
|
|
27
|
+
config: AppStrataConfig;
|
|
28
|
+
/** Absolute path of the file that was actually loaded. */
|
|
29
|
+
filePath: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Load an AppStrata config file (`.ts` or `.json`).
|
|
33
|
+
*
|
|
34
|
+
* When `configFile` points to a `.ts` file that doesn't exist, falls back
|
|
35
|
+
* to a `.json` file with the same base name.
|
|
36
|
+
*
|
|
37
|
+
* @param configFile - Path to the config file (absolute or relative to `root`).
|
|
38
|
+
* @param root - Directory to resolve relative paths against. Defaults to `process.cwd()`.
|
|
39
|
+
* @returns The parsed config and the path of the file that was loaded, or `null`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadConfig(configFile: string, root?: string): Promise<LoadConfigResult | null>;
|
|
42
|
+
//# sourceMappingURL=load-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../src/load-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAWlD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAqBlC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file loader for the AppStrata CLI.
|
|
3
|
+
*
|
|
4
|
+
* Supports two config formats:
|
|
5
|
+
*
|
|
6
|
+
* - `appstrata.config.ts` — TypeScript with `defineConfig()` for type checking
|
|
7
|
+
* and IDE autocomplete. Requires `@appstrata/dev` as a devDependency in the
|
|
8
|
+
* project, OR works without any dependencies (the CLI provides the import
|
|
9
|
+
* via a jiti alias).
|
|
10
|
+
*
|
|
11
|
+
* - `appstrata.config.json` — Plain JSON, no imports or dependencies needed.
|
|
12
|
+
* Works from any directory with zero setup.
|
|
13
|
+
*
|
|
14
|
+
* ## Why jiti + alias for .ts configs?
|
|
15
|
+
*
|
|
16
|
+
* Config files do `import { defineConfig } from "@appstrata/dev"`. When the
|
|
17
|
+
* user doesn't have `@appstrata/dev` installed in their project, jiti can't
|
|
18
|
+
* resolve it from the config file's directory. We alias `@appstrata/dev` to
|
|
19
|
+
* this module's own directory so the import resolves to the CLI's bundled
|
|
20
|
+
* copy. When the user DOES have it installed, the alias is harmless —
|
|
21
|
+
* `defineConfig` is just an identity function either way.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import * as path from "node:path";
|
|
26
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
import { createJiti } from "jiti";
|
|
29
|
+
const OWN_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
const jiti = createJiti(import.meta.url, {
|
|
31
|
+
interopDefault: true,
|
|
32
|
+
alias: {
|
|
33
|
+
"@appstrata/dev": OWN_DIR,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Load an AppStrata config file (`.ts` or `.json`).
|
|
38
|
+
*
|
|
39
|
+
* When `configFile` points to a `.ts` file that doesn't exist, falls back
|
|
40
|
+
* to a `.json` file with the same base name.
|
|
41
|
+
*
|
|
42
|
+
* @param configFile - Path to the config file (absolute or relative to `root`).
|
|
43
|
+
* @param root - Directory to resolve relative paths against. Defaults to `process.cwd()`.
|
|
44
|
+
* @returns The parsed config and the path of the file that was loaded, or `null`.
|
|
45
|
+
*/
|
|
46
|
+
export async function loadConfig(configFile, root) {
|
|
47
|
+
const configPath = path.isAbsolute(configFile)
|
|
48
|
+
? configFile
|
|
49
|
+
: path.resolve(root ?? process.cwd(), configFile);
|
|
50
|
+
if (configPath.endsWith(".json")) {
|
|
51
|
+
return loadJsonConfig(configPath);
|
|
52
|
+
}
|
|
53
|
+
// Try given file if it exists, otherwise fall back to .json
|
|
54
|
+
if (existsSync(configPath)) {
|
|
55
|
+
return loadTsConfig(configPath);
|
|
56
|
+
}
|
|
57
|
+
// Fall back to .json with the same base name
|
|
58
|
+
const jsonPath = configPath.replace(/\.[^.]+$/, ".json");
|
|
59
|
+
if (existsSync(jsonPath)) {
|
|
60
|
+
return loadJsonConfig(jsonPath);
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function loadJsonConfig(configPath) {
|
|
65
|
+
try {
|
|
66
|
+
const content = readFileSync(configPath, "utf-8");
|
|
67
|
+
return { config: JSON.parse(content), filePath: configPath };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error(`[AppStrata] Error loading ${configPath}:`, error);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function loadTsConfig(configPath) {
|
|
75
|
+
try {
|
|
76
|
+
// jiti caches modules in Node's require.cache (shared globally).
|
|
77
|
+
// Delete the entry so re-imports read the file from disk.
|
|
78
|
+
delete jiti.cache[configPath];
|
|
79
|
+
const config = await jiti.import(configPath);
|
|
80
|
+
return { config, filePath: configPath };
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(`[AppStrata] Error loading ${configPath}:`, error);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMapp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