create-pmos 0.397.0 → 0.398.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/package.json +13 -13
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +101 -52
- package/workspace/briefing-premium-board-test.js +252 -128
- package/workspace/briefing-premium-calendar-2-test.js +135 -198
- package/workspace/briefing-premium-calendar-3-test.js +143 -418
- package/workspace/briefing-premium-calendar-test.js +86 -196
- package/workspace/briefing-premium-doc-edit-test.js +95 -83
- package/workspace/briefing-premium-initiative-test.js +159 -296
- package/workspace/briefing-premium-insights-test.js +337 -219
- package/workspace/briefing-premium-metrics-test.js +53 -97
- package/workspace/briefing-premium-products-test.js +40 -27
- package/workspace/briefing-premium-sources-test.js +66 -48
- package/workspace/briefing-premium-test.js +150 -647
- package/workspace/briefing-premium-work-test.js +88 -283
- package/workspace/changelog.json +12 -0
- package/workspace/fixtures/board-premium-trail.js +32 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/guide/home.md +47 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/lib/agent-roles.js +71 -0
- package/workspace/lib/board-premium.js +85 -19
- package/workspace/lib/board-trail.js +223 -0
- package/workspace/lib/home-work-item.js +58 -0
- package/workspace/lib/insights-goals.js +196 -0
- package/workspace/lib/insights-premium.js +62 -14
- package/workspace/lib/insights-records.js +101 -0
- package/workspace/lib/jira-tickets.js +1 -1
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-board-trail.js +33 -0
- package/workspace/lib/routes-home-desk.js +176 -0
- package/workspace/lib/routes-insights-premium.js +12 -3
- package/workspace/lib/routes-insights-records.js +129 -0
- package/workspace/lib/routes-notes.js +1 -0
- package/workspace/lib/routes-viewer.js +108 -0
- package/workspace/lib/transcript-steps.js +123 -0
- package/workspace/lib/viewer-meeting.js +205 -0
- package/workspace/lib/viewer-report.js +89 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +85 -75
- package/workspace/premium-briefing-depth-test.js +66 -53
- package/workspace/premium-chat-attach-test.js +54 -63
- package/workspace/premium-chat-chart-tab-test.js +35 -37
- package/workspace/premium-chat-context-test.js +19 -18
- package/workspace/premium-chat-goal-view-test.js +23 -23
- package/workspace/premium-chat-notes-test.js +26 -31
- package/workspace/premium-chat-report-tab-test.js +32 -28
- package/workspace/premium-chat-term-test.js +16 -16
- package/workspace/premium-chat-viewer-test.js +60 -59
- package/workspace/premium-core-doc-issue-test.js +50 -43
- package/workspace/premium-html-viewer-test.js +14 -17
- package/workspace/premium-phone-card-test.js +7 -2
- package/workspace/premium-phone-room-test.js +41 -35
- package/workspace/premium-report-read-test.js +115 -197
- package/workspace/premium-viewer-download-test.js +19 -22
- package/workspace/premium-viewer-flicker-test.js +11 -16
- package/workspace/premium-viewer-share-test.js +6 -9
- package/workspace/premium-viewer-test.js +41 -60
- package/workspace/premium-vw-backlog-test.js +53 -33
- package/workspace/premium-vw-cal-test.js +82 -128
- package/workspace/premium-vw-copy-test.js +17 -33
- package/workspace/premium-vw-doc-test.js +11 -10
- package/workspace/premium-vw-item-test.js +50 -49
- package/workspace/premium-vw-jira-test.js +53 -27
- package/workspace/premium-vw-meet-test.js +118 -187
- package/workspace/premium-vw-notes-test.js +85 -108
- package/workspace/premium-vw-rec-test.js +72 -194
- package/workspace/premium-vw-slides-test.js +46 -50
- package/workspace/premium-welcome-test.js +3 -2
- package/workspace/premium-work-depth-test.js +61 -53
- package/workspace/public/pm/bd-acts.js +305 -0
- package/workspace/public/pm/bd-span.js +186 -82
- package/workspace/public/pm/bd-stages.js +25 -11
- package/workspace/public/pm/c3-doc-sheet.js +1 -1
- package/workspace/public/pm/c3-md.js +3 -395
- package/workspace/public/pm/c3-phone-detail.js +1 -1
- package/workspace/public/pm/c3-phone-model.js +3 -68
- package/workspace/public/pm/chat-term.js +3 -3
- package/workspace/public/pm/cozy-board.css +497 -230
- package/workspace/public/pm/cozy-home.css +570 -142
- package/workspace/public/pm/cozy-home.js +5 -3
- package/workspace/public/pm/cozy-insights.css +296 -167
- package/workspace/public/pm/cozy-md.js +396 -0
- package/workspace/public/pm/cozy-nav.js +17 -6
- package/workspace/public/pm/cozy-placeholder.js +26 -0
- package/workspace/public/pm/cozy-viewer.css +3 -3
- package/workspace/public/pm/cozy-viewer.js +144 -0
- package/workspace/public/pm/cozy-vw.css +485 -0
- package/workspace/public/pm/cozy.css +83 -1
- package/workspace/public/pm/home-adddoc.js +48 -0
- package/workspace/public/pm/home-app.js +905 -0
- package/workspace/public/pm/home-around.js +515 -0
- package/workspace/public/pm/home-chat.js +459 -0
- package/workspace/public/pm/home-data.js +312 -0
- package/workspace/public/pm/home-draft.js +68 -0
- package/workspace/public/pm/home-more.js +249 -0
- package/workspace/public/pm/home-phone-card.js +109 -0
- package/workspace/public/pm/home-work.js +519 -0
- package/workspace/public/pm/phone-moment.js +69 -0
- package/workspace/public/pm/pm-work-view.js +1 -1
- package/workspace/public/pm/premium-attach.js +4 -0
- package/workspace/public/pm/premium-board.js +423 -394
- package/workspace/public/pm/premium-chart-tab.js +110 -62
- package/workspace/public/pm/premium-deck.js +3 -3
- package/workspace/public/pm/premium-first.js +25 -21
- package/workspace/public/pm/premium-insights.js +792 -568
- package/workspace/public/pm/premium-meeting.js +61 -549
- package/workspace/public/pm/premium-notes.js +1 -1
- package/workspace/public/pm/premium-report-frame.css +20 -0
- package/workspace/public/pm/premium-report-read.js +509 -480
- package/workspace/public/pm/premium-report-tab.js +87 -63
- package/workspace/public/pm/premium-shell.js +72 -119
- package/workspace/public/pm/premium-viewer.js +22 -1
- package/workspace/public/pm/premium-vw-cal.js +187 -48
- package/workspace/public/pm/premium-vw-doc.css +6 -0
- package/workspace/public/pm/premium-vw-doc.js +40 -2
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium-vw-meet.js +6 -83
- package/workspace/public/pm/premium-vw-mtg.js +731 -0
- package/workspace/public/pm/premium-vw-notes.js +56 -69
- package/workspace/public/pm/premium-vw-open.js +35 -0
- package/workspace/public/pm/premium-vw-page.js +16 -0
- package/workspace/public/pm/premium-vw-rec.js +11 -218
- package/workspace/public/pm/premium-vw-slides.css +5 -0
- package/workspace/public/pm/premium-vw-slides.js +44 -8
- package/workspace/public/pm/term-view.js +22 -0
- package/workspace/public/premium-board.html +28 -70
- package/workspace/public/premium-initiative.html +8 -48
- package/workspace/public/premium-insights.html +22 -60
- package/workspace/public/premium-viewer.html +20 -0
- package/workspace/public/premium.html +16 -107
- package/workspace/server.js +18 -3
- package/workspace/test-files.json +1 -0
- package/workspace/test-lists/home-libs.json +9 -0
- package/workspace/test-lists/premium-report-read.json +1 -1
- package/workspace/test-lists/premium-vw-agreed.json +9 -0
- package/workspace/test-lists/premium-vw-notes.json +1 -1
- package/workspace/public/pm/premium-work.js +0 -729
- package/workspace/public/pm/premium.js +0 -1146
|
@@ -1,395 +1,3 @@
|
|
|
1
|
-
/* pm/c3-md.js —
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* parseMd(md) → blocks the subset PMOS documents use: headings, paragraphs, quotes, bulleted, numbered and
|
|
5
|
-
* checklist lists, tables, dividers and fenced code; inline bold, italic, code and links
|
|
6
|
-
* toMd(blocks) → md the canonical markdown of blocks; toMd(parseMd(toMd(b))) === toMd(b)
|
|
7
|
-
* canonMd(md) → md toMd(parseMd(md)): two texts that read the same compare equal
|
|
8
|
-
* diffMd(before, after) → md `after`, with the words removed and added since `before` wrapped in markers that
|
|
9
|
-
* toDom draws as <del> and <ins>; a line or sentence rewritten in most of its words is
|
|
10
|
-
* shown whole, removed then added
|
|
11
|
-
* toDom(blocks, doc?) → Node[] the blocks as elements (no innerHTML: every text is a text node); links are http(s),
|
|
12
|
-
* mailto or relative only
|
|
13
|
-
* fromDom(root) → blocks what the rich-text editor holds, read back as blocks
|
|
14
|
-
*
|
|
15
|
-
* parseMd, toMd, canonMd and diffMd are pure (Node-testable: c3-md.test.js); toDom and fromDom need a document.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export const INS = '\uE000';
|
|
19
|
-
export const INS_END = '\uE001';
|
|
20
|
-
export const DEL = '\uE002';
|
|
21
|
-
export const DEL_END = '\uE003';
|
|
22
|
-
const MARK = /[\uE000-\uE003]/g;
|
|
23
|
-
|
|
24
|
-
/* ── inline ── */
|
|
25
|
-
|
|
26
|
-
/** Inline markdown → [{ t:'text', s } | { t:'b'|'i', c:[…] } | { t:'code', s } | { t:'a', href, c:[…] }]. */
|
|
27
|
-
export function parseInline(src) {
|
|
28
|
-
const s = String(src == null ? '' : src);
|
|
29
|
-
const out = [];
|
|
30
|
-
let buf = '';
|
|
31
|
-
const flush = () => { if (buf) { out.push({ t: 'text', s: buf }); buf = ''; } };
|
|
32
|
-
let i = 0;
|
|
33
|
-
while (i < s.length) {
|
|
34
|
-
const c = s[i];
|
|
35
|
-
if (c === '\\' && i + 1 < s.length && /[\\`*_[\]()#|>-]/.test(s[i + 1])) { buf += s[i + 1]; i += 2; continue; }
|
|
36
|
-
if (c === '`') {
|
|
37
|
-
const j = s.indexOf('`', i + 1);
|
|
38
|
-
if (j > i) { flush(); out.push({ t: 'code', s: s.slice(i + 1, j) }); i = j + 1; continue; }
|
|
39
|
-
}
|
|
40
|
-
if (c === '[') {
|
|
41
|
-
const m = /^\[((?:[^\]\\]|\\.)+)\]\(([^)\s]+)\)/.exec(s.slice(i));
|
|
42
|
-
if (m) { flush(); out.push({ t: 'a', href: m[2], c: parseInline(m[1]) }); i += m[0].length; continue; }
|
|
43
|
-
}
|
|
44
|
-
if ((c === '*' || c === '_') && s[i + 1] === c) {
|
|
45
|
-
const j = s.indexOf(c + c, i + 2);
|
|
46
|
-
if (j > i + 2) { flush(); out.push({ t: 'b', c: parseInline(s.slice(i + 2, j)) }); i = j + 2; continue; }
|
|
47
|
-
}
|
|
48
|
-
if ((c === '*' || c === '_') && s[i + 1] !== c && s[i + 1] !== ' ' && (c === '*' || !/\w/.test(s[i - 1] || ''))) {
|
|
49
|
-
let j = i + 1;
|
|
50
|
-
while (j < s.length && !(s[j] === c && s[j + 1] !== c && s[j - 1] !== ' ' && s[j - 1] !== c)) j++;
|
|
51
|
-
if (j < s.length && j > i + 1 && (c === '*' || !/\w/.test(s[j + 1] || ''))) { flush(); out.push({ t: 'i', c: parseInline(s.slice(i + 1, j)) }); i = j + 1; continue; }
|
|
52
|
-
}
|
|
53
|
-
buf += c; i++;
|
|
54
|
-
}
|
|
55
|
-
flush();
|
|
56
|
-
return out;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Text is escaped only where markdown would read it as syntax: a backslash before punctuation, `, *, [ and ], and an _ that
|
|
60
|
-
// is not inside a word (snake_case stays as written).
|
|
61
|
-
const escText = (s) => String(s).replace(/\\(?=[\\`*_[\]()#|>-])/g, '\\\\').replace(/[`*[\]]/g, '\\$&').replace(/(^|\W)_|_(?=\W|$)/g, (m) => m.replace('_', '\\_'));
|
|
62
|
-
/** Inline nodes → markdown. `raw`: text as it is, unescaped (for a plain-text label). */
|
|
63
|
-
export function inlineMd(nodes, raw) {
|
|
64
|
-
return (nodes || []).map((n) => {
|
|
65
|
-
if (n.t === 'text') return raw ? n.s : escText(n.s);
|
|
66
|
-
if (n.t === 'code') return raw ? n.s : '`' + n.s + '`';
|
|
67
|
-
const inner = inlineMd(n.c, raw);
|
|
68
|
-
if (raw || !inner.trim()) return inner;
|
|
69
|
-
const lead = inner.match(/^\s*/)[0]; const tail = inner.match(/\s*$/)[0]; const core = inner.trim();
|
|
70
|
-
if (n.t === 'b') return lead + '**' + core + '**' + tail;
|
|
71
|
-
if (n.t === 'i') return lead + '*' + core + '*' + tail;
|
|
72
|
-
if (n.t === 'a') return lead + '[' + core + '](' + n.href + ')' + tail;
|
|
73
|
-
return inner;
|
|
74
|
-
}).join('');
|
|
75
|
-
}
|
|
76
|
-
// a paragraph or list item whose text would start a heading, quote, list or rule is escaped at its start
|
|
77
|
-
const lineSafe = (s) => s.replace(/^(#{1,6}\s|>|[-+]\s|\d+[.)]\s|-{3,}\s*$)/, '\\$1');
|
|
78
|
-
|
|
79
|
-
/* ── blocks ── */
|
|
80
|
-
|
|
81
|
-
const LIST = /^(\s*)([-*+]|\d+[.)])\s+/;
|
|
82
|
-
const TASK = /^\[( |x|X)\]\s+/;
|
|
83
|
-
const cells = (r) => {
|
|
84
|
-
const t = r.trim().replace(/^\|/, '').replace(/\|\s*$/, '');
|
|
85
|
-
const out = []; let cur = ''; for (let i = 0; i < t.length; i++) { if (t[i] === '\\' && t[i + 1] === '|') { cur += '|'; i++; } else if (t[i] === '|') { out.push(cur.trim()); cur = ''; } else cur += t[i]; }
|
|
86
|
-
out.push(cur.trim()); return out;
|
|
87
|
-
};
|
|
88
|
-
const isRule = (l) => /^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(l);
|
|
89
|
-
const startsBlock = (l) => /^(#{1,6}\s|>|```|~~~|\s*(-{3,}|\*{3,}|_{3,})\s*$)/.test(l) || LIST.test(l) || /^\s*\|/.test(l);
|
|
90
|
-
|
|
91
|
-
/** Markdown → blocks: { t:'h', level, c } · { t:'p', c } · { t:'quote', blocks } · { t:'list', ordered, items:[{ task, c }] } ·
|
|
92
|
-
* { t:'table', head:[c], rows:[[c]] } · { t:'hr' } · { t:'code', lang, s }. Marker characters (diffMd) pass through as text. */
|
|
93
|
-
export function parseMd(md) {
|
|
94
|
-
const L = String(md == null ? '' : md).replace(/\r\n?/g, '\n').split('\n');
|
|
95
|
-
const out = []; let i = 0;
|
|
96
|
-
const bare = (l) => l.replace(MARK, '');
|
|
97
|
-
while (i < L.length) {
|
|
98
|
-
const l = L[i]; const b = bare(l); let m;
|
|
99
|
-
if (!b.trim()) { i++; continue; }
|
|
100
|
-
if ((m = /^(```|~~~)\s*([\w-]*)/.exec(b))) {
|
|
101
|
-
const fence = m[1]; const body = []; i++;
|
|
102
|
-
while (i < L.length && !bare(L[i]).startsWith(fence)) body.push(L[i++]);
|
|
103
|
-
i++; out.push({ t: 'code', lang: m[2] || '', s: body.join('\n') }); continue;
|
|
104
|
-
}
|
|
105
|
-
if ((m = /^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(l))) { out.push({ t: 'h', level: m[1].length, c: parseInline(m[2]) }); i++; continue; }
|
|
106
|
-
if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(b)) { out.push({ t: 'hr' }); i++; continue; }
|
|
107
|
-
if (/^\s*>/.test(b)) {
|
|
108
|
-
const body = [];
|
|
109
|
-
while (i < L.length && /^\s*>/.test(bare(L[i]))) body.push(L[i++].replace(/^(\s*[\uE000-\uE003]*)\s*>\s?/, '$1'));
|
|
110
|
-
out.push({ t: 'quote', blocks: parseMd(body.join('\n')) }); continue;
|
|
111
|
-
}
|
|
112
|
-
if (/^\s*\|/.test(b) && i + 1 < L.length && isRule(bare(L[i + 1]))) {
|
|
113
|
-
const head = cells(l); i += 2; const rows = [];
|
|
114
|
-
while (i < L.length && /^\s*\|/.test(bare(L[i]))) rows.push(cells(L[i++]));
|
|
115
|
-
out.push({ t: 'table', head: head.map(parseInline), rows: rows.map((r) => head.map((_, k) => parseInline(r[k] || ''))) }); continue;
|
|
116
|
-
}
|
|
117
|
-
if (LIST.test(b)) {
|
|
118
|
-
const ordered = /^\s*\d/.test(b); const items = [];
|
|
119
|
-
while (i < L.length && LIST.test(bare(L[i])) && /^\s*\d/.test(bare(L[i])) === ordered) {
|
|
120
|
-
const lead = (/^[\uE000-\uE003]*/.exec(L[i]) || [''])[0];
|
|
121
|
-
let t = lead + L[i].slice(lead.length).replace(LIST, ''); i++;
|
|
122
|
-
while (i < L.length && /^\s{2,}\S/.test(L[i]) && !LIST.test(bare(L[i]))) t += ' ' + L[i++].trim();
|
|
123
|
-
const tk = TASK.exec(t.replace(MARK, ''));
|
|
124
|
-
if (tk) { const k = t.indexOf('['); t = t.slice(0, k) + t.slice(k).replace(TASK, ''); }
|
|
125
|
-
items.push({ task: tk ? tk[1] !== ' ' : null, c: parseInline(t) });
|
|
126
|
-
}
|
|
127
|
-
out.push({ t: 'list', ordered, items }); continue;
|
|
128
|
-
}
|
|
129
|
-
const body = [];
|
|
130
|
-
while (i < L.length && bare(L[i]).trim() && (!body.length || !startsBlock(bare(L[i])))) body.push(L[i++].trim());
|
|
131
|
-
out.push({ t: 'p', c: parseInline(body.join(' ')) });
|
|
132
|
-
}
|
|
133
|
-
return out;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/** Blocks → markdown, one blank line between blocks. */
|
|
137
|
-
export function toMd(blocks) {
|
|
138
|
-
return (blocks || []).map((b) => {
|
|
139
|
-
if (b.t === 'h') return '#'.repeat(b.level || 2) + ' ' + inlineMd(b.c).trim();
|
|
140
|
-
if (b.t === 'p') return lineSafe(inlineMd(b.c).trim());
|
|
141
|
-
if (b.t === 'hr') return '---';
|
|
142
|
-
if (b.t === 'code') return '```' + (b.lang || '') + '\n' + b.s + '\n```';
|
|
143
|
-
if (b.t === 'quote') return toMd(b.blocks).split('\n').map((x) => (x ? '> ' + x : '>')).join('\n');
|
|
144
|
-
if (b.t === 'list') return b.items.map((it, k) => (b.ordered ? (k + 1) + '. ' : '- ') + (it.task == null ? '' : it.task ? '[x] ' : '[ ] ') + inlineMd(it.c).trim()).join('\n');
|
|
145
|
-
if (b.t === 'table') {
|
|
146
|
-
const cell = (c) => inlineMd(c).trim().replace(/\|/g, '\\|');
|
|
147
|
-
const w = Math.max(b.head.length, ...b.rows.map((r) => r.length));
|
|
148
|
-
const line = (r) => '| ' + Array.from({ length: w }, (_, k) => (r[k] ? cell(r[k]) : '')).join(' | ') + ' |';
|
|
149
|
-
return [line(b.head), '|' + Array.from({ length: w }, () => '---').join('|') + '|', ...b.rows.map(line)].join('\n');
|
|
150
|
-
}
|
|
151
|
-
return '';
|
|
152
|
-
}).filter((x) => x !== '').join('\n\n');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export const canonMd = (md) => toMd(parseMd(md));
|
|
156
|
-
|
|
157
|
-
/* ── the rendered diff ── */
|
|
158
|
-
|
|
159
|
-
function lcs(a, b) {
|
|
160
|
-
const n = a.length, m = b.length;
|
|
161
|
-
if (n * m > 400000) return [...a.map((x) => ['-', x]), ...b.map((x) => ['+', x])];
|
|
162
|
-
const T = Array.from({ length: n + 1 }, () => new Int32Array(m + 1));
|
|
163
|
-
for (let i = n - 1; i >= 0; i--) for (let j = m - 1; j >= 0; j--) T[i][j] = a[i] === b[j] ? T[i + 1][j + 1] + 1 : Math.max(T[i + 1][j], T[i][j + 1]);
|
|
164
|
-
const ops = []; let i = 0, j = 0;
|
|
165
|
-
while (i < n && j < m) { if (a[i] === b[j]) { ops.push(['=', a[i]]); i++; j++; } else if (T[i + 1][j] >= T[i][j + 1]) ops.push(['-', a[i++]]); else ops.push(['+', b[j++]]); }
|
|
166
|
-
while (i < n) ops.push(['-', a[i++]]); while (j < m) ops.push(['+', b[j++]]);
|
|
167
|
-
return ops;
|
|
168
|
-
}
|
|
169
|
-
/** Runs of ops: [{ eq:true, items } | { eq:false, del:[…], add:[…] }]. */
|
|
170
|
-
function runs(ops) {
|
|
171
|
-
const out = [];
|
|
172
|
-
for (const [op, x] of ops) {
|
|
173
|
-
const last = out[out.length - 1];
|
|
174
|
-
if (op === '=') { if (last && last.eq) last.items.push(x); else out.push({ eq: true, items: [x] }); }
|
|
175
|
-
else { if (!last || last.eq) out.push({ eq: false, del: [], add: [] }); out[out.length - 1][op === '-' ? 'del' : 'add'].push(x); }
|
|
176
|
-
}
|
|
177
|
-
return out;
|
|
178
|
-
}
|
|
179
|
-
const wrap = (s, a, z) => (s && s.trim() ? a + s + z : s);
|
|
180
|
-
function words(a, b) {
|
|
181
|
-
const tok = (x) => x.match(/\s+|[^\s]+/g) || [];
|
|
182
|
-
const A = tok(a), B = tok(b); const ops = lcs(A, B);
|
|
183
|
-
const real = (x) => /\S/.test(x);
|
|
184
|
-
const same = ops.filter(([o, x]) => o === '=' && real(x)).length;
|
|
185
|
-
const tot = Math.max(A.filter(real).length, B.filter(real).length);
|
|
186
|
-
if (tot > 4 && same / tot < 0.6) return wrap(a, DEL, DEL_END) + ' ' + wrap(b, INS, INS_END);
|
|
187
|
-
return runs(ops).map((r) => (r.eq ? r.items.join('') : wrap(r.del.join(''), DEL, DEL_END) + (r.del.length && r.add.length ? ' ' : '') + wrap(r.add.join(''), INS, INS_END))).join('');
|
|
188
|
-
}
|
|
189
|
-
function sentences(a, b) {
|
|
190
|
-
const cut = (x) => x.split(/(?<=[.;!?])\s+/);
|
|
191
|
-
const A = cut(a), B = cut(b);
|
|
192
|
-
if (A.length < 2 && B.length < 2) return words(a, b);
|
|
193
|
-
return runs(lcs(A, B)).map((r) => {
|
|
194
|
-
if (r.eq) return r.items.join(' ');
|
|
195
|
-
const n = Math.min(r.del.length, r.add.length); const parts = [];
|
|
196
|
-
for (let k = 0; k < n; k++) parts.push(words(r.del[k], r.add[k]));
|
|
197
|
-
r.del.slice(n).forEach((x) => parts.push(wrap(x, DEL, DEL_END)));
|
|
198
|
-
r.add.slice(n).forEach((x) => parts.push(wrap(x, INS, INS_END)));
|
|
199
|
-
return parts.join(' ');
|
|
200
|
-
}).join(' ');
|
|
201
|
-
}
|
|
202
|
-
const PREFIX = /^(\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?|\s*>\s?|#{1,6}\s+)/;
|
|
203
|
-
function wrapLine(l, a, z) {
|
|
204
|
-
if (!l.trim() || isRule(l)) return l;
|
|
205
|
-
if (/^\s*\|/.test(l)) return '| ' + cells(l).map((c) => wrap(c, a, z)).join(' | ') + ' |';
|
|
206
|
-
if (/^(```|~~~)/.test(l) || /^\s*(-{3,}|\*{3,})\s*$/.test(l)) return l;
|
|
207
|
-
const p = (PREFIX.exec(l) || [''])[0];
|
|
208
|
-
return p + wrap(l.slice(p.length), a, z);
|
|
209
|
-
}
|
|
210
|
-
function lineDiff(a, b) {
|
|
211
|
-
const pa = (PREFIX.exec(a) || [''])[0], pb = (PREFIX.exec(b) || [''])[0];
|
|
212
|
-
if (/^\s*\|/.test(a) && /^\s*\|/.test(b) && !isRule(a) && !isRule(b)) {
|
|
213
|
-
const ca = cells(a), cb = cells(b);
|
|
214
|
-
return '| ' + cb.map((c, k) => (ca[k] === c ? c : sentences(ca[k] || '', c))).join(' | ') + ' |';
|
|
215
|
-
}
|
|
216
|
-
if (pa === pb) return pb + sentences(a.slice(pa.length), b.slice(pb.length));
|
|
217
|
-
return null;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/** `after` with the change since `before` marked. `before` null: the whole of `after` is new. */
|
|
221
|
-
export function diffMd(before, after) {
|
|
222
|
-
const B = String(after == null ? '' : after).split('\n');
|
|
223
|
-
if (before == null) return B.map((l) => wrapLine(l, INS, INS_END)).join('\n');
|
|
224
|
-
const A = String(before).split('\n');
|
|
225
|
-
const out = [];
|
|
226
|
-
for (const r of runs(lcs(A, B))) {
|
|
227
|
-
if (r.eq) { out.push(...r.items); continue; }
|
|
228
|
-
const n = Math.min(r.del.length, r.add.length);
|
|
229
|
-
const removed = []; const added = [];
|
|
230
|
-
for (let k = 0; k < n; k++) {
|
|
231
|
-
const d = lineDiff(r.del[k], r.add[k]);
|
|
232
|
-
if (d == null) { removed.push(wrapLine(r.del[k], DEL, DEL_END)); added.push(wrapLine(r.add[k], INS, INS_END)); } else added.push(d);
|
|
233
|
-
}
|
|
234
|
-
r.del.slice(n).forEach((l) => removed.push(wrapLine(l, DEL, DEL_END)));
|
|
235
|
-
r.add.slice(n).forEach((l) => added.push(wrapLine(l, INS, INS_END)));
|
|
236
|
-
// a removed table row or list item stays in its table or list: put it with the rows after it
|
|
237
|
-
out.push(...removed.filter((l) => l.trim()), ...added);
|
|
238
|
-
}
|
|
239
|
-
return out.join('\n');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/** Words added and removed between two texts: [added, removed]. */
|
|
243
|
-
export function wordCounts(before, after) {
|
|
244
|
-
const A = String(before || '').match(/\S+/g) || [], B = String(after || '').match(/\S+/g) || [];
|
|
245
|
-
let add = 0, del = 0;
|
|
246
|
-
for (const [o] of lcs(A, B)) { if (o === '+') add++; else if (o === '-') del++; }
|
|
247
|
-
return [add, del];
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/* ── DOM ── */
|
|
251
|
-
|
|
252
|
-
/** A safe href: http(s), mailto, a fragment or a relative path; anything else (javascript:, data:) is dropped. */
|
|
253
|
-
export function safeHref(h) {
|
|
254
|
-
const s = String(h || '').trim();
|
|
255
|
-
if (/^(https?:|mailto:)/i.test(s)) return s;
|
|
256
|
-
if (/^[a-z][\w+.-]*:/i.test(s)) return null;
|
|
257
|
-
return s;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/** Text with diff markers → nodes: the marked runs inside <ins> and <del>. `st` carries an open marker across inline nodes. */
|
|
261
|
-
function textNodes(doc, s, st) {
|
|
262
|
-
const out = []; let buf = '';
|
|
263
|
-
const push = () => {
|
|
264
|
-
if (!buf) return;
|
|
265
|
-
const t = doc.createTextNode(buf); buf = '';
|
|
266
|
-
if (st.mode) { const w = doc.createElement(st.mode); w.appendChild(t); out.push(w); } else out.push(t);
|
|
267
|
-
};
|
|
268
|
-
for (const ch of String(s)) {
|
|
269
|
-
if (ch === INS || ch === DEL) { push(); st.mode = ch === INS ? 'ins' : 'del'; }
|
|
270
|
-
else if (ch === INS_END || ch === DEL_END) { push(); st.mode = null; }
|
|
271
|
-
else buf += ch;
|
|
272
|
-
}
|
|
273
|
-
push();
|
|
274
|
-
return out;
|
|
275
|
-
}
|
|
276
|
-
function inlineDom(doc, nodes, st) {
|
|
277
|
-
const out = [];
|
|
278
|
-
for (const n of nodes || []) {
|
|
279
|
-
if (n.t === 'text') { out.push(...textNodes(doc, n.s, st)); continue; }
|
|
280
|
-
if (n.t === 'code') { const c = doc.createElement('code'); c.append(...textNodes(doc, n.s, st)); out.push(c); continue; }
|
|
281
|
-
const tag = n.t === 'b' ? 'strong' : n.t === 'i' ? 'em' : 'a';
|
|
282
|
-
const e = doc.createElement(tag);
|
|
283
|
-
if (n.t === 'a') {
|
|
284
|
-
const h = safeHref(n.href);
|
|
285
|
-
if (h != null) { e.setAttribute('href', h); if (/^https?:/i.test(h)) { e.setAttribute('target', '_blank'); e.setAttribute('rel', 'noopener'); } }
|
|
286
|
-
}
|
|
287
|
-
e.append(...inlineDom(doc, n.c, st));
|
|
288
|
-
out.push(e);
|
|
289
|
-
}
|
|
290
|
-
return out;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/** Blocks → elements. `opts.editable` draws checklist boxes that can be ticked (the editor). */
|
|
294
|
-
export function toDom(blocks, doc, opts = {}) {
|
|
295
|
-
const d = doc || document;
|
|
296
|
-
const mk = (tag, cls) => { const e = d.createElement(tag); if (cls) e.className = cls; return e; };
|
|
297
|
-
return (blocks || []).map((b) => {
|
|
298
|
-
const st = { mode: null };
|
|
299
|
-
if (b.t === 'h') { const e = mk('h' + Math.min(6, Math.max(1, b.level || 2))); e.append(...inlineDom(d, b.c, st)); return e; }
|
|
300
|
-
if (b.t === 'p') { const e = mk('p'); e.append(...inlineDom(d, b.c, st)); return e; }
|
|
301
|
-
if (b.t === 'hr') return mk('hr');
|
|
302
|
-
if (b.t === 'code') { const p = mk('pre'); if (b.lang) p.setAttribute('data-lang', b.lang); const c = mk('code'); c.append(...textNodes(d, b.s, st)); p.appendChild(c); return p; }
|
|
303
|
-
if (b.t === 'quote') { const q = mk('blockquote'); q.append(...toDom(b.blocks, d, opts)); return q; }
|
|
304
|
-
if (b.t === 'list') {
|
|
305
|
-
const l = mk(b.ordered ? 'ol' : 'ul', b.items.some((it) => it.task != null) ? 'tasks' : '');
|
|
306
|
-
for (const it of b.items) {
|
|
307
|
-
const li = mk('li');
|
|
308
|
-
if (it.task != null) {
|
|
309
|
-
li.className = 'task' + (it.task ? ' done' : '');
|
|
310
|
-
const box = mk('input'); box.type = 'checkbox'; box.checked = !!it.task; box.setAttribute('aria-label', 'Done');
|
|
311
|
-
if (opts.editable) box.setAttribute('contenteditable', 'false'); else box.disabled = true;
|
|
312
|
-
const sp = mk('span'); sp.append(...inlineDom(d, it.c, st));
|
|
313
|
-
li.append(box, sp);
|
|
314
|
-
} else li.append(...inlineDom(d, it.c, st));
|
|
315
|
-
l.appendChild(li);
|
|
316
|
-
}
|
|
317
|
-
return l;
|
|
318
|
-
}
|
|
319
|
-
if (b.t === 'table') {
|
|
320
|
-
const w = mk('div', 'tw'); const t = mk('table'); const th = mk('thead'); const tr = mk('tr');
|
|
321
|
-
for (const c of b.head) { const x = mk('th'); x.append(...inlineDom(d, c, st)); tr.appendChild(x); }
|
|
322
|
-
th.appendChild(tr); const tb = mk('tbody');
|
|
323
|
-
for (const r of b.rows) { const row = mk('tr'); for (const c of r) { const x = mk('td'); x.append(...inlineDom(d, c, st)); row.appendChild(x); } tb.appendChild(row); }
|
|
324
|
-
t.append(th, tb); w.appendChild(t); return w;
|
|
325
|
-
}
|
|
326
|
-
return d.createTextNode('');
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/* reading the editor back */
|
|
331
|
-
function inlineOf(n) {
|
|
332
|
-
const out = [];
|
|
333
|
-
const text = (s) => { if (!s) return; const last = out[out.length - 1]; if (last && last.t === 'text') last.s += s; else out.push({ t: 'text', s }); };
|
|
334
|
-
for (const c of Array.from(n.childNodes || [])) {
|
|
335
|
-
if (c.nodeType === 3) { text(c.textContent.replace(/\u00a0/g, ' ').replace(/\u200b/g, '').replace(/\s+/g, ' ')); continue; }
|
|
336
|
-
if (c.nodeType !== 1) continue;
|
|
337
|
-
const t = c.tagName;
|
|
338
|
-
if (t === 'BR') { text(' '); continue; }
|
|
339
|
-
if (t === 'INPUT' || t === 'UL' || t === 'OL') continue;
|
|
340
|
-
if (t === 'CODE') { out.push({ t: 'code', s: c.textContent.replace(/\u200b/g, '') }); continue; }
|
|
341
|
-
if (t === 'STRONG' || t === 'B') { out.push({ t: 'b', c: inlineOf(c) }); continue; }
|
|
342
|
-
if (t === 'EM' || t === 'I') { out.push({ t: 'i', c: inlineOf(c) }); continue; }
|
|
343
|
-
if (t === 'A') { out.push({ t: 'a', href: c.getAttribute('href') || '', c: inlineOf(c) }); continue; }
|
|
344
|
-
if (t === 'SPAN' && /font-weight:\s*(bold|[6-9]00)/.test(c.getAttribute('style') || '')) { out.push({ t: 'b', c: inlineOf(c) }); continue; }
|
|
345
|
-
if (t === 'SPAN' && /font-style:\s*italic/.test(c.getAttribute('style') || '')) { out.push({ t: 'i', c: inlineOf(c) }); continue; }
|
|
346
|
-
for (const x of inlineOf(c)) { if (x.t === 'text') text(x.s); else out.push(x); }
|
|
347
|
-
}
|
|
348
|
-
return out;
|
|
349
|
-
}
|
|
350
|
-
const trimInline = (c) => {
|
|
351
|
-
const a = c.slice();
|
|
352
|
-
while (a.length && a[0].t === 'text' && !a[0].s.trim()) a.shift();
|
|
353
|
-
while (a.length && a[a.length - 1].t === 'text' && !a[a.length - 1].s.trim()) a.pop();
|
|
354
|
-
if (a.length && a[0].t === 'text') a[0] = { ...a[0], s: a[0].s.replace(/^\s+/, '') };
|
|
355
|
-
if (a.length && a[a.length - 1].t === 'text') a[a.length - 1] = { ...a[a.length - 1], s: a[a.length - 1].s.replace(/\s+$/, '') };
|
|
356
|
-
return a;
|
|
357
|
-
};
|
|
358
|
-
const BLOCK = /^(P|DIV|H[1-6]|BLOCKQUOTE|UL|OL|TABLE|PRE|HR|SECTION)$/;
|
|
359
|
-
/** The editor's children → blocks. Loose text and inline nodes between blocks become a paragraph. */
|
|
360
|
-
export function fromDom(root) {
|
|
361
|
-
const out = []; let loose = null;
|
|
362
|
-
const endLoose = () => { if (loose) { const c = trimInline(inlineOf(loose)); if (c.length) out.push({ t: 'p', c }); loose = null; } };
|
|
363
|
-
for (const n of Array.from(root.childNodes || [])) {
|
|
364
|
-
if (n.nodeType === 1 && BLOCK.test(n.tagName)) { endLoose(); out.push(...blockOf(n)); continue; }
|
|
365
|
-
if (n.nodeType === 3 && !n.textContent.trim() && !loose) continue;
|
|
366
|
-
if (!loose) loose = (root.ownerDocument || document).createElement('p');
|
|
367
|
-
loose.appendChild(n.cloneNode(true));
|
|
368
|
-
}
|
|
369
|
-
endLoose();
|
|
370
|
-
return out;
|
|
371
|
-
}
|
|
372
|
-
function blockOf(n) {
|
|
373
|
-
const t = n.tagName;
|
|
374
|
-
if (/^H[1-6]$/.test(t)) return [{ t: 'h', level: +t[1], c: trimInline(inlineOf(n)) }];
|
|
375
|
-
if (t === 'HR') return [{ t: 'hr' }];
|
|
376
|
-
if (t === 'PRE') return [{ t: 'code', lang: n.getAttribute('data-lang') || '', s: n.textContent.replace(/\n$/, '') }];
|
|
377
|
-
if (t === 'BLOCKQUOTE') { const b = fromDom(n); return b.length ? [{ t: 'quote', blocks: b }] : []; }
|
|
378
|
-
if (t === 'UL' || t === 'OL') {
|
|
379
|
-
const items = Array.from(n.children).filter((li) => li.tagName === 'LI').map((li) => {
|
|
380
|
-
const box = li.querySelector(':scope > input[type=checkbox]');
|
|
381
|
-
return { task: box ? !!box.checked : null, c: trimInline(inlineOf(li)) };
|
|
382
|
-
});
|
|
383
|
-
const nested = Array.from(n.querySelectorAll(':scope > li > ul, :scope > li > ol')).flatMap(blockOf);
|
|
384
|
-
return [{ t: 'list', ordered: t === 'OL', items }, ...nested];
|
|
385
|
-
}
|
|
386
|
-
if (t === 'TABLE' || (t === 'DIV' && n.querySelector(':scope > table'))) {
|
|
387
|
-
const tb = t === 'TABLE' ? n : n.querySelector(':scope > table');
|
|
388
|
-
const rows = Array.from(tb.querySelectorAll('tr')).map((r) => Array.from(r.children).map((c) => trimInline(inlineOf(c))));
|
|
389
|
-
if (!rows.length) return [];
|
|
390
|
-
return [{ t: 'table', head: rows[0], rows: rows.slice(1) }];
|
|
391
|
-
}
|
|
392
|
-
if ((t === 'DIV' || t === 'SECTION') && Array.from(n.children).some((c) => BLOCK.test(c.tagName))) return fromDom(n);
|
|
393
|
-
const c = trimInline(inlineOf(n));
|
|
394
|
-
return c.length ? [{ t: 'p', c }] : [];
|
|
395
|
-
}
|
|
1
|
+
/* pm/c3-md.js — moved to pm/cozy-md.js (premium-agreed-design: no c3-* module loads on a premium page). The console keeps importing
|
|
2
|
+
* this name, so it re-exports the one copy. */
|
|
3
|
+
export * from './cozy-md.js';
|
|
@@ -15,7 +15,7 @@ import { button, row } from './primitives.js';
|
|
|
15
15
|
import { pmGet } from './http.js';
|
|
16
16
|
import { c3ic } from './pm-work-view.js';
|
|
17
17
|
import { openSheet, closeSheet } from './c3-sheet.js';
|
|
18
|
-
import { parseMd, toDom } from './
|
|
18
|
+
import { parseMd, toDom } from './cozy-md.js';
|
|
19
19
|
|
|
20
20
|
const p2 = (n) => String(n).padStart(2, '0');
|
|
21
21
|
const hm = (iso) => { const d = new Date(iso); return p2(d.getHours()) + ':' + p2(d.getMinutes()); };
|
|
@@ -1,68 +1,3 @@
|
|
|
1
|
-
/* pm/c3-phone-model.js —
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* momentOf({ today, needs, now }) → { kind, meeting?, next?, minutes?, fits?, later }
|
|
5
|
-
* kind 'meeting' a meeting is under way (start ≤ now < end) meeting = that one
|
|
6
|
-
* 'before' the next meeting starts within BEFORE_MIN minutes meeting = the next one, minutes = until it starts
|
|
7
|
-
* 'after' a meeting ended less than AFTER_MIN minutes ago, nothing under way meeting = the one that ended
|
|
8
|
-
* 'gap' a free stretch of GAP_MIN minutes or more before the next meeting minutes = free minutes, fits = items that fit
|
|
9
|
-
* 'morning' before noon with no meeting under way or near next = the next meeting, or null
|
|
10
|
-
* 'work' working hours after noon with no meeting near next = the next meeting, or null
|
|
11
|
-
* 'recap' from WRAP_HOUR on: the evening recap of the day next = null
|
|
12
|
-
* 'night' from NIGHT_HOUR on, or before EARLY_HOUR: tomorrow at a glance next = null
|
|
13
|
-
* later the meetings still to come after the one the moment is about (time order), for "I'll bring up later".
|
|
14
|
-
* part the part of the day the moment belongs to (PART_OF), drawn as one icon in the header:
|
|
15
|
-
* morning · work (gap, work) · meeting (before, meeting, after) · evening (recap) · night
|
|
16
|
-
* fitsIn(needs, minutes) the own items worth doing in a free stretch: overdue first (most late first), then due today; at most two.
|
|
17
|
-
* The meeting rows are the brief page's today[] rows: { id, title, start, end, people, initiative, prepared, before }. */
|
|
18
|
-
|
|
19
|
-
export const BEFORE_MIN = 30;
|
|
20
|
-
export const AFTER_MIN = 20;
|
|
21
|
-
export const GAP_MIN = 15;
|
|
22
|
-
export const WRAP_HOUR = 17;
|
|
23
|
-
export const NIGHT_HOUR = 20;
|
|
24
|
-
export const EARLY_HOUR = 5;
|
|
25
|
-
export const PART_OF = Object.freeze({ morning: 'morning', gap: 'work', work: 'work', before: 'meeting', meeting: 'meeting', after: 'meeting', recap: 'evening', night: 'night' });
|
|
26
|
-
|
|
27
|
-
const ms = (iso) => Date.parse(iso);
|
|
28
|
-
const ok = (m) => m && m.id && !Number.isNaN(ms(m.start)) && !Number.isNaN(ms(m.end || m.start));
|
|
29
|
-
|
|
30
|
-
export function fitsIn(needs, minutes) {
|
|
31
|
-
if (!(minutes >= GAP_MIN)) return [];
|
|
32
|
-
const own = (needs || []).filter((n) => n && (n.kind === 'overdue' || n.kind === 'due-today'));
|
|
33
|
-
own.sort((a, b) => (a.kind === b.kind ? (b.days_late || 0) - (a.days_late || 0) : a.kind === 'overdue' ? -1 : 1));
|
|
34
|
-
return own.slice(0, 2);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function momentOf(args = {}) {
|
|
38
|
-
const mo = kindOf(args);
|
|
39
|
-
return { ...mo, part: PART_OF[mo.kind] };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function kindOf({ today, needs, now } = {}) {
|
|
43
|
-
const t = (now instanceof Date ? now : new Date(now || Date.now())).getTime();
|
|
44
|
-
const hour = new Date(t).getHours();
|
|
45
|
-
const rows = (today || []).filter(ok).slice().sort((a, b) => ms(a.start) - ms(b.start));
|
|
46
|
-
const end = (m) => ms(m.end || m.start);
|
|
47
|
-
const cur = rows.find((m) => ms(m.start) <= t && t < end(m));
|
|
48
|
-
const upcoming = rows.filter((m) => ms(m.start) > t);
|
|
49
|
-
const next = upcoming[0] || null;
|
|
50
|
-
const laterThan = (m) => upcoming.filter((x) => x !== m);
|
|
51
|
-
if (cur) return { kind: 'meeting', meeting: cur, minutes: Math.round((end(cur) - t) / 60000), later: upcoming };
|
|
52
|
-
const until = next ? Math.round((ms(next.start) - t) / 60000) : null;
|
|
53
|
-
if (next && until <= BEFORE_MIN) return { kind: 'before', meeting: next, minutes: until, later: laterThan(next) };
|
|
54
|
-
const ended = rows.filter((m) => end(m) <= t && t - end(m) < AFTER_MIN * 60000).pop();
|
|
55
|
-
if (ended) return { kind: 'after', meeting: ended, later: upcoming };
|
|
56
|
-
if (hour >= NIGHT_HOUR || hour < EARLY_HOUR) return { kind: 'night', next: null, later: upcoming };
|
|
57
|
-
if (hour >= WRAP_HOUR) return { kind: 'recap', next: null, later: upcoming };
|
|
58
|
-
if (next && until >= GAP_MIN && rows.some((m) => end(m) <= t)) return { kind: 'gap', next, minutes: until, fits: fitsIn(needs, until), later: upcoming };
|
|
59
|
-
if (hour < 12) return { kind: 'morning', next, later: upcoming };
|
|
60
|
-
return { kind: 'work', next, minutes: until, fits: fitsIn(needs, until === null ? 120 : until), later: upcoming };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** "in 25 min", "in 1 h 5 min" */
|
|
64
|
-
export function inText(minutes) {
|
|
65
|
-
const m = Math.max(0, Math.round(minutes || 0));
|
|
66
|
-
if (m < 60) return 'in ' + m + ' min';
|
|
67
|
-
return 'in ' + Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '');
|
|
68
|
-
}
|
|
1
|
+
/* pm/c3-phone-model.js — moved to pm/phone-moment.js (premium-agreed-design: no c3-* module loads on a premium page). The console keeps importing
|
|
2
|
+
* this name, so it re-exports the one copy. */
|
|
3
|
+
export * from './phone-moment.js';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* chat-term — the chat header's Open in terminal icon (chat-open-in-terminal, Wawan 2026-10-22). Pure: no DOM, so Node tests it.
|
|
2
|
-
* A running session opens in the
|
|
2
|
+
* A running session's terminal opens read only in the Viewer (term-view.js): nothing on the premium pages links to the console any more.
|
|
3
3
|
* An ended chat copies the line that resumes its Claude Code conversation in a terminal (lib/briefing-premium-agent.js resumeCommand).
|
|
4
4
|
* Nothing to open or copy: the icon is hidden. */
|
|
5
5
|
export const TERM_ICON = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 10 3 2-3 2M12 15h5"/></svg>';
|
|
6
6
|
|
|
7
|
-
/** { live, command, ws } → {
|
|
7
|
+
/** { live, command, ws } → { term, label } for a running session, { copy, label } for an ended one, or null. */
|
|
8
8
|
export function termTarget({ live = null, command = null, ws = null } = {}) {
|
|
9
|
-
if (live && /^sess-\d+$/.test(String(live))) return {
|
|
9
|
+
if (live && /^sess-\d+$/.test(String(live))) return { term: String(live), label: 'Watch its terminal' };
|
|
10
10
|
if (command && typeof command === 'string') return { copy: command, label: 'Copy the terminal command' };
|
|
11
11
|
return null;
|
|
12
12
|
}
|