ludicord 2.2.5 → 3.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.
Files changed (150) hide show
  1. package/README.md +8 -4
  2. package/dist/activity/game-loop.d.ts +16 -0
  3. package/dist/activity/game-loop.js +33 -0
  4. package/dist/activity/index.d.ts +12 -0
  5. package/dist/activity/index.js +6 -0
  6. package/dist/activity/lifecycle.d.ts +11 -0
  7. package/dist/activity/lifecycle.js +41 -0
  8. package/dist/activity/presence.d.ts +10 -0
  9. package/dist/activity/presence.js +15 -0
  10. package/dist/activity/query.d.ts +21 -0
  11. package/dist/activity/query.js +148 -0
  12. package/dist/activity/shared-state.d.ts +10 -0
  13. package/dist/activity/shared-state.js +100 -0
  14. package/dist/activity/storage.d.ts +16 -0
  15. package/dist/activity/storage.js +88 -0
  16. package/dist/api/runtime.d.ts +5 -2
  17. package/dist/api/runtime.js +53 -10
  18. package/dist/auth/client.d.ts +0 -1
  19. package/dist/auth/client.js +3 -5
  20. package/dist/auth/index.d.ts +0 -1
  21. package/dist/auth/index.js +0 -1
  22. package/dist/auth/server.d.ts +2 -1
  23. package/dist/auth/server.js +161 -16
  24. package/dist/auth/types.d.ts +5 -1
  25. package/dist/auth/types.js +0 -1
  26. package/dist/cli/index.d.ts +0 -1
  27. package/dist/cli/index.js +116 -19
  28. package/dist/cli/project-commands.d.ts +1 -5
  29. package/dist/cli/project-commands.js +14 -162
  30. package/dist/compiler/build.d.ts +10 -1
  31. package/dist/compiler/build.js +124 -16
  32. package/dist/compiler/bundle-report.d.ts +17 -0
  33. package/dist/compiler/bundle-report.js +60 -0
  34. package/dist/compiler/client-entry.d.ts +0 -1
  35. package/dist/compiler/client-entry.js +28 -4
  36. package/dist/compiler/client-tooling.d.ts +0 -1
  37. package/dist/compiler/client-tooling.js +8 -2
  38. package/dist/compiler/index.d.ts +3 -1
  39. package/dist/compiler/index.js +2 -1
  40. package/dist/compiler/scanner.d.ts +0 -1
  41. package/dist/compiler/scanner.js +59 -4
  42. package/dist/compiler/server-bundle.d.ts +1 -2
  43. package/dist/compiler/server-bundle.js +11 -2
  44. package/dist/compiler/type-generation.d.ts +0 -1
  45. package/dist/compiler/type-generation.js +2 -1
  46. package/dist/compiler/write-manifests.d.ts +0 -1
  47. package/dist/compiler/write-manifests.js +0 -1
  48. package/dist/config/defaults.d.ts +0 -1
  49. package/dist/config/defaults.js +14 -2
  50. package/dist/config/environment.d.ts +0 -1
  51. package/dist/config/environment.js +0 -1
  52. package/dist/config/index.d.ts +0 -1
  53. package/dist/config/index.js +0 -1
  54. package/dist/config/loader.d.ts +0 -1
  55. package/dist/config/loader.js +0 -1
  56. package/dist/config/project-root.d.ts +0 -1
  57. package/dist/config/project-root.js +0 -1
  58. package/dist/config/types.d.ts +25 -1
  59. package/dist/config/types.js +0 -1
  60. package/dist/discord/assets.d.ts +5 -0
  61. package/dist/discord/assets.js +29 -0
  62. package/dist/discord/data.d.ts +38 -2
  63. package/dist/discord/data.js +178 -11
  64. package/dist/discord/events.d.ts +28 -2
  65. package/dist/discord/events.js +109 -39
  66. package/dist/discord/index.d.ts +6 -5
  67. package/dist/discord/index.js +3 -3
  68. package/dist/discord/payload.d.ts +6 -0
  69. package/dist/discord/payload.js +5 -0
  70. package/dist/discord/runtime.d.ts +0 -1
  71. package/dist/discord/runtime.js +0 -1
  72. package/dist/discord/safe-area.d.ts +0 -1
  73. package/dist/discord/safe-area.js +0 -1
  74. package/dist/discord/testing.d.ts +0 -1
  75. package/dist/discord/testing.js +0 -1
  76. package/dist/index.d.ts +6 -1
  77. package/dist/index.js +3 -1
  78. package/dist/lint/index.d.ts +6 -0
  79. package/dist/lint/index.js +71 -0
  80. package/dist/manifests/types.d.ts +11 -1
  81. package/dist/manifests/types.js +0 -1
  82. package/dist/metadata/index.d.ts +13 -0
  83. package/dist/metadata/index.js +4 -0
  84. package/dist/navigation/index.d.ts +3 -1
  85. package/dist/navigation/index.js +1 -1
  86. package/dist/navigation/link.d.ts +8 -0
  87. package/dist/navigation/link.js +38 -0
  88. package/dist/router/match.d.ts +0 -1
  89. package/dist/router/match.js +0 -1
  90. package/dist/runtime/client/dev-panel.d.ts +0 -1
  91. package/dist/runtime/client/dev-panel.js +722 -38
  92. package/dist/runtime/client/embed-router.d.ts +8 -1
  93. package/dist/runtime/client/embed-router.js +116 -62
  94. package/dist/runtime/client/files.d.ts +5 -1
  95. package/dist/runtime/client/files.js +0 -1
  96. package/dist/runtime/client/minimize-card.d.ts +0 -1
  97. package/dist/runtime/client/minimize-card.js +0 -1
  98. package/dist/runtime/client/minimize.d.ts +0 -1
  99. package/dist/runtime/client/minimize.js +0 -1
  100. package/dist/runtime/client/root.d.ts +5 -3
  101. package/dist/runtime/client/root.js +28 -3
  102. package/dist/runtime/index.d.ts +1 -2
  103. package/dist/runtime/index.js +0 -1
  104. package/dist/runtime/server/dev-server.d.ts +0 -1
  105. package/dist/runtime/server/dev-server.js +187 -30
  106. package/dist/runtime/server/diagnostics.d.ts +1 -1
  107. package/dist/runtime/server/diagnostics.js +5 -4
  108. package/dist/runtime/server/index.d.ts +0 -1
  109. package/dist/runtime/server/index.js +0 -1
  110. package/dist/runtime/server/production-server.d.ts +2 -1
  111. package/dist/runtime/server/production-server.js +145 -25
  112. package/dist/security/discord.d.ts +0 -1
  113. package/dist/security/discord.js +0 -1
  114. package/dist/security/index.d.ts +0 -1
  115. package/dist/security/index.js +0 -1
  116. package/dist/security/secret-scan.d.ts +0 -1
  117. package/dist/security/secret-scan.js +0 -1
  118. package/dist/server/discord-rest.d.ts +42 -7
  119. package/dist/server/discord-rest.js +135 -18
  120. package/dist/server/index.d.ts +7 -2
  121. package/dist/server/index.js +3 -1
  122. package/dist/server/instrumentation.d.ts +16 -0
  123. package/dist/server/instrumentation.js +3 -0
  124. package/dist/server/proxy.d.ts +21 -0
  125. package/dist/server/proxy.js +76 -0
  126. package/dist/server/session.d.ts +0 -1
  127. package/dist/server/session.js +0 -1
  128. package/dist/server/types.d.ts +0 -1
  129. package/dist/server/types.js +0 -1
  130. package/dist/sessions/cookies.d.ts +0 -1
  131. package/dist/sessions/cookies.js +0 -1
  132. package/dist/sessions/crypto.d.ts +0 -1
  133. package/dist/sessions/crypto.js +0 -1
  134. package/dist/sessions/data-store.d.ts +18 -0
  135. package/dist/sessions/data-store.js +45 -0
  136. package/dist/shared/errors.d.ts +0 -1
  137. package/dist/shared/errors.js +0 -1
  138. package/dist/testing/index.d.ts +0 -1
  139. package/dist/testing/index.js +2 -2
  140. package/dist/version.d.ts +1 -2
  141. package/dist/version.js +1 -2
  142. package/dist/ws/client.d.ts +0 -1
  143. package/dist/ws/client.js +0 -1
  144. package/dist/ws/index.d.ts +3 -2
  145. package/dist/ws/index.js +1 -1
  146. package/dist/ws/server.d.ts +5 -3
  147. package/dist/ws/server.js +65 -19
  148. package/dist/ws/shared-state.d.ts +13 -0
  149. package/dist/ws/shared-state.js +137 -0
  150. package/package.json +14 -1
