diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 127a135..974ee14 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -65,7 +65,6 @@ jobs: - uses: ncipollo/release-action@v1 with: - # artifacts: "dist/wyzant-looker.zip,dist/changelog.md,CHANGELOG.md" allowUpdates: true artifacts: "build/jiffyReader*" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 0558a04..f305a01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.5.0](https://github.com/ansh/jiffyreader.com/compare/v1.4.0...v1.5.0) (2024-12-31) + + +### Features + +* ability to enable and disable elements on a page like buttons, links, ... etc ([30b889a](https://github.com/ansh/jiffyreader.com/commit/30b889a27906786c2220b4ec3d389d5790e697e2)) + ## [1.4.0](https://github.com/ansh/jiffyreader.com/compare/v1.3.5...v1.4.0) (2024-12-30) diff --git a/package-lock.json b/package-lock.json index b4d5991..7d97f02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jiffy-reader", - "version": "1.4.0", + "version": "1.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "jiffy-reader", - "version": "1.4.0", + "version": "1.5.0", "license": "ISC", "dependencies": { "@plasmohq/prettier-plugin-sort-imports": "^1.1.1", diff --git a/package.json b/package.json index 059514d..2026cfb 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "jiffy-reader", "displayName": "Jiffy reader", - "version": "1.4.0", + "version": "1.5.0", "description": "jiffy reader", "packageManager": "yarn@1.22.19", "scripts": { "dev": "PLASMO_PUBLIC_VERSION=\"$(npm pkg get version | tr -d '\"')\" PLASMO_PUBLIC_TARGET=${PLASMO_PUBLIC_TARGET:-chrome} PLASMO_PUBLIC_NAME=${PLASMO_PUBLIC_NAME:-\"jiffy-reader-chrome\"} PLASMO_PUBLIC_TAG=${PLASMO_PUBLIC_TAG:-dev} PLASMO_TAG=$PLASMO_PUBLIC_TAG PLASMO_PUBLIC_VERSION_NAME=$PLASMO_PUBLIC_VERSION-$PLASMO_PUBLIC_TARGET-$PLASMO_PUBLIC_TAG PLASMO_PUBLIC_DEBUG=${PLASMO_PUBLIC_DEBUG:-TRUE} PLASMO_PUBLIC_SHORTCUT=${PLASMO_PUBLIC_SHORTCUT:-\"Alt+B\"} plasmo dev --target=${PLASMO_PUBLIC_MANIFEST_VERSION:-chrome-mv3}", + "dev:bookmarklet": "nodemon -x 'pnpm gh:build:bookmarklet' -w src/Bookmarklet", "buildx": "PLASMO_PUBLIC_VERSION=\"$(npm pkg get version | tr -d '\"')\" PLASMO_PUBLIC_TARGET=${PLASMO_PUBLIC_TARGET:-chrome} PLASMO_PUBLIC_NAME=${PLASMO_PUBLIC_NAME:-\"Jiffy Reader\"} PLASMO_PUBLIC_TAG=${PLASMO_PUBLIC_TAG:-prod} PLASMO_TAG=$PLASMO_PUBLIC_TAG PLASMO_PUBLIC_VERSION_NAME=$PLASMO_PUBLIC_VERSION-$PLASMO_PUBLIC_TARGET-$PLASMO_PUBLIC_TAG PLASMO_PUBLIC_DEBUG=${PLASMO_PUBLIC_DEBUG:-FALSE} PLASMO_PUBLIC_SHORTCUT=${PLASMO_PUBLIC_SHORTCUT:-\"Alt+B\"} plasmo build --target=${PLASMO_PUBLIC_MANIFEST_VERSION:-chrome-mv3}", "build": "npm run build:opera && npm run build:chrome & npm run build:firefox & npm run build:safari", "dev:chrome": "npm run dev", @@ -19,7 +20,7 @@ "gh:build:opera": "PLASMO_PUBLIC_TARGET=opera PLASMO_PUBLIC_SHORTCUT=\"Alt+B\" PLASMO_PUBLIC_MANIFEST_VERSION=opera-mv3 npm run buildx && npm run bundle:opera", "gh:build:firefox": "PLASMO_PUBLIC_TARGET=firefox PLASMO_PUBLIC_SHORTCUT=\"Alt+W\" PLASMO_PUBLIC_MANIFEST_VERSION=firefox-mv2 npm run buildx && npm run bundle:firefox", "gh:build:safari": "PLASMO_PUBLIC_TARGET=safari PLASMO_PUBLIC_SHORTCUT=\"Alt+W\" PLASMO_PUBLIC_MANIFEST_VERSION=safari-mv2 npm run buildx && npm run bundle:safari", - "gh:build": "echo 'PLASMO_PUBLIC_TAG=prod NODE_ENV=production npm run gh:build:' | xargs -I{} bash -c '{}opera && {}chrome & {}firefox & {}safari && wait'", + "gh:build": "echo 'PLASMO_PUBLIC_TAG=prod NODE_ENV=production npm run gh:build:' | xargs -I{} bash -c '{}opera && {}chrome & {}firefox & {}safari && wait && pnpm gh:build:bookmarklet'", "gh:build:development": "echo 'PLASMO_PUBLIC_TAG=dev NODE_ENV=development PLASMO_PUBLIC_NAME=Jiffy-Reader-Dev npm run gh:build:' | xargs -I{} bash -c '{}opera && {}chrome & {}firefox & {}safari && wait'", "gh:build:bookmarklet": "PLASMO_PUBLIC_VERSION=\"$(npm pkg get version | tr -d '\"')\" node src/Bookmarklet/esbuild.mjs", "bundle": "npm run bundle:chrome & npm run bundle:firefix & npm run bundle:safari", @@ -49,8 +50,8 @@ "postcss": "^8.4.49", "react": "18.2.0", "react-dom": "18.2.0", - "webpack": "^4.47.0", - "zod": "^3.24.1" + "valibot": "1.0.0-beta.9", + "webpack": "^4.47.0" }, "devDependencies": { "@parcel/transformer-sass": "2.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ace5e05..6efd929 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,12 +41,12 @@ dependencies: react-dom: specifier: 18.2.0 version: 18.2.0(react@18.2.0) + valibot: + specifier: 1.0.0-beta.9 + version: 1.0.0-beta.9(typescript@4.7.4) webpack: specifier: ^4.47.0 version: 4.47.0 - zod: - specifier: ^3.24.1 - version: 3.24.1 devDependencies: '@parcel/transformer-sass': @@ -11656,7 +11656,6 @@ packages: resolution: {integrity: sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==} engines: {node: '>=4.2.0'} hasBin: true - dev: true /typescript@5.0.4: resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} @@ -11809,6 +11808,17 @@ packages: resolution: {integrity: sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw==} engines: {node: '>= 4'} + /valibot@1.0.0-beta.9(typescript@4.7.4): + resolution: {integrity: sha512-yEX8gMAZ2R1yI2uwOO4NCtVnJQx36zn3vD0omzzj9FhcoblvPukENIiRZXKZwCnqSeV80bMm8wNiGhQ0S8fiww==} + peerDependencies: + typescript: '>=5' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + typescript: 4.7.4 + dev: false + /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: @@ -12201,7 +12211,3 @@ packages: compress-commons: 4.1.2 readable-stream: 3.6.2 dev: false - - /zod@3.24.1: - resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==} - dev: false diff --git a/src/Bookmarklet/esbuild.mjs b/src/Bookmarklet/esbuild.mjs index 8662ea2..4649e1a 100644 --- a/src/Bookmarklet/esbuild.mjs +++ b/src/Bookmarklet/esbuild.mjs @@ -7,7 +7,16 @@ const /** @type {import('esbuild').BuildOptions} */ defaultConfigs = { minify: true, write: false, plugins: [sassPlugin({ type: 'css-text' })], - define: { 'process.env.PLASMO_PUBLIC_DEBUG': '"false"' }, + define: { + 'process.env.PLASMO_PUBLIC_SHORTCUT': `'${process.env.PLASMO_PUBLIC_SHORTCUT}'`, + 'process.env.PLASMO_PUBLIC_VERSION': `'${process.env.PLASMO_PUBLIC_VERSION}'`, + 'process.env.PLASMO_PUBLIC_VERSION_NAME': `'${process.env.PLASMO_PUBLIC_VERSION_NAME}'`, + 'process.env.PLASMO_PUBLIC_TARGET': `'${process.env.PLASMO_PUBLIC_TARGET}'`, + 'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`, + 'process.env.PLASMO_PUBLIC_DEBUG': `'${process.env.PLASMO_PUBLIC_DEBUG ?? 'FALSE'}'`, + 'process.env.PLASMO_PUBLIC_ENABLE_TRACKING': `'${process.env.PLASMO_PUBLIC_ENABLE_TRACKING ?? 'FALSE'}'`, + 'process.env.PLASMO_PUBLIC_HOME_URL': `'${process.env.PLASMO_PUBLIC_HOME_URL}'`, + }, tsconfig: './tsconfig.json', }; @@ -23,7 +32,7 @@ build({ }) .then(({ outputFiles: [res] }) => { const outputScript = res.text.replace(/\n/g, ''); - const output = [ + const buttons = [ ...[ ['JiffyReader Toggle', 'fireReadingToggle'], ['FixationStrength Toggle', 'fireFixationStrengthTransition'], @@ -35,6 +44,8 @@ build({ `

