Skip to content

Allow PubSub to Use External Instance#828

Open
KetanReddy wants to merge 9 commits intoplayer-1-dot-zerofrom
pubsub-changes
Open

Allow PubSub to Use External Instance#828
KetanReddy wants to merge 9 commits intoplayer-1-dot-zerofrom
pubsub-changes

Conversation

@KetanReddy
Copy link
Member

Closes #785

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major
  • N/A

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

A1shK and others added 6 commits March 16, 2026 21:54
Co-authored-by: Kelly Harrop <kn.harrop@gmail.com>
…ts (#827)

* Add CLAUDE.md with guidelines for reporting and reviewing pull requests

* Fix: Include CONTRIBUTORS in Claude Code Review job conditions
* Cancels the already-running scroll animation on page transition
@KetanReddy KetanReddy self-assigned this Mar 19, 2026
@KetanReddy KetanReddy changed the title First pass at pubsub changes Allow PubSub to Use External Dispatcher Mar 19, 2026
@KetanReddy KetanReddy marked this pull request as ready for review March 19, 2026 22:49
@KetanReddy KetanReddy requested review from a team as code owners March 19, 2026 22:49
@KetanReddy KetanReddy changed the title Allow PubSub to Use External Dispatcher Allow PubSub to Use External Instance Mar 19, 2026
@KetanReddy KetanReddy requested a review from a team as a code owner March 19, 2026 22:52
@codecov
Copy link

codecov bot commented Mar 19, 2026

Bundle Report

Changes will increase total bundle size by 9.24kB (0.16%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
plugins/beacon/core 402.2kB 162 bytes (0.04%) ⬆️
plugins/check-path/core 420.61kB 162 bytes (0.04%) ⬆️
plugins/stage-revert-data/core 384.23kB 162 bytes (0.04%) ⬆️
plugins/reference-assets/core 463.23kB 1.47kB (0.32%) ⬆️
react/player 73.12kB -234 bytes (-0.32%) ⬇️
plugins/common-expressions/core 406.46kB 160 bytes (0.04%) ⬆️
plugins/pubsub/core 46.12kB 898 bytes (1.99%) ⬆️
plugins/markdown/core 661.26kB 143 bytes (0.02%) ⬆️
plugins/auto-scroll/react 19.9kB 1.45kB (7.87%) ⬆️
plugins/common-types/core 480.79kB 160 bytes (0.03%) ⬆️
plugins/metrics/core 438.77kB 162 bytes (0.04%) ⬆️
plugins/async-node/core 458.26kB 3.45kB (0.76%) ⬆️
core/partial-match-registry 28.09kB 591 bytes (2.15%) ⬆️
core/player 952.08kB 505 bytes (0.05%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: plugins/reference-assets/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ReferenceAssetsPlugin.native.js 1.47kB 433.33kB 0.34%
view changes for bundle: core/player

Assets Changed:

Asset Name Size Change Total Size Change (%)
Player.native.js 139 bytes 402.0kB 0.03%
cjs/index.cjs 122 bytes 187.63kB 0.07%
index.legacy-esm.js 122 bytes 181.22kB 0.07%
index.mjs 122 bytes 181.22kB 0.07%
view changes for bundle: plugins/auto-scroll/react

Assets Changed:

Asset Name Size Change Total Size Change (%)
cjs/index.cjs 496 bytes 8.06kB 6.56% ⚠️
index.legacy-esm.js 478 bytes 5.92kB 8.79% ⚠️
index.mjs 478 bytes 5.92kB 8.79% ⚠️
view changes for bundle: plugins/metrics/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MetricsPlugin.native.js 162 bytes 406.42kB 0.04%
view changes for bundle: core/partial-match-registry

Assets Changed:

Asset Name Size Change Total Size Change (%)
Registry.native.js 195 bytes 18.79kB 1.05%
cjs/index.cjs 130 bytes 4.24kB 3.16%
index.legacy-esm.js 133 bytes 2.52kB 5.56% ⚠️
index.mjs 133 bytes 2.52kB 5.56% ⚠️
view changes for bundle: plugins/markdown/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MarkdownPlugin.native.js 143 bytes 636.11kB 0.02%
view changes for bundle: plugins/async-node/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
AsyncNodePlugin.native.js 1.68kB 410.42kB 0.41%
cjs/index.cjs 590 bytes 17.41kB 3.51%
index.legacy-esm.js 590 bytes 15.22kB 4.03%
index.mjs 590 bytes 15.22kB 4.03%
view changes for bundle: plugins/stage-revert-data/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
StageRevertDataPlugin.native.js 162 bytes 377.4kB 0.04%
view changes for bundle: plugins/common-types/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
CommonTypesPlugin.native.js 160 bytes 409.61kB 0.04%
view changes for bundle: plugins/check-path/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
CheckPathPlugin.native.js 162 bytes 391.12kB 0.04%
view changes for bundle: react/player

Assets Changed:

Asset Name Size Change Total Size Change (%)
cjs/index.cjs -78 bytes 26.63kB -0.29%
index.legacy-esm.js -78 bytes 23.25kB -0.33%
index.mjs -78 bytes 23.25kB -0.33%
view changes for bundle: plugins/common-expressions/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
CommonExpressionsPlugin.native.js 160 bytes 385.21kB 0.04%
view changes for bundle: plugins/beacon/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
BeaconPlugin.native.js 162 bytes 387.74kB 0.04%
view changes for bundle: plugins/pubsub/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
PubSubPlugin.native.js 449 bytes 22.89kB 2.0%
cjs/index.cjs 171 bytes 8.58kB 2.03%
index.legacy-esm.js 139 bytes 7.33kB 1.93%
index.mjs 139 bytes 7.33kB 1.93%

Comment on lines +33 to +48
/**
The JS context in which this TinyPubSub instance lives.
Setting this property loads the PubSubPlugin native bundle (if not already loaded) and
constructs the JS TinyPubSub instance. Subsequent assignments are ignored once the instance
has been created.
*/
public var context: JSContext? {
didSet {
guard let jsContext = context, jsValue == nil else { return }
if let url = ResourceUtilities.urlForFile(name: "PubSubPlugin.native", ext: "js", bundle: Bundle.module),
let jsString = try? String(contentsOf: url, encoding: .utf8) {
jsContext.evaluateScript(jsString)
}
jsValue = jsContext.evaluateScript("new PubSubPlugin.TinyPubSub()")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved to the init? Since this is only supposed to happen once, re: "Subsequent assignments are ignored once the instance has been created.", the init seems like the more appropriate place for this to live. Using didSet like this is strange and will confuse users, imo.

@KetanReddy KetanReddy requested a review from KVSRoyal March 20, 2026 16:43
Copy link
Contributor

@KVSRoyal KVSRoyal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (ec0701d) to head (0e9d52a).
⚠️ Report is 69 commits behind head on player-1-dot-zero.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           player-1-dot-zero   #828       +/-   ##
====================================================
- Coverage              85.90%      0   -85.91%     
====================================================
  Files                    507      0      -507     
  Lines                  22891      0    -22891     
  Branches                2656      0     -2656     
====================================================
- Hits                   19664      0    -19664     
+ Misses                  2898      0     -2898     
+ Partials                 329      0      -329     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Allow a pubsub to be passed into the PubSubPlugin or initialized on every new plugin

6 participants