@pairdraw/pen 0.21.0 → 0.22.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/index.d.ts CHANGED
@@ -618,14 +618,62 @@ declare function parsePenFile(json: string, options?: PenReadOptions): SceneGrap
618
618
  declare function readPenFile(file: File, options?: PenReadOptions): Promise<SceneGraph>;
619
619
  //#endregion
620
620
  //#region src/write.d.ts
621
+ /**
622
+ * What a written `.pen` file could not hold, as facts rather than a sentence: the app shows these
623
+ * in the reader's language, while the CLI and MCP print `penWriteWarningText` of each.
624
+ */
625
+ type PenWriteWarning = {
626
+ kind: 'merged-pages';
627
+ pages: number;
628
+ name: string;
629
+ } | {
630
+ kind: 'display-p3-colors';
631
+ } | {
632
+ kind: 'library-definitions';
633
+ count: number;
634
+ } | {
635
+ kind: 'missing-image-fills';
636
+ count: number;
637
+ } | {
638
+ kind: 'flattened-image-tiles';
639
+ count: number;
640
+ } | {
641
+ kind: 'dropped-constraints';
642
+ count: number;
643
+ } | {
644
+ kind: 'dropped-effects';
645
+ count: number;
646
+ } | {
647
+ kind: 'dropped-filters';
648
+ count: number;
649
+ } | {
650
+ kind: 'dropped-scroll';
651
+ count: number;
652
+ } | {
653
+ kind: 'dropped-font-features';
654
+ count: number;
655
+ } | {
656
+ kind: 'dropped-layout-grids';
657
+ count: number;
658
+ } | {
659
+ kind: 'dropped-overrides';
660
+ count: number;
661
+ } | {
662
+ kind: 'flattened-swaps';
663
+ count: number;
664
+ };
665
+ /** The English sentence a write warning has always been reported as. */
666
+ declare function penWriteWarningText(warning: PenWriteWarning): string;
621
667
  /** What a caller learns about content a written `.pen` file cannot hold. */
622
668
  interface PenWriteOptions {
623
669
  /** Collects one sentence per kind of content left out, in place of silently losing it. */
624
670
  warnings?: string[];
671
+ /** Collects the same facts as kinds, for a host that shows them in its own language. */
672
+ warningDetails?: PenWriteWarning[];
625
673
  }
626
674
  declare function penDocumentFromGraph(graph: SceneGraph, options?: PenWriteOptions): PenDocument;
627
675
  declare function stringifyPenDocument(document: PenDocument): string;
628
676
  declare function writePenDocument(source: PenDocument | SceneGraph, options?: PenWriteOptions): string;
629
677
  //#endregion
630
- export { PEN_PLUGIN_DATA_NAMESPACE, type PenAssets, type PenDocument, type PenFont, type PenIconRequest, type PenIconSource, type PenImport, type PenImports, type PenNode, type PenOverride, type PenReadOptions, type PenWriteOptions, buildPenGraph, iconName, iconOptions, importedDocument, isDataURL, isDocumentAssetPath, parseImportedImageURL, parsePenDocument, parsePenFile, penAssets, penDocumentFromGraph, readPenFile, stringifyPenDocument, withUsedImports, writePenDocument };
678
+ export { PEN_PLUGIN_DATA_NAMESPACE, type PenAssets, type PenDocument, type PenFont, type PenIconRequest, type PenIconSource, type PenImport, type PenImports, type PenNode, type PenOverride, type PenReadOptions, type PenWriteOptions, type PenWriteWarning, buildPenGraph, iconName, iconOptions, importedDocument, isDataURL, isDocumentAssetPath, parseImportedImageURL, parsePenDocument, parsePenFile, penAssets, penDocumentFromGraph, penWriteWarningText, readPenFile, stringifyPenDocument, withUsedImports, writePenDocument };
631
679
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/schema.ts","../src/assets.ts","../src/imports.ts","../src/nodes.ts","../src/library.ts","../src/plugin-data.ts","../src/read.ts","../src/write.ts"],"mappings":";;;;;;cA6KM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A4sBc,qBACd,OAAO,YACP,UAAS,kBACR;iBA6Ha,qBAAqB,UAAU;iBAI/B,iBACd,QAAQ,cAAc,YACtB,UAAS"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/schema.ts","../src/assets.ts","../src/imports.ts","../src/nodes.ts","../src/library.ts","../src/plugin-data.ts","../src/read.ts","../src/write.ts"],"mappings":";;;;;;cA6KM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4FM,aAAa,EAAE,YAAY,EAAE,oBAAoB;;UAG5C,oBAAoB;EACnC;EACA;EACA,WAAW;EACX,cAAc,eAAe;GAC5B;;UAGc,gBAAgB;EAC/B;EACA;;;cA8CI,YAAU,EAAA;;;;cAwDV,mBAAiB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2CX,cAAc,EAAE,mBAAmB;KACnC,UAAU,EAAE,mBAAmB;;;;iBC7Y3B,SAAS,iBAAiB;;iBAM1B,YACd,iBACA,6BACC;;UAKc;EACf;EACA,UAAU;;;;;;iBAOI,oBAAoB;;iBAMpB,UAAU;;;;;iBAWV,sBAAsB;EAAgB;EAAe;;;UASpD;;EAEf,OAAO;;;;;EAKP;;;;;EAKA;;;;;;iBAsHc,UAAU,KAAK,cAAc;;;;UCrM5B;;EAEf;;EAEA,KAAK;;;KAIK,aAAa,oBAAoB;;;;;;;iBAqH7B,iBACd,eACA,cACA,KAAK,aACL,SAAS,aACR;;;;UCtGc;;;;;;EAMf,KACE,OAAO,YACP,iBACA,cACA,cACA,OAAO,OACP,UAAU;;;;;;;;;iBC8BE,gBAAgB,KAAK,aAAa,SAAS,aAAa;;;;;;;;cCpE3D;;;;UCUI;;;;;EAKf,QAAQ,OAAO;;EAEf,SAAS,oBAAoB;;;;;EAK7B,UAAU;;EAEV,QAAQ;;;;;;EAMR,QAAQ,oBAAoB;;;;;;;EAO5B,UAAU;;EAEV,mBAAmB;;EAEnB,mBAAmB;;;iBAgDL,iBAAiB,eAAe;;iBAShC,cAAc,KAAK,aAAa,UAAS,iBAAsB;iBA8D/D,aAAa,cAAc,UAAS,iBAAsB;iBAIpD,YAAY,MAAM,MAAM,UAAU,iBAAiB,QAAQ;;;;;;;KCxErE;EACN;EAAsB;EAAe;;EACrC;;EACA;EAA6B;;EAC7B;EAA6B;;EAC7B;EAA+B;;EAC/B;EAA6B;;EAC7B;EAAyB;;EACzB;EAAyB;;EACzB;EAAwB;;EACxB;EAA+B;;EAC/B;EAA8B;;EAC9B;EAA2B;;EAC3B;EAAyB;;;iBAGf,oBAAoB,SAAS;;UA0C5B;;EAEf;;EAEA,iBAAiB;;iBAq2BH,qBACd,OAAO,YACP,UAAS,kBACR;iBA2Ha,qBAAqB,UAAU;iBAI/B,iBACd,QAAQ,cAAc,YACtB,UAAS"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PEN_PLUGIN_DATA_NAMESPACE } from "./chunks/annotations.js";
2
2
  import { iconName, iconOptions, isDataURL, isDocumentAssetPath, parseImportedImageURL, penAssets } from "./chunks/assets.js";
