From 777f4948083fce3332c91f32fa175b5da40e43a8 Mon Sep 17 00:00:00 2001 From: Chris Zuber Date: Thu, 19 Sep 2024 15:29:57 -0700 Subject: [PATCH 1/2] Fix importing polyfills in `md5.js` ### Added - Add `safeExecute` function in `utility.js` ### Fixed - Do not import polyfills in `md5.js` (duplicate policy conflicts) --- CHANGELOG.md | 8 ++++++++ md5.js | 3 +-- package-lock.json | 4 ++-- package.json | 2 +- test/css/index.css | 9 +++++++++ test/index.html | 17 ++++++++++++----- test/js/index.js | 30 +++++++++++++++++++++++++++++- utility.js | 17 +++++++++++++++++ 8 files changed, 79 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4421a63..a93d75c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v1.0.9] - 2024-09-19 + +### Added +- Add `safeExecute` function in `utility.js` + +### Fixed +- Do not import polyfills in `md5.js` (duplicate policy conflicts) + ## [v1.0.8] - 2024-09-17 ### Added diff --git a/md5.js b/md5.js index ee7b2a9..d5e54c8 100644 --- a/md5.js +++ b/md5.js @@ -1,5 +1,3 @@ -import '@shgysk8zer0/polyfills'; - const K = new Uint32Array([ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, @@ -25,6 +23,7 @@ const s = [ 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21 ]; + const a0 = 0x67452301; const b0 = 0xefcdab89; const c0 = 0x98badcfe; diff --git a/package-lock.json b/package-lock.json index 348971f..f168544 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@shgysk8zer0/kazoo", - "version": "1.0.8", + "version": "1.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@shgysk8zer0/kazoo", - "version": "1.0.8", + "version": "1.0.9", "funding": [ { "type": "librepay", diff --git a/package.json b/package.json index ed30bbd..77c9f37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@shgysk8zer0/kazoo", - "version": "1.0.8", + "version": "1.0.9", "private": false, "type": "module", "description": "A JavaScript monorepo for all the things!", diff --git a/test/css/index.css b/test/css/index.css index e3e7c91..401abe2 100644 --- a/test/css/index.css +++ b/test/css/index.css @@ -8,6 +8,15 @@ box-sizing: inherit; } +:popover-open { + border: none; +} + +:popover-open::backdrop { + background-color: rgba(0, 0, 0, 0.7); + backdrop-filter: blur(4px); +} + body { display: grid; margin: 0; diff --git a/test/index.html b/test/index.html index 6753bfa..c64687a 100644 --- a/test/index.html +++ b/test/index.html @@ -4,7 +4,7 @@ - + - + @@ -86,6 +84,15 @@
+
+
+ Gravatar Test + + +
+ + +
diff --git a/test/js/index.js b/test/js/index.js index 0bf042b..8fcb494 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -1,9 +1,10 @@ import { createElement } from '../../elements.js'; import { getJSON, getHTML } from '../../http.js'; -import { html, attr, each } from '../../dom.js'; +import { html, attr, each, on } from '../../dom.js'; import { animate } from '../../animate.js'; import { createYouTubeEmbed } from '../../youtube.js'; import { createSVGFile } from '../../svg.js'; +import { createGravatar } from '../../gravatar.js'; import * as icons from '../../icons.js'; import { whenIntersecting } from '../../intersect.js'; import { isPrime } from '../../math.js'; @@ -25,6 +26,33 @@ registerLanguage('bash', bash); registerLanguage('xml', xml); registerLanguage('html', xml); +on('#grav', 'submit', async event => { + event.preventDefault(); + const data = new FormData(event.target); + const img = await createGravatar(data.get('email'), { + size: 512, + animation: { + keyframes: [ + { opacity: 0, transform: 'scale(0)' }, + { opacity: 1, transform: 'none' }, + ], + duration: 300, + easing: 'ease-in-out', + }, + events:{ + toggle(event) { + if (event.newState === 'closed') { + event.target.remove(); + } + } + } + }); + + img.popover = 'auto'; + document.body.append(img); + img.showPopover(); +}); + fetchMarkdown('../../README.md').then(frag => { const readme = document.createElement('div'); readme.id = 'readme-popover'; diff --git a/utility.js b/utility.js index fb8a7fb..f02b434 100644 --- a/utility.js +++ b/utility.js @@ -458,3 +458,20 @@ export const ucFirst = str => str.toString().substring(0, 1).toUpperCase() + str export async function filterKeys(obj, keys) { return Object.fromEntries(Object.entries(obj).filter(([key]) => keys.includes(key))); } + +/** + * Safely executes a callback function and returns a tuple of [result, error]. + * + * @param {Function} cb - The callback function to execute. + * @returns {Promise<[any, Error|null]>} A promise that resolves with a tuple `[result|null, Error|null]`. + * The tuple is frozen to ensure immutability. + */ +export async function safeExecute(cb) { + if (! (cb instanceof Function)) { + return Object.freeze(null, new TypeError('Callback is not a function.')); + } else { + return Promise.try(cb) + .then(result => Object.freeze([result, null])) + .catch(err => Object.freeze([null, err])); + } +} From f8b1be29d4a9ef35c0ce340b00e735afa00ecb6c Mon Sep 17 00:00:00 2001 From: Chris Zuber Date: Thu, 19 Sep 2024 15:37:22 -0700 Subject: [PATCH 2/2] Disable CSS linting in super linter --- .github/workflows/super-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index 30bc516..350cfd2 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -88,7 +88,7 @@ jobs: # Valate Languages - Uncomment to Enable # JS/TS/JSON Disabled until ESLint in super-linter is updated VALIDATE_HTML: true - VALIDATE_CSS: true + # VALIDATE_CSS: true # VALIDATE_JAVASCRIPT_ES: true # VALIDATE_JAVASCRIPT_STANDARD: true # VALIDATE_JSON: true