Skip to content

Commit

Permalink
new API rework to share engine with vscode plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
drom committed Jan 22, 2024
1 parent 4e19c2c commit 5d0795a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 217 deletions.
16 changes: 0 additions & 16 deletions lib/get-element.js

This file was deleted.

24 changes: 0 additions & 24 deletions lib/get-listing.js

This file was deleted.

7 changes: 6 additions & 1 deletion lib/get-readers.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const urlZip = {

const getReaders = async (handler, vcdPath) => {
const res = [];
if (vcdPath) {
if (typeof vcdPath === 'string') {
const resp = await fetch(vcdPath);
const body = await resp.body;
const reader = body.getReader();
Expand All @@ -63,6 +63,11 @@ const getReaders = async (handler, vcdPath) => {
reader
});
// return;
} else
if (typeof vcdPath === 'function') {

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 4 spaces but found 2

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 4 spaces but found 2

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 4 spaces but found 2

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 4 spaces but found 2

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 4 spaces but found 2

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 4 spaces but found 2

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 4 spaces but found 2

Check warning on line 67 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 4 spaces but found 2
console.log('vcdPath is function');

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Unexpected console statement

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Unexpected console statement

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Unexpected console statement

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected console statement

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Unexpected console statement

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Unexpected console statement

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Unexpected console statement

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 68 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Unexpected console statement
const context = vcdPath(handler);

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 6 spaces but found 4

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 69 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4
console.log(context);

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Unexpected console statement

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Unexpected console statement

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Unexpected console statement

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected console statement

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Unexpected console statement

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Unexpected console statement

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Unexpected console statement

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 70 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Unexpected console statement
} else {

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 4 spaces but found 2

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 4 spaces but found 2

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 4 spaces but found 2

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 4 spaces but found 2

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 4 spaces but found 2

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 4 spaces but found 2

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 4 spaces but found 2

Check warning on line 71 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 4 spaces but found 2
const urlSearchParams = new URLSearchParams(window.location.search);

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 6 spaces but found 4

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 6 spaces but found 4

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 6 spaces but found 4

Check warning on line 72 in lib/get-readers.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 6 spaces but found 4
for (const [key, value] of urlSearchParams) {
Expand Down
45 changes: 0 additions & 45 deletions lib/get-vcd.js

This file was deleted.

23 changes: 0 additions & 23 deletions lib/lister.js

This file was deleted.

95 changes: 0 additions & 95 deletions lib/vcd-pipe-deso.js

This file was deleted.

43 changes: 30 additions & 13 deletions lib/vcdrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const pkg = require('../package.json');

const createVCD = require('vcd-stream/out/vcd.js');
const webVcdParser = require('vcd-stream/lib/web-vcd-parser.js');
const vcdPipeDeso = require('vcd-stream/lib/vcd-pipe-deso.js');
const getVcd = require('vcd-stream/lib/get-vcd.js');

const stringify = require('onml/stringify.js');

Expand All @@ -15,6 +17,8 @@ const {
pluginRenderTimeGrid,
keyBindo,
mountTree,
getElement,
getListing,
// renderMenu,
// mountCodeMirror5,
genKeyHandler,
Expand All @@ -23,16 +27,15 @@ const {
helpPanel
} = require('@wavedrom/doppler');

const {mountCodeMirror6} = require('waveql');
const {
createCodeMirrorState,
mountCodeMirror6
} = require('waveql');

const getReaders = require('./get-readers.js');
const vcdPipeDeso = require('./vcd-pipe-deso.js');
const dropZone = require('./drop-zone.js');
const getWaveql = require('./get-waveql.js');
const getListing = require('./get-listing.js');
const getVcd = require('./get-vcd.js');
const getJsonls = require('./get-jsonls.js');
const getElement = require('./get-element.js');
const pluginLocalStore = require('./plugin-local-store.js');

const getHandler = (content, inst) => async readers => {
Expand All @@ -42,7 +45,7 @@ const getHandler = (content, inst) => async readers => {
const jsonls = await getJsonls(readers);
const timeOpt = readers.find(row => row.key === 'time');

vcdPipeDeso({}, inst, deso => {
vcdPipeDeso({wires: {body: []}}, inst, deso => {
// console.log('parsed', deso);
content.innerHTML = '';
deso.waveql = waveql;
Expand All @@ -63,7 +66,8 @@ const getHandler = (content, inst) => async readers => {
}
});

const {render} = container.start(content, deso);
content.appendChild(container.pstate.container);
container.start(deso);

container.elo.menu.innerHTML = stringify(helpPanel.mlIcon('https://github.com/wavedrom/vcdrom/blob/trunk/help.md'));
container.elo.menu.addEventListener('click', () => helpPanel.toggle(container.pstate));
Expand All @@ -79,22 +83,35 @@ const getHandler = (content, inst) => async readers => {
// });
// });

deso.hasHistory = true;
deso.isRO = true;
deso.updater = (str) => {

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (14)

'str' is defined but never used

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (16)

'str' is defined but never used

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (12)

'str' is defined but never used

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (18)

'str' is defined but never used

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (16)

'str' is defined but never used

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (14)

'str' is defined but never used

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (12)

'str' is defined but never used

Check failure on line 88 in lib/vcdrom.js

View workflow job for this annotation

GitHub Actions / build (14)

'str' is defined but never used
console.log('updater');
};

const cmState = createCodeMirrorState(
deso,
container.pstate
);

const cm = mountCodeMirror6(
cmState,
container.elo.waveqlPanel,
deso,
container.pstate,
render
container.pstate
);
container.elo.container.addEventListener('keydown', genKeyHandler.genKeyHandler(content, container.pstate, render, cm, keyBindo));
container.elo.container.addEventListener('wheel', genOnWheel(content, container.pstate, render, cm, keyBindo));

cm.view.dispatch({changes: {from: 0, insert: ' '}});
cm.view.dispatch({changes: {from: 0, to: 1, insert: ''}});

container.elo.container.addEventListener('keydown', genKeyHandler.genKeyHandler(content, container.pstate, deso, cm, keyBindo));
container.elo.container.addEventListener('wheel', genOnWheel(content, container.pstate, deso, cm, keyBindo));
// console.log(cm);
cm.view.focus();

});

await getVcd(readers, content, inst);

console.log('getVcd');
};

global.VCDrom = async (divName, vcdPath) => {
Expand Down

0 comments on commit 5d0795a

Please sign in to comment.