@weasel-js/diagram-formats 1.11.1 → 1.13.0-rc.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
@@ -179,7 +179,7 @@ type PageExportScene = Scene<unknown, string, RectPose>;
179
179
  * that derives its path (a connector) is drawn along that path, and anything
180
180
  * else is written by `svgLeafFromKit`.
181
181
  */
182
- declare function pageSvgNodes(scene: PageExportScene, page: PageRect): SvgNode[];
182
+ declare function pageSvgNodes(live: PageExportScene, page: PageRect): SvgNode[];
183
183
 
184
184
  /** Options for {@link exportPageSvg}. */
185
185
  interface ExportPageSvgOptions extends Pick<SerializeOptions, 'title' | 'onWarn' | 'pretty'> {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { diagramThemeFrom, DIAGRAM_THEME_KEY, diagramLabelOf, offPageSplits, diagramScene, themeDocValue, diagramShape, markShape, documentBoundsOf, dataNodeStyle, dataEdgeStyle, diagramEdgeOf, diagramContainerOf, NODE_STROKE_WIDTH, dataRegionStyle, poolAxisOf, titleIdOf, layoutOwnsRoute, EDGE_STROKE_WIDTH, diagramThemeOf, edgeIdOf, layoutOwnsPort, DEFAULT_PORTS, LANE_STROKE_WIDTH } from '@weasel-js/diagram';
2
- import { placedPagesOf, layoutPages, PAGES_DOC_KEY, isAnnotationLayer, boundsOfPath, layoutTextPose, warmRender, renderSceneToPixels, planPixelRender, viewToMat3, createRasterSession, pageHolding, effectivePose, derivedDepOf, pageName, derivedPartsOf, createScene, mat3 } from '@weasel-js/core';
2
+ import { placedPagesOf, layoutPages, PAGES_DOC_KEY, documentOf, isAnnotationLayer, boundsOfPath, layoutTextPose, warmRender, renderSceneToPixels, planPixelRender, viewToMat3, createRasterSession, pageHolding, effectivePose, derivedDepOf, pageName, derivedPartsOf, INHERIT, resolvePartPaint, createScene, mat3 } from '@weasel-js/core';
3
3
  import { svgNodesFromKit, svgLeafFromKit, warmSvg, serializeSvg, escapeAttr, svgPaintFromKit, svgStrokeFromKit } from '@weasel-js/svg';
4
4
  import { writePdf, registryFontSource } from '@weasel-js/pdf';
5
5
 
@@ -2978,15 +2978,15 @@ function diagramPainted(painters, node, pose) {
2978
2978
  return painter.paint(node, pose).flatMap((cmd) => commandNode(cmd, at) ?? []);
2979
2979
  }
2980
2980
  function derivedNodes(path, data) {
2981
- const parts = derivedPartsOf(path) ?? [{ path }];
2982
- return parts.flatMap((part) => svgLeafFromKit({
2983
- path: part.path,
2984
- ...part.fill !== void 0 ? { fill: part.fill } : data.fill !== void 0 ? { fill: data.fill } : {},
2985
- stroke: part.stroke !== void 0 ? part.stroke : data.stroke
2986
- }, boundsOfPath(part.path)) ?? []);
2981
+ const parts = derivedPartsOf(path) ?? [{ path, fill: INHERIT, stroke: INHERIT }];
2982
+ return parts.flatMap((part) => svgLeafFromKit(
2983
+ { path: part.path, ...resolvePartPaint(part, data) },
2984
+ boundsOfPath(part.path)
2985
+ ) ?? []);
2987
2986
  }
2988
2987
  var one = (nodes) => nodes.length === 0 ? null : nodes.length === 1 ? nodes[0] : { kind: "group", children: nodes };
2989
- function pageSvgNodes(scene, page) {
2988
+ function pageSvgNodes(live, page) {
2989
+ const scene = documentOf(live);
2990
2990
  const painters = [diagramShape(), markShape()];
2991
2991
  const shown = new Set(scene.layers.filter((l) => l.visible && !isAnnotationLayer(l)).map((l) => l.id));
2992
2992
  const poseCache = /* @__PURE__ */ new Map();
@@ -2995,7 +2995,7 @@ function pageSvgNodes(scene, page) {
2995
2995
  if (p === void 0) poseCache.set(node.id, p = effectivePose(scene, node));
2996
2996
  return p;
2997
2997
  };
2998
- const pathOf = (node) => node.kind === "leaf" ? derivedDepOf(scene, node.id)?.path ?? null : null;
2998
+ const pathOf = (node) => node.kind === "mark" ? derivedDepOf(scene, node.id)?.path ?? null : null;
2999
2999
  const tree = {
3000
3000
  roots: scene.layers.flatMap((l) => scene.roots.filter((id) => scene.get(id)?.layer === l.id)),
3001
3001
  childrenOf: (id) => scene.childrenOf(id),
@@ -3007,7 +3007,8 @@ function pageSvgNodes(scene, page) {
3007
3007
  data: node.data,
3008
3008
  pose: poseOf(pose(node)),
3009
3009
  ...node.hidden ? { hidden: true } : {},
3010
- ...node.kind === "container" && node.copiesFromPose ? { copiesFromPose: node.copiesFromPose } : {}
3010
+ ...node.clip ? { clip: node.clip } : {},
3011
+ ...node.copiesFromPose ? { copiesFromPose: node.copiesFromPose } : {}
3011
3012
  };
3012
3013
  }
3013
3014
  };
@@ -3024,11 +3025,6 @@ function pageSvgNodes(scene, page) {
3024
3025
  if (path) return one(derivedNodes(path, kit.data));
3025
3026
  const painted = diagramPainted(painters, node, pose(node));
3026
3027
  return painted ? one(painted) : svgLeafFromKit(kit.data, kit.pose);
3027
- },
3028
- group(id, g) {
3029
- const node = scene.get(id);
3030
- const outline = diagramPainted(painters, node, pose(node));
3031
- return outline ? { ...g, children: [...outline, ...g.children] } : g;
3032
3028
  }
3033
3029
  });
3034
3030
  }
@@ -3089,7 +3085,8 @@ function pageRasterizer(session) {
3089
3085
  scene: empty,
3090
3086
  sourceRect: { x: -toRaster[6] / sx, y: -toRaster[7] / sy, width: rect.width * scale / sx, height: rect.height * scale / sy },
3091
3087
  scale: { x: sx, y: sy },
3092
- overlay: [{ kind: "group", transform: toPixels, children: [...commands] }]
3088
+ overlay: [{ kind: "group", transform: toPixels, children: [...commands] }],
3089
+ screen: toPixels
3093
3090
  });
3094
3091
  };
3095
3092
  }