tw5-vis-network 10.5.5

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.
Files changed (33) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +37 -0
  3. package/package.json +37 -0
  4. package/plugins/vis-network/DefaultColourMappings.multids +7 -0
  5. package/plugins/vis-network/Stylesheet.tid +39 -0
  6. package/plugins/vis-network/adapter.js +179 -0
  7. package/plugins/vis-network/felixhayashi_vis_vis.js +36 -0
  8. package/plugins/vis-network/lib/icon.svg +2 -0
  9. package/plugins/vis-network/lib/tiddlywiki.files +27 -0
  10. package/plugins/vis-network/lib/vis-network.min.js +48 -0
  11. package/plugins/vis-network/license.tid +29 -0
  12. package/plugins/vis-network/messages/graph-center-node.js +19 -0
  13. package/plugins/vis-network/messages/graph-export-png.js +28 -0
  14. package/plugins/vis-network/messages/graph-move-view.js +52 -0
  15. package/plugins/vis-network/messages/tiddlywiki.files +17 -0
  16. package/plugins/vis-network/plugin.info +13 -0
  17. package/plugins/vis-network/properties/background.js +51 -0
  18. package/plugins/vis-network/properties/canvas.js +79 -0
  19. package/plugins/vis-network/properties/color.js +104 -0
  20. package/plugins/vis-network/properties/defaults.js +42 -0
  21. package/plugins/vis-network/properties/edges.js +87 -0
  22. package/plugins/vis-network/properties/events.js +127 -0
  23. package/plugins/vis-network/properties/id.js +24 -0
  24. package/plugins/vis-network/properties/image.js +35 -0
  25. package/plugins/vis-network/properties/interaction.js +48 -0
  26. package/plugins/vis-network/properties/layout.js +55 -0
  27. package/plugins/vis-network/properties/manipulation.js +181 -0
  28. package/plugins/vis-network/properties/nodes.js +42 -0
  29. package/plugins/vis-network/properties/physics.js +110 -0
  30. package/plugins/vis-network/properties/position.js +60 -0
  31. package/plugins/vis-network/properties/tiddlywiki.files +17 -0
  32. package/plugins/vis-network/readme.tid +8 -0
  33. package/plugins/vis-network/vis.js +59 -0
