jazz-tools 0.19.3 → 0.19.4

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 (78) hide show
  1. package/.svelte-kit/__package__/jazz.class.svelte.d.ts +2 -2
  2. package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
  3. package/.svelte-kit/__package__/jazz.class.svelte.js +15 -17
  4. package/.turbo/turbo-build.log +64 -64
  5. package/CHANGELOG.md +14 -0
  6. package/dist/{chunk-JPWM4CS2.js → chunk-PT7FCV26.js} +145 -77
  7. package/dist/chunk-PT7FCV26.js.map +1 -0
  8. package/dist/index.js +14 -7
  9. package/dist/index.js.map +1 -1
  10. package/dist/inspector/{custom-element-3JAYHXWQ.js → custom-element-P76EIWEV.js} +301 -142
  11. package/dist/inspector/{custom-element-3JAYHXWQ.js.map → custom-element-P76EIWEV.js.map} +1 -1
  12. package/dist/inspector/index.js +281 -122
  13. package/dist/inspector/index.js.map +1 -1
  14. package/dist/inspector/register-custom-element.js +1 -1
  15. package/dist/inspector/tests/viewer/co-plain-text-view.test.d.ts +2 -0
  16. package/dist/inspector/tests/viewer/co-plain-text-view.test.d.ts.map +1 -0
  17. package/dist/inspector/utils/history.d.ts +5 -1
  18. package/dist/inspector/utils/history.d.ts.map +1 -1
  19. package/dist/inspector/viewer/co-plain-text-view.d.ts +4 -2
  20. package/dist/inspector/viewer/co-plain-text-view.d.ts.map +1 -1
  21. package/dist/inspector/viewer/page.d.ts.map +1 -1
  22. package/dist/inspector/viewer/use-resolve-covalue.d.ts +0 -1
  23. package/dist/inspector/viewer/use-resolve-covalue.d.ts.map +1 -1
  24. package/dist/react-core/hooks.d.ts.map +1 -1
  25. package/dist/react-core/index.js +4 -17
  26. package/dist/react-core/index.js.map +1 -1
  27. package/dist/svelte/jazz.class.svelte.d.ts +2 -2
  28. package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
  29. package/dist/svelte/jazz.class.svelte.js +15 -17
  30. package/dist/testing.js +1 -1
  31. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  32. package/dist/tools/coValues/group.d.ts.map +1 -1
  33. package/dist/tools/coValues/interfaces.d.ts +7 -6
  34. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  35. package/dist/tools/coValues/promise.d.ts +9 -0
  36. package/dist/tools/coValues/promise.d.ts.map +1 -0
  37. package/dist/tools/coValues/request.d.ts.map +1 -1
  38. package/dist/tools/exports.d.ts +1 -1
  39. package/dist/tools/exports.d.ts.map +1 -1
  40. package/dist/tools/implementation/refs.d.ts +1 -1
  41. package/dist/tools/implementation/refs.d.ts.map +1 -1
  42. package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts +3 -1
  43. package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts.map +1 -1
  44. package/dist/tools/subscribe/SubscriptionScope.d.ts +5 -2
  45. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  46. package/dist/tools/subscribe/index.d.ts +1 -1
  47. package/dist/tools/subscribe/index.d.ts.map +1 -1
  48. package/dist/tools/subscribe/types.d.ts +2 -1
  49. package/dist/tools/subscribe/types.d.ts.map +1 -1
  50. package/dist/tools/tests/SubscriptionScope.test.d.ts +2 -0
  51. package/dist/tools/tests/SubscriptionScope.test.d.ts.map +1 -0
  52. package/package.json +4 -4
  53. package/src/inspector/tests/utils/history.test.ts +233 -2
  54. package/src/inspector/tests/viewer/co-plain-text-view.test.tsx +125 -0
  55. package/src/inspector/tests/viewer/history-view.test.tsx +134 -2
  56. package/src/inspector/utils/history.ts +168 -1
  57. package/src/inspector/viewer/co-plain-text-view.tsx +102 -3
  58. package/src/inspector/viewer/history-view.tsx +5 -25
  59. package/src/inspector/viewer/page.tsx +8 -1
  60. package/src/inspector/viewer/use-resolve-covalue.ts +2 -6
  61. package/src/react-core/hooks.ts +5 -29
  62. package/src/svelte/jazz.class.svelte.ts +16 -34
  63. package/src/tools/coValues/coFeed.ts +10 -7
  64. package/src/tools/coValues/coMap.ts +10 -7
  65. package/src/tools/coValues/group.ts +6 -2
  66. package/src/tools/coValues/interfaces.ts +48 -28
  67. package/src/tools/coValues/promise.ts +34 -0
  68. package/src/tools/coValues/request.ts +12 -8
  69. package/src/tools/exports.ts +1 -0
  70. package/src/tools/implementation/refs.ts +9 -17
  71. package/src/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.ts +62 -30
  72. package/src/tools/subscribe/SubscriptionScope.ts +45 -2
  73. package/src/tools/subscribe/index.ts +28 -13
  74. package/src/tools/subscribe/types.ts +5 -2
  75. package/src/tools/tests/SubscriptionScope.test.ts +397 -0
  76. package/src/tools/tests/deepLoading.test.ts +22 -0
  77. package/src/tools/tests/subscribe.test.ts +69 -0
  78. package/dist/chunk-JPWM4CS2.js.map +0 -1
@@ -31782,14 +31782,14 @@ var require_jsx_runtime = __commonJS({
31782
31782
  });
31783
31783
 
31784
31784
  // src/inspector/custom-element.tsx
31785
- var import_react27 = __toESM(require_react(), 1);
31785
+ var import_react28 = __toESM(require_react(), 1);
31786
31786
  var import_client = __toESM(require_client(), 1);
31787
31787
  import { setup } from "goober";
