@vvfx/svg2ir 0.0.1-beta.11 → 0.0.1-beta.12

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.
Files changed (50) hide show
  1. package/README.md +26 -17
  2. package/dist/{svg2ge-adapter → adapter/svg2ge}/assemble.d.ts +2 -2
  3. package/dist/adapter/svg2ge/convert.d.ts +7 -0
  4. package/dist/{svg2ge-adapter → adapter/svg2ge}/normalize-shape-animation.d.ts +1 -1
  5. package/dist/{svg2ge-adapter → adapter/svg2ge}/post-process/apply-shape-geometry-animation.d.ts +1 -1
  6. package/dist/{svg2ge-adapter → adapter/svg2ge}/post-process/apply-shape-paint-animation.d.ts +1 -1
  7. package/dist/{svg2ge-adapter → adapter/svg2ge}/post-process/rewrite-text-components.d.ts +1 -1
  8. package/dist/{svg2ge-adapter → adapter/svg2ge}/pre-process.d.ts +1 -1
  9. package/dist/{svg2ge-adapter → adapter/svg2ge}/types.d.ts +2 -2
  10. package/dist/{svg2layers-adapter → adapter/svg2layers}/assemble.d.ts +9 -7
  11. package/dist/{svg2layers-adapter → adapter/svg2layers}/baking/build-baked-layers.d.ts +1 -1
  12. package/dist/{svg2layers-adapter → adapter/svg2layers}/baking/plan-graphic-baking.d.ts +1 -1
  13. package/dist/adapter/svg2layers/convert.d.ts +4 -0
  14. package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/diagnostics/collect-warnings.d.ts +1 -1
  15. package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/layers/conversion-session.d.ts +2 -2
  16. package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/text/parse-text-runs.d.ts +1 -1
  17. package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/text/text-layout.d.ts +2 -2
  18. package/dist/{svg2layers-adapter → adapter/svg2layers}/matrix.d.ts +1 -1
  19. package/dist/{svg2layers-adapter → adapter/svg2layers}/types.d.ts +8 -1
  20. package/dist/common/types.d.ts +1 -1
  21. package/dist/index.d.ts +5 -6
  22. package/dist/index.js +124 -92
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +124 -92
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/node.js +124 -92
  27. package/dist/node.js.map +1 -1
  28. package/dist/node.mjs +124 -92
  29. package/dist/node.mjs.map +1 -1
  30. package/dist/svg2ir/convert.d.ts +2 -1
  31. package/package.json +5 -5
  32. package/dist/convert.d.ts +0 -21
  33. package/dist/svg2ge-adapter/convert.d.ts +0 -5
  34. package/dist/svg2layers-adapter/convert.d.ts +0 -4
  35. /package/dist/{svg2ge-adapter → adapter/svg2ge}/converter/animation.d.ts +0 -0
  36. /package/dist/{svg2ge-adapter → adapter/svg2ge}/converter/data-path.d.ts +0 -0
  37. /package/dist/{svg2ge-adapter → adapter/svg2ge}/post-process/apply-fonts.d.ts +0 -0
  38. /package/dist/{svg2ge-adapter → adapter/svg2ge}/post-process/paint-animation-sampling.d.ts +0 -0
  39. /package/dist/{svg2ge-adapter → adapter/svg2ge}/post-process/restore-gradient-uv.d.ts +0 -0
  40. /package/dist/{svg2layers-adapter → adapter/svg2layers}/baking/normalize-layer-blending.d.ts +0 -0
  41. /package/dist/{svg2layers-adapter → adapter/svg2layers}/baking/resolve-baking-warnings.d.ts +0 -0
  42. /package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/image/convert-image-layer.d.ts +0 -0
  43. /package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/image/inspect-mask.d.ts +0 -0
  44. /package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/layers/build-layers.d.ts +0 -0
  45. /package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/layers/registry.d.ts +0 -0
  46. /package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/layers/resolve-visual-state.d.ts +0 -0
  47. /package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/text/convert-text-layer.d.ts +0 -0
  48. /package/dist/{svg2layers-adapter → adapter/svg2layers}/converter/transform/build-transform.d.ts +0 -0
  49. /package/dist/{svg2layers-adapter → adapter/svg2layers}/post-process/inline-image-resources.d.ts +0 -0
  50. /package/dist/{svg2layers-adapter → adapter/svg2layers}/strip-layer-animation.d.ts +0 -0
