Skip to main content

Storyteller

Storyteller is a library for the discovery and rendering of UI stories and powers our storybook plugin Flipbook.

The API for this package focuses around the following areas:

  1. Validation for the Story format and Storybook format
  2. Discovery of valid ModuleScripts with .story and .storybook extensions
  3. Loading of Stories and Storybooks into a sandbox with cacheless module requiring
  4. Rendering stories into a container with lifecycle callbacks for updating and unmounting

There also exist React hooks for ease of integration into storybook apps.

Functions​

findStoryModules​

StoryDiscovery
Storyteller.findStoryModules(parent: Instance) → {ModuleScript}

Discovers all Story modules that are descendants of parent.

findStoryModulesForStorybook​

StorybookStoryDiscovery
since 0.1.0
</>
Storyteller.findStoryModulesForStorybook(storybook: types.LoadedStorybook) → {ModuleScript}

Discovers all Story modules that are managed by the given Storybook.

getLoadedStorybooks​

Storybook
Storyteller.getLoadedStorybooks() → {LoadedStorybook}

Returns the Storybooks loaded by Storyteller's shared runtime.

This is a Charm getter for the shared runtime only; it does not read React context or start discovery. Mount a StorytellerProvider without a custom store, or use a Storyteller hook outside a provider, to start shared discovery.

A provider with a custom store and its descendant hooks use that store instead. They do not start the shared runtime or supply results to this getter.

render​

Rendering
Storyteller.render(
container: Instance,
story: LoadedStory<T>,
initialExtraProps: ExtraStoryProps?
) → RenderLifecycle

Render a Story to an Instance in the DataModel.

After discovering, validating, and loading Story modules, rendering them is the final step to getting stories visually presented to the user.

This function handles the lifecycle of mounting, updating, and unmounting the Story. On each update, controls can be passed down to the story for live-reloading from user interaction.

Usage:

local ModuleLoader = require("@pkg/ModuleLoader")
local Storyteller = require("@pkg/Storyteller")

