From c3c6a1bd4e391958b7112247219d61dec3cf806a Mon Sep 17 00:00:00 2001 From: Atanas Atanasov Date: Wed, 4 Jan 2023 15:07:35 +0200 Subject: [PATCH] Migrate to TypeScript and Node 18 (#152) --- .codebeatsettings | 28 + .github/workflows/build.yml | 2 +- .npmignore | 1 + .nvmrc | 1 + README.md | 8 +- demo/index.html | 8 +- demo/scripts/node.js | 9 - demo/scripts/node.mjs | 13 + package.json | 22 +- src/svg64.js | 136 -- src/svg64.ts | 93 + tsconfig.json | 39 + yarn.lock | 3273 ++++++++++++++++++++++++++++++++++- 13 files changed, 3470 insertions(+), 163 deletions(-) create mode 100644 .codebeatsettings create mode 100644 .nvmrc delete mode 100644 demo/scripts/node.js create mode 100644 demo/scripts/node.mjs delete mode 100644 src/svg64.js create mode 100644 src/svg64.ts create mode 100644 tsconfig.json diff --git a/.codebeatsettings b/.codebeatsettings new file mode 100644 index 0000000..cd81b13 --- /dev/null +++ b/.codebeatsettings @@ -0,0 +1,28 @@ +{ + "TYPESCRIPT": { + "ABC": [ + 20, + 40, + 80, + 120 + ], + "LOC": [ + 50, + 80, + 120, + 160 + ], + "TOTAL_LOC": [ + 400, + 500, + 640, + 900 + ], + "BLOCK_NESTING": [ + 6, + 8, + 10, + 12 + ] + } +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad18ca2..6b40cb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x] + node-version: [18.x] steps: - uses: actions/checkout@v3 diff --git a/.npmignore b/.npmignore index 5b49455..f5c3cfb 100644 --- a/.npmignore +++ b/.npmignore @@ -21,6 +21,7 @@ Thumbs.db .github _config.yml _.config.yml +.codebeatsettings .editorconfig .gitattributes .gitignore diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..b009dfb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/README.md b/README.md index 5df4338..93db3ac 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,11 @@ or unclude it from unpkg.com ## Usage -### In a browser: +### In a browser ```javascript +import svg64 from 'svg64'; // or use window.svg64.default + // This is your SVG DOM element const svg = document.getElementById('svg'); @@ -65,13 +67,13 @@ const svg = document.getElementById('svg'); const demo = document.getElementById('demo'); // This is your SVG in base64 representation -const base64fromSVG = window.svg64(svg); +const base64fromSVG = svg64(svg); // Add the base64 image as a background to your element demo.style.backgroundImage = `url(${base64fromSVG})`; ``` -### In Node: +### In Node ```javascript // Require svg64 diff --git a/demo/index.html b/demo/index.html index 310f85b..1308620 100644 --- a/demo/index.html +++ b/demo/index.html @@ -146,8 +146,10 @@

Usage in browser

+import svg64 from 'svg64'; // or use window.svg64.default
+
 const svg = document.getElementById('svg');
-const b64 = window.svg64(svg);
+const b64 = svg64(svg);
 const demo = document.getElementById('demo');
 
 demo.style.backgroundImage = `url(${b64})`;
@@ -212,11 +214,11 @@ 

This is the base64 encoded SVG used as a backgrou - +