@vite-hub/comments 0.4.1 → 0.5.1

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 (87) hide show
  1. package/README.md +23 -7
  2. package/dist/anchor.d.ts +3 -5
  3. package/dist/anchor.js +1 -2
  4. package/dist/{client-diagnostics-Bubm7Shd.js → client-diagnostics-CvfTW5d4.js} +1 -2
  5. package/dist/{client-files-CJZl5Kc4.js → client-files-lC6X7XyS.js} +1 -2
  6. package/dist/client.d.ts +430 -24
  7. package/dist/client.js +413 -20
  8. package/dist/{console-h4KlhIik.d.ts → console-CK2F53QP.d.ts} +2 -4
  9. package/dist/{context-BqIsmYP1.js → context-DbkBjITZ.js} +1 -2
  10. package/dist/database/postgres.d.ts +1 -3
  11. package/dist/database/postgres.js +1 -2
  12. package/dist/{migrate-Bpw3xL5e.js → database-BkPoOdZr.js} +116 -59
  13. package/dist/database-CPua6Q6_.d.ts +573 -0
  14. package/dist/{database-CA1aHKN7.d.ts → database-DUs3c2al.d.ts} +625 -73
  15. package/dist/database.d.ts +4 -5
  16. package/dist/database.js +1 -2
  17. package/dist/{define-CX_Yr_hz.js → define-9uMM3Ewc.js} +2 -3
  18. package/dist/{define-CHTWfHPo.d.ts → define-B1jLSPe9.d.ts} +8 -6
  19. package/dist/{errors-4gelGVmK.js → errors-C0VwRHiy.js} +25 -2
  20. package/dist/{errors-BHsVXlpd.js → errors-DFNiJg67.js} +26 -3
  21. package/dist/{fold-name-B7Zb3-MF.js → fold-name-g-xg0mQk.js} +1 -2
  22. package/dist/hosted/hosted-comments/client-B3dlmmQd.js +4 -0
  23. package/dist/{overlay/dist-BoHMOFax.js → hosted/hosted-comments/dist-DyVmH21U.js} +1 -1
  24. package/dist/hosted/hosted-comments/frame.js +1 -0
  25. package/dist/hosted/hosted-comments/overlay-4-mWX4Uz.js +170 -0
  26. package/dist/hosted/hosted-comments/protocol-BHvtQKte.js +1 -0
  27. package/dist/hosted/hosted-comments/rest-transport-D-9_pNqZ.js +1 -0
  28. package/dist/hosted/hosted-comments/tools-CdwnUCOr.js +126 -0
  29. package/dist/hosted/hosted-comments.js +9 -0
  30. package/dist/{identity-CBOzgxSf.js → identity-CT7-UGmS.js} +1 -2
  31. package/dist/{index-iPGlSAgj.d.ts → index-BEnHTj2Z.d.ts} +109 -15
  32. package/dist/index.d.ts +6 -7
  33. package/dist/index.js +23 -10
  34. package/dist/{install-96NXWnrw.d.ts → install-B-FQpi47.d.ts} +24 -7
  35. package/dist/{install-jRKmuLHK.js → install-BUXxryut.js} +950 -55
  36. package/dist/{installed-g6nDr5ac.js → installed-C9SkldMi.js} +8 -8
  37. package/dist/{invariant-D8_xBqmZ.js → invariant-CmdvZ3vp.js} +1 -2
  38. package/dist/{migrate-B0k_0swk.d.ts → migrate-XjFeQppf.d.ts} +2 -2
  39. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  40. package/dist/{operations-7ycAhDCw.d.ts → operations-8hqTi0DH.d.ts} +8 -4
  41. package/dist/{operations-9tskoLsk.js → operations-CKC_lMG_.js} +309 -229
  42. package/dist/{operations-D93EV10O.d.ts → operations-Cic9A9e_.d.ts} +9 -7
  43. package/dist/operations.d.ts +2 -2
  44. package/dist/operations.js +2 -2
  45. package/dist/overlay/{client-lZesR40x.js → client-CerbVjTz.js} +3 -3
  46. package/dist/overlay/dist-DyVmH21U.js +14 -0
  47. package/dist/overlay/overlay.js +36 -40
  48. package/dist/page/loader.js +45 -52
  49. package/dist/page-DE71P_gQ.d.ts +11 -0
  50. package/dist/{page-tools-shared-NHUjKI8E.js → page-tools-shared-fvmJQCrP.js} +8 -5
  51. package/dist/{page-DRz_sDY4.js → page-xzgZ6DGm.js} +2 -3
  52. package/dist/{path--zk6PEMz.js → path-8yqMd8zR.js} +0 -1
  53. package/dist/{plugin-BNFd1zGz.js → plugin-B2hETRii.js} +16 -13
  54. package/dist/realtime.d.ts +3 -5
  55. package/dist/realtime.js +4 -5
  56. package/dist/{reply-id-P_bSuEng.js → reply-id-Cm9FGOBs.js} +1 -2
  57. package/dist/request-log-DllKQXj7.js +104 -0
  58. package/dist/request-origin-YPzfE2eh.js +48 -0
  59. package/dist/{rpc-BQqYx8kb.js → rpc-BKY7XRlR.js} +5 -7
  60. package/dist/{rpc-BZ1QNkCC.d.ts → rpc-D-eqtyfh.d.ts} +1 -3
  61. package/dist/rpc.d.ts +1 -1
  62. package/dist/rpc.js +1 -2
  63. package/dist/runtime/auth.d.ts +3 -5
  64. package/dist/runtime/auth.js +2 -3
  65. package/dist/runtime/console.d.ts +2 -4
  66. package/dist/runtime/console.js +4 -5
  67. package/dist/runtime/index.d.ts +12 -27
  68. package/dist/runtime/index.js +160 -31
  69. package/dist/{server-CqyzrqTI.js → server-BGbD7H5s.js} +2 -3
  70. package/dist/server.d.ts +6 -7
  71. package/dist/server.js +6 -6
  72. package/dist/service-CPiWPoiY.d.ts +69 -0
  73. package/dist/{service-C8ZgFWvy.js → service-DDD4Ubxd.js} +44 -18
  74. package/dist/{session-ByjMyTak.js → session-BGN6Vlm6.js} +31 -37
  75. package/dist/{session-CKfW6DGE.d.ts → session-CTh9nisq.d.ts} +3 -5
  76. package/dist/{service-wC9kx9EX.d.ts → store-DvNTDNgn.d.ts} +3 -73
  77. package/dist/{table-names-DfiKUlOV.js → table-names-BIHjuEFK.js} +4 -3
  78. package/dist/testing.d.ts +2 -4
  79. package/dist/testing.js +4 -5
  80. package/dist/{tokens-DSbwkVSy.js → tokens-Bx4lZ0yt.js} +3 -6
  81. package/dist/{types-C7LzhgRb.d.ts → types-BX3vH18p.d.ts} +1 -3
  82. package/dist/{types-C1qzObs2.d.ts → types-l6GOb_yc.d.ts} +79 -6
  83. package/dist/vite.d.ts +22 -21
  84. package/dist/vite.js +161 -104
  85. package/package.json +19 -19
  86. package/dist/errors-BEChnUo7.d.ts +0 -197
  87. package/dist/page-CWwnmF3K.d.ts +0 -22
