@woosh/meep-engine 2.48.22 → 2.49.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.
Files changed (230) hide show
  1. package/editor/ecs/component/editors/three/BufferGeometryEditor.js +1 -1
  2. package/editor/ecs/component/editors/three/MeshEditor.js +1 -1
  3. package/editor/tools/GridPaintTool.js +1 -1
  4. package/editor/tools/SelectionTool.js +1 -1
  5. package/editor/tools/paint/TerrainPaintTool.js +1 -1
  6. package/editor/view/GridPickCoordinateView.js +1 -1
  7. package/editor/view/library/MeshLibraryView.js +1 -1
  8. package/package.json +1 -1
  9. package/src/core/UUID.js +2 -0
  10. package/src/core/assert.js +4 -1
  11. package/src/core/binary/32BitEncoder.js +1 -1
  12. package/src/core/binary/ctz32.js +1 -1
  13. package/src/core/binary/operations/bitCount.spec.js +19 -0
  14. package/src/core/binary/uint82float.spec.js +7 -0
  15. package/src/core/bvh2/LeafNode.js +2 -2
  16. package/src/core/bvh2/Node.d.ts +1 -1
  17. package/src/core/bvh2/Node.js +1 -1
  18. package/src/core/bvh2/NodeValidator.js +1 -1
  19. package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +3 -0
  20. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +5 -4
  21. package/src/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
  22. package/src/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -2
  23. package/src/core/bvh2/serialization/serializeBinaryNode.js +1 -1
  24. package/src/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -2
  25. package/src/core/bvh2/transform/RotationOptimizer.spec.js +161 -155
  26. package/src/core/cache/Cache.js +4 -2
  27. package/src/core/codegen/LineBuilder.js +15 -3
  28. package/src/core/codegen/LineBuilder.spec.js +7 -0
  29. package/src/core/collection/HashMap.js +491 -236
  30. package/src/core/collection/HashMap.spec.js +110 -1
  31. package/src/core/collection/array/{typedArrayToDataType.js → typed/typedArrayToDataType.js} +1 -1
  32. package/src/core/collection/array/weightedRandomFromArray.spec.js +20 -0
  33. package/src/core/collection/heap/Uint32Heap.js +1 -0
  34. package/src/core/debug/matchers/AnyOf.js +1 -2
  35. package/src/core/events/signal/Signal.js +7 -5
  36. package/src/core/events/signal/SignalBinding.js +56 -54
  37. package/src/core/events/signal/SignalFlags.js +7 -0
  38. package/src/core/function/Functions.js +1 -1
  39. package/src/core/geom/{Rectangle.js → 2d/Rectangle.js} +5 -5
  40. package/src/core/geom/{AABB2.js → 2d/aabb/AABB2.js} +10 -78
  41. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.js +19 -0
  42. package/src/core/geom/2d/aabb/aabb2_compute_overlap.js +42 -0
  43. package/src/core/geom/2d/aabb/aabb2_contains.js +23 -0
  44. package/src/core/geom/2d/aabb/aabb2_distance_sqr_to_point.js +25 -0
  45. package/src/core/geom/2d/aabb/aabb2_distance_to_point.js +17 -0
  46. package/src/core/geom/2d/aabb/aabb2_distance_to_point.spec.js +17 -0
  47. package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +18 -0
  48. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.js +45 -0
  49. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.spec.js +40 -0
  50. package/src/core/geom/2d/aabb/aabb2_signed_distance_to_point.js +27 -0
  51. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +4 -0
  52. package/src/core/geom/2d/quad-tree/PointQuadTree.js +3 -0
  53. package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +1 -1
  54. package/src/core/geom/2d/quad-tree/QuadTreeNode.js +3 -3
  55. package/src/core/geom/2d/quad-tree/qt_collect_by_circle.js +6 -8
  56. package/src/core/geom/2d/quad-tree/qt_match_data_by_circle.js +3 -3
  57. package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +8 -10
  58. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.d.ts +1 -1
  59. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.js +13 -13
  60. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.spec.js +1 -1
  61. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.js +17 -15
  62. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.spec.js +25 -0
  63. package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +1 -1
  64. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +3 -0
  65. package/src/core/geom/3d/aabb/aabb3_from_v3_array.spec.js +32 -0
  66. package/src/core/geom/3d/aabb/aabb3_intersects_aabb3.spec.js +115 -0
  67. package/src/core/geom/3d/aabb/aabb3_raycast.js +6 -1
  68. package/src/core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js +13 -9
  69. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Encoded_v0.js +6 -6
  70. package/src/core/geom/3d/{CircleMath.js → compute_circle_bounding_box.js} +1 -1
  71. package/src/core/geom/3d/decompose_matrix_4_array.js +18 -19
  72. package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  73. package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/matrix}/allocate_transform_m4.js +1 -1
  74. package/src/core/geom/3d/normal/hemioct/decode_hemioct_to_unit.js +26 -0
  75. package/src/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +0 -26
  76. package/src/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +2 -1
  77. package/src/core/geom/3d/plane/computePlaneLineIntersection.js +51 -0
  78. package/src/core/geom/3d/plane/computePlanePlaneIntersection.js +77 -0
  79. package/src/core/geom/3d/plane/computePlaneRayIntersection.js +55 -0
  80. package/src/core/geom/3d/plane/plane3_computeLineSegmentIntersection.js +50 -0
  81. package/src/core/geom/3d/plane/planeRayIntersection.js +14 -0
  82. package/src/core/geom/3d/{tetrahedra/in_sphere_fast.js → sphere/in_sphere3d_fast.js} +1 -1
  83. package/src/core/geom/3d/{tetrahedra/in_sphere_robust.js → sphere/in_sphere3d_robust.js} +1 -1
  84. package/src/core/geom/3d/sphere/sphere_array_intersects_point.js +2 -2
  85. package/src/core/geom/3d/sphere/{sphereIntersectsPoint.js → sphere_intersects_point.js} +7 -4
  86. package/src/core/geom/3d/sphere/sphere_intersects_point.spec.js +134 -0
  87. package/src/core/geom/3d/sphere/sphere_intersects_ray.spec.js +49 -0
  88. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +11 -7
  89. package/src/core/geom/3d/tetrahedra/delaunay/{debug_validate_mesh.js → debug/debug_validate_mesh.js} +1 -1
  90. package/src/core/geom/3d/tetrahedra/delaunay/{push_boundary_with_validation.js → debug/push_boundary_with_validation.js} +1 -1
  91. package/src/core/geom/3d/tetrahedra/delaunay/{validate_cavity_boundary.js → debug/validate_cavity_boundary.js} +2 -2
  92. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +2 -2
  93. package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +0 -164
  94. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +87 -0
  95. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +81 -0
  96. package/src/core/geom/{GeometryMath.js → 3d/triangle/rayTriangleIntersection.js} +7 -3
  97. package/src/core/geom/ConicRay.js +160 -152
  98. package/src/core/geom/Matrix4.js +2 -0
  99. package/src/core/geom/Quaternion.js +19 -1
  100. package/src/core/geom/packing/max-rect/MaxRectangles.js +5 -215
  101. package/src/core/geom/packing/max-rect/cost/costByBestShortSide.js +11 -0
  102. package/src/core/geom/packing/max-rect/cost/costByRemainingArea.js +14 -0
  103. package/src/core/geom/packing/max-rect/cutArea.js +79 -0
  104. package/src/core/geom/packing/max-rect/findBestContainer.js +58 -0
  105. package/src/core/geom/packing/max-rect/packOneBox.js +49 -0
  106. package/src/core/geom/v3_dot.js +1 -1
  107. package/src/core/graph/GraphUtils.js +1 -1
  108. package/src/core/graph/build_face_graph_from_mesh.js +1 -3
  109. package/src/core/graph/layout/CircleLayout.js +3 -3
  110. package/src/core/graph/layout/{BoxLayouter.js → box/BoxLayouter.js} +6 -50
  111. package/src/core/graph/layout/box/applyCentralGravityAABB2.js +29 -0
  112. package/src/core/json/resolvePath.spec.js +14 -0
  113. package/src/core/land/reactive/{compiler/ReactiveCompiler.spec.js → compileReactiveExpression.spec.js} +17 -17
  114. package/src/core/math/random/MersenneTwister.spec.js +19 -0
  115. package/src/core/math/random/randomGaussian.spec.js +9 -0
  116. package/src/core/math/statistics/computeStatisticalMean.js +2 -2
  117. package/src/core/model/node-graph/visual/NodeVisualData.js +1 -1
  118. package/src/core/model/reactive/model/arithmetic/ReactiveAdd.js +1 -1
  119. package/src/core/model/reactive/model/arithmetic/ReactiveDivide.js +3 -1
  120. package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.js +1 -1
  121. package/src/core/model/reactive/model/arithmetic/ReactiveNegate.js +3 -1
  122. package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.js +1 -1
  123. package/src/core/model/reactive/model/comparative/ReactiveEquals.js +1 -1
  124. package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.js +3 -1
  125. package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.js +3 -1
  126. package/src/core/model/reactive/model/comparative/ReactiveLessThan.js +3 -1
  127. package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.js +3 -1
  128. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.js +1 -1
  129. package/src/core/model/reactive/model/logic/ReactiveAnd.js +1 -1
  130. package/src/core/model/reactive/model/logic/ReactiveNot.js +3 -1
  131. package/src/core/model/reactive/model/logic/ReactiveOr.js +1 -1
  132. package/src/core/primitives/numbers/computeHashFloat.spec.js +7 -0
  133. package/src/core/process/task/util/iteratorTask.js +3 -1
  134. package/src/engine/animation/curve/AnimationCurve.js +34 -5
  135. package/src/engine/animation/curve/AnimationCurve.spec.js +100 -0
  136. package/src/engine/asset/AssetTransformer.js +1 -0
  137. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  138. package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +2 -2
  139. package/src/engine/asset/preloader/Preloader.js +3 -3
  140. package/src/engine/computeStridedIntegerArrayHash.js +4 -2
  141. package/src/engine/ecs/components/Renderable.d.ts +2 -2
  142. package/src/engine/ecs/components/Renderable.js +1 -1
  143. package/src/{ecs → engine/ecs}/grid/pick.js +4 -4
  144. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +1 -1
  145. package/src/engine/ecs/parent/entity_node_compute_bounding_box.js +1 -1
  146. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -18
  147. package/src/engine/ecs/systems/MotionSystem.js +7 -1
  148. package/src/engine/ecs/systems/SynchronizePositionSystem.js +8 -2
  149. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  150. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +2 -2
  151. package/src/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
  152. package/src/engine/ecs/transform/Transform.js +1 -1
  153. package/src/engine/graphics/camera/makeScreenScissorFrustum.d.ts +1 -1
  154. package/src/engine/graphics/camera/makeScreenScissorFrustum.js +3 -3
  155. package/src/engine/graphics/camera/testClippingPlaneComputation.js +13 -13
  156. package/src/engine/graphics/ecs/camera/Camera.js +1 -1
  157. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  158. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +1 -1
  159. package/src/engine/graphics/ecs/mesh/Mesh.js +1 -1
  160. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +1 -1
  161. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +1 -1
  162. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +1 -1
  163. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +1 -1
  164. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +9 -0
  165. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.d.ts +1 -1
  166. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +1 -1
  167. package/src/engine/graphics/geometry/MikkT/STSpace.js +1 -1
  168. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  169. package/src/engine/graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js +1 -1
  170. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  171. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +1 -1
  172. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1 -1
  173. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +1 -1
  174. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +1 -0
  175. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
  176. package/src/engine/graphics/postprocess/threejs/postprocessing/TexturePass.js +2 -2
  177. package/src/engine/graphics/render/forward_plus/debug/createScreenGrid.js +1 -1
  178. package/src/engine/graphics/render/view/CameraView.js +1 -1
  179. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -2
  180. package/src/engine/graphics/texture/atlas/AtlasPatch.js +2 -2
  181. package/src/engine/graphics/texture/atlas/TextureAtlas.spec.js +2 -2
  182. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  183. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +1 -1
  184. package/src/engine/graphics/util/makeMeshPreviewScene.js +1 -1
  185. package/src/engine/graphics/util/renderObjectToSampler2D.js +1 -1
  186. package/src/engine/intelligence/behavior/Behavior.spec.js +15 -0
  187. package/src/engine/intelligence/mcts/MoveEdge.js +1 -1
  188. package/src/engine/reference/v1/ReferenceManager.js +3 -0
  189. package/src/engine/reference/v2/Reference.js +33 -37
  190. package/src/engine/sound/sopra/README.md +6 -0
  191. package/src/engine/ui/tiles2d/computeTileGridMove.js +3 -2
  192. package/src/engine/ui/tiles2d/computeTileGridMove.spec.js +1 -1
  193. package/src/generation/automata/CaveGeneratorCellularAutomata.js +10 -7
  194. package/src/generation/automata/CaveGeneratorCellularAutomata.spec.js +12 -0
  195. package/src/generation/automata/CellularAutomata.js +5 -4
  196. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +25 -9
  197. package/src/generation/theme/AreaMask.js +1 -1
  198. package/src/view/View.js +1 -1
  199. package/src/view/elements/progress/RectangularPieProgressView.js +1 -1
  200. package/src/view/minimap/Minimap.js +1 -1
  201. package/src/view/minimap/dom/MinimapCameraView.js +1 -1
  202. package/src/view/minimap/gl/MinimapFogOfWar.js +1 -1
  203. package/src/view/tooltip/DomTooltipObserver.js +1 -1
  204. package/src/view/tooltip/TooltipManager.js +1 -1
  205. package/src/view/tooltip/TooltipView.js +1 -1
  206. package/src/view/util/DomSizeObserver.js +2 -2
  207. package/src/core/geom/2d/AABB2Math.js +0 -40
  208. package/src/core/geom/2d/AABB2Math.spec.js +0 -17
  209. package/src/core/geom/Plane.js +0 -250
  210. package/src/core/land/reactive/ReactiveLexer.js +0 -158
  211. package/src/core/land/reactive/ReactiveLexer.ts +0 -181
  212. package/src/core/land/reactive/ReactiveListener.ts +0 -323
  213. package/src/core/land/reactive/ReactiveParser.js +0 -1573
  214. package/src/core/land/reactive/ReactiveParser.ts +0 -1776
  215. package/src/core/land/reactive/ReactiveVisitor.js +0 -1
  216. package/src/core/land/reactive/ReactiveVisitor.ts +0 -218
  217. package/src/core/land/reactive/compiler/ReactiveCompiler.js +0 -350
  218. package/src/core/land/reactive/compiler/ReactiveNearlyCompiler.js +0 -166
  219. package/src/core/land/reactive/compiler/ReactiveParser.js +0 -34
  220. package/src/core/land/reactive/nearley/ReactiveNearley.js +0 -187
  221. /package/src/core/geom/{LineSegment2.js → 2d/LineSegment2.js} +0 -0
  222. /package/src/core/geom/{Rectangle.spec.js → 2d/Rectangle.spec.js} +0 -0
  223. /package/src/core/geom/{AABB2.d.ts → 2d/aabb/AABB2.d.ts} +0 -0
  224. /package/src/core/geom/{AABB2.spec.js → 2d/aabb/AABB2.spec.js} +0 -0
  225. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3.js +0 -0
  226. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Encoded_v0.js +0 -0
  227. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Quantized16Uint.js +0 -0
  228. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3.js +0 -0
  229. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Quantized16Uint.js +0 -0
  230. /package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/vector}/allocate_v3.js +0 -0
