Skip to content

Commit

Permalink
Build and test action (#30)
Browse files Browse the repository at this point in the history
* Version bump

* Style fixes and test action
  • Loading branch information
traut authored Jul 14, 2024
1 parent 610ae06 commit 78b6451
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# Defaults to the user or organization that owns the workflow file
scope: '@traut'
- run: yarn
- run: yarn npm publish
- run: yarn publish --verbose --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
release-github:
Expand All @@ -33,6 +33,6 @@ jobs:
# Defaults to the user or organization that owns the workflow file
scope: '@traut'
- run: yarn
- run: yarn npm publish
- run: yarn publish --verbose --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build and test the package
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: yarn
- run: yarn lint
2 changes: 1 addition & 1 deletion dist/stixview.bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const compat = new FlatCompat({
export default [...compat.extends("google"), {
languageOptions: {
parser: babelParser,
ecmaVersion: 5,
sourceType: "script",

ecmaVersion: 6,
sourceType: "module",
parserOptions: {
requireConfigFile: false,
sourceType: "module",
},
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stixview",
"version": "2.1.3a1",
"version": "2.2.0",
"description": "Embeddable STIX2 graph viewer in JS",
"main": "src/index.js",
"repository": {
Expand Down
49 changes: 16 additions & 33 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ import {readFile} from './utils.js';
import {bundleToGraphElements} from './data.js';
import {renderSidebarContent} from './sidebar.js';

import {
computePosition,
flip,
shift,
limitShift,
} from '@floating-ui/dom';
import {computePosition} from '@floating-ui/dom';


cytoscape.use(klay);
Expand All @@ -32,27 +27,16 @@ cytoscape.use(cise);
// cytoscape-popper requires an explicit factory
// https://github.com/cytoscape/cytoscape.js-popper?tab=readme-ov-file#migration-from-v2
function popperFactory(ref, content, opts) {
// see https://floating-ui.com/docs/computePosition#options
const popperOptions = {
// matching the default behaviour from Popper@2
// https://floating-ui.com/docs/migration#configure-middleware
middleware: [
flip(),
shift({limiter: limitShift()})
],
...opts,
}

function update() {
computePosition(ref, content, opts).then(({x, y}) => {
Object.assign(content.style, {
left: `${x}px`,
top: `${y}px`,
});
});
}
update();
return { update };
function update() {
computePosition(ref, content, opts).then(({x, y}) => {
Object.assign(content.style, {
left: `${x}px`,
top: `${y}px`,
});
});
}
update();
return {update};
}

cytoscape.use(cytoscapePopper(popperFactory));
Expand Down Expand Up @@ -257,15 +241,15 @@ function clustersForCise(cy) {
// https://github.com/iVis-at-Bilkent/cytoscape.js-cise/

const options = {};
let clusters = cy.elements().markovClustering(options);
const clusters = cy.elements().markovClustering(options);

for(var i = 0; i < clusters.length; i++){
for(var j = 0; j < clusters[i].length; j++){
for (let i = 0; i < clusters.length; i++) {
for (let j = 0; j < clusters[i].length; j++) {
clusters[i][j]._private.data.clusterID = i;
}
};

let arrayOfClusterArrays = [];
const arrayOfClusterArrays = [];
cy.nodes().forEach(function (node) {
arrayOfClusterArrays.push([node.data('id')]);
});
Expand All @@ -274,9 +258,8 @@ function clustersForCise(cy) {


function runLayout(cy, layoutName) {

const localProps = {};
if (layoutName === "cise") {
if (layoutName === 'cise') {
localProps.clusters = clustersForCise(cy);
}

Expand Down

0 comments on commit 78b6451

Please sign in to comment.