@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/index.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 { IRPaintType, IRLineJoin, IRLineCap, IRShapePrimitiveType, IRLayerType, ANIMATION_IR_SCHEMA_VERSION, validateIRScene, IRBlendMode } from '@vvfx/animation-ir';
@@ -3978,7 +3978,7 @@ function distPointToSegment(p, a, b) {
3978
3978
  return transformVector(gChain, t);
3979
3979
  });
3980
3980
  return {
3981
- mode: "add",
3981
+ mode: 'add',
3982
3982
  path: {
3983
3983
  points: pts,
3984
3984
  inTangents: inTangents,
@@ -5935,12 +5935,16 @@ function applyClipMask(es, el, layer, clipMasks) {
5935
5935
  }
5936
5936
  if (isClip) {
5937
5937
  return _extends({}, layer, {
5938
- mask: baseMask
5938
+ masks: [
5939
+ baseMask
5940
+ ]
5939
5941
  });
5940
5942
  }
5941
5943
  var rebased = rebaseMaskToLocal(baseMask, layer);
5942
5944
  return rebased ? _extends({}, layer, {
5943
- mask: rebased
5945
+ masks: [
5946
+ rebased
5947
+ ]
5944
5948
  }) : layer;
5945
5949
  }
5946
5950
  /** 将 SVG 绝对 mask 点转换为 image 的 asset-local 坐标。 */ function rebaseMaskToLocal(mask, layer) {
@@ -5978,7 +5982,7 @@ function applyClipMask(es, el, layer, clipMasks) {
5978
5982
  outTangents: mask.path.outTangents,
5979
5983
  closed: mask.path.closed
5980
5984
  },
5981
- mode: "add"
5985
+ mode: 'add'
5982
5986
  };
5983
5987
  }
5984
5988
  // shape 没有 asset 尺寸,mask 需要转换到以 layer anchor 为基准的 element-local 空间。
@@ -6008,7 +6012,7 @@ function applyClipMask(es, el, layer, clipMasks) {
6008
6012
  outTangents: mask.path.outTangents,
6009
6013
  closed: mask.path.closed
6010
6014
  },
6011
- mode: "add"
6015
+ mode: 'add'
6012
6016
  };
6013
6017
  }
