@erclx/canon 5.29.0 → 5.30.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/package.json
CHANGED
|
@@ -51,6 +51,15 @@ chrome.rel = 'stylesheet'
|
|
|
51
51
|
chrome.href = '/api/chrome.css'
|
|
52
52
|
document.head.prepend(chrome)
|
|
53
53
|
|
|
54
|
+
/*
|
|
55
|
+
* The page declares an empty icon so the browser never asks for /favicon.ico,
|
|
56
|
+
* since the bundler cannot resolve a route the server answers, and this points
|
|
57
|
+
* it at the brand icon once the shell loads.
|
|
58
|
+
*/
|
|
59
|
+
document
|
|
60
|
+
.querySelector('link[rel="icon"]')
|
|
61
|
+
?.setAttribute('href', '/api/icon.svg')
|
|
62
|
+
|
|
54
63
|
const events = new EventSource('/api/events')
|
|
55
64
|
events.addEventListener('message', (message) => {
|
|
56
65
|
void applyChange(JSON.parse(message.data) as ChangeEvent)
|
package/src/canvas/server.ts
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
tokenGroups,
|
|
35
35
|
} from '@/canvas/tokens'
|
|
36
36
|
import { buildDesignCss } from '@/design/css'
|
|
37
|
+
import { brandFavicon } from '@/design/brand-favicon'
|
|
37
38
|
import {
|
|
38
39
|
bindFirstFree,
|
|
39
40
|
PORT_ATTEMPTS,
|
|
@@ -713,6 +714,12 @@ export function startCanvas(
|
|
|
713
714
|
},
|
|
714
715
|
}),
|
|
715
716
|
),
|
|
717
|
+
'/api/icon.svg': guarded(
|
|
718
|
+
() =>
|
|
719
|
+
new Response(brandFavicon(), {
|
|
720
|
+
headers: { 'content-type': 'image/svg+xml' },
|
|
721
|
+
}),
|
|
722
|
+
),
|
|
716
723
|
'/api/events': guarded(() => changes.open()),
|
|
717
724
|
},
|
|
718
725
|
fetch: guarded((request) => {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import { FAVICON_COLORS, renderFavicon } from '@/design/favicon'
|
|
4
|
+
import { PROJECT_ROOT } from '@/roots/project'
|
|
5
|
+
|
|
6
|
+
const BRAND_MARK = 'assets/brand/mark.svg'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The brand icon, built from the mark and the favicon's own pair, the same two
|
|
10
|
+
* inputs `web/public/favicon.svg` is generated from. Every surface that shows
|
|
11
|
+
* the icon reads it here rather than keeping a copy that drifts from the mark.
|
|
12
|
+
* It sits apart from `favicon.ts` because the card build imports that module
|
|
13
|
+
* through an `@` alias pointed at `web/src`, so it must import nothing.
|
|
14
|
+
*/
|
|
15
|
+
export function brandFavicon(): string {
|
|
16
|
+
const mark = readFileSync(join(PROJECT_ROOT, BRAND_MARK), 'utf8')
|
|
17
|
+
return renderFavicon(mark, FAVICON_COLORS)
|
|
18
|
+
}
|
package/src/teach/nav.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
2
|
import { readdir, readFile, rm } from 'node:fs/promises'
|
|
3
3
|
import { join, posix, relative } from 'node:path'
|
|
4
4
|
import {
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
TEACH_STYLESHEET_COMPONENTS,
|
|
7
7
|
} from '@/design/components'
|
|
8
8
|
import { buildDesignCss } from '@/design/css'
|
|
9
|
-
import {
|
|
9
|
+
import { brandFavicon } from '@/design/brand-favicon'
|
|
10
|
+
import { faviconLink } from '@/design/favicon'
|
|
10
11
|
import { stripFrontmatter } from '@/markdown/frontmatter'
|
|
11
12
|
import { parseFrontmatter, readField } from '@/indexes/frontmatter'
|
|
12
|
-
import { PROJECT_ROOT } from '@/roots/project'
|
|
13
13
|
import { compileScript } from '@/teach/browser/compile'
|
|
14
14
|
import { dismiss } from '@/teach/browser/dismiss'
|
|
15
15
|
import { focusLine } from '@/teach/browser/focus-line'
|
|
@@ -39,8 +39,6 @@ import {
|
|
|
39
39
|
} from '@/teach/workspace'
|
|
40
40
|
import { writeIfChanged } from '@/teach/write-if-changed'
|
|
41
41
|
|
|
42
|
-
const BRAND_MARK = 'assets/brand/mark.svg'
|
|
43
|
-
|
|
44
42
|
/**
|
|
45
43
|
* The link `teach-workspace` once had a session write by hand into every page.
|
|
46
44
|
* A lesson keeps whatever sits outside its marked regions, so the old icon
|
|
@@ -68,14 +66,9 @@ function dropHandWrittenHead(html: string): string {
|
|
|
68
66
|
)
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
/**
|
|
72
|
-
* Built from the brand mark and the favicon's own pair, the same two inputs
|
|
73
|
-
* `web/public/favicon.svg` is generated from, so every teach page carries the
|
|
74
|
-
* icon the landing page does rather than a copy of its own.
|
|
75
|
-
*/
|
|
69
|
+
/** Every teach page carries the icon the landing page does rather than a copy of its own. */
|
|
76
70
|
function teachFavicon(): string {
|
|
77
|
-
|
|
78
|
-
return faviconLink(renderFavicon(mark, FAVICON_COLORS))
|
|
71
|
+
return faviconLink(brandFavicon())
|
|
79
72
|
}
|
|
80
73
|
|
|
81
74
|
/**
|