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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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.0
6
+ * Version: v0.0.1-beta.11
7
7
  */
8
8
 
9
9
  'use strict';
@@ -1507,7 +1507,7 @@ function parseHexColor(raw) {
1507
1507
  return null;
1508
1508
  }
1509
1509
  var hex = match[1];
1510
- var expanded = hex.length <= 4 ? [].concat(hex).map(function(char) {
1510
+ var expanded = hex.length <= 4 ? Array.from(hex).map(function(char) {
1511
1511
  return "" + char + char;
1512
1512
  }).join('') : hex;
1513
1513
  var r = parseInt(expanded.slice(0, 2), 16) / 255;
@@ -2608,7 +2608,24 @@ function parseSMILTag(tag, root, beginCache, comparisonDuration, valueParser, un
2608
2608
  return maxEnd;
2609
2609
  }
2610
2610
 
2611
- /** SVG 转换诊断码。不支持的特性按降级和 warning 处理。 */ var SVG2IR_WARNING_CODES = {
2611
+ /** Structural source identity, independent of optional or duplicate SVG IDs. */ function buildElementTreePath(element) {
2612
+ var indices = [];
2613
+ var current = element;
2614
+ while(isElementNode(current.parentNode)){
2615
+ var parent = current.parentNode;
2616
+ indices.unshift(Array.from(parent.children).indexOf(current));
2617
+ current = parent;
2618
+ }
2619
+ return indices.join('/');
2620
+ }
2621
+ function isElementNode(node) {
2622
+ return (node == null ? void 0 : node.nodeType) === 1;
2623
+ }
2624
+
2625
+ /** SVG 转换诊断码;用于报告烘焙、降级和不支持的特性。 */ var SVG2IR_WARNING_CODES = {
2626
+ /** 图形或图形组已栅格化,矢量编辑能力变化通过 warning 报告。 */ LAYERS_GRAPHIC_BAKED: 'svg2ge_layers_graphic_baked',
2627
+ LAYERS_BLEND_MODE_DOWNGRADED: 'svg2ge_layers_blend_mode_downgraded',
2628
+ LAYERS_ANIMATION_STRIPPED: 'svg2ge_layers_animation_stripped',
2612
2629
  LAYERS_UNSUPPORTED_TYPE: 'svg2ge_layers_unsupported_type',
2613
2630
  LAYERS_UNSUPPORTED_FEATURE: 'svg2ge_layers_unsupported_feature',
2614
2631
  LAYERS_INVALID_DATA: 'svg2ge_layers_invalid_data',
@@ -6128,8 +6145,9 @@ function readVec3(channel) {
6128
6145
  node
6129
6146
  ], Array.from(node.querySelectorAll('*')));
6130
6147
  var hasUnsupportedRule = ruleNodes.some(function(candidate) {
6148
+ var _ref, _ref1;
6131
6149
  var _candidate_getAttribute, _candidate_getAttribute1;
6132
- return ((_candidate_getAttribute = candidate.getAttribute('clip-rule')) == null ? void 0 : _candidate_getAttribute.trim()) !== '' || ((_candidate_getAttribute1 = candidate.getAttribute('fill-rule')) == null ? void 0 : _candidate_getAttribute1.trim()) !== '';
6150
+ return ((_ref = (_candidate_getAttribute = candidate.getAttribute('clip-rule')) == null ? void 0 : _candidate_getAttribute.trim()) != null ? _ref : '') !== '' || ((_ref1 = (_candidate_getAttribute1 = candidate.getAttribute('fill-rule')) == null ? void 0 : _candidate_getAttribute1.trim()) != null ? _ref1 : '') !== '';
6133
6151
  });
6134
6152
  if (hasUnsupportedRule) {
6135
6153
  warn(SVG2IR_WARNING_CODES.CLIP_RULE_DROPPED, "" + tag + " 内显式 clip-rule/fill-rule 未映射,IR 只保留 mask 几何,不保留该规则。");
@@ -6970,8 +6988,10 @@ function createSVGConversionSession(es, options) {
6970
6988
  };
6971
6989
  var appendLayer = function appendLayer(layer, element, applyElementClip) {
6972
6990
  if (applyElementClip === void 0) applyElementClip = true;
6991
+ var _options_layerSourceCollector;
6973
6992
  var clippedLayer = applyElementClip ? applyClipMask(es, element, layer, clipMasks) : layer;
6974
6993
  layers.push(withGroupParent(clippedLayer, element));
6994
+ (_options_layerSourceCollector = options.layerSourceCollector) == null ? void 0 : _options_layerSourceCollector.set(layer.id, buildElementTreePath(element.node));
6975
6995
  };
6976
6996
  var appendAsset = function appendAsset(asset) {
6977
6997
  if (registeredAssetIds.has(asset.id)) {
@@ -10379,7 +10399,7 @@ function mapFontWeight(raw, fontFamily) {
10379
10399
  seen.set(Math.round(w * 100), ch);
10380
10400
  }
10381
10401
  }
10382
- return [].concat(seen.entries()).map(function(param) {
10402
+ return Array.from(seen.entries()).map(function(param) {
10383
10403
  var k = param[0], ch = param[1];
10384
10404
  return {
10385
10405
  ch: ch,
@@ -10429,6 +10449,9 @@ function mapFontWeight(raw, fontFamily) {
10429
10449
  // latin / digit / 标点:典型比例字体 sans-serif 大写字母约 0.65em,数字稍窄。
10430
10450
  return /[0-9]/.test(ch) ? 0.55 : 0.62;
10431
10451
  }
10452
+ /** 去除单个字体族名的 CSS 字符串引号。 */ function normalizeFontFamilyName(fontFamily) {
10453
+ return fontFamily.trim().replace(/^(['"])(.*)\1$/, '$2');
10454
+ }
10432
10455
  /** 构造与 Effects Runtime getFontDesc 一致的 CSS font 简写字符串,用于 Canvas measureText。 */ function buildCanvasFontDesc(fontSize, fontFamily, fontWeight, fontStyle) {
10433
10456
  var weightStr = String(fontWeight);
10434
10457
  var genericFamilies = [
@@ -10437,7 +10460,8 @@ function mapFontWeight(raw, fontFamily) {
10437
10460
  'monospace',
10438
10461
  'courier'
10439
10462
  ];
10440
- var familyName = genericFamilies.includes(fontFamily) ? fontFamily : '"' + fontFamily + '"';
10463
+ var family = normalizeFontFamilyName(fontFamily);
10464
+ var familyName = genericFamilies.includes(family) ? family : '"' + family + '"';
10441
10465
  var desc = fontSize + "px " + familyName;
10442
10466
  if (weightStr !== 'normal' && weightStr !== '') {
10443
10467
  desc = weightStr + " " + desc;
@@ -10448,13 +10472,13 @@ function mapFontWeight(raw, fontFamily) {
10448
10472
  return desc;
10449
10473
  }
10450
10474
  /** 文本宽度估算。优先使用调用方提供的 Canvas measureText,否则使用字符级启发式系数。 */ function estimateTextWidth(content, fontSize, letterSpacing, measureText, fontFamily, fontWeight, fontStyle) {
10451
- var len = [].concat(content).length;
10475
+ var chars = Array.from(content);
10476
+ var len = chars.length;
10452
10477
  if (measureText != null && fontFamily !== '') {
10453
10478
  var fontDesc = buildCanvasFontDesc(fontSize, fontFamily, fontWeight, fontStyle);
10454
10479
  var width = measureText(fontDesc, content).width;
10455
10480
  return width + letterSpacing * Math.max(len - 1, 0);
10456
10481
  }
10457
- var chars = [].concat(content);
10458
10482
  var width1 = chars.reduce(function(s, ch) {
10459
10483
  return s + charWidthCoef(ch) * fontSize;
10460
10484
  }, 0);
@@ -12051,7 +12075,16 @@ function createSVGElementConverterRegistry(session) {
12051
12075
  }
12052
12076
 
12053
12077
  function buildSVGLayers(es, options) {
12054
- var session = createSVGConversionSession(es, options);
12078
+ var currentPath;
12079
+ var warningSourceCollector = options.warningSourceCollector;
12080
+ var session = createSVGConversionSession(es, warningSourceCollector == null ? options : _extends({}, options, {
12081
+ emit: function emit(warning) {
12082
+ if (currentPath != null) {
12083
+ warningSourceCollector.set(warning, currentPath);
12084
+ }
12085
+ options.emit(warning);
12086
+ }
12087
+ }));
12055
12088
  var converters = createSVGElementConverterRegistry(session);
12056
12089
  for(var _iterator = _create_for_of_iterator_helper_loose(session.all), _step; !(_step = _iterator()).done;){
12057
12090
  var element = _step.value;
@@ -12059,6 +12092,9 @@ function buildSVGLayers(es, options) {
12059
12092
  var _element_node_tagName, _element_node;
12060
12093
  var tag = (_ref = (_element_node = element.node) == null ? void 0 : (_element_node_tagName = _element_node.tagName) == null ? void 0 : _element_node_tagName.toLowerCase()) != null ? _ref : '';
12061
12094
  var selector = describeElement(element);
12095
+ if (warningSourceCollector != null) {
12096
+ currentPath = buildElementTreePath(element.node);
12097
+ }
12062
12098
  if (isInInactiveSwitchBranch(element)) {
12063
12099
  continue;
12064
12100
  }
@@ -12092,11 +12128,10 @@ function buildSVGLayers(es, options) {
12092
12128
 
12093
12129
  var ParseableSVG = /*#__PURE__*/ function() {
12094
12130
  function ParseableSVG(svgStr, _options) {
12095
- var _ref, _SVG;
12096
- var _svgStr_match;
12097
- // 从字符串里抠出首个 <svg>...</svg> 再交给 svg.js(兼容前导注释/doctype)。
12131
+ var _SVG;
12132
+ // svg.js parses a fragment; remove only the prolog and let the DOM handle nested markup.
12133
+ var content = svgStr.replace(/^\uFEFF/, '').replace(/^(?:\s|<\?xml\b[\s\S]*?\?>|<!DOCTYPE\b[^>]*>|<!--[\s\S]*?-->)+/i, '');
12098
12134
  // svg.js SVG(string) 的 d.ts 标为 Element,但对完整 <svg> 文档运行时返回根 SVG 文档实例。
12099
- var content = typeof svgStr === 'string' ? (_ref = (_svgStr_match = svgStr.match(RegExp("<svg\\s+.*?>.*?<\\/svg>", "s"))) == null ? void 0 : _svgStr_match[0]) != null ? _ref : svgStr : svgStr;
12100
12135
  // svg.js 对非 SVG 字符串(如 'not svg')解析返 null。兜底空 svg:让 svg2ir 上层
12101
12136
  // hasSVGRootElement 检查(非 svg 抛 INVALID_SVG)生效,而非在构造期抛错。
12102
12137
  this.svg = (_SVG = svg_js.SVG(content)) != null ? _SVG : svg_js.SVG('<svg xmlns="http://www.w3.org/2000/svg"/>');
@@ -12299,6 +12334,8 @@ function parseSVGToIRScene(svgString, options) {
12299
12334
  value: scannedSmilDuration
12300
12335
  };
12301
12336
  var layerBuildOptions = {
12337
+ layerSourceCollector: options == null ? void 0 : options.layerSourceCollector,
12338
+ warningSourceCollector: options == null ? void 0 : options.warningSourceCollector,
12302
12339
  frameRate: frameRate,
12303
12340
  durationSeconds: effectiveDuration,
12304
12341
  emit: emit,
@@ -12478,6 +12515,8 @@ function parseSVGToIRWithPreservedData(source, options, collectors) {
12478
12515
  var svgString = readSVGString(source);
12479
12516
  var irScene = parseSVGToIRScene(svgString, _extends({}, options, {
12480
12517
  onWarning: emitWarning,
12518
+ layerSourceCollector: collectors == null ? void 0 : collectors.layerSourceCollector,
12519
+ warningSourceCollector: collectors == null ? void 0 : collectors.warningSourceCollector,
12481
12520
  textDataCollector: collectors == null ? void 0 : collectors.textDataByLayerId,
12482
12521
  paintAnimationsCollector: collectors == null ? void 0 : collectors.paintAnimationsByLayerId,
12483
12522
  shapeAnimationCollector: collectors == null ? void 0 : collectors.shapeAnimationsByLayerId
@@ -12653,7 +12692,8 @@ function collectLayerWarning(warnings, options, code, message, selector) {
12653
12692
  });
12654
12693
  warnings.push(warning);
12655
12694
  options.onWarning == null ? void 0 : options.onWarning.call(options, warning);
12656
- if (options.strict === true && code !== SVG2IR_WARNING_CODES.LAYERS_TEXT_BOUNDS_ESTIMATED) {
12695
+ var advisory = code === SVG2IR_WARNING_CODES.LAYERS_TEXT_BOUNDS_ESTIMATED || code === SVG2IR_WARNING_CODES.LAYERS_GRAPHIC_BAKED;
12696
+ if (options.strict === true && !advisory) {
12657
12697
  throw new SVGConverterError(SVG_CONVERTER_ERROR_CODES.LAYERS_CONVERSION_FAILED, warning.message, {
12658
12698
  stage: 'layers',
12659
12699
  sourceId: selector,
@@ -12978,9 +13018,12 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
12978
13018
  // 分段文字使用统一参考字号度量字宽和字体边界,再按片段字号缩放。
12979
13019
  var measurementSize = segmented ? 10 : run.fontSize;
12980
13020
  var scale = run.fontSize / measurementSize;
12981
- var font = (run.italic ? 'italic' : 'normal') + " " + (run.bold ? 'bold' : 'normal') + " " + measurementSize + "px" + (' "' + family + '"');
13021
+ var weight = run.bold ? 'bold' : 'normal';
13022
+ var style = run.italic ? 'italic' : 'normal';
13023
+ var font = buildCanvasFontDesc(measurementSize, family, weight, style);
12982
13024
  var metrics = conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, font, segmented ? 'x' : run.text);
12983
- var chunks = segmented ? run.text.split('') : [
13025
+ var characters = Array.from(run.text);
13026
+ var chunks = segmented ? characters : [
12984
13027
  run.text
12985
13028
  ];
12986
13029
  var advance = 0;
@@ -12989,12 +13032,13 @@ function buildTextRunLayout(runs, family, spacing, content, size, conversionOpti
12989
13032
  var width = segmented ? conversionOptions.measureText == null ? void 0 : conversionOptions.measureText.call(conversionOptions, font, chunk).width : metrics == null ? void 0 : metrics.width;
12990
13033
  var valid = width != null && Number.isFinite(width) && width >= 0;
12991
13034
  estimated || (estimated = !valid);
12992
- advance += valid ? width : Array.from(chunk).length * measurementSize * 0.6;
13035
+ advance += valid ? width : estimateTextWidth(chunk, measurementSize, 0, undefined, family, weight, style);
12993
13036
  }
12994
- var characterCount = segmented ? run.text.length : Array.from(run.text).length;
13037
+ var characterCount = characters.length;
12995
13038
  var width1 = advance * scale + Math.max(0, characterCount - 1) * spacing;
12996
- var ascent = (metrics == null ? void 0 : metrics.fontBoundingBoxAscent) == null ? run.fontSize * 0.8 : metrics.fontBoundingBoxAscent * scale;
12997
- var descent = (metrics == null ? void 0 : metrics.fontBoundingBoxDescent) == null ? run.fontSize * 0.2 : metrics.fontBoundingBoxDescent * scale;
13039
+ var fallback = resolveFontMetrics(undefined, family, weight, style, run.fontSize);
13040
+ var ascent = (metrics == null ? void 0 : metrics.fontBoundingBoxAscent) == null ? fallback.asc : metrics.fontBoundingBoxAscent * scale;
13041
+ var descent = (metrics == null ? void 0 : metrics.fontBoundingBoxDescent) == null ? fallback.desc : metrics.fontBoundingBoxDescent * scale;
12998
13042
  estimated || (estimated = (metrics == null ? void 0 : metrics.fontBoundingBoxAscent) == null || metrics.fontBoundingBoxDescent == null);
12999
13043
  if (!Number.isFinite(width1) || width1 < 0 || !Number.isFinite(ascent) || !Number.isFinite(descent)) {
13000
13044
  throwInvalidLayerData('Text measurement returned invalid metrics.');
@@ -13141,6 +13185,7 @@ function convertIRTextLayer(layer, state, session, id) {
13141
13185
  content: part.run.text,
13142
13186
  bbox: mapPointsToBBox(polygon),
13143
13187
  polygon: polygon,
13188
+ // Keep the authored font-family string, quotes included; consumers resolve families themselves.
13144
13189
  font_family: font.family,
13145
13190
  font_size: roundPixel(part.run.fontSize * scaleY),
13146
13191
  color: part.run.color,
@@ -13185,6 +13230,41 @@ function createLayerConverterRegistry(session) {
13185
13230
  ]);
13186
13231
  }
13187
13232
 
13233
+ /** 完全覆盖图片的直边矩形 mask 不改变可见内容。 */ function maskCoversImage(mask, bounds) {
13234
+ var _Math, _Math1, _Math2, _Math3;
13235
+ var path = mask.path;
13236
+ var epsilon = 1e-6;
13237
+ if (mask.mode === 'subtract' || mask.inverted === true || !path.closed || path.points.length !== 4) {
13238
+ return false;
13239
+ }
13240
+ if (path.inTangents.length !== 4 || path.outTangents.length !== 4 || [].concat(path.inTangents, path.outTangents).some(function(tangent) {
13241
+ return tangent.x !== 0 || tangent.y !== 0;
13242
+ })) {
13243
+ return false;
13244
+ }
13245
+ var straightEdges = path.points.every(function(point, index) {
13246
+ var next = path.points[(index + 1) % 4];
13247
+ var opposite = path.points[(index + 2) % 4];
13248
+ var dx = Math.abs(next.x - point.x);
13249
+ var dy = Math.abs(next.y - point.y);
13250
+ return Number.isFinite(point.x) && Number.isFinite(point.y) && Math.abs(opposite.x - point.x) > epsilon && Math.abs(opposite.y - point.y) > epsilon && (dx <= epsilon && dy > epsilon || dy <= epsilon && dx > epsilon);
13251
+ });
13252
+ if (!straightEdges) {
13253
+ return false;
13254
+ }
13255
+ var xs = path.points.map(function(point) {
13256
+ return point.x;
13257
+ });
13258
+ var ys = path.points.map(function(point) {
13259
+ return point.y;
13260
+ });
13261
+ var left = (_Math = Math).min.apply(_Math, [].concat(xs));
13262
+ var right = (_Math1 = Math).max.apply(_Math1, [].concat(xs));
13263
+ var top = (_Math2 = Math).min.apply(_Math2, [].concat(ys));
13264
+ var bottom = (_Math3 = Math).max.apply(_Math3, [].concat(ys));
13265
+ return bounds.width > 0 && bounds.height > 0 && left <= bounds.x + epsilon && right >= bounds.x + bounds.width - epsilon && top <= bounds.y + epsilon && bottom >= bounds.y + bounds.height - epsilon;
13266
+ }
13267
+
13188
13268
  function resolveIRVisualState(layer, session) {
13189
13269
  if (!layer.visible) {
13190
13270
  return undefined;
@@ -13193,19 +13273,20 @@ function resolveIRVisualState(layer, session) {
13193
13273
  if (!state.visible || state.opacity <= 0) {
13194
13274
  return undefined;
13195
13275
  }
13196
- if (layer.mask != null || layer.matte != null) {
13276
+ var unsupportedMask = layer.mask != null && (layer.type !== 'image' || !maskCoversImage(layer.mask, layer.localBounds));
13277
+ if (unsupportedMask || layer.matte != null) {
13197
13278
  throwUnsupportedLayerFeature('Mask or clipping is not supported by the flat layer protocol.');
13198
13279
  }
13199
13280
  if (Math.abs(state.opacity - 1) > 1e-6) {
13200
13281
  throwUnsupportedLayerFeature('Layer opacity cannot be expressed by the target protocol.');
13201
13282
  }
13202
13283
  if (layer.blendMode != null && layer.blendMode !== animationIr.IRBlendMode.Normal) {
13203
- throwUnsupportedLayerFeature('Non-default blending cannot be expressed by the target protocol.');
13284
+ collectLayerWarning(session.warnings, session.options, SVG2IR_WARNING_CODES.LAYERS_BLEND_MODE_DOWNGRADED, 'Blend mode "' + String(layer.blendMode) + '" was downgraded to "normal"; the layer is retained.', layer.id);
13204
13285
  }
13205
13286
  return state;
13206
13287
  }
13207
13288
 
13208
- function buildIRStaticLayers(session) {
13289
+ function buildIRStaticLayers(session, sourceIds) {
13209
13290
  var composition = session.composition, maskSourceIds = session.maskSourceIds, options = session.options, warnings = session.warnings;
13210
13291
  var registry = createLayerConverterRegistry(session);
13211
13292
  var result = [];
@@ -13230,6 +13311,7 @@ function buildIRStaticLayers(session) {
13230
13311
  var converted = converter.convert(layer, state, converter.layerType + "_" + String(index).padStart(4, '0'));
13231
13312
  if (converted != null) {
13232
13313
  result.push(converted);
13314
+ sourceIds == null ? void 0 : sourceIds.set(converted, layer.id);
13233
13315
  layerCounts.set(converter.layerType, index);
13234
13316
  }
13235
13317
  } catch (error) {
@@ -13242,9 +13324,9 @@ function buildIRStaticLayers(session) {
13242
13324
  return result;
13243
13325
  }
13244
13326
 
13245
- function assembleSVGStaticLayers(scene, options, warnings, preservedData) {
13327
+ function assembleSVGStaticLayers(scene, options, warnings, preservedData, sourceIds) {
13246
13328
  var session = buildLayerConversionSession(scene, options, warnings, preservedData);
13247
- var data = buildIRStaticLayers(session);
13329
+ var data = buildIRStaticLayers(session, sourceIds);
13248
13330
  var composition = session.composition;
13249
13331
  if (composition.backgroundColor != null) {
13250
13332
  collectLayerWarning(warnings, options, SVG2IR_WARNING_CODES.LAYERS_UNSUPPORTED_TYPE, 'Composition background color is not an image or text layer.');
@@ -13257,6 +13339,1034 @@ function assembleSVGStaticLayers(scene, options, warnings, preservedData) {
13257
13339
  data: data
13258
13340
  };
13259
13341
  }
13342
+ /** Replace baked sources, combine native and raster layers in painter order, then report final diagnostics. */ function assembleSVGLayers(input) {
13343
+ 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) {
13346
+ return !baking.resolvesWarning(warning, warningSources.get(warning));
13347
+ });
13348
+ var composition = adapter.getIRSceneEntryComposition(scene);
13349
+ var nativeScene = _extends({}, scene, {
13350
+ compositions: scene.compositions.map(function(candidate) {
13351
+ return candidate === composition ? _extends({}, candidate, {
13352
+ layers: candidate.layers.filter(function(layer) {
13353
+ return !baking.replacesSource(layerSources.get(layer.id));
13354
+ })
13355
+ }) : candidate;
13356
+ })
13357
+ });
13358
+ var sourceIds = new Map();
13359
+ (_warnings = warnings).push.apply(_warnings, [].concat(baking.warnings));
13360
+ var native = assembleSVGStaticLayers(nativeScene, _extends({}, options, {
13361
+ strict: false,
13362
+ onWarning: undefined
13363
+ }), warnings, preservedData, sourceIds);
13364
+ var ordered = native.data.map(function(layer) {
13365
+ var _layerSources_get, _sourceIds_get;
13366
+ return {
13367
+ path: (_layerSources_get = layerSources.get((_sourceIds_get = sourceIds.get(layer)) != null ? _sourceIds_get : '')) != null ? _layerSources_get : '',
13368
+ layer: layer
13369
+ };
13370
+ });
13371
+ (_ordered = ordered).push.apply(_ordered, [].concat(baking.layers));
13372
+ ordered.sort(function(left, right) {
13373
+ return comparePaths(left.path, right.path);
13374
+ });
13375
+ var counts = {
13376
+ image: 0,
13377
+ text: 0
13378
+ };
13379
+ var data = ordered.map(function(param) {
13380
+ var layer = param.layer;
13381
+ return _extends({}, layer, {
13382
+ id: layer.type + "_" + String(++counts[layer.type]).padStart(4, '0')
13383
+ });
13384
+ });
13385
+ for(var _iterator = _create_for_of_iterator_helper_loose(warnings), _step; !(_step = _iterator()).done;){
13386
+ var warning = _step.value;
13387
+ options.onWarning == null ? void 0 : options.onWarning.call(options, warning);
13388
+ if (options.strict === true) {
13389
+ var message = warning.message.replace(/^\[svg2ge:layers\] /, '');
13390
+ collectLayerWarning([], _extends({}, options, {
13391
+ onWarning: undefined
13392
+ }), warning.code, message, warning.elementSelector);
13393
+ }
13394
+ }
13395
+ return {
13396
+ size: native.size,
13397
+ data: data,
13398
+ warnings: warnings
13399
+ };
13400
+ }
13401
+ function comparePaths(left, right) {
13402
+ var a = left.split('/').map(Number);
13403
+ var b = right.split('/').map(Number);
13404
+ for(var index = 0; index < Math.min(a.length, b.length); index++){
13405
+ if (a[index] !== b[index]) {
13406
+ return a[index] - b[index];
13407
+ }
13408
+ }
13409
+ return a.length - b.length;
13410
+ }
13411
+
13412
+ var animatedElements = new Set([
13413
+ 'animate',
13414
+ 'animatetransform',
13415
+ 'animatemotion',
13416
+ 'set'
13417
+ ]);
13418
+ var declarations$1 = new Set([
13419
+ 'defs',
13420
+ 'style',
13421
+ 'title',
13422
+ 'desc',
13423
+ 'metadata',
13424
+ 'symbol',
13425
+ 'clippath',
13426
+ 'mask',
13427
+ 'filter',
13428
+ 'lineargradient',
13429
+ 'radialgradient',
13430
+ 'pattern',
13431
+ 'marker'
13432
+ ]);
13433
+ /** Preserve selector context until styles are frozen, then isolate the requested paint subtree. */ function prepareSVGSnapshot(source, path, size, inspect) {
13434
+ var parsed = new DOMParser().parseFromString(source, 'image/svg+xml');
13435
+ if (parsed.querySelector('parsererror') != null) {
13436
+ throw new Error('Invalid SVG document.');
13437
+ }
13438
+ var root = parsed.documentElement;
13439
+ var elements = [].concat([
13440
+ root
13441
+ ], Array.from(root.querySelectorAll('*')));
13442
+ var selected = elements.find(function(element) {
13443
+ return buildElementTreePath(element) === path;
13444
+ });
13445
+ if (selected == null) {
13446
+ throw new Error('The graphic source element could not be located.');
13447
+ }
13448
+ if (root.querySelector('script, foreignObject') != null) {
13449
+ throw new Error('Scripts and foreignObject are outside static graphic baking support.');
13450
+ }
13451
+ if (Array.from(root.querySelectorAll('style')).some(function(element) {
13452
+ var _element_textContent;
13453
+ return /@import|@font-face/i.test((_element_textContent = element.textContent) != null ? _element_textContent : '');
13454
+ })) {
13455
+ throw new Error('External stylesheets and fonts require explicit resource preparation.');
13456
+ }
13457
+ for(var _iterator = _create_for_of_iterator_helper_loose(elements), _step; !(_step = _iterator()).done;){
13458
+ var element = _step.value;
13459
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(element.attributes)), _step1; !(_step1 = _iterator1()).done;){
13460
+ var attribute = _step1.value;
13461
+ if (/^on/i.test(attribute.name)) {
13462
+ element.removeAttributeNode(attribute);
13463
+ }
13464
+ }
13465
+ }
13466
+ var frame = document.createElement('iframe');
13467
+ frame.setAttribute('sandbox', 'allow-same-origin');
13468
+ frame.style.cssText = "position:fixed;left:-100000px;top:0;width:" + size[0] + "px;height:" + size[1] + "px;border:0;";
13469
+ document.body.appendChild(frame);
13470
+ try {
13471
+ var _loop = function() {
13472
+ var element = _step3.value;
13473
+ var _element_getAttribute;
13474
+ var computed = frameWindow.getComputedStyle(element);
13475
+ var inside = target.contains(element);
13476
+ var ancestor = element !== target && element.contains(target);
13477
+ if ((inside || ancestor) && (computed.animationName !== 'none' || hasAnimationChildren(element))) {
13478
+ throw new Error('Animated graphics require an explicit sampling policy.');
13479
+ }
13480
+ // Freezing inherited defaults on a definition changes <use> instance inheritance.
13481
+ // Freeze only authored declarations, after matching selectors in the intact source tree.
13482
+ var authored = frameDocument.createElement('div').style;
13483
+ authored.cssText = (_element_getAttribute = element.getAttribute('style')) != null ? _element_getAttribute : '';
13484
+ var names = new Set(Array.from(authored));
13485
+ for(var _iterator = _create_for_of_iterator_helper_loose(styleRules), _step; !(_step = _iterator()).done;){
13486
+ var rule = _step.value;
13487
+ if (element.matches(rule.selectorText)) {
13488
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(rule.style)), _step1; !(_step1 = _iterator1()).done;){
13489
+ var name = _step1.value;
13490
+ names.add(name);
13491
+ }
13492
+ }
13493
+ }
13494
+ var properties = Array.from(names, function(name) {
13495
+ var value = computed.getPropertyValue(name);
13496
+ value = value.replace(/url\(["']?([^)'"\s]+)["']?\)/g, function(_match, url) {
13497
+ return 'url("' + normalizeReference(url) + '")';
13498
+ });
13499
+ return name + ":" + value + " !important;";
13500
+ });
13501
+ var isTemplate = templateRoots.some(function(template) {
13502
+ return template.contains(element);
13503
+ });
13504
+ frozenStyles.push(isTemplate ? null : properties.join(''));
13505
+ };
13506
+ var frameDocument = frame.contentDocument;
13507
+ var frameWindow = frame.contentWindow;
13508
+ if (frameDocument == null || frameWindow == null) {
13509
+ throw new Error('Unable to create isolated SVG context.');
13510
+ }
13511
+ frameDocument.body.style.cssText = 'margin:0;';
13512
+ var mounted = frameDocument.importNode(root, true);
13513
+ mounted.setAttribute('width', String(size[0]));
13514
+ mounted.setAttribute('height', String(size[1]));
13515
+ frameDocument.body.appendChild(mounted);
13516
+ var mountedElements = [].concat([
13517
+ mounted
13518
+ ], Array.from(mounted.querySelectorAll('*')));
13519
+ var selectedIndex = elements.indexOf(selected);
13520
+ var target = mountedElements[selectedIndex];
13521
+ var normalizeReference = function normalizeReference(url) {
13522
+ if (url.startsWith('#')) {
13523
+ return url;
13524
+ }
13525
+ var hash = url.indexOf('#');
13526
+ if (hash >= 0 && url.slice(0, hash) === frameDocument.baseURI.split('#')[0]) {
13527
+ return url.slice(hash);
13528
+ }
13529
+ throw new Error('External paint resources require explicit resource preparation.');
13530
+ };
13531
+ var frozenStyles = [];
13532
+ var templateRoots = Array.from(mounted.querySelectorAll('use')).flatMap(function(element) {
13533
+ var _ref, _element_getAttribute;
13534
+ var href = (_ref = (_element_getAttribute = element.getAttribute('href')) != null ? _element_getAttribute : element.getAttribute('xlink:href')) != null ? _ref : '';
13535
+ var template = href.startsWith('#') ? mountedElements.find(function(candidate) {
13536
+ return candidate.id === href.slice(1);
13537
+ }) : null;
13538
+ return template == null ? [] : [
13539
+ template
13540
+ ];
13541
+ });
13542
+ var styleRules = [];
13543
+ var collectRules = function collectRules1(rules) {
13544
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(rules)), _step; !(_step = _iterator()).done;){
13545
+ var rule = _step.value;
13546
+ if (isStyleRule$2(rule)) {
13547
+ styleRules.push(rule);
13548
+ } else if (hasNestedRules$1(rule)) {
13549
+ if (isMediaRule(rule) && !frameWindow.matchMedia(rule.conditionText).matches) {
13550
+ continue;
13551
+ }
13552
+ collectRules(rule.cssRules);
13553
+ }
13554
+ }
13555
+ };
13556
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(Array.from(frameDocument.styleSheets)), _step2; !(_step2 = _iterator2()).done;){
13557
+ var sheet = _step2.value;
13558
+ collectRules(sheet.cssRules);
13559
+ }
13560
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(mountedElements), _step3; !(_step3 = _iterator3()).done;)_loop();
13561
+ for(var index = 0; index < mountedElements.length; index++){
13562
+ var style = frozenStyles[index];
13563
+ if (style != null) {
13564
+ mountedElements[index].setAttribute('style', style);
13565
+ }
13566
+ }
13567
+ var byId = new Map(mountedElements.filter(function(element) {
13568
+ return element.id !== '';
13569
+ }).map(function(element) {
13570
+ return [
13571
+ element.id,
13572
+ element
13573
+ ];
13574
+ }));
13575
+ var seen = new Set();
13576
+ var checkDependencies = function checkDependencies1(element) {
13577
+ if (seen.has(element)) {
13578
+ return;
13579
+ }
13580
+ seen.add(element);
13581
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(element.attributes)), _step; !(_step = _iterator()).done;){
13582
+ var attribute = _step.value;
13583
+ if (attribute.localName === 'href' && element.tagName.toLowerCase() === 'a') {
13584
+ continue;
13585
+ }
13586
+ if (attribute.localName === 'href' && !attribute.value.startsWith('#') && !([
13587
+ 'image',
13588
+ 'feimage'
13589
+ ].includes(element.tagName.toLowerCase()) && /^data:image\//i.test(attribute.value))) {
13590
+ throw new Error('External SVG references require explicit resource preparation.');
13591
+ }
13592
+ var normalized = attribute.value.replace(/url\(\s*["']?([^)'"\s]+)["']?\s*\)/g, function(_match, url) {
13593
+ return 'url("' + normalizeReference(url) + '")';
13594
+ });
13595
+ var ids = Array.from(normalized.matchAll(/url\(["']?#([^)'"\s]+)["']?\)/g), function(match) {
13596
+ return match[1];
13597
+ });
13598
+ if (normalized !== attribute.value) {
13599
+ element.setAttribute(attribute.name, normalized);
13600
+ }
13601
+ if (attribute.localName === 'href' && attribute.value.startsWith('#')) {
13602
+ ids.push(attribute.value.slice(1));
13603
+ }
13604
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(ids), _step1; !(_step1 = _iterator1()).done;){
13605
+ var id = _step1.value;
13606
+ var dependency = byId.get(id);
13607
+ if (dependency == null) {
13608
+ throw new Error("Missing SVG reference: #" + id + ".");
13609
+ }
13610
+ checkDependencies(dependency);
13611
+ }
13612
+ }
13613
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(Array.from(element.children)), _step2; !(_step2 = _iterator2()).done;){
13614
+ var child = _step2.value;
13615
+ if (!declarations$1.has(child.tagName.toLowerCase())) {
13616
+ checkDependencies(child);
13617
+ }
13618
+ }
13619
+ };
13620
+ checkDependencies(target);
13621
+ for(var _iterator4 = _create_for_of_iterator_helper_loose(seen), _step4; !(_step4 = _iterator4()).done;){
13622
+ var dependency = _step4.value;
13623
+ if (frameWindow.getComputedStyle(dependency).animationName !== 'none' || hasAnimationChildren(dependency)) {
13624
+ throw new Error('Animated graphics require an explicit sampling policy.');
13625
+ }
13626
+ }
13627
+ inspect == null ? void 0 : inspect({
13628
+ root: mounted,
13629
+ target: target,
13630
+ elements: mountedElements,
13631
+ dependencies: seen,
13632
+ readStyle: function readStyle(element) {
13633
+ return frameWindow.getComputedStyle(element);
13634
+ }
13635
+ });
13636
+ var isolate = function isolate1(element) {
13637
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(element.children)), _step; !(_step = _iterator()).done;){
13638
+ var child = _step.value;
13639
+ var tag = child.tagName.toLowerCase();
13640
+ if (declarations$1.has(tag) || child === target || target.contains(child)) {
13641
+ continue;
13642
+ }
13643
+ if (child.contains(target)) {
13644
+ isolate(child);
13645
+ } else {
13646
+ var definitions = frameDocument.createElementNS('http://www.w3.org/2000/svg', 'defs');
13647
+ child.replaceWith(definitions);
13648
+ definitions.appendChild(child);
13649
+ }
13650
+ }
13651
+ };
13652
+ if (target !== mounted) {
13653
+ isolate(mounted);
13654
+ }
13655
+ return new XMLSerializer().serializeToString(mounted);
13656
+ } finally{
13657
+ frame.remove();
13658
+ }
13659
+ }
13660
+ /** Only animations attached to this element reject its own bake scope, not unrelated subtrees. */ function hasAnimationChildren(element) {
13661
+ return Array.from(element.children).some(function(child) {
13662
+ return animatedElements.has(child.tagName.toLowerCase());
13663
+ });
13664
+ }
13665
+ function isStyleRule$2(rule) {
13666
+ return rule.type === 1;
13667
+ }
13668
+ function hasNestedRules$1(rule) {
13669
+ return 'cssRules' in rule;
13670
+ }
13671
+ function isMediaRule(rule) {
13672
+ return rule.type === 4;
13673
+ }
13674
+
13675
+ /** Render an SVG subtree as a cropped PNG, or return null if it has no visible pixels. */ function rasterizeSVG(source, path, size, scale, inspect) {
13676
+ if (scale === void 0) scale = 2;
13677
+ return _async_to_generator(function() {
13678
+ var snapshot, canvas;
13679
+ return _ts_generator(this, function(_state) {
13680
+ switch(_state.label){
13681
+ case 0:
13682
+ if (!Number.isFinite(scale) || scale <= 0) {
13683
+ throw new RangeError('rasterScale must be finite and positive.');
13684
+ }
13685
+ if (Math.ceil(size[0] * scale) * Math.ceil(size[1] * scale) > 16777216) {
13686
+ throw new RangeError('SVG rasterization exceeds the 16 megapixel working limit; reduce rasterScale.');
13687
+ }
13688
+ snapshot = prepareSVGSnapshot(source, path, size, inspect);
13689
+ return [
13690
+ 4,
13691
+ renderSVG(snapshot, size, scale)
13692
+ ];
13693
+ case 1:
13694
+ canvas = _state.sent();
13695
+ return [
13696
+ 2,
13697
+ cropRasterImage(canvas, scale)
13698
+ ];
13699
+ }
13700
+ });
13701
+ })();
13702
+ }
13703
+ /** No DOM access at module initialization: the Node entry also imports this module. */ function canRasterizeSVG() {
13704
+ return typeof window !== 'undefined' && typeof document !== 'undefined' && typeof window.HTMLCanvasElement === 'function' && typeof window.Image === 'function' && typeof window.getComputedStyle === 'function';
13705
+ }
13706
+ function renderSVG(svg, size, scale) {
13707
+ return _async_to_generator(function() {
13708
+ var canvas, context, image, url;
13709
+ return _ts_generator(this, function(_state) {
13710
+ switch(_state.label){
13711
+ case 0:
13712
+ canvas = document.createElement('canvas');
13713
+ canvas.width = Math.ceil(size[0] * scale);
13714
+ canvas.height = Math.ceil(size[1] * scale);
13715
+ context = canvas.getContext('2d');
13716
+ if (context == null) {
13717
+ throw new Error('A 2D canvas context is required for SVG rasterization.');
13718
+ }
13719
+ image = new Image();
13720
+ url = URL.createObjectURL(new Blob([
13721
+ svg
13722
+ ], {
13723
+ type: 'image/svg+xml'
13724
+ }));
13725
+ _state.label = 1;
13726
+ case 1:
13727
+ _state.trys.push([
13728
+ 1,
13729
+ ,
13730
+ 3,
13731
+ 4
13732
+ ]);
13733
+ return [
13734
+ 4,
13735
+ new Promise(function(resolve, reject) {
13736
+ image.onload = function() {
13737
+ return resolve();
13738
+ };
13739
+ image.onerror = function() {
13740
+ return reject(new Error('The prepared SVG could not be decoded.'));
13741
+ };
13742
+ image.src = url;
13743
+ })
13744
+ ];
13745
+ case 2:
13746
+ _state.sent();
13747
+ context.drawImage(image, 0, 0, canvas.width, canvas.height);
13748
+ return [
13749
+ 2,
13750
+ canvas
13751
+ ];
13752
+ case 3:
13753
+ URL.revokeObjectURL(url);
13754
+ return [
13755
+ 7
13756
+ ];
13757
+ case 4:
13758
+ return [
13759
+ 2
13760
+ ];
13761
+ }
13762
+ });
13763
+ })();
13764
+ }
13765
+ /** Trim transparent pixels after rendering, retaining strokes, blur and filter extents. */ function cropRasterImage(canvas, scale) {
13766
+ var context = canvas.getContext('2d');
13767
+ if (context == null) {
13768
+ throw new Error('A 2D canvas context is required for SVG rasterization.');
13769
+ }
13770
+ var data = context.getImageData(0, 0, canvas.width, canvas.height).data;
13771
+ var left = canvas.width;
13772
+ var top = canvas.height;
13773
+ var right = 0;
13774
+ var bottom = 0;
13775
+ for(var y = 0; y < canvas.height; y++){
13776
+ for(var x = 0; x < canvas.width; x++){
13777
+ if (data[(y * canvas.width + x) * 4 + 3] === 0) {
13778
+ continue;
13779
+ }
13780
+ left = Math.min(left, x);
13781
+ top = Math.min(top, y);
13782
+ right = Math.max(right, x + 1);
13783
+ bottom = Math.max(bottom, y + 1);
13784
+ }
13785
+ }
13786
+ if (right <= left || bottom <= top) {
13787
+ return null;
13788
+ }
13789
+ var cropped = document.createElement('canvas');
13790
+ cropped.width = right - left;
13791
+ cropped.height = bottom - top;
13792
+ var croppedContext = cropped.getContext('2d');
13793
+ if (croppedContext == null) {
13794
+ throw new Error('A 2D canvas context is required for SVG rasterization.');
13795
+ }
13796
+ croppedContext.drawImage(canvas, left, top, cropped.width, cropped.height, 0, 0, cropped.width, cropped.height);
13797
+ return {
13798
+ url: cropped.toDataURL('image/png'),
13799
+ bbox: [
13800
+ left / scale,
13801
+ top / scale,
13802
+ right / scale,
13803
+ bottom / scale
13804
+ ]
13805
+ };
13806
+ }
13807
+
13808
+ var normalValues = new Set([
13809
+ 'normal',
13810
+ 'initial',
13811
+ 'inherit',
13812
+ 'unset',
13813
+ 'revert',
13814
+ 'revert-layer'
13815
+ ]);
13816
+ /** Replace non-normal mix-blend-mode declarations with normal and report each downgrade. */ function normalizeLayerBlending(source) {
13817
+ var _loop = function() {
13818
+ var element = _step.value;
13819
+ var _element_getAttribute;
13820
+ var _readPresentationAttribute;
13821
+ var tag = element.tagName.toLowerCase();
13822
+ var id = (_element_getAttribute = element.getAttribute('id')) != null ? _element_getAttribute : '';
13823
+ var selector = id === '' ? tag : tag + "#" + id;
13824
+ var mode = (_readPresentationAttribute = readPresentationAttribute(element, 'mix-blend-mode')) == null ? void 0 : _readPresentationAttribute.replace(/\/\*[\s\S]*?\*\//g, '').trim();
13825
+ if (mode != null && !normalValues.has(mode.toLowerCase())) {
13826
+ downgrades.push({
13827
+ mode: mode,
13828
+ selector: selector
13829
+ });
13830
+ }
13831
+ var style = element.getAttribute('style');
13832
+ if (style != null) {
13833
+ var normalized = normalizeBlendDeclarations(style);
13834
+ if (normalized !== style) {
13835
+ element.setAttribute('style', normalized);
13836
+ changed = true;
13837
+ }
13838
+ }
13839
+ var attribute = element.getAttribute('mix-blend-mode');
13840
+ if (attribute != null && !normalValues.has(attribute.trim().toLowerCase())) {
13841
+ element.setAttribute('mix-blend-mode', 'normal');
13842
+ changed = true;
13843
+ }
13844
+ if (tag === 'style') {
13845
+ var _element_textContent;
13846
+ var text = (_element_textContent = element.textContent) != null ? _element_textContent : '';
13847
+ var normalized1 = normalizeBlendDeclarations(text, function(value) {
13848
+ return downgrades.push({
13849
+ mode: value,
13850
+ selector: selector
13851
+ });
13852
+ });
13853
+ if (normalized1 !== text) {
13854
+ element.textContent = normalized1;
13855
+ changed = true;
13856
+ }
13857
+ }
13858
+ };
13859
+ var svg = svg_js.SVG(source);
13860
+ var downgrades = [];
13861
+ var changed = false;
13862
+ for(var _iterator = _create_for_of_iterator_helper_loose([].concat([
13863
+ svg.node
13864
+ ], Array.from(svg.node.querySelectorAll('*')))), _step; !(_step = _iterator()).done;)_loop();
13865
+ return {
13866
+ source: changed ? svg.svg() : source,
13867
+ downgrades: downgrades
13868
+ };
13869
+ }
13870
+ /** Match declaration boundaries without changing strings, comments or function arguments. */ function normalizeBlendDeclarations(source, onDowngrade) {
13871
+ var replacements = [];
13872
+ var start = 0;
13873
+ var colon = -1;
13874
+ var parentheses = 0;
13875
+ var quote;
13876
+ var comment = false;
13877
+ var finish = function finish(end) {
13878
+ if (colon < start) {
13879
+ return;
13880
+ }
13881
+ var name = source.slice(start, colon).replace(/\/\*[\s\S]*?\*\//g, '').trim().toLowerCase();
13882
+ if (name !== 'mix-blend-mode') {
13883
+ return;
13884
+ }
13885
+ var value = source.slice(colon + 1, end).replace(/\/\*[\s\S]*?\*\//g, '').trim();
13886
+ var mode = value.replace(/\s*!important\s*$/i, '').trim();
13887
+ if (mode === '' || normalValues.has(mode.toLowerCase())) {
13888
+ return;
13889
+ }
13890
+ onDowngrade == null ? void 0 : onDowngrade(mode);
13891
+ replacements.push({
13892
+ start: colon + 1,
13893
+ end: end,
13894
+ value: /!important\s*$/i.test(value) ? ' normal !important' : ' normal'
13895
+ });
13896
+ };
13897
+ for(var index = 0; index < source.length; index++){
13898
+ var character = source[index];
13899
+ var next = source[index + 1];
13900
+ if (comment) {
13901
+ if (character === '*' && next === '/') {
13902
+ comment = false;
13903
+ index++;
13904
+ }
13905
+ continue;
13906
+ }
13907
+ if (quote != null) {
13908
+ if (character === '\\') {
13909
+ index++;
13910
+ } else if (character === quote) {
13911
+ quote = undefined;
13912
+ }
13913
+ continue;
13914
+ }
13915
+ if (character === '/' && next === '*') {
13916
+ comment = true;
13917
+ index++;
13918
+ continue;
13919
+ }
13920
+ if (character === '"' || character === "'") {
13921
+ quote = character;
13922
+ continue;
13923
+ }
13924
+ if (character === '(') {
13925
+ parentheses++;
13926
+ continue;
13927
+ }
13928
+ if (character === ')') {
13929
+ parentheses = Math.max(0, parentheses - 1);
13930
+ continue;
13931
+ }
13932
+ if (parentheses > 0) {
13933
+ continue;
13934
+ }
13935
+ if (character === ':' && colon < start) {
13936
+ colon = index;
13937
+ }
13938
+ if (character === ';' || character === '}' || character === '{') {
13939
+ if (character !== '{') {
13940
+ finish(index);
13941
+ }
13942
+ start = index + 1;
13943
+ colon = -1;
13944
+ }
13945
+ }
13946
+ finish(source.length);
13947
+ var result = '';
13948
+ var cursor = 0;
13949
+ for(var _iterator = _create_for_of_iterator_helper_loose(replacements), _step; !(_step = _iterator()).done;){
13950
+ var replacement = _step.value;
13951
+ result += source.slice(cursor, replacement.start) + replacement.value;
13952
+ cursor = replacement.end;
13953
+ }
13954
+ return result + source.slice(cursor);
13955
+ }
13956
+
13957
+ var declarations = new Set([
13958
+ 'defs',
13959
+ 'style',
13960
+ 'title',
13961
+ 'desc',
13962
+ 'metadata',
13963
+ 'symbol',
13964
+ 'clippath',
13965
+ 'mask',
13966
+ 'filter',
13967
+ 'lineargradient',
13968
+ 'radialgradient',
13969
+ 'pattern',
13970
+ 'marker'
13971
+ ]);
13972
+ var graphics = new Set([
13973
+ 'path',
13974
+ 'rect',
13975
+ 'circle',
13976
+ 'ellipse',
13977
+ 'line',
13978
+ 'polyline',
13979
+ 'polygon',
13980
+ 'use'
13981
+ ]);
13982
+ var containers = new Set([
13983
+ 'svg',
13984
+ 'g',
13985
+ 'a',
13986
+ 'switch'
13987
+ ]);
13988
+ var groupEffects = [
13989
+ 'opacity',
13990
+ 'filter',
13991
+ 'mask',
13992
+ 'clip-path'
13993
+ ];
13994
+ var native = new Set([
13995
+ 'text',
13996
+ 'image',
13997
+ 'foreignobject'
13998
+ ]);
13999
+ /** Select graphic-only subtrees; keep native text and images as separate layers. */ function planGraphicBaking(source) {
14000
+ var root = svg_js.SVG(source).node;
14001
+ var scopes = [];
14002
+ var warnings = [];
14003
+ var effectRules = collectGroupEffectRules(root);
14004
+ var byId = new Map(Array.from(root.querySelectorAll('[id]')).map(function(element) {
14005
+ var _element_getAttribute;
14006
+ return [
14007
+ (_element_getAttribute = element.getAttribute('id')) != null ? _element_getAttribute : '',
14008
+ element
14009
+ ];
14010
+ }));
14011
+ var tagOf = function tagOf(element) {
14012
+ return element.tagName.toLowerCase();
14013
+ };
14014
+ var selectorOf = function selectorOf(element) {
14015
+ var _element_getAttribute;
14016
+ var id = (_element_getAttribute = element.getAttribute('id')) != null ? _element_getAttribute : '';
14017
+ return "" + tagOf(element) + (id === '' ? '' : "#" + id);
14018
+ };
14019
+ var references = function references(element) {
14020
+ var ids = Array.from(element.attributes).flatMap(function(attribute) {
14021
+ var values = Array.from(attribute.value.matchAll(/url\(\s*['"]?#([^)'"\s]+)['"]?\s*\)/g), function(match) {
14022
+ return match[1];
14023
+ });
14024
+ if (attribute.localName === 'href' && attribute.value.startsWith('#')) {
14025
+ values.push(attribute.value.slice(1));
14026
+ }
14027
+ return values;
14028
+ });
14029
+ return ids.flatMap(function(id) {
14030
+ var target = byId.get(id);
14031
+ return target == null ? [] : [
14032
+ target
14033
+ ];
14034
+ });
14035
+ };
14036
+ var containsNative = function containsNative1(element, seen) {
14037
+ if (seen === void 0) seen = new Set();
14038
+ if (seen.has(element)) {
14039
+ return false;
14040
+ }
14041
+ seen.add(element);
14042
+ if (native.has(tagOf(element))) {
14043
+ return true;
14044
+ }
14045
+ return Array.from(element.children).some(function(child) {
14046
+ return !declarations.has(tagOf(child)) && containsNative(child, seen);
14047
+ }) || references(element).some(function(target) {
14048
+ return containsNative(target, seen);
14049
+ });
14050
+ };
14051
+ var hasGraphics = function hasGraphics1(element) {
14052
+ return graphics.has(tagOf(element)) || Array.from(element.children).some(function(child) {
14053
+ return !declarations.has(tagOf(child)) && hasGraphics(child);
14054
+ });
14055
+ };
14056
+ var hasGroupEffect = function hasGroupEffect(element) {
14057
+ var _element_getAttribute;
14058
+ var style = (_element_getAttribute = element.getAttribute('style')) != null ? _element_getAttribute : '';
14059
+ return effectRules.some(function(rule) {
14060
+ return element.matches(rule.selectorText);
14061
+ }) || hasGraphicGroupEffect(function(name) {
14062
+ var _element_getAttribute;
14063
+ var _exec_, _exec;
14064
+ return (_element_getAttribute = element.getAttribute(name)) != null ? _element_getAttribute : (_exec = new RegExp("(?:^|;)\\s*" + name + "\\s*:\\s*([^;]+)").exec(style)) == null ? void 0 : (_exec_ = _exec[1]) == null ? void 0 : _exec_.trim();
14065
+ });
14066
+ };
14067
+ var visit = function visit1(element) {
14068
+ var _element_getAttribute, _ref;
14069
+ var _exec_, _exec;
14070
+ var tag = tagOf(element);
14071
+ var style = (_element_getAttribute = element.getAttribute('style')) != null ? _element_getAttribute : '';
14072
+ var display = (_ref = (_exec = /(?:^|;)\s*display\s*:\s*([^;]+)/.exec(style)) == null ? void 0 : (_exec_ = _exec[1]) == null ? void 0 : _exec_.trim()) != null ? _ref : element.getAttribute('display');
14073
+ if (display === 'none') {
14074
+ return;
14075
+ }
14076
+ if (declarations.has(tag) || native.has(tag)) {
14077
+ return;
14078
+ }
14079
+ if (!containers.has(tag) && !graphics.has(tag)) {
14080
+ return;
14081
+ }
14082
+ if (!hasGraphics(element)) {
14083
+ return;
14084
+ }
14085
+ if ((graphics.has(tag) || tag === 'switch') && !containsNative(element)) {
14086
+ scopes.push({
14087
+ path: buildElementTreePath(element),
14088
+ selector: selectorOf(element),
14089
+ isGroup: containers.has(tag)
14090
+ });
14091
+ return;
14092
+ }
14093
+ if (hasGroupEffect(element) && !containsNative(element)) {
14094
+ scopes.push({
14095
+ path: buildElementTreePath(element),
14096
+ selector: selectorOf(element),
14097
+ isGroup: containers.has(tag)
14098
+ });
14099
+ return;
14100
+ }
14101
+ if (hasGroupEffect(element)) {
14102
+ warnings.push({
14103
+ message: 'A compositing group contains native text or images; its graphics cannot be baked separately.',
14104
+ selector: selectorOf(element)
14105
+ });
14106
+ return;
14107
+ }
14108
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(element.children)), _step; !(_step = _iterator()).done;){
14109
+ var child = _step.value;
14110
+ visit(child);
14111
+ }
14112
+ };
14113
+ visit(root);
14114
+ return {
14115
+ scopes: scopes,
14116
+ warnings: warnings
14117
+ };
14118
+ }
14119
+ function collectGroupEffectRules(root) {
14120
+ var result = [];
14121
+ if (typeof CSSStyleSheet !== 'function') {
14122
+ return result;
14123
+ }
14124
+ var visit = function visit1(rules) {
14125
+ var _loop = function() {
14126
+ var rule = _step.value;
14127
+ if (isStyleRule$1(rule)) {
14128
+ var affectsGroup = hasGraphicGroupEffect(function(name) {
14129
+ var value = rule.style.getPropertyValue(name).trim();
14130
+ return value === '' || value === 'initial' || value === 'unset' ? undefined : value;
14131
+ });
14132
+ if (affectsGroup) {
14133
+ result.push(rule);
14134
+ }
14135
+ } else if (hasNestedRules(rule)) {
14136
+ visit(rule.cssRules);
14137
+ }
14138
+ };
14139
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(rules)), _step; !(_step = _iterator()).done;)_loop();
14140
+ };
14141
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(root.querySelectorAll('style'))), _step; !(_step = _iterator()).done;){
14142
+ var style = _step.value;
14143
+ var _style_textContent;
14144
+ var sheet = new CSSStyleSheet();
14145
+ sheet.replaceSync((_style_textContent = style.textContent) != null ? _style_textContent : '');
14146
+ visit(sheet.cssRules);
14147
+ }
14148
+ return result;
14149
+ }
14150
+ /** Reject text/image dependencies and effects that cannot be rendered independently. */ function validateGraphicSnapshot(context) {
14151
+ var _loop = function() {
14152
+ var element = _step1.value;
14153
+ var computed = readStyle(element);
14154
+ var ancestor = element !== target && element.contains(target);
14155
+ var groupEffect = ancestor && hasGraphicGroupEffect(function(name) {
14156
+ return name === 'mask' ? computed.maskImage : computed.getPropertyValue(name);
14157
+ });
14158
+ if (ancestor && (groupEffect || computed.mixBlendMode !== 'normal')) {
14159
+ throw new Error('A mixed group effect cannot be applied independently to its graphics.');
14160
+ }
14161
+ if (target.contains(element) && target !== root && computed.mixBlendMode !== 'normal') {
14162
+ throw new Error('Blend modes that depend on an external backdrop cannot be baked independently.');
14163
+ }
14164
+ };
14165
+ var root = context.root, target = context.target, elements = context.elements, dependencies = context.dependencies, readStyle = context.readStyle;
14166
+ for(var _iterator = _create_for_of_iterator_helper_loose(dependencies), _step; !(_step = _iterator()).done;){
14167
+ var element = _step.value;
14168
+ if ([
14169
+ 'text',
14170
+ 'image',
14171
+ 'foreignobject'
14172
+ ].includes(element.tagName.toLowerCase())) {
14173
+ throw new Error('Graphic dependencies contain native text or images; they must remain editable.');
14174
+ }
14175
+ }
14176
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(elements), _step1; !(_step1 = _iterator1()).done;)_loop();
14177
+ }
14178
+ function isStyleRule$1(rule) {
14179
+ return rule.type === 1;
14180
+ }
14181
+ function hasNestedRules(rule) {
14182
+ return 'cssRules' in rule;
14183
+ }
14184
+ function hasGraphicGroupEffect(readValue) {
14185
+ return groupEffects.some(function(name) {
14186
+ var value = readValue(name);
14187
+ return value != null && value !== 'none' && value !== 'normal' && value !== '1';
14188
+ });
14189
+ }
14190
+
14191
+ /** Mask and clipPath definitions do not produce visible layers. */ function collectNonRenderingDeclarationPaths(source) {
14192
+ var root = svg_js.SVG(source).node;
14193
+ var elements = Array.from(root.querySelectorAll('*')).filter(function(element) {
14194
+ var tag = element.tagName.toLowerCase();
14195
+ return tag === 'mask' || tag === 'clippath';
14196
+ });
14197
+ return new Set(elements.map(buildElementTreePath));
14198
+ }
14199
+ /** A stylesheet diagnostic is resolved only when every element it can affect was baked. */ function collectBakedStylesheetPaths(source, isBaked) {
14200
+ var resolved = new Set();
14201
+ if (typeof DOMParser === 'undefined' || typeof CSSStyleSheet !== 'function') {
14202
+ return resolved;
14203
+ }
14204
+ var root = new DOMParser().parseFromString(source, 'image/svg+xml').documentElement;
14205
+ var allUsesBaked = Array.from(root.querySelectorAll('use')).every(function(element) {
14206
+ return isBaked(buildElementTreePath(element));
14207
+ });
14208
+ var isHandled = function isHandled(element) {
14209
+ if (isBaked(buildElementTreePath(element))) {
14210
+ return true;
14211
+ }
14212
+ if (element.closest('defs, symbol, marker, pattern, clipPath, mask, filter') != null) {
14213
+ return allUsesBaked;
14214
+ }
14215
+ return false;
14216
+ };
14217
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(root.querySelectorAll('style'))), _step; !(_step = _iterator()).done;){
14218
+ var style = _step.value;
14219
+ var _style_textContent;
14220
+ var sheet = new CSSStyleSheet();
14221
+ sheet.replaceSync((_style_textContent = style.textContent) != null ? _style_textContent : '');
14222
+ var rules = Array.from(sheet.cssRules);
14223
+ var handled = rules.every(function(rule) {
14224
+ if (!isStyleRule(rule)) {
14225
+ return false;
14226
+ }
14227
+ if (Array.from(rule.style).every(function(name) {
14228
+ return name === 'mix-blend-mode';
14229
+ })) {
14230
+ return true;
14231
+ }
14232
+ var matched = [].concat([
14233
+ root
14234
+ ], Array.from(root.querySelectorAll('*'))).filter(function(element) {
14235
+ return element.matches(rule.selectorText);
14236
+ });
14237
+ return matched.every(isHandled);
14238
+ });
14239
+ if (handled) {
14240
+ resolved.add(buildElementTreePath(style));
14241
+ }
14242
+ }
14243
+ return resolved;
14244
+ }
14245
+ function isStyleRule(rule) {
14246
+ return rule.type === 1;
14247
+ }
14248
+
14249
+ /** Rasterize graphics and track the source layers and warnings they replace. */ function buildBakedLayers(source, size, options, rasterScale) {
14250
+ return _async_to_generator(function() {
14251
+ var deferredOptions, bakedPaths, baked, bakingWarnings, blending, plan, _iterator, _step, downgrade, _iterator1, _step1, warning, _iterator2, _step2, scope, image, message, _image_bbox, left, top, right, bottom, width, height, error, reason, replacesSource, handledStyles, declarations;
14252
+ return _ts_generator(this, function(_state) {
14253
+ switch(_state.label){
14254
+ case 0:
14255
+ deferredOptions = _extends({}, options, {
14256
+ strict: false,
14257
+ onWarning: undefined
14258
+ });
14259
+ bakedPaths = [];
14260
+ baked = [];
14261
+ bakingWarnings = [];
14262
+ blending = normalizeLayerBlending(source);
14263
+ plan = planGraphicBaking(blending.source);
14264
+ for(_iterator = _create_for_of_iterator_helper_loose(blending.downgrades); !(_step = _iterator()).done;){
14265
+ downgrade = _step.value;
14266
+ collectLayerWarning(bakingWarnings, deferredOptions, SVG2IR_WARNING_CODES.LAYERS_BLEND_MODE_DOWNGRADED, 'mix-blend-mode "' + downgrade.mode + '" was downgraded to "normal"; the layer is retained.', downgrade.selector);
14267
+ }
14268
+ for(_iterator1 = _create_for_of_iterator_helper_loose(plan.warnings); !(_step1 = _iterator1()).done;){
14269
+ warning = _step1.value;
14270
+ collectLayerWarning(bakingWarnings, deferredOptions, SVG2IR_WARNING_CODES.LAYERS_UNSUPPORTED_FEATURE, warning.message, warning.selector);
14271
+ }
14272
+ _iterator2 = _create_for_of_iterator_helper_loose(plan.scopes);
14273
+ _state.label = 1;
14274
+ case 1:
14275
+ if (!!(_step2 = _iterator2()).done) return [
14276
+ 3,
14277
+ 6
14278
+ ];
14279
+ scope = _step2.value;
14280
+ _state.label = 2;
14281
+ case 2:
14282
+ _state.trys.push([
14283
+ 2,
14284
+ 4,
14285
+ ,
14286
+ 5
14287
+ ]);
14288
+ if (!canRasterizeSVG()) {
14289
+ throw new Error('Graphic baking requires a browser with SVG and Canvas support.');
14290
+ }
14291
+ return [
14292
+ 4,
14293
+ rasterizeSVG(blending.source, scope.path, size, rasterScale, validateGraphicSnapshot)
14294
+ ];
14295
+ case 3:
14296
+ image = _state.sent();
14297
+ bakedPaths.push(scope.path);
14298
+ message = image == null ? 'Graphic rasterization produced no visible pixels; no image layer was emitted.' : scope.isGroup ? 'Graphic group baked into a single PNG; child graphics and paint/effect parameters are no longer editable.' : 'Graphic baked into a PNG; vector geometry and paint/effect parameters are no longer editable.';
14299
+ collectLayerWarning(bakingWarnings, deferredOptions, SVG2IR_WARNING_CODES.LAYERS_GRAPHIC_BAKED, message, scope.selector);
14300
+ if (image == null) {
14301
+ return [
14302
+ 3,
14303
+ 5
14304
+ ];
14305
+ }
14306
+ _image_bbox = image.bbox, left = _image_bbox[0], top = _image_bbox[1], right = _image_bbox[2], bottom = _image_bbox[3];
14307
+ width = right - left;
14308
+ height = bottom - top;
14309
+ baked.push({
14310
+ path: scope.path,
14311
+ layer: {
14312
+ id: '',
14313
+ type: 'image',
14314
+ role: 'content',
14315
+ bbox: image.bbox,
14316
+ size: [
14317
+ width,
14318
+ height
14319
+ ],
14320
+ rotation: [
14321
+ 0,
14322
+ 0,
14323
+ 0
14324
+ ],
14325
+ url: image.url,
14326
+ width: width,
14327
+ height: height
14328
+ }
14329
+ });
14330
+ return [
14331
+ 3,
14332
+ 5
14333
+ ];
14334
+ case 4:
14335
+ error = _state.sent();
14336
+ reason = _instanceof(error, Error) ? error.message : String(error);
14337
+ collectLayerWarning(bakingWarnings, deferredOptions, SVG2IR_WARNING_CODES.LAYERS_UNSUPPORTED_FEATURE, "Graphic baking failed: " + reason, scope.selector);
14338
+ return [
14339
+ 3,
14340
+ 5
14341
+ ];
14342
+ case 5:
14343
+ return [
14344
+ 3,
14345
+ 1
14346
+ ];
14347
+ case 6:
14348
+ replacesSource = function replacesSource(path) {
14349
+ return path != null && bakedPaths.some(function(scope) {
14350
+ return scope === '' || path === scope || path.startsWith("" + scope + "/");
14351
+ });
14352
+ };
14353
+ handledStyles = collectBakedStylesheetPaths(blending.source, replacesSource);
14354
+ declarations = collectNonRenderingDeclarationPaths(source);
14355
+ return [
14356
+ 2,
14357
+ {
14358
+ layers: baked,
14359
+ warnings: bakingWarnings,
14360
+ replacesSource: replacesSource,
14361
+ resolvesWarning: function resolvesWarning(warning, path) {
14362
+ return replacesSource(path) || warning.code === SVG2IR_WARNING_CODES.ELEMENT_DROPPED && path != null && (handledStyles.has(path) || declarations.has(path));
14363
+ }
14364
+ }
14365
+ ];
14366
+ }
14367
+ });
14368
+ })();
14369
+ }
13260
14370
 
13261
14371
  function encodeBase64(data) {
13262
14372
  var chunks = [];
@@ -13445,26 +14555,103 @@ function fetchImageResource(url) {
13445
14555
  }).apply(this, arguments);
13446
14556
  }
13447
14557
 
13448
- function convertSVGToLayers(source, options, loadImage, preservedData) {
14558
+ var animatedTags = new Set([
14559
+ 'animate',
14560
+ 'animatetransform',
14561
+ 'animatemotion',
14562
+ 'set'
14563
+ ]);
14564
+ /** Static layers cannot sample animation; drop SMIL nodes so elements keep their authored state. */ function stripLayerAnimation(source) {
14565
+ var svg = svg_js.SVG(source);
14566
+ if ((svg == null ? void 0 : svg.node) == null) {
14567
+ return {
14568
+ source: source,
14569
+ removed: 0
14570
+ };
14571
+ }
14572
+ var elements = Array.from(svg.node.querySelectorAll('*')).filter(function(element) {
14573
+ return animatedTags.has(element.tagName.toLowerCase());
14574
+ });
14575
+ if (elements.length === 0) {
14576
+ return {
14577
+ source: source,
14578
+ removed: 0
14579
+ };
14580
+ }
14581
+ for(var _iterator = _create_for_of_iterator_helper_loose(elements), _step; !(_step = _iterator()).done;){
14582
+ var element = _step.value;
14583
+ element.remove();
14584
+ }
14585
+ return {
14586
+ source: svg.svg(),
14587
+ removed: elements.length
14588
+ };
14589
+ }
14590
+
14591
+ function convertSVGToLayers(source, options, loadImage, preservedData, rasterScale) {
14592
+ if (rasterScale === void 0) rasterScale = 2;
13449
14593
  return _async_to_generator(function() {
13450
- var splitResult, parsed, _assembleSVGStaticLayers, size, data, _tmp;
14594
+ var layerSources, warningSources, collected, stripped, staticSource, parsed, composition, baking, assembled, _tmp, _tmp1;
13451
14595
  return _ts_generator(this, function(_state) {
13452
14596
  switch(_state.label){
13453
14597
  case 0:
13454
- splitResult = preservedData == null ? splitSVG(source, options) : undefined;
13455
- parsed = splitResult != null ? splitResult : parseSVGToIRWithPreservedData(source, options);
13456
- _assembleSVGStaticLayers = assembleSVGStaticLayers(parsed.ir, options, parsed.warnings, preservedData != null ? preservedData : splitResult == null ? void 0 : splitResult.preservedData), size = _assembleSVGStaticLayers.size, data = _assembleSVGStaticLayers.data;
13457
- _tmp = {
13458
- size: size
14598
+ layerSources = new Map();
14599
+ warningSources = new Map();
14600
+ collected = {
14601
+ textDataByLayerId: new Map(),
14602
+ paintAnimationsByLayerId: new Map(),
14603
+ shapeAnimationsByLayerId: new Map()
13459
14604
  };
14605
+ stripped = stripLayerAnimation(source);
14606
+ staticSource = stripped.source;
14607
+ // Preserve original layer IDs while gathering the source identities required by baking and assembly.
14608
+ parsed = parseSVGToIRWithPreservedData(staticSource, _extends({}, options, {
14609
+ strict: false,
14610
+ onWarning: undefined
14611
+ }), _extends({}, collected, {
14612
+ layerSourceCollector: layerSources,
14613
+ warningSourceCollector: warningSources
14614
+ }));
14615
+ if (stripped.removed > 0) {
14616
+ collectLayerWarning(parsed.warnings, _extends({}, options, {
14617
+ strict: false,
14618
+ onWarning: undefined
14619
+ }), SVG2IR_WARNING_CODES.LAYERS_ANIMATION_STRIPPED, "" + stripped.removed + " animated element(s) were removed; static layers output does not sample animation.");
14620
+ }
14621
+ composition = parsed.ir.compositions[0];
13460
14622
  return [
13461
14623
  4,
13462
- inlineImageResources(data, loadImage)
14624
+ buildBakedLayers(staticSource, [
14625
+ composition.width,
14626
+ composition.height
14627
+ ], options, rasterScale)
13463
14628
  ];
13464
14629
  case 1:
14630
+ baking = _state.sent();
14631
+ 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,
14638
+ baking: baking
14639
+ });
14640
+ _tmp = [
14641
+ {},
14642
+ assembled
14643
+ ];
14644
+ _tmp1 = {};
14645
+ return [
14646
+ 4,
14647
+ inlineImageResources(assembled.data, loadImage)
14648
+ ];
14649
+ case 2:
13465
14650
  return [
13466
14651
  2,
13467
- (_tmp.data = _state.sent(), _tmp.warnings = parsed.warnings, _tmp)
14652
+ _extends.apply(void 0, _tmp.concat([
14653
+ (_tmp1.data = _state.sent(), _tmp1)
14654
+ ]))
13468
14655
  ];
13469
14656
  }
13470
14657
  });
@@ -15994,11 +17181,12 @@ function convertSVG(source, options, preservedData) {
15994
17181
  throw new TypeError('[svg2ir] outputFormat must be ge or layers.');
15995
17182
  }
15996
17183
  if ((options == null ? void 0 : options.outputFormat) === 'layers') {
15997
- options.outputFormat; var loadImage = options.loadImage, parserOptions = _object_without_properties_loose(options, [
17184
+ options.outputFormat; var loadImage = options.loadImage, rasterScale = options.rasterScale, parserOptions = _object_without_properties_loose(options, [
15998
17185
  "outputFormat",
15999
- "loadImage"
17186
+ "loadImage",
17187
+ "rasterScale"
16000
17188
  ]);
16001
- return convertSVGToLayers(source, parserOptions, loadImage, preservedData);
17189
+ return convertSVGToLayers(source, parserOptions, loadImage, preservedData, rasterScale);
16002
17190
  }
16003
17191
  var _ref1 = options != null ? options : {}; _ref1.outputFormat; var geOptions = _object_without_properties_loose(_ref1, [
16004
17192
  "outputFormat"
@@ -16009,5 +17197,6 @@ function convertSVG(source, options, preservedData) {
16009
17197
  exports.convertSVG = convertSVG;
16010
17198
  exports.convertSVGToGE = convertSVGToGE;
16011
17199
  exports.convertSVGToIR = convertSVGToIR;
17200
+ exports.inferNumericWeightFromFamily = inferNumericWeightFromFamily;
16012
17201
  exports.splitSVG = splitSVG;
16013
17202
  //# sourceMappingURL=index.js.map