3
3
  import { importedDocument } from "./chunks/imports.js";
4
- import { buildPenGraph, parsePenDocument, parsePenFile, penDocumentFromGraph, readPenFile, stringifyPenDocument, withUsedImports, writePenDocument } from "./chunks/index.js";
5
- export { PEN_PLUGIN_DATA_NAMESPACE, buildPenGraph, iconName, iconOptions, importedDocument, isDataURL, isDocumentAssetPath, parseImportedImageURL, parsePenDocument, parsePenFile, penAssets, penDocumentFromGraph, readPenFile, stringifyPenDocument, withUsedImports, writePenDocument };
4
+ import { buildPenGraph, parsePenDocument, parsePenFile, penDocumentFromGraph, penWriteWarningText, readPenFile, stringifyPenDocument, withUsedImports, writePenDocument } from "./chunks/index.js";
5
+ export { PEN_PLUGIN_DATA_NAMESPACE, buildPenGraph, iconName, iconOptions, importedDocument, isDataURL, isDocumentAssetPath, parseImportedImageURL, parsePenDocument, parsePenFile, penAssets, penDocumentFromGraph, penWriteWarningText, readPenFile, stringifyPenDocument, withUsedImports, writePenDocument };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pairdraw/pen",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -15,7 +15,7 @@
15
15
  "valibot": "^1.5.0"
16
16
  },
17
17
  "peerDependencies": {
18
- "@pairdraw/scene-graph": "^0.21.0"
18
+ "@pairdraw/scene-graph": "^0.22.0"
19
19
  },
20
20
  "exports": {
21
21
  ".": {
package/src/index.ts CHANGED
@@ -22,7 +22,9 @@ export {
22
22
  export type { PenDocument, PenFont, PenNode, PenOverride } from './schema'
23
23
  export {
24
24
  penDocumentFromGraph,
25
+ penWriteWarningText,
25
26
  stringifyPenDocument,
26
27
  writePenDocument,
27
- type PenWriteOptions
28
+ type PenWriteOptions,
29
+ type PenWriteWarning
28
30
  } from './write'
package/src/nodes.ts CHANGED
@@ -213,10 +213,10 @@ const PROPERTY_FIELDS = {
213
213
  rotation: PLACEMENT_FIELDS,
214
214
  fill: ['fills'],
215
215
  stroke: STROKE_WRITES,
216
- strokeWidth: STROKE_WRITES,
216
+ strokeWidth: [...STROKE_WRITES, 'strokeWeight'],
217
217
  strokeLinecap: ['strokes', 'strokeCap'],
218
218
  strokeLinejoin: ['strokes', 'strokeJoin'],
219
- strokeAlignment: ['strokes'],
219
+ strokeAlignment: ['strokes', 'strokeAlign'],
220
220
  effect: ['effects'],
221
221
  cornerRadius: CORNER_FIELDS,
222
222
  layout: ['layoutMode'],
@@ -265,6 +265,9 @@ const PROPERTY_FIELDS = {
265
265
  scrollY: ['pluginData']
266
266
  } satisfies Record<keyof NodeFields, readonly (keyof SceneNode)[]>
267
267
 
268
+ /** Every pen field an override can name, and the scene fields it writes (see PROPERTY_FIELDS). */
269
+ export const PEN_PROPERTY_FIELDS = Object.keys(PROPERTY_FIELDS) as (keyof typeof PROPERTY_FIELDS)[]
270
+
268
271
  const isProperty = (key: string): key is keyof typeof PROPERTY_FIELDS => key in PROPERTY_FIELDS
269
272
 
270
273
  /**