From a3176588767dc32e33fa38ebce147ade461fcee2 Mon Sep 17 00:00:00 2001 From: Tim Smart Date: Mon, 9 Nov 2026 23:18:31 +0000 Subject: [PATCH] Move the HTML modules into effect as effect/ui/html Fold @effect/ui-html into the effect package. The modules now live in packages/effect/src/ui/html and are exported as effect/ui/html, effect/ui/html/testing and effect/ui/html/, with ./ui/html/internal/* hidden. Neither the effect/ui barrel, effect/ui/testing nor the root index re-exports them, so only code that imports effect/ui/html needs the DOM lib. An oxlint no-restricted-imports override stops anything else in packages/effect/src from importing ui/html, and check-dist-types now type-checks effect/ui and effect/ui/testing without the DOM lib and with skipLibCheck: false. Tests and type tests move to packages/effect/test/ui/html (run under happy-dom) and packages/effect/typetest/ui/html. The standalone package, its workspace, tsconfig, vitest and lockfile entries, and its changeset entry are removed; the release note is folded into the effect changeset. The scheduler's internal exports are marked @internal, so docgen reports no errors under src/ui. --- .changeset/effect-ui-scaffold.md | 7 +- .oxlintrc.json | 16 ++++ deno.json | 3 +- packages/effect/package.json | 6 ++ packages/effect/src/ui/Router.ts | 2 +- .../src => effect/src/ui/html}/BrowserHost.ts | 18 ++--- .../src/ui/html}/BrowserRouter.ts | 14 ++-- .../html/src => effect/src/ui/html}/Html.ts | 22 +++--- .../src => effect/src/ui/html}/HtmlServer.ts | 14 ++-- .../html/src => effect/src/ui/html}/index.ts | 0 .../src/ui/html}/internal/head.ts | 2 +- .../src/ui/html}/internal/markers.ts | 0 .../src/ui/html}/internal/server.ts | 4 +- .../src/ui/html}/internal/submit.ts | 0 .../src/ui/html}/testing/HtmlQuery.ts | 4 +- .../src => effect/src/ui/html}/testing/Ssr.ts | 24 +++--- .../src/ui/html}/testing/index.ts | 2 +- packages/effect/src/ui/internal/schedule.ts | 16 +++- .../test/ui/html}/BrowserHost.test.ts | 5 +- .../test/ui/html}/BrowserRouter.test.ts | 5 +- .../test => effect/test/ui/html}/Head.test.ts | 3 +- .../test/ui/html}/HtmlQuery.test.ts | 3 +- .../test/ui/html}/HtmlServer.test.ts | 5 +- .../test/ui/html}/fixtures/routed.ts | 2 +- .../test/ui/html}/fixtures/todos.ts | 2 +- .../typetest/ui/html}/Html.tst.ts | 4 +- packages/ui/html/LICENSE | 21 ------ packages/ui/html/README.md | 25 ------- packages/ui/html/package.json | 75 ------------------- packages/ui/html/tsconfig.json | 8 -- pnpm-lock.yaml | 6 -- pnpm-workspace.yaml | 1 - scripts/check-dist-types.mjs | 5 +- scripts/circular.mjs | 2 +- scripts/clean.mjs | 2 +- tsconfig.packages.json | 1 - tsconfig.tests.json | 5 +- vitest.config.ts | 5 -- 38 files changed, 118 insertions(+), 221 deletions(-) rename packages/{ui/html/src => effect/src/ui/html}/BrowserHost.ts (97%) rename packages/{ui/html/src => effect/src/ui/html}/BrowserRouter.ts (97%) rename packages/{ui/html/src => effect/src/ui/html}/Html.ts (97%) rename packages/{ui/html/src => effect/src/ui/html}/HtmlServer.ts (94%) rename packages/{ui/html/src => effect/src/ui/html}/index.ts (100%) rename packages/{ui/html/src => effect/src/ui/html}/internal/head.ts (99%) rename packages/{ui/html/src => effect/src/ui/html}/internal/markers.ts (100%) rename packages/{ui/html/src => effect/src/ui/html}/internal/server.ts (98%) rename packages/{ui/html/src => effect/src/ui/html}/internal/submit.ts (100%) rename packages/{ui/html/src => effect/src/ui/html}/testing/HtmlQuery.ts (99%) rename packages/{ui/html/src => effect/src/ui/html}/testing/Ssr.ts (95%) rename packages/{ui/html/src => effect/src/ui/html}/testing/index.ts (85%) rename packages/{ui/html/test => effect/test/ui/html}/BrowserHost.test.ts (99%) rename packages/{ui/html/test => effect/test/ui/html}/BrowserRouter.test.ts (98%) rename packages/{ui/html/test => effect/test/ui/html}/Head.test.ts (98%) rename packages/{ui/html/test => effect/test/ui/html}/HtmlQuery.test.ts (98%) rename packages/{ui/html/test => effect/test/ui/html}/HtmlServer.test.ts (99%) rename packages/{ui/html/test => effect/test/ui/html}/fixtures/routed.ts (99%) rename packages/{ui/html/test => effect/test/ui/html}/fixtures/todos.ts (99%) rename packages/{ui/html/typetest => effect/typetest/ui/html}/Html.tst.ts (98%) delete mode 100644 packages/ui/html/LICENSE delete mode 100644 packages/ui/html/README.md delete mode 100644 packages/ui/html/package.json delete mode 100644 packages/ui/html/tsconfig.json diff --git a/.changeset/effect-ui-scaffold.md b/.changeset/effect-ui-scaffold.md index cc54d44361..58e3266f13 100644 --- a/.changeset/effect-ui-scaffold.md +++ b/.changeset/effect-ui-scaffold.md @@ -1,15 +1,14 @@ --- "effect": patch -"@effect/ui-html": patch --- -Add `effect/ui`, a Layer-composed frontend framework for Effect, and `@effect/ui-html`, its HTML package. +Add `effect/ui`, a Layer-composed frontend framework for Effect, and `effect/ui/html`, which runs it in the DOM and on the server. The host-agnostic core holds `Component`, `Command`, `Subscription`, `Feature` and `View`, plus `Renderer` to mount a component tree on any host and `MessageLog` to record what it does. `effect/ui/testing` adds `Story` for one-instance tests, `TestHost` and `Query` for runtime tests, and `Story.fromLog` to replay a logged session. `Route` defines a typed route table that parses and prints URLs, `Router` holds the current route with navigation and blocking Commands (`Router.push(AppRoute, route)` takes only routes of the table, `Router.memory` is for tests and `Router.static` for the server), and restores a page's Model on back and forward, skipping the `Command.Service`s declared `server: true`, and a component's `head` option sets the document title, meta, links, JSON-LD and `` / `` attributes. The modules are experimental. -`@effect/ui-html` runs the same components in a real DOM. `Html` is the element vocabulary (typed events with plain payloads, controlled `value` / `checked` / `selected` / `open`, refs typed by tag, and the `focus`, `blur`, `scrollIntoView` and `measure` ref Commands), `BrowserHost.mount` mounts an HTML root into an element with delegated events and keeps the document head in sync, `BrowserRouter` routes through `window.history` with link interception, scroll restoration and route-change announcements, `HtmlQuery` in `@effect/ui-html/testing` finds elements by ARIA role and accessible name. +`effect/ui/html` runs the same components in a real DOM. It is the only part of `effect/ui` whose types need the `DOM` lib, and nothing else in `effect` re-exports it. `Html` is the element vocabulary (typed events with plain payloads, controlled `value` / `checked` / `selected` / `open`, refs typed by tag, and the `focus`, `blur`, `scrollIntoView` and `measure` ref Commands), `BrowserHost.mount` mounts an HTML root into an element with delegated events and keeps the document head in sync, `BrowserRouter` routes through `window.history` with link interception, scroll restoration and route-change announcements, `HtmlQuery` in `effect/ui/html/testing` finds elements by ARIA role and accessible name. -Server rendering: `HtmlServer.renderToHtml` renders a tree to HTML within a `budget`, running only `init`'s `server: true` Commands, and returns the markup, the state the client adopts, the root's Model and the head as escaped strings. `BrowserHost.mount(App, props, container, { state })` hydrates it, adopting the server's nodes and Models, and `root.adopted` completes when no slot is still waiting for its Layer. `Component.provide(..., { server: false })` keeps a Layer off the server, and `ssr` in `@effect/ui-html/testing` renders, hydrates and checks the two agree. +Server rendering: `HtmlServer.renderToHtml` renders a tree to HTML within a `budget`, running only `init`'s `server: true` Commands, and returns the markup, the state the client adopts, the root's Model and the head as escaped strings. `BrowserHost.mount(App, props, container, { state })` hydrates it, adopting the server's nodes and Models, and `root.adopted` completes when no slot is still waiting for its Layer. `Component.provide(..., { server: false })` keeps a Layer off the server, and `ssr` in `effect/ui/html/testing` renders, hydrates and checks the two agree. ```ts import { Schema } from "effect" diff --git a/.oxlintrc.json b/.oxlintrc.json index 43b87b895a..37d087a880 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -38,5 +38,21 @@ "rules": { "eslint/no-control-regex": "off" } + }, { + // Only effect/ui/html may use DOM types, so nothing else in effect imports it. + "files": ["packages/effect/src/**"], + "rules": { + "eslint/no-restricted-imports": ["error", { + "patterns": [{ + "regex": "(^|/)ui/html(/|$)|^\\.{1,2}/(\\.\\./)*html(/|$)", + "message": "Only effect/ui/html may use DOM types; nothing else in effect may import it." + }] + }] + } + }, { + "files": ["packages/effect/src/ui/html/**"], + "rules": { + "eslint/no-restricted-imports": "off" + } }] } diff --git a/deno.json b/deno.json index 2d317b322c..a4cd36b571 100644 --- a/deno.json +++ b/deno.json @@ -23,7 +23,9 @@ "packages/*/benchmark/", "packages/ai", "packages/atom", + "packages/effect/src/ui/html/", "packages/effect/test/cluster/", + "packages/effect/test/ui/html/", "packages/opentelemetry/", "packages/platform/browser/", "packages/platform/bun/", @@ -31,7 +33,6 @@ "packages/platform/node/", "packages/platform/node-shared/", "packages/tools/", - "packages/ui/", "packages/sql" ] } diff --git a/packages/effect/package.json b/packages/effect/package.json index 26b62c8bf3..df1d9c3f1d 100644 --- a/packages/effect/package.json +++ b/packages/effect/package.json @@ -58,6 +58,8 @@ "./workers": "./src/workers/index.ts", "./ui": "./src/ui/index.ts", "./ui/testing": "./src/ui/testing/index.ts", + "./ui/html": "./src/ui/html/index.ts", + "./ui/html/testing": "./src/ui/html/testing/index.ts", "./*": "./src/*.ts", "./ai/internal/*": null, "./cli/internal/*": null, @@ -74,6 +76,7 @@ "./rpc/internal/*": null, "./workflow/internal/*": null, "./ui/internal/*": null, + "./ui/html/internal/*": null, "./internal/*": null, "./index": null, "./*/index": null @@ -121,6 +124,8 @@ "./workers": "./dist/workers/index.js", "./ui": "./dist/ui/index.js", "./ui/testing": "./dist/ui/testing/index.js", + "./ui/html": "./dist/ui/html/index.js", + "./ui/html/testing": "./dist/ui/html/testing/index.js", "./*": "./dist/*.js", "./internal/*": null, "./cli/internal/*": null, @@ -138,6 +143,7 @@ "./rpc/internal/*": null, "./workflow/internal/*": null, "./ui/internal/*": null, + "./ui/html/internal/*": null, "./index": null, "./*/index": null } diff --git a/packages/effect/src/ui/Router.ts b/packages/effect/src/ui/Router.ts index f30a78a3fa..1b9640d159 100644 --- a/packages/effect/src/ui/Router.ts +++ b/packages/effect/src/ui/Router.ts @@ -4,7 +4,7 @@ * * `Router` is a host service. Its Layers are `Router.memory` (tests and * `TestHost`), `Router.static` (server rendering) and, in - * `@effect/ui-html`, `BrowserRouter.layer` and `BrowserRouter.layerHash`. + * `effect/ui/html`, `BrowserRouter.layer` and `BrowserRouter.layerHash`. * Each provides the `Router` service and the navigation Commands, `Push`, * `Replace`, `Back`, `Forward`, `Load`, `Block` and `Unblock`. A component * that navigates has them in its requirements, so a missing Router is a diff --git a/packages/ui/html/src/BrowserHost.ts b/packages/effect/src/ui/html/BrowserHost.ts similarity index 97% rename from packages/ui/html/src/BrowserHost.ts rename to packages/effect/src/ui/html/BrowserHost.ts index 213269641a..175b1fdb56 100644 --- a/packages/ui/html/src/BrowserHost.ts +++ b/packages/effect/src/ui/html/BrowserHost.ts @@ -17,7 +17,7 @@ * **Example** (Mounting an app) * * ```ts - * import { BrowserHost, Html } from "@effect/ui-html" + * import { BrowserHost, Html } from "effect/ui/html" * import { Effect, Schema } from "effect" * import { Component } from "effect/ui" * @@ -42,14 +42,14 @@ * @stability experimental * @since 4.1.3 */ -import * as Context from "effect/Context" -import * as Effect from "effect/Effect" -import * as Layer from "effect/Layer" -import type * as AsyncResult from "effect/reactivity/AsyncResult" -import type * as Scope from "effect/Scope" -import type * as Component from "effect/ui/Component" -import * as Renderer from "effect/ui/Renderer" -import type * as View from "effect/ui/View" +import * as Context from "../../Context.ts" +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import type * as AsyncResult from "../../reactivity/AsyncResult.ts" +import type * as Scope from "../../Scope.ts" +import type * as Component from "../Component.ts" +import * as Renderer from "../Renderer.ts" +import type * as View from "../View.ts" import * as Html from "./Html.ts" import * as headSync from "./internal/head.ts" import * as markers from "./internal/markers.ts" diff --git a/packages/ui/html/src/BrowserRouter.ts b/packages/effect/src/ui/html/BrowserRouter.ts similarity index 97% rename from packages/ui/html/src/BrowserRouter.ts rename to packages/effect/src/ui/html/BrowserRouter.ts index 330fd8ca74..3a0768bbbb 100644 --- a/packages/ui/html/src/BrowserRouter.ts +++ b/packages/effect/src/ui/html/BrowserRouter.ts @@ -22,7 +22,7 @@ * **Example** (A two-page app) * * ```ts - * import { BrowserHost, BrowserRouter, Html } from "@effect/ui-html" + * import { BrowserHost, BrowserRouter, Html } from "effect/ui/html" * import { Effect, Layer, Option, Schema } from "effect" * import { Component, Route, Router } from "effect/ui" * @@ -64,12 +64,12 @@ * @stability experimental * @since 4.1.3 */ -import * as Context from "effect/Context" -import * as Effect from "effect/Effect" -import * as Layer from "effect/Layer" -import * as Option from "effect/Option" -import type * as Route from "effect/ui/Route" -import * as Router from "effect/ui/Router" +import * as Context from "../../Context.ts" +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as Option from "../../Option.ts" +import type * as Route from "../Route.ts" +import * as Router from "../Router.ts" import * as submit from "./internal/submit.ts" /** diff --git a/packages/ui/html/src/Html.ts b/packages/effect/src/ui/html/Html.ts similarity index 97% rename from packages/ui/html/src/Html.ts rename to packages/effect/src/ui/html/Html.ts index b800e3bf4d..1b48ca673c 100644 --- a/packages/ui/html/src/Html.ts +++ b/packages/effect/src/ui/html/Html.ts @@ -16,7 +16,7 @@ * **Example** (Registering the vocabulary for the app) * * ```ts - * import { Html } from "@effect/ui-html" + * import { Html } from "effect/ui/html" * import { View } from "effect/ui" * * declare module "effect/ui/View" { @@ -31,7 +31,7 @@ * **Example** (A controlled text field) * * ```ts import.meta.vitest - * import { Html } from "@effect/ui-html" + * import { Html } from "effect/ui/html" * import { Schema } from "effect" * import { Component } from "effect/ui" * @@ -58,12 +58,12 @@ * @stability experimental * @since 4.1.3 */ -import * as Context from "effect/Context" -import * as Effect from "effect/Effect" -import * as Option from "effect/Option" -import * as Command from "effect/ui/Command" -import * as Renderer from "effect/ui/Renderer" -import * as View from "effect/ui/View" +import * as Context from "../../Context.ts" +import * as Effect from "../../Effect.ts" +import * as Option from "../../Option.ts" +import * as Command from "../Command.ts" +import * as Renderer from "../Renderer.ts" +import * as View from "../View.ts" // --------------------------------------------------------------------------- // host @@ -89,9 +89,9 @@ export class Host extends Context.Service void readonly scrollIntoView: (element: globalThis.Element, options: ScrollOptions) => void readonly measure: (element: globalThis.Element) => Rect -}>()("@effect/ui-html/Html/Host") {} +}>()("effect/ui/html/Html/Host") {} -declare module "effect/ui/Command" { +declare module "../Command.ts" { interface FrameworkServices { readonly HtmlHost: Host } @@ -772,7 +772,7 @@ export const Measure: Command.Factory<[ref: Renderer.Ref], Option.Option` and `lang` / `dir`. */ -import * as Head from "effect/ui/Head" +import * as Head from "../../Head.ts" type Warn = (message: string) => void diff --git a/packages/ui/html/src/internal/markers.ts b/packages/effect/src/ui/html/internal/markers.ts similarity index 100% rename from packages/ui/html/src/internal/markers.ts rename to packages/effect/src/ui/html/internal/markers.ts diff --git a/packages/ui/html/src/internal/server.ts b/packages/effect/src/ui/html/internal/server.ts similarity index 98% rename from packages/ui/html/src/internal/server.ts rename to packages/effect/src/ui/html/internal/server.ts index 6afb4899af..53a81377fa 100644 --- a/packages/ui/html/src/internal/server.ts +++ b/packages/effect/src/ui/html/internal/server.ts @@ -2,8 +2,8 @@ * Server HTML: the tree, the head tags and the `` / `` attributes * as escaped strings. */ -import * as Head from "effect/ui/Head" -import type * as Renderer from "effect/ui/Renderer" +import * as Head from "../../Head.ts" +import type * as Renderer from "../../Renderer.ts" import * as markers from "./markers.ts" // --------------------------------------------------------------------------- diff --git a/packages/ui/html/src/internal/submit.ts b/packages/effect/src/ui/html/internal/submit.ts similarity index 100% rename from packages/ui/html/src/internal/submit.ts rename to packages/effect/src/ui/html/internal/submit.ts diff --git a/packages/ui/html/src/testing/HtmlQuery.ts b/packages/effect/src/ui/html/testing/HtmlQuery.ts similarity index 99% rename from packages/ui/html/src/testing/HtmlQuery.ts rename to packages/effect/src/ui/html/testing/HtmlQuery.ts index 89d221e607..24d1ec1b81 100644 --- a/packages/ui/html/src/testing/HtmlQuery.ts +++ b/packages/effect/src/ui/html/testing/HtmlQuery.ts @@ -17,7 +17,7 @@ * **Example** (Finding a button by its name) * * ```ts import.meta.vitest - * import { HtmlQuery } from "@effect/ui-html/testing" + * import { HtmlQuery } from "effect/ui/html/testing" * * const tree = { * tag: "form", @@ -35,7 +35,7 @@ * @stability experimental * @since 4.1.3 */ -import type * as Query from "effect/ui/testing/Query" +import type * as Query from "../../testing/Query.ts" // --------------------------------------------------------------------------- // trees diff --git a/packages/ui/html/src/testing/Ssr.ts b/packages/effect/src/ui/html/testing/Ssr.ts similarity index 95% rename from packages/ui/html/src/testing/Ssr.ts rename to packages/effect/src/ui/html/testing/Ssr.ts index 8c8f6ad30c..f5b432b2dd 100644 --- a/packages/ui/html/src/testing/Ssr.ts +++ b/packages/effect/src/ui/html/testing/Ssr.ts @@ -17,7 +17,7 @@ * **Example** (Checking a page hydrates) * * ```ts - * import { ssr } from "@effect/ui-html/testing" + * import { ssr } from "effect/ui/html/testing" * import { Effect, Schema } from "effect" * import { Component, Head } from "effect/ui" * @@ -40,17 +40,17 @@ * @stability experimental * @since 4.1.3 */ -import * as Context from "effect/Context" -import * as Data from "effect/Data" -import type * as Duration from "effect/Duration" -import * as Effect from "effect/Effect" -import * as Schema from "effect/Schema" -import type * as Scope from "effect/Scope" -import type * as Component from "effect/ui/Component" -import * as Head from "effect/ui/Head" -import * as MessageLog from "effect/ui/MessageLog" -import * as Renderer from "effect/ui/Renderer" -import type * as View from "effect/ui/View" +import * as Context from "../../../Context.ts" +import * as Data from "../../../Data.ts" +import type * as Duration from "../../../Duration.ts" +import * as Effect from "../../../Effect.ts" +import * as Schema from "../../../Schema.ts" +import type * as Scope from "../../../Scope.ts" +import type * as Component from "../../Component.ts" +import * as Head from "../../Head.ts" +import * as MessageLog from "../../MessageLog.ts" +import * as Renderer from "../../Renderer.ts" +import type * as View from "../../View.ts" import * as BrowserHost from "../BrowserHost.ts" import * as Html from "../Html.ts" import * as markers from "../internal/markers.ts" diff --git a/packages/ui/html/src/testing/index.ts b/packages/effect/src/ui/html/testing/index.ts similarity index 85% rename from packages/ui/html/src/testing/index.ts rename to packages/effect/src/ui/html/testing/index.ts index 239af252b5..71576766bc 100644 --- a/packages/ui/html/src/testing/index.ts +++ b/packages/effect/src/ui/html/testing/index.ts @@ -1,5 +1,5 @@ /** - * Test helpers for `@effect/ui-html`: `HtmlQuery`, and `ssr`, which renders + * Test helpers for `effect/ui/html`: `HtmlQuery`, and `ssr`, which renders * on the server, hydrates and checks the two agree. * * @stability experimental diff --git a/packages/effect/src/ui/internal/schedule.ts b/packages/effect/src/ui/internal/schedule.ts index 3e0e2686a2..a237191864 100644 --- a/packages/effect/src/ui/internal/schedule.ts +++ b/packages/effect/src/ui/internal/schedule.ts @@ -7,7 +7,11 @@ */ import type * as Command from "../Command.ts" -/** A run the scheduler knows about: a Command that is running or waiting to run. */ +/** + * A run the scheduler knows about: a Command that is running or waiting to run. + * + * @internal + */ export interface Entry { readonly name: string readonly key: string | undefined @@ -16,7 +20,11 @@ export interface Entry { readonly value: A } -/** What to do with an issued Command, and which in-flight entries it interrupts. */ +/** + * What to do with an issued Command, and which in-flight entries it interrupts. + * + * @internal + */ export interface Decision { readonly action: "start" | "queue" | "drop" | "none" readonly interrupt: ReadonlyArray> @@ -34,6 +42,8 @@ const sameGroup = (entry: Entry, name: string, key: string | undefined): b * running run. `queue` waits while the group has a running run. An `Interrupt` * starts nothing and interrupts every run with its name, or only those with * its key when it has one. + * + * @internal */ export const schedule = ( inFlight: ReadonlyArray>, @@ -63,6 +73,8 @@ export const schedule = ( /** * Decides which queued run starts when a running one ends: the oldest queued * run of the same group, if `remaining` no longer has a running one. + * + * @internal */ export const next = (remaining: ReadonlyArray>, ended: Entry): Entry | undefined => { const group = remaining.filter((entry) => sameGroup(entry, ended.name, ended.key)) diff --git a/packages/ui/html/test/BrowserHost.test.ts b/packages/effect/test/ui/html/BrowserHost.test.ts similarity index 99% rename from packages/ui/html/test/BrowserHost.test.ts rename to packages/effect/test/ui/html/BrowserHost.test.ts index 3774914799..1a172cecec 100644 --- a/packages/ui/html/test/BrowserHost.test.ts +++ b/packages/effect/test/ui/html/BrowserHost.test.ts @@ -1,8 +1,9 @@ -import { BrowserHost, Html } from "@effect/ui-html" -import { HtmlQuery } from "@effect/ui-html/testing" +// @vitest-environment happy-dom import { expect, it } from "@effect/vitest" import { Effect, Exit, Option, Schema, Scope } from "effect" import { Component, View } from "effect/ui" +import { BrowserHost, Html } from "effect/ui/html" +import { HtmlQuery } from "effect/ui/html/testing" import { describe } from "vitest" import { maxTitle, TodoApp } from "./fixtures/todos.ts" diff --git a/packages/ui/html/test/BrowserRouter.test.ts b/packages/effect/test/ui/html/BrowserRouter.test.ts similarity index 98% rename from packages/ui/html/test/BrowserRouter.test.ts rename to packages/effect/test/ui/html/BrowserRouter.test.ts index 47156bb33e..4c9898debf 100644 --- a/packages/ui/html/test/BrowserRouter.test.ts +++ b/packages/effect/test/ui/html/BrowserRouter.test.ts @@ -1,9 +1,10 @@ -import { BrowserHost, BrowserRouter } from "@effect/ui-html" -import { HtmlQuery } from "@effect/ui-html/testing" +// @vitest-environment happy-dom import { expect, it } from "@effect/vitest" import { Context, Effect, Exit, Layer, Option, Scope } from "effect" import { TestClock } from "effect/testing" import { Router } from "effect/ui" +import { BrowserHost, BrowserRouter } from "effect/ui/html" +import { HtmlQuery } from "effect/ui/html/testing" import { describe } from "vitest" import { App, AppRoute, People } from "./fixtures/routed.ts" diff --git a/packages/ui/html/test/Head.test.ts b/packages/effect/test/ui/html/Head.test.ts similarity index 98% rename from packages/ui/html/test/Head.test.ts rename to packages/effect/test/ui/html/Head.test.ts index 52ffe1ddbf..db1a8ea6da 100644 --- a/packages/ui/html/test/Head.test.ts +++ b/packages/effect/test/ui/html/Head.test.ts @@ -1,5 +1,6 @@ -import { BrowserHost } from "@effect/ui-html" +// @vitest-environment happy-dom import { Head } from "effect/ui" +import { BrowserHost } from "effect/ui/html" import { afterEach, describe, expect, it } from "vitest" const head = (...entries: ReadonlyArray) => Head.merge({ entries, children: [] }) diff --git a/packages/ui/html/test/HtmlQuery.test.ts b/packages/effect/test/ui/html/HtmlQuery.test.ts similarity index 98% rename from packages/ui/html/test/HtmlQuery.test.ts rename to packages/effect/test/ui/html/HtmlQuery.test.ts index a26184e3e5..0c7e7d18ab 100644 --- a/packages/ui/html/test/HtmlQuery.test.ts +++ b/packages/effect/test/ui/html/HtmlQuery.test.ts @@ -1,6 +1,7 @@ -import { HtmlQuery } from "@effect/ui-html/testing" +// @vitest-environment happy-dom import { describe, expect, it } from "@effect/vitest" import { Effect } from "effect" +import { HtmlQuery } from "effect/ui/html/testing" import { Query, Story, TestHost } from "effect/ui/testing" import { TodoApp, TodoAppMessage } from "./fixtures/todos.ts" diff --git a/packages/ui/html/test/HtmlServer.test.ts b/packages/effect/test/ui/html/HtmlServer.test.ts similarity index 99% rename from packages/ui/html/test/HtmlServer.test.ts rename to packages/effect/test/ui/html/HtmlServer.test.ts index 10fa35a93d..f5dc814450 100644 --- a/packages/ui/html/test/HtmlServer.test.ts +++ b/packages/effect/test/ui/html/HtmlServer.test.ts @@ -1,8 +1,9 @@ -import { BrowserHost, Html, HtmlServer } from "@effect/ui-html" -import { ssr } from "@effect/ui-html/testing" +// @vitest-environment happy-dom import { expect, it } from "@effect/vitest" import { Context, Effect, Fiber, Layer, Option, Schema } from "effect" import { Command, Component, Feature, Head, Router } from "effect/ui" +import { BrowserHost, Html, HtmlServer } from "effect/ui/html" +import { ssr } from "effect/ui/html/testing" import { describe } from "vitest" import { App, AppRoute, People } from "./fixtures/routed.ts" diff --git a/packages/ui/html/test/fixtures/routed.ts b/packages/effect/test/ui/html/fixtures/routed.ts similarity index 99% rename from packages/ui/html/test/fixtures/routed.ts rename to packages/effect/test/ui/html/fixtures/routed.ts index 1346c2d02b..86c6de0221 100644 --- a/packages/ui/html/test/fixtures/routed.ts +++ b/packages/effect/test/ui/html/fixtures/routed.ts @@ -3,9 +3,9 @@ * page that loads its bio on entry with a server Command, a search route * and a slow page whose provided Layer takes a second to build. */ -import { Html } from "@effect/ui-html" import { Context, Effect, Layer, Schema } from "effect" import { Command, Component, Head, Route, Router } from "effect/ui" +import { Html } from "effect/ui/html" export const AppRoute = Route.union({ Home: Route.make("/"), diff --git a/packages/ui/html/test/fixtures/todos.ts b/packages/effect/test/ui/html/fixtures/todos.ts similarity index 99% rename from packages/ui/html/test/fixtures/todos.ts rename to packages/effect/test/ui/html/fixtures/todos.ts index a4112826cb..c73fff67d8 100644 --- a/packages/ui/html/test/fixtures/todos.ts +++ b/packages/effect/test/ui/html/fixtures/todos.ts @@ -3,9 +3,9 @@ * characters, a keyed list of rows with a controlled checkbox each, and a * button that clears the done ones. */ -import { Html } from "@effect/ui-html" import { Schema } from "effect" import { Component } from "effect/ui" +import { Html } from "effect/ui/html" export const maxTitle = 20 diff --git a/packages/ui/html/typetest/Html.tst.ts b/packages/effect/typetest/ui/html/Html.tst.ts similarity index 98% rename from packages/ui/html/typetest/Html.tst.ts rename to packages/effect/typetest/ui/html/Html.tst.ts index e084c8a317..7db4b6746f 100644 --- a/packages/ui/html/typetest/Html.tst.ts +++ b/packages/effect/typetest/ui/html/Html.tst.ts @@ -1,7 +1,7 @@ -import { BrowserHost, Html } from "@effect/ui-html" -import { HtmlQuery } from "@effect/ui-html/testing" import { Effect, Schema, type Scope } from "effect" import { Component, Renderer, type View } from "effect/ui" +import { BrowserHost, Html } from "effect/ui/html" +import { HtmlQuery } from "effect/ui/html/testing" import type { Query } from "effect/ui/testing" import { describe, expect, it } from "tstyche" diff --git a/packages/ui/html/LICENSE b/packages/ui/html/LICENSE deleted file mode 100644 index be1f5c14c7..0000000000 --- a/packages/ui/html/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Effectful Technologies Inc - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/ui/html/README.md b/packages/ui/html/README.md deleted file mode 100644 index d61f7c5525..0000000000 --- a/packages/ui/html/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# @effect/ui-html - -The HTML vocabulary, browser host, browser router and server renderer for `effect/ui`, the Layer-composed frontend framework in the `effect` package. - -## Installation - -```sh -npm install effect @effect/ui-html -``` - -## Links - -- [Website](https://effect.website): documentation, guides, and news. -- [Reference](https://effect.website/docs/v4/api/ui-html): API documentation for this package. -- [Discord](https://discord.gg/effect-ts): ask questions, share what you're building, and talk to the core team. -- [Community](https://effect.website/community-hub): meetups and events, or bring Effect to your own. -- [Issues](https://github.com/Effect-TS/effect/issues): bug reports and feature requests. - -## Let's talk - -Whether your team is considering Effect, rolling it out, or already running it in production, we'd love to hear from you: what you're building, what works, and what you need from Effect next. - -- **Talk to the maintainers.** Introduce your team on [Discord](https://discord.gg/effect-ts) or email [contact@effectful.co](mailto:contact@effectful.co). We're happy to connect privately on Slack or Discord for feedback and help with adoption. -- **Production support.** We're exploring how to better support teams running Effect in production. If your organization has specific support needs, let's discuss them. -- **Adoption help.** Our [adoption partners](https://effect.website/adoption-partners) offer implementation, consulting, team extension, training, and commercial support. diff --git a/packages/ui/html/package.json b/packages/ui/html/package.json deleted file mode 100644 index 6f6a6112db..0000000000 --- a/packages/ui/html/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@effect/ui-html", - "type": "module", - "version": "0.0.0", - "license": "MIT", - "description": "HTML vocabulary, browser host and server renderer for effect/ui", - "homepage": "https://effect.website", - "repository": { - "type": "git", - "url": "https://github.com/Effect-TS/effect.git", - "directory": "packages/ui/html" - }, - "bugs": { - "url": "https://github.com/Effect-TS/effect/issues" - }, - "tags": [ - "typescript", - "ui", - "html", - "browser", - "functional-programming" - ], - "keywords": [ - "typescript", - "ui", - "html", - "browser", - "functional-programming" - ], - "sideEffects": [], - "exports": { - "./package.json": "./package.json", - ".": "./src/index.ts", - "./testing": "./src/testing/index.ts", - "./*": "./src/*.ts", - "./internal/*": null, - "./index": null, - "./*/index": null - }, - "files": [ - "src/**/*.ts", - "dist/**/*.js", - "dist/**/*.js.map", - "dist/**/*.d.ts", - "dist/**/*.d.ts.map", - "AGENTS.md", - "CLAUDE.md", - "ai-docs/**/*" - ], - "publishConfig": { - "access": "public", - "provenance": true, - "exports": { - "./package.json": "./package.json", - ".": "./dist/index.js", - "./testing": "./dist/testing/index.js", - "./*": "./dist/*.js", - "./internal/*": null, - "./index": null, - "./*/index": null - } - }, - "scripts": { - "codegen": "effect-utils codegen", - "build": "tsc -b tsconfig.json && pnpm babel", - "babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", - "check": "tsc -b tsconfig.json" - }, - "peerDependencies": { - "effect": "workspace:^" - }, - "devDependencies": { - "effect": "workspace:^" - } -} diff --git a/packages/ui/html/tsconfig.json b/packages/ui/html/tsconfig.json deleted file mode 100644 index e2a8ca19a0..0000000000 --- a/packages/ui/html/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "extends": "../../../tsconfig.base.json", - "include": ["src"], - "references": [ - { "path": "../../effect" } - ] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b1118d2314..c4060dda2c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1067,12 +1067,6 @@ importers: specifier: ^26.6.6 version: 26.6.6 - packages/ui/html: - devDependencies: - effect: - specifier: workspace:^ - version: link:../../effect - packages/vitest: devDependencies: '@types/node': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 55ac6d45e0..cba8d98961 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -8,7 +8,6 @@ packages: - packages/platform/* - packages/sql/* - packages/tools/* - - packages/ui/* - examples/* verifyDepsBeforeRun: error diff --git a/scripts/check-dist-types.mjs b/scripts/check-dist-types.mjs index ee639fe1b7..e65584bd75 100644 --- a/scripts/check-dist-types.mjs +++ b/scripts/check-dist-types.mjs @@ -48,10 +48,11 @@ try { Fs.writeFileSync(Path.join(dir, "tsconfig.json"), JSON.stringify(config)) execFileSync("pnpm", ["exec", "tsc", "-p", Path.join(dir, "tsconfig.json")], { cwd: root, stdio: "inherit" }) - // Core, crypto and JOSE imports must work without DOM types (see Effect-TS/effect#10115). + // Core, crypto, JOSE and UI imports must work without DOM types (see Effect-TS/effect#10115). + // Only `effect/ui/html` may need the DOM lib. Fs.writeFileSync( Path.join(dir, "index.ts"), - ["effect", "effect/Effect", "effect/Schema", "effect/crypto/KeyFormat", "effect/jose"] + ["effect", "effect/Effect", "effect/Schema", "effect/crypto/KeyFormat", "effect/jose", "effect/ui", "effect/ui/testing"] .map((entry, i) => `import * as _${i} from "${entry}"\nexport { _${i} }\n`).join("") ) config.compilerOptions.lib = ["ES2024"] diff --git a/scripts/circular.mjs b/scripts/circular.mjs index bcfc6106d6..39fead0e60 100644 --- a/scripts/circular.mjs +++ b/scripts/circular.mjs @@ -3,7 +3,7 @@ import * as glob from "glob" import madge from "madge" madge( - glob.globSync(["packages/*/src/**/*.ts", "packages/ai/*/src/**/*.ts", "packages/platform/*/src/**/*.ts", "packages/ui/*/src/**/*.ts"], { + glob.globSync(["packages/*/src/**/*.ts", "packages/ai/*/src/**/*.ts", "packages/platform/*/src/**/*.ts"], { ignore: [ "packages/sql-sqlite-bun/**", "packages/experimental/src/EventLogServer/Cloudflare.ts" diff --git a/scripts/clean.mjs b/scripts/clean.mjs index 84994daec9..aad0b637eb 100644 --- a/scripts/clean.mjs +++ b/scripts/clean.mjs @@ -1,7 +1,7 @@ import * as Glob from "glob" import * as Fs from "node:fs" -const dirs = [".", ...Glob.sync("packages/*/"), ...Glob.sync("packages/sql/*/"), ...Glob.sync("packages/tools/*/"), ...Glob.sync("packages/ai/*/"), ...Glob.sync("packages/atom/*/"), ...Glob.sync("packages/platform/*/"), ...Glob.sync("packages/ui/*/")] +const dirs = [".", ...Glob.sync("packages/*/"), ...Glob.sync("packages/sql/*/"), ...Glob.sync("packages/tools/*/"), ...Glob.sync("packages/ai/*/"), ...Glob.sync("packages/atom/*/"), ...Glob.sync("packages/platform/*/")] dirs.forEach((pkg) => { const files = [".tsbuildinfo", "tsconfig.tsbuildinfo", "tsconfig.fixtures.tsbuildinfo", "tsconfig.src.tsbuildinfo", "docs", "build", "dist", "coverage"] if (pkg !== ".") { diff --git a/tsconfig.packages.json b/tsconfig.packages.json index 61d3b95346..e92c8e8fa6 100644 --- a/tsconfig.packages.json +++ b/tsconfig.packages.json @@ -46,7 +46,6 @@ { "path": "packages/tools/npm-promote" }, { "path": "packages/tools/oxc" }, { "path": "packages/tools/utils" }, - { "path": "packages/ui/html" }, { "path": "packages/vitest" } ] } diff --git a/tsconfig.tests.json b/tsconfig.tests.json index 0f5ff48d9c..3b76641f6b 100644 --- a/tsconfig.tests.json +++ b/tsconfig.tests.json @@ -41,6 +41,8 @@ "effect/schema": ["./packages/effect/src/schema/index.ts"], "effect/ui": ["./packages/effect/src/ui/index.ts"], "effect/ui/testing": ["./packages/effect/src/ui/testing/index.ts"], + "effect/ui/html": ["./packages/effect/src/ui/html/index.ts"], + "effect/ui/html/testing": ["./packages/effect/src/ui/html/testing/index.ts"], "effect/*": ["./packages/effect/src/*.ts"], "@effect/ai-amazon-bedrock": ["./packages/ai/amazon-bedrock/src/index.ts"], "@effect/ai-amazon-bedrock/*": ["./packages/ai/amazon-bedrock/src/*.ts"], @@ -116,9 +118,6 @@ "@effect/oxc/*": ["./packages/tools/oxc/src/*.ts"], "@effect/tools-utils": ["./packages/tools/utils/src/index.ts"], "@effect/tools-utils/*": ["./packages/tools/utils/src/*.ts"], - "@effect/ui-html": ["./packages/ui/html/src/index.ts"], - "@effect/ui-html/testing": ["./packages/ui/html/src/testing/index.ts"], - "@effect/ui-html/*": ["./packages/ui/html/src/*.ts"], "@effect/vitest": ["./packages/vitest/src/index.ts"], "@effect/vitest/*": ["./packages/vitest/src/*.ts"], // TODO: This is a special alias used by some tests. We should try to get rid of it. diff --git a/vitest.config.ts b/vitest.config.ts index 379b92e257..5a19ae900f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -198,11 +198,6 @@ export default defineConfig({ ] ), ...project("@effect/platform-node-shared", "packages/platform/node-shared", isNode), - ...project("@effect/ui-html", "packages/ui/html", true, { - test: { - environment: "happy-dom" - } - }), ...project("@effect/vitest", "packages/vitest"), ...project("@effect/sql-clickhouse", "packages/sql/clickhouse"), ...project("@effect/sql-d1", "packages/sql/d1", !isDeno),