@north-light/cli 0.3.507 → 0.3.509

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 (53) hide show
  1. package/dist/api/client.d.ts +2 -1
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/docs.d.ts +4 -0
  6. package/dist/api/routes.d.ts +1 -0
  7. package/dist/api/routes.js +1 -1
  8. package/dist/clients/attach/assets/mermaid.min.js +3631 -0
  9. package/dist/clients/attach/render/doc-links.d.ts +2 -5
  10. package/dist/clients/attach/render/doc-links.js +1 -1
  11. package/dist/clients/attach/session/document-links.d.ts +6 -18
  12. package/dist/clients/attach/session/document-links.js +1 -1
  13. package/dist/clients/attach/session/file-links.d.ts +0 -2
  14. package/dist/clients/attach/session/file-links.js +1 -1
  15. package/dist/clients/attach/viewer.js +558 -625
  16. package/dist/core/config.js +1 -1
  17. package/dist/core/graph/events.d.ts +1 -0
  18. package/dist/core/graph/events.js +6 -6
  19. package/dist/core/graph/names.d.ts +6 -3
  20. package/dist/core/graph/names.js +3 -3
  21. package/dist/core/user-settings.d.ts +4 -4
  22. package/dist/core/user-settings.js +1 -1
  23. package/dist/daemon/api/bridge.js +3 -3
  24. package/dist/daemon/api/document-listener.d.ts +7 -0
  25. package/dist/daemon/api/document-listener.js +11 -0
  26. package/dist/daemon/api/document-merge.d.ts +2 -0
  27. package/dist/daemon/api/document-merge.js +1 -0
  28. package/dist/daemon/api/document-secret.d.ts +2 -0
  29. package/dist/daemon/api/document-secret.js +1 -0
  30. package/dist/daemon/api/handlers/docs.d.ts +14 -0
  31. package/dist/daemon/api/handlers/docs.js +1 -1
  32. package/dist/daemon/api/handlers/document-access.d.ts +2 -0
  33. package/dist/daemon/api/handlers/document-access.js +1 -0
  34. package/dist/daemon/api/handlers/objects.js +3 -3
  35. package/dist/daemon/api/map.js +2 -2
  36. package/dist/daemon/api/operations.js +1 -1
  37. package/dist/daemon/api/router.js +1 -1
  38. package/dist/daemon/api/server.js +1 -1
  39. package/dist/daemon/api/vendor-signin.d.ts +1 -0
  40. package/dist/daemon/api/vendor-signin.js +1 -1
  41. package/dist/daemon/crtrd.js +9 -9
  42. package/dist/daemon/peer/ingress.js +1 -1
  43. package/dist/doc-editor/editor.css +1 -0
  44. package/dist/doc-editor/editor.js +53 -0
  45. package/dist/types.d.ts +2 -9
  46. package/dist/types.js +1 -1
  47. package/package.json +13 -2
  48. package/packages/crouter-identity/package.json +1 -1
  49. package/runtime.lock.json +364 -12
  50. package/dist/clients/attach/session/doc-html.d.ts +0 -8
  51. package/dist/clients/attach/session/doc-html.js +0 -66
  52. package/dist/clients/attach/session/doc-materialize.d.ts +0 -57
  53. package/dist/clients/attach/session/doc-materialize.js +0 -3