@@ -1,63 +1,747 @@
1
1
  const hot = import.meta.hot;
2
+ const devToken = globalThis
3
+ .__LUDICORD_DEV_TOKEN__ ?? "";
4
+ const devHeaders = { "x-ludicord-dev-token": devToken };
5
+ document.querySelector("ludicord-devtools")?.remove();
2
6
  const host = document.createElement("ludicord-devtools");
3
7
  const shadow = host.attachShadow({ mode: "open" });
4
8
  shadow.innerHTML = `<style>
5
- :host{all:initial;font-family:Inter,ui-sans-serif,system-ui,sans-serif;color:#f4f0ff}*{box-sizing:border-box}button{font:inherit;cursor:pointer}
6
- .backdrop{position:fixed;inset:0;z-index:2147483646;background:#080712c9;display:grid;place-items:center;padding:24px;backdrop-filter:blur(8px)}
7
- .panel{width:min(960px,100%);max-height:90vh;overflow:auto;background:#14121f;border:1px solid #4c355c;border-radius:18px;box-shadow:0 30px 100px #0009}
8
- header{display:flex;align-items:center;gap:12px;padding:20px 24px;border-bottom:1px solid #30283f}.brand{color:#e9c9ff;font-weight:800;letter-spacing:-.4px}.pill{color:#b3a4c9;background:#272033;padding:4px 8px;border-radius:6px;font-size:10px;letter-spacing:1.5px}
9
- .close{margin-left:auto;border:0;background:transparent;color:#b7aec8;font-size:23px}article{padding:26px}h1{font-size:22px;line-height:1.4;margin:12px 0 20px;white-space:pre-wrap;overflow-wrap:anywhere}.kind{font-size:11px;letter-spacing:1.5px;color:#ffaba8;text-transform:uppercase}
10
- .file{font:13px ui-monospace,monospace;color:#d8b8fa;overflow-wrap:anywhere}pre{font:13px/1.75 ui-monospace,SFMono-Regular,monospace;overflow:auto;max-height:45vh;background:#0d0c14;padding:20px;border:1px solid #30283f;border-radius:10px;tab-size:2;color:#ded7eb}details{margin-top:20px;color:#a79bbd}summary{cursor:pointer;font-size:13px}
11
- footer{padding:16px 24px;border-top:1px solid #30283f;display:flex;align-items:center;gap:10px;font-size:12px;color:#9a8fab}footer button{border:1px solid #514160;background:#251d33;color:#eadcf8;padding:8px 12px;border-radius:7px}.count{margin-right:auto}.badge{position:fixed;bottom:18px;left:18px;z-index:2147483647;background:#20172c;border:1px solid #b778e3;border-radius:100px;color:#f4eaff;padding:10px 15px;box-shadow:0 8px 30px #0006;font-size:12px}.hidden{display:none!important}
12
- @media(max-width:600px){.backdrop{padding:10px}header,article,footer{padding:16px}h1{font-size:18px}pre{font-size:11px}}
13
- </style><div class="backdrop hidden"><section class="panel" role="dialog" aria-modal="true" aria-label="Ludicord development error"><header><span class="brand">◈ ludicord</span><span class="pill">DEVELOPMENT</span><button class="close" aria-label="Dismiss error">×</button></header><article><span class="kind"></span><h1></h1><div class="file"></div><pre class="frame"></pre><details><summary>Call stack</summary><pre class="stack"></pre></details></article><footer><span class="count"></span><button class="previous" aria-label="Previous error">←</button><button class="next" aria-label="Next error">→</button><button class="copy">Copy location</button><button class="retry">Retry</button></footer></section></div><button class="badge hidden"></button>`;
9
+ :host{
10
+ all:initial;
11
+ --bg:#000000;
12
+ --surface:#0A0A0A;
13
+ --surface-2:#131313;
14
+ --border:#1F1F1F;
15
+ --border-soft:#171717;
16
+ --text:#FAFAFA;
17
+ --text-dim:#8C8C8C;
18
+ --text-faint:#565656;
19
+ --danger:#FF4438;
20
+ --danger-dim:rgba(255,68,56,.13);
21
+ --danger-line:rgba(255,68,56,.35);
22
+ --kw:#8AB4FF;
23
+ --str:#7EE7A8;
24
+ --num:#FFB454;
25
+ font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
26
+ color:var(--text)
27
+ }
28
+ *{box-sizing:border-box}
29
+ button{font:inherit;cursor:pointer;background:none;border:none;color:inherit}
30
+
31
+ .veil{
32
+ position:fixed;
33
+ inset:0;
34
+ z-index:2147483646;
35
+ display:grid;
36
+ place-items:center;
37
+ padding:24px;
38
+ background:var(--bg)
39
+ }
40
+
41
+ .glow{
42
+ position:absolute;
43
+ inset:0;
44
+ pointer-events:none;
45
+ background:radial-gradient(620px circle at 50% 40%,rgba(255,68,56,.16),transparent 70%)
46
+ }
47
+
48
+ .sheet{
49
+ position:relative;
50
+ width:min(680px,100%);
51
+ max-height:88vh;
52
+ display:flex;
53
+ flex-direction:column;
54
+ overflow:hidden;
55
+ background:var(--surface);
56
+ border:1px solid var(--border);
57
+ border-radius:20px;
58
+ box-shadow:0 30px 80px rgba(0,0,0,.65);
59
+ animation:ludi-in .26s cubic-bezier(.2,.7,.3,1) both
60
+ }
61
+ @keyframes ludi-in{from{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}
62
+ @media(prefers-reduced-motion:reduce){.sheet{animation:none}}
63
+
64
+ .notch{
65
+ display:flex;
66
+ align-items:center;
67
+ gap:8px;
68
+ padding:14px 16px;
69
+ flex:0 0 auto
70
+ }
71
+
72
+ .kindpill{
73
+ display:flex;
74
+ align-items:center;
75
+ gap:7px;
76
+ background:var(--danger-dim);
77
+ color:var(--danger);
78
+ border:1px solid var(--danger-line);
79
+ border-radius:999px;
80
+ padding:6px 12px 6px 10px;
81
+ font-size:12.5px;
82
+ font-weight:500
83
+ }
84
+ .kindpill .dot{width:6px;height:6px;border-radius:50%;background:var(--danger);flex-shrink:0}
85
+
86
+ .spacer{flex:1}
87
+
88
+ .pager{
89
+ display:flex;
90
+ align-items:center;
91
+ gap:2px;
92
+ background:var(--surface-2);
93
+ border:1px solid var(--border-soft);
94
+ border-radius:999px;
95
+ padding:3px;
96
+ font-family:'IBM Plex Mono',ui-monospace,monospace;
97
+ font-size:12px;
98
+ color:var(--text-dim)
99
+ }
100
+ .pagerbtn{width:24px;height:24px;display:grid;place-items:center;border-radius:999px;color:var(--text-dim)}
101
+ .pagerbtn:hover{background:var(--border);color:var(--text)}
102
+ .pagerbtn:disabled{cursor:default;opacity:.35;background:none;color:var(--text-dim)}
103
+ .pagernum{padding:0 6px;white-space:nowrap}
104
+ .pagernum .cur{color:var(--text)}
105
+
106
+ .dismiss{
107
+ width:26px;height:26px;
108
+ display:grid;place-items:center;
109
+ border-radius:999px;
110
+ color:var(--text-dim);
111
+ font-size:17px
112
+ }
113
+ .dismiss:hover{background:var(--surface-2);color:var(--text)}
114
+
115
+ .body{padding:6px 24px 20px;overflow:auto;flex:1 1 auto}
116
+
117
+ .message{
118
+ font-size:20px;
119
+ line-height:1.45;
120
+ font-weight:600;
121
+ letter-spacing:-.01em;
122
+ margin:2px 0 14px;
123
+ white-space:pre-wrap;
124
+ overflow-wrap:anywhere
125
+ }
126
+
127
+ .source{
128
+ display:inline-flex;
129
+ align-items:center;
130
+ gap:6px;
131
+ font-family:'IBM Plex Mono',ui-monospace,monospace;
132
+ font-size:12.5px;
133
+ color:var(--text-dim);
134
+ margin:0 0 18px;
135
+ overflow-wrap:anywhere;
136
+ text-align:left
137
+ }
138
+ .source:hover{color:var(--text)}
139
+ .source svg{flex-shrink:0;opacity:.7}
140
+ .source.static{cursor:default}
141
+ .source.static:hover{color:var(--text-dim)}
142
+ .source:disabled{cursor:default}
143
+
144
+ .frame{
145
+ border:1px solid var(--border);
146
+ border-radius:10px;
147
+ overflow:hidden;
148
+ margin:0 0 18px;
149
+ background:var(--bg)
150
+ }
151
+ .frow{display:flex;font-family:'IBM Plex Mono',ui-monospace,monospace;font-size:12.5px;line-height:1.8}
152
+ .frow .gut{width:38px;flex:0 0 auto;text-align:right;padding-right:12px;color:var(--text-faint);user-select:none}
153
+ .frow .code{flex:1;padding-right:14px;white-space:pre;overflow-x:auto}
154
+ .frow.flagged{background:var(--danger-dim);border-left:2px solid var(--danger)}
155
+ .frow.flagged .gut{padding-right:10px}
156
+ .caretline{color:var(--danger);font-weight:600}
157
+ .kw{color:var(--kw)}
158
+ .str{color:var(--str)}
159
+ .num{color:var(--num)}
160
+ .cmt{color:var(--text-faint);font-style:italic}
161
+
162
+ .stackblock{margin-bottom:6px}
163
+ .stackhead{font-size:12.5px;color:var(--text-dim);margin-bottom:8px;font-weight:500}
164
+ .stacklist{font-family:'IBM Plex Mono',ui-monospace,monospace;font-size:12px;line-height:1.85}
165
+ .srow{color:var(--text);overflow-wrap:anywhere}
166
+ .srow.lib{color:var(--text-faint)}
167
+ .ignored{
168
+ margin-top:8px;
169
+ font-size:12px;
170
+ color:var(--text-dim);
171
+ display:flex;
172
+ align-items:center;
173
+ gap:5px
174
+ }
175
+ .ignored:hover{color:var(--text)}
176
+ .ignored svg{transition:transform .15s}
177
+ .ignored.open svg{transform:rotate(90deg)}
178
+
179
+ .footer{
180
+ display:flex;
181
+ align-items:center;
182
+ gap:10px;
183
+ padding:14px 20px;
184
+ border-top:1px solid var(--border);
185
+ flex:0 0 auto
186
+ }
187
+
188
+ .feedback{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--text-dim)}
189
+ .fbbtn{width:26px;height:26px;display:grid;place-items:center;border-radius:999px;color:var(--text-dim)}
190
+ .fbbtn:hover{background:var(--surface-2);color:var(--text)}
191
+ .fbbtn.picked.up{background:rgba(126,231,168,.15);color:var(--str)}
192
+ .fbbtn.picked.down{background:var(--danger-dim);color:var(--danger)}
193
+ .fbbtn[disabled]{pointer-events:none;opacity:.4}
194
+
195
+ .action{
196
+ font-size:12.5px;
197
+ font-weight:500;
198
+ border:1px solid var(--border);
199
+ border-radius:8px;
200
+ padding:7px 13px;
201
+ color:var(--text);
202
+ transition:background .12s,border-color .12s
203
+ }
204
+ .action:hover{background:var(--surface-2);border-color:var(--text-dim)}
205
+ .action.copied{background:var(--text);color:var(--bg);border-color:var(--text)}
206
+
207
+ button:focus-visible{outline:2px solid var(--text);outline-offset:2px}
208
+ .kindpill button:focus-visible,.frow.flagged :focus-visible{outline:2px solid #fff}
209
+
210
+ .badge{
211
+ position:fixed;
212
+ bottom:18px;
213
+ left:18px;
214
+ z-index:2147483647;
215
+ height:34px;
216
+ display:flex;
217
+ align-items:stretch;
218
+ background:var(--surface);
219
+ border:1px solid var(--border);
220
+ border-radius:999px;
221
+ overflow:hidden;
222
+ box-shadow:0 10px 24px rgba(0,0,0,.5);
223
+ animation:ludi-badge-in .22s cubic-bezier(.2,.7,.3,1) both
224
+ }
225
+ @keyframes ludi-badge-in{from{opacity:0;transform:translateY(8px) scale(.96)}to{opacity:1;transform:none}}
226
+ @media(prefers-reduced-motion:reduce){.badge{animation:none}}
227
+
228
+ .badge-icon{
229
+ position:relative;
230
+ width:34px;
231
+ flex:0 0 auto;
232
+ display:grid;
233
+ place-items:center;
234
+ font-size:11px;
235
+ color:var(--text)
236
+ }
237
+ .badge-icon:hover{background:var(--surface-2)}
238
+ .badge-ring{
239
+ position:absolute;
240
+ inset:5px;
241
+ border-radius:999px;
242
+ border:1.5px solid var(--danger-line);
243
+ animation:ludi-pulse 2.4s ease-out infinite
244
+ }
245
+ [data-state="expanded"] .badge-ring{display:none}
246
+ @keyframes ludi-pulse{0%{transform:scale(.85);opacity:.8}100%{transform:scale(1.5);opacity:0}}
247
+ @media(prefers-reduced-motion:reduce){.badge-ring{animation:none}}
248
+
249
+ .badge-issues{display:flex;align-items:stretch;white-space:nowrap}
250
+ [data-state="collapsed"] .badge-issues{display:none}
251
+ .badge-issues-btn{
252
+ display:flex;
253
+ align-items:center;
254
+ gap:5px;
255
+ padding:0 9px;
256
+ font-family:'IBM Plex Mono',ui-monospace,monospace;
257
+ font-size:11px;
258
+ color:var(--danger)
259
+ }
260
+ .badge-issues-btn:hover{background:var(--surface-2)}
261
+ .badge-issues-btn .dot{width:5px;height:5px;border-radius:50%;background:var(--danger);flex-shrink:0}
262
+ .badge-collapse{
263
+ width:24px;
264
+ flex:0 0 auto;
265
+ display:grid;
266
+ place-items:center;
267
+ color:var(--text-dim);
268
+ font-size:12px
269
+ }
270
+ .badge-collapse:hover{background:var(--surface-2);color:var(--text)}
271
+ .countpop{display:inline-block;animation:ludi-count-in .22s cubic-bezier(.2,.7,.3,1) both}
272
+ @keyframes ludi-count-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
273
+ @media(prefers-reduced-motion:reduce){.countpop{animation:none}}
274
+
275
+ .hidden{display:none!important}
276
+
277
+ @media(max-width:600px){
278
+ .veil{padding:10px}
279
+ .sheet{max-height:92vh;border-radius:16px}
280
+ .notch{padding:12px 14px}
281
+ .body{padding:4px 18px 16px}
282
+ .footer{padding:12px 16px}
283
+ .message{font-size:18px}
284
+ .feedback .fbq{display:none}
285
+ }
286
+ </style>
287
+
288
+ <div class="veil hidden">
289
+ <div class="glow" aria-hidden="true"></div>
290
+ <div class="sheet" tabindex="-1" role="dialog" aria-modal="true" aria-label="Ludicord build error" aria-live="polite">
291
+ <div class="notch">
292
+ <span class="kindpill"><span class="dot"></span><span class="kindtext"></span></span>
293
+ <span class="spacer"></span>
294
+ <div class="pager">
295
+ <button class="pagerbtn prev" aria-label="Previous issue">‹</button>
296
+ <span class="pagernum"><span class="cur">1</span>/<span class="tot">1</span></span>
297
+ <button class="pagerbtn next" aria-label="Next issue">›</button>
298
+ </div>
299
+ <button class="dismiss" aria-label="Minimize error panel">–</button>
300
+ </div>
301
+
302
+ <div class="body">
303
+ <h1 class="message"></h1>
304
+
305
+ <button class="source">
306
+ <svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden="true">
307
+ <path d="M6 3H3.5A1.5 1.5 0 0 0 2 4.5v8A1.5 1.5 0 0 0 3.5 14h8a1.5 1.5 0 0 0 1.5-1.5V10M9 2h5v5M13.5 2.5 7 9" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
308
+ </svg>
309
+ <span class="sourcetext"></span>
310
+ </button>
311
+
312
+ <div class="frame"></div>
313
+
314
+ <div class="stackblock">
315
+ <div class="stackhead">Call stack</div>
316
+ <div class="stacklist"></div>
317
+ <button class="ignored hidden">
318
+ <svg width="10" height="10" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M5 3l6 5-6 5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
319
+ <span class="ignoredtext"></span>
320
+ </button>
321
+ </div>
322
+ </div>
323
+
324
+ <div class="footer">
325
+ <div class="feedback">
326
+ <span class="fbq">Was this helpful?</span>
327
+ <button class="fbbtn up" aria-label="Yes, this was helpful">
328
+ <svg width="14" height="14" viewBox="0 0 20 20" fill="none"><path d="M7 9v9H4a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3Zm0 0 4-7a2 2 0 0 1 2 2v4h4.2a1.5 1.5 0 0 1 1.47 1.79l-1.2 6A1.5 1.5 0 0 1 16 17H9a2 2 0 0 1-2-2" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg>
329
+ </button>
330
+ <button class="fbbtn down" aria-label="Not helpful">
331
+ <svg width="14" height="14" viewBox="0 0 20 20" fill="none" style="transform:rotate(180deg)"><path d="M7 9v9H4a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3Zm0 0 4-7a2 2 0 0 1 2 2v4h4.2a1.5 1.5 0 0 1 1.47 1.79l-1.2 6A1.5 1.5 0 0 1 16 17H9a2 2 0 0 1-2-2" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg>
332
+ </button>
333
+ </div>
334
+ <span class="spacer"></span>
335
+ <button class="action copy">Copy</button>
336
+ <button class="action retry">Retry</button>
337
+ </div>
338
+ </div>
339
+ </div>
340
+
341
+ <div class="badge hidden" data-state="collapsed">
342
+ <button class="badge-icon" aria-label="Toggle development error status">
343
+ <span class="badge-ring" aria-hidden="true"></span>
344
+ <span aria-hidden="true">◆</span>
345
+ </button>
346
+ <div class="badge-issues">
347
+ <button class="badge-issues-btn" aria-label="Open development error panel">
348
+ <span class="dot" aria-hidden="true"></span>
349
+ <span class="countslot"></span>
350
+ </button>
351
+ <button class="badge-collapse" aria-label="Collapse error status to icon">×</button>
352
+ </div>
353
+ </div>`;
14
354
  document.documentElement.append(host);
15
355
  const element = (selector) => shadow.querySelector(selector);
356
+ function escapeHtml(value) {
357
+ return value
358
+ .replace(/&/g, "&amp;")
359
+ .replace(/</g, "&lt;")
360
+ .replace(/>/g, "&gt;");
361
+ }
362
+ const KEYWORDS = new Set([
363
+ "async", "await", "catch", "class", "const", "default", "else",
364
+ "export", "extends", "for", "from", "function", "if", "import", "in",
365
+ "interface", "let", "new", "of", "return", "this", "throw", "try",
366
+ "type", "typeof", "var", "while",
367
+ ]);
368
+ function tokenizeCode(code) {
369
+ let html = "";
370
+ let cursor = 0;
371
+ while (cursor < code.length) {
372
+ const current = code[cursor] ?? "";
373
+ const next = code[cursor + 1] ?? "";
374
+ if (current === "/" && next === "/") {
375
+ html += `<span class="cmt">${escapeHtml(code.slice(cursor))}</span>`;
376
+ break;
377
+ }
378
+ if (current === "\"" || current === "'" || current === "`") {
379
+ const quote = current;
380
+ let end = cursor + 1;
381
+ while (end < code.length) {
382
+ if (code[end] === "\\") {
383
+ end += 2;
384
+ continue;
385
+ }
386
+ if (code[end] === quote) {
387
+ end += 1;
388
+ break;
389
+ }
390
+ end += 1;
391
+ }
392
+ html += `<span class="str">${escapeHtml(code.slice(cursor, end))}</span>`;
393
+ cursor = end;
394
+ continue;
395
+ }
396
+ const remaining = code.slice(cursor);
397
+ const number = /^(?:0[xob][0-9a-f]+|\d+(?:\.\d+)?)/i.exec(remaining)?.[0];
398
+ if (number !== undefined) {
399
+ html += `<span class="num">${escapeHtml(number)}</span>`;
400
+ cursor += number.length;
401
+ continue;
402
+ }
403
+ const identifier = /^[A-Za-z_$][A-Za-z0-9_$]*/.exec(remaining)?.[0];
404
+ if (identifier !== undefined) {
405
+ html += KEYWORDS.has(identifier)
406
+ ? `<span class="kw">${identifier}</span>`
407
+ : escapeHtml(identifier);
408
+ cursor += identifier.length;
409
+ continue;
410
+ }
411
+ html += escapeHtml(current);
412
+ cursor += 1;
413
+ }
414
+ return html || " ";
415
+ }
416
+ function renderFrame(raw) {
417
+ const rows = raw.split("\n").map((line) => {
418
+ const match = line.match(/^[ >]\s*(\d+)?\s*\|\s?(.*)$/);
419
+ if (match) {
420
+ const num = match[1] ?? "";
421
+ const content = match[2] ?? "";
422
+ const caret = num === "" && /^\s*\^+\s*$/.test(content);
423
+ return { num, content, caret };
424
+ }
425
+ return { num: "", content: line, caret: false };
426
+ });
427
+ return rows
428
+ .map((row, i) => {
429
+ const next = rows[i + 1];
430
+ const flagged = row.num !== "" && next?.caret === true;
431
+ const body = row.caret
432
+ ? `<span class="caretline">${escapeHtml(row.content)}</span>`
433
+ : tokenizeCode(row.content);
434
+ return `<div class="frow${flagged ? " flagged" : ""}"><span class="gut">${row.num}</span><span class="code">${body}</span></div>`;
435
+ })
436
+ .join("");
437
+ }
438
+ function renderStack(raw) {
439
+ const lines = raw.split("\n").map((l) => l.trim()).filter(Boolean);
440
+ const isLib = (l) => /node_modules|react-dom|react\/|webpack|vite|esbuild|scheduler/i.test(l);
441
+ const appLines = lines.filter((l) => !isLib(l));
442
+ const libLines = lines.filter(isLib);
443
+ const row = (l, lib) => `<div class="srow${lib ? " lib" : ""}">${escapeHtml(l)}</div>`;
444
+ return {
445
+ appHtml: appLines.map((l) => row(l, false)).join(""),
446
+ libHtml: libLines.map((l) => row(l, true)).join(""),
447
+ libCount: libLines.length,
448
+ };
449
+ }
450
+ function titleCase(kind) {
451
+ const value = kind ?? "runtime";
452
+ return value.charAt(0).toUpperCase() + value.slice(1);
453
+ }
16
454
  let issues = [];
