@open-artifact/design-core 0.9.2 → 0.11.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-artifact/design-core",
3
- "version": "0.9.2",
3
+ "version": "0.11.0",
4
4
  "description": "The Design artifact model: canvas.json, merging, view context and project checks.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -16,7 +16,7 @@
16
16
  "NOTICE"
17
17
  ],
18
18
  "dependencies": {
19
- "@open-artifact/dc": "0.9.2"
19
+ "@open-artifact/dc": "0.11.0"
20
20
  },
21
21
  "license": "Apache-2.0",
22
22
  "author": {
package/src/canvas.d.ts CHANGED
@@ -15,10 +15,11 @@ export declare const MAX_BOARD_SIZE = 8000;
15
15
  /** Gap between frames in a row, and between rows. */
16
16
  export declare const ROW_GAP = 80;
17
17
  export declare const COLUMN_GAP = 120;
18
- /** Most pages, notes, guides per board. */
18
+ /** Most pages, and guides per board. */
19
19
  export declare const MAX_PAGES = 40;
20
- export declare const MAX_NOTES = 999;
21
20
  export declare const MAX_GUIDES = 6;
21
+ /** Largest index an agent should write, in UTF-8 bytes. Notes have no count limit; this bounds them. */
22
+ export declare const MAX_INDEX_BYTES: number;
22
23
  /** How deep note groups may nest (see `note-groups.ts`). */
23
24
  export declare const MAX_NOTE_GROUPS = 8;
24
25
  /** Id grammar of pages and notes. */
package/src/canvas.js CHANGED
@@ -15,10 +15,11 @@ export const MAX_BOARD_SIZE = 8000;
15
15
  /** Gap between frames in a row, and between rows. */
16
16
  export const ROW_GAP = 80;
17
17
  export const COLUMN_GAP = 120;
18
- /** Most pages, notes, guides per board. */
18
+ /** Most pages, and guides per board. */
19
19
  export const MAX_PAGES = 40;
20
- export const MAX_NOTES = 999;
21
20
  export const MAX_GUIDES = 6;
21
+ /** Largest index an agent should write, in UTF-8 bytes. Notes have no count limit; this bounds them. */
22
+ export const MAX_INDEX_BYTES = 1024 * 1024;
22
23
  /** How deep note groups may nest (see `note-groups.ts`). */
23
24
  export const MAX_NOTE_GROUPS = 8;
24
25
  /** Id grammar of pages and notes. */
@@ -95,7 +96,7 @@ export function normalizeCanvas(input) {
95
96
  const notes = {};
96
97
  if (isRecord(raw.notes)) {
97
98
  for (const [id, note] of Object.entries(raw.notes)) {
98
- if (!isRecord(note) || Object.keys(notes).length >= MAX_NOTES)
99
+ if (!isRecord(note))
99
100
  continue;
100
101
  const { groups: rawGroups, ...rest } = note;
101
102
  const groups = normalizeNoteGroups(rawGroups);
package/src/check.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * files, then every artboard file. Paths are relative to `project/`.
4
4
  */
5
5
  import { checkDcFile, isBoardPath } from '@open-artifact/dc';
6
- import { CANVAS_VERSION, DS_FOLDER_PATTERN, ID_PATTERN, MAX_BOARD_SIZE, MAX_GUIDES, MAX_NOTES, MAX_NOTE_GROUPS, MAX_PAGES, MIN_BOARD_SIZE, intersects, noteFontSize, pageOf, } from "./canvas.js";
6
+ import { CANVAS_VERSION, DS_FOLDER_PATTERN, ID_PATTERN, MAX_BOARD_SIZE, MAX_GUIDES, MAX_INDEX_BYTES, MAX_NOTE_GROUPS, MAX_PAGES, MIN_BOARD_SIZE, intersects, noteFontSize, pageOf, } from "./canvas.js";
7
7
  /** Most files a design holds (under `project/`). */
8
8
  export const MAX_PROJECT_FILES = 512;
9
9
  /** Most bytes a design holds: its files and uploads together. */
@@ -20,6 +20,9 @@ export function checkDesignProject(files, options = {}) {
20
20
  add('canvas.json', 'error', 'project/canvas.json is missing.');
21
21
  return out;
22
22
  }
23
+ const indexBytes = new TextEncoder().encode(canvasText).length;
24
+ if (indexBytes >= MAX_INDEX_BYTES)
25
+ add('canvas.json', 'error', `canvas.json is ${indexBytes} bytes; keep the index under 1 MiB.`);
23
26
  let raw;
24
27
  try {
25
28
  raw = JSON.parse(canvasText);
@@ -126,8 +129,6 @@ export function checkDesignProject(files, options = {}) {
126
129
  }
127
130
  // Notes.
128
131
  const noteIds = Object.keys(notes);
129
- if (noteIds.length > MAX_NOTES)
130
- add('canvas.json', 'error', `At most ${MAX_NOTES} notes.`);
131
132
  for (const id of noteIds) {
132
133
  const note = notes[id];
133
134
  if (!ID_PATTERN.test(id))