@powersync/web 0.0.0-dev-20260311080613 → 0.0.0-dev-20260311081226

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15588,7 +15588,7 @@ class TriggerManagerImpl {
15588
15588
  }
15589
15589
  async createDiffTrigger(options) {
15590
15590
  await this.db.waitForReady();
15591
- const { source, destination, columns, when, hooks,
15591
+ const { source, destination, columns, when, hooks, setupContext,
15592
15592
  // Fall back to the provided default if not given on this level
15593
15593
  useStorage = this.defaultConfig.useStorageByDefault } = options;
15594
15594
  const operations = Object.keys(when);
@@ -15643,13 +15643,19 @@ class TriggerManagerImpl {
15643
15643
  * we need to ensure we can cleanup the created resources.
15644
15644
  * We unfortunately cannot rely on transaction rollback.
15645
15645
  */
15646
- const cleanup = async () => {
15646
+ const cleanup = async (context) => {
15647
15647
  disposeWarningListener();
15648
- return this.db.writeLock(async (tx) => {
15648
+ const doCleanup = async (tx) => {
15649
15649
  await this.removeTriggers(tx, triggerIds);
15650
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
15650
+ await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
15651
15651
  await releaseStorageClaim?.();
15652
- });
15652
+ };
15653
+ if (context) {
15654
+ await doCleanup(context);
15655
+ }
15656
+ else {
15657
+ await this.db.writeLock(doCleanup);
15658
+ }
15653
15659
  };
15654
15660
  const setup = async (tx) => {
15655
15661
  // Allow user code to execute in this lock context before the trigger is created.
@@ -15723,7 +15729,12 @@ class TriggerManagerImpl {
15723
15729
  }
15724
15730
  };
15725
15731
  try {
15726
- await this.db.writeLock(setup);
15732
+ if (setupContext) {
15733
+ await setup(setupContext);
15734
+ }
15735
+ else {
15736
+ await this.db.writeLock(setup);
15737
+ }
15727
15738
  return cleanup;
15728
15739
  }
15729
15740
  catch (error) {