All files / src/ts/pkjs plugin-texts.ts

100% Statements 3/3
100% Branches 2/2
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                26x               189x                 230x        
/**
 * The face's own wording for the plugin rows and the supported plugins panel, held where every plugin
 * source page reads it.
 *
 * A face passes it to startPebbleApp as `pluginTexts`. faceStart keeps it here, and it is what the
 * phone, the build's own page load, and clay-preview all start the face through, so each of them opens
 * the page in the face's words. pluginSourcePage reads it for every kind and the panel, so no feature
 * or driver hands it on, and a new kind gets it without asking.
 *
 * This file is in every face's phone bundle, since app.ts sets it, so it holds the wording alone and
 * imports nothing but types.
 */
 
import type { PluginTextOverrides } from '../plugin-sources/page';
 
/** The wording the face started with, empty for a face that passes none. */
let held: PluginTextOverrides = {};
 
/**
 * Keeps the face's wording for every plugin source page from here on, in place of any kept before.
 *
 * @param texts What the face passed as `pluginTexts`, or undefined for none.
 */
export function keepPluginTexts(texts: PluginTextOverrides | undefined): void {
  held = texts || {};
}
 
/**
 * The face's own wording, as faceStart last kept it.
 *
 * @return The wording by kind and for the panel, empty when the face passed none.
 */
export function pluginTexts(): PluginTextOverrides {
  return held;
}
 
export default { keepPluginTexts, pluginTexts };