@woosh/meep-engine 2.81.3 → 2.82.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/build/meep.cjs +4392 -4420
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +4392 -4420
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +2 -2
- package/editor/enableEditor.js +1 -1
- package/editor/view/EditorView.js +25 -25
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +11 -11
- package/editor/view/node-graph/NodeView.js +7 -7
- package/package.json +1 -1
- package/samples/terrain/editor.js +19 -18
- package/src/core/cache/Cache.js +4 -2
- package/src/core/cache/Cache.spec.js +1 -1
- package/src/core/collection/array/arraySetDiff.js +8 -2
- package/src/core/collection/array/computeHashArray.js +5 -0
- package/src/core/collection/array/groupArrayBy.js +1 -1
- package/src/core/collection/array/weightedRandomFromArray.spec.js +3 -1
- package/src/core/collection/heap/FastBinaryHeap.spec.js +3 -2
- package/src/core/collection/list/List.js +8 -17
- package/src/core/collection/list/List.spec.js +55 -0
- package/src/core/collection/map/HashMap.spec.js +3 -1
- package/src/core/collection/set/HashSet.spec.js +23 -0
- package/src/core/collection/table/RowFirstTableSpec.js +44 -30
- package/src/core/events/signal/signal_aggregate_by_time_window.js +1 -1
- package/src/core/fsm/simple/SimpleStateMachine.js +2 -1
- package/src/core/function/chain.js +19 -0
- package/src/core/function/makeReturnValue.js +8 -0
- package/src/core/function/noop.js +6 -0
- package/src/core/function/objectsEqual.js +14 -0
- package/src/core/function/passThrough.js +9 -0
- package/src/core/function/returnEmptyArray.js +7 -0
- package/src/core/function/returnFalse.js +7 -0
- package/src/core/function/returnOne.js +7 -0
- package/src/core/function/returnTrue.js +7 -0
- package/src/core/function/returnZero.js +7 -0
- package/src/core/function/strictEquals.js +10 -0
- package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +2 -2
- package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +5 -4
- package/src/core/lang/reactive/AbstractCachingParser.js +2 -1
- package/src/core/math/random/randomFloatBetween.spec.js +2 -1
- package/src/core/math/random/randomIntegerBetween.spec.js +2 -1
- package/src/core/model/node-graph/Connection.js +2 -1
- package/src/core/model/node-graph/node/parameter/NodeParameterDescription.js +2 -2
- package/src/core/model/object/ObjectPoolFactory.js +2 -1
- package/src/core/model/stat/Stat.js +4 -4
- package/src/core/process/PromiseWatcher.spec.js +1 -1
- package/src/core/process/task/Task.js +2 -1
- package/src/engine/EngineHarness.js +2 -1
- package/src/engine/achievements/gateway/StorageAchievementGateway.js +1 -1
- package/src/engine/asset/AssetManager.js +14 -14
- package/src/engine/asset/loaders/ArrayBufferLoader.js +1 -1
- package/src/engine/ecs/EntityComponentDataset.spec.js +2 -2
- package/src/engine/ecs/EntityManager.js +2 -1
- package/src/engine/ecs/EntityObserver.spec.js +4 -4
- package/src/engine/ecs/System.js +2 -2
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/src/engine/ecs/ik/IKProblem.js +1 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +2 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +2 -1
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +2 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +2 -1
- package/src/engine/ecs/terrain/util/obtainTerrain.js +1 -1
- package/src/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +3 -3
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -1
- package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +7 -7
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -1
- package/src/engine/graphics/material/SplatMaterial.js +1 -15
- package/src/engine/graphics/render/layers/RenderLayer.js +1 -1
- package/src/engine/graphics/render/utils/ThreeBypassRenderer.js +2 -1
- package/src/engine/graphics/render/visibility/VisibilityFilter.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -1
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +5 -5
- package/src/engine/graphics/texture/cubemap/load_environment_map.js +2 -2
- package/src/engine/graphics/texture/makeOnePixelTexture.js +5 -3
- package/src/engine/graphics/texture/virtual/VirtualTexturePage.js +2 -1
- package/src/engine/graphics/texture/whitePixelTexture.js +9 -0
- package/src/engine/intelligence/behavior/ecs/BehaviorSystem.spec.js +5 -5
- package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.js +3 -3
- package/src/engine/intelligence/mcts/MonteCarlo.js +3 -3
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.js +3 -3
- package/src/engine/network/PriorityFetch.js +2 -2
- package/src/engine/options/Option.js +2 -2
- package/src/engine/options/Option.spec.js +1 -1
- package/src/engine/options/OptionGroup.js +2 -2
- package/src/engine/options/OptionGroup.spec.js +2 -2
- package/src/engine/save/Storage.js +2 -1
- package/src/engine/save/StorageBackedList.js +2 -1
- package/src/engine/save/storage/InMemoryStorage.js +2 -2
- package/src/engine/scene/transitionToScene.js +2 -1
- package/src/engine/sound/ecs/SoundListenerSystem.js +7 -7
- package/src/engine/sound/ecs/emitter/loadSoundTrackAsset.js +3 -3
- package/src/engine/ui/DraggableAspect.js +2 -2
- package/src/engine/ui/GUIEngine.js +17 -17
- package/src/engine/ui/notification/AnimatedObjectEmitter.js +3 -3
- package/src/engine/ui/notification/NotificationManager.js +4 -4
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +9 -9
- package/src/generation/grid/generation/util/buildPathFromDistanceMap.js +1 -1
- package/src/generation/markers/actions/util/GridCellActionDebugBreak.js +1 -1
- package/src/view/common/LabelView.js +9 -9
- package/src/view/common/ListView.js +3 -2
- package/src/view/common/VirtualListView.js +7 -6
- package/src/view/common/dnd/DropTarget.js +2 -2
- package/src/view/elements/DropDownSelectionView.js +2 -2
- package/src/view/elements/image/ImageView.js +4 -4
- package/src/view/elements/progress/SmoothProgressBar.js +4 -4
- package/src/view/elements/radial/RadialMenuElementDefinition.js +1 -1
- package/src/view/elements/tiles2d/TileGrid.js +8 -8
- package/src/view/elements/video/VideoView.js +5 -5
- package/src/view/math/FunctionGraphView.js +1 -1
- package/src/view/tooltip/gml/TooltipParser.js +6 -5
- package/src/core/function/Functions.js +0 -103
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TypeEditor } from "../../TypeEditor.js";
|
|
2
1
|
import List from "../../../../../src/core/collection/list/List.js";
|
|
2
|
+
import { noop } from "../../../../../src/core/function/noop.js";
|
|
3
3
|
import { FieldDescriptor } from "../../FieldDescriptor.js";
|
|
4
4
|
import { FieldValueAdapter } from "../../FieldValueAdapter.js";
|
|
5
|
+
import { TypeEditor } from "../../TypeEditor.js";
|
|
5
6
|
import { ListEditor } from "../collection/ListEditor.js";
|
|
6
|
-
import { noop } from "../../../../../src/core/function/Functions.js";
|
|
7
7
|
|
|
8
8
|
export class ArrayEditor extends TypeEditor {
|
|
9
9
|
inline = false;
|
package/editor/enableEditor.js
CHANGED
|
@@ -3,38 +3,38 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import { passThrough } from "../../src/core/function/passThrough.js";
|
|
7
|
+
import { SurfacePoint3 } from "../../src/core/geom/3d/SurfacePoint3.js";
|
|
8
|
+
import Vector2 from "../../src/core/geom/Vector2.js";
|
|
9
|
+
import Vector3 from "../../src/core/geom/Vector3.js";
|
|
10
|
+
import { ProcessState } from "../../src/core/process/ProcessState.js";
|
|
11
|
+
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
12
|
+
import { Transform } from "../../src/engine/ecs/transform/Transform.js";
|
|
13
|
+
import Mesh from "../../src/engine/graphics/ecs/mesh/Mesh.js";
|
|
14
|
+
import { MeshEvents } from "../../src/engine/graphics/ecs/mesh/MeshEvents.js";
|
|
15
|
+
import { make_ray_from_viewport_position } from "../../src/engine/graphics/make_ray_from_viewport_position.js";
|
|
16
|
+
import LabelView from '../../src/view/common/LabelView.js';
|
|
17
|
+
import ListView from "../../src/view/common/ListView.js";
|
|
18
|
+
import VirtualListView from '../../src/view/common/VirtualListView.js';
|
|
7
19
|
import dom from "../../src/view/DOM.js";
|
|
20
|
+
import BottomLeftResizeHandleView from "../../src/view/elements/BottomLeftResizeHandleView.js";
|
|
8
21
|
|
|
9
|
-
import
|
|
10
|
-
import
|
|
22
|
+
import SimpleWindow from '../../src/view/elements/SimpleWindow.js';
|
|
23
|
+
import View from "../../src/view/View.js";
|
|
24
|
+
import ComponentAddAction from "../actions/concrete/ComponentAddAction.js";
|
|
25
|
+
import EntityCreateAction from "../actions/concrete/EntityCreateAction.js";
|
|
26
|
+
import SelectionAddAction from "../actions/concrete/SelectionAddAction.js";
|
|
27
|
+
import SelectionClearAction from "../actions/concrete/SelectionClearAction.js";
|
|
11
28
|
import ComponentControlFactory from './ecs/ComponentControlFactory.js';
|
|
12
|
-
import
|
|
13
|
-
import LabelView from '../../src/view/common/LabelView.js';
|
|
14
|
-
import ToolView from './tools/ToolView.js';
|
|
29
|
+
import EntityEditorView from './ecs/EntityEditor.js';
|
|
15
30
|
|
|
16
|
-
import
|
|
17
|
-
import ToolSettingsView from "./tools/ToolSettingsView.js";
|
|
31
|
+
import EntityListView from './ecs/EntityList.js';
|
|
18
32
|
import GridPickCoordinateView from "./GridPickCoordinateView.js";
|
|
19
|
-
import ListView from "../../src/view/common/ListView.js";
|
|
20
|
-
import ProcessView from "./process/ProcessView.js";
|
|
21
33
|
import MeshLibraryView from "./library/MeshLibraryView.js";
|
|
22
|
-
import BottomLeftResizeHandleView from "../../src/view/elements/BottomLeftResizeHandleView.js";
|
|
23
|
-
import Vector2 from "../../src/core/geom/Vector2.js";
|
|
24
|
-
import Vector3 from "../../src/core/geom/Vector3.js";
|
|
25
|
-
import Mesh from "../../src/engine/graphics/ecs/mesh/Mesh.js";
|
|
26
|
-
import { Transform } from "../../src/engine/ecs/transform/Transform.js";
|
|
27
|
-
import SelectionClearAction from "../actions/concrete/SelectionClearAction.js";
|
|
28
|
-
import EntityCreateAction from "../actions/concrete/EntityCreateAction.js";
|
|
29
|
-
import ComponentAddAction from "../actions/concrete/ComponentAddAction.js";
|
|
30
|
-
import SelectionAddAction from "../actions/concrete/SelectionAddAction.js";
|
|
31
|
-
import { passThrough } from "../../src/core/function/Functions.js";
|
|
32
|
-
import { ProcessState } from "../../src/core/process/ProcessState.js";
|
|
33
|
-
import { MeshEvents } from "../../src/engine/graphics/ecs/mesh/MeshEvents.js";
|
|
34
|
-
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
35
|
-
import { SurfacePoint3 } from "../../src/core/geom/3d/SurfacePoint3.js";
|
|
36
|
-
import { make_ray_from_viewport_position } from "../../src/engine/graphics/make_ray_from_viewport_position.js";
|
|
37
34
|
import { makeEntityDecorators } from "./makeEntityDecorators.js";
|
|
35
|
+
import ProcessView from "./process/ProcessView.js";
|
|
36
|
+
import ToolSettingsView from "./tools/ToolSettingsView.js";
|
|
37
|
+
import ToolView from './tools/ToolView.js';
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class ViewManager extends View {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { ParticleLayer } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js";
|
|
4
|
-
import ParticleLayerController from "./ParticleLayerController.js";
|
|
1
|
+
import { noop } from "../../../../../src/core/function/noop.js";
|
|
2
|
+
import ObservedValue from "../../../../../src/core/model/ObservedValue.js";
|
|
5
3
|
import {
|
|
6
4
|
ParticleEmitterFlag
|
|
7
5
|
} from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js";
|
|
8
|
-
import {
|
|
9
|
-
import EmptyView from "../../../../../src/view/elements/EmptyView.js";
|
|
10
|
-
import ObservedValue from "../../../../../src/core/model/ObservedValue.js";
|
|
11
|
-
import { noop } from "../../../../../src/core/function/Functions.js";
|
|
12
|
-
import {
|
|
13
|
-
SimulationStepType
|
|
14
|
-
} from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepType.js";
|
|
6
|
+
import { ParticleLayer } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js";
|
|
15
7
|
import {
|
|
16
8
|
SimulationStepDefinition
|
|
17
9
|
} from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepDefinition.js";
|
|
10
|
+
import {
|
|
11
|
+
SimulationStepType
|
|
12
|
+
} from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepType.js";
|
|
13
|
+
import { BlendingType } from "../../../../../src/engine/graphics/texture/sampler/BlendingType.js";
|
|
14
|
+
import { NativeListController } from "../../../../../src/view/controller/controls/NativeListController.js";
|
|
15
|
+
import EmptyView from "../../../../../src/view/elements/EmptyView.js";
|
|
16
|
+
import DatGuiController from "../DatGuiController.js";
|
|
17
|
+
import ParticleLayerController from "./ParticleLayerController.js";
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PortView } from "./PortView.js";
|
|
3
|
-
import EmptyView from "../../../src/view/elements/EmptyView.js";
|
|
4
|
-
import LabelView from "../../../src/view/common/LabelView.js";
|
|
5
|
-
import { DraggableAspect } from "../../../src/engine/ui/DraggableAspect.js";
|
|
1
|
+
import { noop } from "../../../src/core/function/noop.js";
|
|
6
2
|
import Vector2 from "../../../src/core/geom/Vector2.js";
|
|
7
|
-
import { noop } from "../../../src/core/function/Functions.js";
|
|
8
3
|
import { NodeParameterDataType } from "../../../src/core/model/node-graph/node/parameter/NodeParameterDataType.js";
|
|
9
|
-
import DatGuiController from "../ecs/components/DatGuiController.js";
|
|
10
4
|
import { PortDirection } from "../../../src/core/model/node-graph/node/PortDirection.js";
|
|
5
|
+
import { DraggableAspect } from "../../../src/engine/ui/DraggableAspect.js";
|
|
6
|
+
import LabelView from "../../../src/view/common/LabelView.js";
|
|
7
|
+
import EmptyView from "../../../src/view/elements/EmptyView.js";
|
|
8
|
+
import View from "../../../src/view/View.js";
|
|
9
|
+
import DatGuiController from "../ecs/components/DatGuiController.js";
|
|
10
|
+
import { PortView } from "./PortView.js";
|
|
11
11
|
|
|
12
12
|
export class NodeView extends View {
|
|
13
13
|
/**
|
package/package.json
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { EngineHarness } from "../../src/engine/EngineHarness.js";
|
|
2
|
-
import EmptyView from "../../src/view/elements/EmptyView.js";
|
|
3
|
-
import { EngineConfiguration } from "../../src/engine/EngineConfiguration.js";
|
|
4
|
-
import { ArrayBufferLoader } from "../../src/engine/asset/loaders/ArrayBufferLoader.js";
|
|
5
|
-
import { TerrainFlags } from "../../src/engine/ecs/terrain/ecs/TerrainFlags.js";
|
|
6
|
-
import Signal from "../../src/core/events/signal/Signal.js";
|
|
7
|
-
import { NativeListController } from "../../src/view/controller/controls/NativeListController.js";
|
|
8
|
-
import { TerrainLayer } from "../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
9
|
-
import CheckersTextureURI from "../../src/engine/graphics/texture/CheckersTextureURI.js";
|
|
10
|
-
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
11
|
-
import { Cache } from "../../src/core/cache/Cache.js";
|
|
12
|
-
import { computeStringHash } from "../../src/core/primitives/strings/computeStringHash.js";
|
|
13
|
-
import { noop, strictEquals } from "../../src/core/function/Functions.js";
|
|
14
|
-
import { sampler2d_scale } from "../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
15
|
-
import { Sampler2D } from "../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
16
1
|
import { BinaryDataType } from "../../src/core/binary/type/BinaryDataType.js";
|
|
17
2
|
import {
|
|
18
3
|
compute_typed_array_constructor_from_data_type
|
|
19
4
|
} from "../../src/core/binary/type/DataType2TypedArrayConstructorMapping.js";
|
|
20
|
-
import {
|
|
5
|
+
import { Cache } from "../../src/core/cache/Cache.js";
|
|
6
|
+
import Signal from "../../src/core/events/signal/Signal.js";
|
|
7
|
+
import { noop } from "../../src/core/function/noop.js";
|
|
8
|
+
import { strictEquals } from "../../src/core/function/strictEquals.js";
|
|
9
|
+
import { computeStringHash } from "../../src/core/primitives/strings/computeStringHash.js";
|
|
10
|
+
import { ArrayBufferLoader } from "../../src/engine/asset/loaders/ArrayBufferLoader.js";
|
|
21
11
|
import { TextureAssetLoader } from "../../src/engine/asset/loaders/texture/TextureAssetLoader.js";
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
12
|
+
import { TerrainLayer } from "../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
13
|
+
import { TerrainFlags } from "../../src/engine/ecs/terrain/ecs/TerrainFlags.js";
|
|
14
|
+
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
15
|
+
import { EngineConfiguration } from "../../src/engine/EngineConfiguration.js";
|
|
16
|
+
import { EngineHarness } from "../../src/engine/EngineHarness.js";
|
|
24
17
|
import { load_and_set_cubemap_v0 } from "../../src/engine/graphics/load_and_set_cubemap_v0.js";
|
|
18
|
+
import CheckersTextureURI from "../../src/engine/graphics/texture/CheckersTextureURI.js";
|
|
19
|
+
import { copy_Sampler2D_channel_data } from "../../src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js";
|
|
20
|
+
import { sampler2d_scale } from "../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
21
|
+
import { Sampler2D } from "../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
22
|
+
import convertSampler2D2Canvas from "../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
23
|
+
import { NativeListController } from "../../src/view/controller/controls/NativeListController.js";
|
|
24
|
+
import { CanvasView } from "../../src/view/elements/CanvasView.js";
|
|
25
|
+
import EmptyView from "../../src/view/elements/EmptyView.js";
|
|
25
26
|
|
|
26
27
|
const engineHarness = new EngineHarness();
|
|
27
28
|
|
package/src/core/cache/Cache.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
|
+
import { collectIteratorValueToArray } from "../collection/collectIteratorValueToArray.js";
|
|
2
3
|
import { HashMap } from "../collection/map/HashMap.js";
|
|
3
4
|
import Signal from "../events/signal/Signal.js";
|
|
4
|
-
import { returnOne
|
|
5
|
+
import { returnOne } from "../function/returnOne.js";
|
|
6
|
+
import { returnZero } from "../function/returnZero.js";
|
|
7
|
+
import { strictEquals } from "../function/strictEquals.js";
|
|
5
8
|
import { CacheElement } from "./CacheElement.js";
|
|
6
|
-
import { collectIteratorValueToArray } from "../collection/collectIteratorValueToArray.js";
|
|
7
9
|
|
|
8
10
|
// TODO validate hashes of held elements to keep them up to date. Keys are assumed to be immutable, but this assumption may be broken by users
|
|
9
11
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
3
|
+
import { strictEquals } from "../../function/strictEquals.js";
|
|
4
|
+
import { arrayIndexByEquality } from "./arrayIndexByEquality.js";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
|
|
@@ -10,6 +12,10 @@ import {arrayIndexByEquality} from "./arrayIndexByEquality.js";
|
|
|
10
12
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
11
13
|
*/
|
|
12
14
|
export function arraySetDiff(a, b, equals = strictEquals) {
|
|
15
|
+
assert.isArray(a, 'a');
|
|
16
|
+
assert.isArray(b, 'b');
|
|
17
|
+
assert.isFunction(equals, 'equals');
|
|
18
|
+
|
|
13
19
|
// TODO we can do this faster if we use a comparator instead of equality and pre-sort the data
|
|
14
20
|
const uniqueA = a.slice();
|
|
15
21
|
const uniqueB = b.slice();
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} array
|
|
4
6
|
* @param {function(T):number} elementHashFunction
|
|
7
|
+
* @returns {number}
|
|
5
8
|
*/
|
|
6
9
|
export function computeHashArray(array, elementHashFunction) {
|
|
10
|
+
assert.isArrayLike(array, 'array');
|
|
11
|
+
assert.isFunction(elementHashFunction, 'elementHashFunction');
|
|
7
12
|
|
|
8
13
|
const numArguments = array.length;
|
|
9
14
|
let hash = numArguments;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { passThrough } from "../../function/passThrough.js";
|
|
2
|
+
import { returnOne } from "../../function/returnOne.js";
|
|
3
|
+
import { returnZero } from "../../function/returnZero.js";
|
|
1
4
|
import { weightedRandomFromArray } from "./weightedRandomFromArray.js";
|
|
2
|
-
import { passThrough, returnOne, returnZero } from "../../function/Functions.js";
|
|
3
5
|
|
|
4
6
|
test("empty array", () => {
|
|
5
7
|
expect(weightedRandomFromArray([], returnZero, passThrough, null, 0))
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { passThrough } from "../../function/passThrough.js";
|
|
2
|
+
import { returnZero } from "../../function/returnZero.js";
|
|
3
|
+
import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
|
|
1
4
|
import { seededRandom } from "../../math/random/seededRandom.js";
|
|
2
5
|
import BinaryHeap from "./FastBinaryHeap.js";
|
|
3
|
-
import { passThrough, returnZero } from "../../function/Functions.js";
|
|
4
|
-
import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
|
|
5
6
|
|
|
6
7
|
test("constructor doesn't throw", () => {
|
|
7
8
|
new BinaryHeap(returnZero);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "../../assert.js";
|
|
7
7
|
import Signal from "../../events/signal/Signal.js";
|
|
8
|
+
import { objectsEqual } from "../../function/objectsEqual.js";
|
|
8
9
|
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
9
10
|
import { arrayIndexByEquality } from "../array/arrayIndexByEquality.js";
|
|
10
11
|
import { arraySetDiff } from "../array/arraySetDiff.js";
|
|
@@ -190,13 +191,13 @@ class List {
|
|
|
190
191
|
* Replace the data, replacements is performed surgically, meaning that diff is computed and add/remove operations are performed on the set
|
|
191
192
|
* This method is tailored to work well with visualisation as only elements that's missing from the new set is removed, and only elements that are new to are added
|
|
192
193
|
* Conversely, relevant events are dispatched that can observe. This results in fewer changes required to the visualisation
|
|
193
|
-
* @param {T[]}
|
|
194
|
+
* @param {T[]} new_data
|
|
194
195
|
*/
|
|
195
|
-
patch(
|
|
196
|
+
patch(new_data) {
|
|
196
197
|
|
|
197
198
|
const data = this.data;
|
|
198
199
|
|
|
199
|
-
const diff = arraySetDiff(data,
|
|
200
|
+
const diff = arraySetDiff(data, new_data, objectsEqual);
|
|
200
201
|
|
|
201
202
|
//resolve diff
|
|
202
203
|
const removals = diff.uniqueA;
|
|
@@ -213,8 +214,8 @@ class List {
|
|
|
213
214
|
|
|
214
215
|
//sort additions by their position in the input
|
|
215
216
|
additions.sort((a, b) => {
|
|
216
|
-
const ai =
|
|
217
|
-
const bi =
|
|
217
|
+
const ai = new_data.indexOf(a);
|
|
218
|
+
const bi = new_data.indexOf(b);
|
|
218
219
|
|
|
219
220
|
return bi - ai;
|
|
220
221
|
});
|
|
@@ -225,11 +226,11 @@ class List {
|
|
|
225
226
|
const item = additions[i];
|
|
226
227
|
|
|
227
228
|
//find where the item is in the input
|
|
228
|
-
const inputIndex =
|
|
229
|
+
const inputIndex = new_data.indexOf(item);
|
|
229
230
|
|
|
230
231
|
let p = 0;
|
|
231
232
|
for (let i = inputIndex - 1; i >= 0; i--) {
|
|
232
|
-
const prev =
|
|
233
|
+
const prev = new_data[i];
|
|
233
234
|
|
|
234
235
|
//look for previous item in the output
|
|
235
236
|
const j = this.indexOf(prev);
|
|
@@ -949,16 +950,6 @@ class List {
|
|
|
949
950
|
}
|
|
950
951
|
}
|
|
951
952
|
|
|
952
|
-
/**
|
|
953
|
-
*
|
|
954
|
-
* @param {Object} a
|
|
955
|
-
* @param {Object} b
|
|
956
|
-
* @returns {boolean}
|
|
957
|
-
*/
|
|
958
|
-
function objectsEqual(a, b) {
|
|
959
|
-
return a === b || (typeof a.equals === "function" && a.equals(b));
|
|
960
|
-
}
|
|
961
|
-
|
|
962
953
|
function conditionEqualsViaMethod(v) {
|
|
963
954
|
return this === v || this.equals(v);
|
|
964
955
|
}
|
|
@@ -94,6 +94,27 @@ test("'set' at the end of the list", () => {
|
|
|
94
94
|
expect(addHandler).toHaveBeenLastCalledWith(42, 0);
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
test("'set' replace existing value", () => {
|
|
98
|
+
const list = new List();
|
|
99
|
+
|
|
100
|
+
const fn = jest.fn();
|
|
101
|
+
|
|
102
|
+
list.on.removed.add(fn);
|
|
103
|
+
|
|
104
|
+
list.set(0, "a");
|
|
105
|
+
|
|
106
|
+
expect(fn).not.toHaveBeenCalled();
|
|
107
|
+
|
|
108
|
+
list.set(0, "b");
|
|
109
|
+
|
|
110
|
+
expect(list.length).toBe(1);
|
|
111
|
+
|
|
112
|
+
expect(list.get(0)).toBe("b");
|
|
113
|
+
|
|
114
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
115
|
+
expect(fn).toHaveBeenCalledWith("a", 0);
|
|
116
|
+
});
|
|
117
|
+
|
|
97
118
|
test("add increases length", () => {
|
|
98
119
|
const list = new List();
|
|
99
120
|
|
|
@@ -200,3 +221,37 @@ test("map", () => {
|
|
|
200
221
|
|
|
201
222
|
expect(list.map(a => a * 7)).toEqual([7, 14, 21]);
|
|
202
223
|
});
|
|
224
|
+
|
|
225
|
+
test("patch", () => {
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
*
|
|
229
|
+
* @type {List<number>}
|
|
230
|
+
*/
|
|
231
|
+
const list = new List();
|
|
232
|
+
|
|
233
|
+
list.patch([]);
|
|
234
|
+
|
|
235
|
+
expect(list.asArray()).toEqual([]);
|
|
236
|
+
expect(list.length).toBe(0);
|
|
237
|
+
|
|
238
|
+
list.patch([1]);
|
|
239
|
+
|
|
240
|
+
expect(list.asArray()).toEqual([1]);
|
|
241
|
+
expect(list.length).toBe(1);
|
|
242
|
+
|
|
243
|
+
list.patch([1, 2]);
|
|
244
|
+
|
|
245
|
+
expect(list.asArray()).toEqual([1, 2]);
|
|
246
|
+
expect(list.length).toBe(2);
|
|
247
|
+
|
|
248
|
+
list.patch([3, 1, 2]);
|
|
249
|
+
|
|
250
|
+
expect(list.asArray()).toEqual([3, 1, 2]);
|
|
251
|
+
expect(list.length).toBe(3);
|
|
252
|
+
|
|
253
|
+
list.patch([3, 1, 2]);
|
|
254
|
+
|
|
255
|
+
expect(list.asArray()).toEqual([3, 1, 2]);
|
|
256
|
+
expect(list.length).toBe(3);
|
|
257
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { passThrough } from "../../function/passThrough.js";
|
|
2
|
+
import { returnOne } from "../../function/returnOne.js";
|
|
3
|
+
import { strictEquals } from "../../function/strictEquals.js";
|
|
1
4
|
import { generate_next_linear_congruential_index, HashMap } from "./HashMap.js";
|
|
2
|
-
import { passThrough, returnOne, strictEquals } from "../../function/Functions.js";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
*
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { strictEquals } from "../../function/strictEquals.js";
|
|
2
|
+
import { computeStringHash } from "../../primitives/strings/computeStringHash.js";
|
|
3
|
+
import { HashSet } from "./HashSet.js";
|
|
4
|
+
|
|
5
|
+
test("constructor", () => {
|
|
6
|
+
const set = new HashSet();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("add same element twice", () => {
|
|
10
|
+
|
|
11
|
+
const set = new HashSet({
|
|
12
|
+
keyHashFunction: computeStringHash,
|
|
13
|
+
keyEqualityFunction: strictEquals
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
set.add("a");
|
|
17
|
+
|
|
18
|
+
expect(set.size).toBe(1);
|
|
19
|
+
|
|
20
|
+
set.add("a");
|
|
21
|
+
|
|
22
|
+
expect(set.size).toBe(1);
|
|
23
|
+
});
|
|
@@ -13,41 +13,43 @@ import { computeHashArray } from "../array/computeHashArray.js";
|
|
|
13
13
|
import { isArrayEqualStrict } from "../array/isArrayEqualStrict.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
16
17
|
* @readonly
|
|
17
18
|
* @enum {string}
|
|
18
19
|
*/
|
|
19
20
|
export const DataType2DataViewReaders = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
[BinaryDataType.Uint8]: "getUint8",
|
|
22
|
+
[BinaryDataType.Uint16]: "getUint16",
|
|
23
|
+
[BinaryDataType.Uint32]: "getUint32",
|
|
24
|
+
[BinaryDataType.Uint64]: "getUint64",
|
|
25
|
+
|
|
26
|
+
[BinaryDataType.Int8]: "getInt8",
|
|
27
|
+
[BinaryDataType.Int16]: "getInt16",
|
|
28
|
+
[BinaryDataType.Int32]: "getInt32",
|
|
29
|
+
[BinaryDataType.Int64]: "getInt64",
|
|
30
|
+
|
|
31
|
+
[BinaryDataType.Float32]: "getFloat32",
|
|
32
|
+
[BinaryDataType.Float64]: "getFloat64"
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
/**
|
|
36
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
35
37
|
* @readonly
|
|
36
38
|
* @enum {string}
|
|
37
39
|
*/
|
|
38
40
|
export const DataType2DataViewWriters = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
[BinaryDataType.Uint8]: "setUint8",
|
|
42
|
+
[BinaryDataType.Uint16]: "setUint16",
|
|
43
|
+
[BinaryDataType.Uint32]: "setUint32",
|
|
44
|
+
[BinaryDataType.Uint64]: "setUint64",
|
|
45
|
+
|
|
46
|
+
[BinaryDataType.Int8]: "setInt8",
|
|
47
|
+
[BinaryDataType.Int16]: "setInt16",
|
|
48
|
+
[BinaryDataType.Int32]: "setInt32",
|
|
49
|
+
[BinaryDataType.Int64]: "setInt64",
|
|
50
|
+
|
|
51
|
+
[BinaryDataType.Float32]: "setFloat32",
|
|
52
|
+
[BinaryDataType.Float64]: "setFloat64"
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
/**
|
|
@@ -67,10 +69,14 @@ function genRowReader(types, endianType = EndianType.BigEndian) {
|
|
|
67
69
|
|
|
68
70
|
const type = types[i];
|
|
69
71
|
|
|
72
|
+
const reader_name = DataType2DataViewReaders[type];
|
|
73
|
+
|
|
74
|
+
assert.isString(reader_name, 'reader_name');
|
|
75
|
+
|
|
70
76
|
const littleEndianFlag = endianType === EndianType.BigEndian ? 'false' : 'true';
|
|
71
77
|
|
|
72
78
|
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
73
|
-
lines.push(`result[${i}] = dataView.${
|
|
79
|
+
lines.push(`result[${i}] = dataView.${reader_name}(${offset} + byteOffset, ${littleEndianFlag});`);
|
|
74
80
|
|
|
75
81
|
offset += DataTypeByteSizes[type];
|
|
76
82
|
|
|
@@ -100,10 +106,14 @@ function genRowWriter(types, endianType = EndianType.BigEndian) {
|
|
|
100
106
|
for (let i = 0; i < numTypes; i++) {
|
|
101
107
|
const type = types[i];
|
|
102
108
|
|
|
109
|
+
const writer_name = DataType2DataViewWriters[type];
|
|
110
|
+
|
|
111
|
+
assert.isString(writer_name, 'writer_name');
|
|
112
|
+
|
|
103
113
|
const littleEndianFlag = endianType === EndianType.BigEndian ? 'false' : 'true';
|
|
104
114
|
|
|
105
115
|
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
106
|
-
lines.push(`dataView.${
|
|
116
|
+
lines.push(`dataView.${writer_name}(${offset} + byteOffset, record[${i}], ${littleEndianFlag});`);
|
|
107
117
|
|
|
108
118
|
offset += DataTypeByteSizes[type];
|
|
109
119
|
}
|
|
@@ -267,7 +277,7 @@ export class RowFirstTableSpec {
|
|
|
267
277
|
}
|
|
268
278
|
|
|
269
279
|
/**
|
|
270
|
-
*
|
|
280
|
+
* Produces an immutable spec, either creates a new spec or retrieves a cached version
|
|
271
281
|
* @param {BinaryDataType[]} types
|
|
272
282
|
* @param {EndianType} [endianType]
|
|
273
283
|
* @returns {RowFirstTableSpec}
|
|
@@ -276,21 +286,25 @@ export class RowFirstTableSpec {
|
|
|
276
286
|
//compute hash
|
|
277
287
|
const hash = types.join('.') + ':' + endianType;
|
|
278
288
|
|
|
279
|
-
const cachedValue =
|
|
289
|
+
const cachedValue = SPEC_CACHE.get(hash);
|
|
280
290
|
|
|
281
291
|
if (cachedValue !== null) {
|
|
282
292
|
return cachedValue;
|
|
283
293
|
}
|
|
284
294
|
|
|
285
295
|
const newValue = new RowFirstTableSpec(types);
|
|
286
|
-
|
|
296
|
+
SPEC_CACHE.put(hash, newValue);
|
|
287
297
|
|
|
288
298
|
return newValue;
|
|
289
299
|
}
|
|
290
300
|
}
|
|
291
301
|
|
|
292
302
|
|
|
293
|
-
|
|
303
|
+
/**
|
|
304
|
+
* @readonly
|
|
305
|
+
* @type {Cache<string,RowFirstTableSpec>}
|
|
306
|
+
*/
|
|
307
|
+
const SPEC_CACHE = new Cache({
|
|
294
308
|
keyHashFunction: computeStringHash
|
|
295
309
|
});
|
|
296
310
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { dispatchViaProxy, findSignalHandlerIndexByHandle } from "../../events/signal/Signal.js";
|
|
2
2
|
import { SignalHandler } from "../../events/signal/SignalHandler.js";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { noop } from "../../function/noop.js";
|
|
4
5
|
import { SimpleStateMachineDescription } from "./SimpleStateMachineDescription.js";
|
|
5
6
|
|
|
6
7
|
export class SimpleStateMachine {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {...function} processes
|
|
4
|
+
* @returns {function(*): *}
|
|
5
|
+
*/
|
|
6
|
+
export function chain(...processes) {
|
|
7
|
+
const numProcesses = processes.length;
|
|
8
|
+
|
|
9
|
+
return function chain(v) {
|
|
10
|
+
let result = v;
|
|
11
|
+
|
|
12
|
+
for (let i = 0; i < numProcesses; i++) {
|
|
13
|
+
const process = processes[i];
|
|
14
|
+
result = process(result);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
}
|