@graphty/cytoscape-extensions 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,7 +45,8 @@ draw();
45
45
  ## Loading
46
46
 
47
47
  - With npm and a bundler (Vite, webpack, esbuild, Rollup), import the package as above. It is ES modules only; the
48
- WebGPU code, the generators, each dataset and the file formats load on first use.
48
+ WebGPU code, the generators and the file formats load on first use, and every dataset downloads from graphty.app
49
+ when asked for.
49
50
  - With no build step, import the ES module build from a CDN:
50
51
  `https://cdn.jsdelivr.net/npm/@graphty/cytoscape-extensions/dist/cdn/cytoscape-extensions.js`.
51
52
  - With a classic `<script src>` tag, load `dist/cytoscape-extensions.bundle.js` after Cytoscape. It registers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphty/cytoscape-extensions",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Graphty layouts, algorithms, graph generators, sample datasets and file import/export as Cytoscape.js extensions",
5
5
  "author": "Adam Powers <apowers@ato.ms>",
6
6
  "type": "module",
@@ -71,9 +71,9 @@
71
71
  },
72
72
  "homepage": "https://github.com/graphty-org/graphty-monorepo/tree/master/cytoscape-extensions#readme",
73
73
  "dependencies": {
74
- "@graphty/graph-io": "^0.3.40",
75
- "@graphty/graph-samples": "^0.1.32",
76
- "@graphty/webgpu-graph-algorithms": "^0.6.54"
74
+ "@graphty/graph-io": "^0.3.41",
75
+ "@graphty/graph-samples": "^0.1.34",
76
+ "@graphty/webgpu-graph-algorithms": "^0.6.56"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "@graphty/algorithms": "^3.0.0",
@@ -96,15 +96,16 @@
96
96
  "eslint": "^9.29.0",
97
97
  "prettier": "^3.4.2",
98
98
  "storybook": "^9.0.11",
99
+ "tsx": "^4.20.3",
99
100
  "typedoc": "^0.28.15",
100
101
  "typedoc-plugin-markdown": "^4.9.0",
101
102
  "typedoc-vitepress-theme": "^1.1.2",
102
103
  "typescript": "^5.9.3",
103
104
  "vite": "^7.0.5",
104
105
  "vitest": "4.1.11",
105
- "@graphty/algorithms": "^3.4.7",
106
- "@graphty/graph-format": "^1.4.1",
107
- "@graphty/layout": "^2.5.3"
106
+ "@graphty/algorithms": "^3.4.9",
107
+ "@graphty/graph-format": "^1.4.2",
108
+ "@graphty/layout": "^2.5.5"
108
109
  },
109
110
  "scripts": {
110
111
  "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && vite build --config vite.bundle.config.ts --mode cdn --logLevel warn && vite build --config vite.bundle.config.ts --logLevel warn",
@@ -121,6 +122,6 @@
121
122
  "ready:commit": "npm run build && npm run lint && npm run test:run",
122
123
  "docs:reference": "UPDATE_REFERENCE=1 vitest run test/reference.test.ts",
123
124
  "docs:api": "typedoc && node ../tools/sanitize-api-docs.js docs/api/generated",
124
- "size": "node scripts/size.mjs"
125
+ "size": "node scripts/size-budgets.test.mjs && node scripts/size.mjs"
125
126
  }
126
127
  }
