@scratch/scratch-svg-renderer 12.1.0-localte-selection → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scratch/scratch-svg-renderer",
3
- "version": "12.1.0-localte-selection",
3
+ "version": "12.1.0-membership-program",
4
4
  "description": "SVG renderer for Scratch",
5
5
  "main": "./dist/node/scratch-svg-renderer.js",
6
6
  "browser": "./dist/web/scratch-svg-renderer.js",
@@ -12,14 +12,16 @@
12
12
  },
13
13
  "files": [
14
14
  "dist",
15
- "src"
15
+ "src",
16
+ "LICENSE",
17
+ "TRADEMARK"
16
18
  ],
17
19
  "scripts": {
18
20
  "build": "npm run clean && webpack",
19
21
  "clean": "rimraf dist playground",
20
22
  "start": "webpack-dev-server",
21
23
  "test": "npm run test:lint && npm run test:unit",
22
- "test:lint": "eslint . --ext .js",
24
+ "test:lint": "eslint",
23
25
  "test:unit": "tap ./test/*.js",
24
26
  "watch": "webpack --watch"
25
27
  },
@@ -46,24 +48,22 @@
46
48
  "transformation-matrix": "1.15.3"
47
49
  },
48
50
  "devDependencies": {
49
- "@babel/core": "7.28.4",
50
- "@babel/eslint-parser": "7.28.4",
51
- "@babel/preset-env": "7.28.3",
51
+ "@babel/core": "7.28.5",
52
+ "@babel/preset-env": "7.28.5",
52
53
  "babel-loader": "9.2.1",
53
54
  "copy-webpack-plugin": "6.4.1",
54
- "eslint": "8.57.1",
55
- "eslint-config-scratch": "9.0.9",
56
- "eslint-plugin-import": "2.32.0",
55
+ "eslint": "9.39.1",
56
+ "eslint-config-scratch": "12.0.38",
57
+ "globals": "16.5.0",
57
58
  "jsdom": "13.2.0",
58
- "json": "9.0.6",
59
59
  "mkdirp": "2.1.6",
60
60
  "rimraf": "3.0.2",
61
- "scratch-render-fonts": "1.0.229",
62
- "scratch-semantic-release-config": "3.0.0",
63
- "scratch-webpack-configuration": "3.0.0",
61
+ "scratch-render-fonts": "1.0.252",
62
+ "scratch-semantic-release-config": "4.0.0",
63
+ "scratch-webpack-configuration": "3.1.0",
64
64
  "semantic-release": "19.0.5",
65
- "tap": "21.1.0",
66
- "webpack": "5.101.3",
65
+ "tap": "21.4.0",
66
+ "webpack": "5.103.0",
67
67
  "webpack-cli": "5.1.4",
68
68
  "webpack-dev-server": "5.2.2",
69
69
  "xmldom": "0.1.31"
@@ -5,8 +5,8 @@ const base64js = require('base64-js');
5
5
  */
6
6
  class BitmapAdapter {
7
7
  /**
8
- * @param {?function} makeImage HTML image constructor. Tests can provide this.
9
- * @param {?function} makeCanvas HTML canvas constructor. Tests can provide this.
8
+ * @param {?Function} makeImage HTML image constructor. Tests can provide this.
9
+ * @param {?Function} makeCanvas HTML canvas constructor. Tests can provide this.
10
10
  */
11
11
  constructor (makeImage, makeCanvas) {
12
12
  this._makeImage = makeImage ? makeImage : () => new Image();
@@ -46,7 +46,7 @@ class BitmapAdapter {
46
46
  * to resolution 2 bitmaps. Therefore, converting a resolution 1 bitmap means doubling
47
47
  * it in width and height.
48
48
  * @param {!string} dataURI Base 64 encoded image data of the bitmap
49
- * @param {!function} callback Node-style callback that returns updated dataURI if conversion succeeded
49
+ * @param {!Function} callback Node-style callback that returns updated dataURI if conversion succeeded
50
50
  */
51
51
  convertResolution1Bitmap (dataURI, callback) {
52
52
  const image = this._makeImage();
@@ -64,7 +64,7 @@ class BitmapAdapter {
64
64
  * to in Scratch 3.0
65
65
  * @param {!number} oldWidth original width
66
66
  * @param {!number} oldHeight original height
67
- * @return {object} Array of new width, new height
67
+ * @returns {object} Array of new width, new height
68
68
  */
69
69
  getResizedWidthHeight (oldWidth, oldHeight) {
70
70
  const STAGE_WIDTH = 480;
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Given an SVG, replace Scratch 2.0 fonts with new 3.0 fonts. Add defaults where there are none.
7
7
  * @param {SVGElement} svgTag The SVG dom object
8
- * @return {void}
8
+ * @returns {void}
9
9
  */
10
10
  const convertFonts = function (svgTag) {
11
11
  // Collect all text elements into a list.
@@ -15,7 +15,7 @@ const getFonts = require('scratch-render-fonts');
15
15
  * // Using a <link> or <style>@import</style> to link to font-family
16
16
  * // injected into the document: no effect.
17
17
  * @param {string} svgString The string representation of the svg to modify
18
- * @return {string} The svg with any needed fonts inlined
18
+ * @returns {string} The svg with any needed fonts inlined
19
19
  */
20
20
  const inlineSvgFonts = function (svgString) {
21
21
  const FONTS = getFonts();
@@ -6,7 +6,7 @@ const {sanitizeSvgText} = require('./sanitize-svg');
6
6
  /**
7
7
  * @param {SVGElement} svgTag the tag to search within
8
8
  * @param {string} [tagName] svg tag to search for (or collect all elements if not given)
9
- * @return {Array} a list of elements with the given tagname
9
+ * @returns {Array} a list of elements with the given tagname
10
10
  */
11
11
  const collectElements = (svgTag, tagName) => {
12
12
  const elts = [];
@@ -162,7 +162,7 @@ const transformText = svgTag => {
162
162
  * This is used to enlarge the computed bounding box, which doesn't take
163
163
  * stroke width into account.
164
164
  * @param {SVGSVGElement} rootNode The root SVG node to traverse.
165
- * @return {number} The largest stroke width in the SVG.
165
+ * @returns {number} The largest stroke width in the SVG.
166
166
  */
167
167
  const findLargestStrokeWidth = rootNode => {
168
168
  let largestStrokeWidth = 0;
@@ -300,7 +300,7 @@ const normalizeSvg = (svgTag, fromVersion2) => {
300
300
  * mimic Scratch 2.0's SVG rendering.
301
301
  * @param {!string} svgString String of SVG data to draw in quirks-mode.
302
302
  * @param {boolean} [fromVersion2] True if we should perform conversion from version 2 to version 3 svg.
303
- * @return {SVGSVGElement} The normalized SVG element.
303
+ * @returns {SVGSVGElement} The normalized SVG element.
304
304
  */
305
305
  const loadSvgString = (svgString, fromVersion2) => {
306
306
  // Parse string into SVG XML.
@@ -98,7 +98,7 @@ let _TextDecoder;
98
98
  let _TextEncoder;
99
99
  if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
100
100
  // Wait to require the text encoding polyfill until we know it's needed.
101
- // eslint-disable-next-line global-require
101
+
102
102
  const encoding = require('fastestsmallesttextencoderdecoder');
103
103
  _TextDecoder = encoding.TextDecoder;
104
104
  _TextEncoder = encoding.TextEncoder;
@@ -110,7 +110,7 @@ if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
110
110
  /**
111
111
  * Load an SVG Uint8Array of bytes and "sanitize" it
112
112
  * @param {!Uint8Array} rawData unsanitized SVG daata
113
- * @return {Uint8Array} sanitized SVG data
113
+ * @returns {Uint8Array} sanitized SVG data
114
114
  */
115
115
  sanitizeSvg.sanitizeByteStream = function (rawData) {
116
116
  const decoder = new _TextDecoder();
@@ -124,7 +124,7 @@ sanitizeSvg.sanitizeByteStream = function (rawData) {
124
124
  * fixup-svg-string.js, and thus more risky; there are known examples of SVGs that
125
125
  * it will clobber. We use DOMPurify's svg profile, which restricts many types of tag.
126
126
  * @param {!string} rawSvgText unsanitized SVG string
127
- * @return {string} sanitized SVG text
127
+ * @returns {string} sanitized SVG text
128
128
  */
129
129
  sanitizeSvg.sanitizeSvgText = function (rawSvgText) {
130
130
  let sanitizedText = DOMPurify.sanitize(rawSvgText, {
@@ -10,7 +10,7 @@ class SvgRenderer {
10
10
  * Create a quirks-mode SVG renderer for a particular canvas.
11
11
  * @param {HTMLCanvasElement} [canvas] An optional canvas element to draw to. If this is not provided, the renderer
12
12
  * will create a new canvas.
13
- * @constructor
13
+ * @class
14
14
  */
15
15
  constructor (canvas) {
16
16
  /**
@@ -59,14 +59,14 @@ class SvgRenderer {
59
59
  }
60
60
 
61
61
  /**
62
- * @return {Array<number>} the natural size, in Scratch units, of this SVG.
62
+ * @returns {Array<number>} the natural size, in Scratch units, of this SVG.
63
63
  */
64
64
  get size () {
65
65
  return [this._measurements.width, this._measurements.height];
66
66
  }
67
67
 
68
68
  /**
69
- * @return {Array<number>} the offset (upper left corner) of the SVG's view box.
69
+ * @returns {Array<number>} the offset (upper left corner) of the SVG's view box.
70
70
  */
71
71
  get viewOffset () {
72
72
  return [this._measurements.x, this._measurements.y];
@@ -143,7 +143,7 @@ class SvgRenderer {
143
143
  /**
144
144
  * Draw to the canvas from a loaded image element.
145
145
  * @param {number} [scale] - Optionally, also scale the image by this factor.
146
- **/
146
+ */
147
147
  _drawFromImage (scale) {
148
148
  if (this._cachedImage === null) return;
149
149
 
@@ -501,14 +501,13 @@ const _parseUrl = (value, windowRef) => {
501
501
  * on groups down to the leaf level and averaging out the stroke width
502
502
  * around the shapes. Note that this doens't just change stroke widths, it
503
503
  * changes path data and attributes throughout the SVG.
504
- *
505
504
  * @param {SVGElement} svgTag The SVG dom object
506
505
  * @param {Window} windowRef The window to use. Need to pass in for
507
506
  * tests to work, as they get angry at even the mention of window.
508
507
  * @param {object} bboxForTesting The bounds to use. Need to pass in for
509
508
  * tests only, because getBBox doesn't work in Node. This should
510
509
  * be the bounds of the svgTag without including stroke width or transforms.
511
- * @return {void}
510
+ * @returns {void}
512
511
  */
513
512
  const transformStrokeWidths = function (svgTag, windowRef, bboxForTesting) {
514
513
  const inherited = Matrix.identity();