1function _assert_this_initialized(self) { 2 if (self === void 0) { 3 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 4 } 5 return self; 6} 7function _class_call_check(instance, Constructor) { 8 if (!(instance instanceof Constructor)) { 9 throw new TypeError("Cannot call a class as a function"); 10 } 11} 12function _defineProperties(target, props) { 13 for(var i = 0; i < props.length; i++){ 14 var descriptor = props[i]; 15 descriptor.enumerable = descriptor.enumerable || false; 16 descriptor.configurable = true; 17 if ("value" in descriptor) descriptor.writable = true; 18 Object.defineProperty(target, descriptor.key, descriptor); 19 } 20} 21function _create_class(Constructor, protoProps, staticProps) { 22 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 23 if (staticProps) _defineProperties(Constructor, staticProps); 24 return Constructor; 25} 26function _define_property(obj, key, value) { 27 if (key in obj) { 28 Object.defineProperty(obj, key, { 29 value: value, 30 enumerable: true, 31 configurable: true, 32 writable: true 33 }); 34 } else { 35 obj[key] = value; 36 } 37 return obj; 38} 39function _get_prototype_of(o) { 40 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { 41 return o.__proto__ || Object.getPrototypeOf(o); 42 }; 43 return _get_prototype_of(o); 44} 45function _inherits(subClass, superClass) { 46 if (typeof superClass !== "function" && superClass !== null) { 47 throw new TypeError("Super expression must either be null or a function"); 48 } 49 subClass.prototype = Object.create(superClass && superClass.prototype, { 50 constructor: { 51 value: subClass, 52 writable: true, 53 configurable: true 54 } 55 }); 56 if (superClass) _set_prototype_of(subClass, superClass); 57} 58function _possible_constructor_return(self, call) { 59 if (call && (_type_of(call) === "object" || typeof call === "function")) { 60 return call; 61 } 62 return _assert_this_initialized(self); 63} 64function _set_prototype_of(o, p) { 65 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) { 66 o.__proto__ = p; 67 return o; 68 }; 69 return _set_prototype_of(o, p); 70} 71function _type_of(obj) { 72 "@swc/helpers - typeof"; 73 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; 74} 75function _is_native_reflect_construct() { 76 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 77 if (Reflect.construct.sham) return false; 78 if (typeof Proxy === "function") return true; 79 try { 80 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); 81 return true; 82 } catch (e) { 83 return false; 84 } 85} 86function _create_super(Derived) { 87 var hasNativeReflectConstruct = _is_native_reflect_construct(); 88 return function _createSuperInternal() { 89 var Super = _get_prototype_of(Derived), result; 90 if (hasNativeReflectConstruct) { 91 var NewTarget = _get_prototype_of(this).constructor; 92 result = Reflect.construct(Super, arguments, NewTarget); 93 } else { 94 result = Super.apply(this, arguments); 95 } 96 return _possible_constructor_return(this, result); 97 }; 98} 99import { Controller } from "@hotwired/stimulus"; 100import { FileManagerState } from "../../lib/file-manager/models/FileManagerState.js"; 101import { decodeIdentifier } from "../../lib/file-manager/utils/index.js"; 102var _class = /*#__PURE__*/ function(Controller) { 103 "use strict"; 104 _inherits(_class, Controller); 105 var _super = _create_super(_class); 106 function _class() { 107 _class_call_check(this, _class); 108 var _this; 109 _this = _super.apply(this, arguments); 110 // ==================== Current Directory State (SSOT) ==================== 111 _define_property(_assert_this_initialized(_this), "currentIdentifier", ""); 112 _define_property(_assert_this_initialized(_this), "currentPath", ""); 113 // ==================== Node Cache (SSOT) ====================
114 _define_property(_assert_this_initialized(_this), "nodeCache", new Map()); 115 // ==================== Tree State ==================== 116 _define_property(_assert_this_initialized(_this), "treeRootNode", null); 117 _define_property(_assert_this_initialized(_this), "treeSelectedPath", null); 118 // ==================== Browser State ==================== 119 _define_property(_assert_this_initialized(_this), "browserCurrentDirectory", null); 120 // ==================== Terminal State ==================== 121 _define_property(_assert_this_initialized(_this), "terminalVisible", false); 122 // ==================== Editor State ==================== 123 _define_property(_assert_this_initialized(_this), "editorOpen", false); 124 // ==================== Info Pane State ==================== 125 _define_property(_assert_this_initialized(_this), "infoPaneVisible", true); 126 // ==================== Persistent State (FileManagerState) ==================== 127 _define_property(_assert_this_initialized(_this), "persistentState", null); 128 return _this; 129 } 130 _create_class(_class, [ 131 { 132 key: "connect", 133 value: function connect() { 134 // Initialize current directory to root on connect 135 this.currentIdentifier = this.rootIdentifierValue; 136 this.currentPath = ""; 137 // Initialize persistent state (localStorage-backed) 138 // Extract filesystem type and identifier from rootIdentifier 139 // rootIdentifier format: base64url(type\0id\0path) 140 try { 141 var decoded = decodeIdentifier(this.rootIdentifierValue); 142 var parts = decoded.split("\x00"); 143 if (parts.length >= 2) { 144 this.persistentState = new FileManagerState(parts[0], parts[1]); 145 // Load info pane visibility from persistent state 146 this.infoPaneVisible = this.persistentState.infoPaneVisible; 147 } 148 } catch (error) { 149 console.warn("Failed to initialize FileManagerState:", error); 150 } 151 } 152 }, 153 { 154 // ==================== Current Directory Management ==================== 155 /** 156 * Get the current directory identifier (SSOT) 157 */ key: "getCurrentIdentifier", 158 value: function getCurrentIdentifier() { 159 return this.currentIdentifier; 160 } 161 }, 162 { 163 /** 164 * Get the current directory path (SSOT) 165 */ key: "getCurrentPath", 166 value: function getCurrentPath() { 167 return this.currentPath; 168 } 169 }, 170 { 171 /** 172 * Set current directory (SSOT) and notify all controllers 173 * @param identifier The directory identifier 174 * @param path Optional path for the directory 175 * @param options Notification options 176 */ key: "setCurrentDirectory", 177 value: function setCurrentDirectory(identifier, path) { 178 var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; 179 var changed = identifier !== this.currentIdentifier; 180 this.currentIdentifier = identifier; 181 if (path !== undefined) { 182 this.currentPath = path; 183 } 184 // Notify other controllers of the change unless silent 185 if (!options.silent && changed) { 186 this.dispatch("directoryChanged", { 187 detail: { 188 identifier: identifier, 189 path: this.currentPath, 190 source: options.source || "unknown" 191 }, 192 bubbles: true 193 }); 194 } 195 } 196 }, 197 { 198 // ==================== Node Cache Management ==================== 199 /** 200 * Get a cached node by identifier (SSOT) 201 */ key: "getCachedNode", 202 value: function getCachedNode(identifier) { 203 return this.nodeCache.get(identifier); 204 } 205 }, 206 { 207 /** 208 * Check if a node is cached 209 */ key: "hasNodeInCache", 210 value: function hasNodeInCache(identifier) { 211 return this.nodeCache.has(identifier); 212 } 213 }, 214 { 215 /** 216 * Add or update a node in the cache (SSOT) 217 */ key: "cacheNode", 218 value: function cacheNode(identifier, node) { 219 this.nodeCache.set(identifier, node); 220 } 221 }, 222 { 223 /** 224 * Remove a node from the cache (SSOT)
225 */ key: "invalidateNode", 226 value: function invalidateNode(identifier) { 227 this.nodeCache.delete(identifier); 228 } 229 }, 230 { 231 /** 232 * Clear the entire node cache (SSOT) 233 */ key: "clearCache", 234 value: function clearCache() { 235 this.nodeCache.clear(); 236 } 237 }, 238 { 239 /** 240 * Get cache size (for debugging) 241 */ key: "getCacheSize", 242 value: function getCacheSize() { 243 return this.nodeCache.size; 244 } 245 }, 246 { 247 // ==================== Tree State Management ==================== 248 /** 249 * Get the tree root node 250 */ key: "getTreeRootNode", 251 value: function getTreeRootNode() { 252 return this.treeRootNode; 253 } 254 }, 255 { 256 /** 257 * Set the tree root node 258 */ key: "setTreeRootNode", 259 value: function setTreeRootNode(node) { 260 this.treeRootNode = node; 261 } 262 }, 263 { 264 /** 265 * Get the currently selected path in the tree 266 */ key: "getTreeSelectedPath", 267 value: function getTreeSelectedPath() { 268 return this.treeSelectedPath; 269 } 270 }, 271 { 272 /** 273 * Set the currently selected path in the tree 274 */ key: "setTreeSelectedPath", 275 value: function setTreeSelectedPath(path) { 276 this.treeSelectedPath = path; 277 } 278 }, 279 { 280 // ==================== Browser State Management ==================== 281 /** 282 * Get the browser's current directory node 283 */ key: "getBrowserCurrentDirectory", 284 value: function getBrowserCurrentDirectory() { 285 return this.browserCurrentDirectory; 286 } 287 }, 288 { 289 /** 290 * Set the browser's current directory node 291 */ key: "setBrowserCurrentDirectory", 292 value: function setBrowserCurrentDirectory(directory) { 293 this.browserCurrentDirectory = directory; 294 } 295 }, 296 { 297 // ==================== Terminal State Management ==================== 298 /** 299 * Get terminal visibility state (SSOT) 300 */ key: "isTerminalVisible", 301 value: function isTerminalVisible() { 302 return this.terminalVisible; 303 } 304 }, 305 { 306 /** 307 * Set terminal visibility state (SSOT) 308 * @param visible Whether the terminal should be visible 309 * @param options Notification options 310 */ key: "setTerminalVisible", 311 value: function setTerminalVisible(visible) { 312 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 313 var changed = visible !== this.terminalVisible; 314 this.terminalVisible = visible; 315 // Notify other controllers of the change unless silent 316 if (!options.silent && changed) { 317 this.dispatch("terminalVisibilityChanged", { 318 detail: { 319 visible: visible 320 }, 321 bubbles: true 322 }); 323 } 324 } 325 }, 326 { 327 // ==================== Editor State Management ==================== 328 /** 329 * Get editor open state (SSOT) 330 */ key: "isEditorOpen", 331 value: function isEditorOpen() { 332 return this.editorOpen; 333 } 334 }, 335 { 336 /** 337 * Set editor open state (SSOT) 338 * @param open Whether the editor is open 339 * @param options Notification options 340 */ key: "setEditorOpen", 341 value: function setEditorOpen(open) { 342 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 343 var changed = open !== this.editorOpen; 344 this.editorOpen = open; 345 // Notify other controllers of the change unless silent 346 if (!options.silent && changed) { 347 this.dispatch("editorStateChanged", { 348 detail: { 349 open: open 350 }, 351 bubbles: true 352 }); 353 } 354 } 355 }, 356 { 357 // ==================== Info Pane State Management ==================== 358 /** 359 * Get info pane visibility state (SSOT) 360 */ key: "isInfoPaneVisible", 361 value: function isInfoPaneVisible() { 362 return this.infoPaneVisible; 363 } 364 }, 365 { 366 /** 367 * Set info pane visibility state (SSOT) 368 * @param visible Whether the info pane should be visible 369 * @param options Notification options 370 */ key: "setInfoPaneVisible", 371 value: function setInfoPaneVisible(visible) { 372 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 373 var changed = visible !== this.infoPaneVisible; 374 this.infoPaneVisible = visible; 375 // Persist to FileManagerState 376 if (this.persistentState) { 377 this.persistentState.infoPaneVisible = visible; 378 } 379 // Notify other controllers of the change unless silent 380 if (!options.silent && changed) { 381 this.dispatch("infoPaneVisibilityChanged", { 382 detail: { 383 visible: visible 384 }, 385 bubbles: true 386 }); 387 } 388 } 389 }, 390 { 391 // ==================== Persistent State Management (FileManagerState) ==================== 392 /** 393 * Get the FileManagerState instance (SSOT for persistent preferences) 394 */ key: "getPersistentState", 395 value: function getPersistentState() { 396 return this.persistentState; 397 } 398 }, 399 { 400 // ==================== Helper Methods ==================== 401 /** 402 * Check if the given identifier is the current directory 403 */ key: "isCurrentDirectory", 404 value: function isCurrentDirectory(identifier) { 405 return this.currentIdentifier === identifier; 406 } 407 }, 408 { 409 /** 410 * Check if at root directory 411 */ key: "isAtRoot", 412 value: function isAtRoot() { 413 return this.currentIdentifier === this.rootIdentifierValue; 414 } 415 }, 416 { 417 /** 418 * Debug: Get state summary 419 */ key: "getStateSummary", 420 value: function getStateSummary() { 421 return { 422 currentIdentifier: this.currentIdentifier, 423 currentPath: this.currentPath, 424 cacheSize: this.nodeCache.size, 425 hasTreeRoot: this.treeRootNode !== null, 426 hasBrowserDirectory: this.browserCurrentDirectory !== null, 427 treeSelectedPath: this.treeSelectedPath, 428 terminalVisible: this.terminalVisible, 429 editorOpen: this.editorOpen, 430 infoPaneVisible: this.infoPaneVisible, 431 hasPersistentState: this.persistentState !== null 432 }; 433 } 434 } 435 ]); 436 return _class; 437}(Controller); 438_define_property(_class, "values", { 439 rootIdentifier: String 440}); 441/** 442 * FileManager State Controller 443 * 444 * **Single Source of Truth** for all file manager state: 445 * - Current working directory (identifier + path)
446 * - Node cache (shared across tree/browser) 447 * - Selection context 448 * 449 * All controllers access state through this controller to ensure consistency. 450 * 451 * Controller identifier: file-manager--state 452 * 453 * @example 454 * <div data-controller="file-manager--state file-manager--manager" 455 * data-file-manager--state-root-identifier-value="..."> 456 * ... 457 * </div> 458 */ export { _class as default };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.