@scratch/scratch-svg-renderer 12.1.0-login-from-editor → 12.1.0-membership-program
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/LICENSE +656 -7
- package/TRADEMARK +1 -0
- package/dist/node/scratch-svg-renderer.js +518 -496
- package/dist/node/scratch-svg-renderer.js.map +1 -1
- package/dist/web/scratch-svg-renderer.js +52 -30
- package/dist/web/scratch-svg-renderer.js.map +1 -1
- package/package.json +14 -14
- package/src/bitmap-adapter.js +4 -4
- package/src/font-converter.js +1 -1
- package/src/font-inliner.js +1 -1
- package/src/load-svg-string.js +3 -3
- package/src/sanitize-svg.js +3 -3
- package/src/svg-renderer.js +4 -4
- package/src/transform-applier.js +1 -2
|
@@ -11650,7 +11650,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"name":"css-tree","version":"1.1.3","
|
|
|
11650
11650
|
/***/ ((module) => {
|
|
11651
11651
|
|
|
11652
11652
|
"use strict";
|
|
11653
|
-
/*! @license DOMPurify 3.
|
|
11653
|
+
/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
|
|
11654
11654
|
|
|
11655
11655
|
|
|
11656
11656
|
|
|
@@ -11838,7 +11838,7 @@ function lookupGetter(object, prop) {
|
|
|
11838
11838
|
}
|
|
11839
11839
|
|
|
11840
11840
|
const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
|
|
11841
|
-
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', '
|
|
11841
|
+
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
11842
11842
|
const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
|
|
11843
11843
|
// List of SVG elements that are disallowed by default.
|
|
11844
11844
|
// We still need to know them so that we can do namespace
|
|
@@ -11852,7 +11852,7 @@ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongd
|
|
|
11852
11852
|
const text = freeze(['#text']);
|
|
11853
11853
|
|
|
11854
11854
|
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
|
|
11855
|
-
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
11855
|
+
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
11856
11856
|
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
11857
11857
|
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
11858
11858
|
|
|
@@ -11959,7 +11959,7 @@ const _createHooksMap = function _createHooksMap() {
|
|
|
11959
11959
|
function createDOMPurify() {
|
|
11960
11960
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
11961
11961
|
const DOMPurify = root => createDOMPurify(root);
|
|
11962
|
-
DOMPurify.version = '3.
|
|
11962
|
+
DOMPurify.version = '3.3.0';
|
|
11963
11963
|
DOMPurify.removed = [];
|
|
11964
11964
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
11965
11965
|
// Not running in a browser, provide a factory function
|
|
@@ -12070,6 +12070,21 @@ function createDOMPurify() {
|
|
|
12070
12070
|
let FORBID_TAGS = null;
|
|
12071
12071
|
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
12072
12072
|
let FORBID_ATTR = null;
|
|
12073
|
+
/* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
|
|
12074
|
+
const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
12075
|
+
tagCheck: {
|
|
12076
|
+
writable: true,
|
|
12077
|
+
configurable: false,
|
|
12078
|
+
enumerable: true,
|
|
12079
|
+
value: null
|
|
12080
|
+
},
|
|
12081
|
+
attributeCheck: {
|
|
12082
|
+
writable: true,
|
|
12083
|
+
configurable: false,
|
|
12084
|
+
enumerable: true,
|
|
12085
|
+
value: null
|
|
12086
|
+
}
|
|
12087
|
+
}));
|
|
12073
12088
|
/* Decide if ARIA attributes are okay */
|
|
12074
12089
|
let ALLOW_ARIA_ATTR = true;
|
|
12075
12090
|
/* Decide if custom data attributes are okay */
|
|
@@ -12262,16 +12277,24 @@ function createDOMPurify() {
|
|
|
12262
12277
|
}
|
|
12263
12278
|
/* Merge configuration parameters */
|
|
12264
12279
|
if (cfg.ADD_TAGS) {
|
|
12265
|
-
if (
|
|
12266
|
-
|
|
12280
|
+
if (typeof cfg.ADD_TAGS === 'function') {
|
|
12281
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
12282
|
+
} else {
|
|
12283
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
12284
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
12285
|
+
}
|
|
12286
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
12267
12287
|
}
|
|
12268
|
-
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
12269
12288
|
}
|
|
12270
12289
|
if (cfg.ADD_ATTR) {
|
|
12271
|
-
if (
|
|
12272
|
-
|
|
12290
|
+
if (typeof cfg.ADD_ATTR === 'function') {
|
|
12291
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
12292
|
+
} else {
|
|
12293
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
12294
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
12295
|
+
}
|
|
12296
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
12273
12297
|
}
|
|
12274
|
-
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
12275
12298
|
}
|
|
12276
12299
|
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
12277
12300
|
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
@@ -12579,7 +12602,7 @@ function createDOMPurify() {
|
|
|
12579
12602
|
return true;
|
|
12580
12603
|
}
|
|
12581
12604
|
/* Remove element if anything forbids its presence */
|
|
12582
|
-
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
12605
|
+
if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {
|
|
12583
12606
|
/* Check if we have a custom element to handle */
|
|
12584
12607
|
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
12585
12608
|
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
@@ -12651,7 +12674,7 @@ function createDOMPurify() {
|
|
|
12651
12674
|
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
12652
12675
|
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
12653
12676
|
We don't need to check the value; it's always URI safe. */
|
|
12654
|
-
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
12677
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
12655
12678
|
if (
|
|
12656
12679
|
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
12657
12680
|
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
@@ -15811,8 +15834,8 @@ const base64js = __webpack_require__(/*! base64-js */ "../../node_modules/base64
|
|
|
15811
15834
|
*/
|
|
15812
15835
|
class BitmapAdapter {
|
|
15813
15836
|
/**
|
|
15814
|
-
* @param {?
|
|
15815
|
-
* @param {?
|
|
15837
|
+
* @param {?Function} makeImage HTML image constructor. Tests can provide this.
|
|
15838
|
+
* @param {?Function} makeCanvas HTML canvas constructor. Tests can provide this.
|
|
15816
15839
|
*/
|
|
15817
15840
|
constructor(makeImage, makeCanvas) {
|
|
15818
15841
|
this._makeImage = makeImage ? makeImage : () => new Image();
|
|
@@ -15852,7 +15875,7 @@ class BitmapAdapter {
|
|
|
15852
15875
|
* to resolution 2 bitmaps. Therefore, converting a resolution 1 bitmap means doubling
|
|
15853
15876
|
* it in width and height.
|
|
15854
15877
|
* @param {!string} dataURI Base 64 encoded image data of the bitmap
|
|
15855
|
-
* @param {!
|
|
15878
|
+
* @param {!Function} callback Node-style callback that returns updated dataURI if conversion succeeded
|
|
15856
15879
|
*/
|
|
15857
15880
|
convertResolution1Bitmap(dataURI, callback) {
|
|
15858
15881
|
const image = this._makeImage();
|
|
@@ -15870,7 +15893,7 @@ class BitmapAdapter {
|
|
|
15870
15893
|
* to in Scratch 3.0
|
|
15871
15894
|
* @param {!number} oldWidth original width
|
|
15872
15895
|
* @param {!number} oldHeight original height
|
|
15873
|
-
* @
|
|
15896
|
+
* @returns {object} Array of new width, new height
|
|
15874
15897
|
*/
|
|
15875
15898
|
getResizedWidthHeight(oldWidth, oldHeight) {
|
|
15876
15899
|
const STAGE_WIDTH = 480;
|
|
@@ -16050,7 +16073,7 @@ module.exports = function (svgString) {
|
|
|
16050
16073
|
/**
|
|
16051
16074
|
* Given an SVG, replace Scratch 2.0 fonts with new 3.0 fonts. Add defaults where there are none.
|
|
16052
16075
|
* @param {SVGElement} svgTag The SVG dom object
|
|
16053
|
-
* @
|
|
16076
|
+
* @returns {void}
|
|
16054
16077
|
*/
|
|
16055
16078
|
const convertFonts = function convertFonts(svgTag) {
|
|
16056
16079
|
// Collect all text elements into a list.
|
|
@@ -16105,7 +16128,7 @@ const getFonts = __webpack_require__(/*! scratch-render-fonts */ "../../node_mod
|
|
|
16105
16128
|
* // Using a <link> or <style>@import</style> to link to font-family
|
|
16106
16129
|
* // injected into the document: no effect.
|
|
16107
16130
|
* @param {string} svgString The string representation of the svg to modify
|
|
16108
|
-
* @
|
|
16131
|
+
* @returns {string} The svg with any needed fonts inlined
|
|
16109
16132
|
*/
|
|
16110
16133
|
const inlineSvgFonts = function inlineSvgFonts(svgString) {
|
|
16111
16134
|
const FONTS = getFonts();
|
|
@@ -16187,7 +16210,7 @@ const {
|
|
|
16187
16210
|
/**
|
|
16188
16211
|
* @param {SVGElement} svgTag the tag to search within
|
|
16189
16212
|
* @param {string} [tagName] svg tag to search for (or collect all elements if not given)
|
|
16190
|
-
* @
|
|
16213
|
+
* @returns {Array} a list of elements with the given tagname
|
|
16191
16214
|
*/
|
|
16192
16215
|
const collectElements = (svgTag, tagName) => {
|
|
16193
16216
|
const elts = [];
|
|
@@ -16340,7 +16363,7 @@ const transformText = svgTag => {
|
|
|
16340
16363
|
* This is used to enlarge the computed bounding box, which doesn't take
|
|
16341
16364
|
* stroke width into account.
|
|
16342
16365
|
* @param {SVGSVGElement} rootNode The root SVG node to traverse.
|
|
16343
|
-
* @
|
|
16366
|
+
* @returns {number} The largest stroke width in the SVG.
|
|
16344
16367
|
*/
|
|
16345
16368
|
const findLargestStrokeWidth = rootNode => {
|
|
16346
16369
|
let largestStrokeWidth = 0;
|
|
@@ -16473,7 +16496,7 @@ const normalizeSvg = (svgTag, fromVersion2) => {
|
|
|
16473
16496
|
* mimic Scratch 2.0's SVG rendering.
|
|
16474
16497
|
* @param {!string} svgString String of SVG data to draw in quirks-mode.
|
|
16475
16498
|
* @param {boolean} [fromVersion2] True if we should perform conversion from version 2 to version 3 svg.
|
|
16476
|
-
* @
|
|
16499
|
+
* @returns {SVGSVGElement} The normalized SVG element.
|
|
16477
16500
|
*/
|
|
16478
16501
|
const loadSvgString = (svgString, fromVersion2) => {
|
|
16479
16502
|
// Parse string into SVG XML.
|
|
@@ -16587,7 +16610,7 @@ let _TextDecoder;
|
|
|
16587
16610
|
let _TextEncoder;
|
|
16588
16611
|
if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
|
|
16589
16612
|
// Wait to require the text encoding polyfill until we know it's needed.
|
|
16590
|
-
|
|
16613
|
+
|
|
16591
16614
|
const encoding = __webpack_require__(/*! fastestsmallesttextencoderdecoder */ "../../node_modules/fastestsmallesttextencoderdecoder/EncoderDecoderTogether.min.js");
|
|
16592
16615
|
_TextDecoder = encoding.TextDecoder;
|
|
16593
16616
|
_TextEncoder = encoding.TextEncoder;
|
|
@@ -16599,7 +16622,7 @@ if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
|
|
|
16599
16622
|
/**
|
|
16600
16623
|
* Load an SVG Uint8Array of bytes and "sanitize" it
|
|
16601
16624
|
* @param {!Uint8Array} rawData unsanitized SVG daata
|
|
16602
|
-
* @
|
|
16625
|
+
* @returns {Uint8Array} sanitized SVG data
|
|
16603
16626
|
*/
|
|
16604
16627
|
sanitizeSvg.sanitizeByteStream = function (rawData) {
|
|
16605
16628
|
const decoder = new _TextDecoder();
|
|
@@ -16613,7 +16636,7 @@ sanitizeSvg.sanitizeByteStream = function (rawData) {
|
|
|
16613
16636
|
* fixup-svg-string.js, and thus more risky; there are known examples of SVGs that
|
|
16614
16637
|
* it will clobber. We use DOMPurify's svg profile, which restricts many types of tag.
|
|
16615
16638
|
* @param {!string} rawSvgText unsanitized SVG string
|
|
16616
|
-
* @
|
|
16639
|
+
* @returns {string} sanitized SVG text
|
|
16617
16640
|
*/
|
|
16618
16641
|
sanitizeSvg.sanitizeSvgText = function (rawSvgText) {
|
|
16619
16642
|
let sanitizedText = DOMPurify.sanitize(rawSvgText, {
|
|
@@ -16758,7 +16781,7 @@ class SvgRenderer {
|
|
|
16758
16781
|
* Create a quirks-mode SVG renderer for a particular canvas.
|
|
16759
16782
|
* @param {HTMLCanvasElement} [canvas] An optional canvas element to draw to. If this is not provided, the renderer
|
|
16760
16783
|
* will create a new canvas.
|
|
16761
|
-
* @
|
|
16784
|
+
* @class
|
|
16762
16785
|
*/
|
|
16763
16786
|
constructor(canvas) {
|
|
16764
16787
|
/**
|
|
@@ -16812,14 +16835,14 @@ class SvgRenderer {
|
|
|
16812
16835
|
}
|
|
16813
16836
|
|
|
16814
16837
|
/**
|
|
16815
|
-
* @
|
|
16838
|
+
* @returns {Array<number>} the natural size, in Scratch units, of this SVG.
|
|
16816
16839
|
*/
|
|
16817
16840
|
get size() {
|
|
16818
16841
|
return [this._measurements.width, this._measurements.height];
|
|
16819
16842
|
}
|
|
16820
16843
|
|
|
16821
16844
|
/**
|
|
16822
|
-
* @
|
|
16845
|
+
* @returns {Array<number>} the offset (upper left corner) of the SVG's view box.
|
|
16823
16846
|
*/
|
|
16824
16847
|
get viewOffset() {
|
|
16825
16848
|
return [this._measurements.x, this._measurements.y];
|
|
@@ -16894,7 +16917,7 @@ class SvgRenderer {
|
|
|
16894
16917
|
/**
|
|
16895
16918
|
* Draw to the canvas from a loaded image element.
|
|
16896
16919
|
* @param {number} [scale] - Optionally, also scale the image by this factor.
|
|
16897
|
-
|
|
16920
|
+
*/
|
|
16898
16921
|
_drawFromImage(scale) {
|
|
16899
16922
|
if (this._cachedImage === null) return;
|
|
16900
16923
|
const ratio = Number.isFinite(scale) ? scale : 1;
|
|
@@ -17445,14 +17468,13 @@ const _parseUrl = (value, windowRef) => {
|
|
|
17445
17468
|
* on groups down to the leaf level and averaging out the stroke width
|
|
17446
17469
|
* around the shapes. Note that this doens't just change stroke widths, it
|
|
17447
17470
|
* changes path data and attributes throughout the SVG.
|
|
17448
|
-
*
|
|
17449
17471
|
* @param {SVGElement} svgTag The SVG dom object
|
|
17450
17472
|
* @param {Window} windowRef The window to use. Need to pass in for
|
|
17451
17473
|
* tests to work, as they get angry at even the mention of window.
|
|
17452
17474
|
* @param {object} bboxForTesting The bounds to use. Need to pass in for
|
|
17453
17475
|
* tests only, because getBBox doesn't work in Node. This should
|
|
17454
17476
|
* be the bounds of the svgTag without including stroke width or transforms.
|
|
17455
|
-
* @
|
|
17477
|
+
* @returns {void}
|
|
17456
17478
|
*/
|
|
17457
17479
|
const transformStrokeWidths = function transformStrokeWidths(svgTag, windowRef, bboxForTesting) {
|
|
17458
17480
|
const inherited = Matrix.identity();
|