@anov/3d 0.0.286 → 0.0.288
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/dist/anov3d.js +40 -43
- package/dist/anov3d.js.map +1 -1
- package/dist/applicationApi.js +94 -118
- package/dist/applicationApi.js.map +1 -1
- package/dist/hooksManager.js +10 -10
- package/dist/hooksManager.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/messageStatus.js +3 -3
- package/dist/messageStatus.js.map +1 -1
- package/dist/module/animation/index.js +61 -113
- package/dist/module/animation/index.js.map +1 -1
- package/dist/module/animation/motion/index.js +58 -91
- package/dist/module/animation/motion/index.js.map +1 -1
- package/dist/module/animation/strategy.js +7 -21
- package/dist/module/animation/strategy.js.map +1 -1
- package/dist/module/camera/index.js +216 -278
- package/dist/module/camera/index.js.map +1 -1
- package/dist/module/develop/index.js +27 -35
- package/dist/module/develop/index.js.map +1 -1
- package/dist/module/entity/area/index.js +29 -87
- package/dist/module/entity/area/index.js.map +1 -1
- package/dist/module/entity/bar/index.js +5 -24
- package/dist/module/entity/bar/index.js.map +1 -1
- package/dist/module/entity/bar/style/bar_01.js +13 -52
- package/dist/module/entity/bar/style/bar_01.js.map +1 -1
- package/dist/module/entity/bar/style/index.js +7 -21
- package/dist/module/entity/bar/style/index.js.map +1 -1
- package/dist/module/entity/baseEntity.js +43 -66
- package/dist/module/entity/baseEntity.js.map +1 -1
- package/dist/module/entity/batch/index.js +77 -168
- package/dist/module/entity/batch/index.js.map +1 -1
- package/dist/module/entity/dispose.js +14 -16
- package/dist/module/entity/dispose.js.map +1 -1
- package/dist/module/entity/flyline/index.js +34 -90
- package/dist/module/entity/flyline/index.js.map +1 -1
- package/dist/module/entity/group/index.js +59 -75
- package/dist/module/entity/group/index.js.map +1 -1
- package/dist/module/entity/heatmap/index.js +62 -79
- package/dist/module/entity/heatmap/index.js.map +1 -1
- package/dist/module/entity/hybridList.js +49 -67
- package/dist/module/entity/hybridList.js.map +1 -1
- package/dist/module/entity/index.js +442 -644
- package/dist/module/entity/index.js.map +1 -1
- package/dist/module/entity/infoPanel/index.js +23 -76
- package/dist/module/entity/infoPanel/index.js.map +1 -1
- package/dist/module/entity/light/pointLight/index.js +48 -84
- package/dist/module/entity/light/pointLight/index.js.map +1 -1
- package/dist/module/entity/mark/index.js +51 -101
- package/dist/module/entity/mark/index.js.map +1 -1
- package/dist/module/entity/model/index.js +108 -151
- package/dist/module/entity/model/index.js.map +1 -1
- package/dist/module/entity/model/load/loadFbx.js +8 -8
- package/dist/module/entity/model/load/loadFbx.js.map +1 -1
- package/dist/module/entity/model/load/loadGlb.js +13 -11
- package/dist/module/entity/model/load/loadGlb.js.map +1 -1
- package/dist/module/entity/model/load.js +19 -57
- package/dist/module/entity/model/load.js.map +1 -1
- package/dist/module/entity/poi/index.js +34 -90
- package/dist/module/entity/poi/index.js.map +1 -1
- package/dist/module/entity/shape/index.js +67 -136
- package/dist/module/entity/shape/index.js.map +1 -1
- package/dist/module/entity/spline/index.js +22 -75
- package/dist/module/entity/spline/index.js.map +1 -1
- package/dist/module/entity/strategy.js +92 -274
- package/dist/module/entity/strategy.js.map +1 -1
- package/dist/module/entity/traffic/realismTraffic/index.js +59 -88
- package/dist/module/entity/traffic/realismTraffic/index.js.map +1 -1
- package/dist/module/entity/traffic/streamerTraffic/index.js +50 -81
- package/dist/module/entity/traffic/streamerTraffic/index.js.map +1 -1
- package/dist/module/entity/utils.js +11 -13
- package/dist/module/entity/utils.js.map +1 -1
- package/dist/module/entity/videoPanel/index.js +23 -76
- package/dist/module/entity/videoPanel/index.js.map +1 -1
- package/dist/module/environment/index.js +54 -73
- package/dist/module/environment/index.js.map +1 -1
- package/dist/module/environment/season/index.js +342 -184
- package/dist/module/environment/season/index.js.map +1 -1
- package/dist/module/eventBus/entityEvents.js +1 -1
- package/dist/module/eventBus/entityEvents.js.map +1 -1
- package/dist/module/eventBus/index.js +79 -93
- package/dist/module/eventBus/index.js.map +1 -1
- package/dist/module/material/index.js +279 -334
- package/dist/module/material/index.js.map +1 -1
- package/dist/module/scene/fileParse.js +277 -369
- package/dist/module/scene/fileParse.js.map +1 -1
- package/dist/module/scene/index.js +106 -161
- package/dist/module/scene/index.js.map +1 -1
- package/dist/module/tool/index.js +26 -33
- package/dist/module/tool/index.js.map +1 -1
- package/dist/sdkEntry.js +2 -23
- package/dist/sdkEntry.js.map +1 -1
- package/dist/utils/abstract.js +12 -15
- package/dist/utils/abstract.js.map +1 -1
- package/dist/utils/index.js +23 -24
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/messageFn.js +17 -18
- package/dist/utils/messageFn.js.map +1 -1
- package/package.json +6 -3
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
1
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
2
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
3
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
6
|
import { HeatMap } from '@anov/3d-ability';
|
|
11
7
|
import { Euler, MathUtils, Vector3, use } from '@anov/3d-core';
|
|
12
|
-
|
|
8
|
+
const defaultOption = {
|
|
13
9
|
name: '',
|
|
14
10
|
visible: true,
|
|
15
11
|
position: [0, 0, 0],
|
|
@@ -17,79 +13,66 @@ var defaultOption = {
|
|
|
17
13
|
scale: [1, 1, 1],
|
|
18
14
|
radius: 10
|
|
19
15
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
_classCallCheck(this, HeatmapManage);
|
|
16
|
+
class HeatmapManage {
|
|
17
|
+
constructor() {
|
|
23
18
|
_defineProperty(this, "_heatmap", void 0);
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return this._heatmap;
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "update",
|
|
86
|
-
value: function update(target, option) {
|
|
87
|
-
var lastOption = target.userData.option;
|
|
88
|
-
if (this._heatmap) this._heatmap.removeFromParent();
|
|
89
|
-
return this.create(_objectSpread(_objectSpread({}, lastOption), option));
|
|
90
|
-
}
|
|
91
|
-
}]);
|
|
92
|
-
return HeatmapManage;
|
|
93
|
-
}();
|
|
20
|
+
setOption(option, target) {
|
|
21
|
+
const {
|
|
22
|
+
name,
|
|
23
|
+
visible,
|
|
24
|
+
position,
|
|
25
|
+
rotation,
|
|
26
|
+
scale
|
|
27
|
+
} = _objectSpread(_objectSpread({}, defaultOption), option);
|
|
28
|
+
target.name = name;
|
|
29
|
+
target.visible = visible;
|
|
30
|
+
target.position.copy(new Vector3().fromArray(position));
|
|
31
|
+
target.rotation.copy(new Euler(MathUtils.degToRad(rotation[0]), MathUtils.degToRad(rotation[1]), MathUtils.degToRad(rotation[2])));
|
|
32
|
+
target.scale.copy(new Vector3().fromArray(scale));
|
|
33
|
+
target.userData.option = _objectSpread(_objectSpread({}, defaultOption), option);
|
|
34
|
+
}
|
|
35
|
+
handleMappingGradien(colorGradient) {
|
|
36
|
+
const result = {};
|
|
37
|
+
colorGradient.forEach((color, index) => {
|
|
38
|
+
const position = index === colorGradient.length - 1 ? 1.0 : Number(((index + 1) / colorGradient.length).toFixed(2));
|
|
39
|
+
result[position] = color;
|
|
40
|
+
});
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
create(json) {
|
|
44
|
+
const {
|
|
45
|
+
effectUri,
|
|
46
|
+
radius,
|
|
47
|
+
colorGradient = ['#0000FF', '#00FF00', '#FFFF00', '#FF0000'],
|
|
48
|
+
range = []
|
|
49
|
+
} = _objectSpread(_objectSpread({}, defaultOption), json);
|
|
50
|
+
this._heatmap = new HeatMap({
|
|
51
|
+
height: 1,
|
|
52
|
+
isPixel: effectUri === 'dot',
|
|
53
|
+
radius,
|
|
54
|
+
colorMap: this.handleMappingGradien(colorGradient),
|
|
55
|
+
range: {
|
|
56
|
+
min: range[0],
|
|
57
|
+
max: range[1]
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
this._heatmap.setData(json.points.map(item => ({
|
|
61
|
+
x: item.position[0],
|
|
62
|
+
y: 0,
|
|
63
|
+
z: item.position[1],
|
|
64
|
+
value: item.value,
|
|
65
|
+
radius: item.radius
|
|
66
|
+
})));
|
|
67
|
+
this.setOption(json, this._heatmap);
|
|
68
|
+
use.useScene().scene.add(this._heatmap);
|
|
69
|
+
return this._heatmap;
|
|
70
|
+
}
|
|
71
|
+
update(target, option) {
|
|
72
|
+
const lastOption = target.userData.option;
|
|
73
|
+
if (this._heatmap) this._heatmap.removeFromParent();
|
|
74
|
+
return this.create(_objectSpread(_objectSpread({}, lastOption), option));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
94
77
|
export default HeatmapManage;
|
|
95
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HeatMap","Euler","MathUtils","Vector3","use","defaultOption","name","visible","position","rotation","scale","radius","HeatmapManage","
|
|
1
|
+
{"version":3,"names":["HeatMap","Euler","MathUtils","Vector3","use","defaultOption","name","visible","position","rotation","scale","radius","HeatmapManage","constructor","_defineProperty","setOption","option","target","_objectSpread","copy","fromArray","degToRad","userData","handleMappingGradien","colorGradient","result","forEach","color","index","length","Number","toFixed","create","json","effectUri","range","_heatmap","height","isPixel","colorMap","min","max","setData","points","map","item","x","y","z","value","useScene","scene","add","update","lastOption","removeFromParent"],"sources":["../../../../src/module/entity/heatmap/index.ts"],"sourcesContent":["import { HeatMap } from '@anov/3d-ability'\nimport type { Object3D } from '@anov/3d-core'\nimport { Euler, MathUtils, Vector3, use } from '@anov/3d-core'\n\ntype PointsTypeItem = {\n position: number[]\n value: number\n radius?: number\n}\n\ntype PartialHeatmapOption = Partial<{\n name: string\n visible: boolean\n position: number[]\n rotation: number[]\n scale: number[]\n range: number[]\n colorGradient: number[]\n effectUri: string\n radius?: number\n}> & {\n points: PointsTypeItem[]\n}\n\nconst defaultOption = {\n name: '',\n visible: true,\n position: [0, 0, 0],\n rotation: [0, 0, 0],\n scale: [1, 1, 1],\n radius: 10,\n}\n\nclass HeatmapManage {\n private _heatmap: HeatMap\n\n private setOption(option: PartialHeatmapOption, target: HeatMap) {\n const { name, visible, position, rotation, scale } = { ...defaultOption, ...option }\n\n target.name = name\n target.visible = visible\n target.position.copy(new Vector3().fromArray(position))\n target.rotation.copy(new Euler(MathUtils.degToRad(rotation[0]), MathUtils.degToRad(rotation[1]), MathUtils.degToRad(rotation[2])))\n target.scale.copy(new Vector3().fromArray(scale))\n\n target.userData.option = { ...defaultOption, ...option }\n }\n\n private handleMappingGradien(colorGradient: string[] | number[]) {\n const result = {}\n\n colorGradient.forEach((color, index) => {\n const position = index === colorGradient.length - 1\n ? 1.0\n : Number(((index + 1) / colorGradient.length).toFixed(2))\n\n result[position] = color\n })\n\n return result\n }\n\n public create(json: PartialHeatmapOption) {\n const { effectUri, radius, colorGradient = ['#0000FF', '#00FF00', '#FFFF00', '#FF0000'], range = [] } = { ...defaultOption, ...json }\n\n this._heatmap = new HeatMap({\n height: 1,\n isPixel: effectUri === 'dot',\n radius,\n colorMap: this.handleMappingGradien(colorGradient),\n range: {\n min: range[0],\n max: range[1],\n },\n })\n\n this._heatmap.setData(\n json.points.map(item => ({\n x: item.position[0],\n y: 0,\n z: item.position[1],\n value: item.value,\n radius: item.radius,\n })),\n )\n\n this.setOption(json, this._heatmap)\n use.useScene().scene.add(this._heatmap)\n\n return this._heatmap\n }\n\n public update(target: Object3D, option: PartialHeatmapOption) {\n const lastOption = target.userData.option\n\n if (this._heatmap)\n this._heatmap.removeFromParent()\n\n return this.create({ ...lastOption, ...option })\n }\n}\nexport default HeatmapManage"],"mappings":";;;;;AAAA,SAASA,OAAO,QAAQ,kBAAkB;AAE1C,SAASC,KAAK,EAAEC,SAAS,EAAEC,OAAO,EAAEC,GAAG,QAAQ,eAAe;AAsB9D,MAAMC,aAAa,GAAG;EACpBC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACnBC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACnBC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EAChBC,MAAM,EAAE;AACV,CAAC;AAED,MAAMC,aAAa,CAAC;EAAAC,YAAA;IAAAC,eAAA;EAAA;EAGVC,SAASA,CAACC,MAA4B,EAAEC,MAAe,EAAE;IAC/D,MAAM;MAAEX,IAAI;MAAEC,OAAO;MAAEC,QAAQ;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAQ,aAAA,CAAAA,aAAA,KAAQb,aAAa,GAAKW,MAAM,CAAE;IAEpFC,MAAM,CAACX,IAAI,GAAGA,IAAI;IAClBW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eAAeJ,aAAa"}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
1
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
class ListNode {
|
|
5
|
+
constructor(value, key) {
|
|
6
|
+
_defineProperty(this, "value", void 0);
|
|
7
|
+
_defineProperty(this, "key", void 0);
|
|
8
|
+
_defineProperty(this, "next", void 0);
|
|
9
|
+
_defineProperty(this, "prev", void 0);
|
|
10
|
+
this.value = value;
|
|
11
|
+
this.key = key;
|
|
12
|
+
this.next = null;
|
|
13
|
+
this.prev = null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class HybridList {
|
|
17
|
+
constructor() {
|
|
22
18
|
_defineProperty(this, "map", void 0);
|
|
23
19
|
_defineProperty(this, "head", void 0);
|
|
24
20
|
_defineProperty(this, "tail", void 0);
|
|
@@ -26,53 +22,39 @@ var HybridList = /*#__PURE__*/function () {
|
|
|
26
22
|
this.head = null;
|
|
27
23
|
this.tail = null;
|
|
28
24
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
value:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var newNode = new ListNode(value, key);
|
|
51
|
-
this.map.set(key, newNode);
|
|
52
|
-
if (this.tail) {
|
|
53
|
-
this.tail.next = newNode;
|
|
54
|
-
newNode.prev = this.tail;
|
|
55
|
-
this.tail = newNode;
|
|
56
|
-
} else {
|
|
57
|
-
this.head = this.tail = newNode;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "delete",
|
|
62
|
-
value: function _delete(key) {
|
|
63
|
-
var node = this.map.get(key);
|
|
64
|
-
if (!node) return;
|
|
65
|
-
if (node.prev) node.prev.next = node.next;else this.head = node.next;
|
|
66
|
-
if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
|
|
67
|
-
this.map.delete(key);
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "clear",
|
|
71
|
-
value: function clear() {
|
|
72
|
-
this.map.clear();
|
|
25
|
+
get(key) {
|
|
26
|
+
const node = this.map.get(key);
|
|
27
|
+
return node ? node.value : null;
|
|
28
|
+
}
|
|
29
|
+
update(key, value) {
|
|
30
|
+
const node = this.map.get(key);
|
|
31
|
+
if (node) node.value = value;
|
|
32
|
+
}
|
|
33
|
+
has(key) {
|
|
34
|
+
return this.map.has(key);
|
|
35
|
+
}
|
|
36
|
+
add(key, value) {
|
|
37
|
+
if (this.map.has(key)) throw new Error(`${key} already exists`);
|
|
38
|
+
const newNode = new ListNode(value, key);
|
|
39
|
+
this.map.set(key, newNode);
|
|
40
|
+
if (this.tail) {
|
|
41
|
+
this.tail.next = newNode;
|
|
42
|
+
newNode.prev = this.tail;
|
|
43
|
+
this.tail = newNode;
|
|
44
|
+
} else {
|
|
45
|
+
this.head = this.tail = newNode;
|
|
73
46
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
}
|
|
48
|
+
delete(key) {
|
|
49
|
+
const node = this.map.get(key);
|
|
50
|
+
if (!node) return;
|
|
51
|
+
if (node.prev) node.prev.next = node.next;else this.head = node.next;
|
|
52
|
+
if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
|
|
53
|
+
this.map.delete(key);
|
|
54
|
+
}
|
|
55
|
+
clear() {
|
|
56
|
+
this.map.clear();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
77
59
|
export default HybridList;
|
|
78
60
|
//# sourceMappingURL=hybridList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ListNode","
|
|
1
|
+
{"version":3,"names":["ListNode","constructor","value","key","_defineProperty","next","prev","HybridList","map","Map","head","tail","get","node","update","has","add","Error","newNode","set","delete","clear"],"sources":["../../../src/module/entity/hybridList.ts"],"sourcesContent":["class ListNode<T> {\n value: T\n key: string | number\n next: ListNode<T> | null\n prev: ListNode<T> | null\n\n constructor(value: T, key: string | number) {\n this.value = value\n this.key = key\n this.next = null\n this.prev = null\n }\n}\n\nclass HybridList<T> {\n public map: Map<string | number, ListNode<T>>\n private head: ListNode<T> | null\n private tail: ListNode<T> | null\n\n constructor() {\n this.map = new Map<string | number, ListNode<T>>()\n this.head = null\n this.tail = null\n }\n\n get(key: string | number): T | null {\n const node = this.map.get(key)\n return node ? node.value : null\n }\n\n update(key: string | number, value: T): void {\n const node = this.map.get(key)\n if (node)\n node.value = value\n }\n\n has(key: string | number) {\n return this.map.has(key)\n }\n\n add(key: string | number, value: T): void {\n if (this.map.has(key))\n throw new Error(`${key} already exists`)\n\n const newNode = new ListNode(value, key)\n this.map.set(key, newNode)\n\n if (this.tail) {\n this.tail.next = newNode\n newNode.prev = this.tail\n this.tail = newNode\n }\n else {\n this.head = this.tail = newNode\n }\n }\n\n delete(key: string | number): void {\n const node = this.map.get(key)\n\n if (!node)\n return\n\n if (node.prev)\n node.prev.next = node.next\n else\n this.head = node.next\n\n if (node.next)\n node.next.prev = node.prev\n else\n this.tail = node.prev\n\n this.map.delete(key)\n }\n\n clear() {\n this.map.clear()\n }\n}\n\nexport default HybridList\n"],"mappings":";;;AAAA,MAAMA,QAAQ,CAAI;EAMhBC,WAAWA,CAACC,KAAQ,EAAEC,GAAoB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAC1C,IAAI,CAACF,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,GAAG,GAAGA,GAAG;IACd,IAAI,CAACE,IAAI,GAAG,IAAI;IAChB,IAAI,CAACC,IAAI,GAAG,IAAI;EAClB;AACF;AAEA,MAAMC,UAAU,CAAI;EAKlBN,WAAWA,CAAA,EAAG;IAAAG,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACZ,IAAI,CAACI,GAAG,GAAG,IAAIC,GAAG,CAA+B,CAAC;IA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