@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.
Files changed (77) hide show
  1. package/README.md +3 -3
  2. package/docs/architecture.md +6 -2
  3. package/lib/api.d.ts.map +1 -1
  4. package/lib/api.js +42 -0
  5. package/lib/api.js.map +1 -1
  6. package/lib/client.js +22 -22
  7. package/lib/client.js.map +2 -2
  8. package/lib/domain.d.ts +15 -0
  9. package/lib/domain.d.ts.map +1 -1
  10. package/lib/domain.js.map +1 -1
  11. package/lib/local-provider.d.ts +11 -2
  12. package/lib/local-provider.d.ts.map +1 -1
  13. package/lib/local-provider.js +71 -0
  14. package/lib/local-provider.js.map +1 -1
  15. package/lib/management-proxy.js +1 -1
  16. package/lib/management-proxy.js.map +1 -1
  17. package/lib/notes/domain.d.ts +10 -0
  18. package/lib/notes/domain.d.ts.map +1 -1
  19. package/lib/notes/domain.js.map +1 -1
  20. package/lib/notes/store.d.ts +15 -1
  21. package/lib/notes/store.d.ts.map +1 -1
  22. package/lib/notes/store.js +277 -28
  23. package/lib/notes/store.js.map +1 -1
  24. package/lib/provider.d.ts +10 -2
  25. package/lib/provider.d.ts.map +1 -1
  26. package/lib/remote-provider.d.ts +10 -2
  27. package/lib/remote-provider.d.ts.map +1 -1
  28. package/lib/remote-provider.js +27 -0
  29. package/lib/remote-provider.js.map +1 -1
  30. package/lib/theme-bridge.js +7 -7
  31. package/lib/theme-bridge.js.map +1 -1
  32. package/lib/tool-authorization.js +11 -16
  33. package/lib/tool-authorization.js.map +1 -1
  34. package/lib/web-note-editor-chrome.d.ts +17 -0
  35. package/lib/web-note-editor-chrome.d.ts.map +1 -0
  36. package/lib/web-note-editor-chrome.js +38 -0
  37. package/lib/web-note-editor-chrome.js.map +1 -0
  38. package/lib/web-note-editor-find.d.ts +17 -0
  39. package/lib/web-note-editor-find.d.ts.map +1 -0
  40. package/lib/web-note-editor-find.js +225 -0
  41. package/lib/web-note-editor-find.js.map +1 -0
  42. package/lib/web-note-editor-outline.d.ts +15 -0
  43. package/lib/web-note-editor-outline.d.ts.map +1 -0
  44. package/lib/web-note-editor-outline.js +169 -0
  45. package/lib/web-note-editor-outline.js.map +1 -0
  46. package/lib/web-note-editor-search.d.ts +30 -0
  47. package/lib/web-note-editor-search.d.ts.map +1 -0
  48. package/lib/web-note-editor-search.js +143 -0
  49. package/lib/web-note-editor-search.js.map +1 -0
  50. package/lib/web-note-editor-selection.d.ts +15 -0
  51. package/lib/web-note-editor-selection.d.ts.map +1 -0
  52. package/lib/web-note-editor-selection.js +255 -0
  53. package/lib/web-note-editor-selection.js.map +1 -0
  54. package/lib/web-note-editor.d.ts +7 -0
  55. package/lib/web-note-editor.d.ts.map +1 -1
  56. package/lib/web-note-editor.js +36 -6
  57. package/lib/web-note-editor.js.map +1 -1
  58. package/lib/web-note-history.d.ts +28 -0
  59. package/lib/web-note-history.d.ts.map +1 -0
  60. package/lib/web-note-history.js +163 -0
  61. package/lib/web-note-history.js.map +1 -0
  62. package/lib/web-workspace-effects.d.ts.map +1 -1
  63. package/lib/web-workspace-effects.js +1 -2
  64. package/lib/web-workspace-effects.js.map +1 -1
  65. package/lib/web.d.ts.map +1 -1
  66. package/lib/web.js +4 -0
  67. package/lib/web.js.map +1 -1
  68. package/package.json +1 -1
  69. package/web/api-client.js +94 -0
  70. package/web/app.js +344 -235
  71. package/web/host-theme.js +63 -0
  72. package/web/index.html +1 -0
  73. package/web/note-editor.js +70 -70
  74. package/web/note-history.js +1 -0
  75. package/web/styles.css +374 -154
  76. package/web/ui-primitives.js +77 -0
  77. 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>