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