31788
31788
  import { Account } from "jazz-tools";
31789
31789
 
31790
31790
  // src/inspector/viewer/new-app.tsx
31791
- var import_react26 = __toESM(require_react(), 1);
31792
- import { styled as styled26 } from "goober";
31791
+ var import_react27 = __toESM(require_react(), 1);
31792
+ import { styled as styled27 } from "goober";
31793
31793
 
31794
31794
  // src/inspector/ui/button.tsx
31795
31795
  var import_react = __toESM(require_react(), 1);
@@ -31964,11 +31964,11 @@ var Breadcrumbs = ({
31964
31964
  };
31965
31965
 
31966
31966
  // src/inspector/viewer/page-stack.tsx
31967
- import { styled as styled23 } from "goober";
31967
+ import { styled as styled24 } from "goober";
31968
31968
 
31969
31969
  // src/inspector/viewer/page.tsx
31970
- var import_react21 = __toESM(require_react(), 1);
31971
- import { styled as styled21 } from "goober";
31970
+ var import_react22 = __toESM(require_react(), 1);
31971
+ import { styled as styled22 } from "goober";
31972
31972
 
31973
31973
  // src/inspector/ui/badge.tsx
31974
31974
  var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
@@ -32316,12 +32316,6 @@ function RenderBlobImage({ blob }) {
32316
32316
  var isBrowserImage = (coValue) => {
32317
32317
  return "originalSize" in coValue && "placeholderDataURL" in coValue;
32318
32318
  };
32319
- var isGroup = (coValue) => {
32320
- return "readKey" in coValue;
32321
- };
32322
- var isAccount = (coValue) => {
32323
- return isGroup(coValue) && "profile" in coValue;
32324
- };
32325
32319
  async function resolveCoValue(coValueId, node) {
32326
32320
  const value = await node.load(coValueId);
32327
32321
  if (value === "unavailable") {
@@ -32338,7 +32332,7 @@ async function resolveCoValue(coValueId, node) {
32338
32332
  if (type === "comap") {
32339
32333
  if (isBrowserImage(snapshot)) {
32340
32334
  extendedType = "image";
32341
- } else if (isAccount(snapshot)) {
32335
+ } else if (value.headerMeta?.type === "account") {
32342
32336
  extendedType = "account";
32343
32337
  } else if (value.core.isGroup()) {
32344
32338
  extendedType = "group";
@@ -32367,7 +32361,7 @@ function subscribeToCoValue(coValueId, node, callback) {
32367
32361
  if (type === "comap") {
32368
32362
  if (isBrowserImage(snapshot)) {
32369
32363
  extendedType = "image";
32370
- } else if (isAccount(snapshot)) {
32364
+ } else if (value.headerMeta?.type === "account") {
32371
32365
  extendedType = "account";
32372
32366
  } else if (value.core.isGroup()) {
32373
32367
  extendedType = "group";
@@ -33843,17 +33837,90 @@ function AccountView({
33843
33837
  }
33844
33838
 
33845
33839
  // src/inspector/viewer/co-plain-text-view.tsx
33840
+ var import_react17 = __toESM(require_react(), 1);
33841
+ import { styled as styled18 } from "goober";
33842
+ import { CoPlainText } from "jazz-tools";
33846
33843
  var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
33847
- function CoPlainTextView({ data }) {
33844
+ function CoPlainTextView({
33845
+ data,
33846
+ coValue
33847
+ }) {
33848
+ const currentText = Object.values(data).join("");
33849
+ const [isEditing, setIsEditing] = (0, import_react17.useState)(false);
33850
+ const [editValue, setEditValue] = (0, import_react17.useState)("");
33851
+ const canEdit2 = isWriter(coValue.group.myRole());
33852
+ const handleEditClick = () => {
33853
+ setIsEditing(true);
33854
+ setEditValue(currentText);
33855
+ };
33856
+ const handleCancel = () => {
33857
+ setIsEditing(false);
33858
+ setEditValue(currentText);
33859
+ };
33860
+ const handleSave = (e) => {
33861
+ e.preventDefault();
33862
+ e.stopPropagation();
33863
+ const coPlainText = CoPlainText.fromRaw(coValue);
33864
+ coPlainText.$jazz.applyDiff(editValue);
33865
+ setIsEditing(false);
33866
+ };
33848
33867
  if (!data) return;
33868
+ if (isEditing) {
33869
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
33870
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(EditForm2, { onSubmit: handleSave, children: [
33871
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
33872
+ StyledTextarea2,
33873
+ {
33874
+ value: editValue,
33875
+ onChange: (e) => setEditValue(e.target.value),
33876
+ onClick: (e) => e.stopPropagation()
33877
+ }
33878
+ ),
33879
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(FormActions2, { children: [
33880
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Button, { type: "button", variant: "secondary", onClick: handleCancel, children: "Cancel" }),
33881
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Button, { type: "submit", variant: "primary", children: "Save" })
33882
+ ] })
33883
+ ] }),
33884
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(RawDataCard, { data })
33885
+ ] });
33886
+ }
33849
33887
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
33850
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { children: Object.values(data).join("") }),
33888
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { children: currentText }),
33889
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: canEdit2 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Button, { variant: "secondary", onClick: handleEditClick, title: "Edit", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: "edit" }) }) }),
33851
33890
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(RawDataCard, { data })
33852
33891
  ] });
33853
33892
  }
