ponzu 1.79.0 → 1.79.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chromium.js +13 -0
- package/dist/index.js +106 -11
- 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)}"`;
|
|
@@ -33657,7 +33670,7 @@ The person may have their canvas in dark mode; get_basic_info says which. Artboa
|
|
|
33657
33670
|
|
|
33658
33671
|
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
33672
|
|
|
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.
|
|
33673
|
+
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
33674
|
|
|
33662
33675
|
Don't
|
|
33663
33676
|
- Don't rebuild what exists. duplicate it and edit the copy.
|
|
@@ -33737,7 +33750,7 @@ The .design folder is the spec. Read it directly from disk; don't screenshot and
|
|
|
33737
33750
|
- When something can't be built as drawn, leave a comment on the node explaining what you did instead.`,
|
|
33738
33751
|
format: `# The .design format
|
|
33739
33752
|
|
|
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.
|
|
33753
|
+
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
33754
|
|
|
33742
33755
|
name.design/
|
|
33743
33756
|
design.json name and pages
|
|
@@ -34484,6 +34497,11 @@ var orientTools = [
|
|
|
34484
34497
|
`)}${more ? `
|
|
34485
34498
|
\u2026 ${more} more` : ""}`);
|
|
34486
34499
|
}
|
|
34500
|
+
const held = design.heldFiles;
|
|
34501
|
+
if (held.length)
|
|
34502
|
+
lines.push(`Still being written, shown as last read whole (write files whole: a temp file, then rename it into place):
|
|
34503
|
+
${held.join(`
|
|
34504
|
+
`)}`);
|
|
34487
34505
|
const overlaps = [];
|
|
34488
34506
|
for (const page of doc.pages)
|
|
34489
34507
|
overlaps.push(...await pageOverlapList(ws, key, doc, page.artboards));
|
|
@@ -34507,7 +34525,7 @@ var orientTools = [
|
|
|
34507
34525
|
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
34526
|
}
|
|
34509
34527
|
return { text: lines.join(`
|
|
34510
|
-
`) };
|
|
34528
|
+
`), metrics: { held_files: held.length } };
|
|
34511
34529
|
}
|
|
34512
34530
|
}),
|
|
34513
34531
|
tool({
|
|
@@ -44595,6 +44613,8 @@ function writeBag(doc, layout) {
|
|
|
44595
44613
|
|
|
44596
44614
|
// packages/store/src/design.ts
|
|
44597
44615
|
var HISTORY_LIMIT = 200;
|
|
44616
|
+
var HOLD_DELAY = 1500;
|
|
44617
|
+
var ARTBOARD_FILE = /^pages\/[^/]+\/[^/]+\.html$/;
|
|
44598
44618
|
|
|
44599
44619
|
class Design {
|
|
44600
44620
|
storage;
|
|
@@ -44614,6 +44634,9 @@ class Design {
|
|
|
44614
44634
|
stopWatching = null;
|
|
44615
44635
|
closed = false;
|
|
44616
44636
|
read = { problems: [], unreadable: [] };
|
|
44637
|
+
held = new Map;
|
|
44638
|
+
holdTimer = null;
|
|
44639
|
+
deferred = new Set;
|
|
44617
44640
|
constructor(storage, doc, layout, opts) {
|
|
44618
44641
|
this.storage = storage;
|
|
44619
44642
|
this.opts = opts;
|
|
@@ -44624,7 +44647,10 @@ class Design {
|
|
|
44624
44647
|
const name = opts.name ?? nameFromRoot(storage.root) ?? "Untitled";
|
|
44625
44648
|
const bag = await storage.readAll();
|
|
44626
44649
|
const { doc, layout, problems, unreadable } = readBag(bag, name);
|
|
44627
|
-
const design = new Design(storage, doc, layout, {
|
|
44650
|
+
const design = new Design(storage, doc, layout, {
|
|
44651
|
+
saveDelay: opts.saveDelay ?? 120,
|
|
44652
|
+
holdDelay: opts.holdDelay ?? HOLD_DELAY
|
|
44653
|
+
});
|
|
44628
44654
|
design.read = { problems, unreadable };
|
|
44629
44655
|
for (const [path, content] of Object.entries(bag))
|
|
44630
44656
|
design.written.set(path, content);
|
|
@@ -44761,14 +44787,19 @@ class Design {
|
|
|
44761
44787
|
for (const page of this.doc.pages) {
|
|
44762
44788
|
for (const ab of page.artboards) {
|
|
44763
44789
|
const path = next.artboards.get(ab.id);
|
|
44764
|
-
|
|
44790
|
+
const was = this.layout.artboards.get(ab.id);
|
|
44791
|
+
if (!dirty.has(ab.id) && was === path)
|
|
44792
|
+
continue;
|
|
44793
|
+
if (this.held.has(path) || was && this.held.has(was))
|
|
44794
|
+
this.deferred.add(ab.id);
|
|
44795
|
+
else
|
|
44765
44796
|
writes.set(path, serializeArtboard(ab));
|
|
44766
44797
|
}
|
|
44767
44798
|
}
|
|
44768
44799
|
const keep = new Set(next.artboards.values());
|
|
44769
44800
|
const removals = [];
|
|
44770
44801
|
for (const path of this.layout.artboards.values())
|
|
44771
|
-
if (!keep.has(path))
|
|
44802
|
+
if (!keep.has(path) && !this.held.has(path))
|
|
44772
44803
|
removals.push(path);
|
|
44773
44804
|
if (scopes.has("threads") && noThreads && this.written.has("comments.json"))
|
|
44774
44805
|
removals.push("comments.json");
|
|
@@ -44799,6 +44830,9 @@ class Design {
|
|
|
44799
44830
|
get problems() {
|
|
44800
44831
|
return this.read.problems;
|
|
44801
44832
|
}
|
|
44833
|
+
get heldFiles() {
|
|
44834
|
+
return [...this.held.keys()];
|
|
44835
|
+
}
|
|
44802
44836
|
pathOf(artboardId) {
|
|
44803
44837
|
return this.layout.artboards.get(artboardId) ?? planLayout(this.doc, this.layout).artboards.get(artboardId);
|
|
44804
44838
|
}
|
|
@@ -44826,8 +44860,9 @@ class Design {
|
|
|
44826
44860
|
break;
|
|
44827
44861
|
}
|
|
44828
44862
|
}
|
|
44863
|
+
this.holdUnfinished(bag);
|
|
44829
44864
|
if (!changed)
|
|
44830
|
-
return;
|
|
44865
|
+
return this.saveDeferred();
|
|
44831
44866
|
const { doc: incoming, layout, lazy, problems, unreadable } = readBag(bag, this.doc.name);
|
|
44832
44867
|
this.written = new Map(Object.entries(bag));
|
|
44833
44868
|
this.read = { problems, unreadable };
|
|
@@ -44840,7 +44875,12 @@ class Design {
|
|
|
44840
44875
|
pin.push(ab.id);
|
|
44841
44876
|
}
|
|
44842
44877
|
}
|
|
44843
|
-
const
|
|
44878
|
+
const keep = new Set;
|
|
44879
|
+
for (const map of [layout.artboards, this.layout.artboards])
|
|
44880
|
+
for (const [id, path] of map)
|
|
44881
|
+
if (this.held.has(path))
|
|
44882
|
+
keep.add(id);
|
|
44883
|
+
const ops = diffDocs(this.doc, incoming, keep);
|
|
44844
44884
|
this.layout = layout;
|
|
44845
44885
|
if (incoming.example)
|
|
44846
44886
|
this.doc.example = true;
|
|
@@ -44860,6 +44900,56 @@ class Design {
|
|
|
44860
44900
|
}
|
|
44861
44901
|
if (pin.length)
|
|
44862
44902
|
await this.pinIds(pin, bag);
|
|
44903
|
+
this.saveDeferred();
|
|
44904
|
+
}
|
|
44905
|
+
holdUnfinished(bag) {
|
|
44906
|
+
const now = Date.now();
|
|
44907
|
+
let wait = Number.POSITIVE_INFINITY;
|
|
44908
|
+
for (const path of new Set([...Object.keys(bag), ...this.held.keys()])) {
|
|
44909
|
+
if (!ARTBOARD_FILE.test(path))
|
|
44910
|
+
continue;
|
|
44911
|
+
const text = bag[path];
|
|
44912
|
+
const before = this.written.get(path);
|
|
44913
|
+
const unfinished = text !== undefined && text !== before && !artboardFileComplete(text) && (before === undefined || artboardFileComplete(before));
|
|
44914
|
+
let hold = this.held.get(path);
|
|
44915
|
+
if (unfinished && (!hold || hold.content !== text)) {
|
|
44916
|
+
hold = { content: text, since: now };
|
|
44917
|
+
this.held.set(path, hold);
|
|
44918
|
+
}
|
|
44919
|
+
const left = unfinished && hold ? hold.since + this.opts.holdDelay - now : 0;
|
|
44920
|
+
if (left <= 0) {
|
|
44921
|
+
this.held.delete(path);
|
|
44922
|
+
continue;
|
|
44923
|
+
}
|
|
44924
|
+
wait = Math.min(wait, left);
|
|
44925
|
+
if (before === undefined)
|
|
44926
|
+
delete bag[path];
|
|
44927
|
+
else
|
|
44928
|
+
bag[path] = before;
|
|
44929
|
+
}
|
|
44930
|
+
if (this.holdTimer)
|
|
44931
|
+
clearTimeout(this.holdTimer);
|
|
44932
|
+
this.holdTimer = null;
|
|
44933
|
+
if (this.held.size)
|
|
44934
|
+
this.holdTimer = setTimeout(() => {
|
|
44935
|
+
this.holdTimer = null;
|
|
44936
|
+
this.onOutsideChange([...this.held.keys()]);
|
|
44937
|
+
}, wait + 1);
|
|
44938
|
+
}
|
|
44939
|
+
saveDeferred() {
|
|
44940
|
+
let any = false;
|
|
44941
|
+
for (const id of this.deferred) {
|
|
44942
|
+
const path = this.layout.artboards.get(id);
|
|
44943
|
+
if (path && this.held.has(path))
|
|
44944
|
+
continue;
|
|
44945
|
+
this.deferred.delete(id);
|
|
44946
|
+
if (findArtboard(this.doc, id)) {
|
|
44947
|
+
this.dirtyArtboards.add(id);
|
|
44948
|
+
any = true;
|
|
44949
|
+
}
|
|
44950
|
+
}
|
|
44951
|
+
if (any)
|
|
44952
|
+
this.scheduleSave();
|
|
44863
44953
|
}
|
|
44864
44954
|
async readSettled() {
|
|
44865
44955
|
for (;; ) {
|
|
@@ -44896,6 +44986,9 @@ class Design {
|
|
|
44896
44986
|
}
|
|
44897
44987
|
async close() {
|
|
44898
44988
|
this.stopWatching?.();
|
|
44989
|
+
if (this.holdTimer)
|
|
44990
|
+
clearTimeout(this.holdTimer);
|
|
44991
|
+
this.holdTimer = null;
|
|
44899
44992
|
for (let saving;saving !== this.saving || this.saveTimer; ) {
|
|
44900
44993
|
saving = this.saving;
|
|
44901
44994
|
await this.flush();
|
|
@@ -44924,7 +45017,7 @@ function sameMap(a, b) {
|
|
|
44924
45017
|
return false;
|
|
44925
45018
|
return true;
|
|
44926
45019
|
}
|
|
44927
|
-
function diffDocs(cur, next) {
|
|
45020
|
+
function diffDocs(cur, next, keep = new Set) {
|
|
44928
45021
|
const ops = [];
|
|
44929
45022
|
if (cur.name !== next.name)
|
|
44930
45023
|
ops.push({ op: "file.rename", name: next.name });
|
|
@@ -44961,10 +45054,12 @@ function diffDocs(cur, next) {
|
|
|
44961
45054
|
p.artboards.forEach((a, index) => nextArtboards.set(a.id, { page: p.id, artboard: a, index }));
|
|
44962
45055
|
for (const p of cur.pages) {
|
|
44963
45056
|
for (const a of p.artboards)
|
|
44964
|
-
if (!nextArtboards.has(a.id))
|
|
45057
|
+
if (!nextArtboards.has(a.id) && !keep.has(a.id))
|
|
44965
45058
|
ops.push({ op: "artboard.delete", id: a.id });
|
|
44966
45059
|
}
|
|
44967
45060
|
for (const [id, n] of nextArtboards) {
|
|
45061
|
+
if (keep.has(id))
|
|
45062
|
+
continue;
|
|
44968
45063
|
const hit = findArtboard(cur, id);
|
|
44969
45064
|
if (!hit) {
|
|
44970
45065
|
ops.push({ op: "artboard.create", page: n.page, index: n.index, artboard: n.artboard });
|
|
@@ -50034,7 +50129,7 @@ function remoteUpdater(endpoint, token) {
|
|
|
50034
50129
|
// apps/cli/package.json
|
|
50035
50130
|
var package_default = {
|
|
50036
50131
|
name: "ponzu",
|
|
50037
|
-
version: "1.79.
|
|
50132
|
+
version: "1.79.1",
|
|
50038
50133
|
description: "The open source canvas your agent draws on in HTML and CSS.",
|
|
50039
50134
|
type: "module",
|
|
50040
50135
|
license: "MIT",
|