package/dist/client.js CHANGED
@@ -1,11 +1,11 @@
1
- import { i as commentsUnansweredError, r as commentsClientDiagnostics, t as commentsAnswerError } from "./client-diagnostics-Bubm7Shd.js";
2
- import { i as withCommentFiles, n as outboxAccountHeader, r as retryAfterOf, t as failedCommentPreparation } from "./client-files-CJZl5Kc4.js";
3
- import { t as replyMessageId } from "./reply-id-P_bSuEng.js";
4
- import { t as commentsErrorDiagnostics } from "./errors-BHsVXlpd.js";
5
- import { t as foldName } from "./fold-name-B7Zb3-MF.js";
6
- import { i as commentsRoute } from "./page-DRz_sDY4.js";
7
- import { n as isRecordOrFunction } from "./object-Da1zyPCR.js";
8
- //#region ../internal/src/browser-environment.ts
1
+ import { i as commentsUnansweredError, r as commentsClientDiagnostics, t as commentsAnswerError } from "./client-diagnostics-CvfTW5d4.js";
2
+ import { i as withCommentFiles, n as outboxAccountHeader, r as retryAfterOf, t as failedCommentPreparation } from "./client-files-lC6X7XyS.js";
3
+ import { t as replyMessageId } from "./reply-id-Cm9FGOBs.js";
4
+ import { t as commentsErrorDiagnostics } from "./errors-DFNiJg67.js";
5
+ import { i as commentsRoute } from "./page-xzgZ6DGm.js";
6
+ import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
7
+ import { t as foldName } from "./fold-name-g-xg0mQk.js";
8
+ // ../internal/src/browser-environment.ts
9
9
  /** The real browser: window events, Web Locks, and a BroadcastChannel, each only when the browser has it. */
