Skip to content

Dispatchable init action#1648

Merged
jumpinjackie merged 3 commits into
masterfrom
feature/dispatchable-init-action
May 18, 2026
Merged

Dispatchable init action#1648
jumpinjackie merged 3 commits into
masterfrom
feature/dispatchable-init-action

Conversation

@jumpinjackie
Copy link
Copy Markdown
Owner

@jumpinjackie jumpinjackie commented May 18, 2026

This pull request refactors the viewer initialization logic for MapGuide React Layout, dissolving the DefaultViewerInitCommand class and replacing it with a set of module-level free functions. This change simplifies the codebase, eliminates unnecessary class structure and circular dependencies, and clarifies the separation of responsibilities in the initialization process. The documentation is updated to reflect these architectural changes, and several utility and initialization functions are now exported directly for reuse.

Codebase Simplification and Refactoring

  • Removed the DefaultViewerInitCommand class and its abstract base, along with related interfaces, in favor of free functions for the init payload stage (src/actions/init-command.ts, src/actions/init-mapguide.ts). [1] [2] [3]
  • Refactored viewer initialization logic into standalone functions such as isArbitraryCoordSys, establishInitialMapNameAndSession, initLocaleAsync, and initFromAppDefCoreAsync, making dependencies explicit and removing vestigial extension points. [1] [2] [3] [4]

Documentation and Guidance Updates

  • Added an ADR documenting the rationale and outcome of dissolving DefaultViewerInitCommand, including rejected alternatives and the resulting architectural improvements (docs/adr/0001-dissolve-default-viewer-init-command.md).
  • Updated .github/copilot-instructions.md to clarify import practices, especially prohibiting await import(...) inside functions, and to reinforce static import usage.
  • Added a new context document (CONTEXT.md) describing the terminology and relationships in the viewer initialization flow, clarifying ambiguous terms and documenting the new functional structure.

Export and Utility Function Improvements

  • Promoted several utility functions (e.g., getExtraProjectionsFromFlexLayout, parseSwipePairs) to be exported directly for use in the new functional initialization pipeline. [1] [2]

These changes collectively modernize the initialization architecture, improve maintainability, and provide clearer documentation for future development.

Fixes #1335

- Replaced the `initLayout` command with `fetchInitDocument` and `initAppFromDocument` in the App component.
- Updated the `IInitAppLayout` interface to accommodate `WebLayout` alongside `ApplicationDefinition`.
- Enhanced error handling by exporting `processAndDispatchInitError`.
- Removed the `IViewerInitCommand` dependency from various components and tests.
- Adjusted tests to reflect changes in initialization logic and ensure proper mocking of new functions.
- Cleaned up imports and unused code related to the old initialization command.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Bundle Size Report ✅ PASS

Metric Size Gzip Brotli
Total 10.20 MB 2.28 MB 1.63 MB
Diff +966.00 B 🔴 ↑ +195.00 B 🔴 ↑ +267.00 B 🔴 ↑
Change +0.01% +0.01% +0.02%

Top Changes

File Before After Diff
~ viewer.js 122.73 KB 122.88 KB +154.00 B 🔴 ↑
~ viewer-debug.js 200.83 KB 200.94 KB +113.00 B 🔴 ↑

Generated by build-size-diff Commit: 48b90a6

@coveralls
Copy link
Copy Markdown

coveralls commented May 18, 2026

Coverage Status

coverage: 60.531% (+0.9%) from 59.676% — feature/dispatchable-init-action into master

…edux state

- Implemented a new test file `init-dispatchable.spec.ts` to test the `initAppFromDocument` action.
- Created a mock client to simulate API interactions.
- Added a snapshot file `init-dispatchable.spec.ts.snap` to capture the expected redux baseline state after dispatching the action.
- Ensured the legacy app definition is correctly de-arrayified and integrated into the redux store.
@jumpinjackie jumpinjackie merged commit 7bebb6c into master May 18, 2026
5 checks passed
@jumpinjackie jumpinjackie deleted the feature/dispatchable-init-action branch May 18, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor init command to be a dispatchable init action

2 participants