33893
+ var EditForm2 = styled18("form")`
33894
+ display: flex;
33895
+ flex-direction: column;
33896
+ gap: 0.75rem;
33897
+ margin-bottom: 1rem;
33898
+ `;
33899
+ var StyledTextarea2 = styled18("textarea")`
33900
+ width: 100%;
33901
+ min-height: 120px;
33902
+ border-radius: var(--j-radius-md);
33903
+ border: 1px solid var(--j-border-color);
33904
+ padding: 0.5rem 0.875rem;
33905
+ box-shadow: var(--j-shadow-sm);
33906
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
33907
+ font-size: 0.875rem;
33908
+ background-color: white;
33909
+ color: var(--j-text-color-strong);
33910
+ resize: vertical;
33911
+
33912
+ @media (prefers-color-scheme: dark) {
33913
+ background-color: var(--j-foreground);
33914
+ }
33915
+ `;
33916
+ var FormActions2 = styled18("div")`
33917
+ display: flex;
33918
+ gap: 0.5rem;
33919
+ justify-content: flex-end;
33920
+ `;
33854
33921
 
33855
33922
  // src/inspector/viewer/group-view.tsx
33856
- var import_react17 = __toESM(require_react(), 1);
33923
+ var import_react18 = __toESM(require_react(), 1);
33857
33924
  var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
