Global

Members

(constant) DEFAULT_CAT_PRIORITY

Description:
  • The default category priority when a folder's sidecar sets none (lower = higher in the picker).

Source:

The default category priority when a folder's sidecar sets none (lower = higher in the picker).

(constant) DEFAULT_INTENSITY

Description:
  • Build the {#name} block stage bound to a loader (loader-injected port; suffix-resolved, auto-fx/artists, danbooru substitution).

Source:

Build the {#name} block stage bound to a loader (loader-injected port; suffix-resolved, auto-fx/artists, danbooru substitution).

(constant) DPL_INSERT_CATALOG

Description:
  • The categories and their constructs. Language-neutral: ids, DPL syntax, snippet templates, examples.

Source:

The categories and their constructs. Language-neutral: ids, DPL syntax, snippet templates, examples.

(constant) MAX_GROUP_DEPTH

Description:
  • Recursion cutoff for group-includes-group nesting.

Source:

Recursion cutoff for group-includes-group nesting.

(constant) NSFW_TOKEN :RegExp

Description:
  • Matches an nsfw token: a standalone word in a list name, delimited by a path separator, dash, dot, underscore, or the start/end of the string. So d/general-nsfw, clothes-nsfw, foo.nsfw.bar all match, but nsfwish does not.

Source:

Matches an nsfw token: a standalone word in a list name, delimited by a path separator, dash, dot, underscore, or the start/end of the string. So d/general-nsfw, clothes-nsfw, foo.nsfw.bar all match, but nsfwish does not.

Type:
  • RegExp

(constant) RESERVED_ANY :string

Description:
  • Reserved wildcard base: {#any} (and {#any-sfw} / {#any-nsfw}) is not a file — it runs one random generator drawn from the whole v2 catalog, mode-aware. Reserved like the lists' {keyword}.

Source:

Reserved wildcard base: {#any} (and {#any-sfw} / {#any-nsfw}) is not a file — it runs one random generator drawn from the whole v2 catalog, mode-aware. Reserved like the lists' {keyword}.

Type:
  • string

(constant) RESERVED_WILDCARD :string

Description:
  • Reserved wildcard base. {keyword} (and {keyword-sfw} / {keyword-nsfw}) are not files — they resolve to a random word drawn from ALL loaded vocabulary (mode-aware). The name is reserved: it always supersedes any list literally named keyword, silently (no error), the same way nsfw is a reserved filename token.

Source:

Reserved wildcard base. {keyword} (and {keyword-sfw} / {keyword-nsfw}) are not files — they resolve to a random word drawn from ALL loaded vocabulary (mode-aware). The name is reserved: it always supersedes any list literally named keyword, silently (no error), the same way nsfw is a reserved filename token.

Type:
  • string

(constant) RNG

Description:
  • The DPL random seam — every method draws from the ambient source via randomFloat.

Source:

The DPL random seam — every method draws from the ambient source via randomFloat.

(constant) SFW_SUFFIX

Description:
  • Suffix tokens that select an exclusive SFW or NSFW-inclusive variant.

Source:

Suffix tokens that select an exclusive SFW or NSFW-inclusive variant.

(constant) blockTags :Object.<string, {category: (string|undefined), anime: (boolean|undefined), nsfw: (boolean|undefined)}>

Description:
  • Per-generator tag metadata (the analog of listTags): a category plus anime/nsfw flags, for UI badges and docs. The category is normally derivable from the folder; this map only needs entries that carry extra flags. Anything absent defaults to { anime:false, nsfw:false }.

Source:

Per-generator tag metadata (the analog of listTags): a category plus anime/nsfw flags, for UI badges and docs. The category is normally derivable from the folder; this map only needs entries that carry extra flags. Anything absent defaults to { anime:false, nsfw:false }.

Type:
  • Object.<string, {category: (string|undefined), anime: (boolean|undefined), nsfw: (boolean|undefined)}>

(constant) browserLoader :object

Description:
  • Browser data loader for the engine. Names/structure are served synchronously from the bundle's glob keys; contents (list lines, generators, descriptions, presets) come from the code-split chunk loaded by initBrowserCatalog and read as empty/null until it resolves.

Source:

Browser data loader for the engine. Names/structure are served synchronously from the bundle's glob keys; contents (list lines, generators, descriptions, presets) come from the code-split chunk loaded by initBrowserCatalog and read as empty/null until it resolves.

Type:
  • object

(constant) engineDefaults

Source:

(constant) listTags :Object.<string, {category: (string|undefined), anime: (boolean|undefined), nsfw: (boolean|undefined)}>

Description:
  • Per-list metadata. Any list not listed here defaults to { anime:false, nsfw:false }. nsfw:true means the list as a whole leans adult (still drawn only when includeAdult is on if it is also gated).

Source:

Per-list metadata. Any list not listed here defaults to { anime:false, nsfw:false }. nsfw:true means the list as a whole leans adult (still drawn only when includeAdult is on if it is also gated).

Type:
  • Object.<string, {category: (string|undefined), anime: (boolean|undefined), nsfw: (boolean|undefined)}>

(constant) metroLoader :object

Description:
  • Metro data loader for the engine — the synchronous, static-catalog analog of nodeLoader/browserLoader. Implements readListLines, listNames, loadBlock, blockNames, and the group/marker/meta/preset accessors.

Source:

Metro data loader for the engine — the synchronous, static-catalog analog of nodeLoader/browserLoader. Implements readListLines, listNames, loadBlock, blockNames, and the group/marker/meta/preset accessors.

Type:
  • object

(constant) nodeLoader :object

Description:
  • Node data loader for the engine: filesystem reads + createRequire block loading. Implements readListLines, listNames, loadBlock, blockNames. Reads the app's built-in data/ content AND the user overlay under user/ (user wins on a name clash).

Source:

Node data loader for the engine: filesystem reads + createRequire block loading. Implements readListLines, listNames, loadBlock, blockNames. Reads the app's built-in data/ content AND the user overlay under user/ (user wins on a name clash).

Type:
  • object

Methods

adultAllowed() → {boolean}

Source:
Returns:

Whether adult/explicit lists and prompts are enabled.

Type
boolean

allListNames(names) → {Array.<string>}

Source:
Parameters:
Name Type Description
names Array.<string>

The on-disk list + group names (no extension).

Returns:

De-duplicated, in the guaranteed natural order (compareNames).

Type
Array.<string>

applyIntensityMod()

Description:
  • Apply a relative modifier to an intensity, clamped to 1..100. A signed percent is taken of the value+25 → ×1.25, -25 → ×0.75 ("25% more/less of the intensity"). null/"" → unchanged.

Source:

applyPreset(base, preset) → {object}

Description:
  • Apply a preset's legacy-shaped object onto flat settings. preset.settings merges flat; the legacy imageSettings / upscaleSettings sub-objects are mapped onto the flat keys the providers read (width→imageWidth, height→imageHeight, steps→imageSteps, …). Later presets/flags override.

Source:
Parameters:
Name Type Description
base object

The current flat settings.

preset object

A preset object.

Returns:

The merged settings.

Type
object

artistRepeater(artist, alias, settings) → {string}

Description:
  • Emit a random number of artist tokens — gated by settings.includeArtist and a 50% coin flip — between settings.minArtist and settings.maxArtist.

Source:
Parameters:
Name Type Description
artist string

The repeat target.

alias boolean

Whether to resolve via the alias.

settings object

The merged generation settings.

Returns:

The joined artist tokens (possibly "").

Type
string

autoGroupListDirs(listNames, enableDirsopt, disableDirsopt) → {Array.<string>}

Description:
  • Folders that are IMPLIED groups: a folder with 2+ direct list files is auto-marked (referenceable as {folder} = union of its own lists). An enable-group-list marker forces a folder on (even with one list); a disable-group-list marker forces it off. Does NOT stack — only the folder's own direct lists count, not its subfolders.

Source:
Parameters:
Name Type Attributes Description
listNames Array.<string>

Logical LIST names (txt-derived; groups excluded).

enableDirs Array.<string> <optional>

Folders forced on (.enable-group-list).

disableDirs Array.<string> <optional>

Folders forced off (.disable-group-list).

Returns:

The implied-group folder paths.

Type
Array.<string>

blockNames() → {Array.<string>}

Source:
Returns:

Every block generator name (natural sort).

Type
Array.<string>

blockTokens() → {Array.<string>}

Description:
  • The block generator names to suggest/complete, honouring adult gating via the suggestion builder's classification (user-submitted + excluded generators are kept out of the random pool but still shown here for reference).

Source:
Returns:

Block token names.

Type
Array.<string>

bootNodeEngine() → {Object}

Description:
  • Boot the engine + suggestion catalog once (idempotent). The suggestion builder reads the live settings (for NSFW gating) via setActiveSettings.

Source:
Returns:
Type
Object

buildBlocks(loader, optsopt) → {Array.<object>}

Description:
  • Build the categorized building-block groups (Blocks = the generators, Lists = the word lists).

    Within Blocks, the category/folder pills are ordered by each category's sidecar priority (ascending; default 1000), with the virtual any (0) leading and special (9000) trailing.

Source:
Parameters:
Name Type Attributes Description
loader object

The content loader (nodeLoader / runtimeLoader / metroLoader).

opts object <optional>
Properties
Name Type Attributes Description
includeAdult boolean <optional>

When false (default), NSFW generators are hidden entirely and any category that empties out is dropped.

Returns:

The Blocks + Lists groups.

Type
Array.<object>

buildDplCompletions(loader, optsopt) → {Array.<{token: string, label: string, kind: ("gen"|"list"), description: (string|undefined), group: string, category: string}>}

Description:
  • Flatten the building-block catalog into autocomplete entries for the DPL editor.

Source:
Parameters:
Name Type Attributes Description
loader object

The content loader.

opts object <optional>

Same options as buildBlocks.

Returns:

The completion entries.

Type
Array.<{token: string, label: string, kind: ("gen"|"list"), description: (string|undefined), group: string, category: string}>

buildInsertMenu(labellers) → {Array.<object>}

Description:
  • Attach a target's label layer to the shared grammar, producing the menu the UI renders.

Source:
Parameters:
Name Type Description
labellers object
Returns:

The catalog with label/hint/desc filled in.

Type
Array.<object>

buildTree(lines, depth, startopt) → {Object}

Description:
  • Recursively group depth-tagged lines into { line, children } nodes.

Source:
Parameters:
Name Type Attributes Default Description
lines Array

The (remaining) lexed lines.

depth number

The depth level being collected.

start number <optional>
0

Index to start from.

Returns:

Nodes at this depth and the next index.

Type
Object

camelId(id) → {string}

Description:
  • one-of-nothingoneOfNothing. The label key a target uses for an entry is derived from its id, so a new construct can't be added to the grammar without a label existing for it (the coverage test in tests/unit/dplInsertCatalog.test.js fails). One id, one name, in every target.

Source:
Parameters:
Name Type Description
id string

A catalog category key or item id.

Returns:

The camelCase form.

Type
string

charRank(ch) → {number}

Description:
  • Class rank for a single character: symbols (0) sort before digits (1) before letters (2). Gives a guaranteed, predictable ordering.

Source:
Parameters:
Name Type Description
ch string

A single character.

Returns:

0 symbol, 1 digit, 2 letter.

Type
number

clampDial()

Description:
  • Clamp a percent capture to an integer 1..100 (absent/NaN → default, 0 → 1, >100 → 100).

Source:

clampFocus()

Description:
  • Normalize a focus argument to an integer 1..100 (undefined → default, 0 → 1, >100 → 100).

Source:

clampIntensity()

Description:
  • Normalize an intensity argument to an integer 1..100 (undefined → default, 0 → 1, >100 → 100).

Source:

classifyRemoval(line, optsopt) → {Object|null}

Description:
  • Classify a single list line for removal.

Source:
Parameters:
Name Type Attributes Description
line string

Raw line.

opts object <optional>
Properties
Name Type Attributes Default Description
listType "proper" | "content" <optional>
"content"

Proper lists (cities, names, artists, parts of speech) get core slurs + minor-sexual matched EXACTLY (whole entry); content lists get the full set with token matching.

Returns:

Category + matched term, or null when clean.

Type
Object | null

compareNames(a, b) → {number}

Description:
  • Natural-order comparator giving a GUARANTEED load/precedence order: symbols first, then numbers in true numeric order (so 2 before 10), then letters alphabetically. Lets users engineer a deterministic default by prefixing a name with a symbol or number.

Source:
Parameters:
Name Type Description
a string

First name.

b string

Second name.

Returns:

Negative, zero, or positive.

Type
number

compileDpl(source, bridgeopt) → {Object}

Description:
  • Compile a .dpl source into a block module object (same shape as a JS generator).

Source:
Parameters:
Name Type Attributes Description
source string

The .dpl file text.

bridge object <optional>

Optional JS bridge: { resolveJs(path, ctx) } for {js:} / insert js: / script.

Returns:

The module.

Type
Object

computeButtonNames(names, forcedDirsopt) → {Object.<string, string>}

Description:
  • Compute the SHORTEST unambiguous display token for each list, for editor buttons. By default a list shows just its filename; a name only grows a folder prefix when it would otherwise be ambiguous.

    Two stages:

    1. Manual prefix (.force-prefix) — any name under a folder marked with a .force-prefix file shows its path from the highest such ancestor down (e.g. danbooru/d/generald/general). These are excluded from the auto step, so they never push a prefix onto anyone else.
    2. Auto prefix — the rest start at the bare filename; whenever two share a token they each step out one more folder until distinct.

    A final pass guarantees every token resolveName()s back to its own canonical name (lengthening if a forced/other name would otherwise shadow it).

Source:
Parameters:
Name Type Attributes Description
names Array.<string>

Canonical (logical) list names.

forcedDirs Array.<string> <optional>

Folders that contain a .force-prefix marker.

Returns:

Map of canonical name → display token.

Type
Object.<string, string>

condPasses()

Description:
  • Evaluate a dial condition ({op, value}) against the current dial value (intensity or focus).

Source:

configure(_loader) → {void}

Description:
  • Inject the data loader (fs in Node, glob in the browser). Call once before loadAll().

Source:
Parameters:
Name Type Description
_loader object

The loader implementation.

Returns:
Type
void

consumeBracket()

Description:
  • Consume a leading [weight|cond…] bracket from t, recording onto out; no-op if not a spec.

Source:

convert()

Description:
  • Replace every clean emphasis group via re (one capture: open run, inner, close run).

Source:

createEngine(loader) → {Object}

Description:
  • Create a framework-agnostic prompt engine that runs the same pipeline as the CLI.

Source:
Parameters:
Name Type Description
loader object

Data-access loader (Node fs or browser glob): readListLines, listNames, loadBlock.

Returns:

The engine API.

Type
Object

createPromptRun(engine, optsopt)

Description:
  • Build the shared prompt-run surface over an already-booted engine. Every target that generates prompts uses this instead of re-implementing the seed/reroll rules.

Source:
Parameters:
Name Type Attributes Description
engine Object

An engine from createEngine(loader).

opts object <optional>
Properties
Name Type Attributes Description
setActiveSettings function <optional>

Called with the run's settings before each generation so the engine's NSFW gating / cleanup honour the active includeAdult flag (Node targets pass this; the browser facade reads settings a different way and may omit it).

Returns:

createRng(seedopt) → {Rng}

Description:
  • Create an Rng. With no seed (or an empty one) a fresh random seed is generated and recorded on the returned instance's .seed, so a caller can capture it to reproduce the run later.

Source:
Parameters:
Name Type Attributes Description
seed string | number <optional>

The seed; omitted → a random one.

Returns:

The generator.

Type
Rng

cyrb128(str)

Description:
  • cyrb128 — hash a string into four 32-bit unsigned integers of seed state. Public-domain algorithm (bryc). Distinct strings give well-separated state, so "1" and "2" are unrelated streams.

Source:
Parameters:
Name Type Description
str string

The seed string.

Returns:

danbooruReplacer()

Description:
  • Substitute , Person with the danbooru person token when a danbooru keyword file is active.

Source:

dedupeLines(lines) → {Object}

Description:
  • Drop duplicate entries (case-insensitive, trimmed; keeps the first occurrence and original order).

Source:
Parameters:
Name Type Description
lines Array.<string>

The entries.

Returns:

The de-duplicated entries and how many were removed.

Type
Object

depthToIntensity()

Description:
  • Bracket depth (≥1) → intensity percent. De-emphasis floors at 1 (never 0); emphasis caps at 100.

Source:

dialExcluded() → {boolean}

Description:
  • Hard dial conditions ([i<10%], [f<40%]): deterministic include/exclude, evaluated BEFORE any probability roll. Both an intensity and a focus condition may apply; both must pass to keep the line.

Source:
Returns:

True when the node is excluded by a failing dial condition.

Type
boolean

dpJsModule(key) → {object|null}

Description:
  • The loaded .js generator module for a key (or null). Exposed so the runtime loader (gui/src/lib/runtimeLoader.js) can execute .js-module generators and resolve .dpl JS sidecars — the one thing that can't be loaded from disk text at runtime (it would need eval). Returns null until initBrowserCatalog has resolved.

Source:
Parameters:
Name Type Description
key string

The generator/sidecar key (e.g. "scene/castle").

Returns:

The ESM module namespace (with .default), or null if not loaded.

Type
object | null

dynGroupDirs(names, enableDirsopt, disableDirsopt) → {Array.<string>}

Description:
  • The category folders that are IMPLIED groups: a v2 folder with 2+ generators. Reuses the list rule (autoGroupListDirs) over the v2 names only (v1/ is excluded — it is reached via {#name-v1}, never grouped). Marker dirs force a folder on/off.

Source:
Parameters:
Name Type Attributes Description
names Array.<string>

All block catalog names.

enableDirs Array.<string> <optional>

Folders forced on (_enable-group-list).

disableDirs Array.<string> <optional>

Folders forced off (_disable-group-list).

Returns:

The implied-group folder paths.

Type
Array.<string>

dynGroupMembers(dir, names) → {Array.<string>}

Description:
  • Direct-child generator names of a group folder (NOT descendants — groups don't stack).

Source:
Parameters:
Name Type Description
dir string

The folder path (e.g. "v2/scene").

names Array.<string>

All block catalog names.

Returns:

The member generator keys.

Type
Array.<string>

editIn(settings, keyword) → {string}

Description:
  • Prompt-editing "edit-in": [kw:n] — kw appears after step n.

Source:
Parameters:
Name Type Description
settings object

The merged generation settings (keywordEditingMin/Max).

keyword string

The keyword.

Returns:

The edit-in form.

Type
string

editOut(settings, keyword) → {string}

Description:
  • Prompt-editing "edit-out": [kw::n] — kw drops at step n.

Source:
Parameters:
Name Type Description
settings object

The merged generation settings (keywordEditingMin/Max).

keyword string

The keyword.

Returns:

The edit-out form.

Type
string

effectiveGate() → {Object}

Description:
  • The node's effective gate. An explicit gate (NN%/maybe/NN% chance/otherwise) always wins; a bare simple-clause bullet (plain text / token / ref) defaults to 50%. Structural bullets (one of / repeat / block) and plain (non-bullet) lines are unconditional. A probability gate is auto-scaled by the current intensity (scaleGate); the bare-otherwise gate of 1 is not.

Source:
Returns:
Type
Object

expandPrompt(prompt, settings) → {string}

Description:
  • Expand a prompt for a PREVIEW / illustrative example — always re-rolls a fresh example, independent of the user's pinned seed (never reads or advances promptSeed). The caller's settings object is never mutated.

Source:
Parameters:
Name Type Description
prompt string

The DPL/prompt to expand.

settings object

The generation settings (seed fields are ignored).

Returns:

A fresh, randomly-rolled expansion.

Type
string

expandPromptSeeded(prompt, settings) → {string}

Description:
  • Expand a prompt HONOURING the current seed settings (so a pinned roll reproduces it). Used for the real negative-prompt roll (part of the generated image), not for previews.

Source:
Parameters:
Name Type Description
prompt string

The DPL/prompt to expand.

settings object

The generation settings.

Returns:

The expanded prompt (deterministic when a seed is pinned).

Type
string

focusWord()

Description:
  • The natural-language word for a focus percent 1..100 (the $focus-word token); loose → topic-only.

Source:

forEngine(settings, explicitSeedopt) → {object}

Description:
  • Translate app settings into the shape the core engine wants: the image-provider seed is dropped (it's a different field), and the engine seed is resolved via seedFor.

Source:
Parameters:
Name Type Attributes Description
settings object

The generation settings.

explicitSeed string | number <optional>

A caller-forced seed (see seedFor).

Returns:

Engine settings.

Type
object

forcedToken(segs, forced) → {string|null}

Description:
  • The display token from the highest (closest-to-root) forced ancestor folder of segs down, or null when no ancestor folder is forced.

Source:
Parameters:
Name Type Description
segs Array.<string>

The name's /-split segments.

forced Set.<string>

Folders marked with a .force-prefix file.

Returns:
Type
string | null

gateDecision() → {Object}

Description:
  • Decide whether a node runs, given the running prevGateFailed. Rolls a probability gate through the seeded rng. gateBearing (an authored gate, not the default) is what an otherwise pairs against — a non-bearing node never leaves a "failed gate" behind.

Source:
Returns:
Type
Object

gatePool(names, isGated) → {Array.<string>}

Description:
  • Drop gated (adult) names from a pool unless includeAdult is on.

Source:
Parameters:
Name Type Description
names Array.<string>

The candidate names.

isGated function

Predicate: true if a name is adult-gated.

Returns:

The filtered pool.

Type
Array.<string>

generatePrompt(settings, explicitSeedopt) → {string}

Description:
  • Generate one prompt.

Source:
Parameters:
Name Type Attributes Description
settings object

The generation settings.

explicitSeed string | number <optional>

Force this exact seed.

Returns:

The generated prompt.

Type
string

generatePrompts(settings) → {Object}

Description:
  • Generate settings.promptCount prompts (minimum 1) as a reproducible batch. A base seed is always resolved — the explicit/pinned one, or a freshly minted random one — and the engine forks it per prompt (generateMany), so re-running with that base reproduces the whole batch verbatim (still fully random across runs when no seed is pinned).

Source:
Parameters:
Name Type Description
settings object

The generation settings (promptCount).

Returns:

The base seed and the generated prompts.

Type
Object

getAmbientRng()

Source:
Returns:

getRndSalt() → {string}

Source:
Returns:

A fresh random salt token like [1234567890].

Type
string

growUntilDistinct(auto, shown, tok)

Description:
  • Grow each auto name's shown-folder depth (in shown) by one per round until no two names share a token — the collision-resolution fixpoint.

Source:
Parameters:
Name Type Description
auto Array.<string>

The names being auto-tokenized.

shown Map.<string, number>

name → folders currently shown (mutated).

tok

hasNsfwToken(name) → {boolean}

Source:
Parameters:
Name Type Description
name string

A list/group name.

Returns:

Whether the name carries an nsfw token.

Type
boolean

hasVariantSuffix(name) → {boolean}

Source:
Parameters:
Name Type Description
name string

A list/group name.

Returns:

Whether it ends in an explicit -sfw/-nsfw variant suffix.

Type
boolean

impliedGroupMembers(dir, readers) → {Array.<string>}

Description:
  • Member reference lines for an IMPLIED group (a .force-group-list folder): the folder's OWN direct list files only (NOT descendants — implied groups don't stack), de-duplicated to base names (so -sfw/-nsfw pairs become one member resolved mode-aware), excluding real groups. The result feeds the normal group-union path.

Source:
Parameters:
Name Type Description
dir string

The folder path.

readers Object
Returns:

Member reference lines.

Type
Array.<string>

init(_settings) → {void}

Description:
  • Provide the settings accessor used during suggestion cleanup.

Source:
Parameters:
Name Type Description
_settings function

The settings() accessor.

Returns:
Type
void

initBrowserCatalog() → {Promise.<void>}

Description:
  • Load the heavy prompt-corpus content (words, generators, .dpl text, sidecars, presets) from the code-split chunk. Idempotent. Names/structure are already available (from glob keys); this only fills the content maps. Until it resolves, content getters return empty/null.

Source:
Returns:

Resolves once the content is loaded.

Type
Promise.<void>

intensityWord()

Description:
  • The natural-language word for an intensity percent 1..100 (the $intensity-word token).

Source:

isArtistName(loader) → {Object}

Description:
  • Create a loader-backed list store with the original once-only depletion + alias behaviour.

Source:
Parameters:
Name Type Description
loader object

Data loader (readListLines, listNames).

Returns:

The store API.

Type
Object

isDigit(ch)

Source:
Parameters:
Name Type Description
ch string

A single character. @returns {boolean} Whether it is an ASCII digit.

isGatedBlock(name) → {boolean}

Description:
  • Gate a block behind includeAdult AUTOMATICALLY by its name token — the same rule lists/expansions use (isGatedList) — so a generator named e.g. subject/nude-nsfw is hidden/empty when adult is off, with no hardcoded list to keep in sync. The legacy gatedBlocks array is still honored as an extra escape hatch.

Source:
Parameters:
Name Type Description
name string

A block name (path or token).

Returns:

Whether the block is gated behind includeAdult.

Type
boolean

isGatedList(name) → {boolean}

Source:
Parameters:
Name Type Description
name string

A list/group name.

Returns:

Whether the list is gated behind includeAdult (by nsfw token).

Type
boolean

isNsfw(line) → {boolean}

Source:
Parameters:
Name Type Description
line string

Raw line.

Returns:

True if the line reads as ordinary NSFW (adult/nudity). Used for the SFW/NSFW split, NOT for removal.

Type
boolean

isReservedAny(name) → {boolean}

Source:
Parameters:
Name Type Description
name string

A block reference (may carry a -sfw/-nsfw suffix).

Returns:

Whether it is the reserved {#any} wildcard (any variant).

Type
boolean

isReservedWildcard(name) → {boolean}

Source:
Parameters:
Name Type Description
name string

A reference (may carry a -sfw/-nsfw suffix).

Returns:

Whether it is the reserved keyword wildcard (any variant).

Type
boolean

joinPieces(pieces) → {string}

Description:
  • Weighted-sort a list of { weight, text } pieces (stable; ties keep document order) and join the non-empty ones with ", ".

Source:
Parameters:
Name Type Description
pieces Array.<{weight: number, text: string}>

The collected layer pieces.

Returns:

The joined layer text.

Type
string

keywordRepeater(keyword, alias, settings) → {string}

Description:
  • Emit a random number of keyword tokens, between settings.keywordCount and settings.keywordMaxCount.

Source:
Parameters:
Name Type Description
keyword string

The repeat target.

alias boolean

Whether to resolve via the alias.

settings object

The merged generation settings.

Returns:

The joined keyword tokens.

Type
string

lexLines(body) → {Array.<{depth: number, text: string, raw: string}>}

Description:
  • Turn the body into indentation-tagged raw lines. The indent unit is the first indented line's leading whitespace (tab or N spaces), per the spec; depth = indent / unit.

Source:
Parameters:
Name Type Description
body string

The DPL body (front-matter removed).

Returns:

Non-blank logical lines.

Type
Array.<{depth: number, text: string, raw: string}>

listNames() → {Array.<string>}

Source:
Returns:

Every list name (logical names + implied groups).

Type
Array.<string>

loadAll() → {void}

Description:
  • Load the block and list catalogs.

Source:
Returns:
Type
void

loadBlockList() → {object}

Description:
  • Classify every block into full / partial (plus the user-submitted bucket) — the lists used by promptSuggestion() and the web file pickers.

Source:
Returns:

{fullRegular, partialRegular, userFiles, all}.

Type
object

loadListFileList() → {Array.<string>}

Description:
  • Load the list names (and cache the artist-excluded subset).

Source:
Returns:

The list names.

Type
Array.<string>

loadPreset(name) → {object|null}

Description:
  • Load one preset object by name (user root first), or null if unknown/invalid.

Source:
Parameters:
Name Type Description
name string

The preset name.

Returns:

The preset {settings, imageSettings, upscaleSettings} (or null).

Type
object | null

logicalListNames(physical) → {Array.<string>}

Description:
  • Turn the physical on-disk names into the LOGICAL reference set, the names the rest of the app sees. A mixed list is stored as two files, <base>-sfw and <base>-nsfw, with NO <base> file — the bare {base} is implicit, and this exposes all three references (base, base-sfw, base-nsfw). A standalone <base>-nsfw with no <base>-sfw counterpart is exposed only by its gated -nsfw name (NSFW-only).

    Safety rule: a plain <p> file is only a normal SFW list when it has NO <p>-nsfw sibling; if such a sibling exists the plain file is IGNORED (not exposed, not loaded), to force the explicit -sfw/-nsfw split. Only <base>-sfw counts as an SFW source — a stray <base> next to <base>-nsfw does not.

Source:
Parameters:
Name Type Description
physical Array.<string>

The on-disk list + group names (no extension).

Returns:

Logical names, de-duplicated, in guaranteed natural order.

Type
Array.<string>

makeListStage(store) → {function}

Description:
  • Build the {name} list stage bound to a list store (loader-injected port).

Source:
Parameters:
Name Type Description
store object

The list store ({ pull }).

Returns:

The list stage (prompt, settings) => string.

Type
function

materializeTemplate(template) → {string}

Description:
  • Strip an editor template down to plain text — ${1:foo}foo, ${sel} → nothing.

    Needed by any target without a snippet-aware editor (the mobile app has a plain TextInput, not CodeMirror), so it inserts the concrete text instead of the tab-stop form.

Source:
Parameters:
Name Type Description
template string

The template field of a catalog item.

Returns:

Insertable text.

Type
string

mergeNew(pool, candidates) → {Array.<string>}

Description:
  • The candidates not already present in pool (case-insensitive), de-duplicated against each other, in their original order.

Source:
Parameters:
Name Type Description
pool Array.<string>

The existing entries.

candidates Array.<string>

The proposed new entries.

Returns:

The net-new entries.

Type
Array.<string>

module:gui/App() → {JSX.Element}

Description:
  • The application root: owns settings and establishes the i18n boundary so the whole shell (and its localized strings) renders under a configured provider.

Source:
Returns:
Type
JSX.Element

module:gui/components/ApiKeyField(props) → {JSX.Element|null}

Description:
  • A provider's API-key field.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
settings object

The current settings.

setSettings function

Update the settings.

providerId string <optional>

The provider whose key to edit (defaults to the active image provider). "none" / falsy renders nothing.

Returns:
Type
JSX.Element | null

module:gui/components/DialogHost() → {JSX.Element|null}

Description:
  • The dialog host. Takes no props; reads the active dialog from the lib/dialog.js store.

Source:
Returns:

The active modal (via a portal), or null when the queue is empty.

Type
JSX.Element | null

module:gui/components/DplInsertBar(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
props.settings object

Generation settings (for SFW/NSFW-correct live examples).

Returns:
Type
JSX.Element

module:gui/components/DplRefineBar(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
busyMode string <optional>

The mode string currently running (""/undefined when idle).

disabled boolean <optional>

Hard-disable every control (e.g. while saving).

onRefine function

(action) — the picked refine action { id, mode, label, … }.

Returns:
Type
JSX.Element

module:gui/components/DplStatus(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
value string

The DPL text to validate.

className string <optional>

Extra class for placement.

Returns:
Type
JSX.Element

module:gui/components/Gallery(props) → {JSX.Element}

Description:
  • The photo gallery grid (virtualized).

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
items Array.<object>

The feed items (newest first).

loading boolean

Whether the feed is still loading.

query string

The current search query (lives in App).

onQueryChange function

(value).

onOpen function

(item) — open an image in the single view.

onRefresh function

Re-scan the output folder.

onDelete function <optional>

(item) — delete an image (+ sidecar) from disk.

onDeleteMany function <optional>

(paths) — mass-delete images (+ sidecars) from disk.

pending Array.<object> <optional>

Live placeholder descriptors { id, label } for in-flight gens.

Returns:
Type
JSX.Element

module:gui/components/Home(props) → {JSX.Element}

Description:
  • The compose workspace.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
settings object

The current settings.

setSettings function

Update the settings.

onOpenImage function <optional>

Open a generated image (by served path) in the single view.

Returns:
Type
JSX.Element

module:gui/components/InlineImageControls(props) → {JSX.Element|null}

Description:
  • Inline provider image controls (Images + Size).

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
settings object

The current settings.

setSettings function

Update the settings.

Returns:
Type
JSX.Element | null

module:gui/components/LinksMenu() → {JSX.Element}

Source:
Returns:

The header links menu.

Type
JSX.Element

module:gui/components/LivePreview(props) → {JSX.Element}

Source:
Parameters:
Name Type Attributes Description
props object
props.settings object

The generation settings (for the engine).

props.label string <optional>

Tooltip label.

props.triggerClassName string <optional>

Class for the trigger button.

Returns:
Type
JSX.Element

module:gui/components/Manage(props) → {JSX.Element}

Description:
  • The Manage workspace.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
settings object

Current settings (reads includeAdult).

available boolean

Whether the local-mode backend is present.

active boolean

Whether this tab is currently shown.

Returns:
Type
JSX.Element

module:gui/components/ManageBlockEditor(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
entry object

The selected generator entry { root, path, ext, label, hasJsSidecar }.

settings object

App settings (DPL example expansion + includeAdult gating).

onChanged function

Called after a save/rename to hot-apply + refresh the tree. Receives the new logical path on a rename.

Returns:
Type
JSX.Element

module:gui/components/ManageFolderEditor(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
node object

The folder model node { root, path, name, isCategory, forcePrefix, enableGroup, disableGroup }.

onChanged function

Called after a save/rename to hot-apply + refresh. Gets the new path on rename.

Returns:
Type
JSX.Element

module:gui/components/ManageListEditor(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
entry object

The selected { root, path, ext, label, kind } (kind: list | group).

settings object <optional>

App settings — used to reach the rewrite (text) provider + key for AI Expand.

onChanged function

Hot-apply + refresh after a write; gets the new path on rename.

Returns:
Type
JSX.Element

module:gui/components/NsfwToggle(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
settings object

The current settings (includeAdult).

setSettings function

Update the settings.

locked boolean <optional>

When true, the switch is disabled (online build) and clicking it opens the full-version page.

Returns:

The right-aligned NSFW switch (+ its confirm dialog).

Type
JSX.Element

module:gui/components/ProviderBox(props) → {JSX.Element|null}

Description:
  • The provider's own controls (rendered inside the header gear popover).

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
settings object

The current settings.

setSettings function

Update the settings.

providerId string <optional>

Which provider's controls to render. Defaults to the active image provider (settings.provider); the gear accordion passes the text / upscale provider id so one box can drive any provider row.

Returns:
Type
JSX.Element | null

module:gui/components/ProviderGear(props) → {JSX.Element|null}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
settings object

The current settings.

setSettings function

Update the settings.

Returns:
Type
JSX.Element | null

module:gui/components/ProviderPicker(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
label string

Leading label shown on the trigger (e.g. "Image" / "Text").

value string

The selected option id.

props.onPick function

(id) — called when an option is chosen.

Returns:
Type
JSX.Element

module:gui/components/ProvidersMenu(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
settings object

The current settings.

setSettings function

Update the settings.

Returns:
Type
JSX.Element

module:gui/components/Settings(props) → {JSX.Element}

Description:
  • The prompt-knobs form.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
settings object

The current settings.

setSettings function

Update the settings.

Returns:
Type
JSX.Element

module:gui/components/SettingsDrawer(props) → {JSX.Element|null}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
open boolean

Whether the drawer is shown.

onClose function

Close the drawer.

settings object

The current settings.

setSettings function

Update the settings.

Returns:
Type
JSX.Element | null

module:gui/components/SingleView(props) → {JSX.Element}

Description:
  • The single-image view.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
items Array.<object>

The feed (drives prev/next + ancestry resolution).

current object | null

The image being shown.

magick Object

ImageMagick capability.

settings object

App settings (rewrite provider + key for the keyword rebuild).

active boolean

Whether this view is the visible one (gates keyboard nav).

returnLabel string

Label for the Back button target (e.g. "Generate").

onBack function

Leave the single view.

onNavigate function

(item) — show another image (prev/next/parent/child).

onDelete function

(item).

onSearch function

(term) — search the gallery for a keyword.

onMetaUpdate function

(path, meta) — apply a saved sidecar to the feed + view.

onDerive function <optional>

(item, kind, source) — re-roll / vary into a new image.

onResize function <optional>

(item, scale) — resize into a new image (ImageMagick).

derivations Array.<object> <optional>

In-flight derivations { id, parentPath, kind }.

deriveError string <optional>

The last re-roll / variation / resize failure, if any.

Returns:
Type
JSX.Element

module:gui/components/ThemePicker() → {JSX.Element}

Source:
Returns:

The header appearance (theme) picker.

Type
JSX.Element

module:gui/components/TokenPicker(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
tokens Array.<string>

The tokens to show.

onInsert function

Called with the clicked token.

Returns:
Type
JSX.Element

module:gui/components/UpdateBanner() → {JSX.Element|null}

Source:
Returns:

The update banner, or null when there's nothing to offer.

Type
JSX.Element | null

module:gui/components/WrapperFab(props) → {JSX.Element}

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
settings object

Current settings (reads wrapper / wrapperName).

setSettings function

Update settings.

Returns:
Type
JSX.Element

module:gui/components/home/BlockPalette(props) → {JSX.Element}

Description:
  • The building-block palette.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
includeAdult boolean

Whether nsfw-flagged blocks are shown.

Returns:
Type
JSX.Element

module:gui/components/manage/ManageDetail(props) → {JSX.Element}

Description:
  • The right-pane detail/preview for the current selection.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
selected object | null

The selected entry or folder.

Returns:
Type
JSX.Element

module:gui/components/single/DerivedStrips(props) → {JSX.Element|null}

Description:
  • The derived-children grid.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Description
item object

The current gallery item (its children).

items Array.<object>

The feed (to resolve child items).

derivations Array.<object>

In-flight derivations { parentPath, kind }.

onNavigate function

(item) — open a child image.

Returns:
Type
JSX.Element | null

module:gui/components/single/DetailTable()

Description:
  • A <table> of label/value detail rows (empty rows skipped).

Source:

module:gui/components/single/PromptCard()

Description:
  • The prompt (or negative) card: its layers, most-relevant first, dupes collapsed.

Source:

module:gui/i18n/I18nProvider(props) → {JSX.Element}

Description:
  • Wrap the app subtree in a configured <IntlProvider>.

Source:
Parameters:
Name Type Description
props object
Properties
Name Type Attributes Description
locale string <optional>

The stored settings.locale preference ("auto"/empty follows the browser).

Returns:
Type
JSX.Element

normalize(line) → {string}

Description:
  • Normalize a raw list line to a lowercase, single-spaced token string.

Source:
Parameters:
Name Type Description
line string

Raw line.

Returns:

Normalized form, e.g. "long hair".

Type
string

parseAiCandidates(out) → {Array.<string>}

Description:
  • Parse an AI "expand" reply into clean candidate entries — one per line, tolerating a stray - / 1. / list prefix; falls back to comma-separated when the reply is a single line.

Source:
Parameters:
Name Type Description
out string

The raw model reply.

Returns:

The candidate entries (trimmed, non-empty).

Type
Array.<string>

parseArgs(blob) → {Object}

Description:
  • Parse the optional dial-argument blob after a {#name …} token into { intensity, focus }. Args are i/f-prefixed percents ({#name i25% f80%}); the prefix is mandatory (an unprefixed NN% never reaches here — the resolver regex only matches prefixed args).

Source:
Parameters:
Name Type Description
blob string

The captured argument text (may be empty).

Returns:

The two dials (defaults when unspecified).

Type
Object

parseBracketSpec()

Description:
  • Parse the inside of a leading […] bracket into { weight?, iCond?, fCond? }, or null when it is not a weight/condition spec (so [[castle]], [deemph], [a:b:0.5], the salt literal pass through as payload). A weight is bare digits; a condition is [if] OP NN% — the dial prefix i (intensity) or f (focus) is MANDATORY (the two look-alike percents must be disambiguated; an unprefixed OP NN% is not a condition and leaves the bracket as payload). A bracket may stack a weight and one i-condition and one f-condition, separated by a pipe or whitespace, in any order: [100 i<10% f<40%], [f<40%|100].

Source:

parseChoice()

Description:
  • Parse a one of / N of / A to B of choice (optional (NN% nothing) miss) onto out. Returns true when a choice was recorded (the node is then complete).

Source:

parseFlow()

Description:
  • Flow directive at the head of a line (go back / go to X), or null.

Source:

parseFrontMatter(source) → {Object}

Description:
  • Split a leading --- YAML-ish front-matter block from the body.

Source:
Parameters:
Name Type Description
source string

The raw .dpl text.

Returns:

Parsed key/value meta and the remaining body.

Type
Object

parseGate()

Description:
  • Parse a leading gate (otherwise, NN%, maybe, NN% chance) onto out, returning the remaining text. scaleGate marks a probability gate (intensity auto-scales it); a bare otherwise keeps an unscaled gate of 1 (it runs whenever the paired gate failed).

Source:

parseNode(node) → {object}

Description:
  • Parse one tree node's text into a typed descriptor (weight/gate/repeat/choice/ref/payload).

Source:
Parameters:
Name Type Description
node Object

A raw tree node.

Returns:

The typed node (with parsed children).

Type
object

parseRef()

Description:
  • Parse a reference form (insert js: path / insert name / +name) onto out.

Source:

parseRepeat()

Description:
  • Parse a repeat N times / repeat A to B times prefix onto out, returning the remaining text.

Source:

parseSections(lines) → {object}

Description:
  • Parse the lexed lines into { sectionName: nodeTree }. A heading is a text line whose next line is ={3,}; Start is the entry section. Lines under a heading nest by depth.

Source:
Parameters:
Name Type Description
lines Array

Lexed lines from lexLines.

Returns:

Map of section name -> array of child nodes.

Type
object

pickerListNames() → {Array.<string>}

Description:
  • The list names to show in the web picker, honoring adult mode. When adult is off, every name carrying an nsfw token is hidden (the app behaves as if it doesn't exist). When on, each base that has a <base>-nsfw sibling also offers the explicit <base>-sfw reference, so the picker shows all three (default / SFW-only / NSFW).

Source:
Returns:

The picker-facing list names, in load order.

Type
Array.<string>

pickerLists() → {Array.<string>}

Description:
  • The picker-facing list names (honouring the current adult flag).

Source:
Returns:

List names for the {name} reference.

Type
Array.<string>

presetNames() → {Array.<string>}

Description:
  • Every available preset name (union of both roots), sorted.

Source:
Returns:

The preset names (no .json suffix).

Type
Array.<string>

processMdj(settings, lessEmphasis, keyword) → {string}

Description:
  • Midjourney emphasis: append ::factor, factor = 1.05·N up (or its reciprocal down); N is rolled by emphasisLevelChance up to emphasisMaxLevels.

Source:
Parameters:
Name Type Description
settings object

The merged generation settings.

lessEmphasis boolean

De-emphasize rather than emphasize.

keyword string

The keyword to weight.

Returns:

The weighted keyword.

Type
string

processNAI(settings, lessEmphasis, keyword) → {string}

Description:
  • NovelAI emphasis: same nested-bracket leveling as SD (the list stage later rewrites () to {} for NovelAI).

Source:
Parameters:
Name Type Description
settings object

The merged generation settings.

lessEmphasis boolean

De-emphasize rather than emphasize.

keyword string

The keyword to wrap.

Returns:

The wrapped keyword.

Type
string

processPlain(settings, lessEmphasis, keyword) → {string}

Description:
  • Plain (natural-language) emphasis: roll a level like the other dialects, then prefix the keyword with an intensifier (emphasis) or hedge (de-emphasis) word from the ladder — keeping the emphasis the engine rolled instead of dropping it for syntax-less targets.

Source:
Parameters:
Name Type Description
settings object

The merged generation settings.

lessEmphasis boolean

De-emphasize (hedge) rather than emphasize (intensify).

keyword string

The keyword to modify.

Returns:

The (possibly) word-prefixed keyword.

Type
string

processRepeat(count, keyword, alias) → {string}

Description:
  • Build a comma-joined run of count list tokens.

Source:
Parameters:
Name Type Description
count number

How many tokens to emit (<= 0 yields "").

keyword string

The repeat target ("keyword" or "artist").

alias boolean

Whether to resolve via the keyword/artist alias.

Returns:

The joined {token}, {token}, … string.

Type
string

processSd(settings, lessEmphasis, keyword) → {string}

Description:
  • StableDiffusion emphasis: wrap the keyword in N nested () (emphasis) or [] (de-emphasis); N is rolled by emphasisLevelChance up to emphasisMaxLevels.

Source:
Parameters:
Name Type Description
settings object

The merged generation settings.

lessEmphasis boolean

De-emphasize ([]) rather than emphasize (()).

keyword string

The keyword to wrap.

Returns:

The wrapped keyword.

Type
string

promptSuggestion(fullopt) → {string}

Description:
  • Build a random prompt suggestion (the engine behind #random): one to three full blocks, sometimes AND-weighted, with optional garnish, then cleaned up.

Source:
Parameters:
Name Type Attributes Description
full boolean <optional>

Use the richer multi-prompt form.

Returns:

The suggested prompt.

Type
string

pushUnique(out, seenLine, lines)

Description:
  • Append the \r-stripped, non-empty, not-yet-seen lines from lines onto out.

Source:
Parameters:
Name Type Description
out Array.<string>

Accumulator (mutated).

seenLine Set.<string>

Dedup set (mutated).

lines Array.<string>

Candidate lines.

randomFloat()

Description:
  • A uniform float in [0, 1) from the ambient source — the probability-roll primitive.

Source:

randomInt()

Description:
  • A uniform integer in [min, max] inclusive; order-tolerant.

Source:

randomSeed()

Description:
  • A fresh, unpredictable seed string (crypto if available, else time + Math.random).

Source:

readAmbient()

Source:
Returns:

readSfwBase(base, readers) → {Array.<string>|null}

Description:
  • Read a plain list's SFW base lines. Safety rule: when a <base>-nsfw sibling exists, a plain <base>.txt is IGNORED — the SFW source must be the explicit <base>-sfw.txt. This enforces the naming split so a stray <base>.txt can never leak as SFW alongside NSFW (a lone <base>.txt beside <base>-nsfw.txt is thus treated as NSFW-only). With no <base>-nsfw sibling, a plain <base>.txt is a normal SFW list (with <base>-sfw.txt as a fallback). Returns null when no SFW source exists, else an array (possibly empty).

Source:
Parameters:
Name Type Description
base string

Canonical base name (no sfw/nsfw suffix).

readers Object
Returns:
Type
Array.<string> | null

renderChoice()

Description:
  • Choice: pick 1..N options (weighted by each option's leading %), honoring a miss chance. The pick count is scaled by intensity, so low intensity yields fewer (possibly zero) picks.

Source:

renderEmphasis(mode, phrase, depth, lessEmphasis) → {string}

Description:
  • Render one emphasis group into the active dialect.

Source:
Parameters:
Name Type Description
mode string

The engine mode (StableDiffusion | NovelAI | Midjourney | other → plain).

phrase string

The inner text.

depth number

The bracket depth (≥1).

lessEmphasis boolean

De-emphasis ([]) rather than emphasis (()).

Returns:

The dialect-rendered phrase.

Type
string

renderInlineBody()

Description:
  • Render the payload text of a node, substituting inline {js:path} via the bridge.

Source:

renderRef()

Description:
  • Resolve a reference node (call/insert/js-block) to a string.

Source:

renderRepeat()

Description:
  • Repeat: loop count times, rendering the body (payload or child block) each time. The count is scaled by intensity (round(n × intensity/100)), so the dial thins/thickens repetition.

Source:

requireLoader() → {object}

Source:
Throws:

If configure() has not been called.

Type
Error
Returns:

The configured loader.

Type
object

resolveGroup() → {Array.<string>}

Description:
  • A group (real .group file or implied-group folder): the de-duplicated union of its members' lines, propagating the resolved variant, with the depth + cycle guard.

Source:
Returns:

De-duplicated lines.

Type
Array.<string>

resolveListLines(name, readers, includeAdultopt, forcedopt, depthopt, seenopt) → {Array.<string>|null}

Description:
  • Resolve a list/group reference to its lines, honoring the SFW/NSFW naming model and the includeAdult mode. No runtime content filtering — NSFW is a separate preprocessed <base>-nsfw.txt file that is simply included or not.

    Semantics (per reference):

    • {name} → SFW only when adult is off; SFW + <name>-nsfw when on.
    • {name-sfw} → SFW base only (always; the explicit SFW-exclusive reference).
    • {name-nsfw} → nothing when adult is off (acts as if it doesn't exist); SFW + <name>-nsfw when on (the SFW base is auto-tacked on).

    Groups propagate the resolved variant to their members, so {d} (off) is all-SFW, {d} (on) includes NSFW, and {d-sfw} is SFW even when on.

Source:
Parameters:
Name Type Attributes Description
name string

Canonical list/group name (may carry a -sfw/-nsfw suffix).

readers Object
includeAdult boolean <optional>

Whether adult/NSFW content is enabled.

forced "sfw" | "full" | null <optional>

Variant forced by a parent group (internal).

depth number <optional>

Current group-nesting depth (internal).

seen Set.<string> <optional>

Cycle guard (internal).

Returns:

Resolved lines, or null if a plain list is missing.

Type
Array.<string> | null

resolveName(ref, names) → {string}

Description:
  • Resolve a list reference to a canonical list name by PATH-SUFFIX matching, so a prompt can use a bare filename (general), a partial path (danbooru/general), or a full path — and folders can be nested arbitrarily deep. An exact match wins; otherwise any name whose path ends with /<ref> matches, and the shallowest (fewest folders), then alphabetically-first, match is chosen for determinism.

Source:
Parameters:
Name Type Description
ref string

The reference as written in the prompt.

names Array.<string>

All known canonical names (physical paths + virtual names).

Returns:

The resolved canonical name (or ref unchanged if nothing matches).

Type
string

resolvePresets(spec) → {Array.<object>}

Description:
  • Resolve a comma/space-separated preset list into preset objects, in order. Unknown names throw so a typo surfaces rather than silently doing nothing.

Source:
Parameters:
Name Type Description
spec string

The preset spec (e.g. "1k, no-people").

Throws:

If a named preset doesn't exist.

Type
Error
Returns:

The resolved preset objects.

Type
Array.<object>

resolveVariant() → {Object|Object}

Description:
  • Resolve a reference's base name + variant ("sfw" = SFW only, "full" = SFW+NSFW). An explicit -nsfw reference is excluded (invisible) when adult is off or a parent forces SFW.

Source:
Returns:
Type
Object | Object

resolveWildcard() → {Array.<string>}

Description:
  • Reserved keyword wildcard: the union of ALL general vocabulary (mode-aware), excluding the artist/* and danbooru/* namespaces, groups (covered via their lists), and itself.

Source:
Returns:

De-duplicated lines.

Type
Array.<string>

sample()

Description:
  • A uniformly random element of arr (undefined for an empty array).

Source:

scaleCount()

Description:
  • Scale an authored count by intensity: round(n × intensity/100), never below 0.

Source:

scanDigits() → {number}

Source:
Returns:

The index just past the run of digits in s starting at start.

Type
number

seedFor(settings, explicitSeedopt) → {string|undefined}

Description:
  • Which seed (if any) the engine should use for this call. The rule is explicit — there are NO magic seed values:

    1. explicitSeed (when given) always wins. The batch roll uses this to fork one base seed into a distinct-but-reproducible sub-seed per prompt.
    2. Otherwise, when randomSeed is OFF, the run is pinned to promptSeed verbatim (any integer, including 0 and negatives, is honoured).
    3. Otherwise (random on, the default) → undefined: the engine stays unseeded and rerolls fresh. The image-provider seed is NEVER used here — that's a different field.
Source:
Parameters:
Name Type Attributes Description
settings object

The generation settings.

explicitSeed string | number <optional>

A caller-forced seed.

Returns:

The engine seed, or undefined for a random roll.

Type
string | undefined

setActiveSettings(settings) → {void}

Description:
  • Set the settings the suggestion builder / cleanup should read for gating (notably includeAdult). Call before generating so NSFW gating honours the run's settings.

Source:
Parameters:
Name Type Description
settings object

The effective settings.

Returns:
Type
void

setAmbientRng(rng)

Source:
Parameters:
Name Type Description
rng

setMetroOverlay(next)

Description:
  • Replace the runtime user overlay and invalidate the loader caches. Call with empty/omitted maps to clear it (restoring the pure built-in catalog).

Source:
Parameters:
Name Type Description
next

sfc32(a, b, c, d)

Description:
  • sfc32 — Small Fast Counter, a 128-bit-state PRNG returning floats in [0, 1). Public-domain (PractRand-tested). Not cryptographic — it's for reproducible content generation.

Source:
Parameters:
Name Type Description
a number

First 32-bit state word.

b number

Second.

c number

Third.

d number

Fourth.

Returns:

shuffle()

Description:
  • A new array with arr's elements in uniformly random order (Fisher–Yates).

Source:

sortLines(lines) → {Array.<string>}

Description:
  • Sort entries alphabetically (case-insensitive, locale-aware). Non-mutating.

Source:
Parameters:
Name Type Description
lines Array.<string>

The entries.

Returns:

A new, sorted array.

Type
Array.<string>

swapOut(settings, keyword) → {string}

Description:
  • Prompt-editing "swap": [kw:kw:n] — re-assert the keyword at step n.

Source:
Parameters:
Name Type Description
settings object

The merged generation settings (keywordEditingMin/Max).

keyword string

The keyword.

Returns:

The swap form.

Type
string

weightFor()

Description:
  • A dialect weight number for an intensity (50 = ×1.0): trimmed to ≤2 decimals, no trailing zeros.

Source:

weightOf()

Description:
  • A node's explicit weight, or null (used for refs that carry a weight).

Source:

weightedSampleN(opts, n, rng) → {Array}

Description:
  • Pick n distinct options weighted by each option's leading gate %, else uniform. Draws from the render context's rng (ctx.rng) so the pick is part of the seeded stream — not Math.random.

Source:
Parameters:
Name Type Description
opts Array

The option nodes.

n number

How many to pick.

rng Object

The seam's random source.

Returns:

The picked option nodes.

Type
Array

withAmbientRng(rng, fn) → {T}

Description:
  • Install rng as the ambient source for the duration of fn, restoring the previous source afterward (even if fn throws). Nestable. This is how the engine scopes a seeded stream to a single generation.

Source:
Parameters:
Name Type Description
rng
fn
Returns:

Whatever fn returns.

Type
T