-
Notifications
You must be signed in to change notification settings - Fork 61
OPFS Multiple Tab Trigger Invocation #804
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9637aaf
OPFS Multiple tab triggers
stevensJourney f66ce86
Merge remote-tracking branch 'origin/main' into multiple-tab-triggers…
stevensJourney 22877b6
cleanup defaults and typing
stevensJourney fcfcc32
Improve disposal of resources. Add unit tests for disposal.
stevensJourney 24ac097
use trigger name to determine the table name. cleanup resources with …
stevensJourney dcba009
update trigger naming
stevensJourney f437400
Add more tests.
stevensJourney 797bde5
cleanup
stevensJourney d88e630
cleanup naming for TriggerClaimManager
stevensJourney fa6f129
remove unused items
stevensJourney 7150f96
cleanup naming
stevensJourney db14b39
add test for default temporary triggers
stevensJourney 5ea40a2
remove debugger statement
stevensJourney 066c39a
Merge remote-tracking branch 'origin/main' into multiple-tab-triggers…
stevensJourney 275134f
updates after updating from main
stevensJourney 392b9d4
Update TriggerManager doc comment
stevensJourney 394f056
use const exports for Memory and Navigator trigger claim managers.
stevensJourney fba6018
Update packages/common/src/client/triggers/TriggerManagerImpl.ts
stevensJourney 89b4184
Merge branch 'multiple-tab-triggers-opfs' of github.com:journeyapps/p…
stevensJourney c992cce
Merge branch 'multiple-tab-triggers-opfs' of github.com:journeyapps/p…
stevensJourney 1c88121
cleanup cleanup function to use JS Regex matching
stevensJourney e03ae52
Update packages/common/src/client/triggers/MemoryTriggerClaimManager.ts
stevensJourney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@powersync/common': minor | ||
| '@powersync/web': minor | ||
| --- | ||
|
|
||
| Add support for storage-backed (non-TEMP) SQLite triggers and tables for managed triggers. These resources persist on disk while in use and are automatically cleaned up when no longer claimed or needed. They should not be considered permanent triggers; PowerSync manages their lifecycle. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@powersync/web': minor | ||
| --- | ||
|
|
||
| Managed triggers now use storage-backed (non-TEMP) SQLite triggers and tables when OPFS is the VFS. Resources persist across tabs and connection cycles to detect cross‑tab changes, and are automatically cleaned up when no longer in use. These should not be treated as permanent triggers; their lifecycle is managed by PowerSync. |
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
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
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
25 changes: 25 additions & 0 deletions
25
packages/common/src/client/triggers/MemoryTriggerClaimManager.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { TriggerClaimManager } from './TriggerManager.js'; | ||
|
|
||
| const CLAIM_STORE = new Map<string, () => Promise<void>>(); | ||
|
|
||
| /** | ||
| * @internal | ||
| * @experimental | ||
| */ | ||
| export const MEMORY_TRIGGER_CLAIM_MANAGER: TriggerClaimManager = { | ||
| async obtainClaim(identifier: string): Promise<() => Promise<void>> { | ||
| if (CLAIM_STORE.has(identifier)) { | ||
| throw new Error(`A claim is already present for ${identifier}`); | ||
| } | ||
| const release = async () => { | ||
| CLAIM_STORE.delete(identifier); | ||
| }; | ||
| CLAIM_STORE.set(identifier, release); | ||
|
|
||
| return release; | ||
| }, | ||
|
|
||
| async checkClaim(identifier: string): Promise<boolean> { | ||
| return CLAIM_STORE.has(identifier); | ||
| } | ||
| }; |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.