package/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ Copyright (c) 2022-2025, Cameron Fischer
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # tw5-vis-network
2
+
3
+ This is a TiddlyWiki5 plugin which wraps the [vis-network library](https://github.com/visjs/vis-network). It's intended to be a modern replacement for the [TW5-Vis.js](https://github.com/felixhayashi/TW5-Vis.js/) when used with [TW5-TiddlyMap](https://github.com/felixhayashi/TW5-TiddlyMap).
4
+
5
+ It includes a legacy tiddler which allows it to swap out TW5-Vis, even with older versions of TiddlyMap, although some features may be disabled.
6
+
7
+ To update the version of vis-network used, fetch the latest .min.js file from [here](https://unpkg.com/vis-network/standalone/umd/vis-network.min.js).
8
+
9
+ ---
10
+
11
+ # Notes on Copyright
12
+
13
+ ### TiddlyWiki
14
+
15
+ Created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)
16
+
17
+ Copyright © Jeremy Ruston 2004-2007 Copyright © UnaMesa Association 2007-2022
18
+
19
+ Published under the following [licenses](https://github.com/Jermolene/TiddlyWiki5/tree/master/licenses):
20
+
21
+ 1. BSD 3-clause "New" or "Revised" License (including any right to adopt any future version of a license if permitted)
22
+ 2. Creative Commons Attribution 3.0 (including any right to adopt any future version of a license if permitted)
23
+
24
+ ### The **vis-network** library
25
+
26
+ Copyright (c) 2010-2018 [Almende B.V.](https://github.com/vis/vis-network) and Contributors Copyright (c) 2018-2021 Vis.js contributors
27
+
28
+ Published under the following licenses:
29
+
30
+ 1. Apache License Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
31
+ 2. MIT License (MIT)
32
+
33
+ # How to run tests
34
+
35
+ Make sure you have `tiddlywiki` available on your PATH. Then from the project root directory, type:
36
+
37
+ `tiddlywiki --build test`
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "tw5-vis-network",
3
+ "version": "10.5.5",
4
+ "description": "TiddlyWiki5 plugin for the vis-network library",
5
+ "directories": {
6
+ "doc": "docs"
7
+ },
8
+ "scripts": {
9
+ "test": "tiddlywiki --build test",
10
+ "bundle": "tiddlywiki --build bundle"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/flibbles/tw5-vis-network.git"
15
+ },
16
+ "keywords": [
17
+ "visualization",
18
+ "graphs",
19
+ "tiddlywiki5",
20
+ "tiddlywiki-plugin"
21
+ ],
22
+ "author": "Flibbles",
23
+ "license": "BSD-3-Clause",
24
+ "bugs": {
25
+ "url": "https://github.com/flibbles/tw5-vis-network/issues"
26
+ },
27
+ "homepage": "https://github.com/flibbles/tw5-vis-network#readme",
28
+ "files": [
29
+ "plugins/"
30
+ ],
31
+ "tiddlywiki": {
32
+ "flibbles/vis-network": "./plugins/vis-network/"
33
+ },
34
+ "devDependencies": {
35
+ "tiddlywiki": "^5.3.0"
36
+ }
37
+ }
@@ -0,0 +1,7 @@
1
+ title: $:/config/DefaultColourMappings/
2
+
3
+ vis-button-background: <<colour dropdown-background>>
4
+ vis-button-border: <<colour dropdown-border>>
5
+ vis-button-foreground: <<colour foreground>>
6
+ vis-manipulation-banner-background: <<colour dropdown-background>>
7
+ vis-manipulation-banner-border: <<colour dropdown-border>>
@@ -0,0 +1,39 @@
1
+ title: $:/plugins/flibbles/vis-network/Stylesheet
2
+ tags: $:/tags/Stylesheet
3
+
4
+ \rules only macrocallinline
5
+
6
+ div.vis-network div.vis-edit-mode button.vis-button.vis-edit.vis-edit-mode {
7
+ background-color: <<colour vis-button-background>> !important;
8
+ border-color: <<colour vis-button-border>> !important;
9
+ color: <<colour vis-button-foreground>>;
10
+ fill: <<colour vis-button-foreground>>;
11
+ }
12
+
13
+ div.vis-network div.vis-manipulation button.vis-button {
14
+ background-color: <<colour vis-button-background>>;
15
+ color: <<colour vis-button-foreground>>;
16
+ fill: <<colour vis-button-foreground>>;
17
+ }
18
+
19
+ div.vis-network div.vis-manipulation {
20
+ --color: <<colour vis-manipulation-banner-background>>;
21
+ background: color-mix(in srgb, var(--color) 70%, transparent) !important;
22
+ border-color: <<colour vis-manipulation-banner-border>> !important;
23
+ }
24
+
25
+ /*
26
+ div.vis-network div.vis-edit-mode button.vis-button.vis-edit.vis-edit-mode:hover {
27
+ background-color: <<colour tiddler-controls-foreground-selected>>;
28
+ color: <<colour background>>;
29
+ fill: <<colour background>>;
30
+ }
31
+ */
32
+
33
+ div.vis-network div.vis-edit-mode button.vis-button.vis-edit.vis-edit-mode.tc-selected {
34
+ background-color: <<colour primary>>;
35
+ }
36
+
37
+ .graph-engine-vis-network {
38
+ height: 400px;
39
+ }
@@ -0,0 +1,179 @@
1
+ /*\
2
+ title: $:/plugins/flibbles/vis-network/adapter.js
3
+ type: application/javascript
4
+ module-type: graphengine
5
+
6
+ This is an adapter that the graph plugin uses to interface with vis-network.
7
+ This allows flibbles/graph to alternatively use this library.
8
+
9
+ \*/
10
+
11
+ "use strict";
12
+
13
+ var VisLibrary = require("./vis.js");
14
+
15
+ /*
16
+ We expose these objects like this so the testing framework can get in.
17
+ */
18
+ exports.Vis = function() {
19
+ return VisLibrary;
20
+ };
21
+
22
+ exports.window = function() {
23
+ return window;
24
+ };
25
+
26
+ exports.name = "Vis-Network";
27
+ //exports.platforms = ["browser"];
28
+
29
+ /**
30
+ * Set up all the properties here so it's accessable by TW5-Graph.
31
+ *
32
+ * Property Handlers perform specific operations to the incoming data before
33
+ * passing it along to vis.
34
+ * Partly to account for differences in API.
35
+ * Partly to account for all the bugs in vis-network.
36
+ */
37
+
38
+ var propertyHandlers = $tw.modules.getModulesByTypeAsHashmap("vis-property");
39
+ exports.properties = {};
40
+
41
+ for (var handler in propertyHandlers) {
42
+ var module = propertyHandlers[handler];
43
+ if (module.properties) {
44
+ // This property handler has properties to declare. Fold them in.
45
+ for (var category in module.properties) {
46
+ exports.properties[category] = exports.properties[category] || Object.create(null);
47
+ $tw.utils.extend(
48
+ exports.properties[category],
49
+ module.properties[category]);
50
+ }
51
+ }
52
+ }
53
+
54
+ exports.forEachProperty = function(methodName) {
55
+ var args = Array.prototype.slice.call(arguments, 1);
56
+ for (var name in propertyHandlers) {
57
+ var method = propertyHandlers[name][methodName];
58
+ method && method.apply(this, args);
59
+ }
60
+ };
61
+
62
+ /**
63
+ * Set up all the messages here so it's accessable by TW5-Graph.
64
+ */
65
+
66
+ var Messages = $tw.modules.getModulesByTypeAsHashmap("vis-message");
67
+
68
+ exports.messages = Object.create(null);
69
+
70
+ for (var name in Messages) {
71
+ exports.messages[name] = Messages[name].parameters || {};
72
+ }
73
+
74
+ exports.handleMessage = function(message, params) {
75
+ var handler = Messages[message.type];
76
+ if (handler) {
77
+ return handler.handle.call(this, message, params);
78
+ }
79
+ };
80
+
81
+ /**
82
+ * Core methods for adapter
83
+ */
84
+ exports.init = function(element, objects, options) {
85
+ var Vis = exports.Vis();
86
+ this.element = element;
87
+ options = options || {};
88
+ this.wiki = options.wiki || $tw.wiki;
89
+ this.objects = {};
90
+ var newObjects = this.processObjects(objects);
91
+ this.dataSets = {
92
+ nodes: new Vis.DataSet(Object.values(newObjects.nodes || {}).map((x) => createDiff({}, x)), {queue: true}),
93
+ edges: new Vis.DataSet(Object.values(newObjects.edges || {}).map((x) => createDiff({}, x)), {queue: true})
94
+ };
95
+ var self = this;
96
+ // We remember what children were already attached to the element, because they MUST remain. The TW widget stack requires the DOM to be what it made it.
97
+ // Also, use .childNodes, not .children. The latter misses text nodes
98
+ var children = Array.prototype.slice.call(element.childNodes);
99
+ this.vis = new Vis.Network(element, this.dataSets, createDiff({}, newObjects.graph));
100
+
101
+ // The first child of the frame should always be the canvas element.
102
+ // I think we can just grab it blindly. Let's remember it.
103
+ this.canvasElement = this.vis.canvas.frame.children[0];
104
+ // We MUST preserve any elements already attached to the passed element.
105
+ for (var i = 0; i < children.length; i++) {
106
+ element.appendChild(children[i]);
107
+ }
108
+ this.forEachProperty("init", this.vis);
109
+ };
110
+
111
+ exports.update = function(objects) {
112
+ var changes = this.processObjects(objects);
113
+ for (var type in changes) {
114
+ if (type === "graph") {
115
+ this.vis.setOptions(createDiff({}, changes.graph));
116
+ } else {
117
+ var dataSet = this.dataSets[type];
118
+ for (var id in changes[type]) {
119
+ var object = changes[type][id];
120
+ if (object === null) {
121
+ dataSet.remove({id: id});
122
+ } else {
123
+ var oldObj = dataSet.get(id) || {};
124
+ dataSet.update(createDiff(oldObj, object));
125
+ }
126
+ }
127
+ dataSet.flush();
128
+ }
129
+ }
130
+ };
131
+
132
+ exports.destroy = function() {
133
+ this.forEachProperty("destroy", this.vis);
134
+ this.vis.destroy();
135
+ };
136
+
137
+ exports.processObjects = function(changes) {
138
+ this.forEachProperty("process", this.objects, changes);
139
+ // Apply those changes to our own record.
140
+ for (var type in changes) {
141
+ if (type === "graph") {
142
+ this.objects.graph = changes.graph;
143
+ } else {
144
+ this.objects[type] = this.objects[type] || Object.create(null);
145
+ for (var id in changes[type]) {
146
+ this.objects[type][id] = changes[type][id];
147
+ }
148
+ }
149
+ }
150
+ return changes;
151
+ };
152
+
153
+ /*
154
+ Creates an object representing the differences between the old object and
155
+ the new objects. Because vis applies changes; it doesn't replace.
156
+ */
157
+ function createDiff(oldObject, newObject) {
158
+ var diff = Object.create(null);
159
+ for (var property in newObject) {
160
+ var newValue = newObject[property];
161
+ if (newValue !== undefined) {
162
+ if (typeof newValue === "object"
163
+ && newValue !== null
164
+ && !Array.isArray(newValue)) {
165
+ var oldValue = oldObject[property];
166
+ diff[property] = createDiff((typeof oldValue === "object" && oldValue !== null)? oldValue: {}, newValue);
167
+ } else {
168
+ diff[property] = newValue;
169
+ }
170
+ }
171
+ }
172
+ // Any properties that went missing must be flagged as deleted
173
+ for (var property in oldObject) {
174
+ if (newObject[property] === undefined) {
175
+ diff[property] = null;
176
+ }
177
+ }
178
+ return diff;
179
+ };
@@ -0,0 +1,36 @@
1
+ /*\
2
+ title: $:/plugins/felixhayashi/vis/vis.js
3
+ type: application/javascript
4
+ module-type: library
5
+
6
+ This tiddler exists for backward compatibility to plugins which used ~$:/plugins/felixhayashi/vis. This plugin can be used in place of that one without any migration, although some buttons will have mismatched colors.
7
+ \*/
8
+
9
+ "use strict";
10
+
11
+ exports.default = require("$:/plugins/flibbles/vis-network/vis.js");
12
+
13
+ Object.defineProperty(exports, "__esModule", {
14
+ value: true
15
+ });
16
+
17
+ // vis.js to vis-network changed the expected locale from en-EN to just en.
18
+ // This is the only thing preventing this library from being completely
19
+ // swappable with vis.js. But because this is here, plugins like TiddlyMap
20
+ // can recognize which locale to use by seeing this.
21
+ exports.default.locale = "en";
22
+
23
+ // This is a backup version of vis.keycharm, which was removed between
24
+ // Vis.js and vis-network
25
+ exports.default.keycharm = function(options) {
26
+ return new LegacyKeyCharm(options);
27
+ };
28
+
29
+ function LegacyKeyCharm(options) {
30
+ this.container = options.container;
31
+ };
32
+
33
+ // It's not important that it actually does anything. As far as I can tell,
34
+ // TiddlyMap doesn't actually use it meaningfully anymore.
35
+ LegacyKeyCharm.prototype.bind = function(key, method) {
36
+ };
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><g><path style="fill:#ffcf00" d="M 1,54 C 15.6,33 59,5.6 80,5.5 93,28.6 92.4,56.1 91,79.3 58.8,83.7 20,74.6 1,53.9 Z"/><path style="fill:#109618" d="M 96,75 C 101,85 96,90.5 93.4,92 57,92 33.8,88 3.4,68.4 0.8,66.8 3.7,65.7 5,66 32,75 56.5,79 96,75.5 Z" /><circle style="fill:#ff9800" cx="57" cy="43" r="30.3" /><circle style="fill:#dc3912" cx="61" cy="52" r="18" /><circle style="fill:#ffffff" cx="62" cy="57" r="11.2" /><circle style="fill:#4d4d4d" cx="66" cy="60" r="5.7" /></g></svg>
@@ -0,0 +1,27 @@
1
+ {
2
+ "tiddlers": [
3
+ {
4
+ "file": "./vis-network.min.js",
5
+ "isTiddlerFile": false,
6
+ "fields": {
7
+ "title": {
8
+ "source": "filename",
9
+ "prefix": "$:/plugins/flibbles/vis-network/"
10
+ },
11
+ "type": "application/javascript",
12
+ "module-type": "library"
13
+ }
14
+ },
15
+ {
16
+ "file": "./icon.svg",
17
+ "isTiddlerFile": false,
18
+ "fields": {
19
+ "title": {
20
+ "source": "basename",
21
+ "prefix": "$:/plugins/flibbles/vis-network/"
22
+ },
23
+ "type": "image/svg+xml"
24
+ }
25
+ }
26
+ ]
27
+ }