-- At least one `.storybook` module must be present
local storybookModules = Storyteller.findStorybookModules(game)
assert(#storybookModules > 0, "no Storybook modules found")

local storybook
pcall(function()
	storybook = Storyteller.loadStorybookModule(storybookModules[1])
end)

if storybook then
	-- At least one `.story` module must be a descendant of the Instances in
	-- a Storybook's `storyRoots` array
	local storyModules = Storyteller.findStoryModulesForStorybook(storybook)
	assert(#storyModules > 0, "no Story modules found")

	local story
	pcall(function()
		story = Storyteller.loadStoryModule(storyModules[1], storybook)
	end)

	if story then
		-- Finally, render the story to a container of your choosing
		local lifecycle = Storyteller.render(container, story)

		print(container:GetChildren())

		lifecycle.unmount()

		print(container:GetChildren())
	end
end

getOrphanedStoryModules​

Story
Storyteller.getOrphanedStoryModules() → {ModuleScript}

Returns Story modules in the shared runtime outside the roots of every loaded Storybook.

This is a Charm getter for the shared runtime only; it does not read React context or start discovery. Mount a StorytellerProvider without a custom store, or use a Storyteller hook outside a provider, to start shared discovery.

A provider with a custom store and its descendant hooks use that store instead. They do not start the shared runtime or supply results to this getter.

requestStoryModule​

StoryModule Loading
Storyteller.requestStoryModule(request: StoryRequest) → () → ()

Asks the shared runtime to load a Story module, and returns a function that releases the request.

The module loads after this function returns. Call getStoryModuleRecord with the same request to read the result, or pass that call to Charm.listen to be told when it changes. While the request is held, the module reloads when it or its dependencies are edited.

Requests for the same module and Storybook share one record, including requests from hooks that use the shared runtime. Passing a different storybook table for the same source counts as a new version of that Storybook, so the module reloads.

The record is dropped when its last request is released. So to change a request's priority, make the new request before releasing the old one. If the old one was the last, releasing it first would leave no record until the module loads again.

local request = {
	storyModule = storyModule,
	storybook = storybook,
	priority = "Interactive",
}

local release = Storyteller.requestStoryModule(request)
local stopListening = Charm.listen(function()
	return Storyteller.getStoryModuleRecord(request)
end, function(record)
	print(if record then record.status else "Loading")
end)

-- When the record is no longer needed
stopListening()
release()

This starts the shared runtime and keeps it running until the request is released. It does not read React context, so a provider with a custom store never sees the request.

isStoryModule​

ValidationStory
since 0.1.0
</>
Storyteller.isStoryModule(instance: Instance) → boolean

Validates a given Instance is a Story.

No validation is performed on the internals of the module. Only name and class are checked.

See Storyteller.loadStoryModule for validation of the module source.

loadStoriesFromModule​

StoryModule Loading
Storyteller.loadStoriesFromModule(
storyModule: ModuleScript,
storybook: LoadedStorybook,
providedLoader: ModuleLoader?
) → {LoadedStory<T>}

Loads every Story defined by a Story module.

A Story module can define a single Story, or a group of Stories under stories as an array or a dictionary. Group-level summary, controls, packages, and props become defaults for each Story. Stories are returned in array order, or sorted by key for dictionaries. See the Story format for details.

A ModuleLoader instance is used under the hood for handling the requiring of the Story module.

This function will throw if the module does not conform to the Story format, if two Stories in the module share an id, or if the source has a syntax error that require would normally fail for.

loadStorybookModule​

StorybookModule Loading
Storyteller.loadStorybookModule(
module: ModuleScript,
providedLoader: ModuleLoader?
) → LoadedStorybook

Loads the source of a Storybook module.

A ModuleLoader instance is required for handling the requiring of the module.

This function will throw if the return value of storybookModule does not conform to Storybook format, or if the source has a syntax error that require would normally fail for.

loadStoryModule​

StoryModule Loading
Storyteller.loadStoryModule(
storyModule: ModuleScript,
storybook: LoadedStorybook,
providedLoader: ModuleLoader?
) → LoadedStory<T>

Loads the source of a Story module.

A ModuleLoader instance is used under the hood for handling the requiring of the Story module.

This function will throw if the return value of storyModule does not conform to the Story format, or if the source has a syntax error that require would normally fail for.

For legacy compatibility this function also loads Hoarcekat stories. Instead of a usual table-based Story definition, it takes the returned function and wraps it in a Story, making the story field the function body.

useOrphanedStoryModules​

ReactStory
Storyteller.useOrphanedStoryModules(parent: Instance?) → {ModuleScript}

This hook is used for the discovery of Story modules that are not associated with any Storybooks. These are known as "orphaned" or "unknown" stories

This hook should be used in conjunction with useStorybooks so that a list of the available storybooks is determined first, otherwise all stories would come back as orphans.

INFO

In the future version hooks may be migrated to a new package to remove the React dependency from Storyteller.

Usage:

local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local e = React.createElement

local function OrphanList(props: {
	parent: Instance,
})
	local storybooks = Storyteller.useStorybooks(props.parent)
	local orphanedStoryModules = Storyteller.useOrphanedStoryModules(props.parent, storybooks.available)

	local children = {}
	for index, orphanedStoryModule in orphanedStoryModules do
		children[orphanedStoryModule.Name] = e("TextLabel", {
			Text = orphanedStoryModule.Name,
			LayoutOrder = index,
		}),
	end

	return e("Frame", {
		Size = UDim2.fromScale(1, 1),
		BackgroundTransparency = 1,
	}, {
		Layout = e("UIListLayout", {
			SortOrder = Enum.SortOrder.LayoutOrder
		}),
	}, children)
end

return OrphanList

useStory​

ReactStory
Storyteller.useStory(
module: ModuleScript,
storybook: types.LoadedStorybook,
storyId: string?
) → (
types.LoadedStory<unknown>?,
string?
)

This hook triggers a rerender when the Story module or any of its required modules change. For example, updating the story property or updating a React component’s source will trigger useStory to rerender with the new content.

INFO

In the future version hooks may be migrated to a new package to remove the React dependency from Storyteller.

Usage:

local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local useEffect = React.useEffect
local useRef = React.useRef
local e = React.createElement

local function StoryView(props: {
	parent: Instance,
	storyModule: ModuleScript,
	storybook: Storybook,
	storyId: string?,
})
	local ref = useRef<<Frame?>>(nil)

	local story = Storyteller.useStory(props.storyModule, props.storybook, props.storyId)

	useEffect(function()
		if ref.current then
			local renderer = Storyteller.createRendererForStory(story)
			Storyteller.render(renderer, ref.current, story)
		end
	end, { story })

	return e("Frame", {
		Size = UDim2.fromScale(1, 1),
		BackgroundTransparency = 1,
		ref = ref,
	})
end

return StoryView

useStorybooks​

ReactStorybook
Storyteller.useStorybooks(parent: Instance?) → {
available: {LoadedStorybook},
unavailable: {UnavailableStorybook},
}

Performs all the discovery and loading of Storybook modules that would normally be done via individual API members.

This hook makes it possible to conveniently load (and reload) Storybooks for use in React UI.

INFO

In the future version hooks may be migrated to a new package to remove the React dependency from Storyteller.

Usage:

local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local e = React.createElement

local function StorybookList(props: {
	parent: Instance,
})
	local storybooks = Storyteller.useStorybooks(props.parent)

	local children = {}
	for index, storybook in storybooks do
		children[storybook.name] = e("TextLabel", {
			Text = storybook.name,
			LayoutOrder = index,
		}),
	end

	return e("Frame", {
		Size = UDim2.fromScale(1, 1),
		BackgroundTransparency = 1,
	}, {
		Layout = e("UIListLayout", {
			SortOrder = Enum.SortOrder.LayoutOrder
		}),
	}, children)
end

return StorybookList

This hook triggers a rerender when a Storybook module changes. For example, updating the storyRoots of a Storybook will trigger a rerender, and when paired with useStory you can get live updates to which Stories a Storybook manages.

findOrphanedStoryModules​

StorybookStoryDiscovery
Storyteller.findOrphanedStoryModules(
parent: Instance,
storybooks: {types.LoadedStorybook}
) → {ModuleScript}

Discovers all Story modules that do not have a Storybook.

These are all of the Story modules that are not descendants of an instance in the storyRoots array of the given storybooks.

findStorybookModules​

StorybookDiscovery
Storyteller.findStorybookModules(parent: Instance) → {ModuleScript}

Discovers all Storybook modules that are descendants of parent.

This is the first step in the discovery of Stories. Once you load a Storybook, you can then use its storyRoots array to discover all the Stories it manages.

getUnavailableStorybooks​

Storybook
Storyteller.getUnavailableStorybooks() → {UnavailableStorybook}

Returns the Storybooks Storyteller's shared runtime could not load.

This is a Charm getter for the shared runtime only; it does not read React context or start discovery. Mount a StorytellerProvider without a custom store, or use a Storyteller hook outside a provider, to start shared discovery.

A provider with a custom store and its descendant hooks use that store instead. They do not start the shared runtime or supply results to this getter.

getStoryModuleRecord​

StoryModule Loading
Storyteller.getStoryModuleRecord(request: StoryRequest) → StoryModuleRecord?

Returns the record of a Story module in the shared runtime, or nil when there isn't one yet.

The runtime makes a record after it loads a module that something requested, and drops it when the last request is released. Call requestStoryModule first, or use a hook that requests the module, such as useStory. While a module reloads after an edit, this returns the previous record.

The record's status says whether the module loaded. A Loaded record has name and stories, and an Unavailable record has problem. When an edit to a module that already loaded makes it fail to load, the record stays Loaded with the last working stories and also sets problem to the error.

local record = Storyteller.getStoryModuleRecord(request)

if record and record.status == "Loaded" then
	print(record.name, #record.stories)
	if record.problem then
		warn("showing the last working version:", record.problem)
	end
elseif record and record.status == "Unavailable" then
	warn(record.problem)
end

This is a Charm getter for the shared runtime only; it does not read React context. A provider with a custom store and its descendant hooks use that store instead, and do not supply records to this getter.

isStorybookModule​

ValidationStorybook
since 1.0.0
</>
Storyteller.isStorybookModule(instance: Instance) → boolean

Validates a given Instance is a Storybook module.

No validation is performed on the internals of the module. Only name and class are checked.

See Storyteller.loadStorybookModule for validation of the module source.

Show raw api
{
    "functions": [
        {
            "name": "findStoryModules",
            "desc": "Discovers all Story modules that are descendants of `parent`.",
            "params": [
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ModuleScript }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Story",
                "Discovery"
            ],
            "source": {
                "line": 10,
                "path": "/home/runner/work/storyteller/storyteller/src/findStoryModules.luau"
            }
        },
        {
            "name": "findStoryModulesForStorybook",
            "desc": "Discovers all Story modules that are managed by the given Storybook.",
            "params": [
                {
                    "name": "storybook",
                    "desc": "",
                    "lua_type": "types.LoadedStorybook"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ModuleScript }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Storybook",
                "Story",
                "Discovery"
            ],
            "since": "0.1.0",
            "source": {
                "line": 15,
                "path": "/home/runner/work/storyteller/storyteller/src/findStoryModulesForStorybook.luau"
            }
        },
        {
            "name": "getLoadedStorybooks",
            "desc": "Returns the Storybooks loaded by Storyteller's shared runtime.\n\nThis is a Charm getter for the shared runtime only; it does not read React context or start discovery. Mount a `StorytellerProvider` without a custom `store`, or use a Storyteller hook outside a provider, to start shared discovery.\n\nA provider with a custom `store` and its descendant hooks use that store instead. They do not start the shared runtime or supply results to this getter.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ LoadedStorybook }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Storybook"
            ],
            "source": {
                "line": 16,
                "path": "/home/runner/work/storyteller/storyteller/src/getLoadedStorybooks.luau"
            }
        },
        {
            "name": "render",
            "desc": "Render a Story to an [Instance] in the [DataModel].\n\nAfter discovering, validating, and loading Story modules, rendering them is\nthe final step to getting stories visually presented to the user.\n\nThis function handles the lifecycle of mounting, updating, and unmounting\nthe Story. On each update, controls can be passed down to the story for\nlive-reloading from user interaction.\n\n**Usage:**\n\n```lua\nlocal ModuleLoader = require(\"@pkg/ModuleLoader\")\nlocal Storyteller = require(\"@pkg/Storyteller\")\n\n-- At least one `.storybook` module must be present\nlocal storybookModules = Storyteller.findStorybookModules(game)\nassert(#storybookModules > 0, \"no Storybook modules found\")\n\nlocal storybook\npcall(function()\n\tstorybook = Storyteller.loadStorybookModule(storybookModules[1])\nend)\n\nif storybook then\n\t-- At least one `.story` module must be a descendant of the Instances in\n\t-- a Storybook's `storyRoots` array\n\tlocal storyModules = Storyteller.findStoryModulesForStorybook(storybook)\n\tassert(#storyModules > 0, \"no Story modules found\")\n\n\tlocal story\n\tpcall(function()\n\t\tstory = Storyteller.loadStoryModule(storyModules[1], storybook)\n\tend)\n\n\tif story then\n\t\t-- Finally, render the story to a container of your choosing\n\t\tlocal lifecycle = Storyteller.render(container, story)\n\n\t\tprint(container:GetChildren())\n\n\t\tlifecycle.unmount()\n\n\t\tprint(container:GetChildren())\n\tend\nend\n```",
            "params": [
                {
                    "name": "container",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "story",
                    "desc": "",
                    "lua_type": "LoadedStory<T>"
                },
                {
                    "name": "initialExtraProps",
                    "desc": "",
                    "lua_type": "ExtraStoryProps?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RenderLifecycle\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Rendering"
            ],
            "source": {
                "line": 68,
                "path": "/home/runner/work/storyteller/storyteller/src/render.luau"
            }
        },
        {
            "name": "getOrphanedStoryModules",
            "desc": "Returns Story modules in the shared runtime outside the roots of every loaded Storybook.\n\nThis is a Charm getter for the shared runtime only; it does not read React context or start discovery. Mount a `StorytellerProvider` without a custom `store`, or use a Storyteller hook outside a provider, to start shared discovery.\n\nA provider with a custom `store` and its descendant hooks use that store instead. They do not start the shared runtime or supply results to this getter.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ModuleScript }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Story"
            ],
            "source": {
                "line": 13,
                "path": "/home/runner/work/storyteller/storyteller/src/getOrphanedStoryModules.luau"
            }
        },
        {
            "name": "requestStoryModule",
            "desc": "Asks the shared runtime to load a Story module, and returns a function that releases the request.\n\nThe module loads after this function returns. Call `getStoryModuleRecord` with the same request to read the result,\nor pass that call to `Charm.listen` to be told when it changes. While the request is held, the module reloads when\nit or its dependencies are edited.\n\nRequests for the same module and Storybook share one record, including requests from hooks that use the shared\nruntime. Passing a different `storybook` table for the same source counts as a new version of that Storybook, so the\nmodule reloads.\n\nThe record is dropped when its last request is released. So to change a request's priority, make the new request\nbefore releasing the old one. If the old one was the last, releasing it first would leave no record until the module\nloads again.\n\n```lua\nlocal request = {\n\tstoryModule = storyModule,\n\tstorybook = storybook,\n\tpriority = \"Interactive\",\n}\n\nlocal release = Storyteller.requestStoryModule(request)\nlocal stopListening = Charm.listen(function()\n\treturn Storyteller.getStoryModuleRecord(request)\nend, function(record)\n\tprint(if record then record.status else \"Loading\")\nend)\n\n-- When the record is no longer needed\nstopListening()\nrelease()\n```\n\nThis starts the shared runtime and keeps it running until the request is released. It does not read React context,\nso a provider with a custom `store` never sees the request.",
            "params": [
                {
                    "name": "request",
                    "desc": "",
                    "lua_type": "StoryRequest"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> ()\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Story",
                "Module Loading"
            ],
            "source": {
                "line": 48,
                "path": "/home/runner/work/storyteller/storyteller/src/requestStoryModule.luau"
            }
        },
        {
            "name": "isStoryModule",
            "desc": "Validates a given [Instance] is a Story.\n\nNo validation is performed on the internals of the module. Only name and class are checked.\n\nSee [Storyteller.loadStoryModule] for validation of the module source.",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Validation",
                "Story"
            ],
            "since": "0.1.0",
            "source": {
                "line": 16,
                "path": "/home/runner/work/storyteller/storyteller/src/isStoryModule.luau"
            }
        },
        {
            "name": "loadStoriesFromModule",
            "desc": "Loads every Story defined by a Story module.\n\nA Story module can define a single Story, or a group of Stories under\n`stories` as an array or a dictionary. Group-level `summary`, `controls`,\n`packages`, and `props` become defaults for each Story. Stories are returned\nin array order, or sorted by key for dictionaries. See the\n[Story format](/docs/reference/story-format#multiple-stories-in-one-module) for details.\n\nA [ModuleLoader](https://github.com/flipbook-labs/module-loader) instance is\nused under the hood for handling the requiring of the Story module.\n\nThis function will throw if the module does not conform to the Story\nformat, if two Stories in the module share an id, or if the source has a\nsyntax error that `require` would normally fail for.",
            "params": [
                {
                    "name": "storyModule",
                    "desc": "",
                    "lua_type": "ModuleScript"
                },
                {
                    "name": "storybook",
                    "desc": "",
                    "lua_type": "LoadedStorybook"
                },
                {
                    "name": "providedLoader",
                    "desc": "",
                    "lua_type": "ModuleLoader?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ LoadedStory<T> }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Story",
                "Module Loading"
            ],
            "source": {
                "line": 30,
                "path": "/home/runner/work/storyteller/storyteller/src/loadStoriesFromModule.luau"
            }
        },
        {
            "name": "loadStorybookModule",
            "desc": "Loads the source of a Storybook module.\n\nA [ModuleLoader](https://github.com/flipbook-labs/module-loader) instance\nis required for handling the requiring of the module.\n\nThis function will throw if the return value of `storybookModule` does not\nconform to [Storybook format](/docs/story-format#storybook), or if the\nsource has a syntax error that `require` would normally fail for.",
            "params": [
                {
                    "name": "module",
                    "desc": "",
                    "lua_type": "ModuleScript"
                },
                {
                    "name": "providedLoader",
                    "desc": "",
                    "lua_type": "ModuleLoader?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LoadedStorybook\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Storybook",
                "Module Loading"
            ],
            "source": {
                "line": 26,
                "path": "/home/runner/work/storyteller/storyteller/src/loadStorybookModule.luau"
            }
        },
        {
            "name": "loadStoryModule",
            "desc": "Loads the source of a Story module.\n\nA [ModuleLoader](https://github.com/flipbook-labs/module-loader) instance is\nused under the hood for handling the requiring of the Story module.\n\nThis function will throw if the return value of `storyModule` does not\nconform to the [Story format](/docs/story-format#story), or if the source\nhas a syntax error that `require` would normally fail for.\n\nFor legacy compatibility this function also loads [Hoarcekat](https://github.com/Kampfkarren/hoarcekat)\nstories. Instead of a usual table-based Story definition, it takes the\nreturned function and  wraps it in a Story, making the `story` field the\nfunction body.",
            "params": [
                {
                    "name": "storyModule",
                    "desc": "",
                    "lua_type": "ModuleScript"
                },
                {
                    "name": "storybook",
                    "desc": "",
                    "lua_type": "LoadedStorybook"
                },
                {
                    "name": "providedLoader",
                    "desc": "",
                    "lua_type": "ModuleLoader?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LoadedStory<T>\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Story",
                "Module Loading"
            ],
            "source": {
                "line": 29,
                "path": "/home/runner/work/storyteller/storyteller/src/loadStoryModule.luau"
            }
        },
        {
            "name": "useOrphanedStoryModules",
            "desc": "This hook is used for the discovery of Story modules that are not associated\nwith any Storybooks. These are known as \"orphaned\" or \"unknown\" stories\n\nThis hook should be used in conjunction with `useStorybooks` so that a list\nof the available storybooks is determined first, otherwise all stories would\ncome back as orphans.\n\n:::info\nIn the future version hooks may be migrated to a new package to remove the\nReact dependency from Storyteller.\n:::\n\nUsage:\n\n```lua\nlocal React = require(\"@pkg/React\")\nlocal Storyteller = require(\"@pkg/Storyteller\")\n\nlocal e = React.createElement\n\nlocal function OrphanList(props: {\n\tparent: Instance,\n})\n\tlocal storybooks = Storyteller.useStorybooks(props.parent)\n\tlocal orphanedStoryModules = Storyteller.useOrphanedStoryModules(props.parent, storybooks.available)\n\n\tlocal children = {}\n\tfor index, orphanedStoryModule in orphanedStoryModules do\n\t\tchildren[orphanedStoryModule.Name] = e(\"TextLabel\", {\n\t\t\tText = orphanedStoryModule.Name,\n\t\t\tLayoutOrder = index,\n\t\t}),\n\tend\n\n\treturn e(\"Frame\", {\n\t\tSize = UDim2.fromScale(1, 1),\n\t\tBackgroundTransparency = 1,\n\t}, {\n\t\tLayout = e(\"UIListLayout\", {\n\t\t\tSortOrder = Enum.SortOrder.LayoutOrder\n\t\t}),\n\t}, children)\nend\n\nreturn OrphanList\n```",
            "params": [
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ModuleScript }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "React",
                "Story"
            ],
            "source": {
                "line": 62,
                "path": "/home/runner/work/storyteller/storyteller/src/react/useOrphanedStoryModules.luau"
            }
        },
        {
            "name": "useStory",
            "desc": "This hook triggers a rerender when the Story module or any of its required\nmodules change. For example, updating the `story` property or updating a\nReact component’s source will trigger useStory to rerender with the new\ncontent.\n\n:::info\nIn the future version hooks may be migrated to a new package to remove the React dependency from Storyteller.\n:::\n\nUsage:\n\n```lua\nlocal React = require(\"@pkg/React\")\nlocal Storyteller = require(\"@pkg/Storyteller\")\n\nlocal useEffect = React.useEffect\nlocal useRef = React.useRef\nlocal e = React.createElement\n\nlocal function StoryView(props: {\n\tparent: Instance,\n\tstoryModule: ModuleScript,\n\tstorybook: Storybook,\n\tstoryId: string?,\n})\n\tlocal ref = useRef<<Frame?>>(nil)\n\n\tlocal story = Storyteller.useStory(props.storyModule, props.storybook, props.storyId)\n\n\tuseEffect(function()\n\t\tif ref.current then\n\t\t\tlocal renderer = Storyteller.createRendererForStory(story)\n\t\t\tStoryteller.render(renderer, ref.current, story)\n\t\tend\n\tend, { story })\n\n\treturn e(\"Frame\", {\n\t\tSize = UDim2.fromScale(1, 1),\n\t\tBackgroundTransparency = 1,\n\t\tref = ref,\n\t})\nend\n\nreturn StoryView\n```",
            "params": [
                {
                    "name": "module",
                    "desc": "",
                    "lua_type": "ModuleScript"
                },
                {
                    "name": "storybook",
                    "desc": "",
                    "lua_type": "types.LoadedStorybook"
                },
                {
                    "name": "storyId",
                    "desc": "",
                    "lua_type": "string?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "types.LoadedStory<unknown>?"
                },
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "tags": [
                "React",
                "Story"
            ],
            "source": {
                "line": 55,
                "path": "/home/runner/work/storyteller/storyteller/src/react/useStory.luau"
            }
        },
        {
            "name": "useStorybooks",
            "desc": "Performs all the discovery and loading of Storybook modules that would\nnormally be done via individual API members.\n\nThis hook makes it possible to conveniently load (and reload) Storybooks for\nuse in React UI.\n\n:::info\nIn the future version hooks may be migrated to a new package to remove the React dependency from Storyteller.\n:::\n\nUsage:\n\n```lua\nlocal React = require(\"@pkg/React\")\nlocal Storyteller = require(\"@pkg/Storyteller\")\n\nlocal e = React.createElement\n\nlocal function StorybookList(props: {\n\tparent: Instance,\n})\n\tlocal storybooks = Storyteller.useStorybooks(props.parent)\n\n\tlocal children = {}\n\tfor index, storybook in storybooks do\n\t\tchildren[storybook.name] = e(\"TextLabel\", {\n\t\t\tText = storybook.name,\n\t\t\tLayoutOrder = index,\n\t\t}),\n\tend\n\n\treturn e(\"Frame\", {\n\t\tSize = UDim2.fromScale(1, 1),\n\t\tBackgroundTransparency = 1,\n\t}, {\n\t\tLayout = e(\"UIListLayout\", {\n\t\t\tSortOrder = Enum.SortOrder.LayoutOrder\n\t\t}),\n\t}, children)\nend\n\nreturn StorybookList\n```\n\nThis hook triggers a rerender when a Storybook module changes. For example,\nupdating the `storyRoots` of a Storybook will trigger a rerender, and when\npaired with `useStory` you can get live updates to which Stories a Storybook\nmanages.",
            "params": [
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{\n\tavailable: { LoadedStorybook },\n\tunavailable: { UnavailableStorybook },\n}\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "React",
                "Storybook"
            ],
            "source": {
                "line": 70,
                "path": "/home/runner/work/storyteller/storyteller/src/react/useStorybooks.luau"
            }
        },
        {
            "name": "findOrphanedStoryModules",
            "desc": "Discovers all Story modules that do not have a Storybook.\n\nThese are all of the Story modules that are not descendants of an instance\nin the `storyRoots` array of the given storybooks.",
            "params": [
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "storybooks",
                    "desc": "",
                    "lua_type": "{ types.LoadedStorybook }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ModuleScript }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Storybook",
                "Story",
                "Discovery"
            ],
            "source": {
                "line": 17,
                "path": "/home/runner/work/storyteller/storyteller/src/findOrphanedStoryModules.luau"
            }
        },
        {
            "name": "findStorybookModules",
            "desc": "Discovers all Storybook modules that are descendants of `parent`.\n\nThis is the first step in the discovery of Stories. Once you load a\nStorybook, you can then use its `storyRoots` array to discover all the\nStories it manages.",
            "params": [
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ModuleScript }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Storybook",
                "Discovery"
            ],
            "source": {
                "line": 14,
                "path": "/home/runner/work/storyteller/storyteller/src/findStorybookModules.luau"
            }
        },
        {
            "name": "getUnavailableStorybooks",
            "desc": "Returns the Storybooks Storyteller's shared runtime could not load.\n\nThis is a Charm getter for the shared runtime only; it does not read React context or start discovery. Mount a `StorytellerProvider` without a custom `store`, or use a Storyteller hook outside a provider, to start shared discovery.\n\nA provider with a custom `store` and its descendant hooks use that store instead. They do not start the shared runtime or supply results to this getter.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ UnavailableStorybook }\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Storybook"
            ],
            "source": {
                "line": 16,
                "path": "/home/runner/work/storyteller/storyteller/src/getUnavailableStorybooks.luau"
            }
        },
        {
            "name": "getStoryModuleRecord",
            "desc": "Returns the record of a Story module in the shared runtime, or `nil` when there isn't one yet.\n\nThe runtime makes a record after it loads a module that something requested, and drops it when the last request is\nreleased. Call `requestStoryModule` first, or use a hook that requests the module, such as `useStory`. While a\nmodule reloads after an edit, this returns the previous record.\n\nThe record's `status` says whether the module loaded. A `Loaded` record has `name` and `stories`, and an `Unavailable`\nrecord has `problem`. When an edit to a module that already loaded makes it fail to load, the record stays `Loaded` with\nthe last working stories and also sets `problem` to the error.\n\n```lua\nlocal record = Storyteller.getStoryModuleRecord(request)\n\nif record and record.status == \"Loaded\" then\n\tprint(record.name, #record.stories)\n\tif record.problem then\n\t\twarn(\"showing the last working version:\", record.problem)\n\tend\nelseif record and record.status == \"Unavailable\" then\n\twarn(record.problem)\nend\n```\n\nThis is a Charm getter for the shared runtime only; it does not read React context. A provider with a custom `store`\nand its descendant hooks use that store instead, and do not supply records to this getter.",
            "params": [
                {
                    "name": "request",
                    "desc": "",
                    "lua_type": "StoryRequest"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "StoryModuleRecord?\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Story",
                "Module Loading"
            ],
            "source": {
                "line": 38,
                "path": "/home/runner/work/storyteller/storyteller/src/getStoryModuleRecord.luau"
            }
        },
        {
            "name": "isStorybookModule",
            "desc": "Validates a given [Instance] is a Storybook module.\n\nNo validation is performed on the internals of the module. Only name and class are checked.\n\nSee [Storyteller.loadStorybookModule] for validation of the module source.",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "Validation",
                "Storybook"
            ],
            "since": "1.0.0",
            "source": {
                "line": 16,
                "path": "/home/runner/work/storyteller/storyteller/src/isStorybookModule.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Storyteller",
    "desc": "Storyteller is a library for the discovery and rendering of UI stories and\npowers our storybook plugin [Flipbook](https://github.com/flipbook-labs/flipbook).\n\nThe API for this package focuses around the following areas:\n\n1. **Validation** for the [Story](/docs/reference/story-format#story) format and [Storybook](/docs/reference/story-format#storybook) format\n2. **Discovery** of valid ModuleScripts with `.story` and `.storybook` extensions\n3. **Loading** of Stories and Storybooks into a sandbox with cacheless module requiring\n4. **Rendering** stories into a container with lifecycle callbacks for updating and unmounting\n\nThere also exist React hooks for ease of integration into storybook apps.",
    "source": {
        "line": 20,
        "path": "/home/runner/work/storyteller/storyteller/src/init.luau"
    }
}