10
10
  function createBrowserEnvironment(options) {
11
11
  let channel;
@@ -84,8 +84,7 @@ function backoffDelay(attempt, random) {
84
84
  const ceiling = Math.min(3e4, 1e3 * 2 ** attempt);
85
85
  return ceiling / 2 + random * ceiling / 2;
86
86
  }
87
- //#endregion
88
- //#region src/client-outbox.ts
87
+ // src/client-outbox.ts
89
88
  function changeable(entry) {
90
89
  return entry.status !== "sending" && !entry.uncertain;
91
90
  }
@@ -422,7 +421,7 @@ function createOutbox(options, host) {
422
421
  });
423
422
  } else {
424
423
  const threadId = realId(entry.input.threadId);
425
- const subject = entry.subject ?? serverThread(threadId)?.subject ?? (files.files?.length ? (await host.transport.get({ id: threadId }))?.subject : void 0);
424
+ const subject = entry.subject ?? serverThread(threadId)?.subject ?? (files.files?.length ? (await host.transport.get({ threadId }))?.subject : void 0);
426
425
  if (files.files?.length && !subject) throw Object.assign(/* @__PURE__ */ new Error("The thread for this reply does not exist."), { status: 404 });
427
426
  if (!await withClaim(() => true)) return;
428
427
  writing = true;
@@ -727,8 +726,7 @@ function createOutbox(options, host) {
727
726
  }
728
727
  };
729
728
  }
730
- //#endregion
731
- //#region src/client-anchor.ts
729
+ // src/client-anchor.ts
732
730
  const defaultContext = 32;
733
731
  const clamp = (value) => Math.min(1e3, Math.max(0, value));
734
732
  function thousandths(value, size) {
@@ -1130,8 +1128,360 @@ function resolveAnchor(anchor, root = document) {
1130
1128
  element
1131
1129
  };
1132
1130
  }
