vislite 1.2.0-alpha.0 → 1.2.0-alpha.2

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 (75) hide show
  1. package/CHANGELOG +5 -1
  2. package/README.md +165 -142
  3. package/lib/Buffer/index.es.js +1 -1
  4. package/lib/Buffer/index.es.min.js +1 -1
  5. package/lib/Canvas/index.es.js +15 -5
  6. package/lib/Canvas/index.es.min.js +2 -2
  7. package/lib/Cardinal/index.es.js +1 -1
  8. package/lib/Cardinal/index.es.min.js +1 -1
  9. package/lib/Eoap/index.es.js +1 -1
  10. package/lib/Eoap/index.es.min.js +1 -1
  11. package/lib/Hermite/index.es.js +1 -1
  12. package/lib/Hermite/index.es.min.js +1 -1
  13. package/lib/Matrix4/index.es.js +1 -1
  14. package/lib/Matrix4/index.es.min.js +1 -1
  15. package/lib/Mercator/index.es.js +1 -1
  16. package/lib/Mercator/index.es.min.js +1 -1
  17. package/lib/RawCanvas/index.es.js +1 -1
  18. package/lib/RawCanvas/index.es.min.js +1 -1
  19. package/lib/SVG/index.es.js +1 -1
  20. package/lib/SVG/index.es.min.js +1 -1
  21. package/lib/Shader/index.es.js +1 -1
  22. package/lib/Shader/index.es.min.js +1 -1
  23. package/lib/Texture/index.es.js +1 -1
  24. package/lib/Texture/index.es.min.js +1 -1
  25. package/lib/TreeLayout/index.es.js +6 -6
  26. package/lib/TreeLayout/index.es.min.js +1 -1
  27. package/lib/animation/index.es.js +1 -1
  28. package/lib/animation/index.es.min.js +1 -1
  29. package/lib/assemble/index.es.d.ts +3 -0
  30. package/lib/assemble/index.es.js +23 -0
  31. package/lib/assemble/index.es.min.d.ts +3 -0
  32. package/lib/assemble/index.es.min.js +5 -0
  33. package/lib/getLoopColors/index.es.js +1 -1
  34. package/lib/getLoopColors/index.es.min.js +1 -1
  35. package/lib/getWebGLContext/index.es.js +1 -1
  36. package/lib/getWebGLContext/index.es.min.js +1 -1
  37. package/lib/index.umd.js +58 -9
  38. package/lib/index.umd.min.js +2 -2
  39. package/lib/initOption/index.es.d.ts +3 -0
  40. package/lib/initOption/index.es.js +12 -0
  41. package/lib/initOption/index.es.min.d.ts +3 -0
  42. package/lib/initOption/index.es.min.js +5 -0
  43. package/lib/mergeOption/index.es.d.ts +3 -0
  44. package/lib/mergeOption/index.es.js +42 -0
  45. package/lib/mergeOption/index.es.min.d.ts +3 -0
  46. package/lib/mergeOption/index.es.min.js +5 -0
  47. package/lib/move/index.es.js +1 -1
  48. package/lib/move/index.es.min.js +1 -1
  49. package/lib/rotate/index.es.js +1 -1
  50. package/lib/rotate/index.es.min.js +1 -1
  51. package/lib/ruler/index.es.js +1 -1
  52. package/lib/ruler/index.es.min.js +1 -1
  53. package/lib/scale/index.es.js +1 -1
  54. package/lib/scale/index.es.min.js +1 -1
  55. package/lib/throttle/index.es.js +5 -5
  56. package/lib/throttle/index.es.min.js +1 -1
  57. package/package/assemble/index.ts +3 -0
  58. package/package/index.ts +11 -1
  59. package/package/initOption/index.ts +3 -0
  60. package/package/mergeOption/index.ts +3 -0
  61. package/package.json +1 -1
  62. package/src/Canvas.ts +13 -2
  63. package/src/animation.ts +98 -98
  64. package/src/common/canvas/painter.ts +475 -475
  65. package/src/common/option.ts +30 -0
  66. package/src/common/tree/index.ts +2 -2
  67. package/src/common/type.ts +27 -0
  68. package/src/layout/TreeLayout.ts +2 -2
  69. package/src/throttle.ts +2 -2
  70. package/types/Canvas.d.ts +330 -331
  71. package/types/Matrix4.d.ts +1 -1
  72. package/types/assemble.d.ts +6 -0
  73. package/types/index.d.ts +14 -1
  74. package/types/option.d.ts +13 -0
  75. package/src/common/mergeOption.ts +0 -7