6014
6018
  /** shape layer 的 element-local bbox(以 layer.transform.anchor=localCenter 为原点)。
@@ -6977,7 +6981,7 @@ function createSVGConversionSession(es, options) {
6977
6981
  };
6978
6982
  var withGroupParent = function withGroupParent(layer, element) {
6979
6983
  var parentIndex = nearestMaskedGroupAncestor(element);
6980
- if (parentIndex == null || layer.mask != null) {
6984
+ if (parentIndex == null) {
6981
6985
  return layer;
6982
6986
  }
6983
6987
  return _extends({}, layer, {
@@ -7332,7 +7336,9 @@ function convertGroupElement(element, context) {
7332
7336
  value: 1
7333
7337
  }
7334
7338
  },
7335
- mask: groupMask
7339
+ masks: [
7340
+ groupMask
7341
+ ]
7336
7342
  };
7337
7343
  context.appendLayer(nullLayer, element, false);
7338
7344
  context.groupMaskGNodeToIndex.set(element.node, layerIndex);
@@ -12735,21 +12741,36 @@ function transformBoxCorners(matrix, box) {
12735
12741
  transformPoint(matrix, box[0], box[3])
12736
12742
  ];
12737
12743
  }
12738
- function mapPointsToBBox(points) {
12744
+ function mapPointsToBBox(points, roundCoordinates) {
12745
+ if (roundCoordinates === void 0) roundCoordinates = true;
12739
12746
  var _Math, _Math1, _Math2, _Math3;
12740
- return [
12741
- roundPixel((_Math = Math).min.apply(_Math, [].concat(points.map(function(point) {
12747
+ var bbox = [
12748
+ (_Math = Math).min.apply(_Math, [].concat(points.map(function(point) {
12742
12749
  return point[0];
12743
- })))),
12744
- roundPixel((_Math1 = Math).min.apply(_Math1, [].concat(points.map(function(point) {
12750
+ }))),
12751
+ (_Math1 = Math).min.apply(_Math1, [].concat(points.map(function(point) {
12745
12752
  return point[1];
12746
- })))),
12747
- roundPixel((_Math2 = Math).max.apply(_Math2, [].concat(points.map(function(point) {
12753
+ }))),
12754
+ (_Math2 = Math).max.apply(_Math2, [].concat(points.map(function(point) {
12748
12755
  return point[0];
12749
- })))),
12750
- roundPixel((_Math3 = Math).max.apply(_Math3, [].concat(points.map(function(point) {
12756
+ }))),
12757
+ (_Math3 = Math).max.apply(_Math3, [].concat(points.map(function(point) {
12751
12758
  return point[1];
12752
- }))))
12759
+ })))
12760
+ ];
12761
+ if (bbox.some(function(value) {
12762
+ return !Number.isFinite(value);
12763
+ })) {
12764
+ throwInvalidLayerData('Non-finite pixel geometry.');
12765
+ }
12766
+ if (!roundCoordinates) {
12767
+ return bbox;
12768
+ }
12769
+ return [
12770
+ roundPixel(bbox[0]),
12771
+ roundPixel(bbox[1]),
12772
+ roundPixel(bbox[2]),
12773
+ roundPixel(bbox[3])
12753
12774
  ];
12754
12775
  }
12755
12776
  function roundPixel(value) {
@@ -12957,7 +12978,7 @@ function parseTextRuns(layer, font, preserved) {
12957
12978
  return spans.filter(function(span) {
12958
12979
  return span.text !== '' || span.newLine;
12959
12980
  }).map(function(span) {
12960
- var fontSize = span.fontSize == null || span.fontSize === '' ? base.fontSize : Number.parseInt(span.fontSize, 10);
12981
+ var fontSize = span.fontSize == null || span.fontSize === '' ? base.fontSize : Number.parseFloat(span.fontSize);
12961
12982
  if (!Number.isFinite(fontSize) || fontSize <= 0) {
12962
12983
  throwInvalidLayerData('Invalid text fragment font size.');
12963
12984
  }
@@ -12986,7 +13007,7 @@ function mapTextColor(color) {
12986
13007
  };
12987
13008
  }
12988
13009
 
12989
- function buildTextRunLayout(runs, family, spacing, content, size, conversionOptions, warnings, id, segmented) {
13010
+ function buildTextRunLayout(runs, family, spacing, content, size, conversionOptions, warnings, id, segmented, renderScale) {
12990
13011
  var _loop = function() {
12991
13012
  var run = _step.value;
12992
13013
  run.text.split('\n').forEach(function(text, index) {
@@ -13001,6 +13022,10 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
13001
13022
  });
13002
13023
  };
13003
13024
  if (segmented === void 0) segmented = false;
13025
+ if (renderScale === void 0) renderScale = [
13026
+ 1,
13027
+ 1
13028
+ ];
13004
13029
  var _Math;
13005
13030
  var rows = [
13006
13031
  []
@@ -13013,7 +13038,7 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
13013
13038
  }).map(function(row) {
13014
13039
  var _Math, _Math1;
13015
13040
  var parts = row.map(function(run) {
13016
- // 分段文字使用统一参考字号度量字宽和字体边界,再按片段字号缩放。
13041
+ // 基线沿用参考字号指标,字宽按实际输出字号单独测量。
13017
13042
  var measurementSize = segmented ? 10 : run.fontSize;
13018
13043
  var scale = run.fontSize / measurementSize;
13019
13044
  var weight = run.bold ? 'bold' : 'normal';
@@ -13021,29 +13046,36 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
13021
13046
  var font = buildCanvasFontDesc(measurementSize, family, weight, style);
13022
13047
  var metrics = conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, font, segmented ? 'x' : run.text);
13023
13048
  var characters = Array.from(run.text);
13024
- var chunks = segmented ? characters : [
13025
- run.text
13026
- ];
13027
- var advance = 0;
13028
- for(var _iterator = _create_for_of_iterator_helper_loose(chunks), _step; !(_step = _iterator()).done;){
13029
- var chunk = _step.value;
13030
- var width = segmented ? conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, font, chunk).width : metrics == null ? void 0 : metrics.width;
13031
- var valid = width != null && Number.isFinite(width) && width >= 0;
13032
- estimated || (estimated = !valid);
13033
- advance += valid ? width : estimateTextWidth(chunk, measurementSize, 0, undefined, family, weight, style);
13034
- }
13035
- var characterCount = characters.length;
13036
- var width1 = advance * scale + Math.max(0, characterCount - 1) * spacing;
13049
+ // 片段协议不输出额外字重和斜体,测宽使用同样的普通样式。
13050
+ var widthFontSize = run.fontSize * renderScale[1];
13051
+ var widthFont = buildCanvasFontDesc(widthFontSize, family, 'normal', 'normal');
13052
+ var measureWidth = function measureWidth(text) {
13053
+ var width = conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, widthFont, text).width;
13054
+ if (width != null && Number.isFinite(width) && width >= 0) {
13055
+ return width;
13056
+ }
13057
+ estimated = true;
13058
+ return estimateTextWidth(text, widthFontSize, 0, undefined, family, 'normal', 'normal');
13059
+ };
13060
+ // 字距和字宽交替累加,保持与 Artis 逐字测宽的计算顺序一致。
13061
+ var renderedWidth = 0;
13062
+ characters.forEach(function(character, index) {
13063
+ if (index > 0) {
13064
+ renderedWidth += spacing * renderScale[0];
13065
+ }
13066
+ renderedWidth += measureWidth(character);
13067
+ });
13068
+ var width = renderedWidth / renderScale[0];
13037
13069
  var fallback = resolveFontMetrics(undefined, family, weight, style, run.fontSize);
13038
13070
  var ascent = (metrics == null ? void 0 : metrics.fontBoundingBoxAscent) == null ? fallback.asc : metrics.fontBoundingBoxAscent * scale;
13039
13071
  var descent = (metrics == null ? void 0 : metrics.fontBoundingBoxDescent) == null ? fallback.desc : metrics.fontBoundingBoxDescent * scale;
13040
13072
  estimated || (estimated = (metrics == null ? void 0 : metrics.fontBoundingBoxAscent) == null || metrics.fontBoundingBoxDescent == null);
13041
- if (!Number.isFinite(width1) || width1 < 0 || !Number.isFinite(ascent) || !Number.isFinite(descent)) {
13073
+ if (!Number.isFinite(width) || width < 0 || !Number.isFinite(ascent) || !Number.isFinite(descent)) {
13042
13074
  throwInvalidLayerData('Text measurement returned invalid metrics.');
13043
13075
  }
13044
13076
  return {
13045
13077
  run: run,
13046
- width: width1,
13078
+ width: width,
13047
13079
  ascent: ascent,
13048
13080
  descent: descent
13049
13081
  };
@@ -13156,7 +13188,10 @@ function convertIRTextLayer(layer, state, session, id) {
13156
13188
  var positioned = buildTextRunLayout(runs, font.family, layer.content.letterSpacing, layer.content, [
13157
13189
  bounds.width,
13158
13190
  height
13159
- ], options, warnings, id, preserved != null);
13191
+ ], options, warnings, id, preserved != null, [
13192
+ scaleX,
13193
+ scaleY
13194
+ ]);
13160
13195
  if (positioned.length === 0) {
13161
13196
  return undefined;
13162
13197
  }
@@ -13170,26 +13205,25 @@ function convertIRTextLayer(layer, state, session, id) {
13170
13205
  part.box[3] + centerY
13171
13206
  ]);
13172
13207
  });
13173
- var bbox = mapPointsToBBox(polygons.flat());
13174
- var rotation = roundPixel(Math.atan2(matrix.b, matrix.a) * 180 / Math.PI);
13208
+ var bbox = mapPointsToBBox(polygons.flat(), false);
13209
+ var rotation = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;
13175
13210
  var fragments = positioned.map(function(part, index) {
13176
13211
  var polygon = polygons[index].map(function(point) {
13177
13212
  return [
13178
- roundPixel(point[0] - bbox[0]),
13179
- roundPixel(point[1] - bbox[1])
13213
+ point[0] - bbox[0],
13214
+ point[1] - bbox[1]
13180
13215
  ];
13181
13216
  });
13182
13217
  return {
13183
13218
  content: part.run.text,
13184
- bbox: mapPointsToBBox(polygon),
13219
+ bbox: mapPointsToBBox(polygon, false),
13185
13220
  polygon: polygon,
13186
- // Keep the authored font-family string, quotes included; consumers resolve families themselves.
13187
- font_family: font.family,
13188
- font_size: roundPixel(part.run.fontSize * scaleY),
13221
+ font_family: normalizeFontFamilyName(font.family),
13222
+ font_size: part.run.fontSize * scaleY,
13189
13223
  color: part.run.color,
13190
- letter_spacing: roundPixel(layer.content.letterSpacing * scaleX),
13224
+ letter_spacing: layer.content.letterSpacing * scaleX,
13191
13225
  direction: 'horizontal',
13192
- rotation: rotation
13226
+ rotation: rotation === 0 ? 0 : rotation
13193
13227
  };
13194
13228
  });
13195
13229
  return {
@@ -13264,6 +13298,7 @@ function createLayerConverterRegistry(session) {
13264
13298
  }
13265
13299
 
13266
13300
  function resolveIRVisualState(layer, session) {
13301
+ var _layer_masks;
13267
13302
  if (!layer.visible) {
13268
13303
  return undefined;
13269
13304
  }
@@ -13271,7 +13306,9 @@ function resolveIRVisualState(layer, session) {
13271
13306
  if (!state.visible || state.opacity <= 0) {
13272
13307
  return undefined;
13273
13308
  }
13274
- var unsupportedMask = layer.mask != null && (layer.type !== 'image' || !maskCoversImage(layer.mask, layer.localBounds));
13309
+ var unsupportedMask = ((_layer_masks = layer.masks) != null ? _layer_masks : []).some(function(mask) {
13310
+ return layer.type !== 'image' || !maskCoversImage(mask, layer.localBounds);
13311
+ });
13275
13312
  if (unsupportedMask || layer.matte != null) {
13276
13313
  throwUnsupportedLayerFeature('Mask or clipping is not supported by the flat layer protocol.');
13277
13314
  }
@@ -13339,8 +13376,9 @@ function assembleSVGStaticLayers(scene, options, warnings, preservedData, source
13339
13376
  }
13340
13377
  /** Replace baked sources, combine native and raster layers in painter order, then report final diagnostics. */ function assembleSVGLayers(input) {
13341
13378
  var _warnings, _ordered;
13342
- var scene = input.scene, options = input.options, preservedData = input.preservedData, layerSources = input.layerSources, warningSources = input.warningSources, baking = input.baking;
13343
- var warnings = input.warnings.filter(function(warning) {
13379
+ 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;
13380
+ var options = input.options, baking = input.baking;
13381
+ var warnings = contextWarnings.filter(function(warning) {
13344
13382
  return !baking.resolvesWarning(warning, warningSources.get(warning));
13345
13383
  });
13346
13384
  var composition = getIRSceneEntryComposition(scene);
@@ -14586,13 +14624,17 @@ var animatedTags = new Set([
14586
14624
  };
14587
14625
  }
14588
14626
 
14589
- function convertSVGToLayers(source, options, loadImage, preservedData, rasterScale) {
14590
- if (rasterScale === void 0) rasterScale = 2;
14591
- return _async_to_generator(function() {
14592
- var layerSources, warningSources, collected, stripped, staticSource, parsed, composition, baking, assembled, _tmp, _tmp1;
14627
+ function convertSVGToLayers() {
14628
+ return _async_to_generator(function(source, options, preservedData) {
14629
+ var loadImage, _options_rasterScale, rasterScale, conversionOptions, layerSources, warningSources, collected, stripped, staticSource, parsed, context, composition, baking, assembled, _tmp, _tmp1;
14593
14630
  return _ts_generator(this, function(_state) {
14594
14631
  switch(_state.label){
14595
14632
  case 0:
14633
+ if (options === void 0) options = {};
14634
+ loadImage = options.loadImage, _options_rasterScale = options.rasterScale, rasterScale = _options_rasterScale === void 0 ? 2 : _options_rasterScale, conversionOptions = _object_without_properties_loose(options, [
14635
+ "loadImage",
14636
+ "rasterScale"
14637
+ ]);
14596
14638
  layerSources = new Map();
14597
14639
  warningSources = new Map();
14598
14640
  collected = {
@@ -14603,36 +14645,40 @@ function convertSVGToLayers(source, options, loadImage, preservedData, rasterSca
14603
14645
  stripped = stripLayerAnimation(source);
14604
14646
  staticSource = stripped.source;
14605
14647
  // Preserve original layer IDs while gathering the source identities required by baking and assembly.
14606
- parsed = parseSVGToIRWithPreservedData(staticSource, _extends({}, options, {
14648
+ parsed = parseSVGToIRWithPreservedData(staticSource, _extends({}, conversionOptions, {
14607
14649
  strict: false,
14608
14650
  onWarning: undefined
14609
14651
  }), _extends({}, collected, {
14610
14652
  layerSourceCollector: layerSources,
14611
14653
  warningSourceCollector: warningSources
14612
14654
  }));
14655
+ context = {
14656
+ source: staticSource,
14657
+ ir: parsed.ir,
14658
+ warnings: parsed.warnings,
14659
+ preservedData: preservedData != null ? preservedData : collected,
14660
+ layerSources: layerSources,
14661
+ warningSources: warningSources
14662
+ };
14613
14663
  if (stripped.removed > 0) {
14614
- collectLayerWarning(parsed.warnings, _extends({}, options, {
14664
+ collectLayerWarning(context.warnings, _extends({}, conversionOptions, {
14615
14665
  strict: false,
14616
14666
  onWarning: undefined
14617
14667
  }), SVG2IR_WARNING_CODES.LAYERS_ANIMATION_STRIPPED, "" + stripped.removed + " animated element(s) were removed; static layers output does not sample animation.");
14618
14668
  }
14619
- composition = parsed.ir.compositions[0];
14669
+ composition = context.ir.compositions[0];
14620
14670
  return [
14621
14671
  4,
14622
- buildBakedLayers(staticSource, [
14672
+ buildBakedLayers(context.source, [
14623
14673
  composition.width,
14624
14674
  composition.height
14625
- ], options, rasterScale)
14675
+ ], conversionOptions, rasterScale)
14626
14676
  ];
14627
14677
  case 1:
14628
14678
  baking = _state.sent();
14629
14679
  assembled = assembleSVGLayers({
14630
- scene: parsed.ir,
14631
- options: options,
14632
- warnings: parsed.warnings,
14633
- preservedData: preservedData != null ? preservedData : collected,
14634
- layerSources: layerSources,
14635
- warningSources: warningSources,
14680
+ context: context,
14681
+ options: conversionOptions,
14636
14682
  baking: baking
14637
14683
  });
14638
14684
  _tmp = [
@@ -14653,7 +14699,7 @@ function convertSVGToLayers(source, options, loadImage, preservedData, rasterSca
14653
14699
  ];
14654
14700
  }
14655
14701
  });
14656
- })();
14702
+ }).apply(this, arguments);
14657
14703
  }
14658
14704
 
14659
14705
  /**
@@ -14678,7 +14724,8 @@ function convertSVGToLayers(source, options, loadImage, preservedData, rasterSca
14678
14724
  JSONSceneVersion["3_4"] = "3.4";
14679
14725
  JSONSceneVersion["3_5"] = "3.5";
14680
14726
  JSONSceneVersion["3_6"] = "3.6";
14681
- JSONSceneVersion["LATEST"] = "3.6";
14727
+ JSONSceneVersion["3_7"] = "3.7";
14728
+ JSONSceneVersion["LATEST"] = "3.7";
14682
14729
  })(JSONSceneVersion || (JSONSceneVersion = {}));
14683
14730
 
14684
14731
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -14993,10 +15040,12 @@ var CameraClipMode;
14993
15040
  * 直线
14994
15041
  */ ValueType[ValueType["LINE"] = 5] = "LINE";
14995
15042
  /**
14996
- * 曲线
15043
+ * 曲线(Hermite 曲线)
15044
+ * @deprecated 使用 BEZIER_CURVE 替代,此类型仅用于旧数据迁移兼容
14997
15045
  */ ValueType[ValueType["CURVE"] = 6] = "CURVE";
14998
15046
  /**
14999
15047
  * 贝塞尔路径
15048
+ * @deprecated 使用 BEZIER_CURVE_PATH 替代,此类型仅用于旧数据迁移兼容
15000
15049
  */ ValueType[ValueType["BEZIER_PATH"] = 7] = "BEZIER_PATH";
15001
15050
  /**
15002
15051
  * 颜色
@@ -15433,6 +15482,7 @@ var DataType;
15433
15482
  DataType["AnimationGraphAsset"] = "AnimationGraphAsset";
15434
15483
  DataType["CompositionComponent"] = "CompositionComponent";
15435
15484
  DataType["FFDComponent"] = "FFDComponent";
15485
+ DataType["FrameComponent"] = "FrameComponent";
15436
15486
  DataType["Animator"] = "Animator";
15437
15487
  // Non-EffectObject
15438
15488
  DataType["TimelineClip"] = "TimelineClip";
@@ -17057,7 +17107,8 @@ function asRecordArray(value) {
17057
17107
  }
17058
17108
 
17059
17109
  /** 从已解析的 IR 和 SVG 保留数据生成 GE 场景。 */ function assembleSVGGE(parsed, options, preservedData) {
17060
- var ir = parsed.ir, warnings = parsed.warnings;
17110
+ var ir = parsed.ir;
17111
+ var warnings = [].concat(parsed.warnings);
17061
17112
  var fonts = (options != null ? options : {}).fonts;
17062
17113
  var irForGE = expandIRHoldTransitions(ir);
17063
17114
  if ((preservedData == null ? void 0 : preservedData.shapeAnimationsByLayerId) != null) {
@@ -17165,32 +17216,13 @@ function cleanFontName(raw) {
17165
17216
  return value;
17166
17217
  }
17167
17218
 
17168
- /** SVG→GE 显式入口。传入 preservedData 时应用 SVG 专属后处理。 */ function convertSVGToGE(source, options, preservedData) {
17219
+ function convertSVGToGE(sourceOrContext, options, preservedData) {
17169
17220
  var _ref = options != null ? options : {}; _ref.fonts; var parserOptions = _object_without_properties_loose(_ref, [
17170
17221
  "fonts"
17171
17222
  ]);
17172
- var parsed = parseSVGToIRWithPreservedData(source, parserOptions);
17173
- return assembleSVGGE(parsed, options, preservedData);
17174
- }
17175
-
17176
- function convertSVG(source, options, preservedData) {
17177
- var _ref = options != null ? options : {}, _ref_outputFormat = _ref.outputFormat, outputFormat = _ref_outputFormat === void 0 ? 'ge' : _ref_outputFormat;
17178
- if (outputFormat !== 'ge' && outputFormat !== 'layers') {
17179
- throw new TypeError('[svg2ir] outputFormat must be ge or layers.');
17180
- }
17181
- if ((options == null ? void 0 : options.outputFormat) === 'layers') {
17182
- options.outputFormat; var loadImage = options.loadImage, rasterScale = options.rasterScale, parserOptions = _object_without_properties_loose(options, [
17183
- "outputFormat",
17184
- "loadImage",
17185
- "rasterScale"
17186
- ]);
17187
- return convertSVGToLayers(source, parserOptions, loadImage, preservedData, rasterScale);
17188
- }
17189
- var _ref1 = options != null ? options : {}; _ref1.outputFormat; var geOptions = _object_without_properties_loose(_ref1, [
17190
- "outputFormat"
17191
- ]);
17192
- return convertSVGToGE(source, geOptions, preservedData);
17223
+ var context = typeof sourceOrContext === 'string' ? parseSVGToIRWithPreservedData(sourceOrContext, parserOptions) : sourceOrContext;
17224
+ return assembleSVGGE(context, options, preservedData != null ? preservedData : typeof sourceOrContext === 'string' ? undefined : sourceOrContext.preservedData);
17193
17225
  }
17194
17226
 
17195
- export { convertSVG, convertSVGToGE, convertSVGToIR, inferNumericWeightFromFamily, splitSVG };
17227
+ export { convertSVGToGE, convertSVGToIR, convertSVGToLayers, inferNumericWeightFromFamily, splitSVG };
17196
17228
  //# sourceMappingURL=index.mjs.map