Skip to content

Commit

Permalink
Discovery 81 update (#89)
Browse files Browse the repository at this point in the history
* Updated discovery, added what's new page

* Updated discovery, updated esbuild, fixed build script, added whatsnew content

* Last tweaks
  • Loading branch information
exdis authored Mar 7, 2024
1 parent 0c9ef6e commit 6b4334c
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 210 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## next

* Updated `discovery` to `1.0.0-beta.81`
* Added "What's new" page

## 1.13.4 (29-09-2023)

* Fixed JSON detection in Chrome browser
Expand Down
429 changes: 227 additions & 202 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsondiscovery",
"version": "1.13.4",
"version": "1.13.5",
"description": "Browser (Chrome, Firefox) extension for JSON discovery",
"author": "[email protected]",
"license": "MIT",
Expand All @@ -11,10 +11,10 @@
"build": "NODE_ENV=production node ./scripts/build.js && node ./scripts/zip.js"
},
"devDependencies": {
"@discoveryjs/discovery": "1.0.0-beta.68",
"@discoveryjs/discovery": "1.0.0-beta.81",
"@discoveryjs/json-ext": "^0.5.7",
"css-tree": "^2.3.1",
"esbuild": "^0.19.4",
"esbuild": "^0.20.1",
"eslint": "^8.50.0",
"jszip": "^3.10.1",
"mime": "^3.0.0"
Expand Down
11 changes: 8 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ async function build(browser) {
},
loader: {
'.png': 'dataurl',
'.svg': 'dataurl'
'.svg': 'dataurl',
'.md': 'text'
}
});

