@lemoncat7/dsh-knowledge 2.2.9 → 2.2.13-next.12
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 +3 -3
- package/docs/architecture.md +6 -2
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +42 -0
- package/lib/api.js.map +1 -1
- package/lib/client.js +22 -22
- package/lib/client.js.map +2 -2
- package/lib/domain.d.ts +15 -0
- package/lib/domain.d.ts.map +1 -1
- package/lib/domain.js.map +1 -1
- package/lib/local-provider.d.ts +11 -2
- package/lib/local-provider.d.ts.map +1 -1
- package/lib/local-provider.js +71 -0
- package/lib/local-provider.js.map +1 -1
- package/lib/management-proxy.js +1 -1
- package/lib/management-proxy.js.map +1 -1
- package/lib/notes/domain.d.ts +10 -0
- package/lib/notes/domain.d.ts.map +1 -1
- package/lib/notes/domain.js.map +1 -1
- package/lib/notes/store.d.ts +15 -1
- package/lib/notes/store.d.ts.map +1 -1
- package/lib/notes/store.js +277 -28
- package/lib/notes/store.js.map +1 -1
- package/lib/provider.d.ts +10 -2
- package/lib/provider.d.ts.map +1 -1
- package/lib/remote-provider.d.ts +10 -2
- package/lib/remote-provider.d.ts.map +1 -1
- package/lib/remote-provider.js +27 -0
- package/lib/remote-provider.js.map +1 -1
- package/lib/theme-bridge.js +7 -7
- package/lib/theme-bridge.js.map +1 -1
- package/lib/tool-authorization.js +11 -16
- package/lib/tool-authorization.js.map +1 -1
- package/lib/web-note-editor-chrome.d.ts +17 -0
- package/lib/web-note-editor-chrome.d.ts.map +1 -0
- package/lib/web-note-editor-chrome.js +38 -0
- package/lib/web-note-editor-chrome.js.map +1 -0
- package/lib/web-note-editor-find.d.ts +17 -0
- package/lib/web-note-editor-find.d.ts.map +1 -0
- package/lib/web-note-editor-find.js +225 -0
- package/lib/web-note-editor-find.js.map +1 -0
- package/lib/web-note-editor-outline.d.ts +15 -0
- package/lib/web-note-editor-outline.d.ts.map +1 -0
- package/lib/web-note-editor-outline.js +169 -0
- package/lib/web-note-editor-outline.js.map +1 -0
- package/lib/web-note-editor-search.d.ts +30 -0
- package/lib/web-note-editor-search.d.ts.map +1 -0
- package/lib/web-note-editor-search.js +143 -0
- package/lib/web-note-editor-search.js.map +1 -0
- package/lib/web-note-editor-selection.d.ts +15 -0
- package/lib/web-note-editor-selection.d.ts.map +1 -0
- package/lib/web-note-editor-selection.js +255 -0
- package/lib/web-note-editor-selection.js.map +1 -0
- package/lib/web-note-editor.d.ts +7 -0
- package/lib/web-note-editor.d.ts.map +1 -1
- package/lib/web-note-editor.js +36 -6
- package/lib/web-note-editor.js.map +1 -1
- package/lib/web-note-history.d.ts +28 -0
- package/lib/web-note-history.d.ts.map +1 -0
- package/lib/web-note-history.js +163 -0
- package/lib/web-note-history.js.map +1 -0
- package/lib/web-workspace-effects.d.ts.map +1 -1
- package/lib/web-workspace-effects.js +1 -2
- package/lib/web-workspace-effects.js.map +1 -1
- package/lib/web.d.ts.map +1 -1
- package/lib/web.js +4 -0
- package/lib/web.js.map +1 -1
- package/package.json +1 -1
- package/web/api-client.js +94 -0
- package/web/app.js +344 -235
- package/web/host-theme.js +63 -0
- package/web/index.html +1 -0
- package/web/note-editor.js +70 -70
- package/web/note-history.js +1 -0
- package/web/styles.css +374 -154
- package/web/ui-primitives.js +77 -0
- package/web/workspace-effects.js +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const HOST_THEME_MESSAGE = '@lemoncat7/dsh-knowledge/host-theme'
|
|
2
|
+
const HOST_THEME_READY_MESSAGE = '@lemoncat7/dsh-knowledge/host-theme-ready'
|
|
3
|
+
const HOST_THEME_PROTOCOL_VERSION = 1
|
|
4
|
+
const COLOR_TOKENS = new Set([
|
|
5
|
+
'--bg', '--surface', '--surface-raised', '--surface-soft', '--surface-hover', '--dialog-surface',
|
|
6
|
+
'--text', '--text-secondary', '--text-tertiary', '--border', '--border-strong',
|
|
7
|
+
'--accent', '--accent-hover', '--accent-soft', '--on-accent',
|
|
8
|
+
'--success', '--success-soft', '--warning', '--warning-soft', '--danger', '--danger-soft',
|
|
9
|
+
])
|
|
10
|
+
const STYLE_TOKENS = new Set(['--shadow'])
|
|
11
|
+
|
|
12
|
+
function referrerOrigin() {
|
|
13
|
+
if (!document.referrer) return ''
|
|
14
|
+
try {
|
|
15
|
+
const origin = new URL(document.referrer).origin
|
|
16
|
+
return origin === 'null' ? '' : origin
|
|
17
|
+
} catch {
|
|
18
|
+
return ''
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Synchronise only the host colour scheme and the explicitly allowed tokens. */
|
|
23
|
+
export function installHostThemeBridge() {
|
|
24
|
+
if (window.parent === window) return Promise.resolve()
|
|
25
|
+
const parentOrigin = referrerOrigin()
|
|
26
|
+
return new Promise(resolve => {
|
|
27
|
+
let settled = false
|
|
28
|
+
const settle = () => {
|
|
29
|
+
if (settled) return
|
|
30
|
+
settled = true
|
|
31
|
+
window.clearTimeout(fallback)
|
|
32
|
+
resolve()
|
|
33
|
+
}
|
|
34
|
+
const fallback = window.setTimeout(settle, 160)
|
|
35
|
+
window.addEventListener('message', event => {
|
|
36
|
+
if (event.source !== window.parent || (parentOrigin && event.origin !== parentOrigin)) return
|
|
37
|
+
const message = event.data
|
|
38
|
+
if (!message || message.type !== HOST_THEME_MESSAGE || message.version !== HOST_THEME_PROTOCOL_VERSION) return
|
|
39
|
+
if (message.colorScheme !== 'light' && message.colorScheme !== 'dark') return
|
|
40
|
+
if (!message.tokens || typeof message.tokens !== 'object' || Array.isArray(message.tokens)) return
|
|
41
|
+
|
|
42
|
+
const root = document.documentElement
|
|
43
|
+
for (const name of [...COLOR_TOKENS, ...STYLE_TOKENS]) root.style.removeProperty(name)
|
|
44
|
+
for (const [name, value] of Object.entries(message.tokens)) {
|
|
45
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > 512) continue
|
|
46
|
+
if (COLOR_TOKENS.has(name) && CSS.supports('color', value)) root.style.setProperty(name, value)
|
|
47
|
+
else if (STYLE_TOKENS.has(name) && CSS.supports('box-shadow', value)) root.style.setProperty(name, value)
|
|
48
|
+
}
|
|
49
|
+
root.dataset.dshHostTheme = 'true'
|
|
50
|
+
root.dataset.colorScheme = message.colorScheme
|
|
51
|
+
root.style.colorScheme = message.colorScheme
|
|
52
|
+
document.querySelector('meta[name="color-scheme"]')?.setAttribute('content', message.colorScheme)
|
|
53
|
+
const background = root.style.getPropertyValue('--bg')
|
|
54
|
+
if (background) document.querySelector('meta[name="theme-color"]')?.setAttribute('content', background)
|
|
55
|
+
settle()
|
|
56
|
+
})
|
|
57
|
+
window.parent.postMessage({
|
|
58
|
+
type: HOST_THEME_READY_MESSAGE,
|
|
59
|
+
version: HOST_THEME_PROTOCOL_VERSION,
|
|
60
|
+
}, parentOrigin || '*')
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
package/web/index.html
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<link rel="stylesheet" href="__DSH_KNOWLEDGE_WEB_PATH__/styles.css?v=__DSH_KNOWLEDGE_ASSET_VERSION__">
|
|
14
14
|
<script src="__DSH_KNOWLEDGE_WEB_PATH__/markdown-preview.js?v=__DSH_KNOWLEDGE_ASSET_VERSION__"></script>
|
|
15
15
|
<script src="__DSH_KNOWLEDGE_WEB_PATH__/change-review.js?v=__DSH_KNOWLEDGE_ASSET_VERSION__"></script>
|
|
16
|
+
<script src="__DSH_KNOWLEDGE_WEB_PATH__/note-history.js?v=__DSH_KNOWLEDGE_ASSET_VERSION__"></script>
|
|
16
17
|
<script src="__DSH_KNOWLEDGE_WEB_PATH__/workspace-effects.js?v=__DSH_KNOWLEDGE_ASSET_VERSION__"></script>
|
|
17
18
|
<script type="module" src="__DSH_KNOWLEDGE_WEB_PATH__/app.js?v=__DSH_KNOWLEDGE_ASSET_VERSION__"></script>
|
|
18
19
|
</head>
|