package/src/graph-data.ts CHANGED
@@ -40,8 +40,8 @@ export interface GraphtyGraphData {
40
40
  */
41
41
  graphtyGenerate<N extends GeneratorName>(name: N, options: GeneratorOptions<N>): Promise<AddedGraph>;
42
42
  /**
43
- * Adds a sample dataset: `cy.graphtyDataset("karate")`. The small ones ship with the package; the large ones
44
- * (road-ny, ogbn-arxiv, com-dblp) are downloaded from graphty.app. Throws, adding nothing, when the core already holds one of the graph's node ids.
43
+ * Adds a sample dataset: `cy.graphtyDataset("karate")`, downloaded from graphty.app (`options.baseUrl` for a
44
+ * mirror of your own). Throws, adding nothing, when the core already holds one of the graph's node ids.
45
45
  * `options.signal` cancels it: once aborted, it rejects with the signal's reason and adds nothing, whatever
46
46
  * `options.fetch` does with the signal.
47
47
  */
package/src/samples.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `@graphty/cytoscape-extensions/samples`: the seeded generators and the sample datasets of @graphty/graph-samples
3
- * as Cytoscape elements. cy.graphtyGenerate() and cy.graphtyDataset() load this module on their first call, and
4
- * each bundled dataset is a module of its own, loaded only when it is asked for.
3
+ * as Cytoscape elements. cy.graphtyGenerate() and cy.graphtyDataset() load this module on their first call; every
4
+ * dataset downloads from graphty.app when it is asked for (no dataset's data ships in the package).
5
5
  */
6
6
 
7
7
  import { fromEdgeArrays, type GraphSnapshot } from "@graphty/graph-format";
@@ -94,35 +94,28 @@ export { NAMED_GRAPH_NAMES } from "@graphty/graph-samples/generators";
94
94
  /** The options of a generator. */
95
95
  export type GeneratorOptions<N extends GeneratorName> = Parameters<(typeof GENERATORS)[N]>[0];
96
96
 
97
- // One static specifier per dataset, so a bundler splits each into a chunk of its own.
98
- const BUNDLED: Record<string, () => Promise<SampleGraph>> = {
99
- karate: () => import("@graphty/graph-samples/datasets/karate").then((m) => m.karate()),
100
- "florentine-families": () =>
101
- import("@graphty/graph-samples/datasets/florentine-families").then((m) => m.florentineFamilies()),
102
- "davis-southern-women": () =>
103
- import("@graphty/graph-samples/datasets/davis-southern-women").then((m) => m.davisSouthernWomen()),
104
- "les-miserables": () => import("@graphty/graph-samples/datasets/les-miserables").then((m) => m.lesMiserables()),
105
- football: () => import("@graphty/graph-samples/datasets/football").then((m) => m.football()),
106
- "political-books": () => import("@graphty/graph-samples/datasets/political-books").then((m) => m.politicalBooks()),
107
- dolphins: () => import("@graphty/graph-samples/datasets/dolphins").then((m) => m.dolphins()),
108
- "contiguous-usa": () => import("@graphty/graph-samples/datasets/contiguous-usa").then((m) => m.contiguousUsa()),
109
- "knuth-miles": () => import("@graphty/graph-samples/datasets/knuth-miles").then((m) => m.knuthMiles()),
110
- "celegans-neural": () => import("@graphty/graph-samples/datasets/celegans-neural").then((m) => m.celegansNeural()),
111
- "political-blogs": () => import("@graphty/graph-samples/datasets/political-blogs").then((m) => m.politicalBlogs()),
112
- openflights: () => import("@graphty/graph-samples/datasets/openflights").then((m) => m.openflights()),
113
- "yeast-perturbation": () =>
114
- import("@graphty/graph-samples/datasets/yeast-perturbation").then((m) => m.yeastPerturbation()),
115
- "stelzl-interactome": () =>
116
- import("@graphty/graph-samples/datasets/stelzl-interactome").then((m) => m.stelzlInteractome()),
117
- "wikipathways-senescence-autophagy": () =>
118
- import("@graphty/graph-samples/datasets/wikipathways-senescence-autophagy").then((m) =>
119
- m.wikipathwaysSenescenceAutophagy(),
120
- ),
121
- "go-slim-generic": () => import("@graphty/graph-samples/datasets/go-slim-generic").then((m) => m.goSlimGeneric()),
122
- };
123
-
124
- /** The datasets that ship inside @graphty/graph-samples; the hosted ones (graph-samples' DATASETS) are fetched. */
125
- export const BUNDLED_DATASET_NAMES: readonly string[] = Object.keys(BUNDLED);
97
+ /**
98
+ * The small datasets, which the package used to bundle. Every dataset now downloads from graphty.app like the rest.
99
+ * @deprecated every dataset is downloaded; graph-samples' `DATASET_NAMES` lists them all
100
+ */
101
+ export const BUNDLED_DATASET_NAMES: readonly string[] = [
102
+ "karate",
103
+ "florentine-families",
104
+ "davis-southern-women",
105
+ "les-miserables",
106
+ "football",
107
+ "political-books",
108
+ "dolphins",
109
+ "contiguous-usa",
110
+ "knuth-miles",
111
+ "celegans-neural",
112
+ "political-blogs",
113
+ "openflights",
114
+ "yeast-perturbation",
115
+ "stelzl-interactome",
116
+ "wikipathways-senescence-autophagy",
117
+ "go-slim-generic",
118
+ ];
126
119
 
127
120
  /**
128
121
  * The number of single-character edits that turn one string into the other.
@@ -240,24 +233,22 @@ export function generateElements<N extends GeneratorName>(name: N, options: Gene
240
233
  }
241
234
 
242
235
  /**
243
- * Loads a sample dataset: a bundled one from its own module, any other from graphty.app (see graph-samples'
244
- * `DATASETS` for the list, with each one's source, citation and license). A drawn dataset's saved `x` and `y` become
245
- * node positions, placed where Cytoscape drew them.
236
+ * Loads a sample dataset from graphty.app (see graph-samples' `DATASETS` for the list, with each one's source,
237
+ * citation and license). A drawn dataset's saved `x` and `y` become node positions, placed where Cytoscape drew them.
246
238
  * @param name - the dataset name, e.g. "karate"
247
- * @param options - for a hosted dataset: the base URL and fetch implementation; for any dataset, an abort signal
239
+ * @param options - the base URL (a mirror of your own), the fetch implementation and an abort signal
248
240
  * @returns the elements and the direction
249
241
  * @throws the signal's reason (an AbortError) when it is aborted before the dataset is decoded
250
242
  * @throws RangeError for a name that is not a known dataset, unless `baseUrl` is given
251
243
  */
252
244
  export async function datasetElements(name: string, options: FetchDatasetOptions = {}): Promise<SampleElements> {
253
- // checked here too, not only by fetch: a bundled dataset is not fetched, and a custom fetch may ignore the signal
245
+ // checked here too, not only by fetch: a custom fetch may ignore the signal
254
246
  options.signal?.throwIfAborted();
255
- const load = BUNDLED[name];
256
247
  // only graphty.app's own list is checked: a custom baseUrl may serve any name
257
- if (load === undefined && options.baseUrl === undefined && !DATASET_NAMES.includes(name)) {
248
+ if (options.baseUrl === undefined && !DATASET_NAMES.includes(name)) {
258
249
  throw unknownName("dataset", name, DATASET_NAMES);
259
250
  }
260
- const graph = load === undefined ? await fetchDataset(name, options) : await load();
251
+ const graph = await fetchDataset(name, options);
261
252
  options.signal?.throwIfAborted();
262
253
  const r = fromSample(graph);
263
254
  // a drawn dataset's saved x and y (y growing upward) become the position Cytoscape drew (y growing downward)