ryugi-artifacts 1.68.3 → 1.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -4234,7 +4234,7 @@ async function startServer(options, hooks) {
4234
4234
  import_node_fs15.default.mkdirSync(paths.state, { recursive: true });
4235
4235
  if (!import_node_fs15.default.existsSync(import_node_path15.default.join(paths.state, ".gitignore")))
4236
4236
  import_node_fs15.default.writeFileSync(import_node_path15.default.join(paths.state, ".gitignore"), "*\n");
4237
- const cliVersion = process.env.RYUGI_ARTIFACTS_VERSION || (true ? "1.68.3" : "");
4237
+ const cliVersion = process.env.RYUGI_ARTIFACTS_VERSION || (true ? "1.69.0" : "");
4238
4238
  const known = readProjects(machine.projects).some((entry) => entry.dir === paths.project);
4239
4239
  const finish = async (info, reused) => {
4240
4240
  recordAgent(paths);
@@ -4665,7 +4665,7 @@ var updateCommand = {
4665
4665
  try {
4666
4666
  report2 = await performUpdate(
4667
4667
  {
4668
- current: "1.68.3",
4668
+ current: "1.69.0",
4669
4669
  file: __filename,
4670
4670
  env: process.env,
4671
4671
  registry: process.env.npm_config_registry || "https://registry.npmjs.org/",
@@ -4874,7 +4874,7 @@ async function main(argv) {
4874
4874
  process.on("SIGINT", interrupt);
4875
4875
  process.on("SIGTERM", terminate);
4876
4876
  try {
4877
- return await dispatchSemantic(argv, COMMANDS, BROWSE_OPTIONS, "1.68.3", selection.options, writer, abort.signal);
4877
+ return await dispatchSemantic(argv, COMMANDS, BROWSE_OPTIONS, "1.69.0", selection.options, writer, abort.signal);
4878
4878
  } finally {
4879
4879
  process.removeListener("SIGINT", interrupt);
4880
4880
  process.removeListener("SIGTERM", terminate);
package/dist/server.cjs CHANGED
@@ -48376,14 +48376,14 @@ var require_websocket_server = __commonJS({
48376
48376
  });
48377
48377
 
48378
48378
  // src/server/main.ts
48379
- var import_node_child_process5 = require("node:child_process");
48379
+ var import_node_child_process6 = require("node:child_process");
48380
48380
  var import_node_crypto13 = __toESM(require("node:crypto"), 1);
48381
48381
  var import_node_fs46 = __toESM(require("node:fs"), 1);
48382
48382
  var import_node_os2 = __toESM(require("node:os"), 1);
48383
- var import_node_path42 = __toESM(require("node:path"), 1);
48383
+ var import_node_path43 = __toESM(require("node:path"), 1);
48384
48384
 
48385
48385
  // package.json
48386
- var version = "1.68.3";
48386
+ var version = "1.69.0";
48387
48387
 
48388
48388
  // src/server/browser-focus.ts
48389
48389
  var import_node_child_process = require("node:child_process");
@@ -49191,7 +49191,7 @@ function clearCredentials(file) {
49191
49191
  // src/server/hub.ts
49192
49192
  var import_node_fs43 = __toESM(require("node:fs"), 1);
49193
49193
  var import_node_http2 = __toESM(require("node:http"), 1);
49194
- var import_node_path40 = __toESM(require("node:path"), 1);
49194
+ var import_node_path41 = __toESM(require("node:path"), 1);
49195
49195
 
49196
49196
  // src/server/access.ts
49197
49197
  var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "::1", "[::1]"]);
@@ -49220,7 +49220,7 @@ var navigationAllowed = (secFetchSite) => secFetchSite === void 0 || secFetchSit
49220
49220
  // src/server/app.ts
49221
49221
  var import_node_fs40 = __toESM(require("node:fs"), 1);
49222
49222
  var import_node_http = __toESM(require("node:http"), 1);
49223
- var import_node_path37 = __toESM(require("node:path"), 1);
49223
+ var import_node_path38 = __toESM(require("node:path"), 1);
49224
49224
 
49225
49225
  // src/shared/cloud.ts
49226
49226
  var MAX_ARTIFACT_BYTES = 20 * 1024 * 1024;
@@ -49626,9 +49626,9 @@ function watchArtifacts(ctx) {
49626
49626
  var PAGE_CSP = "sandbox allow-scripts allow-modals allow-forms allow-popups allow-downloads";
49627
49627
  var DOCUMENT_ASSET_CSP = "sandbox; default-src 'none'";
49628
49628
  var ISOLATED_BOARD_CSP = "worker-src 'none'";
49629
- function contentCsp(type, path45, ownOrigin) {
49629
+ function contentCsp(type, path46, ownOrigin) {
49630
49630
  if (type === "html") return PAGE_CSP;
49631
- if (type === "document") return path45.endsWith(".html") ? PAGE_CSP : DOCUMENT_ASSET_CSP;
49631
+ if (type === "document") return path46.endsWith(".html") ? PAGE_CSP : DOCUMENT_ASSET_CSP;
49632
49632
  return ownOrigin ? ISOLATED_BOARD_CSP : "sandbox allow-scripts";
49633
49633
  }
49634
49634
 
@@ -49657,7 +49657,7 @@ function routeBoardRequest(req, pathname) {
49657
49657
 
49658
49658
  // src/server/context.ts
49659
49659
  var import_node_fs36 = __toESM(require("node:fs"), 1);
49660
- var import_node_path33 = __toESM(require("node:path"), 1);
49660
+ var import_node_path34 = __toESM(require("node:path"), 1);
49661
49661
 
49662
49662
  // src/server/agent-review.ts
49663
49663
  var import_node_crypto5 = __toESM(require("node:crypto"), 1);
@@ -66665,7 +66665,7 @@ function createCloudRoutes(options2) {
66665
66665
  const challenge = import_node_crypto10.default.createHash("sha256").update(verifier).digest("base64url");
66666
66666
  return `${origin}/auth/cli?port=${options2.port()}&state=${state2}&challenge=${challenge}`;
66667
66667
  };
66668
- const cloudFetch = async (method, path45, body) => {
66668
+ const cloudFetch = async (method, path46, body) => {
66669
66669
  const credentials = readCredentials(credentialsFile2, origin);
66670
66670
  if (!credentials) throw new SignedOut();
66671
66671
  const headers = { Authorization: `Bearer ${credentials.token}` };
@@ -66679,7 +66679,7 @@ function createCloudRoutes(options2) {
66679
66679
  }
66680
66680
  let res;
66681
66681
  try {
66682
- res = await fetch(`${origin}${path45}`, { method, headers, body: payload });
66682
+ res = await fetch(`${origin}${path46}`, { method, headers, body: payload });
66683
66683
  } catch (err) {
66684
66684
  throw new CloudRefused(502, `could not reach ${origin}: ${err.message}`);
66685
66685
  }
@@ -66800,7 +66800,7 @@ function createCloudRoutes(options2) {
66800
66800
  const content = {
66801
66801
  title: inspected.title,
66802
66802
  payload: inspected.payload,
66803
- files: hashed.map(({ path: path45, hash: hash2 }) => ({ path: path45, hash: hash2 }))
66803
+ files: hashed.map(({ path: path46, hash: hash2 }) => ({ path: path46, hash: hash2 }))
66804
66804
  };
66805
66805
  const fingerprint = sha(
66806
66806
  JSON.stringify({
@@ -69117,19 +69117,19 @@ var ElementDOMSlot = class _ElementDOMSlot extends DOMSlot {
69117
69117
  }
69118
69118
  };
69119
69119
  function indexPath(root, child) {
69120
- const path45 = [];
69120
+ const path46 = [];
69121
69121
  let node = child;
69122
69122
  for (; node !== root && node !== null; node = node.parentNode) {
69123
69123
  let i7 = 0;
69124
69124
  for (let sibling = node.previousSibling; sibling !== null; sibling = sibling.previousSibling) {
69125
69125
  i7++;
69126
69126
  }
69127
- path45.push(i7);
69127
+ path46.push(i7);
69128
69128
  }
69129
69129
  if (!(node === root)) {
69130
69130
  formatDevErrorMessage(`indexPath: root is not a parent of child`);
69131
69131
  }
69132
- return path45.reverse();
69132
+ return path46.reverse();
69133
69133
  }
69134
69134
  var TEXT_MUTATION_VARIANCE = 100;
69135
69135
  var isProcessingMutations = false;
@@ -78489,9 +78489,9 @@ function getActiveElementDeep(root) {
78489
78489
  function getComposedEventTarget(event) {
78490
78490
  const target = event.target;
78491
78491
  if (target !== null && isHTMLElement(target) && target.shadowRoot !== null && typeof event.composedPath === "function") {
78492
- const path45 = event.composedPath();
78493
- if (path45.length > 0) {
78494
- return path45[0];
78492
+ const path46 = event.composedPath();
78493
+ if (path46.length > 0) {
78494
+ return path46[0];
78495
78495
  }
78496
78496
  }
78497
78497
  return target;
@@ -120629,10 +120629,10 @@ function $placeBlocks(runtime, $isTarget) {
120629
120629
  }
120630
120630
  const documentKey = $documentKey();
120631
120631
  for (const [key2, frame] of targets) {
120632
- const path45 = placeOf(frame);
120633
- let id3 = derivePositionalId(documentKey, path45);
120632
+ const path46 = placeOf(frame);
120633
+ let id3 = derivePositionalId(documentKey, path46);
120634
120634
  for (let attempt = 1; taken.has(id3); attempt++) {
120635
- id3 = derivePositionalId(documentKey, `${path45}#${attempt}`);
120635
+ id3 = derivePositionalId(documentKey, `${path46}#${attempt}`);
120636
120636
  }
120637
120637
  taken.add(id3);
120638
120638
  placed.set(key2, id3);
@@ -153382,27 +153382,27 @@ var sqrtTall = function sqrtTall2(extraVinculum, hLinePad2, viewBoxHeight) {
153382
153382
  };
153383
153383
  var sqrtPath = function sqrtPath2(size, extraVinculum, viewBoxHeight) {
153384
153384
  extraVinculum = 1e3 * extraVinculum;
153385
- var path45 = "";
153385
+ var path46 = "";
153386
153386
  switch (size) {
153387
153387
  case "sqrtMain":
153388
- path45 = sqrtMain(extraVinculum, hLinePad);
153388
+ path46 = sqrtMain(extraVinculum, hLinePad);
153389
153389
  break;
153390
153390
  case "sqrtSize1":
153391
- path45 = sqrtSize1(extraVinculum, hLinePad);
153391
+ path46 = sqrtSize1(extraVinculum, hLinePad);
153392
153392
  break;
153393
153393
  case "sqrtSize2":
153394
- path45 = sqrtSize2(extraVinculum, hLinePad);
153394
+ path46 = sqrtSize2(extraVinculum, hLinePad);
153395
153395
  break;
153396
153396
  case "sqrtSize3":
153397
- path45 = sqrtSize3(extraVinculum, hLinePad);
153397
+ path46 = sqrtSize3(extraVinculum, hLinePad);
153398
153398
  break;
153399
153399
  case "sqrtSize4":
153400
- path45 = sqrtSize4(extraVinculum, hLinePad);
153400
+ path46 = sqrtSize4(extraVinculum, hLinePad);
153401
153401
  break;
153402
153402
  case "sqrtTall":
153403
- path45 = sqrtTall(extraVinculum, hLinePad, viewBoxHeight);
153403
+ path46 = sqrtTall(extraVinculum, hLinePad, viewBoxHeight);
153404
153404
  }
153405
- return path45;
153405
+ return path46;
153406
153406
  };
153407
153407
  var innerPath = function innerPath2(name, height) {
153408
153408
  switch (name) {
@@ -157616,8 +157616,8 @@ var svgData = {
157616
157616
  };
157617
157617
  var staticSvg = function staticSvg2(value, options2) {
157618
157618
  var _svgData$value = svgData[value], pathName = _svgData$value[0], width = _svgData$value[1], height = _svgData$value[2];
157619
- var path45 = new PathNode(pathName);
157620
- var svgNode = new SvgNode([path45], {
157619
+ var path46 = new PathNode(pathName);
157620
+ var svgNode = new SvgNode([path46], {
157621
157621
  "width": makeEm(width),
157622
157622
  "height": makeEm(height),
157623
157623
  // Override CSS rule `.katex svg { width: 100% }`
@@ -158760,8 +158760,8 @@ var stretchySvg = function stretchySvg2(group, options2) {
158760
158760
  pathName = "tilde" + imgIndex;
158761
158761
  }
158762
158762
  }
158763
- var path45 = new PathNode(pathName);
158764
- var svgNode = new SvgNode([path45], {
158763
+ var path46 = new PathNode(pathName);
158764
+ var svgNode = new SvgNode([path46], {
158765
158765
  "width": "100%",
158766
158766
  "height": makeEm(_height),
158767
158767
  "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
@@ -159975,8 +159975,8 @@ var makeGlyphSpan = function makeGlyphSpan2(symbol, font, mode, options2) {
159975
159975
  };
159976
159976
  var makeInner = function makeInner2(ch4, height, options2) {
159977
159977
  var width = fontMetricsData["Size4-Regular"][ch4.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch4.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch4.charCodeAt(0)][4];
159978
- var path45 = new PathNode("inner", innerPath(ch4, Math.round(1e3 * height)));
159979
- var svgNode = new SvgNode([path45], {
159978
+ var path46 = new PathNode("inner", innerPath(ch4, Math.round(1e3 * height)));
159979
+ var svgNode = new SvgNode([path46], {
159980
159980
  "width": makeEm(width),
159981
159981
  "height": makeEm(height),
159982
159982
  // Override CSS rule `.katex svg { width: 100% }`
@@ -160145,10 +160145,10 @@ var makeStackedDelim = function makeStackedDelim2(delim, heightTotal, center, op
160145
160145
  var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal;
160146
160146
  var viewBoxHeight = Math.round(realHeightTotal * 1e3);
160147
160147
  var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1e3));
160148
- var path45 = new PathNode(svgLabel, pathStr);
160148
+ var path46 = new PathNode(svgLabel, pathStr);
160149
160149
  var width = makeEm(viewBoxWidth / 1e3);
160150
160150
  var height = makeEm(viewBoxHeight / 1e3);
160151
- var svg = new SvgNode([path45], {
160151
+ var svg = new SvgNode([path46], {
160152
160152
  "width": width,
160153
160153
  "height": height,
160154
160154
  "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight
@@ -160189,8 +160189,8 @@ var makeStackedDelim = function makeStackedDelim2(delim, heightTotal, center, op
160189
160189
  var vbPad = 80;
160190
160190
  var emPad = 0.08;
160191
160191
  var sqrtSvg = function sqrtSvg2(sqrtName, height, viewBoxHeight, extraVinculum, options2) {
160192
- var path45 = sqrtPath(sqrtName, extraVinculum, viewBoxHeight);
160193
- var pathNode = new PathNode(sqrtName, path45);
160192
+ var path46 = sqrtPath(sqrtName, extraVinculum, viewBoxHeight);
160193
+ var pathNode = new PathNode(sqrtName, path46);
160194
160194
  var svg = new SvgNode([pathNode], {
160195
160195
  // Note: 1000:1 ratio of viewBox to document em width.
160196
160196
  "width": "400em",
@@ -160689,8 +160689,8 @@ var htmlBuilder$7 = (group, options2) => {
160689
160689
  var angleHeight = inner2.height + inner2.depth + lineWeight + clearance;
160690
160690
  inner2.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight);
160691
160691
  var viewBoxHeight = Math.floor(1e3 * angleHeight * scale);
160692
- var path45 = phasePath(viewBoxHeight);
160693
- var svgNode = new SvgNode([new PathNode("phase", path45)], {
160692
+ var path46 = phasePath(viewBoxHeight);
160693
+ var svgNode = new SvgNode([new PathNode("phase", path46)], {
160694
160694
  "width": "400em",
160695
160695
  "height": makeEm(viewBoxHeight / 1e3),
160696
160696
  "viewBox": "0 0 400000 " + viewBoxHeight,
@@ -167231,9 +167231,9 @@ function _loadWasmModule(sync, filepath, src, imports2) {
167231
167231
  var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
167232
167232
  if (filepath && isNode2) {
167233
167233
  var fs50 = null;
167234
- var path45 = null;
167234
+ var path46 = null;
167235
167235
  return new Promise((resolve, reject) => {
167236
- fs50.readFile(path45.resolve(__dirname, filepath), (error, buffer) => {
167236
+ fs50.readFile(path46.resolve(__dirname, filepath), (error, buffer) => {
167237
167237
  if (error != null) {
167238
167238
  reject(error);
167239
167239
  } else {
@@ -168536,10 +168536,10 @@ var LoroDoc = class _LoroDoc {
168536
168536
  * @param {string} path
168537
168537
  * @returns {Value | Container | undefined}
168538
168538
  */
168539
- getByPath(path45) {
168539
+ getByPath(path46) {
168540
168540
  try {
168541
168541
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
168542
- const ptr0 = passStringToWasm0(path45, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
168542
+ const ptr0 = passStringToWasm0(path46, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
168543
168543
  const len0 = WASM_VECTOR_LEN;
168544
168544
  wasm.lorodoc_getByPath(retptr, this.__wbg_ptr, ptr0, len0);
168545
168545
  var r02 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -176160,16 +176160,16 @@ var Diff = class {
176160
176160
  }
176161
176161
  }
176162
176162
  }
176163
- addToPath(path45, added, removed, oldPosInc, options2) {
176164
- const last = path45.lastComponent;
176163
+ addToPath(path46, added, removed, oldPosInc, options2) {
176164
+ const last = path46.lastComponent;
176165
176165
  if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
176166
176166
  return {
176167
- oldPos: path45.oldPos + oldPosInc,
176167
+ oldPos: path46.oldPos + oldPosInc,
176168
176168
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
176169
176169
  };
176170
176170
  } else {
176171
176171
  return {
176172
- oldPos: path45.oldPos + oldPosInc,
176172
+ oldPos: path46.oldPos + oldPosInc,
176173
176173
  lastComponent: { count: 1, added, removed, previousComponent: last }
176174
176174
  };
176175
176175
  }
@@ -181705,6 +181705,42 @@ var MAX_RUNTIME_WARNINGS = 20;
181705
181705
  var MAX_COMMENT_OP = 64 * 1024;
181706
181706
  var MAX_DOCUMENT_UPDATE = 8 * 1024 * 1024;
181707
181707
 
181708
+ // src/server/project-name.ts
181709
+ var import_node_child_process3 = require("node:child_process");
181710
+ var import_node_path27 = __toESM(require("node:path"), 1);
181711
+ var SCP_LIKE = /^(?:[^@/]+@)?[^:/]+:(?!\/)(.+)$/;
181712
+ function remotePath(url) {
181713
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(url)) {
181714
+ try {
181715
+ const parsed = new URL(url);
181716
+ return parsed.protocol === "file:" ? null : parsed.pathname;
181717
+ } catch {
181718
+ return null;
181719
+ }
181720
+ }
181721
+ return SCP_LIKE.exec(url)?.[1] ?? null;
181722
+ }
181723
+ function remoteProject(url) {
181724
+ const pathname = remotePath(url.trim());
181725
+ if (!pathname) return null;
181726
+ const segments = pathname.replace(/\.git\/?$/, "").split("/").filter(Boolean);
181727
+ if (segments.length < 2) return null;
181728
+ return segments.join("/").toLowerCase();
181729
+ }
181730
+ function publishedProjectName(dir) {
181731
+ try {
181732
+ const url = (0, import_node_child_process3.execFileSync)("git", ["-C", dir, "remote", "get-url", "origin"], {
181733
+ encoding: "utf8",
181734
+ timeout: 2e3,
181735
+ stdio: ["ignore", "pipe", "ignore"],
181736
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
181737
+ });
181738
+ return remoteProject(url) ?? import_node_path27.default.basename(dir);
181739
+ } catch {
181740
+ return import_node_path27.default.basename(dir);
181741
+ }
181742
+ }
181743
+
181708
181744
  // src/server/artifact-file.ts
181709
181745
  var import_node_fs30 = __toESM(require("node:fs"), 1);
181710
181746
  var RESOLVE = {
@@ -181935,7 +181971,7 @@ async function handleRelay(ctx, key2, body, conn, contentOrigin = "") {
181935
181971
 
181936
181972
  // src/server/selection.ts
181937
181973
  var import_node_fs31 = __toESM(require("node:fs"), 1);
181938
- var import_node_path27 = __toESM(require("node:path"), 1);
181974
+ var import_node_path28 = __toESM(require("node:path"), 1);
181939
181975
 
181940
181976
  // src/shared/selection.ts
181941
181977
  var SELECTION_FULL_NODES = 20;
@@ -182080,7 +182116,7 @@ function readAnySelection(value) {
182080
182116
  function createSelectionStore(stateDir, exists) {
182081
182117
  const tabs = /* @__PURE__ */ new Map();
182082
182118
  let clock = 0;
182083
- const fileOf2 = (kind, id3) => import_node_path27.default.join(stateDir, kind, id3, "selection.json");
182119
+ const fileOf2 = (kind, id3) => import_node_path28.default.join(stateDir, kind, id3, "selection.json");
182084
182120
  const write = (kind, id3) => {
182085
182121
  let winner;
182086
182122
  for (const tab of tabs.values()) {
@@ -182130,7 +182166,7 @@ function createSelectionStore(stateDir, exists) {
182130
182166
  for (const kind of ["artboard", "document", "whiteboard"]) {
182131
182167
  let ids;
182132
182168
  try {
182133
- ids = import_node_fs31.default.readdirSync(import_node_path27.default.join(stateDir, kind));
182169
+ ids = import_node_fs31.default.readdirSync(import_node_path28.default.join(stateDir, kind));
182134
182170
  } catch {
182135
182171
  continue;
182136
182172
  }
@@ -182143,15 +182179,15 @@ function createSelectionStore(stateDir, exists) {
182143
182179
  // src/server/verify-recordings.ts
182144
182180
  var import_node_crypto11 = __toESM(require("node:crypto"), 1);
182145
182181
  var import_node_fs33 = __toESM(require("node:fs"), 1);
182146
- var import_node_path29 = __toESM(require("node:path"), 1);
182182
+ var import_node_path30 = __toESM(require("node:path"), 1);
182147
182183
 
182148
182184
  // src/server/recording-trim.ts
182149
- var import_node_child_process3 = require("node:child_process");
182185
+ var import_node_child_process4 = require("node:child_process");
182150
182186
  var import_node_fs32 = __toESM(require("node:fs"), 1);
182151
- var import_node_path28 = __toESM(require("node:path"), 1);
182187
+ var import_node_path29 = __toESM(require("node:path"), 1);
182152
182188
  function run2(command, args, signal3) {
182153
182189
  return new Promise((resolve, reject) => {
182154
- (0, import_node_child_process3.execFile)(
182190
+ (0, import_node_child_process4.execFile)(
182155
182191
  command,
182156
182192
  args,
182157
182193
  { encoding: "utf8", maxBuffer: 16 * 1024 * 1024, timeout: 12e4, signal: signal3 },
@@ -182240,9 +182276,9 @@ async function trimRecording(input, output, signal3) {
182240
182276
  if (start > 0 || end < duration) status = "trimmed";
182241
182277
  }
182242
182278
  if (status === "trimmed") {
182243
- const temporary = import_node_fs32.default.mkdtempSync(import_node_path28.default.join(import_node_path28.default.dirname(output), ".trim-"));
182279
+ const temporary = import_node_fs32.default.mkdtempSync(import_node_path29.default.join(import_node_path29.default.dirname(output), ".trim-"));
182244
182280
  try {
182245
- const encoded = import_node_path28.default.join(temporary, "clip.mp4");
182281
+ const encoded = import_node_path29.default.join(temporary, "clip.mp4");
182246
182282
  await run2(
182247
182283
  "ffmpeg",
182248
182284
  [
@@ -182305,7 +182341,7 @@ function createVerifyRecordings(options2) {
182305
182341
  const notify = (job) => {
182306
182342
  if (current(job)) options2.onChange(job.artifact);
182307
182343
  };
182308
- const cacheDir = import_node_path29.default.join(options2.stateDir, "recordings");
182344
+ const cacheDir = import_node_path30.default.join(options2.stateDir, "recordings");
182309
182345
  async function process2(job) {
182310
182346
  let temporary;
182311
182347
  try {
@@ -182322,9 +182358,9 @@ function createVerifyRecordings(options2) {
182322
182358
  return;
182323
182359
  }
182324
182360
  const key2 = digest2(`${POLICY}:${digest2(bytes)}`);
182325
- const dir = import_node_path29.default.join(cacheDir, key2);
182326
- const output = import_node_path29.default.join(dir, "clip.mp4");
182327
- const metadata = import_node_path29.default.join(dir, "result.json");
182361
+ const dir = import_node_path30.default.join(cacheDir, key2);
182362
+ const output = import_node_path30.default.join(dir, "clip.mp4");
182363
+ const metadata = import_node_path30.default.join(dir, "result.json");
182328
182364
  let cached;
182329
182365
  try {
182330
182366
  const saved = JSON.parse(import_node_fs33.default.readFileSync(metadata, "utf8"));
@@ -182334,9 +182370,9 @@ function createVerifyRecordings(options2) {
182334
182370
  }
182335
182371
  if (!cached) {
182336
182372
  import_node_fs33.default.mkdirSync(cacheDir, { recursive: true });
182337
- temporary = import_node_fs33.default.mkdtempSync(import_node_path29.default.join(cacheDir, ".prepare-"));
182338
- const input = import_node_path29.default.join(temporary, "capture");
182339
- const prepared = import_node_path29.default.join(temporary, "clip.mp4");
182373
+ temporary = import_node_fs33.default.mkdtempSync(import_node_path30.default.join(cacheDir, ".prepare-"));
182374
+ const input = import_node_path30.default.join(temporary, "capture");
182375
+ const prepared = import_node_path30.default.join(temporary, "clip.mp4");
182340
182376
  import_node_fs33.default.writeFileSync(input, bytes);
182341
182377
  const result = await (options2.prepare ?? trimRecording)(
182342
182378
  input,
@@ -182494,7 +182530,7 @@ function createVerifyRecordings(options2) {
182494
182530
 
182495
182531
  // src/server/whiteboard.ts
182496
182532
  var import_node_fs34 = __toESM(require("node:fs"), 1);
182497
- var import_node_path30 = __toESM(require("node:path"), 1);
182533
+ var import_node_path31 = __toESM(require("node:path"), 1);
182498
182534
 
182499
182535
  // src/server/whiteboard-lint.ts
182500
182536
  var LINE_TYPES = /* @__PURE__ */ new Set(["arrow", "line"]);
@@ -182544,16 +182580,16 @@ var segmentsCross = (a5, b6, c10, d10) => side(a5, b6, c10) * side(a5, b6, d10)
182544
182580
  var pathOf = (element) => {
182545
182581
  const { points: points2 } = element;
182546
182582
  if (!Array.isArray(points2) || points2.length < 2) return null;
182547
- const path45 = [];
182583
+ const path46 = [];
182548
182584
  for (const point2 of points2) {
182549
182585
  if (!Array.isArray(point2) || typeof point2[0] !== "number" || typeof point2[1] !== "number")
182550
182586
  return null;
182551
- path45.push([(element.x ?? 0) + point2[0], (element.y ?? 0) + point2[1]]);
182587
+ path46.push([(element.x ?? 0) + point2[0], (element.y ?? 0) + point2[1]]);
182552
182588
  }
182553
- return path45;
182589
+ return path46;
182554
182590
  };
182555
- var segmentsOf = (path45) => path45.slice(1).map((end, index) => [path45[index], end]);
182556
- var lengthOf = (path45) => segmentsOf(path45).reduce((sum2, [a5, b6]) => sum2 + Math.hypot(b6[0] - a5[0], b6[1] - a5[1]), 0);
182591
+ var segmentsOf = (path46) => path46.slice(1).map((end, index) => [path46[index], end]);
182592
+ var lengthOf = (path46) => segmentsOf(path46).reduce((sum2, [a5, b6]) => sum2 + Math.hypot(b6[0] - a5[0], b6[1] - a5[1]), 0);
182557
182593
  var boundIds = (element) => [element.startBinding?.elementId, element.endBinding?.elementId].filter(
182558
182594
  (id3) => typeof id3 === "string"
182559
182595
  );
@@ -182590,18 +182626,18 @@ function arrowWarnings(live3, geometry) {
182590
182626
  );
182591
182627
  const arrows = live3.flatMap((element) => {
182592
182628
  if (!LINE_TYPES.has(element.type) || ryugi(element).author !== "agent") return [];
182593
- const path45 = pathOf(element);
182594
- return path45 ? [{ element, path: path45, bound: boundIds(element) }] : [];
182629
+ const path46 = pathOf(element);
182630
+ return path46 ? [{ element, path: path46, bound: boundIds(element) }] : [];
182595
182631
  });
182596
182632
  const warnings = [];
182597
- for (const { element, path: path45 } of arrows) {
182598
- const ends = [path45[0], path45.at(-1)];
182633
+ for (const { element, path: path46 } of arrows) {
182634
+ const ends = [path46[0], path46.at(-1)];
182599
182635
  const around = obstacles.filter(
182600
182636
  (shape2) => !ends.some((end) => holds(geometry[shape2.id], end))
182601
182637
  );
182602
182638
  for (const shape2 of around) {
182603
182639
  const box2 = inset(geometry[shape2.id], GRAZE);
182604
- if (segmentsOf(path45).some(([a5, b6]) => segmentHits(a5, b6, box2)))
182640
+ if (segmentsOf(path46).some(([a5, b6]) => segmentHits(a5, b6, box2)))
182605
182641
  warnings.push(
182606
182642
  `arrow ${element.id} crosses ${shape2.id} \u2014 move ${shape2.id} or bend the arrow around it`
182607
182643
  );
@@ -182619,7 +182655,7 @@ function arrowWarnings(live3, geometry) {
182619
182655
  const need = Math.ceil(
182620
182656
  (Math.abs(dx2) * label.w + Math.abs(dy2) * label.h) / chord + LABEL_MARGIN
182621
182657
  );
182622
- const length = lengthOf(path45);
182658
+ const length = lengthOf(path46);
182623
182659
  if (length < need)
182624
182660
  warnings.push(
182625
182661
  `label of arrow ${element.id} needs the arrow to be at least ${need} px long (now ${Math.round(length)}) \u2014 move its ends apart or shorten the label`
@@ -182651,7 +182687,7 @@ function readWhiteboard(dir, id3) {
182651
182687
  const version3 = latestMtime(dir);
182652
182688
  let source;
182653
182689
  try {
182654
- source = import_node_fs34.default.readFileSync(import_node_path30.default.join(dir, ENTRY_FILE.whiteboard), "utf8");
182690
+ source = import_node_fs34.default.readFileSync(import_node_path31.default.join(dir, ENTRY_FILE.whiteboard), "utf8");
182655
182691
  } catch {
182656
182692
  return {
182657
182693
  title: id3,
@@ -182774,7 +182810,7 @@ function onlyPage(result, page, pages) {
182774
182810
  }
182775
182811
 
182776
182812
  // src/server/whiteboard-comments.ts
182777
- var import_node_path31 = __toESM(require("node:path"), 1);
182813
+ var import_node_path32 = __toESM(require("node:path"), 1);
182778
182814
 
182779
182815
  // src/shared/whiteboard/comments.ts
182780
182816
  var MAX_ELEMENTS = 50;
@@ -182899,7 +182935,7 @@ function createWhiteboardComments(options2) {
182899
182935
  let found = stores.get(id3);
182900
182936
  if (!found) {
182901
182937
  found = createStore(
182902
- import_node_path31.default.join(options2.root, "whiteboard", id3, "comments.json"),
182938
+ import_node_path32.default.join(options2.root, "whiteboard", id3, "comments.json"),
182903
182939
  rules,
182904
182940
  options2.names
182905
182941
  );
@@ -182996,7 +183032,7 @@ function createWhiteboardComments(options2) {
182996
183032
 
182997
183033
  // src/server/whiteboards.ts
182998
183034
  var import_node_fs35 = __toESM(require("node:fs"), 1);
182999
- var import_node_path32 = __toESM(require("node:path"), 1);
183035
+ var import_node_path33 = __toESM(require("node:path"), 1);
183000
183036
 
183001
183037
  // src/server/whiteboard-merge.ts
183002
183038
  var nonce = () => Math.floor(Math.random() * 2 ** 31);
@@ -183151,9 +183187,9 @@ function createWhiteboards(opts) {
183151
183187
  const geometries = /* @__PURE__ */ new Map();
183152
183188
  const renders = /* @__PURE__ */ new Map();
183153
183189
  const legacyCleared = /* @__PURE__ */ new Set();
183154
- const stateDir = opts.stateDir ?? import_node_path32.default.join(opts.root, ".state");
183155
- const stateOf2 = (id3) => import_node_path32.default.join(stateDir, "whiteboard", id3);
183156
- const pageStateOf = (id3, page) => import_node_path32.default.join(stateOf2(id3), "pages", page);
183190
+ const stateDir = opts.stateDir ?? import_node_path33.default.join(opts.root, ".state");
183191
+ const stateOf2 = (id3) => import_node_path33.default.join(stateDir, "whiteboard", id3);
183192
+ const pageStateOf = (id3, page) => import_node_path33.default.join(stateOf2(id3), "pages", page);
183157
183193
  const keyOf = (id3, page) => `${id3}
183158
183194
  ${page}`;
183159
183195
  const list2 = (id3) => {
@@ -183161,7 +183197,7 @@ ${page}`;
183161
183197
  if (existing) return existing;
183162
183198
  const dir = resolveArtifactDir(opts.root, "whiteboard", id3);
183163
183199
  if (!dir) return null;
183164
- const file = import_node_path32.default.join(dir, PAGES_FILE);
183200
+ const file = import_node_path33.default.join(dir, PAGES_FILE);
183165
183201
  const text5 = readText3(file);
183166
183202
  const parsed = parsePages(text5);
183167
183203
  const created = {
@@ -183195,7 +183231,7 @@ ${page}`;
183195
183231
  if (existing) return existing;
183196
183232
  const dir = resolveArtifactDir(opts.root, "whiteboard", id3);
183197
183233
  if (!dir) return null;
183198
- const file = import_node_path32.default.join(dir, pageFileOf(page));
183234
+ const file = import_node_path33.default.join(dir, pageFileOf(page));
183199
183235
  const text5 = readText3(file);
183200
183236
  const parsed = text5 === null ? { scene: emptyScene() } : parseScene(text5, pageFileOf(page));
183201
183237
  const session = {
@@ -183224,7 +183260,7 @@ ${page}`;
183224
183260
  session.pending = false;
183225
183261
  const text5 = serializeScene(session.scene);
183226
183262
  if (text5 === session.written) return;
183227
- import_node_fs35.default.mkdirSync(import_node_path32.default.dirname(session.file), { recursive: true });
183263
+ import_node_fs35.default.mkdirSync(import_node_path33.default.dirname(session.file), { recursive: true });
183228
183264
  writeTextAtomic(session.file, text5);
183229
183265
  session.written = text5;
183230
183266
  };
@@ -183290,7 +183326,7 @@ ${page}`;
183290
183326
  if (legacyCleared.has(id3)) return;
183291
183327
  legacyCleared.add(id3);
183292
183328
  for (const name of ["render.png", "render.json", "geometry.json"])
183293
- import_node_fs35.default.rmSync(import_node_path32.default.join(stateOf2(id3), name), { force: true });
183329
+ import_node_fs35.default.rmSync(import_node_path33.default.join(stateOf2(id3), name), { force: true });
183294
183330
  };
183295
183331
  const known = (id3, page) => isPageId(page) && resolveArtifactDir(opts.root, "whiteboard", id3) !== null;
183296
183332
  const live3 = (id3) => livePages(normalized2(id3)?.pages ?? []);
@@ -183359,19 +183395,19 @@ ${page}`;
183359
183395
  reportGeometry(id3, geometry, page = MAIN_PAGE) {
183360
183396
  if (!validGeometry(geometry) || !known(id3, page)) return false;
183361
183397
  geometries.set(keyOf(id3, page), geometry);
183362
- writeJsonAtomic(import_node_path32.default.join(pageStateOf(id3, page), "geometry.json"), geometry);
183398
+ writeJsonAtomic(import_node_path33.default.join(pageStateOf(id3, page), "geometry.json"), geometry);
183363
183399
  stateWritten(id3);
183364
183400
  return true;
183365
183401
  },
183366
183402
  render: (id3, page = MAIN_PAGE) => renders.get(keyOf(id3, page)) ?? null,
183367
- renderPathOf: (id3, page = MAIN_PAGE) => import_node_path32.default.join(pageStateOf(id3, page), "render.png"),
183403
+ renderPathOf: (id3, page = MAIN_PAGE) => import_node_path33.default.join(pageStateOf(id3, page), "render.png"),
183368
183404
  reportRender(id3, png, sceneVersion, page = MAIN_PAGE) {
183369
183405
  if (!Number.isFinite(sceneVersion) || !known(id3, page)) return false;
183370
183406
  import_node_fs35.default.mkdirSync(pageStateOf(id3, page), { recursive: true });
183371
- writeTextAtomic(import_node_path32.default.join(pageStateOf(id3, page), "render.png"), png);
183407
+ writeTextAtomic(import_node_path33.default.join(pageStateOf(id3, page), "render.png"), png);
183372
183408
  const meta = { sceneVersion, at: (/* @__PURE__ */ new Date()).toISOString() };
183373
183409
  renders.set(keyOf(id3, page), meta);
183374
- writeJsonAtomic(import_node_path32.default.join(pageStateOf(id3, page), "render.json"), meta);
183410
+ writeJsonAtomic(import_node_path33.default.join(pageStateOf(id3, page), "render.json"), meta);
183375
183411
  stateWritten(id3);
183376
183412
  return true;
183377
183413
  },
@@ -183425,15 +183461,15 @@ function titleOf(payload) {
183425
183461
  return "Untitled artifact";
183426
183462
  }
183427
183463
  function createServerContext(options2) {
183428
- const root = import_node_path33.default.resolve(options2.root);
183429
- const viewerDir = import_node_path33.default.resolve(options2.viewerDir);
183430
- const runtimeDir = options2.runtimeDir ? import_node_path33.default.resolve(options2.runtimeDir) : null;
183431
- const stateDir = import_node_path33.default.join(root, ".state");
183464
+ const root = import_node_path34.default.resolve(options2.root);
183465
+ const viewerDir = import_node_path34.default.resolve(options2.viewerDir);
183466
+ const runtimeDir = options2.runtimeDir ? import_node_path34.default.resolve(options2.runtimeDir) : null;
183467
+ const stateDir = import_node_path34.default.join(root, ".state");
183432
183468
  import_node_fs36.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
183433
- import_node_fs36.default.writeFileSync(import_node_path33.default.join(stateDir, ".gitignore"), "*\n");
183469
+ import_node_fs36.default.writeFileSync(import_node_path34.default.join(stateDir, ".gitignore"), "*\n");
183434
183470
  if (options2.configFile) ensureConfig(options2.configFile);
183435
- const portFile = import_node_path33.default.join(stateDir, ".last-port");
183436
- const tokenFile = import_node_path33.default.join(stateDir, ".last-token");
183471
+ const portFile = import_node_path34.default.join(stateDir, ".last-port");
183472
+ const tokenFile = import_node_path34.default.join(stateDir, ".last-token");
183437
183473
  const mount = options2.mount;
183438
183474
  const token = mount?.token ?? (readPersisted(tokenFile) || randomToken());
183439
183475
  if (!mount) import_node_fs36.default.writeFileSync(tokenFile, `${token}
@@ -183475,7 +183511,7 @@ function createServerContext(options2) {
183475
183511
  const pages = whiteboards.livePages(id3).flatMap((page) => {
183476
183512
  const scene = whiteboards.scene(id3, page.id);
183477
183513
  if (!scene) return [];
183478
- const bytes = import_node_fs36.default.statSync(import_node_path33.default.join(dir, pageFileOf(page.id)), { throwIfNoEntry: false })?.size ?? 0;
183514
+ const bytes = import_node_fs36.default.statSync(import_node_path34.default.join(dir, pageFileOf(page.id)), { throwIfNoEntry: false })?.size ?? 0;
183479
183515
  return [
183480
183516
  {
183481
183517
  id: page.id,
@@ -183548,8 +183584,8 @@ function createServerContext(options2) {
183548
183584
  });
183549
183585
  const avatars = createAvatars(options2.fetch);
183550
183586
  const names = commentNames({
183551
- agentFile: import_node_path33.default.join(stateDir, "agent"),
183552
- projectDir: import_node_path33.default.resolve(root, "../.."),
183587
+ agentFile: import_node_path34.default.join(stateDir, "agent"),
183588
+ projectDir: import_node_path34.default.resolve(root, "../.."),
183553
183589
  cloud: options2.cloud
183554
183590
  });
183555
183591
  const whiteboardComments = createWhiteboardComments({
@@ -183663,7 +183699,7 @@ function createServerContext(options2) {
183663
183699
  const cloud = options2.cloud && options2.configFile ? createCloudRoutes({
183664
183700
  ...options2.cloud,
183665
183701
  configFile: options2.configFile,
183666
- project: import_node_path33.default.basename(import_node_path33.default.resolve(root, "../..")),
183702
+ project: publishedProjectName(import_node_path34.default.resolve(root, "../..")),
183667
183703
  address: (ref) => artifactPath(root, ref.type, ref.id).split("/").pop(),
183668
183704
  references: (ref) => referencesOf(root, `${ref.type}/${ref.id}`),
183669
183705
  referrers: (ref) => referrersOf(root, `${ref.type}/${ref.id}`),
@@ -183674,7 +183710,7 @@ function createServerContext(options2) {
183674
183710
  }
183675
183711
  }) : null;
183676
183712
  const autoPublisher = cloud ? createAutoPublisher({
183677
- stateFile: import_node_path33.default.join(stateDir, "auto-publish.json"),
183713
+ stateFile: import_node_path34.default.join(stateDir, "auto-publish.json"),
183678
183714
  enabled: cloud.autoPublishEnabled,
183679
183715
  token: cloud.token,
183680
183716
  publish: async (key2) => {
@@ -183735,7 +183771,7 @@ function createServerContext(options2) {
183735
183771
  ref.type === "artboard" ? { ...extra, ...artboardHints(ref.id) } : extra
183736
183772
  );
183737
183773
  writeJsonAtomic(
183738
- import_node_path33.default.join(stateDir, ref.type, ref.id, "backlinks.json"),
183774
+ import_node_path34.default.join(stateDir, ref.type, ref.id, "backlinks.json"),
183739
183775
  backlinksOf(ref.id, ref.type)
183740
183776
  );
183741
183777
  } catch (err) {
@@ -183830,7 +183866,7 @@ function createServerContext(options2) {
183830
183866
  };
183831
183867
  return ctx;
183832
183868
  }
183833
- var projectName = (ctx) => import_node_path33.default.basename(import_node_path33.default.dirname(import_node_path33.default.dirname(ctx.root)));
183869
+ var projectName = (ctx) => import_node_path34.default.basename(import_node_path34.default.dirname(import_node_path34.default.dirname(ctx.root)));
183834
183870
 
183835
183871
  // ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/wrapper.mjs
183836
183872
  var import_stream = __toESM(require_stream(), 1);
@@ -184005,7 +184041,7 @@ function createRelayClient(options2) {
184005
184041
 
184006
184042
  // src/server/routes/content.ts
184007
184043
  var import_node_fs37 = __toESM(require("node:fs"), 1);
184008
- var import_node_path34 = __toESM(require("node:path"), 1);
184044
+ var import_node_path35 = __toESM(require("node:path"), 1);
184009
184045
  function serveContent(ctx, res, rest, range, mode = "main") {
184010
184046
  const { root, runtimeDir, recordings, options: options2 } = ctx;
184011
184047
  if (rest.startsWith("runtime/")) {
@@ -184093,7 +184129,7 @@ var robotsRoute = {
184093
184129
  path: "/robots.txt",
184094
184130
  auth: "public",
184095
184131
  handle: (_req, res, ctx) => {
184096
- sendFile(res, import_node_path34.default.join(ctx.viewerDir, "robots.txt"));
184132
+ sendFile(res, import_node_path35.default.join(ctx.viewerDir, "robots.txt"));
184097
184133
  }
184098
184134
  };
184099
184135
  var contentRoute = {
@@ -184141,7 +184177,7 @@ var createBoardRequestHandler = (ctx) => (req, res) => {
184141
184177
 
184142
184178
  // src/server/routes/agent.ts
184143
184179
  var import_node_fs38 = __toESM(require("node:fs"), 1);
184144
- var import_node_path35 = __toESM(require("node:path"), 1);
184180
+ var import_node_path36 = __toESM(require("node:path"), 1);
184145
184181
 
184146
184182
  // src/shared/whiteboard/summary.ts
184147
184183
  var STICKY_FILL = "#ffec99";
@@ -184272,7 +184308,7 @@ var CHECK_BROWSER_WAIT_MS = 1e4;
184272
184308
  var agentName = (fields) => typeof fields.agent === "string" && fields.agent.length > 0 && fields.agent.length <= 100 ? fields.agent : void 0;
184273
184309
  var blockIdsOf = async (ctx, id3, dir) => {
184274
184310
  await (await ctx.documents.open(id3))?.flush();
184275
- const state2 = parseDocument2(import_node_fs38.default.readFileSync(import_node_path35.default.join(dir, "doc.xml"), "utf8"));
184311
+ const state2 = parseDocument2(import_node_fs38.default.readFileSync(import_node_path36.default.join(dir, "doc.xml"), "utf8"));
184276
184312
  return new Set(
184277
184313
  state2.root.children.flatMap(
184278
184314
  (block) => block.$?.blockId ? [block.$.blockId] : []
@@ -184457,7 +184493,7 @@ async function serveAgentCheck(res, ctx, type, id3, page = null) {
184457
184493
  let merging = false;
184458
184494
  if (ref.type === "document") {
184459
184495
  const session = await documents.open(ref.id);
184460
- const text5 = await import_node_fs38.default.promises.readFile(import_node_path35.default.join(dir, "doc.xml"), "utf8").catch(() => null);
184496
+ const text5 = await import_node_fs38.default.promises.readFile(import_node_path36.default.join(dir, "doc.xml"), "utf8").catch(() => null);
184461
184497
  if (session && text5 !== null) {
184462
184498
  session.onFileText(text5);
184463
184499
  const timeout = new Promise(
@@ -184470,7 +184506,7 @@ async function serveAgentCheck(res, ctx, type, id3, page = null) {
184470
184506
  if (ref.type === "whiteboard") await whiteboardCaughtUp(ctx, ref.id, checkedPages);
184471
184507
  const payload = ctx.writeState(ref, dir);
184472
184508
  const written = JSON.parse(
184473
- await import_node_fs38.default.promises.readFile(import_node_path35.default.join(stateDir, ref.type, ref.id, "warnings.json"), "utf8")
184509
+ await import_node_fs38.default.promises.readFile(import_node_path36.default.join(stateDir, ref.type, ref.id, "warnings.json"), "utf8")
184474
184510
  );
184475
184511
  const state2 = page === null ? written : {
184476
184512
  ...written,
@@ -184637,7 +184673,7 @@ async function serveAgentWhiteboardScene(req, res, ctx, id3) {
184637
184673
  sendJson(res, 404, { error: `whiteboard/${id3} not found` });
184638
184674
  return;
184639
184675
  }
184640
- const selection = readSelectedIds(import_node_path35.default.join(ctx.stateDir, "whiteboard", id3, "selection.json"));
184676
+ const selection = readSelectedIds(import_node_path36.default.join(ctx.stateDir, "whiteboard", id3, "selection.json"));
184641
184677
  const summary = summarize(scene, { ...frame ? { frame } : {}, selected: selection });
184642
184678
  sendJson(res, 200, {
184643
184679
  artifact: `whiteboard/${id3}`,
@@ -184961,8 +184997,8 @@ function shape(element, at7, scale) {
184961
184997
  case "arrow":
184962
184998
  case "line":
184963
184999
  case "freedraw": {
184964
- const path45 = points(element).map(([dx2, dy2]) => at7(x9 + dx2, y5 + dy2).join(",")).join(" ");
184965
- return path45 ? `<polyline points="${path45}" stroke="${stroke}" stroke-width="1.4" fill="none" stroke-linecap="round"/>` : "";
185000
+ const path46 = points(element).map(([dx2, dy2]) => at7(x9 + dx2, y5 + dy2).join(",")).join(" ");
185001
+ return path46 ? `<polyline points="${path46}" stroke="${stroke}" stroke-width="1.4" fill="none" stroke-linecap="round"/>` : "";
184966
185002
  }
184967
185003
  case "text": {
184968
185004
  const size = Math.max(4, Math.min(28, h9 || 12 * scale));
@@ -185232,7 +185268,9 @@ function renderThumbnail(artifact, value) {
185232
185268
  25,
185233
185269
  505,
185234
185270
  3
185235
- ).map((line2, i7) => text4(42, 160 + i7 * 36, line2, 25, "var(--ink)", 600)).join("")}${text4(42, 318, `${artifact.project ?? "RYUGI"} / HTML`, 11, "var(--muted)")}`;
185271
+ ).map((line2, i7) => text4(42, 160 + i7 * 36, line2, 25, "var(--ink)", 600)).join(
185272
+ ""
185273
+ )}${text4(42, 318, `${artifact.project?.split("/").at(-1) ?? "RYUGI"} / HTML`, 11, "var(--muted)")}`;
185236
185274
  }
185237
185275
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 360"><title>${escape6(title)}</title>${STYLE3}${body}</svg>`;
185238
185276
  }
@@ -185499,7 +185537,7 @@ var clientSocketRoute = {
185499
185537
 
185500
185538
  // src/server/routes/viewer.ts
185501
185539
  var import_node_fs39 = __toESM(require("node:fs"), 1);
185502
- var import_node_path36 = __toESM(require("node:path"), 1);
185540
+ var import_node_path37 = __toESM(require("node:path"), 1);
185503
185541
 
185504
185542
  // src/shared/type-icons.ts
185505
185543
  var TYPE_GLYPHS = {
@@ -185628,8 +185666,8 @@ function serveShell(req, res, ctx, { pathname, key: key2 }, embedded) {
185628
185666
  if (ref) headers["Referrer-Policy"] = "same-origin";
185629
185667
  if (key2 !== null && !loopback)
185630
185668
  headers["Set-Cookie"] = `${ctx.cookieName}=${ctx.token}; HttpOnly; SameSite=Strict; Path=/`;
185631
- const entry = preview2 && import_node_fs39.default.existsSync(import_node_path36.default.join(viewerDir, "preview.html")) ? "preview.html" : "index.html";
185632
- void import_node_fs39.default.promises.readFile(import_node_path36.default.join(viewerDir, entry), "utf8").then((template) => {
185669
+ const entry = preview2 && import_node_fs39.default.existsSync(import_node_path37.default.join(viewerDir, "preview.html")) ? "preview.html" : "index.html";
185670
+ void import_node_fs39.default.promises.readFile(import_node_path37.default.join(viewerDir, entry), "utf8").then((template) => {
185633
185671
  const html = viewerPage(template, {
185634
185672
  title,
185635
185673
  description,
@@ -185990,7 +186028,7 @@ async function startArtifactsServer(options2) {
185990
186028
  const boardServer = import_node_http.default.createServer(handleBoardRequest);
185991
186029
  if (mount) ctx.boardPort = mount.boardPort;
185992
186030
  else if (loopback) {
185993
- const boardPortFile = import_node_path37.default.join(stateDir, BOARD_PORT_FILE);
186031
+ const boardPortFile = import_node_path38.default.join(stateDir, BOARD_PORT_FILE);
185994
186032
  const previousBoardPort = Number(readPersisted(boardPortFile));
185995
186033
  try {
185996
186034
  ctx.boardPort = await listen(
@@ -186020,7 +186058,7 @@ async function startArtifactsServer(options2) {
186020
186058
  initialChanges.push({ ref: entry, payload, files: [] });
186021
186059
  if (entry.type === "document") void ctx.documents.open(entry.id);
186022
186060
  }
186023
- writeJsonAtomic(import_node_path37.default.join(stateDir, "server-info"), {
186061
+ writeJsonAtomic(import_node_path38.default.join(stateDir, "server-info"), {
186024
186062
  type: "server-started",
186025
186063
  url,
186026
186064
  port,
@@ -186104,7 +186142,7 @@ async function startArtifactsServer(options2) {
186104
186142
  });
186105
186143
  await ctx.documents.close().catch(() => void 0);
186106
186144
  ctx.whiteboards.close();
186107
- if (mount) import_node_fs40.default.rmSync(import_node_path37.default.join(stateDir, "server-info"), { force: true });
186145
+ if (mount) import_node_fs40.default.rmSync(import_node_path38.default.join(stateDir, "server-info"), { force: true });
186108
186146
  }
186109
186147
  };
186110
186148
  }
@@ -186112,27 +186150,27 @@ var mountArtifactsProject = (options2) => startArtifactsServer(options2);
186112
186150
 
186113
186151
  // src/server/artifact-index.ts
186114
186152
  var import_node_fs42 = __toESM(require("node:fs"), 1);
186115
- var import_node_path39 = __toESM(require("node:path"), 1);
186153
+ var import_node_path40 = __toESM(require("node:path"), 1);
186116
186154
 
186117
186155
  // src/server/machine.ts
186118
186156
  var import_node_fs41 = __toESM(require("node:fs"), 1);
186119
186157
  var import_node_os = __toESM(require("node:os"), 1);
186120
- var import_node_path38 = __toESM(require("node:path"), 1);
186158
+ var import_node_path39 = __toESM(require("node:path"), 1);
186121
186159
  var DORMANT_AFTER_MS = 7 * 24 * 60 * 60 * 1e3;
186122
186160
  function machinePaths(env = process.env, homedir = import_node_os.default.homedir()) {
186123
- const home = env.RYUGI_SERVER_HOME || import_node_path38.default.join(homedir, ".ryugi", "server");
186161
+ const home = env.RYUGI_SERVER_HOME || import_node_path39.default.join(homedir, ".ryugi", "server");
186124
186162
  return {
186125
186163
  home,
186126
- pid: import_node_path38.default.join(home, "server.pid"),
186127
- serverId: import_node_path38.default.join(home, "server-instance-id"),
186128
- info: import_node_path38.default.join(home, "server-info"),
186129
- log: import_node_path38.default.join(home, "server.log"),
186130
- version: import_node_path38.default.join(home, "server-version"),
186131
- lock: import_node_path38.default.join(home, "start.lock"),
186132
- key: import_node_path38.default.join(home, "key"),
186133
- projects: import_node_path38.default.join(home, "projects.json"),
186134
- settings: import_node_path38.default.join(home, "settings.json"),
186135
- stopped: import_node_path38.default.join(home, "server-stopped")
186164
+ pid: import_node_path39.default.join(home, "server.pid"),
186165
+ serverId: import_node_path39.default.join(home, "server-instance-id"),
186166
+ info: import_node_path39.default.join(home, "server-info"),
186167
+ log: import_node_path39.default.join(home, "server.log"),
186168
+ version: import_node_path39.default.join(home, "server-version"),
186169
+ lock: import_node_path39.default.join(home, "start.lock"),
186170
+ key: import_node_path39.default.join(home, "key"),
186171
+ projects: import_node_path39.default.join(home, "projects.json"),
186172
+ settings: import_node_path39.default.join(home, "settings.json"),
186173
+ stopped: import_node_path39.default.join(home, "server-stopped")
186136
186174
  };
186137
186175
  }
186138
186176
  function ensureHome(home) {
@@ -186141,14 +186179,14 @@ function ensureHome(home) {
186141
186179
  }
186142
186180
  var realDir = (dir) => {
186143
186181
  try {
186144
- return import_node_fs41.default.realpathSync(import_node_path38.default.resolve(dir));
186182
+ return import_node_fs41.default.realpathSync(import_node_path39.default.resolve(dir));
186145
186183
  } catch {
186146
- return import_node_path38.default.resolve(dir);
186184
+ return import_node_path39.default.resolve(dir);
186147
186185
  }
186148
186186
  };
186149
186187
  var validEntry = (value) => {
186150
186188
  const entry = value;
186151
- return !!entry && typeof entry.dir === "string" && import_node_path38.default.isAbsolute(entry.dir) && Number.isFinite(entry.registeredAt) && Number.isFinite(entry.lastUsedAt);
186189
+ return !!entry && typeof entry.dir === "string" && import_node_path39.default.isAbsolute(entry.dir) && Number.isFinite(entry.registeredAt) && Number.isFinite(entry.lastUsedAt);
186152
186190
  };
186153
186191
  function readProjects(file) {
186154
186192
  try {
@@ -186159,7 +186197,7 @@ function readProjects(file) {
186159
186197
  }
186160
186198
  }
186161
186199
  function writeProjects(file, projects) {
186162
- ensureHome(import_node_path38.default.dirname(file));
186200
+ ensureHome(import_node_path39.default.dirname(file));
186163
186201
  const tmp = `${file}.${process.pid}.tmp`;
186164
186202
  import_node_fs41.default.writeFileSync(tmp, `${JSON.stringify({ projects }, null, 2)}
186165
186203
  `, { mode: 384 });
@@ -186180,7 +186218,7 @@ function removeProject(file, projectDir) {
186180
186218
  const kept = projects.filter((entry) => entry.dir !== dir);
186181
186219
  if (kept.length !== projects.length) writeProjects(file, kept);
186182
186220
  }
186183
- var artifactsRootOf = (projectDir) => import_node_path38.default.join(projectDir, ".ryugi", "artifacts");
186221
+ var artifactsRootOf = (projectDir) => import_node_path39.default.join(projectDir, ".ryugi", "artifacts");
186184
186222
  function pruneProjects(file) {
186185
186223
  const projects = readProjects(file);
186186
186224
  const kept = projects.filter((entry) => import_node_fs41.default.existsSync(artifactsRootOf(entry.dir)));
@@ -186192,7 +186230,7 @@ var isDormant = (entry, now = Date.now()) => now - entry.lastUsedAt > DORMANT_AF
186192
186230
  // src/server/artifact-index.ts
186193
186231
  var readAddress = (dir) => {
186194
186232
  try {
186195
- const value = import_node_fs42.default.readFileSync(import_node_path39.default.join(dir, ".artifact-id"), "utf8").trim();
186233
+ const value = import_node_fs42.default.readFileSync(import_node_path40.default.join(dir, ".artifact-id"), "utf8").trim();
186196
186234
  return isArtifactAddress(value) ? value : null;
186197
186235
  } catch {
186198
186236
  return null;
@@ -186299,7 +186337,7 @@ var ARTIFACT_KEY = /^(?:artboard|document|html)\/[a-z0-9][a-z0-9-]*$/;
186299
186337
  var SEP = "\n";
186300
186338
  var realDir2 = (dir) => {
186301
186339
  try {
186302
- return import_node_fs43.default.realpathSync(import_node_path40.default.resolve(dir));
186340
+ return import_node_fs43.default.realpathSync(import_node_path41.default.resolve(dir));
186303
186341
  } catch {
186304
186342
  return null;
186305
186343
  }
@@ -186357,7 +186395,7 @@ async function startHub(options2) {
186357
186395
  runtimeDir: options2.runtimeDir,
186358
186396
  host: options2.host,
186359
186397
  urlHost: options2.urlHost,
186360
- configFile: import_node_path40.default.join(project, ".ryugi", "config.json"),
186398
+ configFile: import_node_path41.default.join(project, ".ryugi", "config.json"),
186361
186399
  cloud: options2.cloud,
186362
186400
  fetch: options2.fetch,
186363
186401
  debounceMs: options2.debounceMs,
@@ -186372,7 +186410,7 @@ async function startHub(options2) {
186372
186410
  }
186373
186411
  return pending;
186374
186412
  };
186375
- const configFileOf = (project) => import_node_path40.default.join(project, ".ryugi", "config.json");
186413
+ const configFileOf = (project) => import_node_path41.default.join(project, ".ryugi", "config.json");
186376
186414
  const servedBy = (project) => {
186377
186415
  const mounted = ready.get(project);
186378
186416
  if (mounted) return mounted.served();
@@ -186419,10 +186457,10 @@ async function startHub(options2) {
186419
186457
  }) : null;
186420
186458
  const origin = `http://${urlHostForHttp(options2.urlHost)}:${port}`;
186421
186459
  const url = loopback ? `${origin}/` : `${origin}/?key=${options2.token}`;
186422
- const infoFileOf = (project) => import_node_path40.default.join(artifactsRootOf(project), ".state", "server-info");
186460
+ const infoFileOf = (project) => import_node_path41.default.join(artifactsRootOf(project), ".state", "server-info");
186423
186461
  const writeCompatInfo = (project) => {
186424
186462
  try {
186425
- import_node_fs43.default.mkdirSync(import_node_path40.default.dirname(infoFileOf(project)), { recursive: true, mode: 448 });
186463
+ import_node_fs43.default.mkdirSync(import_node_path41.default.dirname(infoFileOf(project)), { recursive: true, mode: 448 });
186426
186464
  writeJsonAtomic(infoFileOf(project), {
186427
186465
  type: "server-started",
186428
186466
  url,
@@ -186441,7 +186479,7 @@ async function startHub(options2) {
186441
186479
  counts.set(entry.project, (counts.get(entry.project) ?? 0) + 1);
186442
186480
  return ordered3().map((entry) => ({
186443
186481
  dir: entry.dir,
186444
- name: import_node_path40.default.basename(entry.dir),
186482
+ name: import_node_path41.default.basename(entry.dir),
186445
186483
  lastUsedAt: entry.lastUsedAt,
186446
186484
  dormant: isDormant(entry),
186447
186485
  artifacts: counts.get(entry.dir) ?? 0
@@ -186454,7 +186492,7 @@ async function startHub(options2) {
186454
186492
  const root = artifactsRootOf(entry.dir);
186455
186493
  const listed = listArtifacts(root);
186456
186494
  for (const warning of listed.warnings)
186457
- warnings.push(`${import_node_path40.default.basename(entry.dir)}: ${warning}`);
186495
+ warnings.push(`${import_node_path41.default.basename(entry.dir)}: ${warning}`);
186458
186496
  for (const artifact of listed.artifacts) {
186459
186497
  try {
186460
186498
  artifacts.push({
@@ -186505,7 +186543,7 @@ async function startHub(options2) {
186505
186543
  };
186506
186544
  const publishedIn = (project, cloudId) => {
186507
186545
  try {
186508
- const { artifacts } = readConfig(import_node_path40.default.join(project, ".ryugi", "config.json")).config;
186546
+ const { artifacts } = readConfig(import_node_path41.default.join(project, ".ryugi", "config.json")).config;
186509
186547
  return Object.values(artifacts).some((entry) => entry.cloud?.id === cloudId);
186510
186548
  } catch {
186511
186549
  return false;
@@ -186578,7 +186616,7 @@ async function startHub(options2) {
186578
186616
  return entry;
186579
186617
  };
186580
186618
  const remove2 = async (dir) => {
186581
- const real = realDir2(dir) ?? import_node_path40.default.resolve(dir);
186619
+ const real = realDir2(dir) ?? import_node_path41.default.resolve(dir);
186582
186620
  removeProject(projectsFile, real);
186583
186621
  index.rescan();
186584
186622
  import_node_fs43.default.rmSync(infoFileOf(real), { force: true });
@@ -186745,9 +186783,9 @@ async function startHub(options2) {
186745
186783
  }
186746
186784
 
186747
186785
  // src/server/relaunch.ts
186748
- var import_node_child_process4 = require("node:child_process");
186786
+ var import_node_child_process5 = require("node:child_process");
186749
186787
  var import_node_fs44 = __toESM(require("node:fs"), 1);
186750
- var import_node_path41 = __toESM(require("node:path"), 1);
186788
+ var import_node_path42 = __toESM(require("node:path"), 1);
186751
186789
  var LAUNCHER_COMMAND = /^node "(.+)"$/;
186752
186790
  var WAIT_THEN_RUN = `
186753
186791
  const [pid, file, ...args] = process.argv.slice(1);
@@ -186761,17 +186799,17 @@ tick();
186761
186799
  function relaunchCommand(env, serverDir) {
186762
186800
  const launcher = LAUNCHER_COMMAND.exec(env.RYUGI_ARTIFACTS_LAUNCHER ?? "")?.[1];
186763
186801
  if (launcher) return [process.execPath, launcher];
186764
- const cli = import_node_path41.default.join(serverDir, "cli.cjs");
186802
+ const cli = import_node_path42.default.join(serverDir, "cli.cjs");
186765
186803
  return import_node_fs44.default.existsSync(cli) ? [process.execPath, cli] : null;
186766
186804
  }
186767
186805
  function pinLauncherRelease(env, homedir, version3, now = Date.now()) {
186768
- const releases = import_node_path41.default.join(
186769
- env.XDG_CACHE_HOME || import_node_path41.default.join(homedir, ".cache"),
186806
+ const releases = import_node_path42.default.join(
186807
+ env.XDG_CACHE_HOME || import_node_path42.default.join(homedir, ".cache"),
186770
186808
  "ryugi",
186771
186809
  "artifacts"
186772
186810
  );
186773
186811
  import_node_fs44.default.mkdirSync(releases, { recursive: true });
186774
- const file = import_node_path41.default.join(releases, "latest.json");
186812
+ const file = import_node_path42.default.join(releases, "latest.json");
186775
186813
  const tmp = `${file}.${process.pid}`;
186776
186814
  import_node_fs44.default.writeFileSync(tmp, JSON.stringify({ version: version3, checkedAt: now }));
186777
186815
  import_node_fs44.default.renameSync(tmp, file);
@@ -186779,7 +186817,7 @@ function pinLauncherRelease(env, homedir, version3, now = Date.now()) {
186779
186817
  function spawnAfterExit(pid, argv, env = process.env) {
186780
186818
  const [file, ...args] = argv;
186781
186819
  if (!file) return;
186782
- (0, import_node_child_process4.spawn)(process.execPath, ["-e", WAIT_THEN_RUN, String(pid), file, ...args], {
186820
+ (0, import_node_child_process5.spawn)(process.execPath, ["-e", WAIT_THEN_RUN, String(pid), file, ...args], {
186783
186821
  detached: true,
186784
186822
  stdio: "ignore",
186785
186823
  windowsHide: true,
@@ -186853,14 +186891,14 @@ async function main2() {
186853
186891
  const paths = machinePaths();
186854
186892
  ensureHome(paths.home);
186855
186893
  const updates = createUpdateCheck({
186856
- cacheFile: import_node_path42.default.join(paths.home, "latest.json"),
186894
+ cacheFile: import_node_path43.default.join(paths.home, "latest.json"),
186857
186895
  current: version
186858
186896
  });
186859
186897
  const hub = await startHub({
186860
186898
  host: config.host,
186861
186899
  urlHost: config.urlHost,
186862
- viewerDir: import_node_path42.default.join(__dirname, "viewer"),
186863
- runtimeDir: import_node_path42.default.join(__dirname, "runtime"),
186900
+ viewerDir: import_node_path43.default.join(__dirname, "viewer"),
186901
+ runtimeDir: import_node_path43.default.join(__dirname, "runtime"),
186864
186902
  ports: config.ports,
186865
186903
  boardPorts: config.boardPorts,
186866
186904
  paths,
@@ -186879,7 +186917,7 @@ async function main2() {
186879
186917
  open: async (link, local, openCmd) => {
186880
186918
  const command = openCmd ?? config.openCmd;
186881
186919
  if (command) {
186882
- (0, import_node_child_process5.exec)(`${command} ${JSON.stringify(link)}`, () => {
186920
+ (0, import_node_child_process6.exec)(`${command} ${JSON.stringify(link)}`, () => {
186883
186921
  });
186884
186922
  return;
186885
186923
  }
@@ -11653,7 +11653,7 @@ function Am(e, t) {
11653
11653
  return e.code === "plan_limit" && Om(e.limit) ? km(e.limit) : Dm(e.code, typeof e.error == "string" ? e.error : t);
11654
11654
  }
11655
11655
  // src/viewer/lib/version.ts
11656
- var jm = "1.68.3", Mm = {
11656
+ var jm = "1.69.0", Mm = {
11657
11657
  path: (e, t) => `/a/${t}`,
11658
11658
  refId: (e) => e.to,
11659
11659
  frameSrc: (e, t) => `/a/${t}/view`,
@@ -326,7 +326,9 @@ function renderThumbnail(artifact, value) {
326
326
  25,
327
327
  505,
328
328
  3
329
- ).map((line, i) => text(42, 160 + i * 36, line, 25, "var(--ink)", 600)).join("")}${text(42, 318, `${artifact.project ?? "RYUGI"} / HTML`, 11, "var(--muted)")}`;
329
+ ).map((line, i) => text(42, 160 + i * 36, line, 25, "var(--ink)", 600)).join(
330
+ ""
331
+ )}${text(42, 318, `${artifact.project?.split("/").at(-1) ?? "RYUGI"} / HTML`, 11, "var(--muted)")}`;
330
332
  }
331
333
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 360"><title>${escape2(title)}</title>${STYLE}${body}</svg>`;
332
334
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ryugi-artifacts",
3
- "version": "1.68.3",
3
+ "version": "1.69.0",
4
4
  "description": "Server and viewer for the Ryugi artifacts app",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",