@@ -1,166 +0,0 @@
1
- import { ReactiveAdd } from "../../../model/reactive/model/arithmetic/ReactiveAdd.js";
2
- import { ReactiveDivide } from "../../../model/reactive/model/arithmetic/ReactiveDivide.js";
3
- import { ReactiveMultiply } from "../../../model/reactive/model/arithmetic/ReactiveMultiply.js";
4
- import { ReactiveNegate } from "../../../model/reactive/model/arithmetic/ReactiveNegate.js";
5
- import { ReactiveSubtract } from "../../../model/reactive/model/arithmetic/ReactiveSubtract.js";
6
- import { ReactiveEquals } from "../../../model/reactive/model/comparative/ReactiveEquals.js";
7
- import { ReactiveGreaterThan } from "../../../model/reactive/model/comparative/ReactiveGreaterThan.js";
8
- import { ReactiveGreaterThanOrEqual } from "../../../model/reactive/model/comparative/ReactiveGreaterThanOrEqual.js";
9
- import { ReactiveLessThan } from "../../../model/reactive/model/comparative/ReactiveLessThan.js";
10
- import { ReactiveLessThanOrEqual } from "../../../model/reactive/model/comparative/ReactiveLessThanOrEqual.js";
11
- import { ReactiveNotEquals } from "../../../model/reactive/model/comparative/ReactiveNotEquals.js";
12
- import { ReactiveAnd } from "../../../model/reactive/model/logic/ReactiveAnd.js";
13
- import { ReactiveNot } from "../../../model/reactive/model/logic/ReactiveNot.js";
14
- import { ReactiveOr } from "../../../model/reactive/model/logic/ReactiveOr.js";
15
- import { ReactiveLiteralBoolean } from "../../../model/reactive/model/terminal/ReactiveLiteralBoolean.js";
16
- import { ReactiveLiteralNumber } from "../../../model/reactive/model/terminal/ReactiveLiteralNumber.js";
17
- import { ReactiveLiteralString } from "../../../model/reactive/model/terminal/ReactiveLiteralString.js";
18
- import { ReactiveReference } from "../../../model/reactive/model/terminal/ReactiveReference.js";
19
-
20
- const compilers = {
21
- Reference: ({ value }) => new ReactiveReference(value.join('.')),
22
- LiteralNumber: ({ value }) => new ReactiveLiteralNumber(value),
23
- LiteralBoolean: ({ value }) => new ReactiveLiteralBoolean(value),
24
- LiteralString: ({ value }) => new ReactiveLiteralString(value),
25
- BinaryAdd: ({ left, right }) => {
26
- const result = new ReactiveAdd();
27
-
28
- compileBinaryExpression(result, left, right);
29
-
30
- return result;
31
- },
32
- BinarySubtract: ({ left, right }) => {
33
- const result = new ReactiveSubtract();
34
-
35
- compileBinaryExpression(result, left, right);
36
-
37
- return result;
38
- },
39
- BinaryMultiply: ({ left, right }) => {
40
- const result = new ReactiveMultiply();
41
-
42
- compileBinaryExpression(result, left, right);
43
-
44
- return result;
45
- },
46
- BinaryDivide: ({ left, right }) => {
47
- const result = new ReactiveDivide();
48
-
49
- compileBinaryExpression(result, left, right);
50
-
51
- return result;
52
- },
53
- BinaryGreater: ({ left, right }) => {
54
- const result = new ReactiveGreaterThan();
55
-
56
- compileBinaryExpression(result, left, right);
57
-
58
- return result;
59
- },
60
- BinaryGreaterOrEqual: ({ left, right }) => {
61
- const result = new ReactiveGreaterThanOrEqual();
62
-
63
- compileBinaryExpression(result, left, right);
64
-
65
- return result;
66
- },
67
- BinaryLess: ({ left, right }) => {
68
- const result = new ReactiveLessThan();
69
-
70
- compileBinaryExpression(result, left, right);
71
-
72
- return result;
73
- },
74
- BinaryLessOrEqual: ({ left, right }) => {
75
- const result = new ReactiveLessThanOrEqual();
76
-
77
- compileBinaryExpression(result, left, right);
78
-
79
- return result;
80
- },
81
- BinaryEqual: ({ left, right }) => {
82
- const result = new ReactiveEquals();
83
-
84
- compileBinaryExpression(result, left, right);
85
-
86
- return result;
87
- },
88
- BinaryNotEqual: ({ left, right }) => {
89
- const result = new ReactiveNotEquals();
90
-
91
- compileBinaryExpression(result, left, right);
92
-
93
- return result;
94
- },
95
- BinaryAnd: ({ left, right }) => {
96
- const result = new ReactiveAnd();
97
-
98
- compileBinaryExpression(result, left, right);
99
-
100
- return result;
101
- },
102
- BinaryOr: ({ left, right }) => {
103
- const result = new ReactiveOr();
104
-
105
- compileBinaryExpression(result, left, right);
106
-
107
- return result;
108
- },
109
- UnaryNot: ({ value }) => {
110
- const result = new ReactiveNot();
111
-
112
- compileUnaryExpression(result, value);
113
-
114
- return result;
115
- },
116
- UnaryNegate: ({ value }) => {
117
- const result = new ReactiveNegate();
118
-
119
- compileUnaryExpression(result, value);
120
-
121
- return result;
122
- },
123
- };
124
-
125
- /**
126
- *
127
- * @param {ReactiveBinaryExpression} result
128
- * @param left
129
- * @param right
130
- */
131
- function compileBinaryExpression(result, left, right) {
132
- const lExp = compileReactiveExpressionNearly(left);
133
- const rExp = compileReactiveExpressionNearly(right);
134
-
135
- result.connect(lExp, rExp);
136
- }
137
-
138
- /**
139
- *
140
- * @param {ReactiveUnaryExpression} result
141
- * @param value
142
- */
143
- function compileUnaryExpression(result, value) {
144
- const exp = compileReactiveExpressionNearly(value);
145
-
146
- result.connect(exp);
147
- }
148
-
149
- /**
150
- *
151
- * @param node
152
- * @return {ReactiveExpression}
153
- */
154
- export function compileReactiveExpressionNearly(node) {
155
- const type = node.type;
156
-
157
- const compiler = compilers[type];
158
-
159
- if (compiler === undefined) {
160
- throw new Error(`Unsupported node type '${type}'`);
161
- }
162
-
163
- return compiler(node);
164
- }
165
-
166
-
@@ -1,34 +0,0 @@
1
- import nearley from "nearley";
2
- import { AbstractCachingParser } from "../AbstractCachingParser.js";
3
- import grammar from "../nearley/ReactiveNearley.js";
4
-
5
- const rules = nearley.Grammar.fromCompiled(grammar);
6
-
7
- export class ReactiveParser extends AbstractCachingParser {
8
-
9
- /**
10
- *
11
- * @param {string} code
12
- * @returns {*}
13
- */
14
- __invoke_parser(code) {
15
- const parser = new nearley.Parser(rules);
16
-
17
- parser.feed(code);
18
-
19
- const results = parser.results;
20
-
21
- if (results.length > 1) {
22
- console.warn(`Multiple parses of '${code}'`, results);
23
- }
24
-
25
- return results[0];
26
-
27
- }
28
- }
29
-
30
- /**
31
- * @readonly
32
- * @type {ReactiveParser}
33
- */
34
- ReactiveParser.INSTANCE = new ReactiveParser();
@@ -1,187 +0,0 @@
1
- // Generated automatically by nearley, version 2.16.0
2
- // http://github.com/Hardmath123/nearley
3
- (function () {
4
- function id(x) { return x[0]; }
5
- var grammar = {
6
- Lexer: undefined,
7
- ParserRules: [
8
- {"name": "_$ebnf$1", "symbols": []},
9
- {"name": "_$ebnf$1", "symbols": ["_$ebnf$1", "wschar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
10
- {"name": "_", "symbols": ["_$ebnf$1"], "postprocess": function(d) {return null;}},
11
- {"name": "__$ebnf$1", "symbols": ["wschar"]},
12
- {"name": "__$ebnf$1", "symbols": ["__$ebnf$1", "wschar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
13
- {"name": "__", "symbols": ["__$ebnf$1"], "postprocess": function(d) {return null;}},
14
- {"name": "wschar", "symbols": [/[ \t\n\v\f]/], "postprocess": id},
15
- {"name": "unsigned_int$ebnf$1", "symbols": [/[0-9]/]},
16
- {"name": "unsigned_int$ebnf$1", "symbols": ["unsigned_int$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
17
- {"name": "unsigned_int", "symbols": ["unsigned_int$ebnf$1"], "postprocess":
18
- function(d) {
19
- return parseInt(d[0].join(""));
20
- }
21
- },
22
- {"name": "int$ebnf$1$subexpression$1", "symbols": [{"literal":"-"}]},
23
- {"name": "int$ebnf$1$subexpression$1", "symbols": [{"literal":"+"}]},
24
- {"name": "int$ebnf$1", "symbols": ["int$ebnf$1$subexpression$1"], "postprocess": id},
25
- {"name": "int$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
26
- {"name": "int$ebnf$2", "symbols": [/[0-9]/]},
27
- {"name": "int$ebnf$2", "symbols": ["int$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
28
- {"name": "int", "symbols": ["int$ebnf$1", "int$ebnf$2"], "postprocess":
29
- function(d) {
30
- if (d[0]) {
31
- return parseInt(d[0][0]+d[1].join(""));
32
- } else {
33
- return parseInt(d[1].join(""));
34
- }
35
- }
36
- },
37
- {"name": "unsigned_decimal$ebnf$1", "symbols": [/[0-9]/]},
38
- {"name": "unsigned_decimal$ebnf$1", "symbols": ["unsigned_decimal$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
39
- {"name": "unsigned_decimal$ebnf$2$subexpression$1$ebnf$1", "symbols": [/[0-9]/]},
40
- {"name": "unsigned_decimal$ebnf$2$subexpression$1$ebnf$1", "symbols": ["unsigned_decimal$ebnf$2$subexpression$1$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
41
- {"name": "unsigned_decimal$ebnf$2$subexpression$1", "symbols": [{"literal":"."}, "unsigned_decimal$ebnf$2$subexpression$1$ebnf$1"]},
42
- {"name": "unsigned_decimal$ebnf$2", "symbols": ["unsigned_decimal$ebnf$2$subexpression$1"], "postprocess": id},
43
- {"name": "unsigned_decimal$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
44
- {"name": "unsigned_decimal", "symbols": ["unsigned_decimal$ebnf$1", "unsigned_decimal$ebnf$2"], "postprocess":
45
- function(d) {
46
- return parseFloat(
47
- d[0].join("") +
48
- (d[1] ? "."+d[1][1].join("") : "")
49
- );
50
- }
51
- },
52
- {"name": "decimal$ebnf$1", "symbols": [{"literal":"-"}], "postprocess": id},
53
- {"name": "decimal$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
54
- {"name": "decimal$ebnf$2", "symbols": [/[0-9]/]},
55
- {"name": "decimal$ebnf$2", "symbols": ["decimal$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
56
- {"name": "decimal$ebnf$3$subexpression$1$ebnf$1", "symbols": [/[0-9]/]},
57
- {"name": "decimal$ebnf$3$subexpression$1$ebnf$1", "symbols": ["decimal$ebnf$3$subexpression$1$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
58
- {"name": "decimal$ebnf$3$subexpression$1", "symbols": [{"literal":"."}, "decimal$ebnf$3$subexpression$1$ebnf$1"]},
59
- {"name": "decimal$ebnf$3", "symbols": ["decimal$ebnf$3$subexpression$1"], "postprocess": id},
60
- {"name": "decimal$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
61
- {"name": "decimal", "symbols": ["decimal$ebnf$1", "decimal$ebnf$2", "decimal$ebnf$3"], "postprocess":
62
- function(d) {
63
- return parseFloat(
64
- (d[0] || "") +
65
- d[1].join("") +
66
- (d[2] ? "."+d[2][1].join("") : "")
67
- );
68
- }
69
- },
70
- {"name": "percentage", "symbols": ["decimal", {"literal":"%"}], "postprocess":
71
- function(d) {
72
- return d[0]/100;
73
- }
74
- },
75
- {"name": "jsonfloat$ebnf$1", "symbols": [{"literal":"-"}], "postprocess": id},
76
- {"name": "jsonfloat$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
77
- {"name": "jsonfloat$ebnf$2", "symbols": [/[0-9]/]},
78
- {"name": "jsonfloat$ebnf$2", "symbols": ["jsonfloat$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
79
- {"name": "jsonfloat$ebnf$3$subexpression$1$ebnf$1", "symbols": [/[0-9]/]},
80
- {"name": "jsonfloat$ebnf$3$subexpression$1$ebnf$1", "symbols": ["jsonfloat$ebnf$3$subexpression$1$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
81
- {"name": "jsonfloat$ebnf$3$subexpression$1", "symbols": [{"literal":"."}, "jsonfloat$ebnf$3$subexpression$1$ebnf$1"]},
82
- {"name": "jsonfloat$ebnf$3", "symbols": ["jsonfloat$ebnf$3$subexpression$1"], "postprocess": id},
83
- {"name": "jsonfloat$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
84
- {"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$1", "symbols": [/[+-]/], "postprocess": id},
85
- {"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
86
- {"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$2", "symbols": [/[0-9]/]},
87
- {"name": "jsonfloat$ebnf$4$subexpression$1$ebnf$2", "symbols": ["jsonfloat$ebnf$4$subexpression$1$ebnf$2", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
88
- {"name": "jsonfloat$ebnf$4$subexpression$1", "symbols": [/[eE]/, "jsonfloat$ebnf$4$subexpression$1$ebnf$1", "jsonfloat$ebnf$4$subexpression$1$ebnf$2"]},
89
- {"name": "jsonfloat$ebnf$4", "symbols": ["jsonfloat$ebnf$4$subexpression$1"], "postprocess": id},
90
- {"name": "jsonfloat$ebnf$4", "symbols": [], "postprocess": function(d) {return null;}},
91
- {"name": "jsonfloat", "symbols": ["jsonfloat$ebnf$1", "jsonfloat$ebnf$2", "jsonfloat$ebnf$3", "jsonfloat$ebnf$4"], "postprocess":
92
- function(d) {
93
- return parseFloat(
94
- (d[0] || "") +
95
- d[1].join("") +
96
- (d[2] ? "."+d[2][1].join("") : "") +
97
- (d[3] ? "e" + (d[3][1] || "+") + d[3][2].join("") : "")
98
- );
99
- }
100
- },
101
- {"name": "dqstring$ebnf$1", "symbols": []},
102
- {"name": "dqstring$ebnf$1", "symbols": ["dqstring$ebnf$1", "dstrchar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
103
- {"name": "dqstring", "symbols": [{"literal":"\""}, "dqstring$ebnf$1", {"literal":"\""}], "postprocess": function(d) {return d[1].join(""); }},
104
- {"name": "sqstring$ebnf$1", "symbols": []},
105
- {"name": "sqstring$ebnf$1", "symbols": ["sqstring$ebnf$1", "sstrchar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
106
- {"name": "sqstring", "symbols": [{"literal":"'"}, "sqstring$ebnf$1", {"literal":"'"}], "postprocess": function(d) {return d[1].join(""); }},
107
- {"name": "btstring$ebnf$1", "symbols": []},
108
- {"name": "btstring$ebnf$1", "symbols": ["btstring$ebnf$1", /[^`]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
109
- {"name": "btstring", "symbols": [{"literal":"`"}, "btstring$ebnf$1", {"literal":"`"}], "postprocess": function(d) {return d[1].join(""); }},
110
- {"name": "dstrchar", "symbols": [/[^\\"\n]/], "postprocess": id},
111
- {"name": "dstrchar", "symbols": [{"literal":"\\"}, "strescape"], "postprocess":
112
- function(d) {
113
- return JSON.parse("\""+d.join("")+"\"");
114
- }
115
- },
116
- {"name": "sstrchar", "symbols": [/[^\\'\n]/], "postprocess": id},
117
- {"name": "sstrchar", "symbols": [{"literal":"\\"}, "strescape"], "postprocess": function(d) { return JSON.parse("\""+d.join("")+"\""); }},
118
- {"name": "sstrchar$string$1", "symbols": [{"literal":"\\"}, {"literal":"'"}], "postprocess": function joiner(d) {return d.join('');}},
119
- {"name": "sstrchar", "symbols": ["sstrchar$string$1"], "postprocess": function(d) {return "'"; }},
120
- {"name": "strescape", "symbols": [/["\\/bfnrt]/], "postprocess": id},
121
- {"name": "strescape", "symbols": [{"literal":"u"}, /[a-fA-F0-9]/, /[a-fA-F0-9]/, /[a-fA-F0-9]/, /[a-fA-F0-9]/], "postprocess":
122
- function(d) {
123
- return d.join("");
124
- }
125
- },
126
- {"name": "expression", "symbols": ["binary_expression_add"], "postprocess": id},
127
- {"name": "group_expression", "symbols": [{"literal":"("}, "_", "expression", "_", {"literal":")"}], "postprocess": (a) => a[2]},
128
- {"name": "group_expression", "symbols": ["atomic"], "postprocess": id},
129
- {"name": "unary_expression_negate", "symbols": [{"literal":"-"}, "_", "expression"], "postprocess": (d)=> {return {type:'UnaryNegate', value: d[2]}}},
130
- {"name": "unary_expression_negate", "symbols": ["group_expression"], "postprocess": id},
131
- {"name": "unary_expression_not", "symbols": [{"literal":"!"}, "_", "expression"], "postprocess": (d)=> {return {type:'UnaryNot', value: d[2]}}},
132
- {"name": "unary_expression_not", "symbols": ["unary_expression_negate"], "postprocess": id},
133
- {"name": "binary_expression_or$string$1", "symbols": [{"literal":"|"}, {"literal":"|"}], "postprocess": function joiner(d) {return d.join('');}},
134
- {"name": "binary_expression_or", "symbols": ["binary_expression_or", "_", "binary_expression_or$string$1", "_", "unary_expression_not"], "postprocess": (d)=> {return {type:'BinaryOr', left: d[0], right: d[4]}}},
135
- {"name": "binary_expression_or", "symbols": ["unary_expression_not"], "postprocess": id},
136
- {"name": "binary_expression_and$string$1", "symbols": [{"literal":"&"}, {"literal":"&"}], "postprocess": function joiner(d) {return d.join('');}},
137
- {"name": "binary_expression_and", "symbols": ["binary_expression_and", "_", "binary_expression_and$string$1", "_", "binary_expression_or"], "postprocess": (d)=> {return {type:'BinaryAnd', left: d[0], right: d[4]}}},
138
- {"name": "binary_expression_and", "symbols": ["binary_expression_or"], "postprocess": id},
139
- {"name": "binary_expression_equals$string$1", "symbols": [{"literal":"="}, {"literal":"="}], "postprocess": function joiner(d) {return d.join('');}},
140
- {"name": "binary_expression_equals", "symbols": ["binary_expression_equals", "_", "binary_expression_equals$string$1", "_", "binary_expression_and"], "postprocess": (d)=> {return {type:'BinaryEqual', left: d[0], right: d[4]}}},
141
- {"name": "binary_expression_equals", "symbols": ["binary_expression_and"], "postprocess": id},
142
- {"name": "binary_expression_not_equals$string$1", "symbols": [{"literal":"!"}, {"literal":"="}], "postprocess": function joiner(d) {return d.join('');}},
143
- {"name": "binary_expression_not_equals", "symbols": ["binary_expression_not_equals", "_", "binary_expression_not_equals$string$1", "_", "binary_expression_equals"], "postprocess": (d)=> {return {type:'BinaryNotEqual', left: d[0], right: d[4]}}},
144
- {"name": "binary_expression_not_equals", "symbols": ["binary_expression_equals"], "postprocess": id},
145
- {"name": "binary_expression_lte$string$1", "symbols": [{"literal":"<"}, {"literal":"="}], "postprocess": function joiner(d) {return d.join('');}},
146
- {"name": "binary_expression_lte", "symbols": ["binary_expression_lte", "_", "binary_expression_lte$string$1", "_", "binary_expression_not_equals"], "postprocess": (d)=> {return {type:'BinaryLessOrEqual', left: d[0], right: d[4]}}},
147
- {"name": "binary_expression_lte", "symbols": ["binary_expression_not_equals"], "postprocess": id},
148
- {"name": "binary_expression_gte$string$1", "symbols": [{"literal":">"}, {"literal":"="}], "postprocess": function joiner(d) {return d.join('');}},
149
- {"name": "binary_expression_gte", "symbols": ["binary_expression_gte", "_", "binary_expression_gte$string$1", "_", "binary_expression_lte"], "postprocess": (d)=> {return {type:'BinaryGreaterOrEqual', left: d[0], right: d[4]}}},
150
- {"name": "binary_expression_gte", "symbols": ["binary_expression_lte"], "postprocess": id},
151
- {"name": "binary_expression_lt", "symbols": ["binary_expression_lt", "_", {"literal":"<"}, "_", "binary_expression_gte"], "postprocess": (d)=> {return {type:'BinaryLess', left: d[0], right: d[4]}}},
152
- {"name": "binary_expression_lt", "symbols": ["binary_expression_gte"], "postprocess": id},
153
- {"name": "binary_expression_gt", "symbols": ["binary_expression_gt", "_", {"literal":">"}, "_", "binary_expression_lt"], "postprocess": (d)=> {return {type:'BinaryGreater', left: d[0], right: d[4]}}},
154
- {"name": "binary_expression_gt", "symbols": ["binary_expression_lt"], "postprocess": id},
155
- {"name": "binary_expression_multiply", "symbols": ["binary_expression_multiply", "_", {"literal":"*"}, "_", "binary_expression_gt"], "postprocess": (d)=> {return {type:'BinaryMultiply', left: d[0], right: d[4]}}},
156
- {"name": "binary_expression_multiply", "symbols": ["binary_expression_gt"], "postprocess": id},
157
- {"name": "binary_expression_divide", "symbols": ["binary_expression_divide", "_", {"literal":"/"}, "_", "binary_expression_multiply"], "postprocess": (d)=> {return {type:'BinaryDivide', left: d[0], right: d[4]}}},
158
- {"name": "binary_expression_divide", "symbols": ["binary_expression_multiply"], "postprocess": id},
159
- {"name": "binary_expression_subtract", "symbols": ["binary_expression_subtract", "_", {"literal":"-"}, "_", "binary_expression_divide"], "postprocess": (d)=> {return {type:'BinarySubtract', left: d[0], right: d[4]}}},
160
- {"name": "binary_expression_subtract", "symbols": ["binary_expression_divide"], "postprocess": id},
161
- {"name": "binary_expression_add", "symbols": ["binary_expression_add", "_", {"literal":"+"}, "_", "binary_expression_subtract"], "postprocess": (d)=> {return {type:'BinaryAdd', left: d[0], right: d[4]}}},
162
- {"name": "binary_expression_add", "symbols": ["binary_expression_subtract"], "postprocess": id},
163
- {"name": "atomic", "symbols": ["literal"], "postprocess": id},
164
- {"name": "atomic", "symbols": ["reference"], "postprocess": (d,l,r)=> { return {type:'Reference', value: d[0] } }},
165
- {"name": "reference$ebnf$1", "symbols": []},
166
- {"name": "reference$ebnf$1$subexpression$1", "symbols": [{"literal":"."}, "identifier"], "postprocess": (a)=>a[1]},
167
- {"name": "reference$ebnf$1", "symbols": ["reference$ebnf$1", "reference$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
168
- {"name": "reference", "symbols": ["identifier", "reference$ebnf$1"], "postprocess": (a,l,r) => [a[0]].concat(a[1])},
169
- {"name": "identifier$ebnf$1", "symbols": []},
170
- {"name": "identifier$ebnf$1", "symbols": ["identifier$ebnf$1", /[a-zA-Z_0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
171
- {"name": "identifier", "symbols": [/[a-zA-Z_]/, "identifier$ebnf$1"], "postprocess": (d,l,r) => { const value =d[0]+d[1].join(""); if(value === 'true' || value === 'false'){return r}else{return value} }},
172
- {"name": "literal", "symbols": ["decimal"], "postprocess": (d)=> {return {type:'LiteralNumber', value: d[0] }}},
173
- {"name": "literal", "symbols": ["literal_boolean"], "postprocess": (d) => { return {type:'LiteralBoolean', value:d[0]} }},
174
- {"name": "literal", "symbols": ["sqstring"], "postprocess": (d) => {return {type: 'LiteralString', value: d[0] }}},
175
- {"name": "literal_boolean$string$1", "symbols": [{"literal":"t"}, {"literal":"r"}, {"literal":"u"}, {"literal":"e"}], "postprocess": function joiner(d) {return d.join('');}},
176
- {"name": "literal_boolean", "symbols": ["literal_boolean$string$1"], "postprocess": ()=> true},
177
- {"name": "literal_boolean$string$2", "symbols": [{"literal":"f"}, {"literal":"a"}, {"literal":"l"}, {"literal":"s"}, {"literal":"e"}], "postprocess": function joiner(d) {return d.join('');}},
178
- {"name": "literal_boolean", "symbols": ["literal_boolean$string$2"], "postprocess": ()=> false}
179
- ]
180
- , ParserStart: "expression"
181
- }
182
- if (typeof module !== 'undefined'&& typeof module.exports !== 'undefined') {
183
- module.exports = grammar;
184
- } else {
185
- window.grammar = grammar;
186
- }
187
- })();