33858
33925
  function partitionMembers(data) {
33859
33926
  const everyone = Object.entries(data).filter(([key]) => key === "everyone").map(([key, value]) => ({
@@ -33882,7 +33949,7 @@ function GroupView({
33882
33949
  onNavigate,
33883
33950
  node
33884
33951
  }) {
33885
- const [addMemberType, setAddMemberType] = (0, import_react17.useState)(null);
33952
+ const [addMemberType, setAddMemberType] = (0, import_react18.useState)(null);
33886
33953
  const { everyone, members, parentGroups, childGroups } = partitionMembers(
33887
33954
  data
33888
33955
  );
@@ -34142,17 +34209,17 @@ function RoleDisplay({
34142
34209
  }
34143
34210
 
34144
34211
  // src/inspector/viewer/table-viewer.tsx
34145
- var import_react18 = __toESM(require_react(), 1);
34146
- import { styled as styled18 } from "goober";
34212
+ var import_react19 = __toESM(require_react(), 1);
34213
+ import { styled as styled19 } from "goober";
34147
34214
  var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
34148
- var PaginationContainer = styled18("div")`
34215
+ var PaginationContainer = styled19("div")`
34149
34216
  padding: 1rem 0;
34150
34217
  display: flex;
34151
34218
  align-items: center;
34152
34219
  justify-content: space-between;
34153
34220
  gap: 0.5rem;
34154
34221
  `;
34155
- var RedTooltip = styled18("span")`
34222
+ var RedTooltip = styled19("span")`
34156
34223
  position:relative; /* making the .tooltip span a container for the tooltip text */
34157
34224
  border-bottom:1px dashed #000; /* little indicater to indicate it's hoverable */
34158
34225
 
@@ -34189,8 +34256,8 @@ function CoValuesTableView({
34189
34256
  onNavigate,
34190
34257
  onRemove
34191
34258
  }) {
34192
- const [visibleRowsCount, setVisibleRowsCount] = (0, import_react18.useState)(10);
34193
- const [coIdArray, visibleRows] = (0, import_react18.useMemo)(() => {
34259
+ const [visibleRowsCount, setVisibleRowsCount] = (0, import_react19.useState)(10);
34260
+ const [coIdArray, visibleRows] = (0, import_react19.useMemo)(() => {
34194
34261
  const coIdArray2 = Array.isArray(data) ? data : Object.values(data).every((k) => typeof k === "string" && isCoId(k)) ? Object.values(data).map((k) => k) : [];
34195
34262
  const visibleRows2 = coIdArray2.slice(0, visibleRowsCount);
34196
34263
  return [coIdArray2, visibleRows2];
@@ -34287,7 +34354,7 @@ function TableView({
34287
34354
  onNavigate,
34288
34355
  onRemove
34289
34356
  }) {
34290
- const isListOfCoValues = (0, import_react18.useMemo)(() => {
34357
+ const isListOfCoValues = (0, import_react19.useMemo)(() => {
34291
34358
  return Array.isArray(data) && data.every((k) => isCoId(k));
34292
34359
  }, [data]);
34293
34360
  if (isListOfCoValues) {
@@ -34316,8 +34383,8 @@ function TableView({
34316
34383
  }
34317
34384
 
34318
34385
  // src/inspector/viewer/history-view.tsx
34319
- var import_react19 = __toESM(require_react(), 1);
34320
- import { styled as styled19 } from "goober";
34386
+ var import_react20 = __toESM(require_react(), 1);
34387
+ import { styled as styled20 } from "goober";
34321
34388
 
34322
34389
  // src/inspector/utils/transactions-changes.ts
34323
34390
  var isGroupExtension = (change) => {
@@ -34360,13 +34427,147 @@ var isStreamEnd = (change) => {
34360
34427
  return change?.type === "end";
34361
34428
  };
34362
34429
 
34430
+ // src/inspector/utils/history.ts
34431
+ import { stringifyOpID } from "cojson";
34432
+ function areSameOpIds(opId1, opId2) {
34433
+ if (typeof opId1 === "string" || typeof opId2 === "string") {
34434
+ return opId1 === opId2;
34435
+ }
34436
+ return opId1.sessionID === opId2.sessionID && opId1.txIndex === opId2.txIndex && opId1.changeIdx === opId2.changeIdx;
34437
+ }
34438
+ function isCoPlainText(coValue) {
34439
+ return coValue.type === "coplaintext";
34440
+ }
34441
+ function getTransactionChanges(tx, coValue) {
34442
+ if (tx.isValid === false && tx.tx.privacy === "private") {
34443
+ const readKey = coValue.core.getReadKey(tx.tx.keyUsed);
34444
+ if (!readKey) {
34445
+ return [
34446
+ `Unable to decrypt transaction: read key ${tx.tx.keyUsed} not found.`
34447
+ ];
34448
+ }
34449
+ return coValue.core.verified.decryptTransaction(
34450
+ tx.txID.sessionID,
34451
+ tx.txID.txIndex,
34452
+ readKey
34453
+ ) ?? [];
34454
+ }
34455
+ if (isCoPlainText(coValue)) {
34456
+ if (tx.changes === void 0 || tx.changes.length === 0) return [];
34457
+ const firstChange = tx.changes[0];
34458
+ if (isItemAppend(firstChange) && tx.changes.every(
34459
+ (c) => isItemAppend(c) && areSameOpIds(c.after, firstChange.after)
34460
+ )) {
34461
+ const changes = tx.changes;
34462
+ if (firstChange.after !== "start") {
34463
+ changes.reverse();
34464
+ }
34465
+ return [
34466
+ {
34467
+ op: "app",
34468
+ value: changes.map((c) => c.value).join(""),
34469
+ after: firstChange.after
34470
+ }
34471
+ ];
34472
+ }
34473
+ if (isItemPrepend(firstChange) && tx.changes.every(
34474
+ (c) => isItemPrepend(c) && areSameOpIds(c.before, firstChange.before)
34475
+ )) {
34476
+ const changes = tx.changes;
34477
+ if (firstChange.before !== "end") {
34478
+ changes.reverse();
34479
+ }
34480
+ return [
34481
+ {
34482
+ op: "pre",
34483
+ value: changes.map((c) => c.value).join(""),
34484
+ before: firstChange.before
34485
+ }
34486
+ ];
34487
+ }
34488
+ if (isItemDeletion(firstChange) && tx.changes.every((c) => isItemDeletion(c))) {
34489
+ let changesAreConsecutive2 = function(changes) {
34490
+ if (changes.length < 2) return false;
34491
+ const mapping = coValueBeforeDeletions.mapping.idxAfterOpID;
34492
+ for (let i = 1; i < changes.length; ++i) {
34493
+ const prevIdx = mapping[stringifyOpID(changes[i - 1].insertion)];
34494
+ const currIdx = mapping[stringifyOpID(changes[i].insertion)];
34495
+ if (currIdx !== prevIdx && currIdx !== (prevIdx ?? -2) + 1) {
34496
+ return false;
34497
+ }
34498
+ }
34499
+ return true;
34500
+ };
34501
+ var changesAreConsecutive = changesAreConsecutive2;
34502
+ const coValueBeforeDeletions = coValue.atTime(tx.madeAt - 1);
34503
+ if (changesAreConsecutive2(tx.changes)) {
34504
+ const groupedBySession = /* @__PURE__ */ new Map();
34505
+ for (const change of tx.changes) {
34506
+ const group = `${change.insertion.sessionID}-${change.insertion.txIndex}`;
34507
+ if (!groupedBySession.has(group)) groupedBySession.set(group, []);
34508
+ groupedBySession.get(group).push(change);
34509
+ }
34510
+ return Array.from(groupedBySession.values()).map((changes) => {
34511
+ const stringDeleted = changes.toSorted((a, b) => {
34512
+ if (a.insertion.txIndex === b.insertion.txIndex) {
34513
+ return a.insertion.changeIdx - b.insertion.changeIdx;
34514
+ }
34515
+ return a.insertion.txIndex - b.insertion.txIndex;
34516
+ }).map(
34517
+ (c) => coValueBeforeDeletions.get(
34518
+ coValueBeforeDeletions.mapping.idxAfterOpID[stringifyOpID(c.insertion)]
34519
+ )
34520
+ ).join("");
34521
+ return {
34522
+ op: "custom",
34523
+ action: `"${stringDeleted}" has been deleted`
34524
+ };
34525
+ });
34526
+ }
34527
+ }
34528
+ }
34529
+ return tx.changes ?? tx.tx.changes ?? [];
34530
+ }
34531
+ function restoreCoMapToTimestamp(coValue, timestamp, removeUnknownProperties) {
34532
+ const myRole = coValue.group.myRole();
34533
+ if (myRole === void 0 || !["admin", "manager", "writer", "writerOnly"].includes(myRole)) {
34534
+ return;
34535
+ }
34536
+ const newCoValue = coValue.atTime(timestamp).toJSON();
34537
+ const oldCoValue = coValue.toJSON();
34538
+ if (newCoValue === null) return;
34539
+ let changes = [];
34540
+ if (removeUnknownProperties) {
34541
+ for (const key in oldCoValue) {
34542
+ if (!(key in newCoValue)) {
34543
+ changes.push({
34544
+ op: "del",
34545
+ key
34546
+ });
34547
+ }
34548
+ }
34549
+ }
34550
+ for (const key in newCoValue) {
34551
+ if (newCoValue[key] !== oldCoValue[key]) {
34552
+ changes.push({
34553
+ op: "set",
34554
+ key,
34555
+ value: newCoValue[key]
34556
+ });
34557
+ }
34558
+ }
34559
+ if (changes.length > 0) {
34560
+ coValue.core.makeTransaction(changes, "private");
34561
+ }
34562
+ }
34563
+
34363
34564
  // src/inspector/viewer/history-view.tsx
34364
34565
  var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
34365
34566
  function HistoryView({
34366
34567
  coValue,
34367
34568
  node
34368
34569
  }) {
34369
- const transactions = (0, import_react19.useMemo)(
34570
+ const transactions = (0, import_react20.useMemo)(
34370
34571
  () => getHistory(coValue),
34371
34572
  [coValue.core.verifiedTransactions.length]
34372
34573
  );
@@ -34440,22 +34641,6 @@ function HistoryView({
34440
34641
  }
34441
34642
  ) });
34442
34643
  }
34443
- function getTransactionChanges(tx, coValue) {
34444
- if (tx.isValid === false && tx.tx.privacy === "private") {
34445
- const readKey = coValue.core.getReadKey(tx.tx.keyUsed);
34446
- if (!readKey) {
34447
- return [
34448
- `Unable to decrypt transaction: read key ${tx.tx.keyUsed} not found.`
34449
- ];
34450
- }
34451
- return coValue.core.verified.decryptTransaction(
34452
- tx.txID.sessionID,
34453
- tx.txID.txIndex,
34454
- readKey
34455
- ) ?? [];
34456
- }
34457
- return tx.changes ?? tx.tx.changes ?? [];
34458
- }
34459
34644
  function getHistory(coValue) {
34460
34645
  return coValue.core.verifiedTransactions.flatMap((tx, index) => {
34461
34646
  const changes = getTransactionChanges(tx, coValue);
@@ -34534,6 +34719,9 @@ function mapTransactionToAction(change, coValue) {
34534
34719
  if (isPropertyDeletion(change)) {
34535
34720
  return `Property "${change.key}" has been deleted`;
34536
34721
  }
34722
+ if (change.op === "custom") {
34723
+ return change.action;
34724
+ }
34537
34725
  return "Unknown action: " + JSON.stringify(change);
34538
34726
  }
34539
34727
  var findListChange = (opId, coValue) => {
@@ -34541,7 +34729,7 @@ var findListChange = (opId, coValue) => {
34541
34729
  (tx) => tx.txID.sessionID === opId.sessionID && tx.txID.txIndex === opId.txIndex
34542
34730
  )?.changes?.[opId.changeIdx];
34543
34731
  };
34544
- var RedTooltip2 = styled19("span")`
34732
+ var RedTooltip2 = styled20("span")`
34545
34733
  position:relative; /* making the .tooltip span a container for the tooltip text */
34546
34734
  border-bottom:1px dashed #000; /* little indicater to indicate it's hoverable */
34547
34735
 
@@ -34574,44 +34762,8 @@ var RedTooltip2 = styled19("span")`
34574
34762
  `;
34575
34763
 
34576
34764
  // src/inspector/viewer/co-map-view.tsx
34577
- var import_react20 = __toESM(require_react(), 1);
34578
- import { styled as styled20 } from "goober";
34579
-
34580
- // src/inspector/utils/history.ts
34581
- function restoreCoMapToTimestamp(coValue, timestamp, removeUnknownProperties) {
34582
- const myRole = coValue.group.myRole();
34583
- if (myRole === void 0 || !["admin", "manager", "writer", "writerOnly"].includes(myRole)) {
34584
- return;
34585
- }
34586
- const newCoValue = coValue.atTime(timestamp).toJSON();
34587
- const oldCoValue = coValue.toJSON();
34588
- if (newCoValue === null) return;
34589
- let changes = [];
34590
- if (removeUnknownProperties) {
34591
- for (const key in oldCoValue) {
34592
- if (!(key in newCoValue)) {
34593
- changes.push({
34594
- op: "del",
34595
- key
34596
- });
34597
- }
34598
- }
34599
- }
34600
- for (const key in newCoValue) {
34601
- if (newCoValue[key] !== oldCoValue[key]) {
34602
- changes.push({
34603
- op: "set",
34604
- key,
34605
- value: newCoValue[key]
34606
- });
34607
- }
34608
- }
34609
- if (changes.length > 0) {
34610
- coValue.core.makeTransaction(changes, "private");
34611
- }
34612
- }
34613
-
34614
- // src/inspector/viewer/co-map-view.tsx
34765
+ var import_react21 = __toESM(require_react(), 1);
34766
+ import { styled as styled21 } from "goober";
34615
34767
  var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
34616
34768
  function CoMapView({
34617
34769
  coValue,
@@ -34648,8 +34800,8 @@ function AddPropertyModal({
34648
34800
  node,
34649
34801
  disabled
34650
34802
  }) {
34651
- const [isAddPropertyModalOpen, setIsAddPropertyModalOpen] = (0, import_react20.useState)(false);
34652
- const [propertyName, setPropertyName] = (0, import_react20.useState)("");
34803
+ const [isAddPropertyModalOpen, setIsAddPropertyModalOpen] = (0, import_react21.useState)(false);
34804
+ const [propertyName, setPropertyName] = (0, import_react21.useState)("");
34653
34805
  const openAddPropertyModal = () => {
34654
34806
  setIsAddPropertyModalOpen(true);
34655
34807
  setPropertyName("");
@@ -34702,14 +34854,14 @@ function AddPropertyModal({
34702
34854
  ] });
34703
34855
  }
34704
34856
  function RestoreSnapshotModal({ coValue }) {
34705
- const [isRestoreModalOpen, setIsRestoreModalOpen] = (0, import_react20.useState)(false);
34706
- const [selectedIndex, setSelectedIndex] = (0, import_react20.useState)(-1);
34707
- const [removeUnknownProperties, setRemoveUnknownProperties] = (0, import_react20.useState)(false);
34708
- const timestamps = (0, import_react20.useMemo)(
34857
+ const [isRestoreModalOpen, setIsRestoreModalOpen] = (0, import_react21.useState)(false);
34858
+ const [selectedIndex, setSelectedIndex] = (0, import_react21.useState)(-1);
34859
+ const [removeUnknownProperties, setRemoveUnknownProperties] = (0, import_react21.useState)(false);
34860
+ const timestamps = (0, import_react21.useMemo)(
34709
34861
  () => coValue.core.verifiedTransactions.map((tx) => tx.madeAt),
34710
34862
  [coValue.core.verifiedTransactions.length]
34711
34863
  );
34712
- const coMapAtSelectedIndex = (0, import_react20.useMemo)(() => {
34864
+ const coMapAtSelectedIndex = (0, import_react21.useMemo)(() => {
34713
34865
  if (selectedIndex === -1) return null;
34714
34866
  return coValue.atTime(timestamps[selectedIndex]).toJSON();
34715
34867
  }, [coValue, timestamps, selectedIndex]);
@@ -34786,15 +34938,15 @@ function RestoreSnapshotModal({ coValue }) {
34786
34938
  )
34787
34939
  ] });
34788
34940
  }
34789
- var PreviewSection = styled20("div")`
34941
+ var PreviewSection = styled21("div")`
34790
34942
  margin-top: 1.5rem;
34791
34943
  `;
34792
- var PreviewLabel = styled20("div")`
34944
+ var PreviewLabel = styled21("div")`
34793
34945
  font-weight: 500;
34794
34946
  margin-bottom: 0.5rem;
34795
34947
  color: var(--j-text-color-strong);
34796
34948
  `;
34797
- var PreviewPre = styled20("pre")`
34949
+ var PreviewPre = styled21("pre")`
34798
34950
  background-color: var(--j-foreground);
34799
34951
  border: 1px solid var(--j-border-color);
34800
34952
  border-radius: var(--j-radius-md);
@@ -34806,17 +34958,17 @@ var PreviewPre = styled20("pre")`
34806
34958
  color: var(--j-text-color);
34807
34959
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
34808
34960
  `;
34809
- var RangeContainer = styled20("div")`
34961
+ var RangeContainer = styled21("div")`
34810
34962
  display: flex;
34811
34963
  flex-direction: column;
34812
34964
  gap: 0.75rem;
34813
34965
  `;
34814
- var RangeLabel = styled20("label")`
34966
+ var RangeLabel = styled21("label")`
34815
34967
  font-weight: 500;
34816
34968
  color: var(--j-text-color-strong);
34817
34969
  font-size: 0.875rem;
34818
34970
  `;
34819
- var RangeInput = styled20("input")`
34971
+ var RangeInput = styled21("input")`
34820
34972
  width: 100%;
34821
34973
  height: 0.5rem;
34822
34974
  border-radius: var(--j-radius-sm);
@@ -34853,7 +35005,7 @@ var RangeInput = styled20("input")`
34853
35005
  cursor: not-allowed;
34854
35006
  }
34855
35007
  `;
34856
- var TimestampDisplay = styled20("div")`
35008
+ var TimestampDisplay = styled21("div")`
34857
35009
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
34858
35010
  font-size: 0.875rem;
34859
35011
  color: var(--j-text-color);
@@ -34863,35 +35015,35 @@ var TimestampDisplay = styled20("div")`
34863
35015
  border-radius: var(--j-radius-md);
34864
35016
  text-align: center;
34865
35017
  `;
34866
- var CheckboxContainer = styled20("div")`
35018
+ var CheckboxContainer = styled21("div")`
34867
35019
  display: flex;
34868
35020
  align-items: flex-start;
34869
35021
  gap: 0.5rem;
34870
35022
  margin-top: 1rem;
34871
35023
  `;
34872
- var CheckboxInput = styled20("input")`
35024
+ var CheckboxInput = styled21("input")`
34873
35025
  width: 1rem;
34874
35026
  height: 1rem;
34875
35027
  margin-top: 0.125rem;
34876
35028
  cursor: pointer;
34877
35029
  accent-color: var(--j-primary-color);
34878
35030
  `;
34879
- var CheckboxLabel = styled20("label")`
35031
+ var CheckboxLabel = styled21("label")`
34880
35032
  font-size: 0.875rem;
34881
35033
  color: var(--j-text-color);
34882
35034
  cursor: pointer;
34883
35035
  line-height: 1.25rem;
34884
35036
  `;
34885
- var EditorContainer = styled20("div")`
35037
+ var EditorContainer = styled21("div")`
34886
35038
  margin-top: 1rem;
34887
35039
  `;
34888
35040
 
34889
35041
  // src/inspector/viewer/page.tsx
34890
35042
  var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
34891
- var BasePageContainer = import_react21.default.forwardRef(
35043
+ var BasePageContainer = import_react22.default.forwardRef(
34892
35044
  ({ isTopLevel, ...rest }, ref) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { ref, ...rest })
34893
35045
  );
34894
- var PageContainer = styled21(BasePageContainer)`
35046
+ var PageContainer = styled22(BasePageContainer)`
34895
35047
  position: absolute;
34896
35048
  z-index: 10;
34897
35049
  inset: 0;
@@ -34899,36 +35051,36 @@ var PageContainer = styled21(BasePageContainer)`
34899
35051
  height: 100%;
34900
35052
  padding: 0 0.75rem;
34901
35053
  `;
34902
- var BackButton = styled21("div")`
35054
+ var BackButton = styled22("div")`
34903
35055
  position: absolute;
34904
35056
  left: 0;
34905
35057
  right: 0;
34906
35058
  top: 0;
34907
35059
  height: 2.5rem;
34908
35060
  `;
34909
- var HeaderContainer = styled21("div")`
35061
+ var HeaderContainer = styled22("div")`
34910
35062
  display: flex;
34911
35063
  justify-content: space-between;
34912
35064
  align-items: center;
34913
35065
  margin-bottom: 1rem;
34914
35066
  `;
34915
- var TitleContainer = styled21("div")`
35067
+ var TitleContainer = styled22("div")`
34916
35068
  display: flex;
34917
35069
  align-items: center;
34918
35070
  gap: 0.75rem;
34919
35071
  `;
34920
- var Title = styled21(Heading)`
35072
+ var Title = styled22(Heading)`
34921
35073
  display: flex;
34922
35074
  flex-direction: column;
34923
35075
  align-items: flex-start;
34924
35076
  gap: 0.25rem;
34925
35077
  `;
34926
- var BadgeContainer = styled21("div")`
35078
+ var BadgeContainer = styled22("div")`
34927
35079
  display: flex;
34928
35080
  align-items: center;
34929
35081
  gap: 0.75rem;
34930
35082
  `;
34931
- var ContentContainer = styled21("div")`
35083
+ var ContentContainer = styled22("div")`
34932
35084
  overflow: auto;
34933
35085
  display: flex;
34934
35086
  flex-direction: column;
@@ -34974,7 +35126,14 @@ function View(props) {
34974
35126
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AccountView, { data: snapshot, node, onNavigate });
34975
35127
  }
34976
35128
  if (type === "coplaintext") {
34977
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CoPlainTextView, { data: snapshot });
35129
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
35130
+ CoPlainTextView,
35131
+ {
35132
+ data: snapshot,
35133
+ coValue: value,
35134
+ node
35135
+ }
35136
+ );
34978
35137
  }
34979
35138
  if (type === "colist") {
34980
35139
  const handleRemove = (index) => {
@@ -35078,10 +35237,10 @@ function Page(props) {
35078
35237
  }
35079
35238
 
35080
35239
  // src/inspector/ui/error-boundary.tsx
35081
- var import_react22 = __toESM(require_react(), 1);
35240
+ var import_react23 = __toESM(require_react(), 1);
35082
35241
  var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
35083
- import { styled as styled22 } from "goober";
35084
- var ErrorBoundary = class extends import_react22.default.Component {
35242
+ import { styled as styled23 } from "goober";
35243
+ var ErrorBoundary = class extends import_react23.default.Component {
35085
35244
  constructor(props) {
35086
35245
  super(props);
35087
35246
  this.state = { hasError: false };
@@ -35103,7 +35262,7 @@ var ErrorBoundary = class extends import_react22.default.Component {
35103
35262
  return this.props.children;
35104
35263
  }
35105
35264
  };
35106
- var StyledHeading2 = styled22("h1")`
35265
+ var StyledHeading2 = styled23("h1")`
35107
35266
  font-size: 1.125rem;
35108
35267
  font-weight: 500;
35109
35268
  color: var(--j-text-color-strong);
@@ -35111,7 +35270,7 @@ var StyledHeading2 = styled22("h1")`
35111
35270
 
35112
35271
  // src/inspector/viewer/page-stack.tsx
35113
35272
  var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
35114
- var PageStackContainer = styled23("div")`
35273
+ var PageStackContainer = styled24("div")`
35115
35274
  position: relative;
35116
35275
  padding: 0 0.75rem;
35117
35276
  overflow-y: auto;
@@ -35145,10 +35304,10 @@ function PageStack({
35145
35304
  }
35146
35305
 
35147
35306
  // src/inspector/viewer/use-page-path.ts
35148
- var import_react23 = __toESM(require_react(), 1);
35307
+ var import_react24 = __toESM(require_react(), 1);
35149
35308
  var STORAGE_KEY = "jazz-inspector-paths";
35150
35309
  function usePagePath(defaultPath) {
35151
- const [path, setPath] = (0, import_react23.useState)(() => {
35310
+ const [path, setPath] = (0, import_react24.useState)(() => {
35152
35311
  if (typeof window === "undefined") return [];
35153
35312
  const stored = localStorage.getItem(STORAGE_KEY);
35154
35313
  if (stored) {
@@ -35160,34 +35319,34 @@ function usePagePath(defaultPath) {
35160
35319
  }
35161
35320
  return defaultPath || [];
35162
35321
  });
35163
- const updatePath = (0, import_react23.useCallback)((newPath) => {
35322
+ const updatePath = (0, import_react24.useCallback)((newPath) => {
35164
35323
  setPath(newPath);
35165
35324
  localStorage.setItem(STORAGE_KEY, JSON.stringify(newPath));
35166
35325
  }, []);
35167
- (0, import_react23.useEffect)(() => {
35326
+ (0, import_react24.useEffect)(() => {
35168
35327
  if (defaultPath && JSON.stringify(path) !== JSON.stringify(defaultPath)) {
35169
35328
  updatePath(defaultPath);
35170
35329
  }
35171
35330
  }, [defaultPath, path, updatePath]);
35172
- const addPages = (0, import_react23.useCallback)(
35331
+ const addPages = (0, import_react24.useCallback)(
35173
35332
  (newPages) => {
35174
35333
  updatePath([...path, ...newPages]);
35175
35334
  },
35176
35335
  [path, updatePath]
35177
35336
  );
35178
- const goToIndex = (0, import_react23.useCallback)(
35337
+ const goToIndex = (0, import_react24.useCallback)(
35179
35338
  (index) => {
35180
35339
  updatePath(path.slice(0, index + 1));
35181
35340
  },
35182
35341
  [path, updatePath]
35183
35342
  );
35184
- const setPage = (0, import_react23.useCallback)(
35343
+ const setPage = (0, import_react24.useCallback)(
35185
35344
  (coId) => {
35186
35345
  updatePath([{ coId, name: "Root" }]);
35187
35346
  },
35188
35347
  [updatePath]
35189
35348
  );
35190
- const goBack = (0, import_react23.useCallback)(() => {
35349
+ const goBack = (0, import_react24.useCallback)(() => {
35191
35350
  if (path.length > 1) {
35192
35351
  updatePath(path.slice(0, path.length - 1));
35193
35352
  }
@@ -35202,8 +35361,8 @@ function usePagePath(defaultPath) {
35202
35361
  }
35203
35362
 
35204
35363
  // src/inspector/ui/global-styles.tsx
35205
- import { styled as styled24 } from "goober";
35206
- var GlobalStyles = styled24("div")`
35364
+ import { styled as styled25 } from "goober";
35365
+ var GlobalStyles = styled25("div")`
35207
35366
  /* Colors */
35208
35367
  --j-primary-color: #146AFF;
35209
35368
  --j-link-color: var(--j-primary-color);
@@ -35278,8 +35437,8 @@ var GlobalStyles = styled24("div")`
35278
35437
 
35279
35438
  // src/inspector/viewer/inspector-button.tsx
35280
35439
  var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
35281
- import { styled as styled25 } from "goober";
35282
- var StyledInspectorButton = styled25("button")`
35440
+ import { styled as styled26 } from "goober";
35441
+ var StyledInspectorButton = styled26("button")`
35283
35442
  position: fixed;
35284
35443
  width: 2.5rem;
35285
35444
  height: 2.5rem;
@@ -35310,7 +35469,7 @@ var StyledInspectorButton = styled25("button")`
35310
35469
  }
35311
35470
  }}
35312
35471
  `;
35313
- var JazzIcon = styled25("svg")`
35472
+ var JazzIcon = styled26("svg")`
35314
35473
  width: 100%;
35315
35474
  height: auto;
35316
35475
  position: relative;
@@ -35362,27 +35521,27 @@ function InspectorButton({
35362
35521
  }
35363
35522
 
35364
35523
  // src/inspector/viewer/use-open-inspector.ts
35365
- var import_react24 = __toESM(require_react(), 1);
35524
+ var import_react25 = __toESM(require_react(), 1);
35366
35525
  var STORAGE_KEY2 = "jazz-inspector-open";
35367
35526
  function useOpenInspector() {
35368
- const [open, setOpen] = (0, import_react24.useState)(() => {
35527
+ const [open, setOpen] = (0, import_react25.useState)(() => {
35369
35528
  if (typeof window === "undefined") return false;
35370
35529
  const stored = localStorage.getItem(STORAGE_KEY2);
35371
35530
  return stored ? JSON.parse(stored) : false;
35372
35531
  });
35373
- (0, import_react24.useEffect)(() => {
35532
+ (0, import_react25.useEffect)(() => {
35374
35533
  localStorage.setItem(STORAGE_KEY2, JSON.stringify(open));
35375
35534
  }, [open]);
35376
35535
  return [open, setOpen];
35377
35536
  }
35378
35537
 
35379
35538
  // src/inspector/viewer/delete-local-data.tsx
35380
- var import_react25 = __toESM(require_react(), 1);
35539
+ var import_react26 = __toESM(require_react(), 1);
35381
35540
  var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
35382
35541
  var DELETE_LOCAL_DATA_STRING = "delete my local data";
35383
35542
  function DeleteLocalData() {
35384
- const [showDeleteModal, setShowDeleteModal] = (0, import_react25.useState)(false);
35385
- const [confirmDeleteString, setConfirmDeleteString] = (0, import_react25.useState)("");
35543
+ const [showDeleteModal, setShowDeleteModal] = (0, import_react26.useState)(false);
35544
+ const [confirmDeleteString, setConfirmDeleteString] = (0, import_react26.useState)("");
35386
35545
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
35387
35546
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { variant: "destructive", onClick: () => setShowDeleteModal(true), children: "Delete my local data" }),
35388
35547
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
@@ -35497,7 +35656,7 @@ function DeleteLocalData() {
35497
35656
 
35498
35657
  // src/inspector/viewer/new-app.tsx
35499
35658
  var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
35500
- var InspectorContainer = styled26("div")`
35659
+ var InspectorContainer = styled27("div")`
35501
35660
  position: fixed;
35502
35661
  height: 50vh;
35503
35662
  max-height: 800px;
@@ -35514,17 +35673,17 @@ var InspectorContainer = styled26("div")`
35514
35673
  background-color: var(--j-background);
35515
35674
  }
35516
35675
  `;
35517
- var HeaderContainer2 = styled26("div")`
35676
+ var HeaderContainer2 = styled27("div")`
35518
35677
  display: flex;
35519
35678
  align-items: center;
35520
35679
  gap: 1rem;
35521
35680
  padding: 0 0.75rem;
35522
35681
  margin: 0.75rem 0;
35523
35682
  `;
35524
- var Form = styled26("form")`
35683
+ var Form = styled27("form")`
35525
35684
  width: 24rem;
35526
35685
  `;
35527
- var InitialForm = styled26("form")`
35686
+ var InitialForm = styled27("form")`
35528
35687
  display: flex;
35529
35688
  flex-direction: column;
35530
35689
  position: relative;
@@ -35536,7 +35695,7 @@ var InitialForm = styled26("form")`
35536
35695
  max-width: 24rem;
35537
35696
  margin: 0 auto;
35538
35697
  `;
35539
- var OrText = styled26("p")`
35698
+ var OrText = styled27("p")`
35540
35699
  text-align: center;
35541
35700
  `;
35542
35701
  function JazzInspectorInternal({
@@ -35545,7 +35704,7 @@ function JazzInspectorInternal({
35545
35704
  accountId
35546
35705
  }) {
35547
35706
  const [open, setOpen] = useOpenInspector();
35548
- const [coValueId, setCoValueId] = (0, import_react26.useState)("");
35707
+ const [coValueId, setCoValueId] = (0, import_react27.useState)("");
35549
35708
  const { path, addPages, goToIndex, goBack, setPage } = usePagePath();
35550
35709
  const handleCoValueIdSubmit = (e) => {
35551
35710
  e.preventDefault();
@@ -35624,7 +35783,7 @@ function JazzInspectorInternal({
35624
35783
 
35625
35784
  // src/inspector/custom-element.tsx
35626
35785
  var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
35627
- setup(import_react27.default.createElement);
35786
+ setup(import_react28.default.createElement);
35628
35787
  var JazzInspectorElement = class extends HTMLElement {
35629
35788
  constructor() {
35630
35789
  super(...arguments);
@@ -35792,4 +35951,4 @@ react/cjs/react-jsx-runtime.development.js:
35792
35951
  * LICENSE file in the root directory of this source tree.
35793
35952
  *)
35794
35953
  */
35795
- //# sourceMappingURL=custom-element-3JAYHXWQ.js.map
35954
+ //# sourceMappingURL=custom-element-P76EIWEV.js.map