They don’t need to. The code behind this is the same a when playing or recording a action in Photoshop. I would think it’s similar to AppleScript’s class identifiers under the hood. As an action it just plays it out. As script you give it logic. I leave the plug-in active but theres no need it can be moved in/out as needed.
This is a sample from around 5 years ago ( CS2 )
The subs just play javascript/action manager code but I can work with multi-layers no problem. You use AppleScript or JavaScript to get the document in the correct state. Then execute action manager when you need to access stuff not in the DOM. continue.
tell application "Adobe Photoshop CS2"
activate
set Doc_Ref to the current document
tell Doc_Ref
my Select_Layers(Doc_Ref, "Layer 1", "addToSelectionContinuous")
my Align_Layers(Doc_Ref, "AdBt")
my Distribute_Layers(Doc_Ref, "AdCH")
end tell
end tell
on Select_Layers(Doc_Ref, Layer_Ref, Add_Ref)
-- Layer_Ref = Name string of layer to add to selection
-- Add_Ref = addToSelection or addToSelectionContinuous
tell application "Adobe Photoshop CS2"
tell Doc_Ref
do javascript "Select_Layers(); function Select_Layers() { function cTID(s) { return app.charIDToTypeID(s); }; function sTID(s) { return app.stringIDToTypeID(s); }; var desc01 = new ActionDescriptor(); var ref01 = new ActionReference(); ref01.putName( cTID('Lyr '), '" & Layer_Ref & "' ); desc01.putReference( cTID('null'), ref01 ); desc01.putEnumerated( sTID('selectionModifier'), sTID('selectionModifierType'), sTID('" & Add_Ref & "') ); desc01.putBoolean( cTID('MkVs'), false ); executeAction( cTID('slct'), desc01, DialogModes.NO );};" show debugger on runtime error
end tell
end tell
end Select_Layers
on Align_Layers(Doc_Ref, Align_Ref)
-- Align_Ref = AdLf, AdRg, AdCH, AdTp, AdBt, AdCV
tell application "Adobe Photoshop CS2"
tell Doc_Ref
do javascript "Align_Layers(); function Align_Layers() {function cTID(s) { return app.charIDToTypeID(s); }; function sTID(s) { return app.stringIDToTypeID(s); }; var desc01 = new ActionDescriptor(); var ref01 = new ActionReference(); ref01.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') ); desc01.putReference( cTID('null'), ref01 ); desc01.putEnumerated( cTID('Usng'), cTID('ADSt'), cTID('" & Align_Ref & "') ); executeAction( cTID('Algn'), desc01, DialogModes.NO );};" show debugger on runtime error
end tell
end tell
end Align_Layers
on Distribute_Layers(Doc_Ref, Distribute_Ref)
-- Distribute_Ref = AdLf, AdRg, AdCH, AdTp, AdBt, AdCV
tell application "Adobe Photoshop CS2"
tell Doc_Ref
do javascript "Distribute_Layers(); function Distribute_Layers() {function cTID(s) { return app.charIDToTypeID(s); }; function sTID(s) { return app.stringIDToTypeID(s); }; var desc01 = new ActionDescriptor(); var ref01 = new ActionReference(); ref01.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') ); desc01.putReference( cTID('null'), ref01 ); desc01.putEnumerated( cTID('Usng'), cTID('ADSt'), cTID('" & Distribute_Ref & "') ); executeAction( cTID('Dstr'), desc01, DialogModes.NO );};" show debugger on runtime error
end tell
end tell
end Distribute_Layers