1133
- //#endregion
1134
- //#region src/rest-transport.ts
1131
+ // src/client-send.ts
1132
+ const reasonOf = (error) => error instanceof Error ? error.message : String(error);
1133
+ /**
1134
+ * The Send segment of a comment pill, without a framework: it hands the member's waiting threads to their agent, and
1135
+ * pairs one in place first when there is none. `CommentSend` of `@vite-hub/ui` renders it.
1136
+ */
1137
+ function createCommentSend(transport, options = {}) {
1138
+ const pairingInterval = options.pairingInterval ?? 1500;
1139
+ const statusInterval = options.statusInterval ?? 5e3;
1140
+ const sentFor = options.sentFor ?? 2e3;
1141
+ const listeners = /* @__PURE__ */ new Set();
1142
+ let state = {
1143
+ status: "idle",
1144
+ count: 0,
1145
+ inbox: false
1146
+ };
1147
+ let agent;
1148
+ let count = 0;
1149
+ let countRevision = 0;
1150
+ let selection = "";
1151
+ let selections = 0;
1152
+ let code;
1153
+ let fetching = false;
1154
+ let sendId;
1155
+ let thread;
1156
+ let pushed;
1157
+ let step = 0;
1158
+ let timer;
1159
+ let run = 0;
1160
+ const notify = () => {
1161
+ for (const listener of listeners) listener();
1162
+ };
1163
+ const set = (next) => {
1164
+ step++;
1165
+ clearTimeout(timer);
1166
+ timer = void 0;
1167
+ state = next;
1168
+ notify();
1169
+ };
1170
+ const later = (ms, then) => {
1171
+ const at = step;
1172
+ clearTimeout(timer);
1173
+ timer = setTimeout(() => at === step && then(), ms);
1174
+ };
1175
+ const inbox = () => Boolean(agent && !agent.host);
1176
+ const idleState = () => ({
1177
+ status: "idle",
1178
+ count,
1179
+ inbox: inbox(),
1180
+ ...agent && count > 0 ? { canPairAnother: true } : {}
1181
+ });
1182
+ const idle = () => set(idleState());
1183
+ const finish = () => {
1184
+ sendId = void 0;
1185
+ thread = void 0;
1186
+ idle();
1187
+ };
1188
+ const working = () => {
1189
+ set({
1190
+ status: "working",
1191
+ count,
1192
+ ...agent ? { agent } : {},
1193
+ ...thread ? { thread } : {}
1194
+ });
1195
+ if (!transport.subscribe) later(statusInterval, () => void refresh(working));
1196
+ };
1197
+ const limited = (retryAt) => {
1198
+ set({
1199
+ status: "limited",
1200
+ count,
1201
+ retryAt
1202
+ });
1203
+ later(Math.max(0, retryAt - Date.now()), () => void refresh(idle));
1204
+ };
1205
+ const pending = () => {
1206
+ set({
1207
+ status: "sending",
1208
+ count
1209
+ });
1210
+ later(statusInterval, () => void refresh(pending, true));
1211
+ };
1212
+ const apply = (status) => {
1213
+ agent = status.agent;
1214
+ if (status.pending) return pending();
1215
+ if (status.working) {
1216
+ sendId = status.working.id;
1217
+ thread = status.working.thread;
1218
+ if (state.status === "sent") {
1219
+ state = {
1220
+ ...state,
1221
+ count,
1222
+ inbox: inbox()
1223
+ };
1224
+ return notify();
1225
+ }
1226
+ return working();
1227
+ }
1228
+ sendId = void 0;
1229
+ thread = void 0;
1230
+ if (status.retryAt !== void 0 && status.retryAt > Date.now()) return limited(status.retryAt);
1231
+ idle();
1232
+ };
1233
+ const refresh = async (onError, deliveryPending = false) => {
1234
+ const at = step;
1235
+ const canApply = () => at === step && !fetching && state.status !== "pairing" && state.status !== "confirm" && (state.status !== "sending" || deliveryPending);
1236
+ if (!canApply()) return;
1237
+ const revision = countRevision;
1238
+ try {
1239
+ const status = await transport.status();
1240
+ if (!canApply()) return;
1241
+ if (revision === countRevision) count = status.count;
1242
+ selection = status.selection ?? "";
1243
+ apply(status);
1244
+ } catch (error) {
1245
+ if (!onError) throw error;
1246
+ if (canApply()) onError();
1247
+ }
1248
+ };
1249
+ const settle = (result, revision, paired) => {
1250
+ const updates = pushed;
1251
+ pushed = void 0;
1252
+ if (result.status === "changed") {
1253
+ count = result.count;
1254
+ selection = result.selection;
1255
+ if (!paired) return set({
1256
+ status: "failed",
1257
+ count,
1258
+ reason: "The waiting comments changed."
1259
+ });
1260
+ code = paired.code;
1261
+ return set({
1262
+ status: "confirm",
1263
+ count,
1264
+ agent: paired.agent
1265
+ });
1266
+ }
1267
+ if (result.status === "failed") return set({
1268
+ status: "failed",
1269
+ count,
1270
+ reason: result.reason
1271
+ });
1272
+ if (paired) agent = paired.agent;
1273
+ if (result.status === "limited") return limited(result.retryAt);
1274
+ if (result.status === "pending") return pending();
1275
+ sendId = result.id;
1276
+ const update = updates?.get(result.id);
1277
+ thread = update?.thread ?? result.thread;
1278
+ if (revision === countRevision) count = 0;
1279
+ set({
1280
+ status: "sent",
1281
+ count,
1282
+ inbox: inbox()
1283
+ });
1284
+ later(sentFor, update?.done ? finish : working);
1285
+ };
1286
+ const deliver = async (request, paired) => {
1287
+ const revision = countRevision;
1288
+ pushed = transport.subscribe ? /* @__PURE__ */ new Map() : void 0;
1289
+ set({
1290
+ status: "sending",
1291
+ count
1292
+ });
1293
+ const at = step;
1294
+ let result;
1295
+ try {
1296
+ result = await request();
1297
+ } catch (error) {
1298
+ result = {
1299
+ status: "failed",
1300
+ reason: reasonOf(error)
1301
+ };
1302
+ }
1303
+ if (at === step) settle(result, revision, paired);
1304
+ };
1305
+ const drop = (dropped) => void transport.cancel(dropped).catch(() => void 0);
1306
+ const poll = () => {
1307
+ later(pairingInterval, async () => {
1308
+ if (state.status !== "pairing" || !code) return;
1309
+ if (Date.now() >= state.expiresAt) return set({
1310
+ ...state,
1311
+ reason: "expired"
1312
+ });
1313
+ const at = step;
1314
+ const check = await transport.pollPairing(code).catch(() => ({ status: "waiting" }));
1315
+ if (at !== step || state.status !== "pairing") return;
1316
+ if (check.status === "waiting") return poll();
1317
+ if (check.status === "paired") return set({
1318
+ status: "confirm",
1319
+ count,
1320
+ agent: check.agent
1321
+ });
1322
+ set({
1323
+ ...state,
1324
+ reason: check.status
1325
+ });
1326
+ });
1327
+ };
1328
+ const pair = async (copy) => {
1329
+ if (fetching) return;
1330
+ fetching = true;
1331
+ const at = ++step;
1332
+ try {
1333
+ const pairing = transport.startPairing();
1334
+ const prompt = pairing.then((next) => next.prompt);
1335
+ prompt.catch(() => void 0);
1336
+ const copied = (async () => copy ? copy(prompt) : true)().then((ok) => ({ ok }), (error) => ({
1337
+ ok: false,
1338
+ error
1339
+ }));
1340
+ const next = await pairing;
1341
+ const outcome = await copied;
1342
+ if (at !== step) return drop(next.code);
1343
+ fetching = false;
1344
+ if (!outcome.ok) {
1345
+ drop(next.code);
1346
+ const reason = "error" in outcome ? reasonOf(outcome.error) : "The browser did not let the page copy the setup prompt.";
1347
+ return set({
1348
+ status: "failed",
1349
+ count,
1350
+ reason
1351
+ });
1352
+ }
1353
+ if (code) drop(code);
1354
+ code = next.code;
1355
+ count = next.count;
1356
+ selection = next.selection;
1357
+ set({
1358
+ status: "pairing",
1359
+ count,
1360
+ prompt: next.prompt,
1361
+ expiresAt: next.expiresAt,
1362
+ agent: next.agent
1363
+ });
1364
+ poll();
1365
+ } catch (error) {
1366
+ if (at === step) {
1367
+ fetching = false;
1368
+ set({
1369
+ status: "failed",
1370
+ count,
1371
+ reason: reasonOf(error)
1372
+ });
1373
+ }
1374
+ }
1375
+ };
1376
+ const reselect = async () => {
1377
+ const at = ++selections;
1378
+ const pairing = code;
1379
+ const status = await transport.status().catch(() => void 0);
1380
+ if (!status || at !== selections || !pairing || pairing !== code || state.status !== "pairing" && state.status !== "confirm") return;
1381
+ count = status.count;
1382
+ selection = status.selection ?? "";
1383
+ state = {
1384
+ ...state,
1385
+ count
1386
+ };
1387
+ notify();
1388
+ };
1389
+ return {
1390
+ get state() {
1391
+ return state;
1392
+ },
1393
+ onChange(listener) {
1394
+ listeners.add(listener);
1395
+ return () => {
1396
+ listeners.delete(listener);
1397
+ };
1398
+ },
1399
+ start() {
1400
+ const current = ++run;
1401
+ const stop = transport.subscribe?.((event) => {
1402
+ if (current !== run) return;
1403
+ if (event.type === "count") {
1404
+ countRevision++;
1405
+ if (state.status === "pairing" || state.status === "confirm") return void reselect();
1406
+ count = event.count;
1407
+ if (state.status !== "sending") {
1408
+ state = state.status === "idle" ? idleState() : {
1409
+ ...state,
1410
+ count
1411
+ };
1412
+ notify();
1413
+ }
1414
+ return;
1415
+ }
1416
+ if (state.status === "sending") {
1417
+ const update = pushed?.get(event.id);
1418
+ pushed?.set(event.id, event.type === "done" ? {
1419
+ ...update,
1420
+ done: true
1421
+ } : {
1422
+ ...update,
1423
+ thread: event.thread ?? update?.thread
1424
+ });
1425
+ return;
1426
+ }
1427
+ if (fetching || state.status === "pairing" || state.status === "confirm") return;
1428
+ if ((state.status === "working" || state.status === "sent") && sendId !== event.id) return;
1429
+ if (event.type === "working") {
1430
+ thread = event.thread ?? (event.id === sendId ? thread : void 0);
1431
+ sendId = event.id;
1432
+ if (state.status !== "sent") working();
1433
+ return;
1434
+ }
1435
+ if (event.id === sendId) finish();
1436
+ });
1437
+ refresh(() => void 0);
1438
+ return () => {
1439
+ stop?.();
1440
+ if (current !== run) return;
1441
+ run++;
1442
+ if (code) drop(code);
1443
+ code = void 0;
1444
+ fetching = false;
1445
+ pushed = void 0;
1446
+ agent = void 0;
1447
+ count = 0;
1448
+ finish();
1449
+ };
1450
+ },
1451
+ refresh: () => refresh(),
1452
+ async send(copy) {
1453
+ if (fetching || state.status !== "idle" && state.status !== "failed" && state.status !== "working") return;
1454
+ if (state.status !== "failed" && count === 0) return;
1455
+ if (!agent) return pair(copy);
1456
+ return deliver(() => transport.send());
1457
+ },
1458
+ async pairAnother(copy) {
1459
+ if (state.status !== "idle" || !state.canPairAnother) return;
1460
+ return pair(copy);
1461
+ },
1462
+ async allow() {
1463
+ if (state.status !== "confirm" || !code) return;
1464
+ const used = code;
1465
+ code = void 0;
1466
+ return deliver(() => transport.allow(used, selection), {
1467
+ code: used,
1468
+ agent: state.agent
1469
+ });
1470
+ },
1471
+ async copyAgain(copy) {
1472
+ if (state.status !== "pairing" || !state.reason) return;
1473
+ return pair(copy);
1474
+ },
1475
+ cancel() {
1476
+ if (state.status !== "pairing" && state.status !== "confirm") return;
1477
+ if (code) drop(code);
1478
+ code = void 0;
1479
+ fetching = false;
1480
+ idle();
1481
+ }
1482
+ };
1483
+ }
1484
+ // src/rest-transport.ts
1135
1485
  /** The URL of an attachment key below the Comments API, such as `/_vitehub/comments/attachments/comments/<id>/shot.png`. */
