dockview-core
Advanced tools
Comparing version 1.13.0 to 1.13.1
@@ -50,5 +50,16 @@ import { IDisposable } from './lifecycle'; | ||
export declare function addDisposableListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): IDisposable; | ||
export declare class TickDelayedEvent implements IDisposable { | ||
private timer; | ||
/** | ||
* | ||
* Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle. | ||
* | ||
* It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle. | ||
* This implementation exists to avoid external dependencies. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask | ||
* @see https://rxjs.dev/api/index/const/asapScheduler | ||
*/ | ||
export declare class AsapEvent implements IDisposable { | ||
private readonly _onFired; | ||
private _currentFireCount; | ||
private _queued; | ||
readonly onEvent: Event<void>; | ||
@@ -55,0 +66,0 @@ fire(): void; |
@@ -14,3 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TickDelayedEvent = exports.addDisposableListener = exports.addDisposableWindowListener = exports.Emitter = exports.DockviewEvent = exports.Event = void 0; | ||
exports.AsapEvent = exports.addDisposableListener = exports.addDisposableWindowListener = exports.Emitter = exports.DockviewEvent = exports.Event = void 0; | ||
var Event; | ||
@@ -221,22 +221,54 @@ (function (Event) { | ||
exports.addDisposableListener = addDisposableListener; | ||
var TickDelayedEvent = /** @class */ (function () { | ||
function TickDelayedEvent() { | ||
/** | ||
* | ||
* Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle. | ||
* | ||
* It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle. | ||
* This implementation exists to avoid external dependencies. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask | ||
* @see https://rxjs.dev/api/index/const/asapScheduler | ||
*/ | ||
var AsapEvent = /** @class */ (function () { | ||
function AsapEvent() { | ||
var _this = this; | ||
this._onFired = new Emitter(); | ||
this.onEvent = this._onFired.event; | ||
this._currentFireCount = 0; | ||
this._queued = false; | ||
this.onEvent = function (e) { | ||
/** | ||
* when the event is first subscribed to take note of the current fire count | ||
*/ | ||
var fireCountAtTimeOfEventSubscription = _this._currentFireCount; | ||
return _this._onFired.event(function () { | ||
/** | ||
* if the current fire count is greater than the fire count at event subscription | ||
* then the event has been fired since we subscribed and it's ok to "on_next" the event. | ||
* | ||
* if the count is not greater then what we are recieving is an event from the microtask | ||
* queue that was triggered before we actually subscribed and therfore we should ignore it. | ||
*/ | ||
if (_this._currentFireCount > fireCountAtTimeOfEventSubscription) { | ||
e(); | ||
} | ||
}); | ||
}; | ||
} | ||
TickDelayedEvent.prototype.fire = function () { | ||
AsapEvent.prototype.fire = function () { | ||
var _this = this; | ||
if (this.timer) { | ||
clearTimeout(this.timer); | ||
this._currentFireCount++; | ||
if (this._queued) { | ||
return; | ||
} | ||
this.timer = setTimeout(function () { | ||
this._queued = true; | ||
queueMicrotask(function () { | ||
_this._queued = false; | ||
_this._onFired.fire(); | ||
clearTimeout(_this.timer); | ||
}); | ||
}; | ||
TickDelayedEvent.prototype.dispose = function () { | ||
AsapEvent.prototype.dispose = function () { | ||
this._onFired.dispose(); | ||
}; | ||
return TickDelayedEvent; | ||
return AsapEvent; | ||
}()); | ||
exports.TickDelayedEvent = TickDelayedEvent; | ||
exports.AsapEvent = AsapEvent; |
@@ -1,2 +0,2 @@ | ||
import { Event, TickDelayedEvent } from '../events'; | ||
import { Event, AsapEvent } from '../events'; | ||
import { Gridview, IGridView } from './gridview'; | ||
@@ -54,4 +54,2 @@ import { Position } from '../dnd/droptarget'; | ||
protected _activeGroup: T | undefined; | ||
private _onDidLayoutChange; | ||
readonly onDidLayoutChange: Event<void>; | ||
private readonly _onDidRemove; | ||
@@ -63,3 +61,4 @@ readonly onDidRemove: Event<T>; | ||
readonly onDidActiveChange: Event<T | undefined>; | ||
protected readonly _bufferOnDidLayoutChange: TickDelayedEvent; | ||
protected readonly _bufferOnDidLayoutChange: AsapEvent; | ||
readonly onDidLayoutChange: Event<void>; | ||
get id(): string; | ||
@@ -66,0 +65,0 @@ get size(): number; |
@@ -59,4 +59,2 @@ "use strict"; | ||
_this._groups = new Map(); | ||
_this._onDidLayoutChange = new events_1.Emitter(); | ||
_this.onDidLayoutChange = _this._onDidLayoutChange.event; | ||
_this._onDidRemove = new events_1.Emitter(); | ||
@@ -68,3 +66,4 @@ _this.onDidRemove = _this._onDidRemove.event; | ||
_this.onDidActiveChange = _this._onDidActiveChange.event; | ||
_this._bufferOnDidLayoutChange = new events_1.TickDelayedEvent(); | ||
_this._bufferOnDidLayoutChange = new events_1.AsapEvent(); | ||
_this.onDidLayoutChange = _this._bufferOnDidLayoutChange.onEvent; | ||
_this.element.style.height = '100%'; | ||
@@ -84,4 +83,2 @@ _this.element.style.width = '100%'; | ||
_this._bufferOnDidLayoutChange.fire(); | ||
}), _this._bufferOnDidLayoutChange.onEvent(function () { | ||
_this._onDidLayoutChange.fire(); | ||
}), _this._bufferOnDidLayoutChange); | ||
@@ -172,3 +169,3 @@ return _this; | ||
this.gridview.setViewVisible((0, gridview_1.getGridLocation)(panel.element), visible); | ||
this._onDidLayoutChange.fire(); | ||
this._bufferOnDidLayoutChange.fire(); | ||
}; | ||
@@ -285,3 +282,2 @@ BaseGrid.prototype.isVisible = function (panel) { | ||
this._onDidRemove.dispose(); | ||
this._onDidLayoutChange.dispose(); | ||
try { | ||
@@ -288,0 +284,0 @@ for (var _b = __values(this.groups), _c = _b.next(); !_c.done; _c = _b.next()) { |
@@ -50,5 +50,16 @@ import { IDisposable } from './lifecycle'; | ||
export declare function addDisposableListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): IDisposable; | ||
export declare class TickDelayedEvent implements IDisposable { | ||
private timer; | ||
/** | ||
* | ||
* Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle. | ||
* | ||
* It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle. | ||
* This implementation exists to avoid external dependencies. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask | ||
* @see https://rxjs.dev/api/index/const/asapScheduler | ||
*/ | ||
export declare class AsapEvent implements IDisposable { | ||
private readonly _onFired; | ||
private _currentFireCount; | ||
private _queued; | ||
readonly onEvent: Event<void>; | ||
@@ -55,0 +66,0 @@ fire(): void; |
@@ -153,14 +153,45 @@ export var Event; | ||
} | ||
export class TickDelayedEvent { | ||
/** | ||
* | ||
* Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle. | ||
* | ||
* It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle. | ||
* This implementation exists to avoid external dependencies. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask | ||
* @see https://rxjs.dev/api/index/const/asapScheduler | ||
*/ | ||
export class AsapEvent { | ||
constructor() { | ||
this._onFired = new Emitter(); | ||
this.onEvent = this._onFired.event; | ||
this._currentFireCount = 0; | ||
this._queued = false; | ||
this.onEvent = (e) => { | ||
/** | ||
* when the event is first subscribed to take note of the current fire count | ||
*/ | ||
const fireCountAtTimeOfEventSubscription = this._currentFireCount; | ||
return this._onFired.event(() => { | ||
/** | ||
* if the current fire count is greater than the fire count at event subscription | ||
* then the event has been fired since we subscribed and it's ok to "on_next" the event. | ||
* | ||
* if the count is not greater then what we are recieving is an event from the microtask | ||
* queue that was triggered before we actually subscribed and therfore we should ignore it. | ||
*/ | ||
if (this._currentFireCount > fireCountAtTimeOfEventSubscription) { | ||
e(); | ||
} | ||
}); | ||
}; | ||
} | ||
fire() { | ||
if (this.timer) { | ||
clearTimeout(this.timer); | ||
this._currentFireCount++; | ||
if (this._queued) { | ||
return; | ||
} | ||
this.timer = setTimeout(() => { | ||
this._queued = true; | ||
queueMicrotask(() => { | ||
this._queued = false; | ||
this._onFired.fire(); | ||
clearTimeout(this.timer); | ||
}); | ||
@@ -167,0 +198,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Event, TickDelayedEvent } from '../events'; | ||
import { Event, AsapEvent } from '../events'; | ||
import { Gridview, IGridView } from './gridview'; | ||
@@ -54,4 +54,2 @@ import { Position } from '../dnd/droptarget'; | ||
protected _activeGroup: T | undefined; | ||
private _onDidLayoutChange; | ||
readonly onDidLayoutChange: Event<void>; | ||
private readonly _onDidRemove; | ||
@@ -63,3 +61,4 @@ readonly onDidRemove: Event<T>; | ||
readonly onDidActiveChange: Event<T | undefined>; | ||
protected readonly _bufferOnDidLayoutChange: TickDelayedEvent; | ||
protected readonly _bufferOnDidLayoutChange: AsapEvent; | ||
readonly onDidLayoutChange: Event<void>; | ||
get id(): string; | ||
@@ -66,0 +65,0 @@ get size(): number; |
@@ -1,2 +0,2 @@ | ||
import { Emitter, Event, TickDelayedEvent } from '../events'; | ||
import { Emitter, Event, AsapEvent } from '../events'; | ||
import { getGridLocation, Gridview } from './gridview'; | ||
@@ -64,4 +64,2 @@ import { Disposable } from '../lifecycle'; | ||
this._groups = new Map(); | ||
this._onDidLayoutChange = new Emitter(); | ||
this.onDidLayoutChange = this._onDidLayoutChange.event; | ||
this._onDidRemove = new Emitter(); | ||
@@ -73,3 +71,4 @@ this.onDidRemove = this._onDidRemove.event; | ||
this.onDidActiveChange = this._onDidActiveChange.event; | ||
this._bufferOnDidLayoutChange = new TickDelayedEvent(); | ||
this._bufferOnDidLayoutChange = new AsapEvent(); | ||
this.onDidLayoutChange = this._bufferOnDidLayoutChange.onEvent; | ||
this.element.style.height = '100%'; | ||
@@ -89,4 +88,2 @@ this.element.style.width = '100%'; | ||
this._bufferOnDidLayoutChange.fire(); | ||
}), this._bufferOnDidLayoutChange.onEvent(() => { | ||
this._onDidLayoutChange.fire(); | ||
}), this._bufferOnDidLayoutChange); | ||
@@ -96,3 +93,3 @@ } | ||
this.gridview.setViewVisible(getGridLocation(panel.element), visible); | ||
this._onDidLayoutChange.fire(); | ||
this._bufferOnDidLayoutChange.fire(); | ||
} | ||
@@ -203,3 +200,2 @@ isVisible(panel) { | ||
this._onDidRemove.dispose(); | ||
this._onDidLayoutChange.dispose(); | ||
for (const group of this.groups) { | ||
@@ -206,0 +202,0 @@ group.dispose(); |
{ | ||
"name": "dockview-core", | ||
"version": "1.13.0", | ||
"version": "1.13.1", | ||
"description": "Zero dependency layout manager supporting tabs, grids and splitviews", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11931342
90695