ponzu 1.79.0 → 1.79.2
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/chromium.js +13 -0
- package/dist/index.js +111 -15
- package/package.json +1 -1
package/dist/chromium.js
CHANGED
|
@@ -9011,6 +9011,19 @@ function parseArtboardFile(html, fallback) {
|
|
|
9011
9011
|
root.name = name;
|
|
9012
9012
|
return { artboard: { id: root.id, name, x, y, root }, dropped, assigned };
|
|
9013
9013
|
}
|
|
9014
|
+
function artboardFileComplete(html) {
|
|
9015
|
+
const text = html.replace(/<!--[\s\S]*?(?:-->|$)/g, "");
|
|
9016
|
+
const open = /<section\b[^>]*\bdata-artboard\b[^>]*>/i.exec(text);
|
|
9017
|
+
if (!open)
|
|
9018
|
+
return false;
|
|
9019
|
+
let depth = 0;
|
|
9020
|
+
for (const m of text.slice(open.index).matchAll(/<(\/?)section\b[^>]*>/gi)) {
|
|
9021
|
+
depth += m[1] ? -1 : 1;
|
|
9022
|
+
if (depth === 0)
|
|
9023
|
+
return true;
|
|
9024
|
+
}
|
|
9025
|
+
return false;
|
|
9026
|
+
}
|
|
9014
9027
|
function serializeArtboardFile(ab) {
|
|
9015
9028
|
const root = ab.root;
|
|
9016
9029
|
let open = `<section data-artboard data-id="${ab.id}" data-name="${escapeAttr(ab.name)}" data-x="${fmt(ab.x)}" data-y="${fmt(ab.y)}"`;
|
package/dist/index.js
CHANGED
|
@@ -15972,6 +15972,19 @@ function parseArtboardFile(html, fallback) {
|
|
|
15972
15972
|
root.name = name;
|
|
15973
15973
|
return { artboard: { id: root.id, name, x, y, root }, dropped, assigned };
|
|
15974
15974
|
}
|
|
15975
|
+
function artboardFileComplete(html) {
|
|
15976
|
+
const text = html.replace(/<!--[\s\S]*?(?:-->|$)/g, "");
|
|
15977
|
+
const open = /<section\b[^>]*\bdata-artboard\b[^>]*>/i.exec(text);
|
|
15978
|
+
if (!open)
|
|
15979
|
+
return false;
|
|
15980
|
+
let depth = 0;
|
|
15981
|
+
for (const m of text.slice(open.index).matchAll(/<(\/?)section\b[^>]*>/gi)) {
|
|
15982
|
+
depth += m[1] ? -1 : 1;
|
|
15983
|
+
if (depth === 0)
|
|
15984
|
+
return true;
|
|
15985
|
+
}
|
|
15986
|
+
return false;
|
|
15987
|
+
}
|
|
15975
15988
|
function serializeArtboardFile(ab) {
|
|
15976
15989
|
const root = ab.root;
|
|
15977
15990
|
let open = `<section data-artboard data-id="${ab.id}" data-name="${escapeAttr(ab.name)}" data-x="${fmt(ab.x)}" data-y="${fmt(ab.y)}"`;
|
|
@@ -33633,7 +33646,7 @@ Workflow
|
|
|
33633
33646
|
4. screenshot after every few writes. Read the lint lines. Fix clipped text and overflow before moving on. When you add motion or states, record them (get_guide('motion')). If a screenshot fails, its error says why: a renderer that didn't answer means the Ponzu app is busy or showing a dialog, so ask the person; one that isn't running is restarting, so try again shortly. Keep working in Ponzu rather than rendering the page some other way.
|
|
33634
33647
|
5. The canvas shows which artboards you're changing on its own. To tell the person what you're doing, set_status with a few words. When you take on a new request, pass intent too: what they asked for, in one plain line.
|
|
33635
33648
|
6. When you point the person at your work in chat, give them the Link from get_basic_info, not the folder path: a path opens their editor, the link opens Ponzu. Point at the exact work: add &artboard=<id> to open on one artboard, or &page=<id> to open on a whole page (a flow, a set of options). With both, it opens on the artboard if it's on that page, otherwise on the page.
|
|
33636
|
-
7. Explain your work on the canvas itself. A small artboard beside the work, named "Note: \u2026" with height fit-content, holds rationale, labels, a flow's arrows or what to compare. The canvas is infinite, so annotate generously. Comments are for what needs the person: a question, a decision, something you couldn't do.
|
|
33649
|
+
7. Explain your work on the canvas itself. A small artboard beside the work, named "Note: \u2026" with height fit-content, holds rationale, labels, a flow's arrows or what to compare. Color it with light-dark() tokens so it suits the person's canvas in either theme (Light and dark, below). The canvas is infinite, so annotate generously. Comments are for what needs the person: a question, a decision, something you couldn't do.
|
|
33637
33650
|
|
|
33638
33651
|
Several files open: a call without file goes to the file that holds the ids it passes, else the one you last created, named or edited. Pass file once to switch; list_files marks the current one.
|
|
33639
33652
|
|
|
@@ -33650,14 +33663,15 @@ HTML and CSS
|
|
|
33650
33663
|
|
|
33651
33664
|
Light and dark
|
|
33652
33665
|
The person may have their canvas in dark mode; get_basic_info says which. Artboards show in that theme, and screenshots default to it.
|
|
33653
|
-
-
|
|
33666
|
+
- Boards you make to talk to the person follow their canvas. Notes, explainers, diagrams, comparisons, decision docs, plans and cost tables are read, not shipped: give them light-dark() colors so a dark canvas shows them dark and a light one light. A few tokens cover them: paper, raised surface, ink, muted ink, line and an accent, e.g. --note-paper: light-dark(#f6f5f2, #1b1b1a). Do this even in a design whose product screens have one look.
|
|
33667
|
+
- A product's own screens follow the product. One that has a single look keeps it: plain colors stay as they are in both themes.
|
|
33654
33668
|
- A design with both themes puts every color in a light-dark() token: --color-paper: light-dark(#fafaf9, #121212). Use the tokens for text, surfaces, borders, shadows and dot grids alike. A raw #fff or rgba(0,0,0,.06) beside them stays light when the rest turns dark.
|
|
33655
33669
|
- Content that should look one way in either theme (a mock of a light app, a photo's caption, a code block) sets color-scheme: light or dark on its wrapper. light-dark() inside it then picks that side.
|
|
33656
33670
|
- Lint checks a themed design's colors in both themes, and says which text or surface stops reading in the other one. Screenshot the other theme with colorScheme before you call it done.
|
|
33657
33671
|
|
|
33658
33672
|
Results are lean: ids of what you created, and what was dropped. Use get_tree to see structure, get_node for one node's detail.
|
|
33659
33673
|
|
|
33660
|
-
A whole artboard's content can go in one write_html call: target the artboard with mode replace-children. Content too big for a call (a long table, a diagram from a script) can go straight into the artboard's file instead, at the path create_artboard returns. Ponzu picks the edit up live. Elements without a data-id get one: ids from get_tree keep pointing at the same element across later edits to the file, and Ponzu writes them in when it needs to. get_guide('format') has the files and their fields.
|
|
33674
|
+
A whole artboard's content can go in one write_html call: target the artboard with mode replace-children. Content too big for a call (a long table, a diagram from a script) can go straight into the artboard's file instead, at the path create_artboard returns. Write it whole: to a temp file beside it (name.html.tmp), then rename that over it. Ponzu picks the edit up live. Elements without a data-id get one: ids from get_tree keep pointing at the same element across later edits to the file, and Ponzu writes them in when it needs to. get_guide('format') has the files and their fields.
|
|
33661
33675
|
|
|
33662
33676
|
Don't
|
|
33663
33677
|
- Don't rebuild what exists. duplicate it and edit the copy.
|
|
@@ -33737,7 +33751,7 @@ The .design folder is the spec. Read it directly from disk; don't screenshot and
|
|
|
33737
33751
|
- When something can't be built as drawn, leave a comment on the node explaining what you did instead.`,
|
|
33738
33752
|
format: `# The .design format
|
|
33739
33753
|
|
|
33740
|
-
Write the files yourself only to bring in or generate a lot at once: a design ported from another tool, a diagram from a script, dozens of artboards. Ponzu picks them up live. For an artboard you made with create_artboard, write its file once the call returns, at the path it gives. Then open the design with get_basic_info (it lists anything Ponzu couldn't use), screenshot each artboard and fix what lint reports. For everything else use the tools: they lint as you go and the person can undo them.
|
|
33754
|
+
Write the files yourself only to bring in or generate a lot at once: a design ported from another tool, a diagram from a script, dozens of artboards. Ponzu picks them up live. For an artboard you made with create_artboard, write its file once the call returns, at the path it gives. Write each file whole: write a temp file beside it (cart.html.tmp), then rename it over the real one. A file caught half-written shows as it last was until it's finished, and get_basic_info lists it as still being written. Then open the design with get_basic_info (it lists anything Ponzu couldn't use), screenshot each artboard and fix what lint reports. For everything else use the tools: they lint as you go and the person can undo them.
|
|
33741
33755
|
|
|
33742
33756
|
name.design/
|
|
33743
33757
|
design.json name and pages
|
|
@@ -33829,7 +33843,7 @@ Start every session with get_basic_info, then read_notes, then get_guide('basics
|
|
|
33829
33843
|
|
|
33830
33844
|
For a product shot (faux product UI for a launch page: a hero, a feature card, a bento grid, a cursor walking through a flow), read get_guide('product') first.
|
|
33831
33845
|
|
|
33832
|
-
Build in small pieces, screenshot often, and fix what lint reports. Screenshots show the theme the person's canvas is in; a design with both themes uses light-dark() tokens for every color. record shows animation and hover states frame by frame. Put design decisions in tokens and notes. Variations go next to the original, never over it. The canvas shows which artboards you're changing; set_status tells the person what you're doing, and its intent, set once per request, says what they asked for.
|
|
33846
|
+
Build in small pieces, screenshot often, and fix what lint reports. Screenshots show the theme the person's canvas is in; a design with both themes uses light-dark() tokens for every color, and so do the notes, diagrams and docs you make to explain something to the person, so they read on a dark canvas too. record shows animation and hover states frame by frame. Put design decisions in tokens and notes. Variations go next to the original, never over it. The canvas shows which artboards you're changing; set_status tells the person what you're doing, and its intent, set once per request, says what they asked for.
|
|
33833
33847
|
|
|
33834
33848
|
The canvas is yours to annotate: a "Note: \u2026" artboard beside the work carries rationale, labels and what to compare. Comments carry what needs the person: a question, a choice, something you couldn't do.
|
|
33835
33849
|
|
|
@@ -34484,6 +34498,11 @@ var orientTools = [
|
|
|
34484
34498
|
`)}${more ? `
|
|
34485
34499
|
\u2026 ${more} more` : ""}`);
|
|
34486
34500
|
}
|
|
34501
|
+
const held = design.heldFiles;
|
|
34502
|
+
if (held.length)
|
|
34503
|
+
lines.push(`Still being written, shown as last read whole (write files whole: a temp file, then rename it into place):
|
|
34504
|
+
${held.join(`
|
|
34505
|
+
`)}`);
|
|
34487
34506
|
const overlaps = [];
|
|
34488
34507
|
for (const page of doc.pages)
|
|
34489
34508
|
overlaps.push(...await pageOverlapList(ws, key, doc, page.artboards));
|
|
@@ -34497,7 +34516,7 @@ var orientTools = [
|
|
|
34497
34516
|
\u2026 ${more} more; move these and call get_basic_info again for the rest` : ""}`);
|
|
34498
34517
|
}
|
|
34499
34518
|
if (ws.theme)
|
|
34500
|
-
lines.push(isThemed(doc.tokens) || doc.pages.some((p) => p.artboards.some((ab) => isThemed("", ab.root))) ? `The person's canvas is in ${ws.theme} mode, so they see this design's light-dark() colors in ${ws.theme}. Screenshots default to it.` : `The person's canvas is in ${ws.theme} mode. These tokens don't change with the theme, so artboards show as they are in both.`);
|
|
34519
|
+
lines.push(isThemed(doc.tokens) || doc.pages.some((p) => p.artboards.some((ab) => isThemed("", ab.root))) ? `The person's canvas is in ${ws.theme} mode, so they see this design's light-dark() colors in ${ws.theme}. Screenshots default to it.` : `The person's canvas is in ${ws.theme} mode. These tokens don't change with the theme, so artboards show as they are in both. Notes, diagrams and docs you make for the person should still follow it: give them light-dark() colors.`);
|
|
34501
34520
|
const others = ws.presence.list().filter((p) => p.working.length);
|
|
34502
34521
|
if (others.length)
|
|
34503
34522
|
lines.push(`Working now: ${others.map((p) => `${p.name} on ${p.working.join(", ")}`).join("; ")}`);
|
|
@@ -34507,7 +34526,7 @@ var orientTools = [
|
|
|
34507
34526
|
lines.push(rest.length > 5 ? `Other open files: ${rest.length} (list_files).${sticks}` : `Other open files: ${rest.map((f) => f.design.doc.name).join(", ")}.${sticks}`);
|
|
34508
34527
|
}
|
|
34509
34528
|
return { text: lines.join(`
|
|
34510
|
-
`) };
|
|
34529
|
+
`), metrics: { held_files: held.length } };
|
|
34511
34530
|
}
|
|
34512
34531
|
}),
|
|
34513
34532
|
tool({
|
|
@@ -44595,6 +44614,8 @@ function writeBag(doc, layout) {
|
|
|
44595
44614
|
|
|
44596
44615
|
// packages/store/src/design.ts
|
|
44597
44616
|
var HISTORY_LIMIT = 200;
|
|
44617
|
+
var HOLD_DELAY = 1500;
|
|
44618
|
+
var ARTBOARD_FILE = /^pages\/[^/]+\/[^/]+\.html$/;
|
|
44598
44619
|
|
|
44599
44620
|
class Design {
|
|
44600
44621
|
storage;
|
|
@@ -44614,6 +44635,9 @@ class Design {
|
|
|
44614
44635
|
stopWatching = null;
|
|
44615
44636
|
closed = false;
|
|
44616
44637
|
read = { problems: [], unreadable: [] };
|
|
44638
|
+
held = new Map;
|
|
44639
|
+
holdTimer = null;
|
|
44640
|
+
deferred = new Set;
|
|
44617
44641
|
constructor(storage, doc, layout, opts) {
|
|
44618
44642
|
this.storage = storage;
|
|
44619
44643
|
this.opts = opts;
|
|
@@ -44624,7 +44648,10 @@ class Design {
|
|
|
44624
44648
|
const name = opts.name ?? nameFromRoot(storage.root) ?? "Untitled";
|
|
44625
44649
|
const bag = await storage.readAll();
|
|
44626
44650
|
const { doc, layout, problems, unreadable } = readBag(bag, name);
|
|
44627
|
-
const design = new Design(storage, doc, layout, {
|
|
44651
|
+
const design = new Design(storage, doc, layout, {
|
|
44652
|
+
saveDelay: opts.saveDelay ?? 120,
|
|
44653
|
+
holdDelay: opts.holdDelay ?? HOLD_DELAY
|
|
44654
|
+
});
|
|
44628
44655
|
design.read = { problems, unreadable };
|
|
44629
44656
|
for (const [path, content] of Object.entries(bag))
|
|
44630
44657
|
design.written.set(path, content);
|
|
@@ -44761,14 +44788,19 @@ class Design {
|
|
|
44761
44788
|
for (const page of this.doc.pages) {
|
|
44762
44789
|
for (const ab of page.artboards) {
|
|
44763
44790
|
const path = next.artboards.get(ab.id);
|
|
44764
|
-
|
|
44791
|
+
const was = this.layout.artboards.get(ab.id);
|
|
44792
|
+
if (!dirty.has(ab.id) && was === path)
|
|
44793
|
+
continue;
|
|
44794
|
+
if (this.held.has(path) || was && this.held.has(was))
|
|
44795
|
+
this.deferred.add(ab.id);
|
|
44796
|
+
else
|
|
44765
44797
|
writes.set(path, serializeArtboard(ab));
|
|
44766
44798
|
}
|
|
44767
44799
|
}
|
|
44768
44800
|
const keep = new Set(next.artboards.values());
|
|
44769
44801
|
const removals = [];
|
|
44770
44802
|
for (const path of this.layout.artboards.values())
|
|
44771
|
-
if (!keep.has(path))
|
|
44803
|
+
if (!keep.has(path) && !this.held.has(path))
|
|
44772
44804
|
removals.push(path);
|
|
44773
44805
|
if (scopes.has("threads") && noThreads && this.written.has("comments.json"))
|
|
44774
44806
|
removals.push("comments.json");
|
|
@@ -44799,6 +44831,9 @@ class Design {
|
|
|
44799
44831
|
get problems() {
|
|
44800
44832
|
return this.read.problems;
|
|
44801
44833
|
}
|
|
44834
|
+
get heldFiles() {
|
|
44835
|
+
return [...this.held.keys()];
|
|
44836
|
+
}
|
|
44802
44837
|
pathOf(artboardId) {
|
|
44803
44838
|
return this.layout.artboards.get(artboardId) ?? planLayout(this.doc, this.layout).artboards.get(artboardId);
|
|
44804
44839
|
}
|
|
@@ -44826,8 +44861,9 @@ class Design {
|
|
|
44826
44861
|
break;
|
|
44827
44862
|
}
|
|
44828
44863
|
}
|
|
44864
|
+
this.holdUnfinished(bag);
|
|
44829
44865
|
if (!changed)
|
|
44830
|
-
return;
|
|
44866
|
+
return this.saveDeferred();
|
|
44831
44867
|
const { doc: incoming, layout, lazy, problems, unreadable } = readBag(bag, this.doc.name);
|
|
44832
44868
|
this.written = new Map(Object.entries(bag));
|
|
44833
44869
|
this.read = { problems, unreadable };
|
|
@@ -44840,7 +44876,12 @@ class Design {
|
|
|
44840
44876
|
pin.push(ab.id);
|
|
44841
44877
|
}
|
|
44842
44878
|
}
|
|
44843
|
-
const
|
|
44879
|
+
const keep = new Set;
|
|
44880
|
+
for (const map of [layout.artboards, this.layout.artboards])
|
|
44881
|
+
for (const [id, path] of map)
|
|
44882
|
+
if (this.held.has(path))
|
|
44883
|
+
keep.add(id);
|
|
44884
|
+
const ops = diffDocs(this.doc, incoming, keep);
|
|
44844
44885
|
this.layout = layout;
|
|
44845
44886
|
if (incoming.example)
|
|
44846
44887
|
this.doc.example = true;
|
|
@@ -44860,6 +44901,56 @@ class Design {
|
|
|
44860
44901
|
}
|
|
44861
44902
|
if (pin.length)
|
|
44862
44903
|
await this.pinIds(pin, bag);
|
|
44904
|
+
this.saveDeferred();
|
|
44905
|
+
}
|
|
44906
|
+
holdUnfinished(bag) {
|
|
44907
|
+
const now = Date.now();
|
|
44908
|
+
let wait = Number.POSITIVE_INFINITY;
|
|
44909
|
+
for (const path of new Set([...Object.keys(bag), ...this.held.keys()])) {
|
|
44910
|
+
if (!ARTBOARD_FILE.test(path))
|
|
44911
|
+
continue;
|
|
44912
|
+
const text = bag[path];
|
|
44913
|
+
const before = this.written.get(path);
|
|
44914
|
+
const unfinished = text !== undefined && text !== before && !artboardFileComplete(text) && (before === undefined || artboardFileComplete(before));
|
|
44915
|
+
let hold = this.held.get(path);
|
|
44916
|
+
if (unfinished && (!hold || hold.content !== text)) {
|
|
44917
|
+
hold = { content: text, since: now };
|
|
44918
|
+
this.held.set(path, hold);
|
|
44919
|
+
}
|
|
44920
|
+
const left = unfinished && hold ? hold.since + this.opts.holdDelay - now : 0;
|
|
44921
|
+
if (left <= 0) {
|
|
44922
|
+
this.held.delete(path);
|
|
44923
|
+
continue;
|
|
44924
|
+
}
|
|
44925
|
+
wait = Math.min(wait, left);
|
|
44926
|
+
if (before === undefined)
|
|
44927
|
+
delete bag[path];
|
|
44928
|
+
else
|
|
44929
|
+
bag[path] = before;
|
|
44930
|
+
}
|
|
44931
|
+
if (this.holdTimer)
|
|
44932
|
+
clearTimeout(this.holdTimer);
|
|
44933
|
+
this.holdTimer = null;
|
|
44934
|
+
if (this.held.size)
|
|
44935
|
+
this.holdTimer = setTimeout(() => {
|
|
44936
|
+
this.holdTimer = null;
|
|
44937
|
+
this.onOutsideChange([...this.held.keys()]);
|
|
44938
|
+
}, wait + 1);
|
|
44939
|
+
}
|
|
44940
|
+
saveDeferred() {
|
|
44941
|
+
let any = false;
|
|
44942
|
+
for (const id of this.deferred) {
|
|
44943
|
+
const path = this.layout.artboards.get(id);
|
|
44944
|
+
if (path && this.held.has(path))
|
|
44945
|
+
continue;
|
|
44946
|
+
this.deferred.delete(id);
|
|
44947
|
+
if (findArtboard(this.doc, id)) {
|
|
44948
|
+
this.dirtyArtboards.add(id);
|
|
44949
|
+
any = true;
|
|
44950
|
+
}
|
|
44951
|
+
}
|
|
44952
|
+
if (any)
|
|
44953
|
+
this.scheduleSave();
|
|
44863
44954
|
}
|
|
44864
44955
|
async readSettled() {
|
|
44865
44956
|
for (;; ) {
|
|
@@ -44896,6 +44987,9 @@ class Design {
|
|
|
44896
44987
|
}
|
|
44897
44988
|
async close() {
|
|
44898
44989
|
this.stopWatching?.();
|
|
44990
|
+
if (this.holdTimer)
|
|
44991
|
+
clearTimeout(this.holdTimer);
|
|
44992
|
+
this.holdTimer = null;
|
|
44899
44993
|
for (let saving;saving !== this.saving || this.saveTimer; ) {
|
|
44900
44994
|
saving = this.saving;
|
|
44901
44995
|
await this.flush();
|
|
@@ -44924,7 +45018,7 @@ function sameMap(a, b) {
|
|
|
44924
45018
|
return false;
|
|
44925
45019
|
return true;
|
|
44926
45020
|
}
|
|
44927
|
-
function diffDocs(cur, next) {
|
|
45021
|
+
function diffDocs(cur, next, keep = new Set) {
|
|
44928
45022
|
const ops = [];
|
|
44929
45023
|
if (cur.name !== next.name)
|
|
44930
45024
|
ops.push({ op: "file.rename", name: next.name });
|
|
@@ -44961,10 +45055,12 @@ function diffDocs(cur, next) {
|
|
|
44961
45055
|
p.artboards.forEach((a, index) => nextArtboards.set(a.id, { page: p.id, artboard: a, index }));
|
|
44962
45056
|
for (const p of cur.pages) {
|
|
44963
45057
|
for (const a of p.artboards)
|
|
44964
|
-
if (!nextArtboards.has(a.id))
|
|
45058
|
+
if (!nextArtboards.has(a.id) && !keep.has(a.id))
|
|
44965
45059
|
ops.push({ op: "artboard.delete", id: a.id });
|
|
44966
45060
|
}
|
|
44967
45061
|
for (const [id, n] of nextArtboards) {
|
|
45062
|
+
if (keep.has(id))
|
|
45063
|
+
continue;
|
|
44968
45064
|
const hit = findArtboard(cur, id);
|
|
44969
45065
|
if (!hit) {
|
|
44970
45066
|
ops.push({ op: "artboard.create", page: n.page, index: n.index, artboard: n.artboard });
|
|
@@ -50034,7 +50130,7 @@ function remoteUpdater(endpoint, token) {
|
|
|
50034
50130
|
// apps/cli/package.json
|
|
50035
50131
|
var package_default = {
|
|
50036
50132
|
name: "ponzu",
|
|
50037
|
-
version: "1.79.
|
|
50133
|
+
version: "1.79.2",
|
|
50038
50134
|
description: "The open source canvas your agent draws on in HTML and CSS.",
|
|
50039
50135
|
type: "module",
|
|
50040
50136
|
license: "MIT",
|