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

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,20 @@ 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 (options) => {
15647
+ const { context } = options ?? {};
15647
15648
  disposeWarningListener();
15648
- return this.db.writeLock(async (tx) => {
15649
+ const doCleanup = async (tx) => {
15649
15650
  await this.removeTriggers(tx, triggerIds);
15650
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
15651
+ await tx.execute(`DROP TABLE IF EXISTS ${destination};`);
15651
15652
  await releaseStorageClaim?.();
15652
- });
15653
+ };
15654
+ if (context) {
15655
+ await doCleanup(context);
15656
+ }
15657
+ else {
15658
+ await this.db.writeLock(doCleanup);
15659
+ }
15653
15660
  };
15654
15661
  const setup = async (tx) => {
15655
15662
  // Allow user code to execute in this lock context before the trigger is created.
@@ -15723,12 +15730,17 @@ class TriggerManagerImpl {
15723
15730
  }
15724
15731
  };
15725
15732
  try {
15726
- await this.db.writeLock(setup);
15733
+ if (setupContext) {
15734
+ await setup(setupContext);
15735
+ }
15736
+ else {
15737
+ await this.db.writeLock(setup);
15738
+ }
15727
15739
  return cleanup;
15728
15740
  }
15729
15741
  catch (error) {
15730
15742
  try {
15731
- await cleanup();
15743
+ await cleanup(setupContext ? { context: setupContext } : undefined);
15732
15744
  }
15733
15745
  catch (cleanupError) {
15734
15746
  throw new AggregateError([error, cleanupError], 'Error during operation and cleanup');