dsh-artifact-studio 0.9.0 → 0.13.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/dist/contract.js CHANGED
@@ -9,12 +9,12 @@ export function isArtifactType(value) {
9
9
  return ARTIFACT_TYPES.some((type) => type === value);
10
10
  }
11
11
  export const SCOPES = ['workspace', 'library'];
12
- export const EXPORT_FORMATS = ['html', 'md', 'docx', 'png', 'svg', 'fig', 'csv', 'xlsx'];
12
+ export const EXPORT_FORMATS = ['html', 'md', 'docx', 'png', 'svg', 'fig', 'html-svg', 'csv', 'xlsx'];
13
13
  /** Which exporters each type supports. */
14
14
  export const FORMATS_BY_TYPE = {
15
15
  page: ['html'],
16
16
  doc: ['md', 'docx', 'html'],
17
- design: ['png', 'svg', 'fig'],
17
+ design: ['png', 'svg', 'fig', 'html', 'html-svg'],
18
18
  sheet: ['csv', 'xlsx'],
19
19
  };
20
20
  /** Content file name inside `content/`, by type. */
@@ -18,6 +18,18 @@ export const ASSET_FILES = new Map([
18
18
  ['fonts/Roboto-Medium.woff2', 'font/woff2'],
19
19
  ['fonts/Roboto-Bold.woff2', 'font/woff2'],
20
20
  ]);
21
+ /** The bundled faces, with the family and style the font manager knows them by. */
22
+ export const BUNDLED_FACES = [
23
+ { file: 'fonts/Inter-Regular.ttf', family: 'Inter', style: 'Regular' },
24
+ { file: 'fonts/Inter-Medium.ttf', family: 'Inter', style: 'Medium' },
25
+ { file: 'fonts/Inter-SemiBold.ttf', family: 'Inter', style: 'SemiBold' },
26
+ { file: 'fonts/Inter-Bold.ttf', family: 'Inter', style: 'Bold' },
27
+ { file: 'fonts/Inter-ExtraBold.ttf', family: 'Inter', style: 'ExtraBold' },
28
+ { file: 'fonts/NotoNaskhArabic-Regular.ttf', family: 'Noto Naskh Arabic', style: 'Regular' },
29
+ { file: 'fonts/Roboto-Regular.woff2', family: 'Roboto', style: 'Regular' },
30
+ { file: 'fonts/Roboto-Medium.woff2', family: 'Roboto', style: 'Medium' },
31
+ { file: 'fonts/Roboto-Bold.woff2', family: 'Roboto', style: 'Bold' },
32
+ ];
21
33
  /** Where the build copies the engine files, beside the compiled host. */
22
34
  const ASSET_ROOT = fileURLToPath(new URL('../../../assets/', import.meta.url));