1136
1486
  function commentAttachmentUrl(key, base = "") {
1137
1487
  return `${base.replace(/\/+$/, "")}${commentsRoute}/attachments/${key.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
@@ -1227,7 +1577,7 @@ function createRestTransport(options = {}) {
1227
1577
  return (await request(`/threads?${listSearch(query)}`)).data;
1228
1578
  },
1229
1579
  async get(input) {
1230
- const path = "id" in input ? thread(input.id) : `/scopes/${encodeURIComponent(input.scope)}/threads/${input.n}`;
1580
+ const path = "threadId" in input ? thread(input.threadId) : `/scopes/${encodeURIComponent(input.scope)}/threads/${input.n}`;
1231
1581
  return (await request(path)).data;
1232
1582
  },
1233
1583
  async create({ files, outbox, ...input }) {
@@ -1276,8 +1626,52 @@ function createRestTransport(options = {}) {
1276
1626
  attachmentUrl: (key) => commentAttachmentUrl(key, base)
1277
1627
  };
1278
1628
  }
1279
- //#endregion
1280
- //#region src/client.ts
1629
+ // src/send-transport.ts
1630
+ /**
1631
+ * The transport of `createCommentSend()` over the Send routes of Comments, `<base>/_vitehub/comments/send/**`. The
1632
+ * ViteHub pill uses it, and an app renders `CommentSend` of `@vite-hub/ui` with it in its own pill:
1633
+ *
1634
+ * ```ts
1635
+ * import { createCommentSend, createCommentSendTransport } from "@vite-hub/comments/client"
1636
+ *
1637
+ * const send = createCommentSend(createCommentSendTransport({ page: () => location.pathname }))
1638
+ * ```
1639
+ */
1640
+ function createCommentSendTransport(options = {}) {
1641
+ const request = createCommentsRestRequest(options);
1642
+ const page = () => encodeURIComponent(typeof options.page === "function" ? options.page() : options.page ?? location.pathname);
1643
+ const post = (body) => ({
1644
+ method: "POST",
1645
+ ...body === void 0 ? {} : { body: JSON.stringify(body) }
1646
+ });
1647
+ const code = (value) => encodeURIComponent(value);
1648
+ const pairingPages = /* @__PURE__ */ new Map();
1649
+ return {
1650
+ status: async () => (await request(`/send/status?page=${page()}`)).data,
1651
+ startPairing: async () => {
1652
+ const path = page();
1653
+ const pairing = (await request(`/send/start?page=${path}`, post())).data;
1654
+ pairingPages.set(pairing.code, path);
1655
+ return pairing;
1656
+ },
1657
+ pollPairing: async (value) => (await request(`/send/pair/${code(value)}`)).data,
1658
+ allow: async (value, selection) => {
1659
+ const path = pairingPages.get(value) ?? page();
1660
+ const result = (await request(`/send/allow?page=${path}`, post({
1661
+ code: value,
1662
+ selection
1663
+ }))).data;
1664
+ if (result.status !== "changed") pairingPages.delete(value);
1665
+ return result;
1666
+ },
1667
+ cancel: async (value) => {
1668
+ pairingPages.delete(value);
1669
+ await request(`/send/pair/${code(value)}`, { method: "DELETE" });
1670
+ },
1671
+ send: async () => (await request(`/send?page=${page()}`, post())).data
1672
+ };
1673
+ }
1674
+ // src/client.ts
1281
1675
  function createCommentsClient(options) {
1282
1676
  const { transport } = options;
1283
1677
  const listeners = /* @__PURE__ */ new Set();
@@ -1509,5 +1903,4 @@ function createCommentsClient(options) {
1509
1903
  }
1510
1904
  };
1511
1905
  }
