Skip to content

Commit 44dcc82

Browse files
Merge pull request #319 from asieduernest12/master
fix bookmarklet, replace zod with valibot
2 parents 30f59d1 + db96414 commit 44dcc82

File tree

9 files changed

+67
-69
lines changed

9 files changed

+67
-69
lines changed

.github/workflows/publish-release.yml

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ jobs:
6565

6666
- uses: ncipollo/release-action@v1
6767
with:
68-
# artifacts: "dist/wyzant-looker.zip,dist/changelog.md,CHANGELOG.md"
6968
allowUpdates: true
7069
artifacts: "build/jiffyReader*"
7170
token: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
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.
44

5+
## [1.5.0](https://github.com/ansh/jiffyreader.com/compare/v1.4.0...v1.5.0) (2024-12-31)
6+
7+
8+
### Features
9+
10+
* ability to enable and disable elements on a page like buttons, links, ... etc ([30b889a](https://github.com/ansh/jiffyreader.com/commit/30b889a27906786c2220b4ec3d389d5790e697e2))
11+
512
## [1.4.0](https://github.com/ansh/jiffyreader.com/compare/v1.3.5...v1.4.0) (2024-12-30)
613

714

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "jiffy-reader",
33
"displayName": "Jiffy reader",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"description": "jiffy reader",
66
"packageManager": "[email protected]",
77
"scripts": {
88
"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}",
9+
"dev:bookmarklet": "nodemon -x 'pnpm gh:build:bookmarklet' -w src/Bookmarklet",
910
"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}",
1011
"build": "npm run build:opera && npm run build:chrome & npm run build:firefox & npm run build:safari",
1112
"dev:chrome": "npm run dev",
@@ -19,7 +20,7 @@
1920
"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",
2021
"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",
2122
"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",
22-
"gh:build": "echo 'PLASMO_PUBLIC_TAG=prod NODE_ENV=production npm run gh:build:' | xargs -I{} bash -c '{}opera && {}chrome & {}firefox & {}safari && wait'",
23+
"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'",
2324
"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'",
2425
"gh:build:bookmarklet": "PLASMO_PUBLIC_VERSION=\"$(npm pkg get version | tr -d '\"')\" node src/Bookmarklet/esbuild.mjs",
2526
"bundle": "npm run bundle:chrome & npm run bundle:firefix & npm run bundle:safari",
@@ -49,8 +50,8 @@
4950
"postcss": "^8.4.49",
5051
"react": "18.2.0",
5152
"react-dom": "18.2.0",
52-
"webpack": "^4.47.0",
53-
"zod": "^3.24.1"
53+
"valibot": "1.0.0-beta.9",
54+
"webpack": "^4.47.0"
5455
},
5556
"devDependencies": {
5657
"@parcel/transformer-sass": "2.6.2",

pnpm-lock.yaml

+14-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bookmarklet/esbuild.mjs

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ const /** @type {import('esbuild').BuildOptions} */ defaultConfigs = {
77
minify: true,
88
write: false,
99
plugins: [sassPlugin({ type: 'css-text' })],
10-
define: { 'process.env.PLASMO_PUBLIC_DEBUG': '"false"' },
10+
define: {
11+
'process.env.PLASMO_PUBLIC_SHORTCUT': `'${process.env.PLASMO_PUBLIC_SHORTCUT}'`,
12+
'process.env.PLASMO_PUBLIC_VERSION': `'${process.env.PLASMO_PUBLIC_VERSION}'`,
13+
'process.env.PLASMO_PUBLIC_VERSION_NAME': `'${process.env.PLASMO_PUBLIC_VERSION_NAME}'`,
14+
'process.env.PLASMO_PUBLIC_TARGET': `'${process.env.PLASMO_PUBLIC_TARGET}'`,
15+
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
16+
'process.env.PLASMO_PUBLIC_DEBUG': `'${process.env.PLASMO_PUBLIC_DEBUG ?? 'FALSE'}'`,
17+
'process.env.PLASMO_PUBLIC_ENABLE_TRACKING': `'${process.env.PLASMO_PUBLIC_ENABLE_TRACKING ?? 'FALSE'}'`,
18+
'process.env.PLASMO_PUBLIC_HOME_URL': `'${process.env.PLASMO_PUBLIC_HOME_URL}'`,
19+
},
1120
tsconfig: './tsconfig.json',
1221
};
1322

@@ -23,7 +32,7 @@ build({
2332
})
2433
.then(({ outputFiles: [res] }) => {
2534
const outputScript = res.text.replace(/\n/g, '');
26-
const output = [
35+
const buttons = [
2736
...[
2837
['JiffyReader Toggle', 'fireReadingToggle'],
2938
['FixationStrength Toggle', 'fireFixationStrengthTransition'],
@@ -35,6 +44,8 @@ build({
3544
`<p>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 <br/>Version: ${process.env.PLASMO_PUBLIC_VERSION}</p>`,
3645
].join(' ');
3746

47+
const output = `<div style='display: block grid; grid-template-columns: repeat(5,1fr);grid-template-rows: repeat(2,40px);'>${buttons}<div></div>`;
48+
3849
fs.writeFileSync(outputFile, output);
3950
})
4051
.catch((error) => {

src/services/Logger.ts

-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55

66
import { envService } from './envService';
77

8-
/**
9-
* @description stateMachine of debug to cantDebug states
10-
*/
11-
const debugStates = new Map([
12-
['true', false],
13-
['false', true],
14-
]);
15-
168
const cantDebug = (shouldDebug: boolean = false) => !shouldDebug;
179

1810
const nullCallback = () => null;

src/services/envService.ts

+24-43
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,51 @@
1-
import { z } from 'zod';
2-
3-
const booleanMap = new Map<'true' | 'false' | undefined, boolean>([
4-
['true', true],
5-
['false', false],
6-
[undefined, false],
7-
]);
1+
import { boolean, object, optional, parse, picklist, pipe, string, transform, ValiError, type InferOutput } from 'valibot';
82

93
const env = {
10-
PLASMO_PUBLIC_SHORTCUT: { value: process.env.PLASMO_PUBLIC_SHORTCUT, validator: z.string() },
11-
PLASMO_PUBLIC_VERSION: { value: process.env.PLASMO_PUBLIC_VERSION, validator: z.string().optional() },
12-
PLASMO_PUBLIC_VERSION_NAME: { value: process.env.PLASMO_PUBLIC_VERSION_NAME, validator: z.string().optional() },
4+
PLASMO_PUBLIC_SHORTCUT: { value: process.env.PLASMO_PUBLIC_SHORTCUT, validator: string() },
5+
PLASMO_PUBLIC_VERSION: { value: process.env.PLASMO_PUBLIC_VERSION, validator: string() },
6+
PLASMO_PUBLIC_VERSION_NAME: { value: process.env.PLASMO_PUBLIC_VERSION_NAME, validator: string() },
137
PLASMO_PUBLIC_TARGET: {
148
value: process.env.PLASMO_PUBLIC_TARGET,
15-
validator: z
16-
.string()
17-
.default('')
18-
.transform((x) => x as typeof process.env.PLASMO_PUBLIC_TARGET),
9+
validator: string(),
1910
},
2011
NODE_ENV: {
2112
value: process.env.NODE_ENV,
22-
validator: z
23-
.string()
24-
.optional()
25-
.transform((x) => x as typeof process.env.NODE_ENV),
13+
validator: pipe(
14+
string(),
15+
transform((input) => input as typeof process.env.NODE_ENV),
16+
),
2617
},
2718
PLASMO_PUBLIC_DEBUG: {
2819
value: process.env.PLASMO_PUBLIC_DEBUG,
29-
validator: z
30-
.boolean()
31-
.or(
32-
z
33-
.enum(['TRUE', 'FALSE'])
34-
// .optional()
35-
// .default('true')
36-
.transform((x) => booleanMap.get(x as keyof typeof booleanMap.keys)),
37-
)
38-
.default(false),
20+
validator: pipe(
21+
optional(picklist(['TRUE', 'FALSE'] as const), 'FALSE'),
22+
transform((input) => ({ TRUE: true, FALSE: false, '': false })[input]),
23+
boolean(),
24+
),
3925
},
4026
PLASMO_PUBLIC_ENABLE_TRACKING: {
4127
value: process.env.PLASMO_PUBLIC_ENABLE_TRACKING,
42-
validator: z
43-
.boolean()
44-
.or(
45-
z
46-
.enum(['true', 'false'])
47-
.optional()
48-
.default('false')
49-
.transform((x) => booleanMap.get(x as keyof typeof booleanMap.keys)),
50-
)
51-
.default(false),
28+
validator: pipe(
29+
optional(picklist(['TRUE', 'FALSE'] as const), 'FALSE'),
30+
transform((input) => ({ TRUE: true, FALSE: false })[input] ?? false),
31+
boolean(),
32+
),
5233
},
53-
PLASMO_PUBLIC_HOME_URL: { value: process.env.PLASMO_PUBLIC_HOME_URL, validator: z.string().optional() },
34+
PLASMO_PUBLIC_HOME_URL: { value: process.env.PLASMO_PUBLIC_HOME_URL, validator: optional(string(), '') },
5435
};
5536

5637
type Env = typeof env;
5738

5839
console.log({ env });
5940

60-
let envSchema = z.object(Object.fromEntries(Object.entries(env).map(([key, { validator }]) => [key, validator])) as { [K in keyof Env]: Env[K]['validator'] });
41+
let envSchema = object(Object.fromEntries(Object.entries(env).map(([key, { validator }]) => [key, validator])) as { [K in keyof Env]: Env[K]['validator'] });
6142
let envSelection = Object.fromEntries(Object.entries(env).map(([key, { value }]) => [key, value])) as (typeof process)['env'];
62-
let sourceEnv: z.infer<typeof envSchema>;
43+
let sourceEnv: InferOutput<typeof envSchema>;
6344

6445
try {
65-
sourceEnv = envSchema.parse(envSelection);
46+
sourceEnv = parse(envSchema, envSelection);
6647
} catch (error) {
67-
const zerr = JSON.stringify((error as z.ZodError).flatten(), null, 2);
48+
const zerr = JSON.stringify(error as typeof ValiError, null, 2);
6849
console.error(zerr);
6950
throw new Error(zerr);
7051
}

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"exclude": ["node_modules"],
44
"include": [".plasmo/index.d.ts", ".plasmo/**/*", "./**/*.ts", "./**/*.tsx"],
55
"compilerOptions": {
6-
"target": "ES2023",
6+
"target": "ES2018",
77
"strict": true,
88
"noUnusedLocals": true,
99
"alwaysStrict": true,
10+
"removeComments": true,
1011
"baseUrl": ".",
1112
"paths": {
1213
"~*": ["./src/*"]

0 commit comments

Comments
 (0)