Rename the sandbox runtime directory from
Relationships
History 1
fe35477Created (proposed)
Context
A {% sandbox %} with a src attribute loads its program files (html/css/js/glsl) from a project directory, scanned at build time by assembleFromDirectory (packages/runes/src/sandbox-sources.ts). That directory is configurable and surfaces as a shipped convention:
- Config key:
sites.<site>.sandbox.examplesDir(packages/types/src/theme.ts). - Default when unset:
<contentDir>/../examples— i.e.site/examples/(packages/content/src/site.ts). - Internal plumbing:
sandboxExamplesDir/__sandboxExamplesDir, threaded throughcontent,sveltekit,eleventy, and theeditor.
The name dates to the original use case: sandboxes as documentation/showcase examples on refrakt's own site. Bundled site templates (SPEC-109 §7) break that assumption. A template can now ship a sandbox that is a load-bearing part of the site — a music blog's audio visualizer (SPEC-104), a data dashboard's chart scene. Filing a production visualizer under examples/ (and configuring it via sandbox.examplesDir) misnames it: these are programs, not demos.
This is a sandbox-system convention, defined by SPEC-104, that SPEC-109 only reuses. Recording the naming decision here keeps it where the convention lives rather than buried in a template spec. The directory being configurable softens the blow — nothing hard-codes examples/ — but the default path and the public config key still carry the legacy name.
Decision
Adopt Option 3. The sandbox runtime directory is named sandboxes/ (default <contentDir>/../sandboxes), configured via sites.<site>.sandbox.dir. The legacy sandbox.examplesDir key and the site/examples/ default are kept as a deprecated alias that resolves with a warning, so existing projects continue to build unchanged. Internal identifiers (sandboxExamplesDir, __sandboxExamplesDir) are renamed to the sandboxDir form. {% ref "SPEC-109" /%} template packages carry their program trees in a sandboxes/ folder and scaffold them into the project's configured sandbox directory.
Rationale
The directory holds programs that are part of the site; examples describes a use case (docs demos) that is now the minority. Naming the convention after the rune that consumes it (sandbox → sandboxes/ → sandbox.dir) makes the whole chain self-consistent and teachable, and stops misfiling production code under a demo folder. Because the path is already configurable, a deprecated alias is cheap and removes any forced migration — the rename is an improvement projects adopt on their own schedule, not a break imposed on them.
Consequences
packages/types/src/theme.tsgainssandbox.dir;sandbox.examplesDiris marked@deprecatedand still read as a fallback.- Config resolution (
packages/content/src/site.ts) defaults to../sandboxes, falling back to../exampleswhen present, and honoursdirover the deprecatedexamplesDir. sandboxExamplesDir/__sandboxExamplesDirare renamed tosandboxDir/__sandboxDiracrosscontent,sveltekit,eleventy, andeditor; the deprecated alias is mapped at the config boundary so internals see one name.refrakt.config.schema.jsondocumentssandbox.dirand marksexamplesDirdeprecated.- A migration note (and ideally a
refrakt/plan-style helper) covers renamingsite/examples/→site/sandboxes/and the config key; the alias means it is opt-in. - SPEC-109 §7 references "the project's configured sandbox directory" rather than a literal path, so the template spec stays correct regardless of the default name.
References
- Live sandbox guests + the sandbox-as-content convention: SPEC-104.
- Bundled sandboxes in site templates: SPEC-109 §7.
- Sandbox source scanning:
packages/runes/src/sandbox-sources.ts(assembleFromDirectory),packages/runes/src/tags/sandbox.ts(__sandboxExamplesDir). - Config surface + default path:
packages/types/src/theme.ts(sandbox.examplesDir),packages/content/src/site.ts(../examplesdefault),packages/sveltekit/src/plugin.ts,packages/eleventy/src/plugin.ts.