1512
- //#endregion
1513
- export { anchorRange, commentAttachmentUrl, commentsErrorDiagnostics, createAnchor, createCommentsClient, createCommentsRestRequest, createIndexedDBOutboxStore, createMemoryOutboxStore, createRestTransport, foldName, replyMessageId, resolveAnchor, selectorFor };
1906
+ export { anchorRange, commentAttachmentUrl, commentsErrorDiagnostics, createAnchor, createCommentSend, createCommentSendTransport, createCommentsClient, createCommentsRestRequest, createIndexedDBOutboxStore, createMemoryOutboxStore, createRestTransport, foldName, replyMessageId, resolveAnchor, selectorFor };
@@ -1,4 +1,3 @@
1
- //#region ../internal/src/inspect.d.ts
2
1
  interface ViteHubDefinitionField {
3
2
  label: string;
4
3
  value: string;
@@ -48,6 +47,8 @@ interface ViteHubResourceSummary {
48
47
  owner: string;
49
48
  /** Absent when no id is known yet. */
50
49
  source?: ViteHubResourceIdSource;
50
+ /** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
51
+ standalone?: boolean;
51
52
  }
52
53
  interface ViteHubInspectionContributor {
53
54
  definitions?: readonly ViteHubDefinitionInspector[];
@@ -58,8 +59,6 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
58
59
  interface ViteHubInspectionPluginMetadata {
59
60
  inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
60
61
  }
61
- //#endregion
62
- //#region ../internal/src/console.d.ts
63
62
  type MaybePromise<T> = T | Promise<T>;
64
63
  /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
65
64
  interface ViteHubConsoleDefinitionCatalogView {
@@ -328,5 +327,4 @@ interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteH
328
327
  }
329
328
  /** A section whose list comes from an operation, called with the Console user on each visit. It has no build-time data. */
330
329
  interface ViteHubConsoleOperationSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleOperationView> {}
331
- //#endregion
332
330
  export { ViteHubInspectionPluginMetadata as i, ViteHubConsoleRecord as n, ViteHubConsoleRuntimeRecordTableSection as r, ViteHubConsoleOperationSection as t };
@@ -1,4 +1,4 @@
1
- //#region src/context.ts
1
+ // src/context.ts
2
2
  /**
3
3
  * The context of a thread as label and value pairs, in the order a person reads them: page, element, components,
4
4
  * browser, build. The Console and Agent tools show these.
@@ -57,5 +57,4 @@ function describeCommentContext(context) {
57
57
  });
58
58
  return fields;
59
59
  }
60
- //#endregion
61
60
  export { describeCommentContext as t };
@@ -1,4 +1,3 @@
1
- //#region src/operations-core/database/postgres.d.ts
2
1
  /**
3
2
  * Threads of comments. `n` is unique inside `scope`, which is what `?comment=<n>` names. `anchor`, `actor`, and
4
3
  * `resolvedBy` hold JSON. Times are milliseconds since the epoch.
@@ -1398,5 +1397,4 @@ export declare const commentsPostgresSchema: {
1398
1397
  dialect: "pg";
1399
1398
  isAlias: false;
1400
1399
  }>;
1401
- };
1402
- //#endregion
1400
+ };
@@ -1,5 +1,5 @@
1
1
  import { bigint, boolean, index, pgTable, text, uniqueIndex } from "drizzle-orm/pg-core";
2
- //#region src/operations-core/database/postgres.ts
2
+ // src/operations-core/database/postgres.ts
3
3
  /**
4
4
  * Threads of comments. `n` is unique inside `scope`, which is what `?comment=<n>` names. `anchor`, `actor`, and
5
5
  * `resolvedBy` hold JSON. Times are milliseconds since the epoch.
@@ -77,5 +77,4 @@ const commentsPostgresSchema = {
77
77
  vitehubCommentCounters: commentCounters,
78
78
  vitehubCommentForge: commentForge
79
79
  };
80
- //#endregion
81
80
  export { commentCounters, commentForge, commentMessages, commentThreads, commentsPostgresSchema };