recital / exporters / ink / src / utils / next-scene.ts
next-scene.ts
Raw
/**
 * Copyright (c) 2022 Amorphous
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import { FlatObject } from "@a-morphous/recital/dist/types/types"

export const getNextScene = (currentTokenIndex: number, flats: FlatObject[], allowFragment?: boolean) => {
	for (let i = currentTokenIndex + 1; i < flats.length; i++) {
		const target = flats[i]
		if (target.type === 'scene' || (target.type === 'fragment' && allowFragment)) {
			return target
		}
	}
}