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
nsfwtoken: a standalone word in a list name, delimited by a path separator, dash, dot, underscore, or the start/end of the string. Sod/general-nsfw,clothes-nsfw,foo.nsfw.barall match, butnsfwishdoes 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 namedkeyword, silently (no error), the same waynsfwis 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:truemeans 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 +
createRequireblock loading. ImplementsreadListLines,listNames,loadBlock,blockNames. Reads the app's built-indata/content AND the user overlay underuser/(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}
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.settingsmerges flat; the legacyimageSettings/upscaleSettingssub-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.includeArtistand a 50% coin flip — betweensettings.minArtistandsettings.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). Anenable-group-listmarker forces a folder on (even with one list); adisable-group-listmarker 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 ( |
disableDirs |
Array.<string> |
<optional> |
Folders forced off ( |
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 virtualany(0) leading andspecial(9000) trailing.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
loader |
object | The content loader (nodeLoader / runtimeLoader / metroLoader). |
|||||||||
opts |
object |
<optional> |
Properties
|
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-nothing→oneOfNothing. 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 intests/unit/dplInsertCatalog.test.jsfails). 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
|
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
2before10), 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
.dplsource into a block module object (same shape as a JS generator).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
source |
string | The |
|
bridge |
object |
<optional> |
Optional JS bridge: |
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:
- Manual prefix (
.force-prefix) — any name under a folder marked with a.force-prefixfile shows its path from the highest such ancestor down (e.g.danbooru/d/general→d/general). These are excluded from the auto step, so they never push a prefix onto anyone else. - 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).- Manual prefix (
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
names |
Array.<string> | Canonical (logical) list names. |
|
forcedDirs |
Array.<string> |
<optional> |
Folders that contain a |
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 fromt, recording ontoout; 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):
|
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 |
|||||||||
opts |
object |
<optional> |
Properties
|
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
, Personwith 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
.jsgenerator module for a key (or null). Exposed so the runtime loader (gui/src/lib/runtimeLoader.js) can execute.js-module generators and resolve.dplJS 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 ( |
disableDirs |
Array.<string> |
<optional> |
Folders forced off ( |
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 ( |
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 ( |
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-otherwisegate 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-wordtoken); loose → topic-only.
- Source:
forEngine(settings, explicitSeedopt) → {object}
- Description:
Translate app settings into the shape the core engine wants: the image-provider
seedis dropped (it's a different field), and the engineseedis 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
segsdown, or null when no ancestor folder is forced.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
segs |
Array.<string> | The name's |
forced |
Set.<string> | Folders marked with a |
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 anotherwisepairs 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
includeAdultis 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.promptCountprompts (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 ( |
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-listfolder): the folder's OWN direct list files only (NOT descendants — implied groups don't stack), de-duplicated to base names (so-sfw/-nsfwpairs 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 |
Returns:
- Type
- void
initBrowserCatalog() → {Promise.<void>}
- Description:
Load the heavy prompt-corpus content (words, generators,
.dpltext, 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-wordtoken).
- 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 ( |
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
includeAdultAUTOMATICALLY by its name token — the same rule lists/expansions use (isGatedList) — so a generator named e.g.subject/nude-nsfwis hidden/empty when adult is off, with no hardcoded list to keep in sync. The legacygatedBlocksarray 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 |
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 |
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.keywordCountandsettings.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>-sfwand<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>-nsfwwith no<base>-sfwcounterpart is exposed only by its gated-nsfwname (NSFW-only).Safety rule: a plain
<p>file is only a normal SFW list when it has NO<p>-nsfwsibling; if such a sibling exists the plain file is IGNORED (not exposed, not loaded), to force the explicit-sfw/-nsfwsplit. Only<base>-sfwcounts as an SFW source — a stray<base>next to<base>-nsfwdoes 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 ( |
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 |
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
|
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.jsstore.
- 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}
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}
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element
module:gui/components/DplStatus(props) → {JSX.Element}
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
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
|
||||||||||||||||||||||||||||||||||||||||
|
Returns:
- Type
- JSX.Element
module:gui/components/Home(props) → {JSX.Element}
- Description:
The compose workspace.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
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
|
Returns:
- Type
- JSX.Element | null
module:gui/components/LinksMenu() → {JSX.Element}
Returns:
The header links menu.
- Type
- JSX.Element
module:gui/components/LivePreview(props) → {JSX.Element}
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
|
Returns:
- Type
- JSX.Element
module:gui/components/ManageBlockEditor(props) → {JSX.Element}
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element
module:gui/components/ManageFolderEditor(props) → {JSX.Element}
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element
module:gui/components/ManageListEditor(props) → {JSX.Element}
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element
module:gui/components/NsfwToggle(props) → {JSX.Element}
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
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
|
Returns:
- Type
- JSX.Element | null
module:gui/components/ProviderGear(props) → {JSX.Element|null}
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element | null
module:gui/components/ProviderPicker(props) → {JSX.Element}
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
|||||||||
|
|||||||||||
props.onPick |
function |
|
Returns:
- Type
- JSX.Element
module:gui/components/ProvidersMenu(props) → {JSX.Element}
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element
module:gui/components/Settings(props) → {JSX.Element}
- Description:
The prompt-knobs form.
- Source:
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element
module:gui/components/SettingsDrawer(props) → {JSX.Element|null}
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
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
|
Returns:
- Type
- JSX.Element
module:gui/components/ThemePicker() → {JSX.Element}
Returns:
The header appearance (theme) picker.
- Type
- JSX.Element
module:gui/components/TokenPicker(props) → {JSX.Element}
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
Returns:
- Type
- JSX.Element
module:gui/components/UpdateBanner() → {JSX.Element|null}
Returns:
The update banner, or null when there's nothing to offer.
- Type
- JSX.Element | null
module:gui/components/WrapperFab(props) → {JSX.Element}
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
object |
Properties
|
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
|
||||||
|
||||||||
|
||||||||
|
||||||||
|
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
|
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
|
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
|
||||||||
|
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 arei/f-prefixed percents ({#name i25% f80%}); the prefix is mandatory (an unprefixedNN%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 prefixi(intensity) orf(focus) is MANDATORY (the two look-alike percents must be disambiguated; an unprefixedOP 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 ofchoice (optional(NN% nothing)miss) ontoout. 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 |
Returns:
Parsed key/value meta and the remaining body.
- Type
- Object
parseGate()
- Description:
Parse a leading gate (
otherwise,NN%,maybe,NN% chance) ontoout, returning the remaining text.scaleGatemarks a probability gate (intensity auto-scales it); a bareotherwisekeeps 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) ontoout.
- Source:
parseRepeat()
- Description:
Parse a
repeat N times/repeat A to B timesprefix ontoout, 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,};Startis 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
nsfwtoken is hidden (the app behaves as if it doesn't exist). When on, each base that has a<base>-nsfwsibling also offers the explicit<base>-sfwreference, 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 byemphasisLevelChanceup toemphasisMaxLevels.
- 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
countlist 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 byemphasisLevelChanceup toemphasisMaxLevels.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
settings |
object | The merged generation settings. |
lessEmphasis |
boolean | De-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 fromlinesontoout.
- 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>-nsfwsibling exists, a plain<base>.txtis IGNORED — the SFW source must be the explicit<base>-sfw.txt. This enforces the naming split so a stray<base>.txtcan never leak as SFW alongside NSFW (a lone<base>.txtbeside<base>-nsfw.txtis thus treated as NSFW-only). With no<base>-nsfwsibling, a plain<base>.txtis a normal SFW list (with<base>-sfw.txtas a fallback). Returnsnullwhen 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 ( |
phrase |
string | The inner text. |
depth |
number | The bracket depth (≥1). |
lessEmphasis |
boolean | De-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}
Throws:
-
If
configure()has not been called. - Type
- Error
Returns:
The configured loader.
- Type
- object
resolveGroup() → {Array.<string>}
- Description:
A group (real
.groupfile 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
includeAdultmode. No runtime content filtering — NSFW is a separate preprocessed<base>-nsfw.txtfile that is simply included or not.Semantics (per reference):
{name}→ SFW only when adult is off; SFW +<name>-nsfwwhen 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>-nsfwwhen 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 |
|
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
-nsfwreference is excluded (invisible) when adult is off or a parent forces SFW.
- Source:
Returns:
- Type
- Object | Object
resolveWildcard() → {Array.<string>}
- Description:
Reserved
keywordwildcard: 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:
explicitSeed(when given) always wins. The batch roll uses this to fork one base seed into a distinct-but-reproducible sub-seed per prompt.- Otherwise, when
randomSeedis OFF, the run is pinned topromptSeedverbatim (any integer, including 0 and negatives, is honoured). - Otherwise (random on, the default) →
undefined: the engine stays unseeded and rerolls fresh. The image-providerseedis 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 ( |
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
ndistinct 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 — notMath.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
rngas the ambient source for the duration offn, restoring the previous source afterward (even iffnthrows). 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