foldkit-mixins 0.24.0 → 0.25.0

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/README.md CHANGED
@@ -199,9 +199,21 @@ Attachments are not concatenated and left to renderer order. The resolver applie
199
199
  - inline styles from Style pieces merge per property, later attachments winning, over the
200
200
  view's base; a property a Behavior sets (through `h.Style` in its attributes) has exactly one
201
201
  owner, so a Style piece, the base, or a second Behavior setting the same property is an error;
202
- - an event or scalar attribute has exactly one owner — a second owner is an error;
203
- - a `ChildAttribute` (a Submodel's published handler) is preserved by identity;
204
- - `Key` and `InnerHTML` are structural and cannot be overridden;
202
+ - an event or scalar attribute has exactly one owner — a second owner is an error. Owners are
203
+ compared by what Foldkit really sets on the element: `h.OnKeyDownPreventDefault` owns `keydown`
204
+ as `h.OnKeyDown` does, `h.OnDoubleClick` owns `dblclick`, and `h.AriaLabel`,
205
+ `h.Attribute('aria-label', …)` and a `Prop` named `ariaLabel` share one owner;
206
+ - a `ChildAttribute` (a Submodel's published handler) is preserved by identity; one a Mixin adds
207
+ meets the same ownership and protection checks as its own attributes, and a child `Class` joins
208
+ the one `Class`;
209
+ - the resolver writes the one `class` and `style`, so a Mixin may not set either through
210
+ `h.Attribute`, a `Prop` or a child `Style`, nor an inline handler (`h.Attribute('onclick', …)`);
211
+ - a style property is the declaration it writes, so `insetInlineEnd` and `'inset-inline-end'` are
212
+ one property. A protected property, or one a Behavior owns, is also guarded against what writes
213
+ over it: a shorthand (`inset`, `margin`), its physical side (`right` or `left` for
214
+ `insetInlineEnd`), and `translate`, `rotate` or `scale` beside `transform`;
215
+ - `Key`, `InnerHTML` and a `Prop` that replaces the children are structural and cannot be
216
+ overridden;
205
217
  - multiple mount contributions compose into exactly one `OnMount`.
206
218
 
207
219
  Conflicts throw `Diagnostics.DiagnosticError` with stable codes such as
@@ -1318,7 +1330,10 @@ styles({ sheet: '/src/server/sheet.ts', modules: ['/src/client/style.ts'] })
1318
1330
  module and the sheet import.
1319
1331
  - **Production and development.** With a module listed, a production browser
1320
1332
  build's Slots inject nothing: the linked sheet holds every class, and the
1321
- build fails if a class a frozen module draws has no rule in it. Development
1333
+ build fails if a class a frozen module draws has no rule in it. It fails
1334
+ too if the page still compiles a Style (a module left off the list, or a
1335
+ `Style.perItem` made at draw time), naming the modules that bring the
1336
+ compiler, since its classes would have no rule to draw. Development
1322
1337
  is unchanged: modules run as written, and a Slot injects what it draws. The
1323
1338
  server build is unchanged too.
1324
1339
 
package/dist/defaults.js CHANGED
@@ -62,8 +62,8 @@ const controls = global([
62
62
  `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v("error-default", "red")}}`,
63
63
  `:where(button,[type=button],[type=submit],[type=reset]){padding:${v("space-xs", "0.5rem")} ${v("space-md", "1rem")};border:${v("border-thin", "1px")} solid ${v("outline-default", "ButtonBorder")};border-radius:${v("radius-md", "6px")};background:${v("surface-subtle", "ButtonFace")};color:${v("text-default", "ButtonText")};cursor:pointer;transition:background ${v("motion-fast", "150ms")} ${v("motion-ease", "ease-out")}}`,
64
64
  `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover:not([aria-disabled=true]){background:${v("surface-muted", "ButtonFace")}}}`,
65
- `:where(button,[type=button],[type=submit],[type=reset]):active{background:${v("surface-muted", "ButtonFace")}}`,
66
- `:where(:is(button,input,select,textarea):disabled,button[aria-disabled=true]){opacity:0.5;cursor:not-allowed}`,
65
+ `:where(button,[type=button],[type=submit],[type=reset]):active:not([aria-disabled=true]){background:${v("surface-muted", "ButtonFace")}}`,
66
+ `:where(:is(button,input,select,textarea):disabled,:is(button,[type=button],[type=submit],[type=reset])[aria-disabled=true]){opacity:0.5;cursor:not-allowed}`,
67
67
  `:where(:is(input,select,textarea,button)::placeholder){color:${v("text-muted", "GrayText")}}`
68
68
  ].join(""));
69
69
  /** Every default except `reset`, which belongs in its own layer. */
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n // 100%, not none: none stops a phone enlarging text in landscape, and also the\n // reader's own text size, where a browser applies it through this property.\n ':where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n // A tap draws no grey square of the browser's own: what was pressed shows its own\n // `:active` state (Defaults.controls, the recipes). And a second tap is a tap, not a\n // zoom, so a quick press on a stepper or a pager does not wait for one.\n ':where(:root){-webkit-tap-highlight-color:transparent}',\n ':where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}',\n // What a finger needs, 44px, as the platforms advise: the recipes' controls are at least\n // this tall where the pointer is coarse, and keep their density elsewhere. A region that\n // must stay dense sets it to 0.\n '@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}',\n // A control's words are its name, not text to select: a long press on a button, a tab or\n // a menu row selected them on a phone and offered to copy, and a double tap selected a\n // word. Prefixed by hand, as iOS Safari reads only the prefixed one. Not a tree's rows or\n // a grid's cells, whose text may be edited or copied.\n ':where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:var(--fk-reading-heading-wrap, balance)}',\n ':where(p){text-wrap:var(--fk-reading-body-wrap, pretty);overflow-wrap:break-word}',\n // Reduced motion is fewer and gentler, not none: what moves snaps (the\n // `travel` knob on every element, important so one that sets the knob\n // itself, a scoped theme's or an inline one, cannot restore it), while a\n // fade keeps its duration. Keyframes are a recipe's own and still stop.\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n // Only where something hovers: a touch screen keeps `:hover` on the link tapped last.\n `@media (hover:hover){:where(a:hover){color:${v('text-link-hover', 'LinkText')}}}`,\n `:where(a:active){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover:not([aria-disabled=true]){background:${v('surface-muted', 'ButtonFace')}}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):active{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled,button[aria-disabled=true]){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CAGA;CAIA;CACA;CAIA;CAKA;CACA;CACA;CACA;CACA;CACA;CAKA;AACF,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,OAAmB,OAG9B,iCAAiC,EAAE,iBAAiB,MAAM,EAAE,4BAA4B,EA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AAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
1
+ {"version":3,"file":"defaults.js","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n // 100%, not none: none stops a phone enlarging text in landscape, and also the\n // reader's own text size, where a browser applies it through this property.\n ':where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n // A tap draws no grey square of the browser's own: what was pressed shows its own\n // `:active` state (Defaults.controls, the recipes). And a second tap is a tap, not a\n // zoom, so a quick press on a stepper or a pager does not wait for one.\n ':where(:root){-webkit-tap-highlight-color:transparent}',\n ':where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}',\n // What a finger needs, 44px, as the platforms advise: the recipes' controls are at least\n // this tall where the pointer is coarse, and keep their density elsewhere. A region that\n // must stay dense sets it to 0.\n '@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}',\n // A control's words are its name, not text to select: a long press on a button, a tab or\n // a menu row selected them on a phone and offered to copy, and a double tap selected a\n // word. Prefixed by hand, as iOS Safari reads only the prefixed one. Not a tree's rows or\n // a grid's cells, whose text may be edited or copied.\n ':where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:var(--fk-reading-heading-wrap, balance)}',\n ':where(p){text-wrap:var(--fk-reading-body-wrap, pretty);overflow-wrap:break-word}',\n // Reduced motion is fewer and gentler, not none: what moves snaps (the\n // `travel` knob on every element, important so one that sets the knob\n // itself, a scoped theme's or an inline one, cannot restore it), while a\n // fade keeps its duration. Keyframes are a recipe's own and still stop.\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n // Only where something hovers: a touch screen keeps `:hover` on the link tapped last.\n `@media (hover:hover){:where(a:hover){color:${v('text-link-hover', 'LinkText')}}}`,\n `:where(a:active){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover:not([aria-disabled=true]){background:${v('surface-muted', 'ButtonFace')}}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):active:not([aria-disabled=true]){background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled,:is(button,[type=button],[type=submit],[type=reset])[aria-disabled=true]){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CAG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G,EAAE,iBAAiB,YAAY,EAAE;CACxI;CACA,gEAAgE,EAAE,cAAc,UAAU,EAAE;AAC9F,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,MAAkB,QAAQ,MAAM,UAAU,OAAO,MAAM,QAAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
@@ -0,0 +1,42 @@
1
+ import { Attribute } from "foldkit/html";
2
+ import { Option } from "effect";
3
+ /** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */
4
+ export declare const normalizeName: (name: string) => string;
5
+ type FoldkitTag = Attribute<unknown>['_tag'];
6
+ /** Handlers that are no one DOM event: a Mount is composed, an unmount is a hook, and a custom event names its own. */
7
+ type NotOneEvent = 'OnMount' | 'OnUnmount' | 'OnCustomEvent';
8
+ type EventTag = Exclude<Extract<FoldkitTag, `On${string}`>, NotOneEvent> | 'AllowDrop';
9
+ /**
10
+ * The DOM event each Foldkit handler builder registers. The variants own their
11
+ * base event: `OnKeyDownPreventDefault` listens to `keydown`, and Foldkit
12
+ * chains it onto any other `keydown` handler on the element. A Foldkit release
13
+ * that adds a handler fails to compile here until it is listed.
14
+ */
15
+ export declare const EVENT_OF_TAG: { readonly [Tag in EventTag]: string; };
16
+ /**
17
+ * The DOM event a contribution listens to, normalized like a protected event:
18
+ * `OnClick` and `OnCustomEvent('click')` both read `click`, and
19
+ * `OnKeyDownPreventDefault` reads `keydown`. `None` for an attribute that is
20
+ * no event, a custom event with no name, or a handler `isUnknownHandler` names.
21
+ */
22
+ export declare const eventNameOf: (tag: string, value: unknown) => Option.Option<string>;
23
+ /**
24
+ * A tag shaped like a handler that Foldkit's table lacks: a child attribute's
25
+ * from another Foldkit, say. Its event cannot be read from its spelling (that
26
+ * guess once let every variant past protection), so the resolver refuses it.
27
+ */
28
+ export declare const isUnknownHandler: (tag: string) => boolean;
29
+ /**
30
+ * An `Attribute` or `Prop` named like `onclick`: an inline handler, which
31
+ * listens to its event outside every owner and protection the resolver keeps.
32
+ */
33
+ export declare const isInlineHandler: (tag: string, value: unknown) => boolean;
34
+ /**
35
+ * The HTML attribute a contribution sets, normalized to compare with a protected one:
36
+ * `AriaLabel`, `Attribute('aria-label')` and `Prop({ key: 'ariaLabel' })` all read
37
+ * `arialabel`, `Prop({ key: 'className' })` reads `class`, and `DataAttribute('x')`
38
+ * reads as `data-x`.
39
+ */
40
+ export declare const attributeNameOf: (tag: string, value: unknown) => string;
41
+ export {};
42
+ //# sourceMappingURL=foldkitNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foldkitNames.d.ts","names":[],"sources":["../src/foldkitNames.ts"],"mappings":";;;qBAWa,gBAAa;KAErB,aAAa;;KAGb;KAEA,WAAW,QAAQ,QAAQ,4BAA4B;;;;;;;qBAQ/C,0BAA0B,OAAO;;;;;;;qBAsFjC,cAAW,aAAe,mBAAmB,OAAO;;;;;;qBAkBpD,mBAAgB;;;;;qBA8ChB,kBAAe,aAAe;;;;;;;qBAgB9B,kBAAe,aAAe"}
@@ -0,0 +1,169 @@
1
+ import { Option } from "effect";
2
+ // src/foldkitNames.ts
3
+ /**
4
+ * What a Foldkit attribute really sets on its element: the DOM event it
5
+ * listens to and the HTML attribute it writes, read from Foldkit's handler
6
+ * table (`foldkit/dist/html/index.js`, `attributeHandlers`), not from its tag.
7
+ * The resolver compares these, so every spelling of one event or attribute
8
+ * meets one owner and one protection. Internal: not exported from the package.
9
+ */
10
+ /** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */
11
+ const normalizeName = (name) => name.replace(/[^a-z0-9]/gi, "").toLowerCase();
12
+ /**
13
+ * The DOM event each Foldkit handler builder registers. The variants own their
14
+ * base event: `OnKeyDownPreventDefault` listens to `keydown`, and Foldkit
15
+ * chains it onto any other `keydown` handler on the element. A Foldkit release
16
+ * that adds a handler fails to compile here until it is listed.
17
+ */
18
+ const EVENT_OF_TAG = {
19
+ OnClick: "click",
20
+ OnDoubleClick: "dblclick",
21
+ OnMouseDown: "mousedown",
22
+ OnMouseUp: "mouseup",
23
+ OnMouseEnter: "mouseenter",
24
+ OnMouseLeave: "mouseleave",
25
+ OnMouseOver: "mouseover",
26
+ OnMouseOut: "mouseout",
27
+ OnMouseMove: "mousemove",
28
+ OnPointerMove: "pointermove",
29
+ OnPointerLeave: "pointerleave",
30
+ OnPointerDown: "pointerdown",
31
+ OnPointerUp: "pointerup",
32
+ OnKeyDown: "keydown",
33
+ OnKeyDownPreventDefault: "keydown",
34
+ OnKeyDownSelf: "keydown",
35
+ OnKeyDownSelfPreventDefault: "keydown",
36
+ OnKeyDownFocus: "keydown",
37
+ OnKeyUp: "keyup",
38
+ OnKeyUpPreventDefault: "keyup",
39
+ OnKeyPress: "keypress",
40
+ OnFocus: "focus",
41
+ OnBlur: "blur",
42
+ OnFocusEnter: "focusin",
43
+ OnFocusLeave: "focusout",
44
+ OnInput: "input",
45
+ OnChange: "change",
46
+ OnBeforeInput: "beforeinput",
47
+ OnBeforeInputPreventDefault: "beforeinput",
48
+ OnFileChange: "change",
49
+ OnSubmit: "submit",
50
+ OnReset: "reset",
51
+ OnScroll: "scroll",
52
+ OnWheel: "wheel",
53
+ OnCopy: "copy",
54
+ OnCut: "cut",
55
+ OnPaste: "paste",
56
+ OnPastePreventDefault: "paste",
57
+ OnCopyText: "copy",
58
+ OnCutText: "cut",
59
+ OnCancel: "cancel",
60
+ OnCancelPreventDefault: "cancel",
61
+ OnToggle: "toggle",
62
+ OnContextMenu: "contextmenu",
63
+ OnDragStart: "dragstart",
64
+ OnDrag: "drag",
65
+ OnDragEnd: "dragend",
66
+ OnDragEnter: "dragenter",
67
+ OnDragLeave: "dragleave",
68
+ OnDragOver: "dragover",
69
+ AllowDrop: "dragover",
70
+ OnDrop: "drop",
71
+ OnDropFiles: "drop",
72
+ OnTouchStart: "touchstart",
73
+ OnTouchEnd: "touchend",
74
+ OnTouchMove: "touchmove",
75
+ OnTouchCancel: "touchcancel",
76
+ OnAnimationStart: "animationstart",
77
+ OnAnimationEnd: "animationend",
78
+ OnAnimationIteration: "animationiteration",
79
+ OnTransitionEnd: "transitionend",
80
+ OnLoad: "load",
81
+ OnError: "error",
82
+ OnPlay: "play",
83
+ OnPause: "pause",
84
+ OnEnded: "ended",
85
+ OnTimeUpdate: "timeupdate",
86
+ OnVolumeChange: "volumechange",
87
+ OnSelect: "select"
88
+ };
89
+ const eventOfTag = new Map(Object.entries(EVENT_OF_TAG));
90
+ const NOT_ONE_EVENT = /* @__PURE__ */ new Set([
91
+ "OnMount",
92
+ "OnUnmount",
93
+ "OnCustomEvent"
94
+ ]);
95
+ /**
96
+ * The DOM event a contribution listens to, normalized like a protected event:
97
+ * `OnClick` and `OnCustomEvent('click')` both read `click`, and
98
+ * `OnKeyDownPreventDefault` reads `keydown`. `None` for an attribute that is
99
+ * no event, a custom event with no name, or a handler `isUnknownHandler` names.
100
+ */
101
+ const eventNameOf = (tag, value) => {
102
+ const known = eventOfTag.get(tag);
103
+ if (known !== void 0) return Option.some(known);
104
+ if (tag !== "OnCustomEvent") return Option.none();
105
+ const name = typeof value === "object" && value !== null ? value.name : void 0;
106
+ return typeof name === "string" ? Option.some(normalizeName(name)) : Option.none();
107
+ };
108
+ /**
109
+ * A tag shaped like a handler that Foldkit's table lacks: a child attribute's
110
+ * from another Foldkit, say. Its event cannot be read from its spelling (that
111
+ * guess once let every variant past protection), so the resolver refuses it.
112
+ */
113
+ const isUnknownHandler = (tag) => tag.startsWith("On") && !eventOfTag.has(tag) && !NOT_ONE_EVENT.has(tag);
114
+ /** Typed builders whose attribute is not their tag: `For` writes the `htmlFor` property, which is `for`. */
115
+ const ATTRIBUTE_OF_TAG = /* @__PURE__ */ new Map([
116
+ ["For", "for"],
117
+ ["CiteAttr", "cite"],
118
+ ["FormAttr", "form"],
119
+ ["LabelAttr", "label"],
120
+ ["ContentAttr", "content"]
121
+ ]);
122
+ /**
123
+ * DOM properties that write an attribute of another name; the rest normalize
124
+ * alike (`readOnly`, `tabIndex`). `classList` and `relList` forward an
125
+ * assignment to their attribute, and a `default…` property is the attribute
126
+ * its control starts from.
127
+ */
128
+ const ATTRIBUTE_OF_PROPERTY = /* @__PURE__ */ new Map([
129
+ ["className", "class"],
130
+ ["classList", "class"],
131
+ ["htmlFor", "for"],
132
+ ["relList", "rel"],
133
+ ["defaultValue", "value"],
134
+ ["defaultChecked", "checked"],
135
+ ["defaultSelected", "selected"]
136
+ ]);
137
+ /** `ariaControlsElements` and `ariaActiveDescendantElement` reflect `aria-controls` and `aria-activedescendant`. */
138
+ const ARIA_ELEMENTS = /^(aria[A-Z][A-Za-z]*?)Elements?$/;
139
+ const attributeOfProperty = (key) => ATTRIBUTE_OF_PROPERTY.get(key) ?? key.replace(ARIA_ELEMENTS, "$1");
140
+ /** The builders that name their attribute by argument, and the name each sets. */
141
+ const KEYED_BUILDERS = /* @__PURE__ */ new Map([
142
+ ["DataAttribute", (key) => `data-${key}`],
143
+ ["Attribute", (key) => key.replace(/^xlink:/i, "")],
144
+ ["Prop", attributeOfProperty]
145
+ ]);
146
+ /**
147
+ * An `Attribute` or `Prop` named like `onclick`: an inline handler, which
148
+ * listens to its event outside every owner and protection the resolver keeps.
149
+ */
150
+ const isInlineHandler = (tag, value) => {
151
+ if (tag !== "Attribute" && tag !== "Prop") return false;
152
+ const key = typeof value === "object" && value !== null ? value.key : void 0;
153
+ return typeof key === "string" && key.toLowerCase().startsWith("on");
154
+ };
155
+ /**
156
+ * The HTML attribute a contribution sets, normalized to compare with a protected one:
157
+ * `AriaLabel`, `Attribute('aria-label')` and `Prop({ key: 'ariaLabel' })` all read
158
+ * `arialabel`, `Prop({ key: 'className' })` reads `class`, and `DataAttribute('x')`
159
+ * reads as `data-x`.
160
+ */
161
+ const attributeNameOf = (tag, value) => {
162
+ const key = typeof value === "object" && value !== null ? value.key : void 0;
163
+ const keyed = KEYED_BUILDERS.get(tag);
164
+ if (keyed !== void 0 && typeof key === "string") return normalizeName(keyed(key));
165
+ return normalizeName(ATTRIBUTE_OF_TAG.get(tag) ?? tag);
166
+ };
167
+ export { EVENT_OF_TAG, attributeNameOf, eventNameOf, isInlineHandler, isUnknownHandler, normalizeName };
168
+
169
+ //# sourceMappingURL=foldkitNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foldkitNames.js","names":[],"sources":["../src/foldkitNames.ts"],"sourcesContent":["/**\n * What a Foldkit attribute really sets on its element: the DOM event it\n * listens to and the HTML attribute it writes, read from Foldkit's handler\n * table (`foldkit/dist/html/index.js`, `attributeHandlers`), not from its tag.\n * The resolver compares these, so every spelling of one event or attribute\n * meets one owner and one protection. Internal: not exported from the package.\n */\nimport { Option } from 'effect'\nimport type { Attribute } from 'foldkit/html'\n\n/** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */\nexport const normalizeName = (name: string): string => name.replace(/[^a-z0-9]/gi, '').toLowerCase()\n\ntype FoldkitTag = Attribute<unknown>['_tag']\n\n/** Handlers that are no one DOM event: a Mount is composed, an unmount is a hook, and a custom event names its own. */\ntype NotOneEvent = 'OnMount' | 'OnUnmount' | 'OnCustomEvent'\n\ntype EventTag = Exclude<Extract<FoldkitTag, `On${string}`>, NotOneEvent> | 'AllowDrop'\n\n/**\n * The DOM event each Foldkit handler builder registers. The variants own their\n * base event: `OnKeyDownPreventDefault` listens to `keydown`, and Foldkit\n * chains it onto any other `keydown` handler on the element. A Foldkit release\n * that adds a handler fails to compile here until it is listed.\n */\nexport const EVENT_OF_TAG: { readonly [Tag in EventTag]: string } = {\n OnClick: 'click',\n OnDoubleClick: 'dblclick',\n OnMouseDown: 'mousedown',\n OnMouseUp: 'mouseup',\n OnMouseEnter: 'mouseenter',\n OnMouseLeave: 'mouseleave',\n OnMouseOver: 'mouseover',\n OnMouseOut: 'mouseout',\n OnMouseMove: 'mousemove',\n OnPointerMove: 'pointermove',\n OnPointerLeave: 'pointerleave',\n OnPointerDown: 'pointerdown',\n OnPointerUp: 'pointerup',\n OnKeyDown: 'keydown',\n OnKeyDownPreventDefault: 'keydown',\n OnKeyDownSelf: 'keydown',\n OnKeyDownSelfPreventDefault: 'keydown',\n OnKeyDownFocus: 'keydown',\n OnKeyUp: 'keyup',\n OnKeyUpPreventDefault: 'keyup',\n OnKeyPress: 'keypress',\n OnFocus: 'focus',\n OnBlur: 'blur',\n OnFocusEnter: 'focusin',\n OnFocusLeave: 'focusout',\n OnInput: 'input',\n OnChange: 'change',\n OnBeforeInput: 'beforeinput',\n OnBeforeInputPreventDefault: 'beforeinput',\n OnFileChange: 'change',\n OnSubmit: 'submit',\n OnReset: 'reset',\n OnScroll: 'scroll',\n OnWheel: 'wheel',\n OnCopy: 'copy',\n OnCut: 'cut',\n OnPaste: 'paste',\n OnPastePreventDefault: 'paste',\n OnCopyText: 'copy',\n OnCutText: 'cut',\n OnCancel: 'cancel',\n OnCancelPreventDefault: 'cancel',\n OnToggle: 'toggle',\n OnContextMenu: 'contextmenu',\n OnDragStart: 'dragstart',\n OnDrag: 'drag',\n OnDragEnd: 'dragend',\n OnDragEnter: 'dragenter',\n OnDragLeave: 'dragleave',\n OnDragOver: 'dragover',\n AllowDrop: 'dragover',\n OnDrop: 'drop',\n OnDropFiles: 'drop',\n OnTouchStart: 'touchstart',\n OnTouchEnd: 'touchend',\n OnTouchMove: 'touchmove',\n OnTouchCancel: 'touchcancel',\n OnAnimationStart: 'animationstart',\n OnAnimationEnd: 'animationend',\n OnAnimationIteration: 'animationiteration',\n OnTransitionEnd: 'transitionend',\n OnLoad: 'load',\n OnError: 'error',\n OnPlay: 'play',\n OnPause: 'pause',\n OnEnded: 'ended',\n OnTimeUpdate: 'timeupdate',\n OnVolumeChange: 'volumechange',\n OnSelect: 'select',\n}\n\nconst eventOfTag: ReadonlyMap<string, string> = new Map(Object.entries(EVENT_OF_TAG))\n\nconst NOT_ONE_EVENT: ReadonlySet<string> = new Set<NotOneEvent>([\n 'OnMount',\n 'OnUnmount',\n 'OnCustomEvent',\n])\n\n/**\n * The DOM event a contribution listens to, normalized like a protected event:\n * `OnClick` and `OnCustomEvent('click')` both read `click`, and\n * `OnKeyDownPreventDefault` reads `keydown`. `None` for an attribute that is\n * no event, a custom event with no name, or a handler `isUnknownHandler` names.\n */\nexport const eventNameOf = (tag: string, value: unknown): Option.Option<string> => {\n const known = eventOfTag.get(tag)\n if (known !== undefined) return Option.some(known)\n // tag-check: open — the tag may be a child attribute's, from another package.\n if (tag !== 'OnCustomEvent') return Option.none()\n const name =\n typeof value === 'object' && value !== null\n ? (value as { readonly name?: unknown }).name\n : undefined\n return typeof name === 'string' ? Option.some(normalizeName(name)) : Option.none()\n}\n\n/**\n * A tag shaped like a handler that Foldkit's table lacks: a child attribute's\n * from another Foldkit, say. Its event cannot be read from its spelling (that\n * guess once let every variant past protection), so the resolver refuses it.\n */\n// tag-check: open — any `On…` tag is a handler by prefix, and a child attribute's tag is another package's.\nexport const isUnknownHandler = (tag: string): boolean =>\n tag.startsWith('On') && !eventOfTag.has(tag) && !NOT_ONE_EVENT.has(tag)\n\n/** Typed builders whose attribute is not their tag: `For` writes the `htmlFor` property, which is `for`. */\nconst ATTRIBUTE_OF_TAG: ReadonlyMap<string, string> = new Map<FoldkitTag, string>([\n ['For', 'for'],\n ['CiteAttr', 'cite'],\n ['FormAttr', 'form'],\n ['LabelAttr', 'label'],\n ['ContentAttr', 'content'],\n])\n\n/**\n * DOM properties that write an attribute of another name; the rest normalize\n * alike (`readOnly`, `tabIndex`). `classList` and `relList` forward an\n * assignment to their attribute, and a `default…` property is the attribute\n * its control starts from.\n */\nconst ATTRIBUTE_OF_PROPERTY: ReadonlyMap<string, string> = new Map([\n ['className', 'class'],\n ['classList', 'class'],\n ['htmlFor', 'for'],\n ['relList', 'rel'],\n ['defaultValue', 'value'],\n ['defaultChecked', 'checked'],\n ['defaultSelected', 'selected'],\n])\n\n/** `ariaControlsElements` and `ariaActiveDescendantElement` reflect `aria-controls` and `aria-activedescendant`. */\nconst ARIA_ELEMENTS = /^(aria[A-Z][A-Za-z]*?)Elements?$/\n\nconst attributeOfProperty = (key: string): string =>\n ATTRIBUTE_OF_PROPERTY.get(key) ?? key.replace(ARIA_ELEMENTS, '$1')\n\n/** The builders that name their attribute by argument, and the name each sets. */\nconst KEYED_BUILDERS: ReadonlyMap<string, (key: string) => string> = new Map([\n ['DataAttribute', (key: string) => `data-${key}`],\n // `xlink:href` is the `href` an SVG link reads where it has no plain one.\n ['Attribute', (key: string) => key.replace(/^xlink:/i, '')],\n ['Prop', attributeOfProperty],\n])\n\n/**\n * An `Attribute` or `Prop` named like `onclick`: an inline handler, which\n * listens to its event outside every owner and protection the resolver keeps.\n */\nexport const isInlineHandler = (tag: string, value: unknown): boolean => {\n // tag-check: open — the tag may be a child attribute's, from another package.\n if (tag !== 'Attribute' && tag !== 'Prop') return false\n const key =\n typeof value === 'object' && value !== null\n ? (value as { readonly key?: unknown }).key\n : undefined\n return typeof key === 'string' && key.toLowerCase().startsWith('on')\n}\n\n/**\n * The HTML attribute a contribution sets, normalized to compare with a protected one:\n * `AriaLabel`, `Attribute('aria-label')` and `Prop({ key: 'ariaLabel' })` all read\n * `arialabel`, `Prop({ key: 'className' })` reads `class`, and `DataAttribute('x')`\n * reads as `data-x`.\n */\nexport const attributeNameOf = (tag: string, value: unknown): string => {\n const key =\n typeof value === 'object' && value !== null\n ? (value as { readonly key?: unknown }).key\n : undefined\n const keyed = KEYED_BUILDERS.get(tag)\n if (keyed !== undefined && typeof key === 'string') return normalizeName(keyed(key))\n return normalizeName(ATTRIBUTE_OF_TAG.get(tag) ?? tag)\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAa,iBAAiB,SAAyB,KAAK,QAAQ,eAAe,EAAE,CAAC,CAAC,YAAY;;;;;;;AAenG,MAAa,eAAuD;CAClE,SAAS;CACT,eAAe;CACf,aAAa;CACb,WAAW;CACX,cAAc;CACd,cAAc;CACd,aAAa;CACb,YAAY;CACZ,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,e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.ts","names":[],"sources":["../src/resolver.ts"],"mappings":";;;YAyBY,eAAe,WAAW,cAAc,UAAU,WAAW;;;;;YAM7D,qBAAqB,WAC7B,QAAQ,UAAU;WAAqB;KACvC;iBAEa;WACN;WACA,YAAY;;qBA8FV,UAAW,SAAO,MACvB,eAAe,sBAAoB,eAC1B,cAAc,mBAAmB,WAAS,UAChD,mBACR,eAAe"}
1
+ {"version":3,"file":"resolver.d.ts","names":[],"sources":["../src/resolver.ts"],"mappings":";;;YAiCY,eAAe,WAAW,cAAc,UAAU,WAAW;;;;;YAM7D,qBAAqB,WAC7B,QAAQ,UAAU;WAAqB;KACvC;iBAEa;WACN;WACA,YAAY;;qBAmCV,UAAW,SAAO,MACvB,eAAe,sBAAoB,eAC1B,cAAc,mBAAmB,WAAS,UAChD,mBACR,eAAe"}
package/dist/resolver.js CHANGED
@@ -3,8 +3,10 @@ import { classAttribute, isChildAttribute, isTagged, mountAttribute, styleAttrib
3
3
  import { DiagnosticError } from "./diagnostics.js";
4
4
  import { Cause, Match, Option, Stream } from "effect";
5
5
  import { Diagnostics } from "foldkit-surface";
6
+ import { attributeNameOf, eventNameOf, isInlineHandler, isUnknownHandler, normalizeName } from "./foldkitNames.js";
6
7
  import { DRAWN_CLASSES } from "./inject.js";
7
8
  import { mountFailed } from "./mountFailed.js";
9
+ import { declarationName, overlaps } from "./styleNames.js";
8
10
  // src/resolver.ts
9
11
  /**
10
12
  * The deterministic resolver. `resolve` is pure: it decomposes the base
@@ -13,53 +15,18 @@ import { mountFailed } from "./mountFailed.js";
13
15
  * one `OnMount`. Conflicts throw a `DiagnosticError` before Foldkit could
14
16
  * silently chain or replace.
15
17
  */
16
- /** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */
17
- const normalizeName = (name) => name.replace(/[^a-z0-9]/gi, "").toLowerCase();
18
- /** Attribute tags are PascalCase (`OnKeyDown`); event tokens are lowercase. */
19
- const eventNameOfTag = (tag) => normalizeName(tag.startsWith("On") ? tag.slice(2) : tag);
20
18
  /** A Foldkit `Class` attribute, read inside a child attribute another package built. */
21
19
  const isClass = (value) => isTagged(value) && value._tag === "Class" && typeof value.value === "string";
22
20
  const splitClasses = (value) => value.split(/\s+/).filter((token) => token.length > 0);
23
- /** The field that keys an attribute that is owned individually, not by its tag. */
24
- const OWNERSHIP_FIELD = /* @__PURE__ */ new Map([
25
- ["Prop", "key"],
26
- ["Attribute", "key"],
27
- ["DataAttribute", "key"]
28
- ]);
29
- const ownershipKey = (tag, value) => {
30
- if (!OWNERSHIP_FIELD.has(tag) || typeof value !== "object" || value === null) return tag;
31
- return `${tag}:${String(value.key)}`;
32
- };
33
- /**
34
- * The HTML attribute a contribution sets, normalized to compare with a protected one:
35
- * `AriaLabel`, `Attribute('aria-label')` and `Prop({ key: 'ariaLabel' })` all read
36
- * `arialabel`, and `DataAttribute('x')` reads as `data-x`.
37
- */
38
- const attributeNameOf = (tag, value) => {
39
- const key = typeof value === "object" && value !== null ? value.key : void 0;
40
- if (typeof key !== "string") return normalizeName(tag);
41
- return normalizeName(Option.getOrElse(namedByKey(tag, key), () => tag));
42
- };
43
- /** The builders that name their attribute by argument, and the name each sets. */
44
- const KEYED_BUILDERS = /* @__PURE__ */ new Map([
45
- ["DataAttribute", (key) => `data-${key}`],
46
- ["Attribute", (key) => key],
47
- ["Prop", (key) => key]
48
- ]);
49
- const namedByKey = (tag, key) => Option.map(Option.fromNullishOr(KEYED_BUILDERS.get(tag)), (name) => name(key));
50
- /** `OnCustomEvent` names its event by argument and `OnMount` is composed, not one native event. */
51
- const NOT_NATIVE_EVENT = /* @__PURE__ */ new Set(["OnMount", "OnCustomEvent"]);
52
- const isNativeEvent = (tag) => tag.startsWith("On") && !NOT_NATIVE_EVENT.has(tag);
53
- /**
54
- * The DOM event a contribution listens to, normalized like a protected event:
55
- * `OnClick` and `OnCustomEvent('click')` both read `click`. Undefined for a non-event.
56
- */
57
- const eventNameOf = (tag, value) => {
58
- if (isNativeEvent(tag)) return eventNameOfTag(tag);
59
- if (tag !== "OnCustomEvent") return void 0;
60
- const name = typeof value === "object" && value !== null ? value.name : void 0;
61
- return typeof name === "string" ? normalizeName(name) : void 0;
62
- };
21
+ /** The resolver emits the slot's one `class` and `style`; a raw write of either would replace it. */
22
+ const RESOLVER_OWNED = /* @__PURE__ */ new Set(["class", "style"]);
23
+ /** Properties that replace the element's children, as `InnerHTML` does. */
24
+ const REPLACES_CHILDREN = new Set([
25
+ "innerHTML",
26
+ "outerHTML",
27
+ "textContent",
28
+ "innerText"
29
+ ].map(normalizeName));
63
30
  const toDiagnostic = (code, message, slot, details) => ({
64
31
  source: "mixins",
65
32
  code,
@@ -73,7 +40,7 @@ const resolve = (base, contributions, options = {}) => {
73
40
  const protection = options.protected;
74
41
  const protectedEvents = new Set((protection?.events ?? []).map((event) => normalizeName(MetadataToken.nameOf(event))));
75
42
  const protectedAttributes = new Set((protection?.attributes ?? []).map((attr) => normalizeName(MetadataToken.nameOf(attr))));
76
- const protectedStyle = new Set(protection?.style ?? []);
43
+ const protectedStyle = protection?.style ?? [];
77
44
  const classes = [];
78
45
  const classSeen = /* @__PURE__ */ new Set();
79
46
  const style = /* @__PURE__ */ new Map();
@@ -95,15 +62,22 @@ const resolve = (base, contributions, options = {}) => {
95
62
  if (drawn instanceof Set && token.startsWith("style-")) drawn.add(token);
96
63
  };
97
64
  const writeStyle = (property, value, writer) => {
98
- if (writer !== "base" && protectedStyle.has(property)) fail("mixins:protected-style-property", `slot "${slot ?? "?"}" protects style property "${property}"`, { property });
99
- const owner = styleOwners.get(property);
100
- if (writer === "behavior" && owner !== void 0 || writer === "style" && owner === "behavior") fail("mixins:style-property-conflict", `two owners for style property "${property}": ${owner === "base" ? "the view" : owner === "style" ? "a Style" : "a Behavior"} already sets it`, {
65
+ const shielded = protectedStyle.find((name) => overlaps(property, name));
66
+ if (writer !== "base" && shielded !== void 0) fail("mixins:protected-style-property", `slot "${slot ?? "?"}" protects style property "${shielded}", which "${property}" writes`, {
67
+ property,
68
+ protected: shielded
69
+ });
70
+ const declaration = declarationName(property);
71
+ for (const [written, owner] of styleOwners) if ((writer === "behavior" || writer === "style" && owner === "behavior") && overlaps(declaration, written)) fail("mixins:style-property-conflict", `two owners for style property "${property}": ${owner === "base" ? "the view" : owner === "style" ? "a Style" : "a Behavior"} already sets "${written}"`, {
101
72
  property,
102
73
  owner,
103
74
  writer
104
75
  });
105
- if (owner === void 0 || writer === "behavior") styleOwners.set(property, writer);
106
- style.set(property, value);
76
+ if (!styleOwners.has(declaration) || writer === "behavior") styleOwners.set(declaration, writer);
77
+ style.set(declaration, {
78
+ property,
79
+ value
80
+ });
107
81
  };
108
82
  const addMount = (action) => {
109
83
  const count = (mountNames.get(action.name) ?? 0) + 1;
@@ -111,14 +85,14 @@ const resolve = (base, contributions, options = {}) => {
111
85
  if (count > 1) fail("mixins:duplicate-mount-name", `two Mounts are both named "${action.name}"`, { name: action.name });
112
86
  mounts.push(action);
113
87
  };
88
+ const failUnknownHandler = (tag) => fail("mixins:unsupported-event", `"${tag}" is no Foldkit handler the resolver knows, so it cannot tell which event it owns`, { tag });
114
89
  const reserve = (tag, value) => {
115
90
  if (tag === "OnMount") return;
116
- const eventName = eventNameOf(tag, value);
117
- if (eventName !== void 0) {
118
- ownedEvents.set(eventName, tag);
119
- return;
120
- }
121
- ownedAttributes.set(ownershipKey(tag, value), tag);
91
+ if (isUnknownHandler(tag)) failUnknownHandler(tag);
92
+ Option.match(eventNameOf(tag, value), {
93
+ onSome: (eventName) => ownedEvents.set(eventName, tag),
94
+ onNone: () => ownedAttributes.set(attributeNameOf(tag, value), tag)
95
+ });
122
96
  };
123
97
  const addBase = (attribute) => {
124
98
  if (isChildAttribute(attribute)) {
@@ -146,39 +120,51 @@ const resolve = (base, contributions, options = {}) => {
146
120
  };
147
121
  const failStructural = (tag) => fail("mixins:structural-override", `a Mixin may not contribute "${tag}"; it is structural ownership`, { tag });
148
122
  const claim = (tag, attribute) => {
123
+ if (tag === "Key" || tag === "InnerHTML") failStructural(tag);
124
+ if (isUnknownHandler(tag)) failUnknownHandler(tag);
125
+ if (isInlineHandler(tag, attribute)) fail("mixins:unsupported-event", `a Mixin may not set an inline handler through ${tag}; contribute a Foldkit handler (h.On…) instead`, { tag });
149
126
  const eventName = eventNameOf(tag, attribute);
150
- if (eventName !== void 0) {
151
- if (protectedEvents.has(eventName)) fail("mixins:protected-event", `slot "${slot ?? "?"}" protects event "${eventName}"`, {
152
- tag,
153
- event: eventName
154
- });
155
- const owner = ownedEvents.get(eventName);
156
- if (owner !== void 0) fail("mixins:event-conflict", `two owners for event "${eventName}": "${owner}" already owns it`, {
157
- tag,
158
- event: eventName,
159
- owner
160
- });
161
- ownedEvents.set(eventName, tag);
162
- return;
163
- }
164
- const key = ownershipKey(tag, attribute);
127
+ if (Option.isSome(eventName)) return claimEvent(tag, eventName.value);
165
128
  const attributeName = attributeNameOf(tag, attribute);
129
+ if (REPLACES_CHILDREN.has(attributeName)) failStructural(tag);
130
+ if (RESOLVER_OWNED.has(attributeName)) fail("mixins:attribute-conflict", `a Mixin may not set "${attributeName}" through ${tag}: the resolver writes the slot's one ${attributeName}; contribute classes or style instead`, {
131
+ tag,
132
+ attribute: attributeName,
133
+ owner: "resolver"
134
+ });
166
135
  if (protectedAttributes.has(attributeName)) fail("mixins:protected-attribute", `slot "${slot ?? "?"}" protects attribute "${tag}"`, {
167
136
  tag,
168
137
  attribute: attributeName
169
138
  });
170
- const owner = ownedAttributes.get(key);
171
- if (owner !== void 0) fail("mixins:attribute-conflict", `two owners for "${key}": a ${owner} attribute already occupies it`, {
139
+ const owner = ownedAttributes.get(attributeName);
140
+ if (owner !== void 0) fail("mixins:attribute-conflict", `two owners for "${owner}": ${tag} sets the same attribute (${attributeName})`, {
172
141
  tag,
173
- key,
142
+ attribute: attributeName,
174
143
  owner
175
144
  });
176
- ownedAttributes.set(key, tag);
145
+ ownedAttributes.set(attributeName, tag);
146
+ };
147
+ const claimEvent = (tag, eventName) => {
148
+ if (protectedEvents.has(eventName)) fail("mixins:protected-event", `slot "${slot ?? "?"}" protects event "${eventName}"`, {
149
+ tag,
150
+ event: eventName
151
+ });
152
+ const owner = ownedEvents.get(eventName);
153
+ if (owner !== void 0) fail("mixins:event-conflict", `two owners for event "${eventName}": "${owner}" already owns it`, {
154
+ tag,
155
+ event: eventName,
156
+ owner
157
+ });
158
+ ownedEvents.set(eventName, tag);
177
159
  };
178
160
  const applyMixinAttribute = (attribute) => {
179
161
  if (isChildAttribute(attribute)) {
180
162
  const inner = attribute.attribute;
181
- if (isTagged(inner)) reserve(inner._tag, inner);
163
+ if (isClass(inner)) {
164
+ for (const token of splitClasses(inner.value)) addClass(token);
165
+ return;
166
+ }
167
+ if (isTagged(inner)) claim(inner._tag, inner);
182
168
  added.push(attribute);
183
169
  return;
184
170
  }
@@ -189,9 +175,7 @@ const resolve = (base, contributions, options = {}) => {
189
175
  Style: ({ value }) => {
190
176
  for (const [property, entry] of Object.entries(value)) writeStyle(property, entry, "behavior");
191
177
  },
192
- OnMount: ({ action }) => addMount(action),
193
- Key: ({ _tag: tag }) => failStructural(tag),
194
- InnerHTML: ({ _tag: tag }) => failStructural(tag)
178
+ OnMount: ({ action }) => addMount(action)
195
179
  }), Match.orElse((other) => {
196
180
  claim(other._tag, other);
197
181
  added.push(other);
@@ -206,7 +190,7 @@ const resolve = (base, contributions, options = {}) => {
206
190
  }
207
191
  const emitted = [];
208
192
  if (classes.length > 0) emitted.push(classAttribute(classes.join(" ")));
209
- if (style.size > 0) emitted.push(styleAttribute(Object.fromEntries(style)));
193
+ if (style.size > 0) emitted.push(styleAttribute(Object.fromEntries(Array.from(style.values(), (e) => [e.property, e.value]))));
210
194
  emitted.push(...preserved, ...added);
211
195
  const composed = composeMounts(mounts, slot);
212
196
  if (composed !== void 0) emitted.push(composed);
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.js","names":["Reported"],"sources":["../src/resolver.ts"],"sourcesContent":["/**\n * The deterministic resolver. `resolve` is pure: it decomposes the base\n * attributes, applies contributions in attachment order, enforces ownership\n * and protection, then emits one canonical `Class`, one `Style`, and at most\n * one `OnMount`. Conflicts throw a `DiagnosticError` before Foldkit could\n * silently chain or replace.\n */\nimport { Cause, Match, Option, Stream } from 'effect'\nimport type { Attribute, ChildAttribute } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\nimport { Diagnostics as Reported } from 'foldkit-surface'\nimport {\n classAttribute,\n isChildAttribute,\n isTagged,\n mountAttribute,\n styleAttribute,\n} from './attribute.js'\nimport type { StaticContribution } from './contribution.js'\nimport { DiagnosticError, type Diagnostic, type DiagnosticCode } from './diagnostics.js'\nimport { DRAWN_CLASSES } from './inject.js'\nimport * as MetadataToken from './metadataToken.js'\nimport { mountFailed } from './mountFailed.js'\nimport type { SlotProtection } from './slot.js'\n\nexport type SlotAttributes<Message> = ReadonlyArray<Attribute<Message> | ChildAttribute>\n\n/**\n * What a Mixin can add to a slot's attributes: every attribute but\n * `InnerHTML`, which the resolver refuses from one as structural ownership.\n */\nexport type ContributedAttribute<Message> =\n | Exclude<Attribute<Message>, { readonly _tag: 'InnerHTML' }>\n | ChildAttribute\n\nexport interface ResolveOptions {\n readonly slot?: string\n readonly protected?: SlotProtection\n}\n\n/** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */\nconst normalizeName = (name: string): string => name.replace(/[^a-z0-9]/gi, '').toLowerCase()\n\n/** Attribute tags are PascalCase (`OnKeyDown`); event tokens are lowercase. */\nconst eventNameOfTag = (tag: string): string =>\n normalizeName(tag.startsWith('On') ? tag.slice(2) : tag)\n\n/** A Foldkit `Class` attribute, read inside a child attribute another package built. */\nconst isClass = (value: unknown): value is { readonly _tag: 'Class'; readonly value: string } =>\n isTagged(value) &&\n // tag-check: open — a Foldkit attribute's tag, from a package whose union we do not have.\n value._tag === 'Class' &&\n typeof (value as { value?: unknown }).value === 'string'\n\nconst splitClasses = (value: string): ReadonlyArray<string> =>\n value.split(/\\s+/).filter(token => token.length > 0)\n\n/** The field that keys an attribute that is owned individually, not by its tag. */\nconst OWNERSHIP_FIELD: ReadonlyMap<string, 'key'> = new Map([\n ['Prop', 'key'],\n ['Attribute', 'key'],\n ['DataAttribute', 'key'],\n])\n\n// The tag may come from a child attribute another package built, so it is\n// text, not a union we hold.\nconst ownershipKey = (tag: string, value: unknown): string => {\n if (!OWNERSHIP_FIELD.has(tag) || typeof value !== 'object' || value === null) return tag\n return `${tag}:${String((value as { readonly key?: unknown }).key)}`\n}\n\n/**\n * The HTML attribute a contribution sets, normalized to compare with a protected one:\n * `AriaLabel`, `Attribute('aria-label')` and `Prop({ key: 'ariaLabel' })` all read\n * `arialabel`, and `DataAttribute('x')` reads as `data-x`.\n */\nconst attributeNameOf = (tag: string, value: unknown): string => {\n const key =\n typeof value === 'object' && value !== null\n ? (value as { readonly key?: unknown }).key\n : undefined\n if (typeof key !== 'string') return normalizeName(tag)\n return normalizeName(Option.getOrElse(namedByKey(tag, key), () => tag))\n}\n\n/** The builders that name their attribute by argument, and the name each sets. */\nconst KEYED_BUILDERS: ReadonlyMap<string, (key: string) => string> = new Map([\n ['DataAttribute', (key: string) => `data-${key}`],\n ['Attribute', (key: string) => key],\n ['Prop', (key: string) => key],\n])\n\n// The tag is open: it may be a child attribute's, from another package.\nconst namedByKey = (tag: string, key: string): Option.Option<string> =>\n Option.map(Option.fromNullishOr(KEYED_BUILDERS.get(tag)), name => name(key))\n\n/** `OnCustomEvent` names its event by argument and `OnMount` is composed, not one native event. */\nconst NOT_NATIVE_EVENT: ReadonlySet<string> = new Set(['OnMount', 'OnCustomEvent'])\n\n// tag-check: open — any `On…` tag is a native handler by prefix, and a child attribute's tag is another package's.\nconst isNativeEvent = (tag: string): boolean => tag.startsWith('On') && !NOT_NATIVE_EVENT.has(tag)\n\n/**\n * The DOM event a contribution listens to, normalized like a protected event:\n * `OnClick` and `OnCustomEvent('click')` both read `click`. Undefined for a non-event.\n */\nconst eventNameOf = (tag: string, value: unknown): string | undefined => {\n if (isNativeEvent(tag)) return eventNameOfTag(tag)\n // tag-check: open — the tag may be a child attribute's, from another package.\n if (tag !== 'OnCustomEvent') return undefined\n const name =\n typeof value === 'object' && value !== null\n ? (value as { readonly name?: unknown }).name\n : undefined\n return typeof name === 'string' ? normalizeName(name) : undefined\n}\n\nconst toDiagnostic = (\n code: DiagnosticCode,\n message: string,\n slot: string | undefined,\n details: Readonly<Record<string, unknown>>,\n): Diagnostic => ({\n source: 'mixins',\n code,\n severity: 'error',\n message,\n ...(slot === undefined ? {} : { slot }),\n details,\n})\n\nexport const resolve = <Message>(\n base: SlotAttributes<Message> | undefined,\n contributions: ReadonlyArray<StaticContribution<Message>>,\n options: ResolveOptions = {},\n): SlotAttributes<Message> => {\n const slot = options.slot\n const protection = options.protected\n const protectedEvents = new Set(\n (protection?.events ?? []).map(event => normalizeName(MetadataToken.nameOf(event))),\n )\n const protectedAttributes = new Set(\n (protection?.attributes ?? []).map(attr => normalizeName(MetadataToken.nameOf(attr))),\n )\n const protectedStyle = new Set(protection?.style ?? [])\n\n const classes: Array<string> = []\n const classSeen = new Set<string>()\n const style = new Map<string, string>()\n // Who wrote each inline style property. Style pieces layer over the base and\n // over each other (that is restyling); a Behavior's property has one owner,\n // and a Style piece may not overwrite what a Behavior set.\n const styleOwners = new Map<string, 'base' | 'style' | 'behavior'>()\n const mounts: Array<MountAction<Message, any>> = []\n const mountNames = new Map<string, number>()\n const preserved: Array<Attribute<Message> | ChildAttribute> = []\n const added: Array<Attribute<Message> | ChildAttribute> = []\n const ownedEvents = new Map<string, string>()\n const ownedAttributes = new Map<string, string>()\n\n function fail(\n code: DiagnosticCode,\n message: string,\n details: Readonly<Record<string, unknown>>,\n ): never {\n throw new DiagnosticError(toDiagnostic(code, message, slot, details))\n }\n\n const addClass = (token: string): void => {\n if (classSeen.has(token)) return\n classSeen.add(token)\n classes.push(token)\n // A server render collects the classes it drew, so it need not scan its HTML.\n const drawn = (globalThis as Record<symbol, unknown>)[DRAWN_CLASSES]\n if (drawn instanceof Set && token.startsWith('style-')) drawn.add(token)\n }\n\n const writeStyle = (\n property: string,\n value: string,\n writer: 'base' | 'style' | 'behavior',\n ): void => {\n if (writer !== 'base' && protectedStyle.has(property)) {\n fail(\n 'mixins:protected-style-property',\n `slot \"${slot ?? '?'}\" protects style property \"${property}\"`,\n { property },\n )\n }\n const owner = styleOwners.get(property)\n if (\n (writer === 'behavior' && owner !== undefined) ||\n (writer === 'style' && owner === 'behavior')\n ) {\n fail(\n 'mixins:style-property-conflict',\n `two owners for style property \"${property}\": ${owner === 'base' ? 'the view' : owner === 'style' ? 'a Style' : 'a Behavior'} already sets it`,\n { property, owner, writer },\n )\n }\n if (owner === undefined || writer === 'behavior') styleOwners.set(property, writer)\n style.set(property, value)\n }\n\n const addMount = (action: MountAction<Message, any>): void => {\n const count = (mountNames.get(action.name) ?? 0) + 1\n mountNames.set(action.name, count)\n if (count > 1) {\n fail('mixins:duplicate-mount-name', `two Mounts are both named \"${action.name}\"`, {\n name: action.name,\n })\n }\n mounts.push(action)\n }\n\n const reserve = (tag: string, value: unknown): void => {\n // tag-check: open — the tag may be a child attribute's, from another package.\n if (tag === 'OnMount') return\n const eventName = eventNameOf(tag, value)\n if (eventName !== undefined) {\n ownedEvents.set(eventName, tag)\n return\n }\n ownedAttributes.set(ownershipKey(tag, value), tag)\n }\n\n const addBase = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n // A class sends no Message, so a child's joins the slot's own: kept\n // apart, Foldkit would draw one of the two `Class` lists and drop the other.\n if (isClass(inner)) {\n for (const token of splitClasses(inner.value)) addClass(token)\n return\n }\n if (isTagged(inner)) reserve(inner._tag, inner)\n preserved.push(attribute)\n return\n }\n Match.value(attribute).pipe(\n Match.tags({\n Class: ({ value }) => {\n for (const token of splitClasses(value)) addClass(token)\n },\n Style: ({ value }) => {\n for (const [property, entry] of Object.entries(value)) {\n writeStyle(property, entry, 'base')\n }\n },\n OnMount: ({ action }) => addMount(action),\n }),\n Match.orElse(other => {\n reserve(other._tag, other)\n preserved.push(other)\n }),\n )\n }\n\n const failStructural = (tag: string): never =>\n fail(\n 'mixins:structural-override',\n `a Mixin may not contribute \"${tag}\"; it is structural ownership`,\n { tag },\n )\n\n // A contribution's tag that is not one of the above: a native handler or an attribute.\n const claim = (tag: string, attribute: unknown): void => {\n const eventName = eventNameOf(tag, attribute)\n if (eventName !== undefined) {\n if (protectedEvents.has(eventName)) {\n fail('mixins:protected-event', `slot \"${slot ?? '?'}\" protects event \"${eventName}\"`, {\n tag,\n event: eventName,\n })\n }\n const owner = ownedEvents.get(eventName)\n if (owner !== undefined) {\n fail(\n 'mixins:event-conflict',\n `two owners for event \"${eventName}\": \"${owner}\" already owns it`,\n { tag, event: eventName, owner },\n )\n }\n ownedEvents.set(eventName, tag)\n return\n }\n const key = ownershipKey(tag, attribute)\n const attributeName = attributeNameOf(tag, attribute)\n if (protectedAttributes.has(attributeName)) {\n fail('mixins:protected-attribute', `slot \"${slot ?? '?'}\" protects attribute \"${tag}\"`, {\n tag,\n attribute: attributeName,\n })\n }\n const owner = ownedAttributes.get(key)\n if (owner !== undefined) {\n fail(\n 'mixins:attribute-conflict',\n `two owners for \"${key}\": a ${owner} attribute already occupies it`,\n { tag, key, owner },\n )\n }\n ownedAttributes.set(key, tag)\n }\n\n const applyMixinAttribute = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n if (isTagged(inner)) reserve(inner._tag, inner)\n added.push(attribute)\n return\n }\n Match.value(attribute).pipe(\n Match.tags({\n Class: ({ value }) => {\n for (const token of splitClasses(value)) addClass(token)\n },\n // A `Style` attribute inside a contribution's attributes is a Behavior's.\n Style: ({ value }) => {\n for (const [property, entry] of Object.entries(value)) {\n writeStyle(property, entry, 'behavior')\n }\n },\n OnMount: ({ action }) => addMount(action),\n Key: ({ _tag: tag }) => failStructural(tag),\n InnerHTML: ({ _tag: tag }) => failStructural(tag),\n }),\n Match.orElse(other => {\n claim(other._tag, other)\n added.push(other)\n }),\n )\n }\n\n for (const attribute of base ?? []) addBase(attribute)\n\n for (const contribution of contributions) {\n for (const token of contribution.classes ?? []) addClass(token)\n for (const [property, value] of Object.entries(contribution.style ?? {})) {\n writeStyle(property, value, 'style')\n }\n for (const attribute of contribution.attributes ?? []) applyMixinAttribute(attribute)\n for (const mount of contribution.mounts ?? []) addMount(mount)\n }\n\n const emitted: Array<Attribute<Message> | ChildAttribute> = []\n if (classes.length > 0) emitted.push(classAttribute(classes.join(' ')))\n if (style.size > 0) emitted.push(styleAttribute(Object.fromEntries(style)))\n emitted.push(...preserved, ...added)\n const composed = composeMounts(mounts, slot)\n if (composed !== undefined) emitted.push(composed)\n return emitted\n}\n\nconst composeMounts = <Message>(\n mounts: ReadonlyArray<MountAction<Message, any>>,\n slot: string | undefined,\n): Attribute<Message> | undefined => {\n const first = mounts[0]\n if (first === undefined) return undefined\n if (mounts.length === 1) return mountAttribute(first)\n const slotOf = Option.fromUndefinedOr(slot)\n const name = `Mixins[${slot ?? 'slot'}](${mounts.map(mount => mount.name).join(',')})`\n return mountAttribute({\n name,\n args: {\n slot: slot ?? null,\n actions: mounts.map(mount => ({ name: mount.name, args: mount.args })),\n },\n f: (element, viewStateChanges) =>\n Stream.mergeAll(\n mounts.map(mount =>\n // A merge ends every stream in it when one fails, so each fails alone,\n // reported as `MountFailed`, and the rest go on: dispatched at the\n // element, since a Mount runs outside the application's resources.\n // One that ends interrupted is being torn down with its element.\n mount\n .f(element, viewStateChanges)\n .pipe(\n Stream.catchCause(cause =>\n Cause.hasInterruptsOnly(cause)\n ? Stream.empty\n : Stream.fromEffectDrain(\n Reported.dispatch(element, mountFailed(mount.name, slotOf, cause)),\n ),\n ),\n ),\n ),\n { concurrency: 'unbounded' },\n ),\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,MAAM,iBAAiB,SAAyB,KAAK,Q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CAAC;CAC7D,IAAI,QAAQ,SAAS,GAAG,QAAQ,KAAK,eAAe,QAAQ,KAAK,GAAG,CAAC,CAAC;CACtE,IAAI,MAAM,OAAO,GAAG,QAAQ,KAAK,eAAe,OAAO,YAAY,KAAK,CAAC,CAAC;CAC1E,QAAQ,KAAK,GAAG,WAAW,GAAG,KAAK;CACnC,MAAM,WAAW,cAAc,QAAQ,IAAI;CAC3C,IAAI,aAAa,KAAA,GAAW,QAAQ,KAAK,QAAQ;CACjD,OAAO;AACT;AAEA,MAAM,iBACJ,QACA,SACmC;CACnC,MAAM,QAAQ,OAAO;CACrB,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,IAAI,OAAO,WAAW,GAAG,OAAO,eAAe,KAAK;CACpD,MAAM,SAAS,OAAO,gBAAgB,IAAI;CAC1C,MAAM,OAAO,UAAU,QAAQ,OAAO,IAAI,OAAO,KAAI,UAAS,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG,EAAE;CACpF,OAAO,eAAe;EACpB;EACA,MAAM;GACJ,MAAM,QAAQ;GACd,SAAS,OAAO,KAAI,WAAU;IAAE,MAAM,MAAM;IAAM,MAAM,MAAM;GAAK,EAAE;EACvE;EACA,IAAI,SAAS,qBACX,OAAO,SACL,OAAO,KAAI,UAKT,MACG,EAAE,SAAS,gBAAgB,CAAC,CAC5B,KACC,OAAO,YAAW,UAChB,MAAM,kBAAkB,KAAK,IACzB,OAAO,QACP,OAAO,gBACLA,YAAS,SAAS,SAAS,YAAY,MAAM,MAAM,QAAQ,KAAK,CAAC,CACnE,CACN,CACF,CACJ,GACA,EAAE,aAAa,YAAY,CAC7B;CACJ,CAAC;AACH"}
1
+ {"version":3,"file":"resolver.js","names":["Reported"],"sources":["../src/resolver.ts"],"sourcesContent":["/**\n * The deterministic resolver. `resolve` is pure: it decomposes the base\n * attributes, applies contributions in attachment order, enforces ownership\n * and protection, then emits one canonical `Class`, one `Style`, and at most\n * one `OnMount`. Conflicts throw a `DiagnosticError` before Foldkit could\n * silently chain or replace.\n */\nimport { Cause, Match, Option, Stream } from 'effect'\nimport type { Attribute, ChildAttribute } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\nimport { Diagnostics as Reported } from 'foldkit-surface'\nimport {\n classAttribute,\n isChildAttribute,\n isTagged,\n mountAttribute,\n styleAttribute,\n} from './attribute.js'\nimport type { StaticContribution } from './contribution.js'\nimport { DiagnosticError, type Diagnostic, type DiagnosticCode } from './diagnostics.js'\nimport {\n attributeNameOf,\n eventNameOf,\n isInlineHandler,\n isUnknownHandler,\n normalizeName,\n} from './foldkitNames.js'\nimport { DRAWN_CLASSES } from './inject.js'\nimport * as MetadataToken from './metadataToken.js'\nimport { mountFailed } from './mountFailed.js'\nimport { declarationName, overlaps } from './styleNames.js'\nimport type { SlotProtection } from './slot.js'\n\nexport type SlotAttributes<Message> = ReadonlyArray<Attribute<Message> | ChildAttribute>\n\n/**\n * What a Mixin can add to a slot's attributes: every attribute but\n * `InnerHTML`, which the resolver refuses from one as structural ownership.\n */\nexport type ContributedAttribute<Message> =\n | Exclude<Attribute<Message>, { readonly _tag: 'InnerHTML' }>\n | ChildAttribute\n\nexport interface ResolveOptions {\n readonly slot?: string\n readonly protected?: SlotProtection\n}\n\n/** A Foldkit `Class` attribute, read inside a child attribute another package built. */\nconst isClass = (value: unknown): value is { readonly _tag: 'Class'; readonly value: string } =>\n isTagged(value) &&\n // tag-check: open — a Foldkit attribute's tag, from a package whose union we do not have.\n value._tag === 'Class' &&\n typeof (value as { value?: unknown }).value === 'string'\n\nconst splitClasses = (value: string): ReadonlyArray<string> =>\n value.split(/\\s+/).filter(token => token.length > 0)\n\n/** The resolver emits the slot's one `class` and `style`; a raw write of either would replace it. */\nconst RESOLVER_OWNED: ReadonlySet<string> = new Set(['class', 'style'])\n\n/** Properties that replace the element's children, as `InnerHTML` does. */\nconst REPLACES_CHILDREN: ReadonlySet<string> = new Set(\n ['innerHTML', 'outerHTML', 'textContent', 'innerText'].map(normalizeName),\n)\n\nconst toDiagnostic = (\n code: DiagnosticCode,\n message: string,\n slot: string | undefined,\n details: Readonly<Record<string, unknown>>,\n): Diagnostic => ({\n source: 'mixins',\n code,\n severity: 'error',\n message,\n ...(slot === undefined ? {} : { slot }),\n details,\n})\n\nexport const resolve = <Message>(\n base: SlotAttributes<Message> | undefined,\n contributions: ReadonlyArray<StaticContribution<Message>>,\n options: ResolveOptions = {},\n): SlotAttributes<Message> => {\n const slot = options.slot\n const protection = options.protected\n const protectedEvents = new Set(\n (protection?.events ?? []).map(event => normalizeName(MetadataToken.nameOf(event))),\n )\n const protectedAttributes = new Set(\n (protection?.attributes ?? []).map(attr => normalizeName(MetadataToken.nameOf(attr))),\n )\n const protectedStyle = protection?.style ?? []\n\n const classes: Array<string> = []\n const classSeen = new Set<string>()\n // By the declaration Foldkit writes, so two spellings of one are one entry;\n // drawn under the spelling written last.\n const style = new Map<string, { readonly property: string; readonly value: string }>()\n // Who wrote each inline style declaration. Style pieces layer over the base\n // and over each other (that is restyling); a Behavior's property has one\n // owner, shorthands and sides included, and a Style piece may not overwrite\n // what a Behavior set.\n const styleOwners = new Map<string, 'base' | 'style' | 'behavior'>()\n const mounts: Array<MountAction<Message, any>> = []\n const mountNames = new Map<string, number>()\n const preserved: Array<Attribute<Message> | ChildAttribute> = []\n const added: Array<Attribute<Message> | ChildAttribute> = []\n const ownedEvents = new Map<string, string>()\n const ownedAttributes = new Map<string, string>()\n\n function fail(\n code: DiagnosticCode,\n message: string,\n details: Readonly<Record<string, unknown>>,\n ): never {\n throw new DiagnosticError(toDiagnostic(code, message, slot, details))\n }\n\n const addClass = (token: string): void => {\n if (classSeen.has(token)) return\n classSeen.add(token)\n classes.push(token)\n // A server render collects the classes it drew, so it need not scan its HTML.\n const drawn = (globalThis as Record<symbol, unknown>)[DRAWN_CLASSES]\n if (drawn instanceof Set && token.startsWith('style-')) drawn.add(token)\n }\n\n const writeStyle = (\n property: string,\n value: string,\n writer: 'base' | 'style' | 'behavior',\n ): void => {\n const shielded = protectedStyle.find(name => overlaps(property, name))\n if (writer !== 'base' && shielded !== undefined) {\n fail(\n 'mixins:protected-style-property',\n `slot \"${slot ?? '?'}\" protects style property \"${shielded}\", which \"${property}\" writes`,\n { property, protected: shielded },\n )\n }\n const declaration = declarationName(property)\n for (const [written, owner] of styleOwners) {\n if (\n (writer === 'behavior' || (writer === 'style' && owner === 'behavior')) &&\n overlaps(declaration, written)\n ) {\n fail(\n 'mixins:style-property-conflict',\n `two owners for style property \"${property}\": ${owner === 'base' ? 'the view' : owner === 'style' ? 'a Style' : 'a Behavior'} already sets \"${written}\"`,\n { property, owner, writer },\n )\n }\n }\n if (!styleOwners.has(declaration) || writer === 'behavior') {\n styleOwners.set(declaration, writer)\n }\n style.set(declaration, { property, value })\n }\n\n const addMount = (action: MountAction<Message, any>): void => {\n const count = (mountNames.get(action.name) ?? 0) + 1\n mountNames.set(action.name, count)\n if (count > 1) {\n fail('mixins:duplicate-mount-name', `two Mounts are both named \"${action.name}\"`, {\n name: action.name,\n })\n }\n mounts.push(action)\n }\n\n const failUnknownHandler = (tag: string): never =>\n fail(\n 'mixins:unsupported-event',\n `\"${tag}\" is no Foldkit handler the resolver knows, so it cannot tell which event it owns`,\n { tag },\n )\n\n const reserve = (tag: string, value: unknown): void => {\n // tag-check: open — the tag may be a child attribute's, from another package.\n if (tag === 'OnMount') return\n if (isUnknownHandler(tag)) failUnknownHandler(tag)\n Option.match(eventNameOf(tag, value), {\n onSome: eventName => ownedEvents.set(eventName, tag),\n onNone: () => ownedAttributes.set(attributeNameOf(tag, value), tag),\n })\n }\n\n const addBase = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n // A class sends no Message, so a child's joins the slot's own: kept\n // apart, Foldkit would draw one of the two `Class` lists and drop the other.\n if (isClass(inner)) {\n for (const token of splitClasses(inner.value)) addClass(token)\n return\n }\n if (isTagged(inner)) reserve(inner._tag, inner)\n preserved.push(attribute)\n return\n }\n Match.value(attribute).pipe(\n Match.tags({\n Class: ({ value }) => {\n for (const token of splitClasses(value)) addClass(token)\n },\n Style: ({ value }) => {\n for (const [property, entry] of Object.entries(value)) {\n writeStyle(property, entry, 'base')\n }\n },\n OnMount: ({ action }) => addMount(action),\n }),\n Match.orElse(other => {\n reserve(other._tag, other)\n preserved.push(other)\n }),\n )\n }\n\n const failStructural = (tag: string): never =>\n fail(\n 'mixins:structural-override',\n `a Mixin may not contribute \"${tag}\"; it is structural ownership`,\n { tag },\n )\n\n // What a Mixin adds, by the event or attribute it really sets: its own\n // attributes, and the attribute inside each child attribute it adds.\n const claim = (tag: string, attribute: unknown): void => {\n // tag-check: open — the tag may be a child attribute's, from another package.\n if (tag === 'Key' || tag === 'InnerHTML') failStructural(tag)\n if (isUnknownHandler(tag)) failUnknownHandler(tag)\n if (isInlineHandler(tag, attribute)) {\n fail(\n 'mixins:unsupported-event',\n `a Mixin may not set an inline handler through ${tag}; contribute a Foldkit handler (h.On…) instead`,\n { tag },\n )\n }\n const eventName = eventNameOf(tag, attribute)\n if (Option.isSome(eventName)) return claimEvent(tag, eventName.value)\n const attributeName = attributeNameOf(tag, attribute)\n if (REPLACES_CHILDREN.has(attributeName)) failStructural(tag)\n if (RESOLVER_OWNED.has(attributeName)) {\n fail(\n 'mixins:attribute-conflict',\n `a Mixin may not set \"${attributeName}\" through ${tag}: the resolver writes the slot's one ${attributeName}; contribute classes or style instead`,\n { tag, attribute: attributeName, owner: 'resolver' },\n )\n }\n if (protectedAttributes.has(attributeName)) {\n fail('mixins:protected-attribute', `slot \"${slot ?? '?'}\" protects attribute \"${tag}\"`, {\n tag,\n attribute: attributeName,\n })\n }\n const owner = ownedAttributes.get(attributeName)\n if (owner !== undefined) {\n fail(\n 'mixins:attribute-conflict',\n `two owners for \"${owner}\": ${tag} sets the same attribute (${attributeName})`,\n { tag, attribute: attributeName, owner },\n )\n }\n ownedAttributes.set(attributeName, tag)\n }\n\n const claimEvent = (tag: string, eventName: string): void => {\n if (protectedEvents.has(eventName)) {\n fail('mixins:protected-event', `slot \"${slot ?? '?'}\" protects event \"${eventName}\"`, {\n tag,\n event: eventName,\n })\n }\n const owner = ownedEvents.get(eventName)\n if (owner !== undefined) {\n fail(\n 'mixins:event-conflict',\n `two owners for event \"${eventName}\": \"${owner}\" already owns it`,\n { tag, event: eventName, owner },\n )\n }\n ownedEvents.set(eventName, tag)\n }\n\n const applyMixinAttribute = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n // As in the view's own: kept apart, Foldkit would draw one of two `Class` lists.\n if (isClass(inner)) {\n for (const token of splitClasses(inner.value)) addClass(token)\n return\n }\n if (isTagged(inner)) claim(inner._tag, inner)\n added.push(attribute)\n return\n }\n Match.value(attribute).pipe(\n Match.tags({\n Class: ({ value }) => {\n for (const token of splitClasses(value)) addClass(token)\n },\n // A `Style` attribute inside a contribution's attributes is a Behavior's.\n Style: ({ value }) => {\n for (const [property, entry] of Object.entries(value)) {\n writeStyle(property, entry, 'behavior')\n }\n },\n OnMount: ({ action }) => addMount(action),\n }),\n Match.orElse(other => {\n claim(other._tag, other)\n added.push(other)\n }),\n )\n }\n\n for (const attribute of base ?? []) addBase(attribute)\n\n for (const contribution of contributions) {\n for (const token of contribution.classes ?? []) addClass(token)\n for (const [property, value] of Object.entries(contribution.style ?? {})) {\n writeStyle(property, value, 'style')\n }\n for (const attribute of contribution.attributes ?? []) applyMixinAttribute(attribute)\n for (const mount of contribution.mounts ?? []) addMount(mount)\n }\n\n const emitted: Array<Attribute<Message> | ChildAttribute> = []\n if (classes.length > 0) emitted.push(classAttribute(classes.join(' ')))\n if (style.size > 0) {\n emitted.push(\n styleAttribute(Object.fromEntries(Array.from(style.values(), e => [e.property, e.value]))),\n )\n }\n emitted.push(...preserved, ...added)\n const composed = composeMounts(mounts, slot)\n if (composed !== undefined) emitted.push(composed)\n return emitted\n}\n\nconst composeMounts = <Message>(\n mounts: ReadonlyArray<MountAction<Message, any>>,\n slot: string | undefined,\n): Attribute<Message> | undefined => {\n const first = mounts[0]\n if (first === undefined) return undefined\n if (mounts.length === 1) return mountAttribute(first)\n const slotOf = Option.fromUndefinedOr(slot)\n const name = `Mixins[${slot ?? 'slot'}](${mounts.map(mount => mount.name).join(',')})`\n return mountAttribute({\n name,\n args: {\n slot: slot ?? null,\n actions: mounts.map(mount => ({ name: mount.name, args: mount.args })),\n },\n f: (element, viewStateChanges) =>\n Stream.mergeAll(\n mounts.map(mount =>\n // A merge ends every stream in it when one fails, so each fails alone,\n // reported as `MountFailed`, and the rest go on: dispatched at the\n // element, since a Mount runs outside the application's resources.\n // One that ends interrupted is being torn down with its element.\n mount\n .f(element, viewStateChanges)\n .pipe(\n Stream.catchCause(cause =>\n Cause.hasInterruptsOnly(cause)\n ? Stream.empty\n : Stream.fromEffectDrain(\n Reported.dispatch(element, mountFailed(mount.name, slotOf, cause)),\n ),\n ),\n ),\n ),\n { concurrency: 'unbounded' },\n ),\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiDA,MAAM,WAAW,UACf,SAAS,KAAK,KAEd,MAAM,SAAS,WACf,OAAQ,MAA8B,UAAU;AAElD,MAAM,gBAAgB,UACpB,MAAM,MAAM,KAAK,CAAC,CAAC,QAAO,UAAS,MAAM,SAAS,CAAC;;AAGrD,MAAM,iCAAsC,IAAI,IAAI,CAAC,SAAS,OAAO,CAAC;;AAGtE,MAAM,oBAAyC,IAAI,IACjD;CAAC;CAAa;CAAa;CAAe;AAAW,CAAC,CAAC,IAAI,aAAa,CAC1E;AAEA,MAAM,gBACJ,MACA,SACA,MACA,aACgB;CAChB,QAAQ;CACR;CACA,UAAU;CACV;CACA,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;CACrC;AACF;AAEA,MAAa,WACX,MACA,eACA,UAA0B,CAAC,MACC;CAC5B,MAAM,OAAO,QAAQ;CACrB,MAAM,a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S,SAAS,SAAS,YAAY,MAAM,MAAM,QAAQ,KAAK,CAAC,CACnE,CACN,CACF,CACJ,GACA,EAAE,aAAa,YAAY,CAC7B;CACJ,CAAC;AACH"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What an inline style property really writes, so one owner and one
3
+ * protection hold however it is spelled. Internal: not exported from the
4
+ * package.
5
+ *
6
+ * Two names overlap when they write one declaration (`insetInlineEnd` and
7
+ * `inset-inline-end`), when one is a shorthand that sets the other (`inset`,
8
+ * `insetInline` and `margin` over their sides), when a physical side can be
9
+ * the logical one (`right` is `insetInlineEnd` in a left-to-right line, and
10
+ * `left` in a right-to-left one), or when one moves what the other does
11
+ * (`translate`, `rotate` and `scale` beside `transform`). Sides are read for
12
+ * a horizontal writing mode: `insetBlockStart` is `top`.
13
+ */
14
+ /**
15
+ * The CSS declaration Foldkit writes for a `Style` key: `cssDeclarationName`
16
+ * in `foldkit/dist/domReflection.js`, which is not exported.
17
+ */
18
+ export declare const declarationName: (name: string) => string;
19
+ /** Whether writing `a` changes what `b` sets: one declaration, a shorthand of it, or its side. */
20
+ export declare const overlaps: (a: string, b: string) => boolean;
21
+ //# sourceMappingURL=styleNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleNames.d.ts","names":[],"sources":["../src/styleNames.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAoBa,kBAAe;;qBA2Ff,WAAQ,WAAa"}
@@ -0,0 +1,116 @@
1
+ // src/styleNames.ts
2
+ /**
3
+ * What an inline style property really writes, so one owner and one
4
+ * protection hold however it is spelled. Internal: not exported from the
5
+ * package.
6
+ *
7
+ * Two names overlap when they write one declaration (`insetInlineEnd` and
8
+ * `inset-inline-end`), when one is a shorthand that sets the other (`inset`,
9
+ * `insetInline` and `margin` over their sides), when a physical side can be
10
+ * the logical one (`right` is `insetInlineEnd` in a left-to-right line, and
11
+ * `left` in a right-to-left one), or when one moves what the other does
12
+ * (`translate`, `rotate` and `scale` beside `transform`). Sides are read for
13
+ * a horizontal writing mode: `insetBlockStart` is `top`.
14
+ */
15
+ const ASCII_UPPER = /[A-Z]/g;
16
+ /**
17
+ * The CSS declaration Foldkit writes for a `Style` key: `cssDeclarationName`
18
+ * in `foldkit/dist/domReflection.js`, which is not exported.
19
+ */
20
+ const declarationName = (name) => {
21
+ if (name.startsWith("--")) return name;
22
+ if (name === "cssFloat") return "float";
23
+ const kebab = (name.startsWith("Webkit") ? `webkit${name.slice(6)}` : name).replace(ASCII_UPPER, (letter) => `-${letter}`).toLowerCase();
24
+ return kebab.startsWith("webkit-") || kebab.startsWith("ms-") ? `-${kebab}` : kebab;
25
+ };
26
+ /**
27
+ * Shorthands, and the names that extend them without being their longhands.
28
+ * A name not listed here (`position`, `color`, `transform`) sets only itself,
29
+ * so `positionAnchor` and `transformOrigin` stand apart from it.
30
+ */
31
+ const SHORTHANDS = new Map([
32
+ ["inset"],
33
+ ["margin"],
34
+ ["padding"],
35
+ ["scroll-margin"],
36
+ ["scroll-padding"],
37
+ [
38
+ "border",
39
+ "border-collapse",
40
+ "border-spacing"
41
+ ],
42
+ ["outline", "outline-offset"],
43
+ [
44
+ "overflow",
45
+ "overflow-wrap",
46
+ "overflow-anchor",
47
+ "overflow-clip-margin"
48
+ ],
49
+ ["background"],
50
+ ["font"],
51
+ ["grid"],
52
+ ["flex"],
53
+ ["transition"],
54
+ ["animation"],
55
+ ["list-style"],
56
+ ["columns"],
57
+ ["column-rule"],
58
+ ["text-decoration"],
59
+ ["mask"],
60
+ ["offset"],
61
+ ["container"]
62
+ ].map(([root, ...apart]) => [root, new Set(apart)]));
63
+ /** Shorthands whose longhands do not extend their name. */
64
+ const COVERS = /* @__PURE__ */ new Map([
65
+ ["gap", ["row-gap", "column-gap"]],
66
+ ["place-items", ["align-items", "justify-items"]],
67
+ ["place-content", ["align-content", "justify-content"]],
68
+ ["place-self", ["align-self", "justify-self"]],
69
+ ["flex-flow", ["flex-direction", "flex-wrap"]],
70
+ ["transform", [
71
+ "translate",
72
+ "rotate",
73
+ "scale"
74
+ ]]
75
+ ]);
76
+ /** A side and the sides it can be: `left` is the inline start or end, by direction. */
77
+ const SIDES = [
78
+ [/(^|-)(left|right)(?=-|$)/, ["inline-start", "inline-end"]],
79
+ [/(^|-)top(?=-|$)/, ["block-start"]],
80
+ [/(^|-)bottom(?=-|$)/, ["block-end"]],
81
+ [/(^|-)inline(?=-|$)(?!-(start|end))/, ["inline-start", "inline-end"]],
82
+ [/(^|-)block(?=-|$)(?!-(start|end))/, ["block-start", "block-end"]]
83
+ ];
84
+ const INSET_SIDES = /* @__PURE__ */ new Set([
85
+ "top",
86
+ "right",
87
+ "bottom",
88
+ "left"
89
+ ]);
90
+ /** The logical declarations a name writes, its physical sides read both ways. */
91
+ const writes = (declaration) => {
92
+ const named = INSET_SIDES.has(declaration) ? `inset-${declaration}` : declaration;
93
+ const out = [named];
94
+ for (const [side, logical] of SIDES) if (side.test(named)) for (const name of logical) out.push(named.replace(side, `$1${name}`));
95
+ return out;
96
+ };
97
+ /** `border-width` sets `border-top-width`, and `border-radius` `border-top-left-radius`. */
98
+ const BORDER_PART = /^border-(width|style|color|radius)$/;
99
+ const covers = (shorthand, longhand) => {
100
+ if (COVERS.get(shorthand)?.includes(longhand)) return true;
101
+ const part = BORDER_PART.exec(shorthand)?.[1];
102
+ if (part !== void 0) return longhand.startsWith("border-") && longhand.endsWith(`-${part}`);
103
+ const prefix = shorthand.split("-")[0];
104
+ const apart = SHORTHANDS.get(prefix);
105
+ if (apart === void 0 || apart.has(longhand)) return false;
106
+ return longhand.startsWith(`${shorthand}-`);
107
+ };
108
+ /** Whether writing `a` changes what `b` sets: one declaration, a shorthand of it, or its side. */
109
+ const overlaps = (a, b) => {
110
+ const left = writes(declarationName(a));
111
+ const right = writes(declarationName(b));
112
+ return left.some((x) => right.some((y) => x === y || covers(x, y) || covers(y, x)));
113
+ };
114
+ export { declarationName, overlaps };
115
+
116
+ //# sourceMappingURL=styleNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleNames.js","names":[],"sources":["../src/styleNames.ts"],"sourcesContent":["/**\n * What an inline style property really writes, so one owner and one\n * protection hold however it is spelled. Internal: not exported from the\n * package.\n *\n * Two names overlap when they write one declaration (`insetInlineEnd` and\n * `inset-inline-end`), when one is a shorthand that sets the other (`inset`,\n * `insetInline` and `margin` over their sides), when a physical side can be\n * the logical one (`right` is `insetInlineEnd` in a left-to-right line, and\n * `left` in a right-to-left one), or when one moves what the other does\n * (`translate`, `rotate` and `scale` beside `transform`). Sides are read for\n * a horizontal writing mode: `insetBlockStart` is `top`.\n */\n\nconst ASCII_UPPER = /[A-Z]/g\n\n/**\n * The CSS declaration Foldkit writes for a `Style` key: `cssDeclarationName`\n * in `foldkit/dist/domReflection.js`, which is not exported.\n */\nexport const declarationName = (name: string): string => {\n if (name.startsWith('--')) return name\n if (name === 'cssFloat') return 'float'\n const canonical = name.startsWith('Webkit') ? `webkit${name.slice('Webkit'.length)}` : name\n const kebab = canonical.replace(ASCII_UPPER, letter => `-${letter}`).toLowerCase()\n return kebab.startsWith('webkit-') || kebab.startsWith('ms-') ? `-${kebab}` : kebab\n}\n\n/**\n * Shorthands, and the names that extend them without being their longhands.\n * A name not listed here (`position`, `color`, `transform`) sets only itself,\n * so `positionAnchor` and `transformOrigin` stand apart from it.\n */\nconst SHORTHANDS: ReadonlyMap<string, ReadonlySet<string>> = new Map(\n (\n [\n ['inset'],\n ['margin'],\n ['padding'],\n ['scroll-margin'],\n ['scroll-padding'],\n ['border', 'border-collapse', 'border-spacing'],\n ['outline', 'outline-offset'],\n ['overflow', 'overflow-wrap', 'overflow-anchor', 'overflow-clip-margin'],\n ['background'],\n ['font'],\n ['grid'],\n ['flex'],\n ['transition'],\n ['animation'],\n ['list-style'],\n ['columns'],\n ['column-rule'],\n ['text-decoration'],\n ['mask'],\n ['offset'],\n ['container'],\n ] as const\n ).map(([root, ...apart]) => [root, new Set<string>(apart)]),\n)\n\n/** Shorthands whose longhands do not extend their name. */\nconst COVERS: ReadonlyMap<string, ReadonlyArray<string>> = new Map([\n ['gap', ['row-gap', 'column-gap']],\n ['place-items', ['align-items', 'justify-items']],\n ['place-content', ['align-content', 'justify-content']],\n ['place-self', ['align-self', 'justify-self']],\n ['flex-flow', ['flex-direction', 'flex-wrap']],\n // Not a shorthand: composed with `transform`, each moves the element too.\n ['transform', ['translate', 'rotate', 'scale']],\n])\n\n/** A side and the sides it can be: `left` is the inline start or end, by direction. */\nconst SIDES: ReadonlyArray<readonly [RegExp, ReadonlyArray<string>]> = [\n [/(^|-)(left|right)(?=-|$)/, ['inline-start', 'inline-end']],\n [/(^|-)top(?=-|$)/, ['block-start']],\n [/(^|-)bottom(?=-|$)/, ['block-end']],\n [/(^|-)inline(?=-|$)(?!-(start|end))/, ['inline-start', 'inline-end']],\n [/(^|-)block(?=-|$)(?!-(start|end))/, ['block-start', 'block-end']],\n]\n\nconst INSET_SIDES = new Set(['top', 'right', 'bottom', 'left'])\n\n/** The logical declarations a name writes, its physical sides read both ways. */\nconst writes = (declaration: string): ReadonlyArray<string> => {\n // `top` is the inset's side, as `margin-top` is the margin's.\n const named = INSET_SIDES.has(declaration) ? `inset-${declaration}` : declaration\n const out = [named]\n for (const [side, logical] of SIDES) {\n if (side.test(named)) {\n for (const name of logical) out.push(named.replace(side, `$1${name}`))\n }\n }\n return out\n}\n\n/** `border-width` sets `border-top-width`, and `border-radius` `border-top-left-radius`. */\nconst BORDER_PART = /^border-(width|style|color|radius)$/\n\nconst covers = (shorthand: string, longhand: string): boolean => {\n if (COVERS.get(shorthand)?.includes(longhand)) return true\n const part = BORDER_PART.exec(shorthand)?.[1]\n if (part !== undefined) return longhand.startsWith('border-') && longhand.endsWith(`-${part}`)\n const prefix = shorthand.split('-')[0]!\n const apart = SHORTHANDS.get(prefix)\n if (apart === undefined || apart.has(longhand)) return false\n // `margin` sets `margin-top`; `margin-inline` sets `margin-inline-start`.\n return longhand.startsWith(`${shorthand}-`)\n}\n\n/** Whether writing `a` changes what `b` sets: one declaration, a shorthand of it, or its side. */\nexport const overlaps = (a: string, b: string): boolean => {\n const left = writes(declarationName(a))\n const right = writes(declarationName(b))\n return left.some(x => right.some(y => x === y || covers(x, y) || covers(y, x)))\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,cAAc;;;;;AAMpB,MAAa,mBAAmB,SAAyB;CACvD,IAAI,KAAK,WAAW,IAAI,GAAG,OAAO;CAClC,IAAI,SAAS,YAAY,OAAO;CAEhC,MAAM,SADY,KAAK,WAAW,QAAQ,IAAI,SAAS,KAAK,MAAM,CAAe,MAAM,KAAA,CAC/D,QAAQ,cAAa,WAAU,IAAI,QAAQ,CAAC,CAAC,YAAY;CACjF,OAAO,MAAM,WAAW,SAAS,KAAK,MAAM,WAAW,KAAK,IAAI,IAAI,UAAU;AAChF;;;;;;AAOA,MAAM,aAAuD,IAAI,IAE7D;CACE,CAAC,OAAO;CACR,CAAC,QAAQ;CACT,CAAC,SAAS;CACV,CAAC,eAAe;CAChB,CAAC,gBAAgB;CACjB;EAAC;EAAU;EAAmB;CAAgB;CAC9C,CAAC,WAAW,gBAAgB;CAC5B;EAAC;EAAY;EAAiB;EAAmB;CAAsB;CACvE,CAAC,YAAY;CACb,CAAC,MAAM;CACP,CAAC,MAAM;CACP,CAAC,MAAM;CACP,CAAC,YAAY;CACb,CAAC,WAAW;CACZ,CAAC,YAAY;CACb,CAAC,SAAS;CACV,CAAC,aAAa;CACd,CAAC,iBAAiB;CAClB,CAAC,MAAM;CACP,CAAC,QAAQ;CACT,CAAC,WAAW;AACd,CAAC,CACD,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,IAAI,IAAY,KAAK,CAAC,CAAC,CAC5D;;AAGA,MAAM,yBAAqD,IAAI,IAAI;CACjE,CAAC,OAAO,CAAC,WAAW,YAAY,CAAC;CACjC,CAAC,eAAe,CAAC,eAAe,eAAe,CAAC;CAChD,CAAC,iBAAiB,CAAC,iBAAiB,iBAAiB,CAAC;CACtD,CAAC,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AO,OAAO,gBAAgB,CAAC,CAAC;CACtC,MAAM,QAAQ,OAAO,gBAAgB,CAAC,CAAC;CACvC,OAAO,KAAK,MAAK,MAAK,MAAM,MAAK,MAAK,MAAM,KAAK,OAAO,GAAG,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC;AAChF"}
package/dist/vite.d.ts CHANGED
@@ -19,7 +19,8 @@ export interface StylesOptions {
19
19
  * a string or an object of strings (`t`); a Style using `Style.whenInput` or
20
20
  * `Style.perItem` fails the build, and a module that needs one stays off the
21
21
  * list. With any module listed, the build's Slots inject no CSS: the sheet
22
- * holds every class, and the build fails if a frozen class has no rule in it.
22
+ * holds every class, and the build fails if a frozen class has no rule in it
23
+ * or if the page still compiles a Style (a module off the list).
23
24
  * Development is unchanged.
24
25
  */
25
26
  readonly modules?: ReadonlyArray<string> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";iBA+BiB;;WAEN;;;;;;;WAOA;aAAmB,OAAO;;;;;;;;;;;;;WAY1B,UAAU;;;qBAsGR,SAAM,SAAa,kBAAgB"}
1
+ {"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";iBA+BiB;;WAEN;;;;;;;WAOA;aAAmB,OAAO;;;;;;;;;;;;;;WAa1B,UAAU;;;qBA4IR,SAAM,SAAa,kBAAgB"}
package/dist/vite.js CHANGED
@@ -91,6 +91,29 @@ const buildSheet = async (config, sheet, modules) => {
91
91
  assets: files.filter((file) => file.type === "asset")
92
92
  };
93
93
  };
94
+ const COMPILER = /[\\/]styleRules\.[cm]?[jt]s$/;
95
+ const OWN_PACKAGE = /[\\/]mixins[\\/](src|dist)[\\/]|[\\/]foldkit-mixins[\\/]/;
96
+ /**
97
+ * Freezing turns the run-time injection off, which a Style compiled in the
98
+ * page needs for its classes to have any rule: one in a module off the list,
99
+ * or made per item at draw time. The compiler in the bundle is the sign of
100
+ * one, so the build names the modules that bring it and fails.
101
+ */
102
+ const refuseCompiler = (context, bundle) => {
103
+ const rendered = new Set(Object.values(bundle).flatMap((file) => file.type === "chunk" ? Object.entries(file.modules).flatMap(([id, info]) => info.renderedLength > 0 ? [id] : []) : []));
104
+ const compiler = [...rendered].filter((id) => COMPILER.test(id));
105
+ if (compiler.length === 0) return;
106
+ const culprits = /* @__PURE__ */ new Set();
107
+ const seen = new Set(compiler);
108
+ const queue = [...compiler];
109
+ for (const id of queue) for (const importer of context.getModuleInfo(id)?.importers ?? []) {
110
+ if (seen.has(importer)) continue;
111
+ seen.add(importer);
112
+ if (OWN_PACKAGE.test(importer)) queue.push(importer);
113
+ else if (rendered.has(importer)) culprits.add(importer);
114
+ }
115
+ throw new Error(`foldkit-mixins/vite: ${[...culprits].slice(0, 5).join(", ") || "a module"} compiles Styles in the browser build, which \`modules\` leaves with no run-time injection, so a class compiled there would have no rule. List the module in \`modules\`, or drop \`modules\`.`);
116
+ };
94
117
  /** The plugin: see the module's comment. */
95
118
  const styles = (options) => {
96
119
  const modules = [...new Set(options.modules ?? [])];
@@ -171,6 +194,7 @@ const styles = (options) => {
171
194
  },
172
195
  async generateBundle(_options, bundle) {
173
196
  if (this.environment.name !== "client") return;
197
+ if (freezing(this.environment.name)) refuseCompiler(this, bundle);
174
198
  const { css, fileName, assets } = await build();
175
199
  this.emitFile({
176
200
  type: "asset",
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * `foldkit-mixins/vite`: the application's stylesheet as a file. A server\n * that writes the sheet into every page sends it every time and has its\n * framework parse it again to check the page; a hashed file is fetched once\n * and cached. The plugin builds the sheet module, writes `assets/styles-<hash>.css`\n * into the browser build, and gives the server entry its address:\n *\n * ```ts\n * import { href } from 'virtual:foldkit-styles'\n * ```\n *\n * In dev the same `href` serves the sheet from the dev server, so the server\n * entry has one code path.\n *\n * The style modules named in `modules` are evaluated in the same pass, and a\n * production browser build ships each as data: its Styles' classes, not the\n * compiler that worked them out (`viteFreeze.ts`, #420).\n */\nimport { createHash } from 'node:crypto'\nimport type { Plugin, ResolvedConfig, Rollup, ViteDevServer } from 'vite'\nimport { prune } from './theme/prune.js'\nimport { assertRules, freeze, type FrozenModule } from './viteFreeze.js'\n\nconst VIRTUAL = 'virtual:foldkit-styles'\nconst SHEET = 'virtual:foldkit-styles-sheet'\n// Rollup's mark for a module no file holds, which other plugins leave alone.\nconst NUL = String.fromCharCode(0)\nconst DEV_PATH = '/__foldkit-styles.css'\n/** Defined in a production browser build that freezes modules: `SlotView` then injects nothing. */\nconst FROZEN_DEFINE = '__FOLDKIT_MIXINS_FROZEN_STYLES__'\n\nexport interface StylesOptions {\n /** A module id (as an import would write it) that exports the application's stylesheet text as `stylesheet`. */\n readonly sheet: string\n /**\n * Ship only the `--fk-*` tokens the sheet reads (`Inert.prune`), and those\n * `keep` names: a token a view reads inline (`Theme.ref`) or a script reads\n * by name. Run `Inert.missingTokens` over a drawn page and the pruned sheet\n * in a test, so a token pruning took from a view fails there.\n */\n readonly prune?: { readonly keep?: ReadonlyArray<string> } | undefined\n /**\n * Style modules (ids as an import would write them) the production browser\n * build replaces with what they evaluate to: each Style's name and the\n * classes and inline declarations its Slots draw, so the page loads no\n * style compiler. Each export must be a Style, a `Style.slots` declaration,\n * a string or an object of strings (`t`); a Style using `Style.whenInput` or\n * `Style.perItem` fails the build, and a module that needs one stays off the\n * list. With any module listed, the build's Slots inject no CSS: the sheet\n * holds every class, and the build fails if a frozen class has no rule in it.\n * Development is unchanged.\n */\n readonly modules?: ReadonlyArray<string> | undefined\n}\n\n/**\n * The module the plugin builds: the sheet, completed with every class its\n * modules compiled, and the style modules listed, which load first so their\n * classes are among them.\n */\nconst sheetSource = (sheet: string, modules: ReadonlyArray<string>): string =>\n [\n `import { stylesheet } from ${JSON.stringify(sheet)}`,\n ...modules.map((id, index) => `import * as module${index} from ${JSON.stringify(id)}`),\n `import { Style } from 'foldkit-mixins'`,\n `export const css = Style.complete(stylesheet)`,\n `export const modules = [${modules.map((_, index) => `module${index}`).join(', ')}]`,\n ].join('\\n')\n\nconst sheetModule = (sheet: string, modules: ReadonlyArray<string>): Plugin => ({\n name: 'foldkit-mixins:styles-sheet',\n resolveId: id => (id === SHEET ? NUL + SHEET : undefined),\n load: id => (id === NUL + SHEET ? sheetSource(sheet, modules) : undefined),\n})\n\ninterface Evaluated {\n readonly css: string\n /** Each listed module's exports, in the order of `modules`. */\n readonly modules: ReadonlyArray<Readonly<Record<string, unknown>>>\n /** The files the sheet names (a font's `?url`), which only the browser build can emit. */\n readonly assets: ReadonlyArray<Rollup.OutputAsset>\n}\n\n/**\n * The sheet's CSS, from a build of the sheet module on its own that runs here:\n * bundled whole, so an import of a file (`?url`) is the same hashed address the\n * browser build gives it, which the running dev server's address would not be.\n */\nconst buildSheet = async (\n config: ResolvedConfig,\n sheet: string,\n modules: ReadonlyArray<string>,\n): Promise<Evaluated> => {\n const { build } = await import('vite')\n const output = await build({\n configFile: false,\n root: config.root,\n mode: config.mode,\n base: config.base,\n logLevel: 'silent',\n resolve: { conditions: config.resolve.conditions, alias: config.resolve.alias },\n ssr: {\n noExternal: true,\n resolve: { conditions: config.ssr.resolve?.conditions ?? config.resolve.conditions },\n },\n plugins: [sheetModule(sheet, modules)],\n build: {\n ssr: true,\n // Compiling a Style registers its class as a side effect, and a module\n // imported only for that has no export in use: treeshaking would drop\n // it (a package's `sideEffects: false`, or an unused call's result)\n // before it ran, and its classes would be missing from the sheet.\n rollupOptions: { input: SHEET, treeshake: false },\n write: false,\n minify: false,\n emptyOutDir: false,\n // A server build emits no files by default, so the sheet's fonts would\n // be named in it and written nowhere.\n emitAssets: true,\n assetsInlineLimit: config.build.assetsInlineLimit,\n },\n })\n const files = [output].flat().flatMap(result => ('output' in result ? result.output : []))\n const chunk = files.find(file => file.type === 'chunk')\n if (chunk === undefined || chunk.type !== 'chunk')\n throw new Error(`foldkit-mixins/vite: building \"${sheet}\" produced no module`)\n const loaded: unknown = await import(\n /* @vite-ignore */ `data:text/javascript;base64,${Buffer.from(chunk.code).toString('base64')}`\n )\n // The module `sheetSource` wrote: its two exports are known.\n const { css, modules: namespaces } = loaded as Pick<Evaluated, 'modules'> & {\n readonly css: unknown\n }\n if (typeof css !== 'string')\n throw new Error(\n `foldkit-mixins/vite: \"${sheet}\" does not export its stylesheet text as \\`stylesheet\\``,\n )\n return {\n css,\n modules: namespaces,\n assets: files.filter((file): file is Rollup.OutputAsset => file.type === 'asset'),\n }\n}\n\ninterface Built {\n readonly css: string\n readonly fileName: string\n readonly href: string\n /** Each listed module as the browser build ships it, by its id in `modules`. */\n readonly frozen: ReadonlyMap<string, FrozenModule>\n readonly assets: ReadonlyArray<Rollup.OutputAsset>\n}\n\n/** The plugin: see the module's comment. */\nexport const styles = (options: StylesOptions): Plugin => {\n const modules = [...new Set(options.modules ?? [])]\n let config: ResolvedConfig\n let dev: ViteDevServer | undefined\n let devCss: Promise<string> | undefined\n let built: Promise<Built> | undefined\n /** The resolved file of each listed module, in the browser build, to its id in `modules`. */\n const listed = new Map<string, string>()\n // Dev serves the same pruned sheet a build ships, so a missing token shows there first.\n const shipped = (css: string): string =>\n options.prune === undefined ? css : prune(css, options.prune)\n\n const build = (): Promise<Built> =>\n (built ??= buildSheet(config, options.sheet, modules).then(evaluated => {\n const css = shipped(evaluated.css)\n const frozen = new Map(\n modules.map((id, index) => {\n const namespace = evaluated.modules[index]\n if (namespace === undefined)\n throw new Error(`foldkit-mixins/vite: building the sheet did not evaluate \"${id}\"`)\n return [id, freeze(id, namespace)]\n }),\n )\n // With no injection behind it, a frozen class the shipped sheet lacks\n // would draw nothing: refuse the build instead.\n assertRules(frozen, css)\n const fileName = `assets/styles-${createHash('sha256').update(css).digest('hex').slice(0, 8)}.css`\n return { css, fileName, href: `${config.base}${fileName}`, frozen, assets: evaluated.assets }\n }))\n\n const freezing = (environment: string): boolean =>\n modules.length > 0 && config.command === 'build' && environment === 'client'\n\n return {\n name: 'foldkit-mixins:styles',\n sharedDuringBuild: true,\n configResolved(resolved) {\n config = resolved\n if (resolved.command === 'build' && !/^(\\/|https?:\\/\\/)/.test(resolved.base)) {\n throw new Error(\n `foldkit-mixins/vite: base \"${resolved.base}\" is relative, so the sheet's address would depend on the page; give base an absolute path or URL`,\n )\n }\n },\n configEnvironment(name, _options, env) {\n // `freezing`'s test, before `config` is resolved.\n if (modules.length === 0 || env.command !== 'build' || name !== 'client') return undefined\n return { define: { [FROZEN_DEFINE]: 'true' } }\n },\n configureServer(server) {\n dev = server\n // The sheet is read from the modules the server has loaded, so an edit means reading it again.\n server.watcher.on('change', () => {\n devCss = undefined\n })\n server.middlewares.use(DEV_PATH, (_request, response, next) => {\n devCss ??= server.ssrLoadModule(SHEET).then(loaded => shipped(String(loaded.css)))\n devCss.then(\n css => {\n response.setHeader('content-type', 'text/css; charset=utf-8')\n response.setHeader('cache-control', 'no-cache')\n response.end(css)\n },\n error => {\n devCss = undefined\n next(error)\n },\n )\n })\n },\n async buildStart() {\n if (this.environment.name === 'client') built = undefined\n if (!freezing(this.environment.name)) return\n listed.clear()\n for (const id of modules) {\n const resolved = await this.resolve(id)\n if (resolved === null)\n throw new Error(\n `foldkit-mixins/vite: the style module \"${id}\" in \\`modules\\` does not resolve`,\n )\n listed.set(resolved.id, id)\n }\n },\n resolveId(id) {\n if (id === VIRTUAL) return NUL + VIRTUAL\n // The dev server loads the sheet through this plugin; a build loads it through its own.\n if (id === SHEET && dev !== undefined) return NUL + SHEET\n return undefined\n },\n async load(id) {\n if (id === NUL + SHEET) return sheetSource(options.sheet, modules)\n const module = freezing(this.environment.name) ? listed.get(id) : undefined\n if (module !== undefined) return (await build()).frozen.get(module)?.source\n if (id !== NUL + VIRTUAL) return undefined\n const href = dev === undefined ? (await build()).href : DEV_PATH\n return `export const href = ${JSON.stringify(href)}`\n },\n async generateBundle(_options, bundle) {\n // The browser build comes first, and is the one a host serves files from.\n if (this.environment.name !== 'client') return\n const { css, fileName, assets } = await build()\n this.emitFile({ type: 'asset', fileName, source: css })\n // Hashed by content, so a file the browser build also references is the same file.\n for (const asset of assets)\n if (!(asset.fileName in bundle))\n this.emitFile({ type: 'asset', fileName: asset.fileName, source: asset.source })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,UAAU;AAChB,MAAM,QAAQ;AAEd,MAAM,MAAM,OAAO,aAAa,CAAC;AACjC,MAAM,WAAW;;AAEjB,MAAM,gBAAgB;;;;;;AA+BtB,MAAM,eAAe,OAAe,YAClC;CACE,8BAA8B,KAAK,UAAU,KAAK;CAClD,GAAG,QAAQ,KAAK,IAAI,UAAU,qBAAqB,MAAM,QAAQ,KAAK,UAAU,EAAE,GAAG;CACrF;CACA;CACA,2BAA2B,QAAQ,KAAK,GAAG,UAAU,SAAS,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE;AACpF,CAAC,CAAC,KAAK,IAAI;AAEb,MAAM,eAAe,OAAe,aAA4C;CAC9E,MAAM;CACN,YAAW,OAAO,OAAO,QAAQ,MAAM,QAAQ,KAAA;CAC/C,OAAM,OAAO,OAAO,MAAM,QAAQ,YAAY,OAAO,OAAO,IAAI,KAAA;AAClE;;;;;;AAeA,MAAM,aAAa,OACjB,QACA,OACA,YACuB;CACvB,MAAM,EAAE,UAAU,MAAM,OAAO;CA6B/B,MAAM,QAAQ,CAAC,MA5BM,MAAM;EACzB,YAAY;EACZ,MAAM,OAAO;EACb,MAAM,OAAO;EACb,MAAM,OAAO;EACb,UAAU;EACV,SAAS;GAAE,YAAY,OAAO,QAAQ;GAAY,OAAO,OAAO,QAAQ;EAAM;EAC9E,KAAK;GACH,YAAY;GACZ,SAAS,EAAE,YAAY,OAAO,IAAI,SAAS,cAAc,OAAO,QAAQ,WAAW;EACrF;EACA,SAAS,CAAC,YAAY,OAAO,OAAO,CAAC;EACrC,OAAO;GACL,KAAK;GAKL,eAAe;IAAE,OAAO;IAAO,WAAW;GAAM;GAChD,OAAO;GACP,QAAQ;G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AAE;IACtC,IAAI,aAAa,MACf,MAAM,IAAI,MACR,0CAA0C,GAAG,kCAC/C;IACF,OAAO,IAAI,SAAS,IAAI,EAAE;GAC5B;EACF;EACA,UAAU,IAAI;GACZ,IAAI,OAAO,SAAS,OAAO,MAAM;GAEjC,IAAI,OAAO,SAAS,QAAQ,KAAA,GAAW,OAAO,MAAM;EAEtD;EACA,MAAM,KAAK,IAAI;GACb,IAAI,OAAO,MAAM,OAAO,OAAO,YAAY,QAAQ,OAAO,OAAO;GACjE,MAAM,SAAS,SAAS,KAAK,YAAY,IAAI,IAAI,OAAO,IAAI,EAAE,IAAI,KAAA;GAClE,IAAI,WAAW,KAAA,GAAW,QAAQ,MAAM,MAAM,EAAA,CAAG,OAAO,IAAI,MAAM,CAAC,EAAE;GACrE,IAAI,OAAO,MAAM,SAAS,OAAO,KAAA;GACjC,MAAM,OAAO,QAAQ,KAAA,KAAa,MAAM,MAAM,EAAA,CAAG,OAAO;GACxD,OAAO,uBAAuB,KAAK,UAAU,IAAI;EACnD;EACA,MAAM,eAAe,UAAU,QAAQ;GAErC,IAAI,KAAK,YAAY,SAAS,UAAU;GACxC,MAAM,EAAE,KAAK,UAAU,WAAW,MAAM,MAAM;GAC9C,KAAK,SAAS;IAAE,MAAM;IAAS;IAAU,QAAQ;GAAI,CAAC;GAEtD,KAAK,MAAM,SAAS,QAClB,IAAI,EAAE,MAAM,YAAY,SACtB,KAAK,SAAS;IAAE,MAAM;IAAS,UAAU,MAAM;IAAU,QAAQ,MAAM;GAAO,CAAC;EACrF;CACF;AACF"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * `foldkit-mixins/vite`: the application's stylesheet as a file. A server\n * that writes the sheet into every page sends it every time and has its\n * framework parse it again to check the page; a hashed file is fetched once\n * and cached. The plugin builds the sheet module, writes `assets/styles-<hash>.css`\n * into the browser build, and gives the server entry its address:\n *\n * ```ts\n * import { href } from 'virtual:foldkit-styles'\n * ```\n *\n * In dev the same `href` serves the sheet from the dev server, so the server\n * entry has one code path.\n *\n * The style modules named in `modules` are evaluated in the same pass, and a\n * production browser build ships each as data: its Styles' classes, not the\n * compiler that worked them out (`viteFreeze.ts`, #420).\n */\nimport { createHash } from 'node:crypto'\nimport type { Plugin, ResolvedConfig, Rollup, ViteDevServer } from 'vite'\nimport { prune } from './theme/prune.js'\nimport { assertRules, freeze, type FrozenModule } from './viteFreeze.js'\n\nconst VIRTUAL = 'virtual:foldkit-styles'\nconst SHEET = 'virtual:foldkit-styles-sheet'\n// Rollup's mark for a module no file holds, which other plugins leave alone.\nconst NUL = String.fromCharCode(0)\nconst DEV_PATH = '/__foldkit-styles.css'\n/** Defined in a production browser build that freezes modules: `SlotView` then injects nothing. */\nconst FROZEN_DEFINE = '__FOLDKIT_MIXINS_FROZEN_STYLES__'\n\nexport interface StylesOptions {\n /** A module id (as an import would write it) that exports the application's stylesheet text as `stylesheet`. */\n readonly sheet: string\n /**\n * Ship only the `--fk-*` tokens the sheet reads (`Inert.prune`), and those\n * `keep` names: a token a view reads inline (`Theme.ref`) or a script reads\n * by name. Run `Inert.missingTokens` over a drawn page and the pruned sheet\n * in a test, so a token pruning took from a view fails there.\n */\n readonly prune?: { readonly keep?: ReadonlyArray<string> } | undefined\n /**\n * Style modules (ids as an import would write them) the production browser\n * build replaces with what they evaluate to: each Style's name and the\n * classes and inline declarations its Slots draw, so the page loads no\n * style compiler. Each export must be a Style, a `Style.slots` declaration,\n * a string or an object of strings (`t`); a Style using `Style.whenInput` or\n * `Style.perItem` fails the build, and a module that needs one stays off the\n * list. With any module listed, the build's Slots inject no CSS: the sheet\n * holds every class, and the build fails if a frozen class has no rule in it\n * or if the page still compiles a Style (a module off the list).\n * Development is unchanged.\n */\n readonly modules?: ReadonlyArray<string> | undefined\n}\n\n/**\n * The module the plugin builds: the sheet, completed with every class its\n * modules compiled, and the style modules listed, which load first so their\n * classes are among them.\n */\nconst sheetSource = (sheet: string, modules: ReadonlyArray<string>): string =>\n [\n `import { stylesheet } from ${JSON.stringify(sheet)}`,\n ...modules.map((id, index) => `import * as module${index} from ${JSON.stringify(id)}`),\n `import { Style } from 'foldkit-mixins'`,\n `export const css = Style.complete(stylesheet)`,\n `export const modules = [${modules.map((_, index) => `module${index}`).join(', ')}]`,\n ].join('\\n')\n\nconst sheetModule = (sheet: string, modules: ReadonlyArray<string>): Plugin => ({\n name: 'foldkit-mixins:styles-sheet',\n resolveId: id => (id === SHEET ? NUL + SHEET : undefined),\n load: id => (id === NUL + SHEET ? sheetSource(sheet, modules) : undefined),\n})\n\ninterface Evaluated {\n readonly css: string\n /** Each listed module's exports, in the order of `modules`. */\n readonly modules: ReadonlyArray<Readonly<Record<string, unknown>>>\n /** The files the sheet names (a font's `?url`), which only the browser build can emit. */\n readonly assets: ReadonlyArray<Rollup.OutputAsset>\n}\n\n/**\n * The sheet's CSS, from a build of the sheet module on its own that runs here:\n * bundled whole, so an import of a file (`?url`) is the same hashed address the\n * browser build gives it, which the running dev server's address would not be.\n */\nconst buildSheet = async (\n config: ResolvedConfig,\n sheet: string,\n modules: ReadonlyArray<string>,\n): Promise<Evaluated> => {\n const { build } = await import('vite')\n const output = await build({\n configFile: false,\n root: config.root,\n mode: config.mode,\n base: config.base,\n logLevel: 'silent',\n resolve: { conditions: config.resolve.conditions, alias: config.resolve.alias },\n ssr: {\n noExternal: true,\n resolve: { conditions: config.ssr.resolve?.conditions ?? config.resolve.conditions },\n },\n plugins: [sheetModule(sheet, modules)],\n build: {\n ssr: true,\n // Compiling a Style registers its class as a side effect, and a module\n // imported only for that has no export in use: treeshaking would drop\n // it (a package's `sideEffects: false`, or an unused call's result)\n // before it ran, and its classes would be missing from the sheet.\n rollupOptions: { input: SHEET, treeshake: false },\n write: false,\n minify: false,\n emptyOutDir: false,\n // A server build emits no files by default, so the sheet's fonts would\n // be named in it and written nowhere.\n emitAssets: true,\n assetsInlineLimit: config.build.assetsInlineLimit,\n },\n })\n const files = [output].flat().flatMap(result => ('output' in result ? result.output : []))\n const chunk = files.find(file => file.type === 'chunk')\n if (chunk === undefined || chunk.type !== 'chunk')\n throw new Error(`foldkit-mixins/vite: building \"${sheet}\" produced no module`)\n const loaded: unknown = await import(\n /* @vite-ignore */ `data:text/javascript;base64,${Buffer.from(chunk.code).toString('base64')}`\n )\n // The module `sheetSource` wrote: its two exports are known.\n const { css, modules: namespaces } = loaded as Pick<Evaluated, 'modules'> & {\n readonly css: unknown\n }\n if (typeof css !== 'string')\n throw new Error(\n `foldkit-mixins/vite: \"${sheet}\" does not export its stylesheet text as \\`stylesheet\\``,\n )\n return {\n css,\n modules: namespaces,\n assets: files.filter((file): file is Rollup.OutputAsset => file.type === 'asset'),\n }\n}\n\ninterface Built {\n readonly css: string\n readonly fileName: string\n readonly href: string\n /** Each listed module as the browser build ships it, by its id in `modules`. */\n readonly frozen: ReadonlyMap<string, FrozenModule>\n readonly assets: ReadonlyArray<Rollup.OutputAsset>\n}\n\n// The Style compiler's rules module, the one thing a page that compiles a Style at run time holds.\nconst COMPILER = /[\\\\/]styleRules\\.[cm]?[jt]s$/\nconst OWN_PACKAGE = /[\\\\/]mixins[\\\\/](src|dist)[\\\\/]|[\\\\/]foldkit-mixins[\\\\/]/\n\n/**\n * Freezing turns the run-time injection off, which a Style compiled in the\n * page needs for its classes to have any rule: one in a module off the list,\n * or made per item at draw time. The compiler in the bundle is the sign of\n * one, so the build names the modules that bring it and fails.\n */\nconst refuseCompiler = (context: Rollup.PluginContext, bundle: Rollup.OutputBundle): void => {\n const rendered = new Set(\n Object.values(bundle).flatMap(file =>\n file.type === 'chunk'\n ? Object.entries(file.modules).flatMap(([id, info]) =>\n info.renderedLength > 0 ? [id] : [],\n )\n : [],\n ),\n )\n const compiler = [...rendered].filter(id => COMPILER.test(id))\n if (compiler.length === 0) return\n // Up from the compiler through this package to the application's own modules.\n const culprits = new Set<string>()\n const seen = new Set<string>(compiler)\n const queue = [...compiler]\n for (const id of queue)\n for (const importer of context.getModuleInfo(id)?.importers ?? []) {\n if (seen.has(importer)) continue\n seen.add(importer)\n if (OWN_PACKAGE.test(importer)) queue.push(importer)\n else if (rendered.has(importer)) culprits.add(importer)\n }\n throw new Error(\n `foldkit-mixins/vite: ${[...culprits].slice(0, 5).join(', ') || 'a module'} compiles Styles in the browser build, which \\`modules\\` leaves with no run-time injection, so a class compiled there would have no rule. List the module in \\`modules\\`, or drop \\`modules\\`.`,\n )\n}\n\n/** The plugin: see the module's comment. */\nexport const styles = (options: StylesOptions): Plugin => {\n const modules = [...new Set(options.modules ?? [])]\n let config: ResolvedConfig\n let dev: ViteDevServer | undefined\n let devCss: Promise<string> | undefined\n let built: Promise<Built> | undefined\n /** The resolved file of each listed module, in the browser build, to its id in `modules`. */\n const listed = new Map<string, string>()\n // Dev serves the same pruned sheet a build ships, so a missing token shows there first.\n const shipped = (css: string): string =>\n options.prune === undefined ? css : prune(css, options.prune)\n\n const build = (): Promise<Built> =>\n (built ??= buildSheet(config, options.sheet, modules).then(evaluated => {\n const css = shipped(evaluated.css)\n const frozen = new Map(\n modules.map((id, index) => {\n const namespace = evaluated.modules[index]\n if (namespace === undefined)\n throw new Error(`foldkit-mixins/vite: building the sheet did not evaluate \"${id}\"`)\n return [id, freeze(id, namespace)]\n }),\n )\n // With no injection behind it, a frozen class the shipped sheet lacks\n // would draw nothing: refuse the build instead.\n assertRules(frozen, css)\n const fileName = `assets/styles-${createHash('sha256').update(css).digest('hex').slice(0, 8)}.css`\n return { css, fileName, href: `${config.base}${fileName}`, frozen, assets: evaluated.assets }\n }))\n\n const freezing = (environment: string): boolean =>\n modules.length > 0 && config.command === 'build' && environment === 'client'\n\n return {\n name: 'foldkit-mixins:styles',\n sharedDuringBuild: true,\n configResolved(resolved) {\n config = resolved\n if (resolved.command === 'build' && !/^(\\/|https?:\\/\\/)/.test(resolved.base)) {\n throw new Error(\n `foldkit-mixins/vite: base \"${resolved.base}\" is relative, so the sheet's address would depend on the page; give base an absolute path or URL`,\n )\n }\n },\n configEnvironment(name, _options, env) {\n // `freezing`'s test, before `config` is resolved.\n if (modules.length === 0 || env.command !== 'build' || name !== 'client') return undefined\n return { define: { [FROZEN_DEFINE]: 'true' } }\n },\n configureServer(server) {\n dev = server\n // The sheet is read from the modules the server has loaded, so an edit means reading it again.\n server.watcher.on('change', () => {\n devCss = undefined\n })\n server.middlewares.use(DEV_PATH, (_request, response, next) => {\n devCss ??= server.ssrLoadModule(SHEET).then(loaded => shipped(String(loaded.css)))\n devCss.then(\n css => {\n response.setHeader('content-type', 'text/css; charset=utf-8')\n response.setHeader('cache-control', 'no-cache')\n response.end(css)\n },\n error => {\n devCss = undefined\n next(error)\n },\n )\n })\n },\n async buildStart() {\n if (this.environment.name === 'client') built = undefined\n if (!freezing(this.environment.name)) return\n listed.clear()\n for (const id of modules) {\n const resolved = await this.resolve(id)\n if (resolved === null)\n throw new Error(\n `foldkit-mixins/vite: the style module \"${id}\" in \\`modules\\` does not resolve`,\n )\n listed.set(resolved.id, id)\n }\n },\n resolveId(id) {\n if (id === VIRTUAL) return NUL + VIRTUAL\n // The dev server loads the sheet through this plugin; a build loads it through its own.\n if (id === SHEET && dev !== undefined) return NUL + SHEET\n return undefined\n },\n async load(id) {\n if (id === NUL + SHEET) return sheetSource(options.sheet, modules)\n const module = freezing(this.environment.name) ? listed.get(id) : undefined\n if (module !== undefined) return (await build()).frozen.get(module)?.source\n if (id !== NUL + VIRTUAL) return undefined\n const href = dev === undefined ? (await build()).href : DEV_PATH\n return `export const href = ${JSON.stringify(href)}`\n },\n async generateBundle(_options, bundle) {\n // The browser build comes first, and is the one a host serves files from.\n if (this.environment.name !== 'client') return\n if (freezing(this.environment.name)) refuseCompiler(this, bundle)\n const { css, fileName, assets } = await build()\n this.emitFile({ type: 'asset', fileName, source: css })\n // Hashed by content, so a file the browser build also references is the same file.\n for (const asset of assets)\n if (!(asset.fileName in bundle))\n this.emitFile({ type: 'asset', fileName: asset.fileName, source: asset.source })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;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AM,CAAC,EAAE;GACrE,IAAI,OAAO,MAAM,SAAS,OAAO,KAAA;GACjC,MAAM,OAAO,QAAQ,KAAA,KAAa,MAAM,MAAM,EAAA,CAAG,OAAO;GACxD,OAAO,uBAAuB,KAAK,UAAU,IAAI;EACnD;EACA,MAAM,eAAe,UAAU,QAAQ;GAErC,IAAI,KAAK,YAAY,SAAS,UAAU;GACxC,IAAI,SAAS,KAAK,YAAY,IAAI,GAAG,eAAe,MAAM,MAAM;GAChE,MAAM,EAAE,KAAK,UAAU,WAAW,MAAM,MAAM;GAC9C,KAAK,SAAS;IAAE,MAAM;IAAS;IAAU,QAAQ;GAAI,CAAC;GAEtD,KAAK,MAAM,SAAS,QAClB,IAAI,EAAE,MAAM,YAAY,SACtB,KAAK,SAAS;IAAE,MAAM;IAAS,UAAU,MAAM;IAAU,QAAQ,MAAM;GAAO,CAAC;EACrF;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-mixins",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "Typed slot contracts and inside-out Style/Behavior attachments for Foldkit.",
5
5
  "keywords": [
6
6
  "foldkit",