ryugi-artifacts 1.55.0 → 1.55.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.
package/dist/cli.cjs CHANGED
@@ -19084,7 +19084,7 @@ async function start(options, emit) {
19084
19084
  import_node_fs13.default.mkdirSync(paths.state, { recursive: true });
19085
19085
  if (!import_node_fs13.default.existsSync(import_node_path12.default.join(paths.state, ".gitignore")))
19086
19086
  import_node_fs13.default.writeFileSync(import_node_path12.default.join(paths.state, ".gitignore"), "*\n");
19087
- const cliVersion = process.env.RYUGI_ARTIFACTS_VERSION || (true ? "1.55.0" : "");
19087
+ const cliVersion = process.env.RYUGI_ARTIFACTS_VERSION || (true ? "1.55.1" : "");
19088
19088
  const known = readProjects(machine.projects).some((entry) => entry.dir === paths.project);
19089
19089
  const finish = async (info, reused, hint) => {
19090
19090
  recordAgent(paths);
@@ -19544,7 +19544,7 @@ var updateCommand = {
19544
19544
  },
19545
19545
  run: ({ values }, emit) => update2(
19546
19546
  {
19547
- current: "1.55.0",
19547
+ current: "1.55.1",
19548
19548
  file: __filename,
19549
19549
  env: process.env,
19550
19550
  registry: process.env.npm_config_registry || "https://registry.npmjs.org/",
@@ -19625,7 +19625,7 @@ async function main(argv) {
19625
19625
  const [name, ...rest] = argv;
19626
19626
  const command = COMMANDS.find((candidate) => candidate.name === name);
19627
19627
  const json = argv.includes("--json") || !command?.explicitJson && !process.stdout.isTTY;
19628
- notifyUpdate("1.55.0", json, argv);
19628
+ notifyUpdate("1.55.1", json, argv);
19629
19629
  const emit = (value) => {
19630
19630
  const line = json ? JSON.stringify(value) : text(value);
19631
19631
  if (!json && typeof value.error === "string") console.error(line);
@@ -19644,7 +19644,7 @@ async function main(argv) {
19644
19644
  return await command.run(parse(rest, command.options, command.positionals), emit);
19645
19645
  }
19646
19646
  if (name === "--version" || name === "-v") {
19647
- console.info("1.55.0");
19647
+ console.info("1.55.1");
19648
19648
  return 0;
19649
19649
  }
19650
19650
  if (name === "--help" || name === "-h") {
package/dist/server.cjs CHANGED
@@ -8799,7 +8799,7 @@ var import_node_os2 = __toESM(require("node:os"), 1);
8799
8799
  var import_node_path34 = __toESM(require("node:path"), 1);
8800
8800
 
8801
8801
  // package.json
8802
- var version = "1.55.0";
8802
+ var version = "1.55.1";
8803
8803
 
8804
8804
  // src/server/browser-focus.ts
8805
8805
  var import_node_child_process = require("node:child_process");
@@ -99878,30 +99878,79 @@ function agentEditAtVersion(doc, base, target, message) {
99878
99878
  return update2;
99879
99879
  }
99880
99880
  var seenByAgents = (message) => !!message && (message.startsWith("agent:") || message.startsWith("session "));
99881
- function seenVersion(doc, cursor) {
99882
- const oplog = doc.oplogVersion();
99883
- const known = cursor?.every((id2) => (oplog.get(id2.peer) ?? 0) > id2.counter) ?? false;
99884
- oplog.free();
99885
- const seen = doc.frontiersToVV(known ? cursor : []);
99886
- for (const change of [...doc.getAllChanges().values()].flat()) {
99887
- if (!seenByAgents(change.message)) continue;
99888
- const last = { peer: change.peer, counter: change.counter + change.length - 1 };
99889
- for (const [peer, end] of doc.frontiersToVV([last]).toJSON())
99890
- if ((seen.get(peer) ?? 0) < end) seen.setEnd({ peer, counter: end });
99891
- }
99892
- const frontiers = doc.vvToFrontiers(seen);
99893
- seen.free();
99894
- return frontiers;
99895
- }
99896
- function textAt(doc, frontiers) {
99881
+ var lastOp = (change) => ({
99882
+ peer: change.peer,
99883
+ counter: change.counter + change.length - 1
99884
+ });
99885
+ function blocksAt(doc, frontiers) {
99897
99886
  const fork = doc.fork();
99898
99887
  fork.checkout(frontiers);
99899
99888
  const editor = createDocumentHeadlessEditor();
99900
99889
  const binding = createLoroBinding(editor, fork);
99901
- const text3 = serializeDocument(editor.getEditorState().toJSON());
99890
+ const trees = fork.getTree(TREE_NAME).roots()[0]?.children()?.map((node) => node.id) ?? [];
99891
+ const state = editor.getEditorState().toJSON();
99902
99892
  binding.dispose();
99903
99893
  fork.free();
99904
- return text3;
99894
+ return state.root.children.map((child, index) => ({
99895
+ tree: trees[index] ?? `orphan-${index}`,
99896
+ text: serializeDocument({ ...state, root: { ...state.root, children: [child] } }).trimEnd().split("\n").slice(1, -1).join("\n")
99897
+ }));
99898
+ }
99899
+ var documentText = (blocks) => `<doc>
99900
+ ${blocks.map((b6) => `${b6}
99901
+ `).join("")}</doc>
99902
+ `;
99903
+ function unreportedHumanChanges(doc, cursor) {
99904
+ const changes = [...doc.getAllChanges().values()].flat();
99905
+ const oplog = doc.oplogVersion();
99906
+ const known = !!cursor?.length && cursor.every((id2) => (oplog.get(id2.peer) ?? 0) > id2.counter);
99907
+ oplog.free();
99908
+ const limit = doc.frontiersToVV(
99909
+ known ? cursor : changes.filter((change) => seenByAgents(change.message)).map(lastOp)
99910
+ );
99911
+ const unreported = changes.filter(
99912
+ (change) => change.message === "human" && change.counter + change.length > (limit.get(change.peer) ?? 0)
99913
+ ).sort((a5, b6) => a5.lamport - b6.lamport);
99914
+ limit.free();
99915
+ return unreported;
99916
+ }
99917
+ function humanChanges(doc, cursor) {
99918
+ const cache = /* @__PURE__ */ new Map();
99919
+ const at7 = (frontiers) => {
99920
+ const key2 = JSON.stringify(frontiers);
99921
+ let blocks = cache.get(key2);
99922
+ if (!blocks) cache.set(key2, blocks = blocksAt(doc, frontiers));
99923
+ return blocks;
99924
+ };
99925
+ const first = /* @__PURE__ */ new Map();
99926
+ for (const change of unreportedHumanChanges(doc, cursor)) {
99927
+ const before2 = at7(change.deps);
99928
+ const after2 = new Map(at7([lastOp(change)]).map((block) => [block.tree, block.text]));
99929
+ const seen = /* @__PURE__ */ new Set();
99930
+ before2.forEach((block, index) => {
99931
+ seen.add(block.tree);
99932
+ if (after2.get(block.tree) !== block.text && !first.has(block.tree))
99933
+ first.set(block.tree, { text: block.text, prev: before2[index - 1]?.tree ?? null });
99934
+ });
99935
+ for (const tree of after2.keys())
99936
+ if (!seen.has(tree) && !first.has(tree)) first.set(tree, { text: null, prev: null });
99937
+ }
99938
+ const current = at7(doc.frontiers());
99939
+ const previous = current.flatMap((block) => {
99940
+ const touched = first.get(block.tree);
99941
+ if (!touched) return [block];
99942
+ return touched.text === null ? [] : [{ tree: block.tree, text: touched.text }];
99943
+ });
99944
+ const present = new Set(current.map((block) => block.tree));
99945
+ for (const [tree, touched] of first) {
99946
+ if (touched.text === null || present.has(tree)) continue;
99947
+ const index = touched.prev ? previous.findIndex((block) => block.tree === touched.prev) + 1 : 0;
99948
+ previous.splice(index, 0, { tree, text: touched.text });
99949
+ }
99950
+ return {
99951
+ before: documentText(previous.map((block) => block.text)),
99952
+ after: documentText(current.map((block) => block.text))
99953
+ };
99905
99954
  }
99906
99955
  async function lastAgentWrite(activityFile, file) {
99907
99956
  const recorded = Number(await readText(activityFile));
@@ -100081,8 +100130,7 @@ async function createDocumentSession(options) {
100081
100130
  changesSince: async (cursor) => {
100082
100131
  await flush();
100083
100132
  const to3 = loro.frontiers();
100084
- const before2 = textAt(loro, seenVersion(loro, cursor));
100085
- const after2 = serializeDocument(editor.getEditorState().toJSON());
100133
+ const { before: before2, after: after2 } = humanChanges(loro, cursor);
100086
100134
  if (before2 === after2) return { diff: "", empty: true, to: to3 };
100087
100135
  return {
100088
100136
  diff: createTwoFilesPatch("doc.xml (seen)", "doc.xml", before2, after2),
@@ -10925,5 +10925,5 @@ function _p(e, t) {
10925
10925
  return e.code === "plan_limit" && hp(e.limit) ? gp(e.limit) : mp(e.code, typeof e.error == "string" ? e.error : t);
10926
10926
  }
10927
10927
  // src/viewer/lib/version.ts
10928
- var vp = "1.55.0";
10928
+ var vp = "1.55.1";
10929
10929
  export { c as ARTIFACT_LOCATOR_SOURCE, y as ARTIFACT_TYPES, lp as ArtboardView, vr as ArtifactThumbnail, e as BOARD_TYPES, f as CanvasErrorBoundary, v as ENTRY_FILE, Cr as EmbeddedCanvas, at as HTML_LANG, Se as HTML_SANDBOX, fp as HtmlView, j as MAIN_PORTS, tt as MAX_ARTIFACT_BYTES, ge as PHONE_QUERY, $e as PLAN_LIMIT_KINDS, D as PreviewView, Tr as PublicationStatus, rt as RELAY_DAILY_LIMIT, qe as RELAY_REJECTED_CODE, N as RailSwitch, Or as RyugiMark, ht as TYPE_GLYPHS, pt as TYPE_ICON_VIEWBOX, it as Trans, _r as TypeIcon, vp as VIEWER_VERSION, k as ViewerProvider, Be as anchorBlockIds, R as applyAgentOp, re as applyAgentThreadOp, gr as applyBoardAgentOp, hr as applyBoardHumanOp, ne as applyHumanOp, ce as applyThreadOp, lr as boardAnchors, Mr as boardCommentsFromMessage, jr as boardCommentsFromPayload, a as cloudErrorDetails, dt as createRelayConnection, et as createViewerI18n, Te as documentAnchors, ur as emptyBoardComments, M as emptyComments, mp as errorText, s as formatBytes, nt as i18n, t as isArtifactAddress, A as isArtifactId, l as isArtifactLocator, r as isArtifactType, $n as isChoiceRecord, i as isMediaBoard, n as isMintedArtifactId, we as isObject, hp as isPlanLimit, Ze as isVisibility, fr as mergeBoardComments, F as mergeComments, o as mintArtifactId, se as openThread, Xe as ownLink, Ir as pageLink, Je as parseAcceptLanguage, le as parseComments, gp as planLimitMessage, We as publishState, ot as publishing, cr as readBoardAnchor, ye as readCloudHeader, st as readPublication, pp as relativeUpdatedAt, Qe as relayRejection, He as reportCloudHeader, Ye as resolveLocale, _p as responseErrorText, dr as savedBoardComments, ie as savedComments, Ke as syncNote, U as t, ft as typeFaviconHref, oe as unreadThreads, Fr as useCanvasData, fe as useCloudHeader, ze as useMedia, Lr as usePageQuery, V as useSandboxFrame, u as useSystemTheme, Ge as useTranslation, ut as useTypeFavicon, P as waitingOn };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ryugi-artifacts",
3
- "version": "1.55.0",
3
+ "version": "1.55.1",
4
4
  "description": "Server and viewer for the Ryugi artifacts app",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",