Skip to content

Commit

Permalink
Merge pull request #215 from bhollis/manifest-v3
Browse files Browse the repository at this point in the history
Manifest v3
  • Loading branch information
bhollis authored Jun 16, 2024
2 parents 71b6ffc + c208220 commit bf7a463
Show file tree
Hide file tree
Showing 22 changed files with 3,166 additions and 2,569 deletions.
186 changes: 0 additions & 186 deletions .eslintrc

This file was deleted.

12 changes: 7 additions & 5 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: yarn
node-version-file: ".nvmrc"
cache: pnpm

- name: Install
run: yarn install --frozen-lockfile --prefer-offline
run: pnpm install --frozen-lockfile --prefer-offline

- name: Lint
run: yarn lint
run: pnpm lint

- name: Build
run: yarn start
run: pnpm start
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
.tern-port
/ts-out
/build
/build-*
/node_modules

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"gamunu.vscode-yarn",
"Jacano.vscode-pnpm",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
Expand Down
7 changes: 3 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
"files.trimTrailingWhitespace": true,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": true,
"eslint.packageManager": "yarn",
"eslint.validate": ["javascript", "typescript"],
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"jest.jestCommandLine": "yarn test",
"jest.jestCommandLine": "pnpm test --",
"[javascript]": {
"editor.codeActionsOnSave": {
"source.organizeImports": false
"source.organizeImports": "never"
}
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.organizeImports": false
"source.organizeImports": "never"
}
},
"[javascript][typescript]": {
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## JSONView 3.0.0

- JSONView is now compatible with Manifest V3, which is required in Chrome.
- The JSON object is _no longer available_ from the console via the global "data" property in Chrome, due to Manifest V3 changes.
- Fixed JSONView in Edge, where it was conflicting with Edge's new built-in JSON viewer. If you like Edge's default viewer you can uninstall JSONView.
- Fixed detection of "bare" object keys to more reliably follow what a JavaScript object literal would allow.

## JSONView 2.6.1

- Restore JSONView's ability to work in Firefox without having to manually disable the built-in JSON viewer.
Expand Down
49 changes: 22 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
JSONView
========
# JSONView

[JSONView](http://jsonview.com) is a Web extension compatible with Firefox and Google Chrome that helps you view JSON documents in the browser.

* [Install for Firefox](https://addons.mozilla.org/en-US/firefox/addon/jsonview/)
* [Install for Chrome](https://chrome.google.com/webstore/detail/jsonview/gmegofmjomhknnokphhckolhcffdaihd)
* [Install for Edge](https://microsoftedge.microsoft.com/addons/detail/jsonview/kmpfgkgaimakokfhgdahhiaaiidiphco)
- [Install for Firefox](https://addons.mozilla.org/en-US/firefox/addon/jsonview/)
- [Install for Chrome](https://chrome.google.com/webstore/detail/jsonview/gmegofmjomhknnokphhckolhcffdaihd)
- [Install for Edge](https://microsoftedge.microsoft.com/addons/detail/jsonview/kmpfgkgaimakokfhgdahhiaaiidiphco)

Normally, when encountering a [JSON](http://json.org) document (content type `application/json`), Firefox simply prompts you to download the view. With the JSONView extension, JSON documents are shown in the browser similar to how XML documents are shown. The document is formatted, highlighted, and arrays and objects can be collapsed. Even if the JSON document contains errors, JSONView will still show the raw text.

Once you've got JSONView installed, check out [this example JSON file](http://jsonview.com/example.json) to see the extension in action!

If you'd like to contribute to JSONView but don't want to code, consider contributing a translation. Copy the existing localization files from `src/_locale` and fill them in for your own language, then send a pull request. You can do it all from the GitHub interface. There are not many strings to translate!

Keyboard Shortcuts
----------------
## Keyboard Shortcuts

* Left Arrow - Collapses the json on key up
* Right Arrow - Expands the json on key up
- Left Arrow - Collapses the json on key up
- Right Arrow - Expands the json on key up

Reporting Issues
----------------
## Reporting Issues

Use the GitHub [Issue tracker for JSONView](https://github.com/bhollis/jsonview/issues) to file issues. Pull requests are especially welcome.

Developing JSONView
-------------------
## Developing JSONView

Before contributing to JSONView, make sure to read the [Contributing Guidelines](CONTRIBUTING.md). I appreciate contributions people make to JSONView, but the goal of the extension is to be simple and straightforward, so I frequently reject contributions that add complexity or unnecessary features. Please consider filing an issue before doing any work, so you don't waste time on something I won't accept.

* Install [NodeJS](https://nodejs.org/en/) and [Yarn](https://yarnpkg.com/en/docs/install).
* Check out jsonview.
* Run `yarn` inside the jsonview repository.
* Run `yarn start` to build the extension.
* In Firefox, go to `about:debugging#addons` in the address bar, check "Enable add-on debugging", select "Load Temporary Add-on", and choose the `jsonview/build` folder.
* In Chrome, go to `chrome://extensions/` in the address bar, select "Load Unpacked", and choose the `jsonview/build` folder.
- Install [NodeJS](https://nodejs.org/en/) and run `corepack enable`.
- Check out jsonview.
- Run `pnpm i` inside the jsonview repository.
- Run `pnpm start` to build the extension.
- In Firefox, go to `about:debugging#addons` in the address bar, check "Enable add-on debugging", select "Load Temporary Add-on", and choose the `jsonview/build-firefox/manifest.json` file.
- In Chrome, Edge, etc., go to `edge://extensions/`, in the address bar, enable "Developer mode", select "Load Unpacked", and choose the `jsonview/build-chrome` folder.

JSONView makes use of [TypeScript](https://www.typescriptlang.org/). I recommend [VSCode](https://code.visualstudio.com/) for editing the code - it will automatically prompt to install the correct extensions, and will highlight errors. All of the code that makes up the extension itself are in `src/`.

Common Issues
-------------
* **JSONView isn't displaying my file as JSON**: You are probably not serving
## Common Issues

- **JSONView isn't displaying my file as JSON**: You are probably not serving
the JSON with the "application/json" MIME type.
* **Opening a local .json file uses the Firefox default JSON viewer**: You need to disable the built-in JSON viewer to use JSONView. Go to "about:config" and set "devtools.jsonview.enabled" to "false".
- **Opening a local .json file uses the Firefox default JSON viewer**: You need to disable the built-in JSON viewer to use JSONView. Go to "about:config" and set "devtools.jsonview.enabled" to "false".

JSONView is open source software under the MIT license.

Publishing
----------
## Publishing

```
npm start
pnpm start
```

`jsonview.zip` can then be manually uploaded to the extension sites.
`jsonview-chrome.zip` and `jsonview-firefox.zip` can then be manually uploaded to the extension sites.
48 changes: 33 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,37 @@ tsc

node --test

rm -rf build
mkdir -p build

rollup ts-out/background.js --format iife --name 'background' --file build/background.js
rollup ts-out/content.js --format iife --name 'background' --file build/content.js
rollup ts-out/viewer.js --format iife --name 'background' --file build/viewer.js
cp src/viewer.css build/viewer.css
cp src/manifest.json build/manifest.json
cp license.txt build/license.txt
cp -r src/_locales build
cp src/icon*.png build

rm -f jsonview.zip
pushd build
zip -r ../jsonview.zip *
# Chrome
rm -rf build-chrome
mkdir -p build-chrome

rollup ts-out/background-chrome.js --format es --name 'background' --file build-chrome/background.js
rollup ts-out/content.js --format es --name 'content' --file build-chrome/content.js
cp src/viewer.css build-chrome/viewer.css
cp src/manifest.chrome.json build-chrome/manifest.json
cp license.txt build-chrome/license.txt
cp -r src/_locales build-chrome
cp src/icon*.png build-chrome

rm -f jsonview-chrome.zip
pushd build-chrome
zip -r -q ../jsonview-chrome.zip *
popd


# Firefox
rm -rf build-firefox
mkdir -p build-firefox

rollup ts-out/background-firefox.js --format es --name 'background' --file build-firefox/background.js
rollup ts-out/content.js --format es --name 'content' --file build-firefox/content.js
cp src/viewer.css build-firefox/viewer.css
cp src/manifest.firefox.json build-firefox/manifest.json
cp license.txt build-firefox/license.txt
cp -r src/_locales build-firefox
cp src/icon*.png build-firefox

rm -f jsonview-firefox.zip
pushd build-firefox
zip -r -q ../jsonview-firefox.zip *
popd
Loading

0 comments on commit bf7a463

Please sign in to comment.