sp-graph-layout 0.0.1 → 1.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ Graph Layout
2
+ ============
3
+
4
+ ## Overview
5
+
6
+ A library for visualizing directed graphs.
7
+
8
+ | rank dir = TB | rank dir = LR |
9
+ |:----------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------:|
10
+ | ![](https://github.com/CyberZHG/GraphLayout/blob/main/docs/images/example1_tb.svg) | ![](https://github.com/CyberZHG/GraphLayout/blob/main/docs/images/example1_lr.svg) |
11
+ | ![](https://github.com/CyberZHG/GraphLayout/blob/main/docs/images/example2_tb.svg) | ![](https://github.com/CyberZHG/GraphLayout/blob/main/docs/images/example2_lr.svg) |
12
+
13
+ ## Documentation
14
+
15
+ * [Documentation](https://cyberzhg.github.io/GraphLayout/)
16
+
17
+ * [Installation](https://cyberzhg.github.io/GraphLayout/install.html)
18
+ * [Basic Concepts](https://cyberzhg.github.io/GraphLayout/basic.html)
19
+ * [Graph Attributes](https://cyberzhg.github.io/GraphLayout/graph_attr.html)
20
+ * [Vertex Attributes](https://cyberzhg.github.io/GraphLayout/vertex_attr.html)
21
+ * [Edge Attributes](https://cyberzhg.github.io/GraphLayout/edge_attr.html)
package/index.js CHANGED
@@ -2,12 +2,45 @@ import GraphLayoutWASMModule from './wasm/GraphLayoutWASM.js';
2
2
 
3
3
  const GraphLayoutWASM = await GraphLayoutWASMModule();
4
4
 
5
- const createDirectedGraph = GraphLayoutWASM.createDirectedGraph;
5
+ const VectorString = GraphLayoutWASM.VectorString;
6
+
7
+ function buildVectorString(strings) {
8
+ const vector = new VectorString();
9
+ for (const str of strings) {
10
+ vector.push_back(str);
11
+ }
12
+ return vector;
13
+ }
14
+
15
+ const _compareSVG = GraphLayoutWASM._compareSVG;
16
+ const FeedbackArcsMethod = GraphLayoutWASM.FeedbackArcsMethod;
17
+ const LayerAssignmentMethod = GraphLayoutWASM.LayerAssignmentMethod;
18
+ const CrossMinimizationMethod = GraphLayoutWASM.CrossMinimizationMethod;
19
+ const VertexPositioningMethod = GraphLayoutWASM.VertexPositioningMethod;
6
20
  const SPDirectedGraph = GraphLayoutWASM.SPDirectedGraph;
21
+ const Attribute = GraphLayoutWASM.Attribute;
22
+ const AttributeRankDir = GraphLayoutWASM.AttributeRankDir;
23
+ const AttributeShape = GraphLayoutWASM.AttributeShape;
24
+ const Attributes = GraphLayoutWASM.Attributes;
7
25
  const DirectedGraphHierarchicalLayout = GraphLayoutWASM.DirectedGraphHierarchicalLayout;
8
26
 
27
+ SPDirectedGraph.prototype.addEdges = function (edges) {
28
+ for (const edge of edges) {
29
+ this.addEdge(edge[0], edge[1]);
30
+ }
31
+ }
32
+
9
33
  export {
10
- createDirectedGraph,
34
+ _compareSVG,
35
+ buildVectorString,
36
+ FeedbackArcsMethod,
37
+ LayerAssignmentMethod,
38
+ CrossMinimizationMethod,
39
+ VertexPositioningMethod,
11
40
  SPDirectedGraph,
41
+ Attribute,
42
+ AttributeRankDir,
43
+ AttributeShape,
44
+ Attributes,
12
45
  DirectedGraphHierarchicalLayout,
13
46
  };
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "sp-graph-layout",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "files": [
7
8
  "index.js",
9
+ "index.d.js",
8
10
  "wasm/GraphLayoutWASM.js",
9
11
  "wasm/GraphLayoutWASM.wasm"
10
12
  ],
@@ -19,5 +21,7 @@
19
21
  "build": "bash build.sh",
20
22
  "lint": "npx eslint index.js test/**/*.js",
21
23
  "test": "mocha test/**/*.js"
22
- }
24
+ },
25
+ "homepage": "https://cyberzhg.github.io/GraphLayout/",
26
+ "repository": "github:CyberZHG/GraphLayout"
23
27
  }
@@ -1934,6 +1934,77 @@ async function createWasm() {
1934
1934
  );
1935
1935
  };
1936
1936
 
1937
+
1938
+
1939
+ var runDestructors = (destructors) => {
1940
+ while (destructors.length) {
1941
+ var ptr = destructors.pop();
1942
+ var del = destructors.pop();
1943
+ del(ptr);
1944
+ }
1945
+ };
1946
+
1947
+
1948
+
1949
+ var __embind_register_class_class_property = (rawClassType,
1950
+ fieldName,
1951
+ rawFieldType,
1952
+ rawFieldPtr,
1953
+ getterSignature,
1954
+ getter,
1955
+ setterSignature,
1956
+ setter) => {
1957
+ fieldName = AsciiToString(fieldName);
1958
+ getter = embind__requireFunction(getterSignature, getter);
1959
+
1960
+ whenDependentTypesAreResolved([], [rawClassType], (classType) => {
1961
+ classType = classType[0];
1962
+ var humanName = `${classType.name}.${fieldName}`;
1963
+ var desc = {
1964
+ get() {
1965
+ throwUnboundTypeError(`Cannot access ${humanName} due to unbound types`, [rawFieldType]);
1966
+ },
1967
+ enumerable: true,
1968
+ configurable: true
1969
+ };
1970
+ if (setter) {
1971
+ desc.set = () => {
1972
+ throwUnboundTypeError(`Cannot access ${humanName} due to unbound types`, [rawFieldType]);
1973
+ };
1974
+ } else {
1975
+ desc.set = (v) => {
1976
+ throwBindingError(`${humanName} is a read-only property`);
1977
+ };
1978
+ }
1979
+
1980
+ Object.defineProperty(classType.registeredClass.constructor, fieldName, desc);
1981
+
1982
+ whenDependentTypesAreResolved([], [rawFieldType], (fieldType) => {
1983
+ fieldType = fieldType[0];
1984
+ var desc = {
1985
+ get() {
1986
+ return fieldType.fromWireType(getter(rawFieldPtr));
1987
+ },
1988
+ enumerable: true
1989
+ };
1990
+
1991
+ if (setter) {
1992
+ setter = embind__requireFunction(setterSignature, setter);
1993
+ desc.set = (v) => {
1994
+ var destructors = [];
1995
+ setter(rawFieldPtr, fieldType.toWireType(destructors, v));
1996
+ runDestructors(destructors);
1997
+ };
1998
+ }
1999
+
2000
+ Object.defineProperty(classType.registeredClass.constructor, fieldName, desc);
2001
+ return [];
2002
+ });
2003
+
2004
+ return [];
2005
+ });
2006
+ };
2007
+
1937
2008
  var heap32VectorToArray = (count, firstElement) => {
1938
2009
  var array = [];
1939
2010
  for (var i = 0; i < count; i++) {
@@ -1947,13 +2018,6 @@ async function createWasm() {
1947
2018
 
1948
2019
 
1949
2020
 
1950
- var runDestructors = (destructors) => {
1951
- while (destructors.length) {
1952
- var ptr = destructors.pop();
1953
- var del = destructors.pop();
1954
- del(ptr);
1955
- }
1956
- };
1957
2021
 
1958
2022
 
1959
2023
  function usesDestructorStack(argTypes) {
@@ -2279,6 +2343,69 @@ async function createWasm() {
2279
2343
  };
2280
2344
  var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
2281
2345
 
2346
+
2347
+ var enumReadValueFromPointer = (name, width, signed) => {
2348
+ switch (width) {
2349
+ case 1: return signed ?
2350
+ function(pointer) { return this.fromWireType(HEAP8[pointer]) } :
2351
+ function(pointer) { return this.fromWireType(HEAPU8[pointer]) };
2352
+ case 2: return signed ?
2353
+ function(pointer) { return this.fromWireType(HEAP16[((pointer)>>1)]) } :
2354
+ function(pointer) { return this.fromWireType(HEAPU16[((pointer)>>1)]) };
2355
+ case 4: return signed ?
2356
+ function(pointer) { return this.fromWireType(HEAP32[((pointer)>>2)]) } :
2357
+ function(pointer) { return this.fromWireType(HEAPU32[((pointer)>>2)]) };
2358
+ default:
2359
+ throw new TypeError(`invalid integer width (${width}): ${name}`);
2360
+ }
2361
+ };
2362
+
2363
+
2364
+ /** @suppress {globalThis} */
2365
+ var __embind_register_enum = (rawType, name, size, isSigned) => {
2366
+ name = AsciiToString(name);
2367
+
2368
+ function ctor() {}
2369
+ ctor.values = {};
2370
+
2371
+ registerType(rawType, {
2372
+ name,
2373
+ constructor: ctor,
2374
+ fromWireType: function(c) {
2375
+ return this.constructor.values[c];
2376
+ },
2377
+ toWireType: (destructors, c) => c.value,
2378
+ readValueFromPointer: enumReadValueFromPointer(name, size, isSigned),
2379
+ destructorFunction: null,
2380
+ });
2381
+ exposePublicSymbol(name, ctor);
2382
+ };
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+ var requireRegisteredType = (rawType, humanName) => {
2389
+ var impl = registeredTypes[rawType];
2390
+ if (undefined === impl) {
2391
+ throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
2392
+ }
2393
+ return impl;
2394
+ };
2395
+ var __embind_register_enum_value = (rawEnumType, name, enumValue) => {
2396
+ var enumType = requireRegisteredType(rawEnumType, 'enum');
2397
+ name = AsciiToString(name);
2398
+
2399
+ var Enum = enumType.constructor;
2400
+
2401
+ var Value = Object.create(enumType.constructor.prototype, {
2402
+ value: {value: enumValue},
2403
+ constructor: {value: createNamedFunction(`${enumType.name}_${name}`, function() {})},
2404
+ });
2405
+ Enum.values[enumValue] = Value;
2406
+ Enum[name] = Value;
2407
+ };
2408
+
2282
2409
  var floatReadValueFromPointer = (name, width) => {
2283
2410
  switch (width) {
2284
2411
  case 4: return function(pointer) {
@@ -2406,6 +2533,12 @@ async function createWasm() {
2406
2533
  };
2407
2534
 
2408
2535
 
2536
+ var EmValOptionalType = Object.assign({optional: true}, EmValType);;
2537
+ var __embind_register_optional = (rawOptionalType, rawType) => {
2538
+ registerType(rawOptionalType, EmValOptionalType);
2539
+ };
2540
+
2541
+
2409
2542
 
2410
2543
  var __embind_register_smart_ptr = (rawType,
2411
2544
  rawPointeeType,
@@ -2766,15 +2899,6 @@ async function createWasm() {
2766
2899
  return id;
2767
2900
  };
2768
2901
 
2769
-
2770
-
2771
- var requireRegisteredType = (rawType, humanName) => {
2772
- var impl = registeredTypes[rawType];
2773
- if (undefined === impl) {
2774
- throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
2775
- }
2776
- return impl;
2777
- };
2778
2902
  var emval_lookupTypes = (argCount, argTypes) => {
2779
2903
  var a = new Array(argCount);
2780
2904
  for (var i = 0; i < argCount; ++i) {
@@ -3286,7 +3410,6 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
3286
3410
  'unregisterInheritedInstance',
3287
3411
  'getInheritedInstanceCount',
3288
3412
  'getLiveInheritedInstances',
3289
- 'enumReadValueFromPointer',
3290
3413
  'setDelayFunction',
3291
3414
  'validateThis',
3292
3415
  'count_emval_handles',
@@ -3554,6 +3677,7 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
3554
3677
  'registeredPointers',
3555
3678
  'registerType',
3556
3679
  'integerReadValueFromPointer',
3680
+ 'enumReadValueFromPointer',
3557
3681
  'floatReadValueFromPointer',
3558
3682
  'assertIntegerRange',
3559
3683
  'readPointer',
@@ -3671,12 +3795,18 @@ var wasmImports = {
3671
3795
  /** @export */
3672
3796
  _embind_register_class: __embind_register_class,
3673
3797
  /** @export */
3798
+ _embind_register_class_class_property: __embind_register_class_class_property,
3799
+ /** @export */
3674
3800
  _embind_register_class_constructor: __embind_register_class_constructor,
3675
3801
  /** @export */
3676
3802
  _embind_register_class_function: __embind_register_class_function,
3677
3803
  /** @export */
3678
3804
  _embind_register_emval: __embind_register_emval,
3679
3805
  /** @export */
3806
+ _embind_register_enum: __embind_register_enum,
3807
+ /** @export */
3808
+ _embind_register_enum_value: __embind_register_enum_value,
3809
+ /** @export */
3680
3810
  _embind_register_float: __embind_register_float,
3681
3811
  /** @export */
3682
3812
  _embind_register_function: __embind_register_function,
@@ -3685,6 +3815,8 @@ var wasmImports = {
3685
3815
  /** @export */
3686
3816
  _embind_register_memory_view: __embind_register_memory_view,
3687
3817
  /** @export */
3818
+ _embind_register_optional: __embind_register_optional,
3819
+ /** @export */
3688
3820
  _embind_register_smart_ptr: __embind_register_smart_ptr,
3689
3821
  /** @export */
3690
3822
  _embind_register_std_string: __embind_register_std_string,
Binary file