@@ -0,0 +1,30 @@
1
+ import { isPlainObject } from "./type"
2
+
3
+ // 初始化配置
4
+ export function initOption(setOption: any, defaultOption: any) {
5
+ for (const key in setOption) {
6
+ defaultOption[key] = setOption[key]
7
+ }
8
+
9
+ return defaultOption
10
+ }
11
+
12
+ // 合并配置
13
+ export function mergeOption(oldOption: any, newOption: any) {
14
+ (function doit(oldOption, newOption) {
15
+
16
+ for (const key in newOption) {
17
+ const value = newOption[key]
18
+
19
+ if (isPlainObject(value)) {
20
+ if (!oldOption[key]) oldOption[key] = {}
21
+
22
+ doit(oldOption[key], newOption[key])
23
+ } else {
24
+ oldOption[key] = value
25
+ }
26
+
27
+ }
28
+
29
+ })(oldOption, newOption)
30
+ }
@@ -2,7 +2,7 @@ import type TreeConfigType from '../../../types/TreeConfig'
2
2
  import type { TreeResultType } from '../../../types/Tree'
3
3
 
4
4
  import toPlainTree from './toPlainTree'
5
- import mergeOption from '../mergeOption'
5
+ import { initOption } from '../option'
6
6
 
7
7
  class Tree {
8
8
  readonly name: string = 'Tree'
@@ -10,7 +10,7 @@ class Tree {
10
10
  private __config: TreeConfigType
11
11
 
12
12
  constructor(config: TreeConfigType = {}) {
13
- this.__config = mergeOption(config, {
13
+ this.__config = initOption(config, {
14
14
  root: (initTree: any) => initTree,
15
15
  children: (parentTree: any) => parentTree.children,
16
16
  id: (treedata: any) => treedata.name
@@ -0,0 +1,27 @@
1
+ let toString = Object.prototype.toString
2
+
3
+ // 获取一个值的类型字符串[object type]
4
+ export function getType(value: any) {
5
+ if (value == null) {
6
+ return value === undefined ? '[object Undefined]' : '[object Null]'
7
+ }
8
+ return toString.call(value)
9
+ }
10
+
11
+ // 判断一个值是不是一个朴素的'对象'
12
+ export function isPlainObject(value: any) {
13
+ if (value === null || typeof value !== 'object' || getType(value) != '[object Object]') {
14
+ return false
15
+ }
16
+
17
+ // 如果原型为null
18
+ if (Object.getPrototypeOf(value) === null) {
19
+ return true
20
+ }
21
+
22
+ let proto = value
23
+ while (Object.getPrototypeOf(proto) !== null) {
24
+ proto = Object.getPrototypeOf(proto)
25
+ }
26
+ return Object.getPrototypeOf(value) === proto
27
+ }
@@ -3,7 +3,7 @@ import type { TreeResultType } from '../../types/Tree'
3
3
  import type TreeOptionType from '../../types/TreeOption'
4
4
 
5
5
  import Tree from '../common/tree/index'
6
- import mergeOption from '../common/mergeOption'
6
+ import { initOption } from '../common/option'
7
7
  import animation from '../animation'
8
8
  import rotate from '../rotate'
9
9
 
@@ -30,7 +30,7 @@ class TreeLayout extends Tree implements TreeLayoutType {
30
30
  private __noOpens = {}
31
31
 
32
32
  setOption(option: TreeOptionType) {
33
- mergeOption(option, this.__option)
33
+ initOption(option, this.__option)
34
34
  return this
35
35
  }
36
36
 
package/src/throttle.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type throttleOptionType from '../types/throttleOption'
2
2
 
3
- import mergeOption from './common/mergeOption'
3
+ import { initOption } from './common/option'
4
4
 
5
5
  export default function (callback: Function, option: throttleOptionType = {}) {
6
6
 
7
7
  // 校对缺省值
8
- option = mergeOption(option, <throttleOptionType>{
8
+ option = initOption(option, <throttleOptionType>{
9
9
  time: 200,
10
10
  keep: false,
11
11
  opportunity: "end"