23
35
  /**
@@ -122,6 +122,6 @@ export function composeSheetBrief(layers) {
122
122
  parts.push('', '## Project conventions', '', layers.workspace.instructions);
123
123
  if (layers.library.instructions !== '')
124
124
  parts.push('', '## User preferences', '', layers.library.instructions);
125
- parts.push('', '## The workbook', '', 'A sheet artifact holds one JSON workbook. Create it with artifact_create and type "sheet"; the content is this object:', '', '```json', '{', ' "schemaVersion": 1,', ' "sheets": [', ' {', ' "name": "Budget",', ' "cells": {', ' "A1": "Item",', ' "B1": "Cost",', ' "B2": 1200,', ' "B3": 800,', ' "B4": "=SUM(B2:B3)"', ' },', ' "columnWidths": { "A": 160 }', ' }', ' ]', '}', '```', '', 'Rules:', '- 1 to 20 sheets with unique names, 1 to 31 characters, no backslash, slash, question mark, asterisk, square bracket, or colon.', '- 1 to 20,000 cells and 5,000 formulas per artifact; column references stop at CV.', '- A cell key is an A1 reference such as B4. A plain JSON string, number, or boolean is that value.', '- A string that starts with "=" is a formula. Use { "value": "=literal" } for text that starts with "=".', '- A styled cell is an object: { "value": 1200, "style": { "bold": true, "align": "right", "background": "#fff2cc", "numberFormat": "currency" } }.', '- numberFormat is general, number, integer, currency, percent, or date. Dates are Excel serial day numbers, which TODAY() returns.', '- columnWidths maps a column letter to a width from 24 to 800 pixels.', '', '## Editing a sheet', '', 'Read it first with artifact_read when the user may have edited it, then call artifact_sheet_update with the current baseVersion. Send one operations array; set, write, clear, format, add-sheet, rename-sheet, delete-sheet, and set-column-width operations can follow one another in the same call.', '- set: { "op": "set", "sheet": "Budget", "ref": "B4", "value": 2000 } or "formula": "=SUM(B2:B3)". A null value clears the cell.', '- write: { "op": "write", "ref": "A1", "values": [["Item","Cost"],["Hosting",1200]] }; a string starting with "=" is a formula in that block.', '- clear: { "op": "clear", "range": "A2:C4" }; format: { "op": "format", "range": "A1:C1", "style": { "bold": true } }.', '- add-sheet, rename-sheet, delete-sheet, and set-column-width change the structure. Do not set both value and formula in one cell.', '', '## Formulas', '', 'Formulas are Excel syntax: =B2*1.2, =SUM(B2:B3), =IF(B2>1000,"big","small"), =Sheet2!A1*2, =COUNTIF(B2:B3,">1000"), =VLOOKUP(A2,A2:C9,3,FALSE). The bundled parser implements the common Excel function set, with a small gap layer for functions such as MAX, MIN, MATCH, SUMIFS, and TEXTJOIN; an unknown function shows #NAME? and the write returns a warning. A circular reference shows #CYCLE!. An errored cell shows #DIV/0!, #VALUE!, #REF!, #N/A, or #NUM!.', '', '## Save and export', '', 'Every write is a version the user sees. Check the workbook before saving: sheet names, header labels, units, and a formula for each total. Fix all returned warnings in one update.', 'A sheet exports as CSV (first sheet only) or XLSX (every sheet, with styles, formulas, and cached results). Print or save it as PDF from the panel.');
125
+ parts.push('', '## The workbook', '', 'A sheet artifact holds one JSON workbook. Create it with artifact_create and type "sheet"; the content is this object:', '', '```json', '{', ' "schemaVersion": 1,', ' "sheets": [', ' {', ' "name": "Budget",', ' "cells": {', ' "A1": "Item",', ' "B1": "Cost",', ' "B2": 1200,', ' "B3": 800,', ' "B4": "=SUM(B2:B3)"', ' },', ' "columnWidths": { "A": 160 }', ' }', ' ]', '}', '```', '', 'Rules:', '- 1 to 20 sheets with unique names, 1 to 31 characters, no backslash, slash, question mark, asterisk, square bracket, or colon.', '- 1 to 20,000 cells and 5,000 formulas per artifact; column references stop at CV.', '- A cell key is an A1 reference such as B4. A plain JSON string, number, or boolean is that value.', '- A string that starts with "=" is a formula. Use { "value": "=literal" } for text that starts with "=".', '- A styled cell is an object: { "value": 1200, "style": { "bold": true, "align": "right", "background": "#fff2cc", "color": "#1f2933", "numberFormat": "currency" } }. When you set background, set color too: #1f2933 for light fills and #ffffff for dark fills. The panel and exports choose a readable default if color is omitted, and a low-contrast pair returns a warning.', '- numberFormat is general, number, integer, currency, percent, or date. Dates are Excel serial day numbers, which TODAY() returns.', '- columnWidths maps a column letter to a width from 24 to 800 pixels.', '', '## Editing a sheet', '', 'Read it first with artifact_read when the user may have edited it, then call artifact_sheet_update with the current baseVersion. Send one operations array; set, write, clear, format, add-sheet, rename-sheet, delete-sheet, and set-column-width operations can follow one another in the same call.', '- set: { "op": "set", "sheet": "Budget", "ref": "B4", "value": 2000 } or "formula": "=SUM(B2:B3)". A null value clears the cell.', '- write: { "op": "write", "ref": "A1", "values": [["Item","Cost"],["Hosting",1200]] }; a string starting with "=" is a formula in that block.', '- clear: { "op": "clear", "range": "A2:C4" }; format: { "op": "format", "range": "A1:C1", "style": { "bold": true } }.', '- add-sheet, rename-sheet, delete-sheet, and set-column-width change the structure. Do not set both value and formula in one cell.', '', '## Formulas', '', 'Formulas are Excel syntax: =B2*1.2, =SUM(B2:B3), =IF(B2>1000,"big","small"), =Sheet2!A1*2, =COUNTIF(B2:B3,">1000"), =VLOOKUP(A2,A2:C9,3,FALSE). The bundled parser implements the common Excel function set, with a small gap layer for functions such as MAX, MIN, MATCH, SUMIFS, and TEXTJOIN; an unknown function shows #NAME? and the write returns a warning. A circular reference shows #CYCLE!. An errored cell shows #DIV/0!, #VALUE!, #REF!, #N/A, or #NUM!.', '', '## Save and export', '', 'Every write is a version the user sees. Check the workbook before saving: sheet names, header labels, units, and a formula for each total. Fix all returned warnings in one update.', 'A sheet exports as CSV (first sheet only) or XLSX (every sheet, with styles, formulas, and cached results). Print or save it as PDF from the panel.');
126
126
  return parts.join('\n');
127
127
  }
@@ -4,6 +4,7 @@ import { createRequire } from 'node:module';
4
4
  import path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { ArtifactError } from './errors.js';
7
+ import { isSvgPageModel } from './svg-model.js';
7
8
  /** How long one render may take before the child is killed. */