Drag any of the links above onto your bookmark bar to save it as a bookmarklet which works on any site just like the full extension
Version: ${process.env.PLASMO_PUBLIC_VERSION}

`, ].join(' '); + const output = `
${buttons}
`; + fs.writeFileSync(outputFile, output); }) .catch((error) => { diff --git a/src/services/Logger.ts b/src/services/Logger.ts index 44216d3..d288bcf 100644 --- a/src/services/Logger.ts +++ b/src/services/Logger.ts @@ -5,14 +5,6 @@ import { envService } from './envService'; -/** - * @description stateMachine of debug to cantDebug states - */ -const debugStates = new Map([ - ['true', false], - ['false', true], -]); - const cantDebug = (shouldDebug: boolean = false) => !shouldDebug; const nullCallback = () => null; diff --git a/src/services/envService.ts b/src/services/envService.ts index 69197f8..76403ab 100644 --- a/src/services/envService.ts +++ b/src/services/envService.ts @@ -1,70 +1,51 @@ -import { z } from 'zod'; - -const booleanMap = new Map<'true' | 'false' | undefined, boolean>([ - ['true', true], - ['false', false], - [undefined, false], -]); +import { boolean, object, optional, parse, picklist, pipe, string, transform, ValiError, type InferOutput } from 'valibot'; const env = { - PLASMO_PUBLIC_SHORTCUT: { value: process.env.PLASMO_PUBLIC_SHORTCUT, validator: z.string() }, - PLASMO_PUBLIC_VERSION: { value: process.env.PLASMO_PUBLIC_VERSION, validator: z.string().optional() }, - PLASMO_PUBLIC_VERSION_NAME: { value: process.env.PLASMO_PUBLIC_VERSION_NAME, validator: z.string().optional() }, + PLASMO_PUBLIC_SHORTCUT: { value: process.env.PLASMO_PUBLIC_SHORTCUT, validator: string() }, + PLASMO_PUBLIC_VERSION: { value: process.env.PLASMO_PUBLIC_VERSION, validator: string() }, + PLASMO_PUBLIC_VERSION_NAME: { value: process.env.PLASMO_PUBLIC_VERSION_NAME, validator: string() }, PLASMO_PUBLIC_TARGET: { value: process.env.PLASMO_PUBLIC_TARGET, - validator: z - .string() - .default('') - .transform((x) => x as typeof process.env.PLASMO_PUBLIC_TARGET), + validator: string(), }, NODE_ENV: { value: process.env.NODE_ENV, - validator: z - .string() - .optional() - .transform((x) => x as typeof process.env.NODE_ENV), + validator: pipe( + string(), + transform((input) => input as typeof process.env.NODE_ENV), + ), }, PLASMO_PUBLIC_DEBUG: { value: process.env.PLASMO_PUBLIC_DEBUG, - validator: z - .boolean() - .or( - z - .enum(['TRUE', 'FALSE']) - // .optional() - // .default('true') - .transform((x) => booleanMap.get(x as keyof typeof booleanMap.keys)), - ) - .default(false), + validator: pipe( + optional(picklist(['TRUE', 'FALSE'] as const), 'FALSE'), + transform((input) => ({ TRUE: true, FALSE: false, '': false })[input]), + boolean(), + ), }, PLASMO_PUBLIC_ENABLE_TRACKING: { value: process.env.PLASMO_PUBLIC_ENABLE_TRACKING, - validator: z - .boolean() - .or( - z - .enum(['true', 'false']) - .optional() - .default('false') - .transform((x) => booleanMap.get(x as keyof typeof booleanMap.keys)), - ) - .default(false), + validator: pipe( + optional(picklist(['TRUE', 'FALSE'] as const), 'FALSE'), + transform((input) => ({ TRUE: true, FALSE: false })[input] ?? false), + boolean(), + ), }, - PLASMO_PUBLIC_HOME_URL: { value: process.env.PLASMO_PUBLIC_HOME_URL, validator: z.string().optional() }, + PLASMO_PUBLIC_HOME_URL: { value: process.env.PLASMO_PUBLIC_HOME_URL, validator: optional(string(), '') }, }; type Env = typeof env; console.log({ env }); -let envSchema = z.object(Object.fromEntries(Object.entries(env).map(([key, { validator }]) => [key, validator])) as { [K in keyof Env]: Env[K]['validator'] }); +let envSchema = object(Object.fromEntries(Object.entries(env).map(([key, { validator }]) => [key, validator])) as { [K in keyof Env]: Env[K]['validator'] }); let envSelection = Object.fromEntries(Object.entries(env).map(([key, { value }]) => [key, value])) as (typeof process)['env']; -let sourceEnv: z.infer; +let sourceEnv: InferOutput; try { - sourceEnv = envSchema.parse(envSelection); + sourceEnv = parse(envSchema, envSelection); } catch (error) { - const zerr = JSON.stringify((error as z.ZodError).flatten(), null, 2); + const zerr = JSON.stringify(error as typeof ValiError, null, 2); console.error(zerr); throw new Error(zerr); } diff --git a/tsconfig.json b/tsconfig.json index 139ceb6..441fafb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,10 +3,11 @@ "exclude": ["node_modules"], "include": [".plasmo/index.d.ts", ".plasmo/**/*", "./**/*.ts", "./**/*.tsx"], "compilerOptions": { - "target": "ES2023", + "target": "ES2018", "strict": true, "noUnusedLocals": true, "alwaysStrict": true, + "removeComments": true, "baseUrl": ".", "paths": { "~*": ["./src/*"]