package/dist/node.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: SVG to Animation IR and Galacean Effects conversion engine
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 鳞息
6
- * Version: v0.0.1-beta.11
6
+ * Version: v0.0.1-beta.12
7
7
  */
8
8
 
9
9
  import { createSVGWindow } from 'svgdom';
@@ -4197,7 +4197,7 @@ function distPointToSegment(p, a, b) {
4197
4197
  return transformVector(gChain, t);
4198
4198
  });
4199
4199
  return {
4200
- mode: "add",
4200
+ mode: 'add',
4201
4201
  path: {
4202
4202
  points: pts,
4203
4203
  inTangents: inTangents,
@@ -6124,12 +6124,16 @@ function applyClipMask(es, el, layer, clipMasks) {
6124
6124
  }
6125
6125
  if (isClip) {
6126
6126
  return _extends({}, layer, {
6127
- mask: baseMask
6127
+ masks: [
6128
+ baseMask
6129
+ ]
6128
6130
  });
6129
6131
  }
6130
6132
  var rebased = rebaseMaskToLocal(baseMask, layer);
6131
6133
  return rebased ? _extends({}, layer, {
6132
- mask: rebased
6134
+ masks: [
6135
+ rebased
6136
+ ]
6133
6137
  }) : layer;
6134
6138
  }
6135
6139
  /** 将 SVG 绝对 mask 点转换为 image 的 asset-local 坐标。 */ function rebaseMaskToLocal(mask, layer) {
@@ -6167,7 +6171,7 @@ function applyClipMask(es, el, layer, clipMasks) {
6167
6171
  outTangents: mask.path.outTangents,
6168
6172
  closed: mask.path.closed
6169
6173
  },
6170
- mode: "add"
6174
+ mode: 'add'
6171
6175
  };
6172
6176
  }
6173
6177
  // shape 没有 asset 尺寸,mask 需要转换到以 layer anchor 为基准的 element-local 空间。
@@ -6197,7 +6201,7 @@ function applyClipMask(es, el, layer, clipMasks) {
6197
6201
  outTangents: mask.path.outTangents,
6198
6202
  closed: mask.path.closed
6199
6203
  },
6200
- mode: "add"
6204
+ mode: 'add'
6201
6205
  };
6202
6206
  }
