- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
120 lines
3.1 KiB
JavaScript
120 lines
3.1 KiB
JavaScript
import EventTarget from '../event/EventTarget.js';
|
|
import DOMException from '../exception/DOMException.js';
|
|
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
|
|
import * as PropertySymbol from '../PropertySymbol.js';
|
|
/**
|
|
* Browser window with limited access due to CORS restrictions in iframes.
|
|
*/
|
|
export default class CrossOriginBrowserWindow extends EventTarget {
|
|
window = this;
|
|
location;
|
|
// Internal properties
|
|
[PropertySymbol.self] = this;
|
|
// Private properties
|
|
#targetWindow;
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param target Target window.
|
|
* @param [parent] Parent window.
|
|
*/
|
|
constructor(target, parent) {
|
|
super();
|
|
this[PropertySymbol.parent] = parent ?? this;
|
|
this[PropertySymbol.top] = parent ?? this;
|
|
this.location = new Proxy({}, {
|
|
get: () => {
|
|
throw new DOMException(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum.securityError);
|
|
},
|
|
set: () => {
|
|
throw new DOMException(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum.securityError);
|
|
}
|
|
});
|
|
this.#targetWindow = target;
|
|
}
|
|
/**
|
|
* Returns self.
|
|
*
|
|
* @returns Self.
|
|
*/
|
|
get self() {
|
|
return this[PropertySymbol.self];
|
|
}
|
|
/**
|
|
* Returns self.
|
|
*
|
|
* @param self Self.
|
|
*/
|
|
set self(self) {
|
|
this[PropertySymbol.self] = self;
|
|
}
|
|
/**
|
|
* Returns top.
|
|
*
|
|
* @returns Top.
|
|
*/
|
|
get top() {
|
|
return this[PropertySymbol.top];
|
|
}
|
|
/**
|
|
* Returns parent.
|
|
*
|
|
* @returns Parent.
|
|
*/
|
|
get parent() {
|
|
return this[PropertySymbol.parent];
|
|
}
|
|
/**
|
|
* Returns parent.
|
|
*
|
|
* @param parent Parent.
|
|
*/
|
|
set parent(parent) {
|
|
this[PropertySymbol.parent] = parent;
|
|
}
|
|
/**
|
|
* Returns the opener.
|
|
*
|
|
* @returns Opener.
|
|
*/
|
|
get opener() {
|
|
return this.#targetWindow.opener;
|
|
}
|
|
/**
|
|
* Returns the closed state.
|
|
*
|
|
* @returns Closed state.
|
|
*/
|
|
get closed() {
|
|
return this.#targetWindow.closed;
|
|
}
|
|
/**
|
|
* Shifts focus away from the window.
|
|
*/
|
|
blur() {
|
|
this.#targetWindow.blur();
|
|
}
|
|
/**
|
|
* Gives focus to the window.
|
|
*/
|
|
focus() {
|
|
this.#targetWindow.focus();
|
|
}
|
|
/**
|
|
* Closes the window.
|
|
*/
|
|
close() {
|
|
this.#targetWindow.close();
|
|
}
|
|
/**
|
|
* Safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.
|
|
*
|
|
* @param message Message.
|
|
* @param [targetOrigin=*] Target origin.
|
|
* @param transfer Transfer. Not implemented.
|
|
*/
|
|
postMessage(message, targetOrigin = '*', transfer) {
|
|
this.#targetWindow.postMessage(message, targetOrigin, transfer);
|
|
}
|
|
}
|
|
//# sourceMappingURL=CrossOriginBrowserWindow.js.map
|