@weasel-js/svg 1.13.0-rc.0 → 1.14.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 +30 -5
- package/dist/index.js +818 -362
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Affine } from '@weasel-js/geom';
|
|
2
2
|
export { pathToD as serializePathD } from '@weasel-js/geom';
|
|
3
|
-
import { Path, Paint, ScreenLength, StrokeAlign, MarkerRef, VertexWidth, StrokeNib, StyledRun, TextStyle, TextVerticalAlign, Fill, Stroke, PoseLinear, MarkerEntry, TextPoseLayout, RenderNeeds, TilePatternSpec, IngestCtx, Inherit, ImageNodeData, NodeClip } from '@weasel-js/core';
|
|
3
|
+
import { Path, Paint, ScreenLength, StrokeAlign, MarkerRef, VertexWidth, StrokeNib, BooleanShapeOp, StyledRun, TextStyle, TextVerticalAlign, Fill, Stroke, PoseLinear, MarkerEntry, TextPoseLayout, RenderNeeds, TilePatternSpec, IngestCtx, Inherit, ImageNodeData, NodeClip } from '@weasel-js/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Media Queries 4 evaluation against a fixed environment.
|
|
@@ -194,6 +194,11 @@ interface SvgGroupNode {
|
|
|
194
194
|
* `display="none"` here, or a leaf under `visibility="hidden"`. Written
|
|
195
195
|
* back as `display="none"`. */
|
|
196
196
|
hidden?: boolean;
|
|
197
|
+
/** Set on the `<g>` of a boolean group's children, which follows the path
|
|
198
|
+
* the group draws: the operation that path is of them. Written as
|
|
199
|
+
* `data-weasel-boolean`; `parseSvg` keeps such a `<g>` hidden even without
|
|
200
|
+
* `keepHidden`. */
|
|
201
|
+
boolean?: BooleanShapeOp;
|
|
197
202
|
/** Opaque per-element bag for declared namespaces. See `NamespaceMeta`. */
|
|
198
203
|
meta?: NamespaceMeta;
|
|
199
204
|
}
|
|
@@ -498,8 +503,10 @@ declare function warmSvg(nodes: readonly SvgNode[], opts?: Pick<SerializeOptions
|
|
|
498
503
|
*
|
|
499
504
|
* The tile's shapes are written for any SVG consumer to render, and the spec
|
|
500
505
|
* itself goes on a `data-weasel-tile` attribute, which weasel reads back
|
|
501
|
-
* rather than reverse-engineering it from geometry.
|
|
502
|
-
*
|
|
506
|
+
* rather than reverse-engineering it from geometry. An `image` paint is a
|
|
507
|
+
* pattern holding one `<image>` that fills the tile, the form other editors
|
|
508
|
+
* write a bitmap pattern in too, and is read back from that structure. A
|
|
509
|
+
* `texture` paint has no vector form and exports as nothing, with a warning.
|
|
503
510
|
*/
|
|
504
511
|
|
|
505
512
|
/**
|
|
@@ -632,13 +639,24 @@ interface SvgKitTreeNode {
|
|
|
632
639
|
/** The node's copies, as the kit's `SceneNode.copiesFromPose` draws them:
|
|
633
640
|
* each is written as a transformed group of its children. */
|
|
634
641
|
copiesFromPose?(pose: SvgKitPose, node: never): readonly Matrix[] | null;
|
|
642
|
+
/** The kit's `SceneNode.consumesChildren`: a boolean group, written as the
|
|
643
|
+
* path it derives then a hidden `<g>` of its children (`SvgGroupNode.boolean`). */
|
|
644
|
+
consumesChildren?: boolean;
|
|
635
645
|
}
|
|
636
646
|
/** The read side of a scene that {@link svgNodesFromKit} walks. A kit
|
|
637
|
-
* `Scene` is one as it stands.
|
|
647
|
+
* `Scene` is one as it stands. With `composition`, a node's pose is stored in
|
|
648
|
+
* the frame of the nearest container above it that defines one, as a scene's
|
|
649
|
+
* is; without, every pose is world. */
|
|
638
650
|
interface SvgKitTree<TId extends string = string> {
|
|
639
651
|
readonly roots: readonly TId[];
|
|
640
652
|
childrenOf(id: TId): readonly TId[];
|
|
641
653
|
get(id: TId): SvgKitTreeNode | undefined;
|
|
654
|
+
readonly composition?: {
|
|
655
|
+
compose(parent: never, child: never): unknown;
|
|
656
|
+
};
|
|
657
|
+
/** The path a node derives, in the frame its children are stored in. A kit
|
|
658
|
+
* `Scene` needs none: its document is read for it. */
|
|
659
|
+
derivedPathOf?(id: TId): Path | null;
|
|
642
660
|
}
|
|
643
661
|
/** Options for {@link svgNodesFromKit}. */
|
|
644
662
|
interface SvgNodesFromKitOptions<TId extends string = string> {
|
|
@@ -697,7 +715,8 @@ type SvgDraftPose = SvgDraftBounds & {
|
|
|
697
715
|
* containers that mirror the source `<g>` structure — instead of the default
|
|
698
716
|
* single embedded-image node.
|
|
699
717
|
*
|
|
700
|
-
* Leaf data targets the kit's built-in painters. Poses are
|
|
718
|
+
* Leaf data targets the kit's built-in painters. Poses are world AABBs, which
|
|
719
|
+
* an inserter makes local to their containers' frames, and
|
|
701
720
|
* the renderer rebases stored geometry into the pose box, so placement and
|
|
702
721
|
* fit-clamping operate on poses alone and never rewrite path coordinates.
|
|
703
722
|
* Stroke widths, dashes, font sizes, and letter spacing live in data, so
|
|
@@ -732,6 +751,10 @@ type SvgSceneDraft<TData = Record<string, unknown>> = {
|
|
|
732
751
|
data: TData;
|
|
733
752
|
clip?: NodeClip;
|
|
734
753
|
hidden?: true;
|
|
754
|
+
/** A boolean group of the drafts under it, as `svgNodesFromKit` writes one: give it core's
|
|
755
|
+
* `booleanGroupFields()` and this as `data.boolean`. Its data's `path` is the result as the
|
|
756
|
+
* file drew it, which the derivation replaces. */
|
|
757
|
+
boolean?: BooleanShapeOp;
|
|
735
758
|
};
|
|
736
759
|
/** A leaf `SvgNode`: everything but a group. */
|
|
737
760
|
type SvgLeafNode = Exclude<SvgNode, SvgGroupNode>;
|
|
@@ -783,6 +806,8 @@ declare function strokeDataFromSvg(stroke: SvgStroke | undefined, box: SvgDraftB
|
|
|
783
806
|
*
|
|
784
807
|
* `nextId` is handed the node each id is for. `options.leaf` replaces a leaf's
|
|
785
808
|
* data; a group whose leaves it all leaves out is dropped like an empty one.
|
|
809
|
+
* A boolean group `svgNodesFromKit` wrote is drafted as a mark with `boolean`,
|
|
810
|
+
* its operands under it and shown.
|
|
786
811
|
*/
|
|
787
812
|
declare function svgNodesToKitDrafts<TData = Record<string, unknown>>(input: ParseResult | readonly SvgNode[], nextId: (source: SvgNode) => string, options?: SvgNodesToKitDraftsOptions<TData>): SvgSceneDraft<TData>[];
|
|
788
813
|
|