Centralize neowiki.registration fire on ext.neowiki module load#804
Merged
JeroenDeDauw merged 3 commits intomasterfrom May 1, 2026
Merged
Centralize neowiki.registration fire on ext.neowiki module load#804JeroenDeDauw merged 3 commits intomasterfrom
JeroenDeDauw merged 3 commits intomasterfrom
Conversation
1ae224f to
a9b4a3b
Compare
Follows-up to #803 The previous setup duplicated `mw.hook( 'neowiki.registration' ).fire()` in each of the six mount-point initializers in `neowiki.ts`, plus a seventh in RedHerb's SubjectFinder init added by PR #803. Each fire constructed a fresh `FrontendRegistrar` over the same singleton registries — pure boilerplate that any new custom mount point would have to remember to replicate or risk extension property types silently failing to register. Extract a single `registerExtensions()` (mirroring the PHP `NeoWikiExtension::ensureExtensionsRegistered()`) and call it once at `ext.neowiki` module load, before the initializers. Subscribers that load before or after benefit equally thanks to `mw.hook`'s documented replay-on-late-subscribe behavior, already covered by `HookRegistration.spec.ts`. The seven redundant per-mount fires are removed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Boot is now the single point of truth for `neowiki.registration`. A regression that drops or misplaces the module-load fire would silently break every subscriber and only surface in the browser. Pin the contract with a unit test: with `neoWikiTestMode = false`, importing `@/neowiki` must fire the hook with a registrar wired to the live `NeoWikiExtension` registries — registering a fake type via the fired registrar must be observable on the singleton's `PropertyTypeRegistry` *and* `TypeSpecificComponentRegistry`. This catches a missing fire, a fully detached registrar, and a half-detached registrar (where one registry is fresh and the other live — would only surface as broken Vue rendering in the browser). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
a9b4a3b to
8f82a3b
Compare
malberts
commented
Apr 30, 2026
| ( window as unknown as { neoWikiTestMode?: boolean } ).neoWikiTestMode === true; | ||
|
|
||
| if ( !isTestEnvironment ) { | ||
| registerExtensions(); |
Collaborator
Author
There was a problem hiding this comment.
I considered matching the PHP ensureExtensionsRegistered(), but the TS does not have a guard, and this is the point where extensions get registered.
|
|
||
| function registerExtensions(): void { | ||
| const ext = NeoWikiExtension.getInstance(); | ||
| mw.hook( 'neowiki.registration' ).fire( |
Member
There was a problem hiding this comment.
regsiterExtensions? that seems not quite right. It fires a hook which extensions often register handlers for. So triggerRegistrationHooks, fireRegistrationEvent, or similar, seems better
Collaborator
Author
There was a problem hiding this comment.
I went back to the original name that literally matches what happens: fireRegistrationHook.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows-up to #803
Related to #686
The previous setup duplicated
mw.hook( 'neowiki.registration' ).fire()in each of the six mount-point initializers inneowiki.ts, plus a seventh in RedHerb's SubjectFinder init added by PR #803. Each fire constructed a freshFrontendRegistrarover the same singleton registries — pure boilerplate that any new custom mount point would have to remember to replicate or risk extension property types silently failing to register.Extract a single
fireRegistrationHook()and call it once atext.neowikimodule load, before the initializers. Subscribers that load before or after benefit equally thanks tomw.hook's documented replay-on-late-subscribe behavior, already covered byHookRegistration.spec.ts. The seven redundant per-mount fires are removed.A new boot-time test asserts that loading
@/neowikifires the hook with a registrar wired to the liveNeoWikiExtensionregistries — registering a fake type via the fired registrar must be observable on the singleton'sPropertyTypeRegistryandTypeSpecificComponentRegistry. This catches a missing fire, a fully detached registrar, and a half-detached registrar (where one registry is fresh and the other live — would only surface as broken Vue rendering in the browser).