8
9
  const TIMEOUT_MS = 20_000;
9
10
  /** Stdout above this size means something is wrong with the child. */
@@ -148,6 +149,42 @@ export class DesignRenderer {
148
149
  }
149
150
  return { bytes: Buffer.from(response.data, 'base64'), mediaType: response.mediaType };
150
151
  }
152
+ /**
153
+ * Convert a .fig file the host already read into stored Design JSX. The child
154
+ * never touches the filesystem, so the host passes the bytes.
155
+ * @param bytes the .fig file bytes.
156
+ * @returns the source and its summary.
157
+ */
158
+ async importFig(bytes) {
159
+ const response = await this.request('', { action: 'import-fig', bytes: bytes.toString('base64') });
160
+ if (typeof response.source !== 'string') {
161
+ throw new ArtifactError('artifact/design-render-failed', 'The design renderer returned no source.');
162
+ }
163
+ return { source: response.source, info: response.info };
164
+ }
165
+ /**
166
+ * Compile a design into the page model the SVG viewer needs: the shapes SVG and one
167
+ * record per text node, after the layout the panel shows.
168
+ * @param source the Design JSX source.
169
+ * @returns the page model.
170
+ */
171
+ async pageModel(source) {
172
+ const response = await this.request(source, { action: 'export', format: 'html-svg' });
173
+ if (typeof response.data !== 'string') {
174
+ throw new ArtifactError('artifact/design-render-failed', 'The design renderer returned no page model.');
175
+ }
176
+ let parsed;
177
+ try {
178
+ parsed = JSON.parse(Buffer.from(response.data, 'base64').toString('utf8'));
179
+ }
180
+ catch {
181
+ throw new ArtifactError('artifact/design-render-failed', 'The design renderer returned an unreadable page model.');
182
+ }
183
+ if (!isSvgPageModel(parsed)) {
184
+ throw new ArtifactError('artifact/design-render-failed', 'The design renderer returned an unexpected page model.');
185
+ }
186
+ return parsed;
187
+ }
151
188
  /**
152
189
  * Run a task with at most two children alive.
153
190
  * @param task the work.
@@ -4,9 +4,11 @@ import { AlignmentType, BorderStyle, Document, ExternalHyperlink, HeadingLevel,
4
4
  import { marked } from 'marked';
5
5
  import { FORMATS_BY_TYPE } from '../../contract.js';
6
6
  import { DOC_CSP, DOC_STYLE, PAGE_CSP, PRINT_CSP, composePage, escapeHtml } from '../../render.js';
7
- import { evaluateWorkbook, parseSheetWorkbook, sheetTable, sheetToCsv } from '../../sheet/index.js';
7
+ import { effectiveTextColor, evaluateWorkbook, parseSheetWorkbook, sheetTable, sheetToCsv } from '../../sheet/index.js';
8
8
  import { workbookToXlsx } from './xlsx.js';
9
9
  import { ArtifactError } from './errors.js';
10
+ import { buildSvgViewerHtml } from './svg-viewer.js';
11
+ import { buildViewerHtml } from './viewer.js';
10
12
  import { assertWithin, withLock } from './fsutil.js';
11
13
  const MEDIA_TYPES = {
12
14
  html: 'text/html',
@@ -14,10 +16,13 @@ const MEDIA_TYPES = {
14
16
  docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
15
17
  png: 'image/png',
16
18
  svg: 'image/svg+xml',
19
+ 'html-svg': 'text/html',
17
20
  fig: 'application/octet-stream',
18
21
  csv: 'text/csv',
19
22
  xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
20
23
  };
24
+ /** The file extension of a format whose id is not its extension. */
25
+ const EXTENSIONS = { 'html-svg': 'html' };
21
26
  const MARKED_TYPES = new Set([
22
27
  'blockquote', 'br', 'checkbox', 'code', 'codespan', 'def', 'del', 'em', 'escape', 'heading', 'hr', 'html',
23
28
  'image', 'link', 'list', 'list_item', 'paragraph', 'space', 'strong', 'table', 'tag', 'text',
@@ -45,7 +50,7 @@ function exportFileName(manifest, format, now) {
45
50
  .replace(/^-+|-+$/g, '')
46
51
  .slice(0, 60) || 'artifact';
47
52
  const stamp = now.toISOString().replace(/[-:]/g, '').replace(/\..*$/, '').replace('T', '-');
48
- return `${slug}-v${manifest.version}-${stamp}.${format}`;
53
+ return `${slug}-v${manifest.version}-${stamp}.${EXTENSIONS[format] ?? format}`;
49
54
  }
50
55
  /**
51
56
  * Printable HTML for a Markdown document, styled from the design tokens.
@@ -310,8 +315,9 @@ function printCellStyle(cell) {
310
315
  rules.push('text-decoration:' + decoration);
311
316
  if (style.align !== undefined)
312
317
  rules.push('text-align:' + style.align);
313
- if (style.color !== undefined)
314
- rules.push('color:' + style.color);
318
+ const color = effectiveTextColor(style);
319
+ if (color !== undefined)
320
+ rules.push('color:' + color);
315
321
  if (style.background !== undefined)
316
322
  rules.push('background-color:' + style.background);
317
323
  }
@@ -389,14 +395,26 @@ export async function writeExport(root, manifest, content, format, design, now,
389
395
  if (designs === undefined) {
390
396
  throw new ArtifactError('artifact/design-unavailable', 'The design renderer is not available.', {});
391
397
  }
392
- if (format !== 'png' && format !== 'svg' && format !== 'fig') {
398
+ if (format === 'html') {
399
+ const scene = await designs.exportContent(content, 'fig');
400
+ data = await buildViewerHtml({ title: manifest.title, fig: scene.bytes });
401
+ mediaType = 'text/html';
402
+ }
403
+ else if (format === 'html-svg') {
404
+ const model = await designs.pageModel(content);
405
+ data = await buildSvgViewerHtml({ title: manifest.title, model });
406
+ mediaType = 'text/html';
407
+ }
408
+ else if (format === 'png' || format === 'svg' || format === 'fig') {
409
+ const rendered = await designs.exportContent(content, format);
410
+ data = rendered.bytes;
411
+ mediaType = rendered.mediaType;
412
+ }
413
+ else {
393
414
  throw new ArtifactError('artifact/unsupported-format', `A design cannot be exported as ${format}.`, {
394
415
  supported: FORMATS_BY_TYPE.design,
395
416
  });
396
417
  }
397
- const rendered = await designs.exportContent(content, format);
398
- data = rendered.bytes;
399
- mediaType = rendered.mediaType;
400
418
  }
401
419
  else if (manifest.type === 'sheet') {
402
420
  let workbook;
@@ -31,6 +31,8 @@ function canonicalSheet(content) {
31
31
  });
32
32
  }
33
33
  }
34
+ /** The largest .fig file an import reads, in bytes. */
35
+ const FIG_IMPORT_MAX_BYTES = 128 * 1024 * 1024;
34
36
  /**
35
37
  * One facade over the store, the scope roots, the design system, the design
36
38
  * renderer, and export. The route and the tools both call it, so both scopes
@@ -318,8 +320,9 @@ export class ArtifactService {
318
320
  const current = await this.store.manifest(root, id);
319
321
  const existing = await this.store.read(root, id);
320
322
  if (current.type === 'sheet') {
321
- if (input.recipe !== undefined)
323
+ if (input.recipe !== undefined) {
322
324
  throw new ArtifactError('artifact/bad-request', 'Sheets do not use recipes.', { type: current.type });
325
+ }
323
326
  if (input.content !== undefined && input.edits !== undefined) {
324
327
  throw new ArtifactError('artifact/bad-request', 'Send either content or edits, not both.');
325
328
  }
@@ -349,6 +352,30 @@ export class ArtifactService {
349
352
  await this.writeInfo(root, id, next, info);
350
353
  return manifest;
351
354
  }
355
+ /**
356
+ * Import a .fig file as a new design. The file's first page with elements
357
+ * becomes the stored mockup; later pages are named in warnings. The host
358
+ * reads the file, and the renderer child never touches the filesystem.
359
+ * @param target the caller's context.
360
+ * @param input the path, optional title, and write source.
361
+ * @returns the new manifest.
362
+ */
363
+ async importDesign(target, input) {
364
+ let bytes;
365
+ try {
366
+ bytes = await fs.readFile(input.path);
367
+ }
368
+ catch (error) {
369
+ throw new ArtifactError('artifact/bad-request', `The .fig file was not readable: ${error instanceof Error ? error.message : String(error)}`, { path: input.path });
370
+ }
371
+ if (bytes.byteLength > FIG_IMPORT_MAX_BYTES) {
372
+ throw new ArtifactError('artifact/bad-request', 'The .fig file is too large; imports accept up to 128 MB.', { path: input.path });
373
+ }
374
+ const imported = await this.designs.importFig(bytes);
375
+ const name = path.basename(input.path).replace(/\.(fig|pen)$/i, '');
376
+ const title = input.title ?? (name === '' ? 'Imported design' : name);
377
+ return this.create(target, { type: 'design', title, content: imported.source, source: input.source });
378
+ }
352
379
  /**
353
380
  * Restore an earlier version.
354
381
  * @param target the caller's context.
@@ -147,7 +147,7 @@ After creating a sheet, edit it with \`artifact_sheet_update\`, not by rewriting
147
147
 
148
148
  Formulas are Excel syntax and run through a bundled parser with a gap layer for common functions: \`=SUM(B2:B3)\`, \`=IF(B2>1000,"big","small")\`, \`=Sheet2!A1*2\`, \`=VLOOKUP(A2,A2:C9,3,FALSE)\`. An unknown function shows \`#NAME?\`, a broken reference shows \`#REF!\`, and a circular reference shows \`#CYCLE!\`. Dates are Excel serial days; set \`numberFormat\` to \`date\` to show them as a date. A top-level SUM, AVERAGE, MIN, MAX, PRODUCT, or MEDIAN reports a referenced error the way Excel does.
149
149
 
150
- Formatting is per cell: bold, italic, underline, strike, left/center/right alignment, text and fill hex colors, and a number format of general, number, integer, currency, percent, or date. Keep a header row bold with a quiet fill; do not color-code without a legend.
150
+ Formatting is per cell: bold, italic, underline, strike, left/center/right alignment, text and fill hex colors, and a number format of general, number, integer, currency, percent, or date. Keep a header row bold with a quiet fill. When you set a fill, also set a text color that contrasts with it: use #1f2933 on light fills and #ffffff on dark fills. The panel and exports choose a readable default when color is omitted, and a low-contrast pair returns a warning. Do not color-code without a legend.
151
151
 
152
152
  A sheet exports as CSV (first sheet only) or XLSX (every sheet, with styles, formulas, and cached results). The user can also print it or save it as PDF from the panel. Before saving, check sheet names, header labels, units, and that every total has a formula.
153
153
 
@@ -184,7 +184,7 @@ Tell the user in one or two sentences what you made or changed. Do not repeat th
184
184
  /** The artifact design skill, registered by the \`dsh-artifact-studio/skill\` host plugin. */
185
185
  export const ARTIFACT_DESIGN_SKILL = {
186
186
  name: 'artifact-design',
187
- description: 'Author artifact pages, documents, spreadsheets, and OpenPencil mockups: pick a recipe for the intent, follow the artifact brief, build pages from the versioned kit, edit sheet cells with artifact_sheet_update, save lasting conventions, and save each version once.',
187
+ description: 'Author artifact pages, documents, spreadsheets, and mockups: pick a recipe, follow the brief, build from the kit, edit cells, save conventions, and save each version once.',
188
188
  whenToUse: 'Load before artifact_create, when the user asks for an artifact, before an artifact_update that changes layout or styling, and when the user asks to remember an artifact convention.',
189
189
  source: 'bundled',
190
190
  content: CONTENT,
@@ -0,0 +1,85 @@
1
+ /** The page model a design export hands the SVG viewer, and its validator. */
2
+ const ALIGNS = new Set(['LEFT', 'CENTER', 'RIGHT', 'JUSTIFIED']);
3
+ const VERTICAL_ALIGNS = new Set(['TOP', 'CENTER', 'BOTTOM']);
4
+ const TEXT_CASES = new Set(['ORIGINAL', 'UPPER', 'LOWER', 'TITLE']);
5
+ /**
6
+ * Tell a field map from an unknown value.
7
+ * @param value the value.
8
+ * @returns its fields, or null.
9
+ */
10
+ function fieldsOf(value) {
11
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
12
+ return null;
13
+ return { ...value };
14
+ }
15
+ /**
16
+ * Tell one run from an unknown value.
17
+ * @param value the value.
18
+ * @returns whether it is a run.
19
+ */
20
+ function isRun(value) {
21
+ const run = fieldsOf(value);
22
+ return (run !== null &&
23
+ typeof run['text'] === 'string' &&
24
+ typeof run['size'] === 'number' &&
25
+ typeof run['weight'] === 'number' &&
26
+ typeof run['italic'] === 'boolean' &&
27
+ typeof run['letterSpacing'] === 'number' &&
28
+ typeof run['color'] === 'string' &&
29
+ typeof run['alpha'] === 'number');
30
+ }
31
+ /**
32
+ * Tell one text box from an unknown value.
33
+ * @param value the value.
34
+ * @returns whether it is a text box.
35
+ */
36
+ function isTextBox(value) {
37
+ const box = fieldsOf(value);
38
+ if (box === null)
39
+ return false;
40
+ const numbers = ['width', 'height', 'size', 'weight', 'letterSpacing', 'alpha'];
41
+ if (!numbers.every((key) => typeof box[key] === 'number'))
42
+ return false;
43
+ const matrix = fieldsOf(box['matrix']);
44
+ if (matrix === null)
45
+ return false;
46
+ if (!['a', 'b', 'c', 'd', 'e', 'f'].every((key) => typeof matrix[key] === 'number'))
47
+ return false;
48
+ const strings = ['text', 'family', 'color'];
49
+ if (!strings.every((key) => typeof box[key] === 'string'))
50
+ return false;
51
+ if (typeof box['italic'] !== 'boolean')
52
+ return false;
53
+ if (box['lineHeight'] !== null && typeof box['lineHeight'] !== 'number')
54
+ return false;
55
+ if (typeof box['wrap'] !== 'boolean')
56
+ return false;
57
+ if (typeof box['textCase'] !== 'string' || !TEXT_CASES.has(box['textCase']))
58
+ return false;
59
+ if (typeof box['align'] !== 'string' || !ALIGNS.has(box['align']))
60
+ return false;
61
+ if (typeof box['verticalAlign'] !== 'string' || !VERTICAL_ALIGNS.has(box['verticalAlign']))
62
+ return false;
63
+ if (!Array.isArray(box['runs']) || !box['runs'].every(isRun))
64
+ return false;
65
+ return box['clip'] === null || fieldsOf(box['clip']) !== null;
66
+ }
67
+ /**
68
+ * Tell a page model from an unknown value read from the worker.
69
+ * @param value the parsed response.
70
+ * @returns whether it is a page model.
71
+ */
72
+ export function isSvgPageModel(value) {
73
+ const fields = fieldsOf(value);
74
+ if (fields === null)
75
+ return false;
76
+ if (typeof fields['width'] !== 'number' || typeof fields['height'] !== 'number')
77
+ return false;
78
+ if (typeof fields['svg'] !== 'string')
79
+ return false;
80
+ const texts = fields['texts'];
81
+ const families = fields['families'];
82
+ if (!Array.isArray(texts) || !texts.every(isTextBox))
83
+ return false;
84
+ return Array.isArray(families) && families.every((family) => typeof family === 'string');
85
+ }