The positioning engine is pure collision geometry over `$adom` — a runtime artifact, not soma-specific. Moves it out of `soma/layers/floating/engine/` into a new `arts/floating` art (`$floating`), exactly parallel to `$motion`: both soma (the JS positioning path) and eidos (the CSS-anchor path, future) build on it, so the shared pure core belongs in arts, not buried in one consumer. Moved to `$floating` (git renames, history preserved): geometry, rects, clipping, overflow, supports, compute, auto-update, flag, types, the 7 middleware, and the two parity test suites. `placement.ts` and the contract types `Measurable` / `Middleware` / `MiddlewareData` move too — `$floating` is now self-contained (depends only on `$adom`, never back on soma). New `arts/floating/index.ts` barrel is the public surface. Alias `$floating` added to vite.config.ts + svelte.config.js. Stays in `soma/layers/floating/` (reactive composition): use-floating.svelte.ts (runes), floating.svelte.ts (providers/context), shell.ts, safe-polygon.ts, utils.ts, the reactive types, index.ts. These now import `$floating`; soma's types.ts/index.ts + soma/types/index.ts re-export the placement/contract types. Two latent type gaps the typed `$floating` surface exposed (the soma loose-factory shim had hidden them) are fixed: `DetectOverflowOptions` now declares `boundary` (the middleware genuinely accept it; compute's read phase extracts it), and a `size` test's `apply` returns void. `@floating-ui` is UNTOUCHED — P4 deliberately NOT executed: the dep stays installed, the fui imports + the `USE_OWN_ENGINE` flag (still OFF) remain in the wrappers, the runtime still positions via floating-ui. Verified: 350 synthetic + 137 real-DOM parity cases green from the new location, soma overlay providers green, check clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>menubar-v4-safe
parent
f204b55741
commit
58683b0306
@ -1,8 +1,8 @@
|
||||
// Pure placement / coordinate math. No DOM, no reads — all inputs are rects.
|
||||
// Reimplemented from the floating-ui algorithm (spec), our idioms + types.
|
||||
|
||||
import type { Align, Placement, Side } from '../placement'
|
||||
import { OPPOSITE_SIDE } from '../placement'
|
||||
import type { Align, Placement, Side } from './placement'
|
||||
import { OPPOSITE_SIDE } from './placement'
|
||||
import type { Axis, Coords, ElementRects, Length, Padding, SideObject } from './types'
|
||||
|
||||
const OPPOSITE_ALIGN: Record<'start' | 'end', 'start' | 'end'> = { start: 'end', end: 'start' }
|
||||
@ -0,0 +1,82 @@
|
||||
// `$floating` — the in-house positioning engine, an art (parallel to `$motion`).
|
||||
//
|
||||
// Pure collision/positioning geometry over `$adom`'s DOM reads. It has NO
|
||||
// reactive / component dependency — the Svelte wrappers (`use-floating`,
|
||||
// `FloatingContent` providers) live in `soma/layers/floating` and consume this.
|
||||
// Both soma (the JS positioning path) and eidos (the CSS-anchor path) build on
|
||||
// it, exactly as both build on `$motion` / `$color`.
|
||||
//
|
||||
// floating-ui was read as the spec (MIT); nothing is vendored — these are our
|
||||
// own idioms + types. Verified pixel-identical to `@floating-ui` by the parity
|
||||
// suites (`engine.test.ts` + `engine-dom.svelte.test.ts`).
|
||||
|
||||
export { computePosition, runMiddleware, type ReadSnapshot } from './compute'
|
||||
export { autoUpdate, type AutoUpdateOptions } from './auto-update'
|
||||
export { supportsCssAnchor } from './supports'
|
||||
export { USE_OWN_ENGINE } from './flag'
|
||||
|
||||
export {
|
||||
offset,
|
||||
shift,
|
||||
flip,
|
||||
arrow,
|
||||
size,
|
||||
hide,
|
||||
limitShift,
|
||||
type OffsetOptions,
|
||||
type ShiftOptions,
|
||||
type FlipOptions,
|
||||
type ArrowOptions,
|
||||
type SizeOptions,
|
||||
type SizeApplyArgs,
|
||||
type HideOptions,
|
||||
type LimitShiftOptions,
|
||||
type ShiftLimiter
|
||||
} from './middleware'
|
||||
|
||||
export {
|
||||
SIDE_OPTIONS,
|
||||
ALIGN_OPTIONS,
|
||||
OPPOSITE_SIDE,
|
||||
type Side,
|
||||
type Align,
|
||||
type Boundary,
|
||||
type Placement,
|
||||
type Strategy
|
||||
} from './placement'
|
||||
|
||||
export type {
|
||||
Measurable,
|
||||
Middleware,
|
||||
MiddlewareData,
|
||||
MiddlewareState,
|
||||
MiddlewareReturn,
|
||||
ComputePositionConfig,
|
||||
ComputePositionReturn,
|
||||
Coords,
|
||||
Dimensions,
|
||||
Rect,
|
||||
SideObject,
|
||||
Padding,
|
||||
Axis,
|
||||
Length,
|
||||
ElementRects,
|
||||
FloatingElements,
|
||||
ClippingContext
|
||||
} from './types'
|
||||
|
||||
export {
|
||||
getSide,
|
||||
getAlignment,
|
||||
getSideAxis,
|
||||
getAlignmentAxis,
|
||||
getAxisLength,
|
||||
getOppositeAxis,
|
||||
getOppositePlacement,
|
||||
getOppositeAlignmentPlacement,
|
||||
getAlignmentSides,
|
||||
getExpandedPlacements,
|
||||
getOppositeAxisPlacements,
|
||||
getPaddingObject,
|
||||
computeCoordsFromPlacement
|
||||
} from './geometry'
|
||||
@ -1,7 +1,7 @@
|
||||
// offset — shifts the floating element along the main / cross / alignment axes.
|
||||
// PURE. Reimplemented from floating-ui's `offset` (spec).
|
||||
|
||||
import type { Placement } from '../../placement'
|
||||
import type { Placement } from '../placement'
|
||||
import { getAlignment, getSide, getSideAxis } from '../geometry'
|
||||
import type { Coords, Middleware, MiddlewareState } from '../types'
|
||||
|
||||
@ -1,10 +1,27 @@
|
||||
// Engine-internal positioning types. Reimplemented to our idioms (floating-ui as
|
||||
// spec). The public `Middleware`/`MiddlewareData` in ../types are the consumer
|
||||
// surface; these are the math types the engine threads internally.
|
||||
// Positioning types for the `$floating` art — math types the engine threads
|
||||
// internally, plus the public consumer contract (`Measurable`, `Middleware`,
|
||||
// `MiddlewareData`). Reimplemented to our idioms (floating-ui read as spec).
|
||||
|
||||
import type { ActiveDom } from '$adom'
|
||||
import type { Placement, Strategy } from '../placement'
|
||||
import type { MiddlewareData, Measurable } from '../types'
|
||||
import type { Placement, Strategy } from './placement'
|
||||
|
||||
/** The anchor/reference — a real element or a virtual element exposing only a
|
||||
* `getBoundingClientRect` (the context-menu / `customAnchor` pattern). */
|
||||
export type Measurable = {
|
||||
getBoundingClientRect: () => DOMRect
|
||||
}
|
||||
|
||||
/**
|
||||
* Per-middleware results read off `computePosition`. Open-ended (`[key]` index)
|
||||
* for forward-compat + the custom `transformOrigin` middleware. Only the keys
|
||||
* the consumers actually read are typed.
|
||||
*/
|
||||
export interface MiddlewareData {
|
||||
arrow?: { x?: number; y?: number; centerOffset?: number; alignmentOffset?: number }
|
||||
hide?: { referenceHidden?: boolean; escaped?: boolean }
|
||||
transformOrigin?: { x: number | string; y: number | string }
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type Axis = 'x' | 'y'
|
||||
export type Length = 'width' | 'height'
|
||||
Loading…
Reference in new issue