Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core refactor #961

Merged
merged 44 commits into from
Jun 20, 2023
Merged

Core refactor #961

merged 44 commits into from
Jun 20, 2023

Commits on Jun 20, 2023

  1. Eliminate global locationManager and prefs (now storageManager)

    Trying to get to a place where all objects are just owned by context.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    4938075 View commit details
    Browse the repository at this point in the history
  2. Rename "WhateverManager" -> "WhateverSystem"

    PixiJS uses this "system" naming convention so we will too
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    eaf9f76 View commit details
    Browse the repository at this point in the history
  3. Eliminate global presetManager (now presetSystem)

    Trying to get to a place where all objects are just owned by context.
    
    This includes quite a lot of changes to the preset/field system:
    - All the preset related components are ES6 classes now
    - Stuff moved from modules/presets -> modules/core
    - Generally, tried to simplify the code as much as possible and avoid "magic"
    - Lots of changes around Collection, now it just contains an `array` property,
      no more pretending Collections is an Array or PresetIndex is a Collection
    - Some things that were functions before (setAddablePresetIDs) are just properties now
    - uiField -> UiField is now an ES6 class too
    - Most of the fields have been rewritten for ES6, many revisions and updates
    - The old way of converting a field -> presetfield -> uifield was pretty
      complicated, now I try to explicitly copy over properties from one
      component to another and call out places where a class property gets
      replaced by a class function
    
    Also fixed an unrelated bug in uiIcon / disclosure that was causing the hide/show
    toggle icons to not appear (because I removed third argument to UiIcon in 05f2f34)
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    5c3d62d View commit details
    Browse the repository at this point in the history
  4. WIP on modernizing services next

    All will move to ES6 classes that have reference back to context
    and follow predictable setup and initialization flow.
    No more magic contextless globals.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    c97dc2c View commit details
    Browse the repository at this point in the history
  5. WIP on modernizing services - Taginfo, Osmose, Nominatim

    Also removing maprules - I dont think anyone uses it anymore.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    009e96f View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    78eadc8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    0b7ec86 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    f3a8913 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    83f9824 View commit details
    Browse the repository at this point in the history
  10. WIP on modernizing services - NSI

    Fixed the missing links to the preset and location systems
    now that NSI service has a reference back to context
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    3bfa47f View commit details
    Browse the repository at this point in the history
  11. WIP on modernizing services - Mapillary, Kartaview, Streetside

    Still need to fix the show/hide viewer code
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    06cd5b6 View commit details
    Browse the repository at this point in the history
  12. WIP on modernizing services - ServiceOsm

    This is all of them!  Still need to restore some tests
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    fbf9253 View commit details
    Browse the repository at this point in the history
  13. Improve use of this, avoid hacks like thiz/that

    Mostly this is just using fat arrow functions to preserve `this`
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    d29721f View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    96a3108 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    1f6047a View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    7972b04 View commit details
    Browse the repository at this point in the history
  17. pacify eslint

    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    3d79049 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    e89ac19 View commit details
    Browse the repository at this point in the history
  19. urlhash -> urlHashSystem

    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    5031e22 View commit details
    Browse the repository at this point in the history
  20. rendererPhotos -> photoSystem

    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    e5a9eab View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    01ae920 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    82bcb63 View commit details
    Browse the repository at this point in the history
  23. fileFetcher -> DataLoaderSystem

    Rapid does work, but now the tests are a mess.
    
    This is because the interactions between the localizer and everything else get
    complicated, as creating a context will start loading data and the fileFetcher
    isn't global anymore.  The tests did have a lot of code in spec_helpers to
    prevent files from being fetched, that doesn't work now.
    
    This can start getting easier after we change the localizer similarly.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    8243099 View commit details
    Browse the repository at this point in the history
  24. localizer -> LocalizationSystem

    This is a big change:
    - Eliminated the global `localizer` and `t()` functions
    - Added `context.t()` and `context.tHtml()` convenience functions
    - Some util functions relied on the global `t()` for localization
      (e.g. utilDisplayName, etc) these are moved into the LocalizationSystem now
    - Some more things need context now to avoid using the global `t()`
      - `ImagerySource` now passed a context
      - `ActionMergeRemoteChanges` rewritten to take an options param with the localizer
      - several more UI classes take context now
      - Reordered some arglists (e.g. for uiPane), context should always be the first one
    - Lots of changes to the tests.  They were loading the general en locale
      strings before and they should not do this.
    - Still some more work to do on tests to be better at mocking context
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    ff26364 View commit details
    Browse the repository at this point in the history
  25. Fix many tests

    - Restored the service tests that I didn't do before
      (Osm, Kartaview, Mapillary, Streetside)
    - Fixed the other service tests that were failing because of missing fetch mock resets
    - Removed the sticky fetch mock routes (they were only needed by serviceosm capabilities test)
    - Also went through and simplified a bunch of the validator tests
      - We don't need to create a full context for these
      - We don't need to run them async to wait for data to load
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    6d48e47 View commit details
    Browse the repository at this point in the history
  26. Make ValidationIssue and ValidationFix ES6 classes

    This commit also moves a bunch of stuff from /core -> /core/lib for organization
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    76a3ac9 View commit details
    Browse the repository at this point in the history
  27. RendererMap -> MapSystem, 3dMap -> Map3dSystem

    I also got the old RendererMap tests working again.
    These were skipped, but they can work now with some substantial mocking.
    Mostly because MapSystem listens to events emitted by many other things.
    
    It might make more sense to avoid these listeners and instead have the other
    systems tell them map to redraw as needed. We have map.deferredRedraw() now
    so this can be done in a less intrusive way.
    
    Also, we still have to sort out initialization of the map a bit better, but
    we're getting there.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    6f08290 View commit details
    Browse the repository at this point in the history
  28. Rely less on event dispatching to trigger deferred rendering

    Following up on an idea from 1d5e617,
    Just call `mapSystem.deferredRedraw()` or `mapSystem.immediateRedraw()`
    instead of listening to events from various places.  This much simplifies the
    various Pixi layers that were registering listeners on the service objects.
    It also makes mocking mapSystem a little easier.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    69d29ed View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    c8b082c View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    b3a9dc0 View commit details
    Browse the repository at this point in the history
  31. WIP: Modernize and ES6ify coreHistory -> EditSystem

    This is a big change but will make the code easier to work with.
    Some linger issues:
    - Switching from d3_dispatch to EventEmitter means we have to change some of
      the listeners in the walkthrough
    - Some of the listeners seem to be firing too much
    - `reset` used to be used for both resetting but also returning to a
      saved checkpoint.  I split these into two functions.
    - It used to dispatch a 'reset' event that was only used by the validator.
      The validator also has 2 resets, one that resets everything and one that
      preserves the user's ignored issues.  This is also something we can clean up.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    858ec00 View commit details
    Browse the repository at this point in the history
  32. Fix various event listeners d3_dispatch -> eventemitter style

    Mostly in the walkthrough
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    8f083b2 View commit details
    Browse the repository at this point in the history
  33. Moved stuff around, ditched some requestIdleCallbacks we didn't need

    - It's pointless to requestIdleCallback the osm api calls that will be async anyway
    - We're at the point where we can get rid of the distinction between
      instantiate and initialize in the `.init()` function
    
    All core classes can be instantiated earlier now and in any order, as they
    have class constructors that don't depend on each other for anything.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    8683ea1 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    f0e7897 View commit details
    Browse the repository at this point in the history
  35. uiInit -> UiSystem

    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    c18443d View commit details
    Browse the repository at this point in the history
  36. Process smaller chunks in the validation queue

    By using smaller chunks, we will block the main cpu for shorter amounts of
    time, allowing the browser to be more responsive.
    
    Eventually I'd like to move this to a worker, but we don't have a great way
    of sharing the context/graph/edits with worker processes yet.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    1138419 View commit details
    Browse the repository at this point in the history
  37. Standardize on ThingCategory, not CategoryThing

    e.g. "MoveMode" not "ModeMove"
    The former is more how we would speak about and think about the thing.
    We already have the core systems named this way (e.g. "EditSystem")
    so we may as well do it for all the things.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    e641a2f View commit details
    Browse the repository at this point in the history
  38. More consistency in the class hierarchy

    Behaviors -> AbstractBehavior -> EventEmitter
    Modes -> AbstractMode -> EventEmitter
    Services -> AbstractService -> EventEmitter
    Systems -> AbstractSystem -> EventEmitter
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    29d4458 View commit details
    Browse the repository at this point in the history
  39. Trying a more dynamic mapping for all the core components

    This would allow a custom install of Rapid to add/replace/remove
    these components before context.init() is called.  Maybe an early
    first step towards supporting plugins and other customization.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    7c9ba02 View commit details
    Browse the repository at this point in the history
  40. ES6ify coreContext -> Context

    Also replace the d3-dispatch('enter','exit') with EventEmitter and just emit 'modechange'
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    9ce00cf View commit details
    Browse the repository at this point in the history
  41. Systems should all have an id, like other classes

    I thought about making these static.
    For modes it's easier for them to be class properties than static properties.
     (i.e. we need to get `mode.id` in several places)
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    b6f1ac8 View commit details
    Browse the repository at this point in the history
  42. Replace legacy osm-only modeSelect with a more modern SelectOsmMode

    I'd still rather not have 2 select modes, but at least the modes are more
    standardized now.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    3a9e87f View commit details
    Browse the repository at this point in the history
  43. Fix all the tests

    - context, ui, validations all had a lot of work to do
      (many tests that were skipped before will now run!)
    - We avoid creating a new Context() now just to get unit tests to work
      Instead, mock out the systems that the unit tests need.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    a6821ec View commit details
    Browse the repository at this point in the history
  44. Avoid writing 'null' to the localstorage history key.

    localStorage can only store strings, so before if we passed it a null, it stored 'null'.
    Then on a restart we'd see the 'null' there and think there were changes to restrore.
    bhousel committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    6fe7e0d View commit details
    Browse the repository at this point in the history