17
455
  let index = 0;
18
456
  let dismissed = false;
457
+ let stackExpanded = false;
458
+ let copyTimer;
459
+ let badgeVisible = false;
460
+ let badgeCollapsed = false;
461
+ let lastCountShown = -1;
462
+ let lastMorphTime = 0;
463
+ function morphBadge(mutate) {
464
+ const badge = element(".badge");
465
+ const now = Date.now();
466
+ const rapid = now - lastMorphTime < 150;
467
+ lastMorphTime = now;
468
+ if (rapid) {
469
+ mutate();
470
+ return;
471
+ }
472
+ const startWidth = badge.getBoundingClientRect().width;
473
+ mutate();
474
+ const endWidth = badge.getBoundingClientRect().width;
475
+ if (Math.abs(endWidth - startWidth) < 0.5)
476
+ return;
477
+ badge.style.width = `${startWidth}px`;
478
+ void badge.offsetWidth;
479
+ badge.style.transition = "width .22s cubic-bezier(.2,.7,.3,1)";
480
+ badge.style.width = `${endWidth}px`;
481
+ const clear = () => {
482
+ badge.style.width = "";
483
+ badge.style.transition = "";
484
+ badge.removeEventListener("transitionend", clear);
485
+ };
486
+ badge.addEventListener("transitionend", clear);
487
+ }
488
+ function updateBadge(hasIssue) {
489
+ const shouldShow = hasIssue && dismissed;
490
+ const justAppeared = shouldShow && !badgeVisible;
491
+ badgeVisible = shouldShow;
492
+ element(".badge").classList.toggle("hidden", !shouldShow);
493
+ if (!shouldShow)
494
+ return;
495
+ if (issues.length !== lastCountShown)
496
+ badgeCollapsed = false;
497
+ const apply = () => {
498
+ element(".badge").dataset.state = badgeCollapsed ? "collapsed" : "expanded";
499
+ if (issues.length !== lastCountShown) {
500
+ lastCountShown = issues.length;
501
+ const count = document.createElement("span");
502
+ count.className = "countpop";
503
+ count.textContent = `${issues.length} ${issues.length === 1 ? "issue" : "issues"}`;
504
+ element(".countslot").replaceChildren(count);
505
+ }
506
+ };
507
+ if (justAppeared)
508
+ apply();
509
+ else
510
+ morphBadge(apply);
511
+ }
19
512
  function render() {
20
513
  const issue = issues[index];
21
- element(".backdrop").classList.toggle("hidden", issue === undefined || dismissed);
22
- element(".badge").classList.toggle("hidden", issue === undefined || !dismissed);
514
+ const hasIssue = issue !== undefined;
515
+ element(".veil").classList.toggle("hidden", !hasIssue || dismissed);
516
+ updateBadge(hasIssue);
517
+ if (!hasIssue)
518
+ return;
519
+ element(".kindtext").textContent = `${titleCase(issue.kind)} error`;
520
+ element(".message").textContent = issue.message;
521
+ const sourceButton = element(".source");
522
+ if (issue.file) {
523
+ element(".sourcetext").textContent =
524
+ `${issue.file}:${issue.line ?? 1}:${issue.column ?? 1}`;
525
+ sourceButton.classList.remove("static");
526
+ sourceButton.disabled = false;
527
+ }
528
+ else {
529
+ element(".sourcetext").textContent = "No source file for this error";
530
+ sourceButton.classList.add("static");
531
+ sourceButton.disabled = true;
532
+ }
533
+ element(".frame").innerHTML = renderFrame(issue.frame ??
534
+ "No source frame captured. Ludicord recompiles automatically when you save.");
535
+ const stack = [issue.stack, issue.componentStack === undefined
536
+ ? undefined
537
+ : `React component stack\n${issue.componentStack}`]
538
+ .filter((part) => Boolean(part))
539
+ .join("\n");
540
+ const { appHtml, libHtml, libCount } = renderStack(stack || "No call stack captured.");
541
+ element(".stacklist").innerHTML = appHtml + (stackExpanded ? libHtml : "");
542
+ const ignoredButton = element(".ignored");
543
+ ignoredButton.classList.toggle("hidden", libCount === 0);
544
+ ignoredButton.classList.toggle("open", stackExpanded);
545
+ element(".ignoredtext").textContent = stackExpanded
546
+ ? "Hide ignored frames"
547
+ : `Show ${libCount} ignored ${libCount === 1 ? "frame" : "frames"}`;
548
+ element(".cur").textContent = String(index + 1);
549
+ element(".tot").textContent = String(issues.length);
550
+ element(".prev").disabled = issues.length <= 1;
551
+ element(".next").disabled = issues.length <= 1;
552
+ for (const cls of ["up", "down"]) {
553
+ const button = element(`.fbbtn.${cls}`);
554
+ button.classList.remove("picked");
555
+ button.disabled = false;
556
+ }
557
+ element(".fbq").textContent = "Was this helpful?";
558
+ if (!dismissed) {
559
+ requestAnimationFrame(() => element(".sheet").focus());
560
+ }
561
+ }
562
+ function show(next) {
563
+ issues = next;
564
+ index = Math.min(index, Math.max(0, next.length - 1));
565
+ dismissed = false;
566
+ stackExpanded = false;
567
+ render();
568
+ }
569
+ function recover() {
570
+ window.dispatchEvent(new Event("ludicord:recover"));
571
+ }
572
+ function dismiss() {
573
+ dismissed = true;
574
+ render();
575
+ }
576
+ element(".dismiss").onclick = dismiss;
577
+ element(".badge-icon").onclick = () => {
578
+ if (issues.length === 0)
579
+ return;
580
+ morphBadge(() => {
581
+ badgeCollapsed = !badgeCollapsed;
582
+ element(".badge").dataset.state = badgeCollapsed ? "collapsed" : "expanded";
583
+ });
584
+ };
585
+ element(".badge-issues-btn").onclick = () => {
586
+ dismissed = false;
587
+ render();
588
+ };
589
+ element(".badge-collapse").onclick = () => {
590
+ morphBadge(() => {
591
+ badgeCollapsed = true;
592
+ element(".badge").dataset.state = "collapsed";
593
+ });
594
+ };
595
+ element(".next").onclick = () => {
596
+ index = (index + 1) % issues.length;
597
+ stackExpanded = false;
598
+ render();
599
+ };
600
+ element(".prev").onclick = () => {
601
+ index = (index + issues.length - 1) % issues.length;
602
+ stackExpanded = false;
603
+ render();
604
+ };
605
+ element(".ignored").onclick = () => {
606
+ stackExpanded = !stackExpanded;
607
+ render();
608
+ };
609
+ element(".source").onclick = () => {
610
+ const issue = issues[index];
611
+ if (!issue?.file)
612
+ return;
613
+ const location = `${issue.file}:${issue.line ?? 1}:${issue.column ?? 1}`;
614
+ void navigator.clipboard?.writeText(location);
615
+ void fetch(`/__open-in-editor?file=${encodeURIComponent(location)}`, {
616
+ headers: devHeaders,
617
+ }).catch(() => { });
618
+ window.dispatchEvent(new CustomEvent("ludicord:open-source", {
619
+ detail: { file: issue.file, line: issue.line, column: issue.column },
620
+ }));
621
+ };
622
+ element(".copy").onclick = () => {
623
+ const issue = issues[index];
23
624
  if (issue === undefined)
24
625
  return;
25
- element(".kind").textContent = `${issue.kind ?? "runtime"} error`;
26
- element("h1").textContent = issue.message;
27
- element(".file").textContent = issue.file ? `${issue.file}:${issue.line ?? 1}:${issue.column ?? 1}` : "Activity runtime";
28
- element(".frame").textContent = issue.frame ?? "Fix the error in your source. Ludicord will update automatically.";
29
- element(".stack").textContent = issue.stack ?? "No additional stack available.";
30
- element(".count").textContent = `${index + 1} of ${issues.length} · Ludicord dev`;
31
- element(".badge").textContent = `◈ ${issues.length} ${issues.length === 1 ? "issue" : "issues"}`;
32
- }
33
- function show(next) { issues = next; index = Math.min(index, Math.max(0, next.length - 1)); dismissed = false; render(); }
34
- function recover() { window.dispatchEvent(new Event("ludicord:recover")); }
35
- element(".close").onclick = () => { dismissed = true; render(); };
36
- element(".badge").onclick = () => { dismissed = false; render(); };
37
- element(".next").onclick = () => { index = (index + 1) % issues.length; render(); };
38
- element(".previous").onclick = () => { index = (index + issues.length - 1) % issues.length; render(); };
39
- element(".copy").onclick = () => { void navigator.clipboard?.writeText(element(".file").textContent ?? ""); };
40
- element(".retry").onclick = () => { recover(); show([]); };
626
+ const location = issue.file
627
+ ? `${issue.file}:${issue.line ?? 1}:${issue.column ?? 1}`
628
+ : "Activity runtime";
629
+ const text = [issue.message, location, issue.frame, issue.stack, issue.componentStack]
630
+ .filter((part) => Boolean(part))
631
+ .join("\n\n");
632
+ void navigator.clipboard?.writeText(text);
633
+ const button = element(".copy");
634
+ const original = button.textContent;
635
+ button.textContent = "Copied";
636
+ button.classList.add("copied");
637
+ window.clearTimeout(copyTimer);
638
+ copyTimer = window.setTimeout(() => {
639
+ button.textContent = original;
640
+ button.classList.remove("copied");
641
+ }, 1400);
642
+ };
643
+ element(".retry").onclick = async () => {
644
+ recover();
645
+ const button = element(".retry");
646
+ button.disabled = true;
647
+ button.textContent = "Checking…";
648
+ try {
649
+ const response = await fetch("/_ludicord/dev/diagnostics", {
650
+ headers: devHeaders,
651
+ cache: "no-store",
652
+ });
653
+ if (response.ok)
654
+ show((await response.json()).issues);
655
+ }
656
+ finally {
657
+ button.disabled = false;
658
+ button.textContent = "Retry";
659
+ }
660
+ };
661
+ for (const cls of ["up", "down"]) {
662
+ element(`.fbbtn.${cls}`).onclick = () => {
663
+ const issue = issues[index];
664
+ const helpful = cls === "up";
665
+ window.dispatchEvent(new CustomEvent("ludicord:feedback", { detail: { issue, helpful } }));
666
+ for (const other of ["up", "down"]) {
667
+ const button = element(`.fbbtn.${other}`);
668
+ button.classList.toggle("picked", other === cls);
669
+ button.disabled = true;
670
+ }
671
+ element(".fbq").textContent = "Thanks for the feedback";
672
+ };
673
+ }
674
+ const keydown = (event) => {
675
+ if (dismissed || issues.length === 0)
676
+ return;
677
+ if (event.key === "Escape") {
678
+ dismiss();
679
+ }
680
+ else if (event.key === "ArrowRight" && issues.length > 1) {
681
+ element(".next").click();
682
+ }
683
+ else if (event.key === "ArrowLeft" && issues.length > 1) {
684
+ element(".prev").click();
685
+ }
686
+ };
687
+ document.addEventListener("keydown", keydown);
41
688
  async function report(issue) {
42
689
  show([issue]);
43
690
  try {
44
- const response = await fetch("/_ludicord/dev/error", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(issue) });
45
- if (response.ok)
691
+ const response = await fetch("/_ludicord/dev/error", {
692
+ method: "POST",
693
+ headers: { "content-type": "application/json", ...devHeaders },
694
+ body: JSON.stringify(issue),
695
+ });
696
+ if (response.ok) {
46
697
  show([await response.json()]);
698
+ }
699
+ }
700
+ catch {
701
+ // Keep the original error while disconnected.
47
702
  }