6203
6207
  /** shape layer 的 element-local bbox(以 layer.transform.anchor=localCenter 为原点)。
@@ -7166,7 +7170,7 @@ function createSVGConversionSession(es, options) {
7166
7170
  };
7167
7171
  var withGroupParent = function withGroupParent(layer, element) {
7168
7172
  var parentIndex = nearestMaskedGroupAncestor(element);
7169
- if (parentIndex == null || layer.mask != null) {
7173
+ if (parentIndex == null) {
7170
7174
  return layer;
7171
7175
  }
7172
7176
  return _extends({}, layer, {
@@ -7521,7 +7525,9 @@ function convertGroupElement(element, context) {
7521
7525
  value: 1
7522
7526
  }
7523
7527
  },
7524
- mask: groupMask
7528
+ masks: [
7529
+ groupMask
7530
+ ]
7525
7531
  };
7526
7532
  context.appendLayer(nullLayer, element, false);
7527
7533
  context.groupMaskGNodeToIndex.set(element.node, layerIndex);
@@ -12750,21 +12756,36 @@ function transformBoxCorners(matrix, box) {
12750
12756
  transformPoint(matrix, box[0], box[3])
12751
12757
  ];
12752
12758
  }
12753
- function mapPointsToBBox(points) {
12759
+ function mapPointsToBBox(points, roundCoordinates) {
12760
+ if (roundCoordinates === void 0) roundCoordinates = true;
12754
12761
  var _Math, _Math1, _Math2, _Math3;
12755
- return [
12756
- roundPixel((_Math = Math).min.apply(_Math, [].concat(points.map(function(point) {
12762
+ var bbox = [
12763
+ (_Math = Math).min.apply(_Math, [].concat(points.map(function(point) {
12757
12764
  return point[0];
12758
- })))),
12759
- roundPixel((_Math1 = Math).min.apply(_Math1, [].concat(points.map(function(point) {
12765
+ }))),
12766
+ (_Math1 = Math).min.apply(_Math1, [].concat(points.map(function(point) {
12760
12767
  return point[1];
12761
- })))),
12762
- roundPixel((_Math2 = Math).max.apply(_Math2, [].concat(points.map(function(point) {
12768
+ }))),
12769
+ (_Math2 = Math).max.apply(_Math2, [].concat(points.map(function(point) {
12763
12770
  return point[0];
12764
- })))),
12765
- roundPixel((_Math3 = Math).max.apply(_Math3, [].concat(points.map(function(point) {
12771
+ }))),
12772
+ (_Math3 = Math).max.apply(_Math3, [].concat(points.map(function(point) {
12766
12773
  return point[1];
12767
- }))))
12774
+ })))
12775
+ ];
12776
+ if (bbox.some(function(value) {
12777
+ return !Number.isFinite(value);
12778
+ })) {
12779
+ throwInvalidLayerData('Non-finite pixel geometry.');
12780
+ }
12781
+ if (!roundCoordinates) {
12782
+ return bbox;
12783
+ }
12784
+ return [
12785
+ roundPixel(bbox[0]),
12786
+ roundPixel(bbox[1]),
12787
+ roundPixel(bbox[2]),
12788
+ roundPixel(bbox[3])
12768
12789
  ];
12769
12790
  }
12770
12791
  function roundPixel(value) {
@@ -12972,7 +12993,7 @@ function parseTextRuns(layer, font, preserved) {
12972
12993
  return spans.filter(function(span) {
12973
12994
  return span.text !== '' || span.newLine;
12974
12995
  }).map(function(span) {
12975
- var fontSize = span.fontSize == null || span.fontSize === '' ? base.fontSize : Number.parseInt(span.fontSize, 10);
12996
+ var fontSize = span.fontSize == null || span.fontSize === '' ? base.fontSize : Number.parseFloat(span.fontSize);
12976
12997
  if (!Number.isFinite(fontSize) || fontSize <= 0) {
12977
12998
  throwInvalidLayerData('Invalid text fragment font size.');
12978
12999
  }
@@ -13001,7 +13022,7 @@ function mapTextColor(color) {
13001
13022
  };
13002
13023
  }
13003
13024
 
13004
- function buildTextRunLayout(runs, family, spacing, content, size, conversionOptions, warnings, id, segmented) {
13025
+ function buildTextRunLayout(runs, family, spacing, content, size, conversionOptions, warnings, id, segmented, renderScale) {
13005
13026
  var _loop = function() {
13006
13027
  var run = _step.value;
13007
13028
  run.text.split('\n').forEach(function(text, index) {
@@ -13016,6 +13037,10 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
13016
13037
  });
13017
13038
  };
13018
13039
  if (segmented === void 0) segmented = false;
13040
+ if (renderScale === void 0) renderScale = [
13041
+ 1,
13042
+ 1
13043
+ ];
13019
13044
  var _Math;
13020
13045
  var rows = [
13021
13046
  []
@@ -13028,7 +13053,7 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
13028
13053
  }).map(function(row) {
13029
13054
  var _Math, _Math1;
13030
13055
  var parts = row.map(function(run) {
13031
- // 分段文字使用统一参考字号度量字宽和字体边界,再按片段字号缩放。
13056
+ // 基线沿用参考字号指标,字宽按实际输出字号单独测量。
13032
13057
  var measurementSize = segmented ? 10 : run.fontSize;
13033
13058
  var scale = run.fontSize / measurementSize;
13034
13059
  var weight = run.bold ? 'bold' : 'normal';
@@ -13036,29 +13061,36 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
13036
13061
  var font = buildCanvasFontDesc(measurementSize, family, weight, style);
13037
13062
  var metrics = conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, font, segmented ? 'x' : run.text);
13038
13063
  var characters = Array.from(run.text);
13039
- var chunks = segmented ? characters : [
13040
- run.text
13041
- ];
13042
- var advance = 0;
13043
- for(var _iterator = _create_for_of_iterator_helper_loose(chunks), _step; !(_step = _iterator()).done;){
13044
- var chunk = _step.value;
13045
- var width = segmented ? conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, font, chunk).width : metrics == null ? void 0 : metrics.width;
13046
- var valid = width != null && Number.isFinite(width) && width >= 0;
13047
- estimated || (estimated = !valid);
13048
- advance += valid ? width : estimateTextWidth(chunk, measurementSize, 0, undefined, family, weight, style);
13049
- }
13050
- var characterCount = characters.length;
13051
- var width1 = advance * scale + Math.max(0, characterCount - 1) * spacing;
13064
+ // 片段协议不输出额外字重和斜体,测宽使用同样的普通样式。
13065
+ var widthFontSize = run.fontSize * renderScale[1];
13066
+ var widthFont = buildCanvasFontDesc(widthFontSize, family, 'normal', 'normal');
13067
+ var measureWidth = function measureWidth(text) {
13068
+ var width = conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, widthFont, text).width;
13069
+ if (width != null && Number.isFinite(width) && width >= 0) {
13070
+ return width;
13071
+ }
13072
+ estimated = true;
13073
+ return estimateTextWidth(text, widthFontSize, 0, undefined, family, 'normal', 'normal');
13074
+ };
13075
+ // 字距和字宽交替累加,保持与 Artis 逐字测宽的计算顺序一致。
13076
+ var renderedWidth = 0;
13077
+ characters.forEach(function(character, index) {
13078
+ if (index > 0) {
13079
+ renderedWidth += spacing * renderScale[0];
13080
+ }
13081
+ renderedWidth += measureWidth(character);
13082
+ });
13083
+ var width = renderedWidth / renderScale[0];
13052
13084
  var fallback = resolveFontMetrics(undefined, family, weight, style, run.fontSize);
13053
13085
  var ascent = (metrics == null ? void 0 : metrics.fontBoundingBoxAscent) == null ? fallback.asc : metrics.fontBoundingBoxAscent * scale;
13054
13086
  var descent = (metrics == null ? void 0 : metrics.fontBoundingBoxDescent) == null ? fallback.desc : metrics.fontBoundingBoxDescent * scale;
13055
13087
  estimated || (estimated = (metrics == null ? void 0 : metrics.fontBoundingBoxAscent) == null || metrics.fontBoundingBoxDescent == null);
13056
- if (!Number.isFinite(width1) || width1 < 0 || !Number.isFinite(ascent) || !Number.isFinite(descent)) {
13088
+ if (!Number.isFinite(width) || width < 0 || !Number.isFinite(ascent) || !Number.isFinite(descent)) {
13057
13089
  throwInvalidLayerData('Text measurement returned invalid metrics.');
13058
13090
  }
13059
13091
  return {
13060
13092
  run: run,
13061
- width: width1,
13093
+ width: width,
13062
13094
  ascent: ascent,
13063
13095
  descent: descent
13064
13096
  };
@@ -13171,7 +13203,10 @@ function convertIRTextLayer(layer, state, session, id) {
13171
13203
  var positioned = buildTextRunLayout(runs, font.family, layer.content.letterSpacing, layer.content, [
13172
13204
  bounds.width,
13173
13205
  height
13174
- ], options, warnings, id, preserved != null);
13206
+ ], options, warnings, id, preserved != null, [
13207
+ scaleX,
13208
+ scaleY
13209
+ ]);
13175
13210
  if (positioned.length === 0) {
13176
13211
  return undefined;
13177
13212
  }
@@ -13185,26 +13220,25 @@ function convertIRTextLayer(layer, state, session, id) {
13185
13220
  part.box[3] + centerY
13186
13221
  ]);
13187
13222
  });
13188
- var bbox = mapPointsToBBox(polygons.flat());
13189
- var rotation = roundPixel(Math.atan2(matrix.b, matrix.a) * 180 / Math.PI);
13223
+ var bbox = mapPointsToBBox(polygons.flat(), false);
13224
+ var rotation = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;
13190
13225
  var fragments = positioned.map(function(part, index) {
13191
13226
  var polygon = polygons[index].map(function(point) {
13192
13227
  return [
13193
- roundPixel(point[0] - bbox[0]),
13194
- roundPixel(point[1] - bbox[1])
13228
+ point[0] - bbox[0],
13229
+ point[1] - bbox[1]
13195
13230
  ];
13196
13231
  });
13197
13232
  return {
13198
13233
  content: part.run.text,
13199
- bbox: mapPointsToBBox(polygon),
13234
+ bbox: mapPointsToBBox(polygon, false),
13200
13235
  polygon: polygon,
13201
- // Keep the authored font-family string, quotes included; consumers resolve families themselves.
13202
- font_family: font.family,
13203
- font_size: roundPixel(part.run.fontSize * scaleY),
13236
+ font_family: normalizeFontFamilyName(font.family),
13237
+ font_size: part.run.fontSize * scaleY,
13204
13238
  color: part.run.color,
13205
- letter_spacing: roundPixel(layer.content.letterSpacing * scaleX),
13239
+ letter_spacing: layer.content.letterSpacing * scaleX,
13206
13240
  direction: 'horizontal',
13207
- rotation: rotation
13241
+ rotation: rotation === 0 ? 0 : rotation
13208
13242
  };
13209
13243
  });
13210
13244
  return {
@@ -13279,6 +13313,7 @@ function createLayerConverterRegistry(session) {
13279
13313
  }
13280
13314
 
13281
13315
  function resolveIRVisualState(layer, session) {
13316
+ var _layer_masks;
13282
13317
  if (!layer.visible) {
13283
13318
  return undefined;
13284
13319
  }
@@ -13286,7 +13321,9 @@ function resolveIRVisualState(layer, session) {
13286
13321
  if (!state.visible || state.opacity <= 0) {
13287
13322
  return undefined;
13288
13323
  }
13289
- var unsupportedMask = layer.mask != null && (layer.type !== 'image' || !maskCoversImage(layer.mask, layer.localBounds));
13324
+ var unsupportedMask = ((_layer_masks = layer.masks) != null ? _layer_masks : []).some(function(mask) {
13325
+ return layer.type !== 'image' || !maskCoversImage(mask, layer.localBounds);
13326
+ });
13290
13327
  if (unsupportedMask || layer.matte != null) {
13291
13328
  throwUnsupportedLayerFeature('Mask or clipping is not supported by the flat layer protocol.');
13292
13329
  }
@@ -13354,8 +13391,9 @@ function assembleSVGStaticLayers(scene, options, warnings, preservedData, source
13354
13391
  }
13355
13392
  /** Replace baked sources, combine native and raster layers in painter order, then report final diagnostics. */ function assembleSVGLayers(input) {
13356
13393
  var _warnings, _ordered;
13357
- var scene = input.scene, options = input.options, preservedData = input.preservedData, layerSources = input.layerSources, warningSources = input.warningSources, baking = input.baking;
13358
- var warnings = input.warnings.filter(function(warning) {
13394
+ var _input_context = input.context, scene = _input_context.ir, contextWarnings = _input_context.warnings, preservedData = _input_context.preservedData, layerSources = _input_context.layerSources, warningSources = _input_context.warningSources;
13395
+ var options = input.options, baking = input.baking;
13396
+ var warnings = contextWarnings.filter(function(warning) {
13359
13397
  return !baking.resolvesWarning(warning, warningSources.get(warning));
13360
13398
  });
13361
13399
  var composition = getIRSceneEntryComposition(scene);
@@ -14601,13 +14639,17 @@ var animatedTags = new Set([
14601
14639
  };
14602
14640
  }
14603
14641
 
14604
- function convertSVGToLayers(source, options, loadImage, preservedData, rasterScale) {
14605
- if (rasterScale === void 0) rasterScale = 2;
14606
- return _async_to_generator(function() {
14607
- var layerSources, warningSources, collected, stripped, staticSource, parsed, composition, baking, assembled, _tmp, _tmp1;
14642
+ function convertSVGToLayers() {
14643
+ return _async_to_generator(function(source, options, preservedData) {
14644
+ var loadImage, _options_rasterScale, rasterScale, conversionOptions, layerSources, warningSources, collected, stripped, staticSource, parsed, context, composition, baking, assembled, _tmp, _tmp1;
14608
14645
  return _ts_generator(this, function(_state) {
14609
14646
  switch(_state.label){
14610
14647
  case 0:
14648
+ if (options === void 0) options = {};
14649
+ loadImage = options.loadImage, _options_rasterScale = options.rasterScale, rasterScale = _options_rasterScale === void 0 ? 2 : _options_rasterScale, conversionOptions = _object_without_properties_loose(options, [
14650
+ "loadImage",
14651
+ "rasterScale"
14652
+ ]);
14611
14653
  layerSources = new Map();
14612
14654
  warningSources = new Map();
14613
14655
  collected = {
@@ -14618,36 +14660,40 @@ function convertSVGToLayers(source, options, loadImage, preservedData, rasterSca
14618
14660
  stripped = stripLayerAnimation(source);
14619
14661
  staticSource = stripped.source;
14620
14662
  // Preserve original layer IDs while gathering the source identities required by baking and assembly.
14621
- parsed = parseSVGToIRWithPreservedData(staticSource, _extends({}, options, {
14663
+ parsed = parseSVGToIRWithPreservedData(staticSource, _extends({}, conversionOptions, {
14622
14664
  strict: false,
14623
14665
  onWarning: undefined
14624
14666
  }), _extends({}, collected, {
14625
14667
  layerSourceCollector: layerSources,
14626
14668
  warningSourceCollector: warningSources
14627
14669
  }));
14670
+ context = {
14671
+ source: staticSource,
14672
+ ir: parsed.ir,
14673
+ warnings: parsed.warnings,
14674
+ preservedData: preservedData != null ? preservedData : collected,
14675
+ layerSources: layerSources,
14676
+ warningSources: warningSources
14677
+ };
14628
14678
  if (stripped.removed > 0) {
14629
- collectLayerWarning(parsed.warnings, _extends({}, options, {
14679
+ collectLayerWarning(context.warnings, _extends({}, conversionOptions, {
14630
14680
  strict: false,
14631
14681
  onWarning: undefined
14632
14682
  }), SVG2IR_WARNING_CODES.LAYERS_ANIMATION_STRIPPED, "" + stripped.removed + " animated element(s) were removed; static layers output does not sample animation.");
14633
14683
  }
14634
- composition = parsed.ir.compositions[0];
14684
+ composition = context.ir.compositions[0];
14635
14685
  return [
14636
14686
  4,
14637
- buildBakedLayers(staticSource, [
14687
+ buildBakedLayers(context.source, [
14638
14688
  composition.width,
14639
14689
  composition.height
14640
- ], options, rasterScale)
14690
+ ], conversionOptions, rasterScale)
14641
14691
  ];
14642
14692
  case 1:
14643
14693
  baking = _state.sent();
14644
14694
  assembled = assembleSVGLayers({
14645
- scene: parsed.ir,
14646
- options: options,
14647
- warnings: parsed.warnings,
14648
- preservedData: preservedData != null ? preservedData : collected,
14649
- layerSources: layerSources,
14650
- warningSources: warningSources,
14695
+ context: context,
14696
+ options: conversionOptions,
14651
14697
  baking: baking
14652
14698
  });
14653
14699
  _tmp = [
@@ -14668,7 +14714,7 @@ function convertSVGToLayers(source, options, loadImage, preservedData, rasterSca
14668
14714
  ];
14669
14715
  }
14670
14716
  });
14671
- })();
14717
+ }).apply(this, arguments);
14672
14718
  }
14673
14719
 
14674
14720
  /**
@@ -14693,7 +14739,8 @@ function convertSVGToLayers(source, options, loadImage, preservedData, rasterSca
14693
14739
  JSONSceneVersion["3_4"] = "3.4";
14694
14740
  JSONSceneVersion["3_5"] = "3.5";
14695
14741
  JSONSceneVersion["3_6"] = "3.6";
14696
- JSONSceneVersion["LATEST"] = "3.6";
14742
+ JSONSceneVersion["3_7"] = "3.7";
14743
+ JSONSceneVersion["LATEST"] = "3.7";
14697
14744
  })(JSONSceneVersion || (JSONSceneVersion = {}));
14698
14745
 
14699
14746
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -15008,10 +15055,12 @@ var CameraClipMode;
15008
15055
  * 直线
15009
15056
  */ ValueType[ValueType["LINE"] = 5] = "LINE";
15010
15057
  /**
15011
- * 曲线
15058
+ * 曲线(Hermite 曲线)
15059
+ * @deprecated 使用 BEZIER_CURVE 替代,此类型仅用于旧数据迁移兼容
15012
15060
  */ ValueType[ValueType["CURVE"] = 6] = "CURVE";
15013
15061
  /**
15014
15062
  * 贝塞尔路径
15063
+ * @deprecated 使用 BEZIER_CURVE_PATH 替代,此类型仅用于旧数据迁移兼容
15015
15064
  */ ValueType[ValueType["BEZIER_PATH"] = 7] = "BEZIER_PATH";
15016
15065
  /**
15017
15066
  * 颜色
@@ -15448,6 +15497,7 @@ var DataType;
15448
15497
  DataType["AnimationGraphAsset"] = "AnimationGraphAsset";
15449
15498
  DataType["CompositionComponent"] = "CompositionComponent";
15450
15499
  DataType["FFDComponent"] = "FFDComponent";
15500
+ DataType["FrameComponent"] = "FrameComponent";
15451
15501
  DataType["Animator"] = "Animator";
15452
15502
  // Non-EffectObject
15453
15503
  DataType["TimelineClip"] = "TimelineClip";
@@ -17072,7 +17122,8 @@ function asRecordArray(value) {
17072
17122
  }
17073
17123
 
17074
17124
  /** 从已解析的 IR 和 SVG 保留数据生成 GE 场景。 */ function assembleSVGGE(parsed, options, preservedData) {
17075
- var ir = parsed.ir, warnings = parsed.warnings;
17125
+ var ir = parsed.ir;
17126
+ var warnings = [].concat(parsed.warnings);
17076
17127
  var fonts = (options != null ? options : {}).fonts;
17077
17128
  var irForGE = expandIRHoldTransitions(ir);
17078
17129
  if ((preservedData == null ? void 0 : preservedData.shapeAnimationsByLayerId) != null) {
@@ -17180,34 +17231,15 @@ function cleanFontName(raw) {
17180
17231
  return value;
17181
17232
  }
17182
17233
 
17183
- /** SVG→GE 显式入口。传入 preservedData 时应用 SVG 专属后处理。 */ function convertSVGToGE(source, options, preservedData) {
17234
+ function convertSVGToGE(sourceOrContext, options, preservedData) {
17184
17235
  var _ref = options != null ? options : {}; _ref.fonts; var parserOptions = _object_without_properties_loose(_ref, [
17185
17236
  "fonts"
17186
17237
  ]);
17187
- var parsed = parseSVGToIRWithPreservedData(source, parserOptions);
17188
- return assembleSVGGE(parsed, options, preservedData);
17189
- }
17190
-
17191
- function convertSVG(source, options, preservedData) {
17192
- var _ref = options != null ? options : {}, _ref_outputFormat = _ref.outputFormat, outputFormat = _ref_outputFormat === void 0 ? 'ge' : _ref_outputFormat;
17193
- if (outputFormat !== 'ge' && outputFormat !== 'layers') {
17194
- throw new TypeError('[svg2ir] outputFormat must be ge or layers.');
17195
- }
17196
- if ((options == null ? void 0 : options.outputFormat) === 'layers') {
17197
- options.outputFormat; var loadImage = options.loadImage, rasterScale = options.rasterScale, parserOptions = _object_without_properties_loose(options, [
17198
- "outputFormat",
17199
- "loadImage",
17200
- "rasterScale"
17201
- ]);
17202
- return convertSVGToLayers(source, parserOptions, loadImage, preservedData, rasterScale);
17203
- }
17204
- var _ref1 = options != null ? options : {}; _ref1.outputFormat; var geOptions = _object_without_properties_loose(_ref1, [
17205
- "outputFormat"
17206
- ]);
17207
- return convertSVGToGE(source, geOptions, preservedData);
17238
+ var context = typeof sourceOrContext === 'string' ? parseSVGToIRWithPreservedData(sourceOrContext, parserOptions) : sourceOrContext;
17239
+ return assembleSVGGE(context, options, preservedData != null ? preservedData : typeof sourceOrContext === 'string' ? undefined : sourceOrContext.preservedData);
17208
17240
  }
17209
17241
 
17210
17242
  setEditableSVGConstructor(resolveEditableSVGConstructor(editableSVGNodeModule));
17211
17243
 
17212
- export { convertSVG, convertSVGToGE, convertSVGToIR, inferNumericWeightFromFamily, splitSVG };
17244
+ export { convertSVGToGE, convertSVGToIR, convertSVGToLayers, inferNumericWeightFromFamily, splitSVG };
17213
17245
  //# sourceMappingURL=node.mjs.map