@master/internal-site 0.2.0 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@master/internal-site",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "First-party Astro and Svelte website framework for Master sites.",
6
6
  "engines": {
@@ -11,19 +11,29 @@ export interface PropagatedModule<T> {
11
11
  collectedStyles: (string | { id: string, content: string })[]
12
12
  }
13
13
 
14
+ export interface PageStyle {
15
+ /** The dev-time Vite module id. Hydrated islands that import the same CSS update this element in place. */
16
+ id?: string
17
+ content: string
18
+ }
19
+
14
20
  export interface PageAssets {
15
21
  links: string[]
16
- styles: string[]
22
+ styles: PageStyle[]
17
23
  }
18
24
 
19
25
  export const propagatedAssetsQuery = '?astroPropagatedAssets'
20
26
 
21
27
  export function mergeAssets(...modules: PropagatedModule<unknown>[]): PageAssets {
22
28
  const links = new Set<string>()
23
- const styles = new Set<string>()
29
+ const styles = new Map<string, PageStyle>()
24
30
  for (const module of modules) {
25
31
  module.collectedLinks.forEach((link) => links.add(link))
26
- module.collectedStyles.forEach((style) => styles.add(typeof style === 'string' ? style : style.content))
32
+ for (const style of module.collectedStyles) {
33
+ const record: PageStyle = typeof style === 'string' ? { content: style } : style
34
+ const key = record.id ?? record.content
35
+ if (!styles.has(key)) styles.set(key, record)
36
+ }
27
37
  }
28
- return { links: [...links], styles: [...styles] }
38
+ return { links: [...links], styles: [...styles.values()] }
29
39
  }
@@ -56,7 +56,8 @@ if (['dark', 'light'].includes(value)) document.documentElement.style.colorSchem
56
56
  Their request-local context must already exist, even with cached CSS/JS. */}
57
57
  <script is:inline type="application/json" id={siteContextElementId} set:html={siteContextJSON}></script>
58
58
  {assets.links.map((href) => <link rel="stylesheet" href={href} />)}
59
- {assets.styles.map((css) => <style is:inline set:html={css}></style>)}
59
+ {/* Without the dev id, Vite appends a second copy when an island imports the same CSS, reordering the cascade. */}
60
+ {assets.styles.map(({ id, content }) => <style is:inline data-vite-dev-id={id} set:html={content}></style>)}
60
61
  <title>{head.title}</title>
61
62
  {config.feeds?.map(feed => <link rel="alternate" type={feed.type} title={feed.title} href={new URL(feed.href, config.origin).href} />)}
62
63
  {head.tags.map(({ tag: Tag, attributes }) => <Tag {...attributes} />)}
@@ -40,7 +40,7 @@
40
40
 
41
41
  /* Media: whole pictures on the code panels' corner, with the quiet perimeter every image keeps — except an
42
42
  illustration, which is a tray's stage and is told apart by its tone alone. */
43
- .ui-prose :is(img, video):not(:where(.site-demo *, [data-demo-container] *)) { height: auto; }
43
+ .ui-prose :is(img, video):not(:where(.site-demo *, [data-demo-container] *, .ui-tree *)) { height: auto; }
44
44
  .ui-prose :is(img, video):not(:where(.site-demo *, [data-demo-container] *, .document-illustration *, :focus-visible)) { outline: 1px solid var(--color-line-media); outline-offset: -1px; }
45
45
  :is(figure, p, a, picture):is(.ui-prose > *) :is(img, video):not(:where(.site-demo *, [data-demo-container] *)), :is(img, video):is(.ui-prose > *) { display: block; width: 100%; max-width: none; border-radius: var(--ui-radius-xl); }
46
46
  :is(a, picture):is(.ui-prose > *) { display: block; }