48
- catch { /* Keep the original error while disconnected. */ }
49
703
  }
50
- const runtime = (event) => { void report(event.detail); };
51
- const rejection = (event) => { void report({ message: event.reason?.message ?? String(event.reason), stack: event.reason?.stack }); };
52
- const error = (event) => { if (event.message)
53
- void report({ message: event.message, stack: event.error?.stack, file: event.filename, line: event.lineno, column: event.colno }); };
704
+ const runtime = (event) => {
705
+ void report(event.detail);
706
+ };
707
+ const rejection = (event) => {
708
+ void report({
709
+ message: event.reason?.message ?? String(event.reason),
710
+ stack: event.reason?.stack,
711
+ });
712
+ };
713
+ const error = (event) => {
714
+ if (event.message) {
715
+ void report({
716
+ message: event.message,
717
+ stack: event.error?.stack,
718
+ file: event.filename,
719
+ line: event.lineno,
720
+ column: event.colno,
721
+ });
722
+ }
723
+ };
54
724
  window.addEventListener("ludicord:runtime-error", runtime);
55
725
  window.addEventListener("unhandledrejection", rejection);
56
726
  window.addEventListener("error", error);
57
727
  hot?.on("ludicord:diagnostics", (data) => show(data.issues));
58
728
  hot?.on("vite:error", (data) => show([data.err]));