@@ -1,66 +0,0 @@
1
- var n=Object.defineProperty;var o=(e,r)=>n(e,"name",{value:r,configurable:!0});import{Marked as i}from"marked";const l=/\[\[([^[\]\n]+?)\]\]/g;function a(e){return e.replace(/[&<>"']/g,r=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[r])}o(a,"escapeHtml");const p=new i({gfm:!0,renderer:{html({text:e}){return a(e)}}});function s(e){return e.split(/(<pre[\s\S]*?<\/pre>|<code>[\s\S]*?<\/code>)/).map((r,t)=>t%2===1?r:r.replace(l,(c,d)=>`<span class="doc-ref" title="${d.trim()}">${d.trim().split("/").pop()}</span>`)).join("")}o(s,"markDocRefs");function g(e){const r=e.name.split("/").pop()??e.name,t=s(p.parse(e.body,{async:!1}));return`<!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <title>${a(r)}</title>
7
- <style>
8
- :root { color-scheme: light dark; --fg: #1f2328; --muted: #656d76; --bg: #ffffff; --panel: #f6f8fa; --border: #d0d7de; --accent: #0969da; }
9
- @media (prefers-color-scheme: dark) { :root { --fg: #e6edf3; --muted: #8d96a0; --bg: #0d1117; --panel: #161b22; --border: #30363d; --accent: #4493f8; } }
10
- * { box-sizing: border-box; }
11
- body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
12
- header { position: sticky; top: 0; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--border); }
13
- header .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
14
- header .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
15
- header .spacer { flex: 1; }
16
- .toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
17
- .toggle button { font: inherit; font-size: 13px; padding: 4px 12px; border: 0; background: transparent; color: var(--fg); cursor: pointer; }
18
- .toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }
19
- main { max-width: 860px; margin: 0 auto; padding: 32px 24px 80px; }
20
- #raw { display: none; white-space: pre-wrap; word-wrap: break-word; font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 0; }
21
- body.raw #raw { display: block; } body.raw #rendered { display: none; }
22
- #rendered h1, #rendered h2 { border-bottom: 1px solid var(--border); padding-bottom: .3em; }
23
- #rendered a { color: var(--accent); }
24
- #rendered code { font: 85% ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel); padding: .2em .4em; border-radius: 4px; }
25
- #rendered pre { background: var(--panel); padding: 14px 16px; border-radius: 6px; overflow: auto; }
26
- #rendered pre code { background: none; padding: 0; }
27
- #rendered blockquote { margin: 0; padding: 0 1em; color: var(--muted); border-left: .25em solid var(--border); }
28
- #rendered table { border-collapse: collapse; display: block; overflow: auto; }
29
- #rendered th, #rendered td { border: 1px solid var(--border); padding: 6px 13px; }
30
- #rendered tr:nth-child(2n) { background: var(--panel); }
31
- #rendered img { max-width: 100%; }
32
- .doc-ref { color: var(--accent); font-weight: 500; border-bottom: 1px dotted var(--accent); cursor: help; }
33
- </style>
34
- </head>
35
- <body>
36
- <header>
37
- <span class="name" title="${a(e.name)}">${a(r)}</span>
38
- <span class="meta">${a(e.name)} \xB7 revision ${e.revision}</span>
39
- <span class="spacer"></span>
40
- <span class="toggle" role="group" aria-label="View">
41
- <button type="button" data-mode="rendered" aria-pressed="true">Rendered</button>
42
- <button type="button" data-mode="raw" aria-pressed="false">Raw</button>
43
- </span>
44
- </header>
45
- <main>
46
- <article id="rendered">
47
- ${t}
48
- </article>
49
- <pre id="raw">${a(e.body)}</pre>
50
- </main>
51
- <script>
52
- (function () {
53
- var KEY = 'crtr-doc-view';
54
- function set(mode) {
55
- document.body.classList.toggle('raw', mode === 'raw');
56
- document.querySelectorAll('.toggle button').forEach(function (b) { b.setAttribute('aria-pressed', String(b.dataset.mode === mode)); });
57
- try { localStorage.setItem(KEY, mode); } catch (e) {}
58
- }
59
- document.querySelectorAll('.toggle button').forEach(function (b) { b.addEventListener('click', function () { set(b.dataset.mode); }); });
60
- var saved = null; try { saved = localStorage.getItem(KEY); } catch (e) {}
61
- set(saved === 'raw' ? 'raw' : 'rendered');
62
- })();
63
- <\/script>
64
- </body>
65
- </html>
66
- `}o(g,"renderDocumentPage");export{g as renderDocumentPage};
@@ -1,57 +0,0 @@
1
- /** Environment variable carrying the edited document path to the reattached viewer. */
2
- export declare const DOC_SAVEBACK_ENV = "CRTR_ATTACH_DOC_SAVEBACK";
3
- /** The document a materialized file was read from. */
4
- export interface MaterializedDoc {
5
- /** The ref as the transcript wrote it (no brackets). */
6
- ref: string;
7
- id: string;
8
- /** Canonical `<owner>/<name>` (or the ref when no owner). */
9
- name: string;
10
- revision: number;
11
- /** The heads the body was read at — the base a save-back is made from. */
12
- heads_key: string;
13
- /** sha256 of the body as written. */
14
- sha256: string;
15
- }
16
- /** The subset of a document read this module needs. */
17
- export interface DocumentSnapshot {
18
- id: string;
19
- name: string;
20
- revision: number;
21
- heads_key: string;
22
- body: string;
23
- }
24
- export declare function docMaterializeRoot(): string;
25
- /** Write the snapshot's body to its stable path (idempotent) and return the path.
26
- * An existing file at that path is kept: it may hold the person's unsaved edit. */
27
- export declare function materializeDocument(ref: string, snap: DocumentSnapshot, root?: string): string;
28
- /** Write the snapshot's browser page beside its Markdown copy (idempotent per
29
- * revision) and return the page's path. Materializes the Markdown copy and
30
- * sidecar too, so the page's directory is still recognized as a document. */
31
- export declare function materializeDocumentPage(ref: string, snap: DocumentSnapshot, root?: string): string;
32
- /** The document a local path was materialized from, or undefined for a plain file. */
33
- export declare function documentForPath(path: string, root?: string): MaterializedDoc | undefined;
34
- /** Save a person's edit of a materialized document. */
35
- export type DocSaveOutcome = {
36
- outcome: 'unchanged';
37
- } | {
38
- outcome: 'saved';
39
- revision: number;
40
- } | {
41
- outcome: 'stale';
42
- path: string;
43
- } | {
44
- outcome: 'missing';
45
- } | {
46
- outcome: 'failed';
47
- message: string;
48
- };
49
- /** The document write the save-back uses: `crtr doc edit`'s body replacement,
50
- * made from an explicit base. Resolves `stale` rather than throwing on a
51
- * moved document. */
52
- export type DocEditFn = (id: string, body: string, base: string) => Promise<{
53
- revision: number;
54
- } | 'stale'>;
55
- export declare function saveDocumentEdit(path: string, edit: DocEditFn, root?: string): Promise<DocSaveOutcome>;
56
- /** The notice a save-back outcome shows, or undefined for none. */
57
- export declare function saveOutcomeNotice(name: string, outcome: DocSaveOutcome): string | undefined;
@@ -1,3 +0,0 @@
1
- var v=Object.defineProperty;var o=(t,e)=>v(t,"name",{value:e,configurable:!0});import{createHash as $}from"node:crypto";import{existsSync as d,mkdirSync as S,readFileSync as y,renameSync as _,writeFileSync as p}from"node:fs";import{tmpdir as x}from"node:os";import{basename as A,dirname as g,join as c}from"node:path";import{renderDocumentPage as C}from"./doc-html.js";const z="CRTR_ATTACH_DOC_SAVEBACK",m=".crtr-doc.json";function a(){return c(x(),"crtr-docs")}o(a,"docMaterializeRoot");const f=o(t=>$("sha256").update(t).digest("hex"),"sha");function h(t){return t.replace(/[^A-Za-z0-9._-]/g,"_").slice(0,120)||"doc"}o(h,"safeSegment");function k(t,e,r=a()){const i=c(r,h(e.id),`r${e.revision}`),n=c(i,`${h(A(e.name))}.md`),s=c(i,m);if(d(n)&&d(s))return n;S(i,{recursive:!0});const l={ref:t,id:e.id,name:e.name,revision:e.revision,heads_key:e.heads_key,sha256:f(e.body)};return u(n,e.body),u(s,`${JSON.stringify(l)}
2
- `),n}o(k,"materializeDocument");function R(t,e,r=a()){const n=k(t,e,r).replace(/\.md$/,".html");return d(n)||u(n,C({name:e.name,revision:e.revision,body:e.body})),n}o(R,"materializeDocumentPage");function u(t,e){const r=`${t}.${process.pid}.tmp`;p(r,e),_(r,t)}o(u,"writeAtomic");function w(t,e=a()){if(t.startsWith(`${e}/`))try{const r=JSON.parse(y(c(g(t),m),"utf8"));return typeof r.id=="string"&&typeof r.heads_key=="string"?r:void 0}catch{return}}o(w,"documentForPath");async function F(t,e,r=a()){const i=w(t,r);if(i===void 0||!d(t))return{outcome:"missing"};const n=y(t,"utf8");if(f(n)===i.sha256)return{outcome:"unchanged"};try{const s=await e(i.id,n,i.heads_key);return s==="stale"?{outcome:"stale",path:t}:(u(c(g(t),m),`${JSON.stringify({...i,sha256:f(n)})}
3
- `),{outcome:"saved",revision:s.revision})}catch(s){return{outcome:"failed",message:s instanceof Error?s.message:String(s)}}}o(F,"saveDocumentEdit");function J(t,e){switch(e.outcome){case"unchanged":return;case"saved":return`Saved ${t} as revision ${e.revision}`;case"stale":return`${t} changed while you edited it \u2014 not saved; your text is kept at ${e.path}`;case"missing":return`Could not find the edited copy of ${t}`;case"failed":return`Could not save ${t}: ${e.message}`}}o(J,"saveOutcomeNotice");export{z as DOC_SAVEBACK_ENV,a as docMaterializeRoot,w as documentForPath,k as materializeDocument,R as materializeDocumentPage,F as saveDocumentEdit,J as saveOutcomeNotice};