release: bump version to 0.50.0
This commit is contained in:
@@ -14,6 +14,7 @@ export class CruiseSequencer {
|
||||
hideItem,
|
||||
clearCurrent,
|
||||
onStop,
|
||||
presentationMode = "auto_advance",
|
||||
dwellMs = 2400,
|
||||
transitionGapMs = 24,
|
||||
}) {
|
||||
@@ -25,6 +26,7 @@ export class CruiseSequencer {
|
||||
this.hideItem = hideItem;
|
||||
this.clearCurrent = clearCurrent;
|
||||
this.onStop = onStop;
|
||||
this.presentationMode = presentationMode === "pinned" ? "pinned" : "auto_advance";
|
||||
this.dwellMs = dwellMs;
|
||||
this.transitionGapMs = transitionGapMs;
|
||||
|
||||
@@ -39,11 +41,12 @@ export class CruiseSequencer {
|
||||
this.primaryTimerId = null;
|
||||
this.secondaryTimerId = null;
|
||||
this.presentationVisible = false;
|
||||
this.currentItem = null;
|
||||
}
|
||||
|
||||
getCurrentItem() {
|
||||
if (!this.currentItemId) return null;
|
||||
return this.getItems().find((item) => this.getItemId(item) === this.currentItemId) || null;
|
||||
return this.getItems().find((item) => this.getItemId(item) === this.currentItemId) || this.currentItem || null;
|
||||
}
|
||||
|
||||
getCurrentItemId() {
|
||||
@@ -58,6 +61,10 @@ export class CruiseSequencer {
|
||||
return this.advanceInFlight || this.presentationVisible;
|
||||
}
|
||||
|
||||
isPinnedMode() {
|
||||
return this.presentationMode === "pinned";
|
||||
}
|
||||
|
||||
enqueue(itemIds = []) {
|
||||
if (!Array.isArray(itemIds) || itemIds.length === 0) return;
|
||||
this.queuedItemIds = Array.from(
|
||||
@@ -91,12 +98,14 @@ export class CruiseSequencer {
|
||||
}
|
||||
if (!preservePresentation) {
|
||||
this.presentationVisible = false;
|
||||
this.currentItem = null;
|
||||
this.clearCurrent?.();
|
||||
}
|
||||
}
|
||||
|
||||
stop({ preservePresentation = false } = {}) {
|
||||
this.interruptPresentation({ preservePresentation });
|
||||
this.currentItem = preservePresentation ? this.currentItem : null;
|
||||
this.currentItemId = preservePresentation ? this.currentItemId : null;
|
||||
this.currentIndex = preservePresentation ? this.currentIndex : -1;
|
||||
this.queuedItemIds = [];
|
||||
@@ -145,15 +154,11 @@ export class CruiseSequencer {
|
||||
return items[nextIndex] || items[0] || null;
|
||||
}
|
||||
|
||||
async performAdvance({ interrupt = false } = {}) {
|
||||
async presentResolvedItem(targetItem, { interrupt = false } = {}) {
|
||||
if (!this.isActive()) return;
|
||||
|
||||
const items = this.getItems();
|
||||
if (!Array.isArray(items) || items.length === 0) return;
|
||||
|
||||
const targetItem = this.resolveNextItem(items);
|
||||
if (!targetItem) return;
|
||||
|
||||
const items = this.getItems();
|
||||
const token = ++this.sequenceToken;
|
||||
const context = this.createContext(token);
|
||||
|
||||
@@ -161,10 +166,11 @@ export class CruiseSequencer {
|
||||
this.presentationVisible = false;
|
||||
this.clearCurrent?.();
|
||||
|
||||
this.currentItem = targetItem;
|
||||
this.currentItemId = this.getItemId(targetItem);
|
||||
this.currentIndex = items.findIndex(
|
||||
(item) => this.getItemId(item) === this.currentItemId,
|
||||
);
|
||||
this.currentIndex = Array.isArray(items)
|
||||
? items.findIndex((item) => this.getItemId(item) === this.currentItemId)
|
||||
: -1;
|
||||
|
||||
await this.focusItem?.(targetItem, { interrupt, context });
|
||||
if (!context.isCurrent()) {
|
||||
@@ -179,6 +185,10 @@ export class CruiseSequencer {
|
||||
}
|
||||
|
||||
this.presentationVisible = true;
|
||||
if (this.isPinnedMode()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const dwellCompleted = await context.wait(this.dwellMs);
|
||||
if (!dwellCompleted || !context.isCurrent()) {
|
||||
this.presentationVisible = false;
|
||||
@@ -198,6 +208,26 @@ export class CruiseSequencer {
|
||||
}
|
||||
|
||||
void this.advance();
|
||||
return true;
|
||||
}
|
||||
|
||||
async performAdvance({ interrupt = false } = {}) {
|
||||
if (!this.isActive()) return;
|
||||
|
||||
const items = this.getItems();
|
||||
if (!Array.isArray(items) || items.length === 0) return;
|
||||
|
||||
const targetItem = this.resolveNextItem(items);
|
||||
return this.presentResolvedItem(targetItem, { interrupt });
|
||||
}
|
||||
|
||||
async presentSpecificItem(item, { interrupt = false } = {}) {
|
||||
if (!this.isActive() || !item) return false;
|
||||
this.advanceLoopToken += 1;
|
||||
this.advanceQueued = false;
|
||||
this.advanceInterrupt = false;
|
||||
this.advanceInFlight = false;
|
||||
return Boolean(await this.presentResolvedItem(item, { interrupt }));
|
||||
}
|
||||
|
||||
async advance({ interrupt = false } = {}) {
|
||||
|
||||
Reference in New Issue
Block a user