59
- hot?.on("vite:afterUpdate", () => { recover(); void fetch("/_ludicord/dev/diagnostics").then(r => r.json()).then(data => show(data.issues)).catch(() => { }); });
60
- void fetch("/_ludicord/dev/diagnostics").then(r => r.json()).then(data => show(data.issues)).catch(() => { });
61
- hot?.dispose(() => { host.remove(); window.removeEventListener("ludicord:runtime-error", runtime); window.removeEventListener("unhandledrejection", rejection); window.removeEventListener("error", error); });
729
+ hot?.on("vite:afterUpdate", () => {
730
+ recover();
731
+ void fetch("/_ludicord/dev/diagnostics", { headers: devHeaders, cache: "no-store" })
732
+ .then((response) => response.json())
733
+ .then((data) => show(data.issues))
734
+ .catch(() => { });
735
+ });
736
+ void fetch("/_ludicord/dev/diagnostics", { headers: devHeaders, cache: "no-store" })
737
+ .then((response) => response.json())
738
+ .then((data) => show(data.issues))
739
+ .catch(() => { });
740
+ hot?.dispose(() => {
741
+ host.remove();
742
+ window.removeEventListener("ludicord:runtime-error", runtime);
743
+ window.removeEventListener("unhandledrejection", rejection);
744
+ window.removeEventListener("error", error);
745
+ document.removeEventListener("keydown", keydown);
746
+ });
62
747
  export {};
63
- //# sourceMappingURL=dev-panel.js.map