# UnifiedFiler v1.9.4 Notes

v1.9.4 introduces the first implementation of the Control architecture discussed for Host integration.

## Core idea

UnifiedFiler is treated as a Host-embedded File Operation Control Framework rather than only a FileExplorer UI widget.

```text
Host System
  -> FileExplorerControl / FilePickerControl / FileSaverControl / UnifiedFilerControl
     -> CommandRegistry / StateStore / EventBus / Service / Adapter
        -> internal View modules / jQuery plugin ViewController APIs
```

The important rule is that the Control owns the internal UI system. View modules remain active UI View/Controller components; they register jQuery plugin APIs internally, but they are not treated as the Host-level API.

## Added modules

```text
scripts/controls/
  FileExplorerControl.js
  FilePickerControl.js
  FileSaverControl.js
  UnifiedFilerControl.js

scripts/commands/
  BaseCommand.js
  CommandRegistry.js
  DefaultFileCommands.js

scripts/models/
  EventBus.js
  StateStore.js
  SelectionModel.js
  ClipboardModel.js
```

## FileExplorerControl

New Host-facing API:

```javascript
var control = new UnifiedFiler.controls.FileExplorerControl('#explorer', options);
control.mount();
control.exec('rename');
control.openFolder('/Documents');
control.on('selectionChanged', handler);
```

The Control internally mounts the existing `$.fn.fileExplorer` plugin and bridges events such as `selectionChanged`, `folderChanged`, and `fileOpened` to the Host.

## Commands

`CommandRegistry` centralizes command execution and state. The initial default command set covers existing FileExplorer operations:

```text
refresh, up, back, forward, newFolder, newFile, upload,
rename, delete, paste, toggleFavorite, togglePreview,
showRecent, showFavorites
```

Toolbar, ContextMenu, KeyboardShortcut and Host API can gradually be unified around this command model in later versions.

## State and EventBus

`StateStore` provides a small observable state container. `EventBus` provides Control-level event subscription independent from jQuery DOM events.

## Capability model

`BaseStorageAdapter.getCapabilities()` now includes additional capability flags used by Control command state:

```javascript
canUpload, canExport, canShare, canPreview
```

Existing adapters remain compatible because missing flags are interpreted permissively unless a command needs a strict false check.

## Compatibility

The existing jQuery plugin APIs remain available because they are registered by the View modules:

```javascript
$('#explorer').fileExplorer(options);
$('#host').filePickerDialog(options);
$('#host').fileSaverDialog(options);
```

New Host integrations should prefer the Control classes.
