@sdxc/kit 0.0.0-stage → 2026.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +92 -2
- package/changelog.jsonl +1040 -0
- package/config.schema.json +89 -0
- package/dist/bin.d.ts +9 -0
- package/dist/bin.js +10 -0
- package/dist/cli.d.ts +33 -0
- package/dist/cli.js +58 -0
- package/dist/commands/create.d.ts +20 -0
- package/dist/commands/create.js +164 -0
- package/dist/commands/init.d.ts +16 -0
- package/dist/commands/init.js +27 -0
- package/dist/commands/make.d.ts +335 -0
- package/dist/commands/make.js +152 -0
- package/dist/commands/run.d.ts +23 -0
- package/dist/commands/run.js +51 -0
- package/dist/commands/ui/add.d.ts +23 -0
- package/dist/commands/ui/add.js +50 -0
- package/dist/commands/ui/diff.d.ts +20 -0
- package/dist/commands/ui/diff.js +28 -0
- package/dist/commands/ui/list.d.ts +24 -0
- package/dist/commands/ui/list.js +45 -0
- package/dist/commands/ui/remove.d.ts +22 -0
- package/dist/commands/ui/remove.js +48 -0
- package/dist/commands/ui/update.d.ts +23 -0
- package/dist/commands/ui/update.js +37 -0
- package/dist/commands/upgrade.d.ts +30 -0
- package/dist/commands/upgrade.js +184 -0
- package/dist/config.d.ts +81 -0
- package/dist/config.js +157 -0
- package/dist/contract.d.ts +161 -0
- package/dist/contract.js +308 -0
- package/dist/create/github.d.ts +63 -0
- package/dist/create/github.js +172 -0
- package/dist/create/target.d.ts +31 -0
- package/dist/create/target.js +56 -0
- package/dist/create/templates.d.ts +62 -0
- package/dist/create/templates.js +228 -0
- package/dist/dependencies.d.ts +34 -0
- package/dist/dependencies.js +76 -0
- package/dist/diff.d.ts +14 -0
- package/dist/diff.js +103 -0
- package/dist/format.d.ts +21 -0
- package/dist/format.js +40 -0
- package/dist/init.d.ts +38 -0
- package/dist/init.js +92 -0
- package/dist/lock.d.ts +74 -0
- package/dist/lock.js +214 -0
- package/dist/make/declare.d.ts +54 -0
- package/dist/make/declare.js +495 -0
- package/dist/make/generate.d.ts +62 -0
- package/dist/make/generate.js +154 -0
- package/dist/make/imports.d.ts +43 -0
- package/dist/make/imports.js +105 -0
- package/dist/make/index.d.ts +43 -0
- package/dist/make/index.js +136 -0
- package/dist/make/kinds.d.ts +39 -0
- package/dist/make/kinds.js +95 -0
- package/dist/make/migrations.d.ts +41 -0
- package/dist/make/migrations.js +116 -0
- package/dist/make/names.d.ts +31 -0
- package/dist/make/names.js +47 -0
- package/dist/make/stubs.d.ts +44 -0
- package/dist/make/stubs.js +89 -0
- package/dist/middleware.d.ts +44 -0
- package/dist/middleware.js +49 -0
- package/dist/package-manager.d.ts +41 -0
- package/dist/package-manager.js +80 -0
- package/dist/project.d.ts +19 -0
- package/dist/project.js +42 -0
- package/dist/releases.d.ts +40 -0
- package/dist/releases.js +110 -0
- package/dist/testing.d.ts +50 -0
- package/dist/testing.js +129 -0
- package/dist/ui/commands.d.ts +114 -0
- package/dist/ui/commands.js +432 -0
- package/dist/ui/imports.d.ts +46 -0
- package/dist/ui/imports.js +160 -0
- package/dist/ui/layout.d.ts +48 -0
- package/dist/ui/layout.js +138 -0
- package/dist/ui/registry.d.ts +58 -0
- package/dist/ui/registry.js +82 -0
- package/dist/upgrade/changelog.d.ts +50 -0
- package/dist/upgrade/changelog.js +69 -0
- package/dist/upgrade/project.d.ts +62 -0
- package/dist/upgrade/project.js +132 -0
- package/dist/upgrade/prompt.d.ts +51 -0
- package/dist/upgrade/prompt.js +227 -0
- package/dist/upgrade/registry.d.ts +33 -0
- package/dist/upgrade/registry.js +50 -0
- package/lock.schema.json +60 -0
- package/package.json +44 -5
- package/registry/ui/accordion.json +15 -0
- package/registry/ui/alert-dialog.json +20 -0
- package/registry/ui/alert.json +15 -0
- package/registry/ui/aspect-ratio.json +13 -0
- package/registry/ui/attachment.json +15 -0
- package/registry/ui/avatar.json +15 -0
- package/registry/ui/badge.json +13 -0
- package/registry/ui/breadcrumbs.json +15 -0
- package/registry/ui/bubble.json +13 -0
- package/registry/ui/button.json +16 -0
- package/registry/ui/calendar.json +16 -0
- package/registry/ui/card.json +18 -0
- package/registry/ui/carousel.json +15 -0
- package/registry/ui/chart.json +13 -0
- package/registry/ui/checkbox-group.json +13 -0
- package/registry/ui/checkbox.json +16 -0
- package/registry/ui/color-area.json +13 -0
- package/registry/ui/color-field.json +20 -0
- package/registry/ui/color-picker.json +17 -0
- package/registry/ui/color-slider.json +13 -0
- package/registry/ui/color-swatch-picker.json +15 -0
- package/registry/ui/color-swatch.json +13 -0
- package/registry/ui/color-wheel.json +13 -0
- package/registry/ui/combobox.json +15 -0
- package/registry/ui/command.json +13 -0
- package/registry/ui/confirm.json +19 -0
- package/registry/ui/context-menu.json +16 -0
- package/registry/ui/date-field.json +19 -0
- package/registry/ui/date-picker.json +15 -0
- package/registry/ui/date-range-picker.json +16 -0
- package/registry/ui/description.json +13 -0
- package/registry/ui/dialog.json +19 -0
- package/registry/ui/disclosure.json +18 -0
- package/registry/ui/drawer.json +18 -0
- package/registry/ui/drop-indicator.json +13 -0
- package/registry/ui/drop-zone.json +13 -0
- package/registry/ui/empty.json +15 -0
- package/registry/ui/field-error.json +13 -0
- package/registry/ui/file-trigger.json +13 -0
- package/registry/ui/form.json +21 -0
- package/registry/ui/grid-list.json +18 -0
- package/registry/ui/group.json +13 -0
- package/registry/ui/header.json +13 -0
- package/registry/ui/heading-scope.json +20 -0
- package/registry/ui/heading.json +15 -0
- package/registry/ui/highlight.json +16 -0
- package/registry/ui/hover-card.json +13 -0
- package/registry/ui/image-placeholder.json +16 -0
- package/registry/ui/input.json +13 -0
- package/registry/ui/item.json +13 -0
- package/registry/ui/keyboard.json +13 -0
- package/registry/ui/label.json +13 -0
- package/registry/ui/link-button.json +16 -0
- package/registry/ui/link.json +13 -0
- package/registry/ui/listbox.json +15 -0
- package/registry/ui/logo.json +15 -0
- package/registry/ui/marker.json +13 -0
- package/registry/ui/menu.json +19 -0
- package/registry/ui/menubar.json +13 -0
- package/registry/ui/message-scroller.json +16 -0
- package/registry/ui/message.json +13 -0
- package/registry/ui/meter.json +13 -0
- package/registry/ui/modal.json +15 -0
- package/registry/ui/nav-link.json +13 -0
- package/registry/ui/navigation-menu.json +15 -0
- package/registry/ui/number-field.json +15 -0
- package/registry/ui/otp-field.json +15 -0
- package/registry/ui/overlay-arrow.json +13 -0
- package/registry/ui/pagination.json +16 -0
- package/registry/ui/popover.json +13 -0
- package/registry/ui/progress-bar.json +13 -0
- package/registry/ui/radio-group.json +13 -0
- package/registry/ui/range-calendar.json +16 -0
- package/registry/ui/resizable.json +13 -0
- package/registry/ui/scroll-area.json +13 -0
- package/registry/ui/search-field.json +16 -0
- package/registry/ui/section.json +13 -0
- package/registry/ui/select.json +13 -0
- package/registry/ui/selection-indicator.json +13 -0
- package/registry/ui/sentinel-row.json +16 -0
- package/registry/ui/separator.json +13 -0
- package/registry/ui/shared-element.json +13 -0
- package/registry/ui/sheet.json +15 -0
- package/registry/ui/shortcut-list.json +18 -0
- package/registry/ui/sidebar.json +20 -0
- package/registry/ui/skeleton.json +13 -0
- package/registry/ui/slider.json +16 -0
- package/registry/ui/spinner.json +13 -0
- package/registry/ui/switch.json +16 -0
- package/registry/ui/table.json +16 -0
- package/registry/ui/tabs.json +17 -0
- package/registry/ui/tag-group.json +18 -0
- package/registry/ui/text-field.json +19 -0
- package/registry/ui/text.json +13 -0
- package/registry/ui/textarea.json +13 -0
- package/registry/ui/time-field.json +19 -0
- package/registry/ui/toast.json +16 -0
- package/registry/ui/toggle-button.json +17 -0
- package/registry/ui/toolbar.json +13 -0
- package/registry/ui/tooltip.json +16 -0
- package/registry/ui/tree.json +18 -0
- package/registry/ui/typeset.json +16 -0
- package/registry/ui/youtube-embed.json +16 -0
- package/stubs/command.stub +12 -0
- package/stubs/command.test.stub +18 -0
- package/stubs/controller.form.stub +33 -0
- package/stubs/controller.stub +17 -0
- package/stubs/controller.test.stub +15 -0
- package/stubs/email.stub +44 -0
- package/stubs/email.test.stub +16 -0
- package/stubs/factory.stub +10 -0
- package/stubs/initializer.stub +7 -0
- package/stubs/initializer.test.stub +13 -0
- package/stubs/job.cron.stub +12 -0
- package/stubs/job.stub +11 -0
- package/stubs/job.test.stub +15 -0
- package/stubs/mcp.resource.stub +12 -0
- package/stubs/mcp.stub +10 -0
- package/stubs/mcp.test.stub +15 -0
- package/stubs/middleware.stub +11 -0
- package/stubs/middleware.test.stub +13 -0
- package/stubs/migration.stub +1 -0
- package/stubs/model.stub +24 -0
- package/stubs/model.test.stub +15 -0
- package/stubs/policy.stub +13 -0
- package/stubs/policy.test.stub +17 -0
- package/stubs/service.stub +13 -0
- package/stubs/service.test.stub +14 -0
- package/stubs/validator.stub +14 -0
- package/stubs/validator.test.stub +22 -0
- package/templates/app/README.md +57 -0
- package/templates/app/app/commands/about.test.ts +29 -0
- package/templates/app/app/commands/about.ts +34 -0
- package/templates/app/app/commands/index.ts +15 -0
- package/templates/app/app/http/controllers/home.tsx +22 -0
- package/templates/app/app/http/controllers/not-found.tsx +25 -0
- package/templates/app/app/initializers/assets.ts +11 -0
- package/templates/app/app/initializers/cli.ts +35 -0
- package/templates/app/app/initializers/dispatcher.ts +18 -0
- package/templates/app/app/initializers/logger.ts +10 -0
- package/templates/app/app/initializers/mcp.ts +16 -0
- package/templates/app/app/initializers/router.tsx +65 -0
- package/templates/app/app/jobs/index.ts +10 -0
- package/templates/app/app/mcp/resources/index.ts +9 -0
- package/templates/app/app/mcp/tools/index.ts +10 -0
- package/templates/app/bootstrap/browser.ts +27 -0
- package/templates/app/bootstrap/cli.ts +9 -0
- package/templates/app/bootstrap/worker.ts +31 -0
- package/templates/app/cloudflare.config.ts +28 -0
- package/templates/app/config/router-context.d.ts +20 -0
- package/templates/app/gitignore +9 -0
- package/templates/app/package.json +38 -0
- package/templates/app/resources/layouts/document.tsx +58 -0
- package/templates/app/routes/web.ts +12 -0
- package/templates/app/tsconfig.json +40 -0
- package/templates/app/vite.config.ts +40 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tree",
|
|
3
|
+
"changedIn": "2026.10.13",
|
|
4
|
+
"dependencies": [
|
|
5
|
+
"sentinel-row"
|
|
6
|
+
],
|
|
7
|
+
"exports": [
|
|
8
|
+
"Tree"
|
|
9
|
+
],
|
|
10
|
+
"source": {
|
|
11
|
+
"path": "tree.tsx",
|
|
12
|
+
"content": "/**\n * A hierarchical list of nodes built from nested `<details>` and `<summary>`\n * elements, so a branch's expand/collapse state, keyboard toggling, and\n * content hiding all come from the platform rather than tracked state.\n * {@link Tree.Item} nests further {@link Tree.Item} nodes directly inside\n * itself to describe a subtree, {@link Tree.ItemContent} renders each node's\n * always-visible row, and {@link Tree.LoadMoreItem} holds a trailing loading\n * placeholder exactly like a row list's own.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { ChevronRightIcon } from \"@sdxc/icons\";\nimport { bg, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, raw } from \"@sdxc/u/general\";\nimport { center, hidden, hstack, interpolateSize, shrink, vstack } from \"@sdxc/u/layout\";\nimport { clip } from \"@sdxc/u/overflow\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, pb, pie, pi } from \"@sdxc/u/size\";\nimport { detailsContent, when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { text } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { panelChrome } from \"@sdxc/ui/styles\";\nimport { warnIfNoAccessibleLabel } from \"@sdxc/ui/utils\";\n\nimport { SentinelRow } from \"@sdxc/ui/sentinel-row\";\n\n/** `role=\"tree\"` applied to {@link Tree} through {@link attrs} unless a consumer supplies its own `role`. */\nconst DEFAULT_ROLE = \"tree\";\n\n/**\n * `role=\"group\"` applied to {@link Tree.Item} through {@link attrs} unless a\n * consumer supplies its own `role` — the only role a native `<details>`\n * accepts, and a fitting one since each item's own `<details>` groups its nodes.\n */\nconst DEFAULT_ITEM_ROLE = \"group\";\n\n/** `role=\"treeitem\"` applied to {@link Tree.ItemContent} through {@link attrs} unless a consumer supplies its own `role`. */\nconst DEFAULT_CONTENT_ROLE = \"treeitem\";\n\n/**\n * Nesting depth {@link Tree.Item} falls back to when nothing wraps it in\n * another {@link Tree.Item} at all, so a root-level node's row renders with\n * no extra indentation and an `aria-level` of `1`.\n */\nconst DEFAULT_DEPTH = 0;\n\n/**\n * Marker {@link Tree.ExpandButton} always carries as its `data-slot`\n * attribute, applied through {@link attrs} unless a consumer supplies its\n * own value, letting {@link Tree.Item}'s styling target just this chevron.\n */\nconst DEFAULT_EXPAND_BUTTON_SLOT = \"expand-button\";\n\n/**\n * Inline space a row with no {@link Tree.ExpandButton} keeps where the chevron would\n * sit — the chevron's own width plus the row's gap — so a leaf's icon lines up under\n * the icons of the branches around it instead of under their chevrons.\n */\nconst LEAF_GUTTER = \"calc(var(--ui-spacing, 0.25rem) * 7)\";\n\n/**\n * Prop and context types for {@link Tree} and its compound parts.\n */\nexport namespace Tree {\n\t/** Value each {@link Tree.Item} provides to the nodes nested inside it. */\n\texport interface ItemContext {\n\t\t/** Nesting depth this item occupies, `0` for a node rendered directly inside {@link Tree}. */\n\t\tdepth: number;\n\t}\n\n\t/**\n\t * Props accepted by {@link Tree}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** {@link Tree.Item} and {@link Tree.LoadMoreItem} nodes to render. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Tree.Item}. Every native `<details>` attribute\n\t * still applies, so `open` sets a branch's initial and current expanded\n\t * state declaratively, exactly as on any native `<details>` element.\n\t */\n\texport interface ItemProps extends TagProps<\"details\"> {\n\t\t/**\n\t\t * Stable identifier for this node, mirrored onto the rendered element's\n\t\t * own `id` and a `data-rmx-key` attribute so a paired selection, navigation, or\n\t\t * reorder behavior can correlate the node with its own tracked state.\n\t\t */\n\t\tid: string;\n\t\t/** The node's {@link Tree.ItemContent} row, followed by zero or more nested {@link Tree.Item} nodes describing its subtree. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Tree.ItemContent}.\n\t */\n\texport interface ItemContentProps extends TagProps<\"summary\"> {}\n\n\t/**\n\t * Props accepted by {@link Tree.LoadMoreItem}.\n\t */\n\texport interface LoadMoreItemProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Props accepted by {@link Tree.ExpandButton}: every native `<span>` attribute.\n\t *\n\t * No accessible name is asked for, because the chevron names nothing: the row it\n\t * sits in is a `<summary>`, which announces the branch and its expanded state on\n\t * its own, and a second name beside it would be read out twice.\n\t */\n\texport interface ExpandButtonProps extends TagProps<\"span\"> {}\n}\n\n/**\n * Reads the nesting depth published by the nearest ancestor {@link Tree.Item},\n * resolving to `undefined` when the lookup finds no ancestor item at all.\n *\n * @param handle Runtime handle of the component performing the lookup.\n * @returns The nearest ancestor item's depth, or `undefined` where nothing wraps the caller.\n * @example\n * let ambient = readAmbientDepth(handle); // 1, nested one level inside a Tree.Item holding depth 1\n */\nfunction readAmbientDepth(handle: Handle<unknown, any>): number | undefined {\n\ttry {\n\t\tlet ambient = handle.context.get(TreeItem) as Tree.ItemContext | undefined;\n\n\t\treturn ambient?.depth;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Renders the tree's root host: a bordered `<div>` carrying `role=\"tree\"`,\n * stacking {@link Tree.Item} nodes in block flow, with `data-empty`\n * centering a fallback message; an unlabeled tree logs a dev `console.warn`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the tree's markup.\n * @example\n * <Tree aria-label={t(\"files.title\")}>\n * \t<Tree.Item id=\"src\">\n * \t\t<Tree.ItemContent>\n * \t\t\t<Tree.ExpandButton aria-label={t(\"files.expand\")} />\n * \t\t\t{t(\"files.folder\", { name: \"src\" })}\n * \t\t</Tree.ItemContent>\n * \t\t<Tree.Item id=\"src-index\">\n * \t\t\t<Tree.ItemContent>{t(\"files.file\", { name: \"index.ts\" })}</Tree.ItemContent>\n * \t\t</Tree.Item>\n * \t</Tree.Item>\n * </Tree>\n * @example\n * <Tree aria-label={t(\"files.title\")} data-empty>\n * \t{t(\"files.empty\")}\n * </Tree>\n */\nexport function Tree(handle: Handle<Tree.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Tree: needs an \"aria-label\" or \"aria-labelledby\" describing its contents for assistive technology.',\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_ROLE }),\n\t\t\t\t\tpanelChrome(),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\tvstack(),\n\t\t\t\t\tpb(1),\n\t\t\t\t\tpi(1),\n\t\t\t\t\toutline(\"none\"),\n\t\t\t\t\twhen(\"&[data-empty]\", [center(), pb(8), fg(\"neutral.muted\")]),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n}\n\n/**\n * Renders a node as a native `<details>`, so a subtree's reveal and `[open]`\n * state come from the platform. Nest {@link Tree.ItemContent} first as the\n * row, then nested {@link Tree.Item} children; reveal animates via `::details-content`.\n *\n * @param handle Runtime handle carrying the host `<details>`'s props and providing {@link Tree.ItemContext} to nodes nested inside it.\n * @returns The render function producing the node's markup.\n * @example\n * <Tree.Item id=\"src\">\n * \t<Tree.ItemContent>\n * \t\t<Tree.ExpandButton aria-label={t(\"files.expand\")} />\n * \t\t{t(\"files.folder\", { name: \"src\" })}\n * \t</Tree.ItemContent>\n * \t<Tree.Item id=\"src-index\">\n * \t\t<Tree.ItemContent>{t(\"files.file\", { name: \"index.ts\" })}</Tree.ItemContent>\n * \t</Tree.Item>\n * </Tree.Item>\n * @example\n * <Tree.Item id=\"src\" open>\n * \t<Tree.ItemContent>\n * \t\t<Tree.ExpandButton aria-label={t(\"files.collapse\")} />\n * \t\t{t(\"files.folder\", { name: \"src\" })}\n * \t</Tree.ItemContent>\n * </Tree.Item>\n */\nfunction TreeItem(handle: Handle<Tree.ItemProps, Tree.ItemContext>) {\n\treturn () => {\n\t\tlet { id, children, mix, ...rest } = handle.props;\n\t\tlet ambient = readAmbientDepth(handle);\n\t\tlet depth = ambient === undefined ? DEFAULT_DEPTH : ambient + 1;\n\n\t\thandle.context.set({ depth });\n\n\t\treturn (\n\t\t\t<details\n\t\t\t\t{...rest}\n\t\t\t\tid={id}\n\t\t\t\tdata-rmx-key={id}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_ITEM_ROLE }),\n\t\t\t\t\tinterpolateSize(),\n\t\t\t\t\tdetailsContent([\n\t\t\t\t\t\tclip(),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\ttransitionProperty: \"block-size, content-visibility\",\n\t\t\t\t\t\t\ttransitionBehavior: \"allow-discrete\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttransitionDuration(\"200ms\"),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * Collapsed and expanded sizes are written under selectors that never\n\t\t\t\t\t * match at once, so the reveal holds whichever order the cascade puts\n\t\t\t\t\t * the pair in.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&:not([open])::details-content\", bs(0)),\n\t\t\t\t\twhen(\"&[open]::details-content\", bs(\"auto\")),\n\t\t\t\t\twhen(`&[open] > summary [data-slot=\"${DEFAULT_EXPAND_BUTTON_SLOT}\"]`, rotate(90)),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", detailsContent(transitionDuration(\"0s\"))),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</details>\n\t\t);\n\t};\n}\n\nTree.Item = TreeItem;\n\n/**\n * Renders {@link Tree.ItemContentProps.children} inside a native\n * `<summary>` — the enclosing {@link Tree.Item}'s always-visible row —\n * indented from its ambient depth, with `aria-selected`/`aria-disabled` styling.\n *\n * @param handle Runtime handle carrying the host `<summary>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Tree.ItemContent>\n * \t<Tree.ExpandButton aria-label={t(\"files.expand\")} />\n * \t{t(\"files.folder\", { name: \"src\" })}\n * </Tree.ItemContent>\n * @example\n * <Tree.ItemContent aria-selected=\"true\">\n * \t{t(\"files.file\", { name: \"index.ts\" })}\n * </Tree.ItemContent>\n */\nTree.ItemContent = function TreeItemContent(handle: Handle<Tree.ItemContentProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\t\tlet depth = readAmbientDepth(handle) ?? DEFAULT_DEPTH;\n\n\t\treturn (\n\t\t\t<summary\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tattrs({ role: DEFAULT_CONTENT_ROLE, \"aria-level\": depth + 1 }),\n\t\t\t\t\thstack({ gap: 2, align: \"center\" }),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpb(1.5),\n\t\t\t\t\tpie(3),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\tlistStyle(),\n\t\t\t\t\t/**\n\t\t\t\t\t * The two indents are written under selectors that never match at once, so\n\t\t\t\t\t * a row keeps its own whichever order the cascade puts the pair in.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\n\t\t\t\t\t\t`&:has([data-slot=\"${DEFAULT_EXPAND_BUTTON_SLOT}\"])`,\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tpaddingInlineStart: `calc(0.5rem + ${depth} * var(--ui-tree-indent, 1.25rem))`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t`&:not(:has([data-slot=\"${DEFAULT_EXPAND_BUTTON_SLOT}\"]))`,\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tpaddingInlineStart: `calc(0.5rem + ${depth} * var(--ui-tree-indent, 1.25rem) + ${LEAF_GUTTER})`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t\toutline(\"none\"),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\twhen(\"&::-webkit-details-marker\", hidden()),\n\t\t\t\t\twhen(\"&::marker\", raw({ content: '\"\"' })),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", transitionDuration(\"0s\")),\n\t\t\t\t\twhen(\"&:hover\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\twhen(\"&:active\", bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\twhen(\"&:focus\", bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\twhen('&[aria-selected=\"true\"]', bg(\"brand.tint\")),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', opacity(50)),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</summary>\n\t\t);\n\t};\n};\n\n/**\n * Renders a decorative sentinel node: a `<div>` styled as centered, muted\n * small text sized to match {@link Tree.ItemContent}'s vertical rhythm,\n * ready to hold whatever loading indicator a paired enhancement supplies.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the sentinel node's markup.\n * @example\n * <Tree.LoadMoreItem>{t(\"files.loadingMore\")}</Tree.LoadMoreItem>\n */\nTree.LoadMoreItem = SentinelRow;\n\n/**\n * Renders the chevron a node's row shows for a subtree, rotated 90 degrees\n * while the enclosing {@link Tree.Item}'s `<details>` carries `[open]`.\n *\n * It is decoration, not a control: the row it sits in is a `<summary>`, which is already\n * the thing that opens the branch, and a button nested inside one takes the activation\n * for itself — the chevron would be the one place on the row that did not expand it.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the chevron's markup.\n * @example\n * <Tree.ItemContent>\n * \t<Tree.ExpandButton aria-label={t(\"files.expand\")} />\n * \t{t(\"files.folder\", { name: \"src\" })}\n * </Tree.ItemContent>\n */\nTree.ExpandButton = function TreeExpandButton(handle: Handle<Tree.ExpandButtonProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"data-slot\": DEFAULT_EXPAND_BUTTON_SLOT, \"aria-hidden\": \"true\" }),\n\t\t\t\t\tcenter(),\n\t\t\t\t\tis(5),\n\t\t\t\t\tbs(5),\n\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\ttransition(\"transform, background-color\"),\n\t\t\t\t\tshrink(),\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", transitionDuration(\"0s\")),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children ?? <ChevronRightIcon size={16} />}\n\t\t\t</span>\n\t\t);\n\t};\n};\n"
|
|
13
|
+
},
|
|
14
|
+
"test": {
|
|
15
|
+
"path": "tree.test.tsx",
|
|
16
|
+
"content": "/**\n * Tests for the `type` {@link Tree.ExpandButton} writes: an explicit\n * `type=\"button\"`, positioned before the consumer's own attributes, without\n * which the platform refuses to run an Invoker Command the chevron carries\n * inside a `<form>` — it decides whether the pairing is ambiguous while it\n * parses `command`/`commandfor` and never sees a `type` serialized after them.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport { renderToString } from \"remix/component/server\";\nimport { describe, expect, test } from \"vitest\";\n\nimport { Tree } from \"@sdxc/ui/tree\";\n\ndescribe(\"Tree.ExpandButton\", () => {\n\ttest(\"renders as decoration, so the summary it sits in keeps the activation\", async () => {\n\t\tlet html = await renderToString(<Tree.ExpandButton />);\n\n\t\texpect(html).not.toContain(\"<button\");\n\t\texpect(html).toContain(\"<span\");\n\t});\n\n\ttest(\"is hidden from the accessibility tree, which the row already speaks for\", async () => {\n\t\tlet html = await renderToString(<Tree.ExpandButton />);\n\n\t\texpect(html).toContain('aria-hidden=\"true\"');\n\t});\n});\n"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "typeset",
|
|
3
|
+
"changedIn": "2026.10.15",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"Typeset"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "typeset.tsx",
|
|
10
|
+
"content": "/**\n * A typography layer wrapping already-rendered markdown or HTML content and\n * supplying every size, weight, spacing, and color decision through three\n * custom properties: `--ui-typeset-size`, `--ui-typeset-leading`, and\n * `--ui-typeset-flow`. `data-preset` swaps all three for a different rhythm\n * context; `data-not-typeset` opts a subtree out of the whole layer.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { keyframes } from \"@sdxc/u/animation\";\nimport { bg, border, borderEdge, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { raw } from \"@sdxc/u/general\";\nimport { block, container } from \"@sdxc/u/layout\";\nimport { overflow, overflowBlock, overflowInline } from \"@sdxc/u/overflow\";\nimport { at } from \"@sdxc/u/responsive\";\nimport { is, maxIs, pb, pi, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport {\n\tbalance,\n\tleading,\n\tpretty,\n\ttabularNums,\n\ttextAlign,\n\ttextDecoration,\n\ttracking,\n\tweight,\n} from \"@sdxc/u/typography\";\nimport { css } from \"remix/component\";\n\nimport { easings } from \"@sdxc/ui/animations\";\n\n/**\n * Named container {@link Typeset} declares on its own host, so its wide-table\n * handling can grant roomier cell and code-block padding once there's enough\n * space, instead of reading the viewport.\n */\nconst CONTAINER_NAME = \"ui-typeset\";\n\n/** Rhythm context {@link Typeset} falls back to when `preset` is omitted. */\nconst DEFAULT_PRESET: Typeset.Preset = \"docs\";\n\n/** CSS length each edge of a wide table's own fade tapers over. */\nconst TABLE_FADE_SIZE = \"2.5rem\";\n\n/**\n * Custom property carrying the gradient direction a wide table's edge fade\n * paints along, mirrored under `:dir(rtl)` so the same mask string works in\n * both writing directions without a second, mirrored gradient.\n */\nconst TABLE_FADE_DIRECTION_PROPERTY = \"--ui-typeset-table-fade-direction\";\n\n/**\n * `@keyframes` name backing a wide table's scroll-linked edge fade; the\n * `keyframes()` call using it must stay a top-level mixin rather than nested\n * under the table selector, since the serializer only recognizes stops there.\n */\nconst TABLE_FADE_KEYFRAMES_NAME = \"ui-typeset-table-fade\";\n\n/** Proportion of a wide table's own scroll range its edge fade ramps across. */\nconst TABLE_FADE_RAMP_PERCENT = 10;\n\n/** The style shape {@link css} accepts, reused so a keyframes block can be built ahead of the call. */\ntype Styles = Parameters<typeof css>[0];\n\n/**\n * Builds the four-stop mask-image gradient a wide table's edge fade paints:\n * a leading stop, two middle stops marking where the faded band meets the\n * fully opaque middle, and a trailing stop; only the middle stops move.\n */\nfunction tableFadeMask(startStop: string, endStop: string): string {\n\treturn `linear-gradient(to var(${TABLE_FADE_DIRECTION_PROPERTY}, right), transparent 0%, black ${startStop}, black ${endStop}, transparent 100%)`;\n}\n\nconst TABLE_FADE_SETTLED_STOP = `calc(100% - ${TABLE_FADE_SIZE})`;\nconst TABLE_FADE_SETTLED_MASK = tableFadeMask(TABLE_FADE_SIZE, TABLE_FADE_SETTLED_STOP);\n\n/**\n * Stops the wide-table edge fade animates through: fully faded on the leading\n * edge at rest, settled on both edges across the long middle of the scroll\n * range, and fully faded on the trailing edge at the end.\n */\nconst TABLE_FADE_KEYFRAMES: Record<string, Styles> = {\n\t\"0%\": { maskImage: tableFadeMask(\"0%\", TABLE_FADE_SETTLED_STOP) },\n\t[`${TABLE_FADE_RAMP_PERCENT}%, ${100 - TABLE_FADE_RAMP_PERCENT}%`]: {\n\t\tmaskImage: TABLE_FADE_SETTLED_MASK,\n\t},\n\t\"100%\": { maskImage: tableFadeMask(TABLE_FADE_SIZE, \"100%\") },\n};\n\n/**\n * Prop types for {@link Typeset}.\n */\nexport namespace Typeset {\n\t/**\n\t * Rhythm context: `\"docs\"` is the spacious default, `\"chat\"` tightens the\n\t * scale for a conversational bubble's denser turn-taking, and `\"reading\"`\n\t * opens both further for a long-form article.\n\t */\n\texport type Preset = \"docs\" | \"chat\" | \"reading\";\n\n\t/**\n\t * Every native `<div>` attribute plus `mix`. `preset` defaults to\n\t * {@link DEFAULT_PRESET}; setting a `--ui-typeset-*` property directly\n\t * overrides it, and `data-not-typeset` opts a subtree out entirely.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Rhythm context. Defaults to {@link DEFAULT_PRESET}. */\n\t\tpreset?: Preset;\n\t}\n}\n\n/**\n * Renders a `<div>` that sizes and colors already-rendered markdown or HTML\n * content through `--ui-typeset-size`, `--ui-typeset-leading`, and\n * `--ui-typeset-flow`, computing heading sizes via `calc()` off one shared value.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the typeset layer's markup.\n * @example\n * <Typeset preset=\"reading\">{renderedArticleHtml}</Typeset>\n * @example\n * <Typeset preset=\"chat\">\n * \t<p>{t(\"assistant.reply\")}</p>\n * </Typeset>\n * @example\n * <Typeset>\n * \t<p>{t(\"docs.intro\")}</p>\n * \t<div data-not-typeset>\n * \t\t<EmbeddedWidget />\n * \t</div>\n * </Typeset>\n */\nexport function Typeset(handle: Handle<Typeset.Props>) {\n\treturn () => {\n\t\tlet { preset, mix, ...rest } = handle.props;\n\t\tlet resolvedPreset = preset ?? DEFAULT_PRESET;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-preset={resolvedPreset}\n\t\t\t\tdata-slot=\"typeset\"\n\t\t\t\tmix={[\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\tkeyframes(TABLE_FADE_KEYFRAMES_NAME, TABLE_FADE_KEYFRAMES),\n\t\t\t\t\traw({\n\t\t\t\t\t\tfontSize: \"var(--ui-typeset-size, 1rem)\",\n\t\t\t\t\t\tlineHeight: \"var(--ui-typeset-leading, 1.75)\",\n\n\t\t\t\t\t\t'&[data-preset=\"docs\"]': {\n\t\t\t\t\t\t\t\"--ui-typeset-size\": \"1rem\",\n\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.75\",\n\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"1.25em\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'&[data-preset=\"chat\"]': {\n\t\t\t\t\t\t\t\"--ui-typeset-size\": \"0.9375rem\",\n\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.5\",\n\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"0.75em\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'&[data-preset=\"reading\"]': {\n\t\t\t\t\t\t\t\"--ui-typeset-size\": \"1.125rem\",\n\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.8\",\n\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"1.5em\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& > * + *\": {\n\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(blockquote, li) > * + *\": {\n\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& :where(h1)\": {\n\t\t\t\t\t\t\tfontSize: \"calc(var(--ui-typeset-size, 1rem) * 2)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(h2)\": {\n\t\t\t\t\t\t\tfontSize: \"calc(var(--ui-typeset-size, 1rem) * 1.5)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(h3)\": {\n\t\t\t\t\t\t\tfontSize: \"calc(var(--ui-typeset-size, 1rem) * 1.25)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(h4)\": {\n\t\t\t\t\t\t\tfontSize: \"calc(var(--ui-typeset-size, 1rem) * 1.125)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(h5)\": {\n\t\t\t\t\t\t\tfontSize: \"var(--ui-typeset-size, 1rem)\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(h6)\": {\n\t\t\t\t\t\t\tfontSize: \"calc(var(--ui-typeset-size, 1rem) * 0.875)\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& :where(ul)\": {\n\t\t\t\t\t\t\tlistStyleType: \"disc\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(ol)\": {\n\t\t\t\t\t\t\tlistStyleType: \"decimal\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(ul, ol) :where(ul)\": {\n\t\t\t\t\t\t\tlistStyleType: \"circle\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& :where(blockquote)\": {\n\t\t\t\t\t\t\tfontStyle: \"italic\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& :where(a)\": {\n\t\t\t\t\t\t\ttextUnderlineOffset: \"0.15em\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(a):hover\": {\n\t\t\t\t\t\t\ttextDecorationThickness: \"2px\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& :where(em, i)\": {\n\t\t\t\t\t\t\tfontStyle: \"italic\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& :where(code)\": {\n\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(pre)\": {\n\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where(pre code)\": {\n\t\t\t\t\t\t\tpadding: \"0\",\n\t\t\t\t\t\t\tfontSize: \"1em\",\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\"& :where(table)\": {\n\t\t\t\t\t\t\tborderCollapse: \"collapse\",\n\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t\tscrollbarWidth: \"thin\",\n\t\t\t\t\t\t\tscrollbarGutter: \"stable\",\n\n\t\t\t\t\t\t\t[TABLE_FADE_DIRECTION_PROPERTY]: \"right\",\n\t\t\t\t\t\t\tmaskImage: \"none\",\n\t\t\t\t\t\t\t\"-webkit-mask-image\": \"none\",\n\n\t\t\t\t\t\t\t\"&:dir(rtl)\": {\n\t\t\t\t\t\t\t\t[TABLE_FADE_DIRECTION_PROPERTY]: \"left\",\n\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\"&::-webkit-scrollbar\": {\n\t\t\t\t\t\t\t\twidth: \"0.75rem\",\n\t\t\t\t\t\t\t\theight: \"0.75rem\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"&::-webkit-scrollbar-track\": {\n\t\t\t\t\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"&::-webkit-scrollbar-thumb\": {\n\t\t\t\t\t\t\t\tborderRadius: \"var(--ui-radius-full, 9999px)\",\n\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-border)\",\n\t\t\t\t\t\t\t\tborderWidth: \"3px\",\n\t\t\t\t\t\t\t\tborderStyle: \"solid\",\n\t\t\t\t\t\t\t\tborderColor: \"transparent\",\n\t\t\t\t\t\t\t\tbackgroundClip: \"content-box\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"&::-webkit-scrollbar-thumb:hover\": {\n\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-border-strong)\",\n\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\"@supports (animation-timeline: scroll())\": {\n\t\t\t\t\t\t\t\tanimationName: TABLE_FADE_KEYFRAMES_NAME,\n\t\t\t\t\t\t\t\tanimationDuration: \"auto\",\n\t\t\t\t\t\t\t\tanimationTimingFunction: easings.linear,\n\t\t\t\t\t\t\t\tanimationFillMode: \"both\",\n\t\t\t\t\t\t\t\tanimationTimeline: \"scroll(self inline)\",\n\t\t\t\t\t\t\t\t\"@media (prefers-reduced-motion: reduce)\": {\n\t\t\t\t\t\t\t\t\tanimationName: \"none\",\n\t\t\t\t\t\t\t\t\tmaskImage: TABLE_FADE_SETTLED_MASK,\n\t\t\t\t\t\t\t\t\t\"-webkit-mask-image\": TABLE_FADE_SETTLED_MASK,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"& :where([data-not-typeset], [data-not-typeset] *)\": {\n\t\t\t\t\t\t\tall: \"revert-layer\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\n\t\t\t\t\tat(\n\t\t\t\t\t\t\"30rem\",\n\t\t\t\t\t\tCONTAINER_NAME,\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\"& :where(th, td)\": {\n\t\t\t\t\t\t\t\tpaddingInline: \"1em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"& :where(pre)\": {\n\t\t\t\t\t\t\t\tpaddingInline: \"1.25em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\n\t\t\t\t\twhen(\"& :where(pre)\", leading(1.6)),\n\n\t\t\t\t\twhen(\"& :where(h1, h2, h3, h4, h5, h6)\", [\n\t\t\t\t\t\tweight(\"semibold\"),\n\t\t\t\t\t\tleading(1.25),\n\t\t\t\t\t\ttracking(\"tight\"),\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\tbalance(),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"& :where(h6)\", fg(\"neutral\")),\n\n\t\t\t\t\twhen(\"& :where(p, li, blockquote, dd)\", pretty()),\n\n\t\t\t\t\twhen(\"& :where(ul, ol)\", pis(\"1.5em\")),\n\t\t\t\t\twhen(\"& :where(li)::marker\", fg(\"neutral.muted\")),\n\n\t\t\t\t\twhen(\"& :where(blockquote)\", [\n\t\t\t\t\t\tpis(\"1em\"),\n\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\tborderEdge(\"inline-start\", { color: \"neutral\", width: \"0.25em\" }),\n\t\t\t\t\t]),\n\n\t\t\t\t\twhen(\"& :where(hr)\", borderEdge(\"block-start\", { color: \"neutral\", width: \"1px\" })),\n\n\t\t\t\t\twhen(\"& :where(a)\", [fg(\"brand\"), textDecoration(\"underline\")]),\n\t\t\t\t\twhen(\"& :where(a):focus-visible\", [\n\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\trounded(\"xs\"),\n\t\t\t\t\t]),\n\n\t\t\t\t\twhen(\"& :where(strong, b)\", [weight(\"semibold\"), fg(\"neutral.emphasis\")]),\n\n\t\t\t\t\twhen(\"& :where(code)\", [\n\t\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\tpi(\"0.3em\"),\n\t\t\t\t\t\tpb(\"0.15em\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"& :where(pre)\", [\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\tpi(\"1em\"),\n\t\t\t\t\t\tpb(\"0.875em\"),\n\t\t\t\t\t\toverflowInline(\"auto\"),\n\t\t\t\t\t\toverflowBlock(\"hidden\"),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\toverscrollBehaviorInline: \"contain\",\n\t\t\t\t\t\t\toverscrollBehaviorX: \"contain\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * A fenced block's `code` is an inline box, so the chip padding above would\n\t\t\t\t\t * apply at the start of the box alone and indent the block's first line\n\t\t\t\t\t * past every line under it. The block's own padding is the `pre`'s.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"& :where(pre code)\", [\n\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\tfg(\"inherit\"),\n\t\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\t\tpi(0),\n\t\t\t\t\t\tpb(0),\n\t\t\t\t\t]),\n\n\t\t\t\t\twhen(\"& :where(table)\", [\n\t\t\t\t\t\tblock(),\n\t\t\t\t\t\tis(\"max(100%, max-content)\"),\n\t\t\t\t\t\tmaxIs(\"full\"),\n\t\t\t\t\t\toverflow(\"auto\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"& :where(th, td):not([align])\", textAlign(\"start\")),\n\t\t\t\t\twhen(\"& :where(th)\", [weight(\"semibold\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\twhen(\"& :where(th, td)\", [\n\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\tpi(\"0.75em\"),\n\t\t\t\t\t\tpb(\"0.5em\"),\n\t\t\t\t\t\tborderEdge(\"block-end\", { color: \"neutral\", width: \"1px\" }),\n\t\t\t\t\t]),\n\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"path": "typeset.test.tsx",
|
|
14
|
+
"content": "/**\n * Regression tests for the wide-table edge fade's `@keyframes` rule. Its stops\n * are percentages, and `remix/component`'s serializer only reads keyframe stops as\n * stop selectors while the `@keyframes` rule sits outside any selector block —\n * nested inside the table's own selector, every stop serialized as a dropped\n * `0%: [object Object]` declaration and the animation did nothing.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport { renderToString } from \"remix/component/server\";\nimport { describe, expect, test } from \"vitest\";\n\nimport { Typeset } from \"@sdxc/ui/typeset\";\n\n/** The stylesheet {@link Typeset} emits, with every `<style>` tag joined. */\nasync function typesetCss(): Promise<string> {\n\tlet html = await renderToString(<Typeset />);\n\treturn [...html.matchAll(/<style[^>]*>([\\s\\S]*?)<\\/style>/g)].map((match) => match[1]).join(\"\\n\");\n}\n\ndescribe(Typeset.name, () => {\n\ttest(\"emits the table fade keyframes as real stop blocks\", async () => {\n\t\tlet css = await typesetCss();\n\n\t\texpect(css).toContain(\"@keyframes ui-typeset-table-fade\");\n\t\texpect(css).toMatch(/\\b0%\\s*\\{/);\n\t\texpect(css).toMatch(/\\b100%\\s*\\{/);\n\t\texpect(css).toMatch(/\\b10%,\\s*90%\\s*\\{/);\n\t\t/** The stops are only worth emitting if they actually carry the mask. */\n\t\texpect(css).toContain(\"mask-image\");\n\t});\n\n\ttest(\"never serializes a nested style block as a declaration value\", async () => {\n\t\texpect(await typesetCss()).not.toContain(\"[object Object]\");\n\t});\n\n\ttest(\"drives the animation it defines\", async () => {\n\t\tlet css = await typesetCss();\n\n\t\texpect(css).toContain(\"animation-name: ui-typeset-table-fade\");\n\t\texpect(css).toContain(\"animation-timeline: scroll(self inline)\");\n\t});\n\n\ttest(\"lets a vertical wheel over a code block chain to the page\", async () => {\n\t\tlet css = await typesetCss();\n\n\t\texpect(css).toContain(\"overflow-inline: auto\");\n\t\texpect(css).toContain(\"overflow-block: hidden\");\n\t\texpect(css).toContain(\"overscroll-behavior-inline: contain\");\n\t\texpect(css).toContain(\"overscroll-behavior-x: contain\");\n\t\texpect(css).not.toMatch(/overscroll-behavior:\\s*contain/);\n\t});\n});\n"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "youtube-embed",
|
|
3
|
+
"changedIn": "2026.10.14",
|
|
4
|
+
"dependencies": [],
|
|
5
|
+
"exports": [
|
|
6
|
+
"YouTubeEmbed"
|
|
7
|
+
],
|
|
8
|
+
"source": {
|
|
9
|
+
"path": "youtube-embed.tsx",
|
|
10
|
+
"content": "/**\n * A YouTube player sized to its container: a 16:9 `<iframe>` served from YouTube's\n * privacy-enhanced host, so a visitor receives no YouTube cookies until they press play,\n * and lazy-loaded so a video below the fold costs nothing until it scrolls into view.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { border } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { block } from \"@sdxc/u/layout\";\nimport { aspect, is } from \"@sdxc/u/size\";\n\n/** The host every player loads from; a page's `frame-src` has to allow it. */\nconst EMBED_ORIGIN = \"https://www.youtube-nocookie.com\";\n\n/** Loading strategy {@link YouTubeEmbed} falls back to when `loading` is omitted. */\nconst DEFAULT_LOADING: YouTubeEmbed.Props[\"loading\"] = \"lazy\";\n\n/** The player features YouTube asks an embedding page to delegate. */\nconst ALLOWED_FEATURES =\n\t\"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\";\n\n/**\n * Prop types for {@link YouTubeEmbed}.\n */\nexport namespace YouTubeEmbed {\n\t/**\n\t * Props accepted by {@link YouTubeEmbed}.\n\t */\n\texport interface Props extends Omit<\n\t\tTagProps<\"iframe\">,\n\t\t\"src\" | \"title\" | \"allow\" | \"referrerpolicy\" | \"referrerPolicy\"\n\t> {\n\t\t/** The eleven-character id from the video's `watch?v=` or `youtu.be/` URL. */\n\t\tvideoId: string;\n\t\t/** Seconds into the video the player starts at; zero or less starts at the beginning. */\n\t\tstart?: number;\n\t\t/** The frame's accessible name, announced before a reader enters the player. */\n\t\ttitle: string;\n\t}\n}\n\n/**\n * Renders the player filling its container's inline axis at 16:9. The frame always sends\n * the embedding page's origin as referrer, without which YouTube refuses to play.\n *\n * @param handle Runtime handle carrying the host `<iframe>`'s props.\n * @returns The render function producing the player's markup.\n * @example <YouTubeEmbed videoId=\"dQw4w9WgXcQ\" title={t(\"video.title\")} />\n * @example <YouTubeEmbed videoId=\"dQw4w9WgXcQ\" start={90} title={t(\"video.title\")} />\n */\nexport function YouTubeEmbed(handle: Handle<YouTubeEmbed.Props>) {\n\treturn () => {\n\t\tlet { videoId, start, title, loading, mix, ...rest } = handle.props;\n\t\tlet src = new URL(`/embed/${encodeURIComponent(videoId)}`, EMBED_ORIGIN);\n\t\tif (start !== undefined && start >= 1) src.searchParams.set(\"start\", String(Math.floor(start)));\n\n\t\treturn (\n\t\t\t<iframe\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"youtube-embed\"\n\t\t\t\tsrc={src.href}\n\t\t\t\ttitle={title}\n\t\t\t\tloading={loading ?? DEFAULT_LOADING}\n\t\t\t\treferrerpolicy=\"strict-origin-when-cross-origin\"\n\t\t\t\tallow={ALLOWED_FEATURES}\n\t\t\t\tallowFullScreen\n\t\t\t\tmix={[block(), is(\"full\"), aspect(\"video\"), border(\"none\"), rounded(\"lg\"), mix]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"path": "youtube-embed.test.tsx",
|
|
14
|
+
"content": "// @vitest-environment happy-dom\n\n/**\n * Tests the player's frame: the privacy-enhanced embed URL with its start time, the\n * consumer's accessible name, and the attributes YouTube needs before it plays.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { RemixNode } from \"remix/component\";\n\nimport { renderToString } from \"remix/component/server\";\nimport { describe, expect, test } from \"vitest\";\n\nimport { YouTubeEmbed } from \"@sdxc/ui/youtube-embed\";\n\n/** The rendered `<iframe>`, parsed so a test reads attributes rather than matching strings. */\nasync function renderFrame(node: RemixNode) {\n\tlet template = document.createElement(\"template\");\n\ttemplate.innerHTML = await renderToString(node);\n\tlet frame = template.content.querySelector(\"iframe\");\n\tif (!frame) throw new Error(\"The player rendered no iframe\");\n\treturn frame;\n}\n\ndescribe(\"YouTubeEmbed\", () => {\n\ttest(\"loads the video from the privacy-enhanced host under the consumer's title\", async () => {\n\t\tlet frame = await renderFrame(<YouTubeEmbed videoId=\"o07u1oKE6VA\" title=\"The Remix Way\" />);\n\n\t\texpect(frame.getAttribute(\"src\")).toBe(\"https://www.youtube-nocookie.com/embed/o07u1oKE6VA\");\n\t\texpect(frame.getAttribute(\"title\")).toBe(\"The Remix Way\");\n\t\texpect(frame.getAttribute(\"data-slot\")).toBe(\"youtube-embed\");\n\t});\n\n\ttest(\"starts at whole seconds, and at the beginning for a start below one\", async () => {\n\t\tlet later = await renderFrame(<YouTubeEmbed videoId=\"o07u1oKE6VA\" start={905.6} title=\"\" />);\n\t\tlet zero = await renderFrame(<YouTubeEmbed videoId=\"o07u1oKE6VA\" start={0} title=\"\" />);\n\n\t\texpect(later.getAttribute(\"src\")).toBe(\n\t\t\t\"https://www.youtube-nocookie.com/embed/o07u1oKE6VA?start=905\",\n\t\t);\n\t\texpect(zero.getAttribute(\"src\")).toBe(\"https://www.youtube-nocookie.com/embed/o07u1oKE6VA\");\n\t});\n\n\ttest(\"sends the page's origin as referrer, which YouTube requires to play\", async () => {\n\t\tlet frame = await renderFrame(<YouTubeEmbed videoId=\"o07u1oKE6VA\" title=\"\" />);\n\n\t\texpect(frame.getAttribute(\"referrerpolicy\")).toBe(\"strict-origin-when-cross-origin\");\n\t\texpect(frame.hasAttribute(\"allowfullscreen\")).toBe(true);\n\t});\n\n\ttest(\"loads lazily unless the consumer asks for an eager player\", async () => {\n\t\tlet lazy = await renderFrame(<YouTubeEmbed videoId=\"o07u1oKE6VA\" title=\"\" />);\n\t\tlet eager = await renderFrame(<YouTubeEmbed videoId=\"o07u1oKE6VA\" title=\"\" loading=\"eager\" />);\n\n\t\texpect(lazy.getAttribute(\"loading\")).toBe(\"lazy\");\n\t\texpect(eager.getAttribute(\"loading\")).toBe(\"eager\");\n\t});\n});\n"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `{{command}}`: describe what it changes, what it prints, and whether it is safe to run twice.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
6
|
+
|
|
7
|
+
import commandset from "~/app/commands";
|
|
8
|
+
|
|
9
|
+
export default createCommand(commandset{{member}}, (ctx) => {
|
|
10
|
+
ctx.stdout("{{title}}\n");
|
|
11
|
+
return success();
|
|
12
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `{{command}}` command, run through the app's command line.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { invoke } from "@sdxc/cli/test";
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { cli } from "~/app/initializers/cli";
|
|
9
|
+
|
|
10
|
+
describe("{{command}}", () => {
|
|
11
|
+
test("runs and exits 0", async () => {
|
|
12
|
+
let run = await invoke(cli, [{{words}}]);
|
|
13
|
+
|
|
14
|
+
expect(run.code).toBe(0);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test.todo("does the {{title}} work");
|
|
18
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} form: the page that shows it and the action that receives it. Describe what
|
|
3
|
+
* a submission changes and where the visitor lands afterwards.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createController } from "remix/router";
|
|
7
|
+
|
|
8
|
+
import DocumentLayout from "~/resources/layouts/document";
|
|
9
|
+
import routes from "{{routes}}";
|
|
10
|
+
|
|
11
|
+
export default createController(routes.{{path}}, {
|
|
12
|
+
actions: {
|
|
13
|
+
/** Renders the form. */
|
|
14
|
+
index(ctx) {
|
|
15
|
+
return ctx.render(
|
|
16
|
+
<DocumentLayout assets={ctx.assets} title="{{title}}">
|
|
17
|
+
<h1>{{title}}</h1>
|
|
18
|
+
<form method="post" action={routes.{{path}}.action.href()}>
|
|
19
|
+
<button type="submit">Send</button>
|
|
20
|
+
</form>
|
|
21
|
+
</DocumentLayout>,
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
/** Receives a submission and sends the visitor back to the form. */
|
|
26
|
+
action() {
|
|
27
|
+
return new Response(null, {
|
|
28
|
+
status: 303,
|
|
29
|
+
headers: { location: routes.{{path}}.index.href() },
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} page: describe what a visitor finds here and why the route exists.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createAction } from "remix/router";
|
|
6
|
+
|
|
7
|
+
import DocumentLayout from "~/resources/layouts/document";
|
|
8
|
+
import routes from "{{routes}}";
|
|
9
|
+
|
|
10
|
+
/** Renders the {{title}} page. */
|
|
11
|
+
export default createAction(routes.{{path}}, (ctx) =>
|
|
12
|
+
ctx.render(
|
|
13
|
+
<DocumentLayout assets={ctx.assets} title="{{title}}">
|
|
14
|
+
<h1>{{title}}</h1>
|
|
15
|
+
</DocumentLayout>,
|
|
16
|
+
),
|
|
17
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} controller.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import controller from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{name}}", () => {
|
|
10
|
+
test("exports what the router maps", () => {
|
|
11
|
+
expect(controller).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test.todo("answers the {{title}} page");
|
|
15
|
+
});
|
package/stubs/email.stub
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} email: describe who receives it and what it tells them.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Handle } from "remix/component";
|
|
6
|
+
import type { Email as EmailContract } from "@sdxc/mail";
|
|
7
|
+
|
|
8
|
+
import { Email } from "@sdxc/mail";
|
|
9
|
+
|
|
10
|
+
/** What the {{title}} email says. */
|
|
11
|
+
export interface {{Name}}Copy {
|
|
12
|
+
heading: string;
|
|
13
|
+
body: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Renders the email's body from copy the caller wrote. */
|
|
17
|
+
function {{Name}}Body(handle: Handle<{{Name}}Copy>) {
|
|
18
|
+
return () => (
|
|
19
|
+
<Email.Layout preview={handle.props.heading} title={handle.props.heading}>
|
|
20
|
+
<Email.Heading>{handle.props.heading}</Email.Heading>
|
|
21
|
+
<Email.Text>{handle.props.body}</Email.Text>
|
|
22
|
+
</Email.Layout>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The {{title}} email, addressed to one recipient. */
|
|
27
|
+
export class {{Name}}Email implements EmailContract {
|
|
28
|
+
constructor(
|
|
29
|
+
private recipient: string,
|
|
30
|
+
private copy: {{Name}}Copy,
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
get to() {
|
|
34
|
+
return { email: this.recipient };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get subject() {
|
|
38
|
+
return this.copy.heading;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
body() {
|
|
42
|
+
return <{{Name}}Body {...this.copy} />;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} email.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { {{Name}}Email } from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{Name}}Email", () => {
|
|
10
|
+
test("is addressed to its recipient under its heading", () => {
|
|
11
|
+
let email = new {{Name}}Email("ada@example.com", { heading: "Hello", body: "Welcome." });
|
|
12
|
+
|
|
13
|
+
expect(email.to).toEqual({ email: "ada@example.com" });
|
|
14
|
+
expect(email.subject).toBe("Hello");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} factory tests seed rows with, through the same model the app writes with.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineFactory } from "@sdxc/data-model/testing";
|
|
6
|
+
|
|
7
|
+
import { {{Name}} } from "{{model}}";
|
|
8
|
+
|
|
9
|
+
/** A complete {{title}} row; a test overrides only the fields it is about. */
|
|
10
|
+
export const {{Name}}Factory = defineFactory({{Name}}, {});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} initializer.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { {{key}} } from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{key}}", () => {
|
|
10
|
+
test("is built once, at import", () => {
|
|
11
|
+
expect({{key}}).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scheduled {{title}} job: describe what each run sweeps or reports, and why on this
|
|
3
|
+
* schedule.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createJobHandler } from "@sdxc/jobs";
|
|
7
|
+
|
|
8
|
+
import jobs from "~/app/jobs";
|
|
9
|
+
|
|
10
|
+
export default createJobHandler(jobs.{{path}}, async (ctx) => {
|
|
11
|
+
ctx.log.set({ job: { name: "{{name}}" } });
|
|
12
|
+
});
|
package/stubs/job.stub
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} job: describe what it changes and why it runs off the request.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createJobHandler } from "@sdxc/jobs";
|
|
6
|
+
|
|
7
|
+
import jobs from "~/app/jobs";
|
|
8
|
+
|
|
9
|
+
export default createJobHandler(jobs.{{path}}, async (ctx) => {
|
|
10
|
+
ctx.log.set({ job: { name: "{{name}}" } });
|
|
11
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} job.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import handler from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{name}}", () => {
|
|
10
|
+
test("exports the handler the dispatcher maps", () => {
|
|
11
|
+
expect(handler).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test.todo("does the {{title}} work");
|
|
15
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answers the `{{uri}}` resource: describe what a read returns, and `null` for one that does
|
|
3
|
+
* not exist.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createResource } from "@sdxc/mcp";
|
|
7
|
+
|
|
8
|
+
import resourceset from "~/app/mcp/resources";
|
|
9
|
+
|
|
10
|
+
export default createResource(resourceset.{{path}}, {
|
|
11
|
+
read: () => "# {{title}}\n",
|
|
12
|
+
});
|
package/stubs/mcp.stub
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answers the `{{tool}}` tool: describe what it returns, and what a model should do when it
|
|
3
|
+
* finds nothing.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createTool } from "@sdxc/mcp";
|
|
7
|
+
|
|
8
|
+
import toolset from "~/app/mcp/tools";
|
|
9
|
+
|
|
10
|
+
export default createTool(toolset.{{path}}, () => "{{title}}");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} MCP handler.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import handler from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{name}}", () => {
|
|
10
|
+
test("exports the handler the MCP server maps", () => {
|
|
11
|
+
expect(handler).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test.todo("answers {{title}}");
|
|
15
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} middleware: describe what it publishes on the context or which requests it
|
|
3
|
+
* answers before the handler runs.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Middleware } from "remix/router";
|
|
7
|
+
|
|
8
|
+
/** Creates the middleware; add it to a router's chain or to a route's `lazy()` guards. */
|
|
9
|
+
export default function {{key}}(): Middleware {
|
|
10
|
+
return (_context, next) => next();
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} middleware.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import {{key}} from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{name}}", () => {
|
|
10
|
+
test("creates a middleware function", () => {
|
|
11
|
+
expect(typeof {{key}}()).toBe("function");
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- {{Name}}: write the statements this migration applies, in order.
|
package/stubs/model.stub
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} model and its table: describe what a row records and the rules that keep it
|
|
3
|
+
* consistent. Keep the columns in step with the migration that creates the table.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { TableRow } from "remix/data-table";
|
|
7
|
+
|
|
8
|
+
import { column as c, table } from "remix/data-table";
|
|
9
|
+
import { createModel } from "@sdxc/data-model";
|
|
10
|
+
|
|
11
|
+
/** The `{{snake}}` table, as its migration creates it. */
|
|
12
|
+
export const {{key}}Table = table({
|
|
13
|
+
name: "{{snake}}",
|
|
14
|
+
columns: {
|
|
15
|
+
id: c.text().primaryKey(),
|
|
16
|
+
created_at: c.integer(),
|
|
17
|
+
updated_at: c.integer(),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/** One {{title}} row as it reads back from the database. */
|
|
22
|
+
export type {{Name}}Row = TableRow<typeof {{key}}Table>;
|
|
23
|
+
|
|
24
|
+
export const {{Name}} = createModel({{key}}Table, {});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} model.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { {{Name}} } from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{Name}}", () => {
|
|
10
|
+
test("is defined over its table", () => {
|
|
11
|
+
expect({{Name}}).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test.todo("keeps a {{title}} row consistent");
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} policy: describe who may do what, and why the rule sits here.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Who an authorization rule is asked about; `null` for an anonymous visitor. */
|
|
6
|
+
export interface Actor {
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Whether `actor` passes the {{title}} rule. */
|
|
11
|
+
export function {{key}}(actor: Actor | null): boolean {
|
|
12
|
+
return actor !== null;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} policy.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { {{key}} } from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{key}}", () => {
|
|
10
|
+
test("refuses an anonymous visitor", () => {
|
|
11
|
+
expect({{key}}(null)).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("allows a signed-in actor", () => {
|
|
15
|
+
expect({{key}}({ id: "1" })).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {{title}}: describe the rule this service carries out across models, and what a caller can
|
|
3
|
+
* rely on when it succeeds.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Result } from "@sdxc/result";
|
|
7
|
+
|
|
8
|
+
import { success } from "@sdxc/result";
|
|
9
|
+
|
|
10
|
+
/** Carries out {{title}}; a failure says why nothing changed. */
|
|
11
|
+
export function {{key}}(): Result<void, Error> {
|
|
12
|
+
return success(undefined);
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} service.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { isSuccess } from "@sdxc/result";
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { {{key}} } from "{{specifier}}";
|
|
9
|
+
|
|
10
|
+
describe("{{key}}", () => {
|
|
11
|
+
test("succeeds", () => {
|
|
12
|
+
expect(isSuccess({{key}}())).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fields the {{title}} form submits, validated before anything trusts them.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as s from "remix/data-schema";
|
|
6
|
+
import * as f from "remix/data-schema/form-data";
|
|
7
|
+
|
|
8
|
+
/** The {{title}} fields, as an action receives them. */
|
|
9
|
+
export const {{Name}}Schema = f.object({
|
|
10
|
+
name: f.field(s.string()),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/** A validated {{title}} submission. */
|
|
14
|
+
export type {{Name}}Input = s.InferOutput<typeof {{Name}}Schema>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} form's validation.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { isFailure, isSuccess } from "@sdxc/result";
|
|
6
|
+
import { validate } from "@sdxc/validate";
|
|
7
|
+
import { describe, expect, test } from "vitest";
|
|
8
|
+
|
|
9
|
+
import { {{Name}}Schema } from "{{specifier}}";
|
|
10
|
+
|
|
11
|
+
describe("{{Name}}Schema", () => {
|
|
12
|
+
test("accepts a complete submission", async () => {
|
|
13
|
+
let form = new FormData();
|
|
14
|
+
form.set("name", "Ada");
|
|
15
|
+
|
|
16
|
+
expect(isSuccess(await validate(form, {{Name}}Schema))).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("refuses a submission missing a field", async () => {
|
|
20
|
+
expect(isFailure(await validate(new FormData(), {{Name}}Schema))).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
});
|