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