@ableton-extensions/sdk
    Preparing search index...

    Interface ExtensionContext<Version>

    Provides access to all SDK functionality. Returned by initialize.

    interface ExtensionContext<Version extends ApiVersion> {
        application: Application<Version>;
        commands: Commands<Version>;
        environment: Environment<Version>;
        resources: Resources<Version>;
        ui: Ui<Version>;
        getObjectFromHandle<T extends DataModelObject<Version>>(
            handle: Handle,
            type: new (...args: never) => T,
        ): T;
        withinTransaction<T>(fn: () => T): T;
    }

    Type Parameters

    • Version extends ApiVersion
    Index

    Properties

    application: Application<Version>
    commands: Commands<Version>
    environment: Environment<Version>
    resources: Resources<Version>
    ui: Ui<Version>

    Methods

    • Resolves a Handle into a typed SDK object.

      Pass DataModelObject as type when the exact type of the handle is not known in advance, then use instanceof to branch on the actual type:

      const obj = context.getObjectFromHandle(handle, DataModelObject);
      if (obj instanceof ClipSlot) {
      // ...
      }

      Objects are cached by handle ID, so the same Live object always returns the same SDK instance.

      Throws if the underlying object has been deleted, if it is of a different type than type, or if its type is not recognised.

      Type Parameters

      Parameters

      • handle: Handle
      • type: new (...args: never) => T

      Returns T

    • Groups mutations into a single undo step.

      Individual mutations are already undoable on their own; use this only to roll several changes into one user-facing undo entry. Nested transactions collapse into the outermost one.

      The callback must be synchronous — you cannot await inside it — but returning Promise.all([...]) lets you group multiple async operations (such as creating tracks) into one undo step:

      const tracks = await withinTransaction(() =>
      Promise.all([song.createAudioTrack(), song.createAudioTrack()]),
      );

      Type Parameters

      • T

      Parameters

      • fn: () => T

      Returns T