Expand Down Expand Up @@ -114,8 +115,12 @@ const buildAll = async function() {
if (watch) {
const lastChange = new Map();

fs.watch(indir, { recursive: true }, function(_, fn) {
const mtime = Number(fs.statSync(path.join(indir, fn)).mtime);
fs.watch(indir, { recursive: true }, function(event, fn) {
const filename = path.join(indir, fn);
if (event === 'rename' && !fs.existsSync(filename)) {
return;
}
const mtime = Number(fs.statSync(filename).mtime);

// avoid build when file doesn't changed but event is received
if (lastChange.get(fn) !== mtime) {
Expand Down
4 changes: 3 additions & 1 deletion src/content/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ async function checkLoaded(settings) {
}
}),
settings,
version: chrome.runtime.getManifest().version,
styles: [chrome.runtime.getURL('index.css')],
progressbar: preloader.progressbar
}, json
Expand Down Expand Up @@ -279,7 +280,8 @@ function getSettings() {
return new Promise(resolve => {
chrome.storage.sync.get({
expandLevel: 3,
darkmode: 'auto'
darkmode: 'auto',
whatsnew: {}
}, settings => {
resolve(settings);
});
Expand Down
1 change: 1 addition & 0 deletions src/discovery/discovery.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '@discoveryjs/discovery/src/lib.css';
@import './pages/raw.css';
@import './pages/settings.css';
@import './pages/whatsnew.css';
@import './flash-messages.css';

:host {
Expand Down
3 changes: 2 additions & 1 deletion src/discovery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as pages from './pages';
* @returns {Discovery}
*/
export function initDiscovery(options, data) {
const { settings, progressbar, raw } = options;
const { settings, version, progressbar, raw } = options;
const { darkmode = 'auto' } = settings;
const discovery = new Widget({
defaultPage: null,
Expand Down Expand Up @@ -47,6 +47,7 @@ export function initDiscovery(options, data) {
{
name: options.title,
settings,
version,
createdAt: new Date().toISOString() // TODO fix in discovery
},
progressbar
Expand Down
13 changes: 13 additions & 0 deletions src/discovery/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import { navButtons } from '@discoveryjs/discovery';
import copyText from '@discoveryjs/discovery/src/core/utils/copy-text';
import { downloadAsFile } from './download-as-file';
import { flashMessage } from './flash-messages';
import { showWhatsNew, setWhatsnewViewed } from './pages/whatsnew';

export default host => {
host.nav.append({
when: () => showWhatsNew(host.context) && host.pageId !== 'whatsnew',
content: 'text:"What\'s new"',
onClick: () => {
host.setPage('whatsnew');
setWhatsnewViewed(host.context);
}
});
host.nav.append({
when: () => host.pageId !== 'default',
content: 'text:"Default view"',
Expand Down Expand Up @@ -40,4 +49,8 @@ export default host => {
content: 'text:"Settings"',
onClick: (_, { hide }) => hide() & host.setPage('settings')
});
host.nav.menu.append({
content: 'text:"What\'s new"',
onClick: (_, { hide }) => hide() & host.setPage('whatsnew') & setWhatsnewViewed(host.context)
});
};
1 change: 1 addition & 0 deletions src/discovery/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as default } from './default';
export { default as raw } from './raw';
export { default as settings } from './settings';
export { default as whatsnew } from './whatsnew';
4 changes: 4 additions & 0 deletions src/discovery/pages/whatsnew.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.discovery-root[data-page="whatsnew"] {
--discovery-page-padding-left: 40px;
--discovery-page-padding-right: 40px;
}
31 changes: 31 additions & 0 deletions src/discovery/pages/whatsnew.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import whatsnew from './whatsnew.md';

export const setWhatsnewViewed = ({ version }) => {
if (version && typeof chrome !== 'undefined') {
chrome.storage.sync.set({ whatsnew: {
[version]: true
} });
}
};
export const showWhatsNew = context => {
const { version } = context;
return !version ? false : !(
context &&
context.settings &&
context.settings.whatsnew &&
context.settings.whatsnew[version]
);
};

export default host => {
host.page.define('whatsnew', {
view: 'block',
content: [{
view: 'page-header',
content: 'h1:"What\'s new"'
}, {
view: 'markdown',
source: whatsnew
}]
});
};
26 changes: 26 additions & 0 deletions src/discovery/pages/whatsnew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## 1.13.5

### Interface & Views

- Reworked the report page to include a query graph and an enhanced query editor.
- Added a "Copy report as page hash" button.
- Implemented [`tooltip`](#views-showcase&!anchor=tooltip) as an option for all views.
- Introduced new options and improvements for the `struct`, `markdown`, and `source` views.
- Changed the default rendering of arrays in a table cell to display the number of elements instead of `[…]`.

See details in [Discovery.js release notes](https://github.com/discoveryjs/discovery/releases).

### Jora Query Language

- **New Methods**:
- **String and array processing**: Added `indexOf()`, `lastIndexOf()`, `replace()`, `toLowerCase()`, `toUpperCase()`, and `trim()` methods.
- **Statistics**: Introduced `min()`, `max()`, `numbers()`, `sum()`, `avg()`, `count()`, `variance()`, `stdev()`, `percentile()` (with alias `p()`), and `median()`.
- **Math**: Added a suite of math methods such as `abs()`, `acos()`, and many others, aligning closely with JavaScript's `Math` object functions.
- **New Operators and Syntax Enhancements**:
- Introduced the nullish coalescing operator (`??`).
- Added [assertions](https://discoveryjs.github.io/jora/#article:jora-syntax-assertions) to enhance conditional checks with the `is` operator, e.g., `is number` or `is not (number or string)`.
- Provided basic support for function arguments in the syntax, enabling `$arg => expr` and `($a, $b) => expr` forms.
- Updated queries to start with a pipeline operator, e.g., `| expr`.
- Modified the ternary operator to allow optional components, enabling syntaxes like `expr ? : []`, `expr ? 1`, and `expr?`, with a default structure of `expr ? $ : undefined` when parts are omitted.

For more details, see the [Jora release notes](https://github.com/discoveryjs/jora/releases) for versions between 1.0.0-beta.7 & 1.0.0-beta.10.

0 comments on commit 6b4334c

Please sign in to comment.