@telepath-computer/television 1.5.9 → 1.6.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.
Files changed (130) hide show
  1. package/dist/THIRD-PARTY-NOTICES.txt +701 -0
  2. package/dist/cli.cjs +9035 -596
  3. package/dist/onboarding/tv-guide/welcome.html +14 -4
  4. package/dist/skills/television/SKILL.md +39 -33
  5. package/dist/skills/television/resources.md +4 -4
  6. package/dist/skills/television/templates.md +77 -0
  7. package/dist/skills/television/theming.md +31 -17
  8. package/dist/templates/calendar/README.md +17 -0
  9. package/dist/{skills/tv-tasks → templates/calendar}/THIRD-PARTY-NOTICES.txt +22 -22
  10. package/dist/templates/calendar/calendar-attendees.js +131 -0
  11. package/dist/templates/calendar/calendar-event.js +22 -0
  12. package/dist/templates/calendar/calendar-motion.js +273 -0
  13. package/dist/templates/calendar/calendar-page.js +403 -0
  14. package/dist/templates/calendar/calendar-time-axis.js +32 -0
  15. package/dist/templates/calendar/calendar-week.js +711 -0
  16. package/dist/templates/calendar/data.json +3 -0
  17. package/dist/templates/calendar/icon.svg +1 -0
  18. package/dist/templates/calendar/index.html +27 -0
  19. package/dist/templates/calendar/manifest.json +148 -0
  20. package/dist/templates/calendar/styles.css +771 -0
  21. package/dist/templates/checklist/README.md +45 -0
  22. package/dist/templates/checklist/THIRD-PARTY-NOTICES.txt +29 -0
  23. package/dist/templates/checklist/data.json +1 -0
  24. package/dist/templates/checklist/icon.svg +8 -0
  25. package/dist/templates/checklist/icons.css +61 -0
  26. package/dist/templates/checklist/index.html +47 -0
  27. package/dist/templates/checklist/manifest.json +49 -0
  28. package/dist/templates/checklist/model.d.ts +30 -0
  29. package/dist/templates/checklist/model.js +60 -0
  30. package/dist/templates/checklist/page.js +425 -0
  31. package/dist/templates/checklist/styles.css +206 -0
  32. package/dist/templates/document/README.md +55 -0
  33. package/dist/templates/document/THIRD-PARTY-NOTICES.txt +1080 -0
  34. package/dist/templates/document/data.json +3 -0
  35. package/dist/templates/document/editor.css +1 -0
  36. package/dist/templates/document/editor.js +37 -0
  37. package/dist/templates/document/icon.svg +6 -0
  38. package/dist/templates/document/index.html +29 -0
  39. package/dist/templates/document/manifest.json +22 -0
  40. package/dist/templates/document/page.js +190 -0
  41. package/dist/templates/document/styles.css +76 -0
  42. package/dist/templates/map/README.md +85 -0
  43. package/dist/templates/map/THIRD-PARTY-NOTICES.txt +84 -0
  44. package/dist/templates/map/data.json +1 -0
  45. package/dist/templates/map/icon.svg +8 -0
  46. package/dist/templates/map/icons.svg +43 -0
  47. package/dist/templates/map/index.html +95 -0
  48. package/dist/templates/map/manifest.json +227 -0
  49. package/dist/templates/map/map-model.js +18 -0
  50. package/dist/templates/map/map.css +202 -0
  51. package/dist/templates/map/map.js +728 -0
  52. package/dist/templates/map/vendor/LICENSE +26 -0
  53. package/dist/templates/map/vendor/README.md +11 -0
  54. package/dist/templates/map/vendor/leaflet.css +661 -0
  55. package/dist/templates/map/vendor/leaflet.js +6 -0
  56. package/dist/templates/map/vendor/lucide/LICENSE +43 -0
  57. package/dist/templates/map/vendor/lucide/README.md +46 -0
  58. package/dist/templates/map/vendor/lucide/icons.js +832 -0
  59. package/dist/templates/map/vendor/lucide/svg/airport.svg +15 -0
  60. package/dist/templates/map/vendor/lucide/svg/bar.svg +17 -0
  61. package/dist/templates/map/vendor/lucide/svg/beach.svg +17 -0
  62. package/dist/templates/map/vendor/lucide/svg/bridge.svg +20 -0
  63. package/dist/templates/map/vendor/lucide/svg/bus.svg +21 -0
  64. package/dist/templates/map/vendor/lucide/svg/church.svg +19 -0
  65. package/dist/templates/map/vendor/lucide/svg/coffee.svg +18 -0
  66. package/dist/templates/map/vendor/lucide/svg/ferry.svg +19 -0
  67. package/dist/templates/map/vendor/lucide/svg/flag.svg +15 -0
  68. package/dist/templates/map/vendor/lucide/svg/heart.svg +15 -0
  69. package/dist/templates/map/vendor/lucide/svg/home.svg +16 -0
  70. package/dist/templates/map/vendor/lucide/svg/hospital.svg +19 -0
  71. package/dist/templates/map/vendor/lucide/svg/hotel.svg +24 -0
  72. package/dist/templates/map/vendor/lucide/svg/info.svg +17 -0
  73. package/dist/templates/map/vendor/lucide/svg/landmark.svg +20 -0
  74. package/dist/templates/map/vendor/lucide/svg/mountain.svg +15 -0
  75. package/dist/templates/map/vendor/lucide/svg/museum.svg +20 -0
  76. package/dist/templates/map/vendor/lucide/svg/music.svg +17 -0
  77. package/dist/templates/map/vendor/lucide/svg/park.svg +18 -0
  78. package/dist/templates/map/vendor/lucide/svg/parking.svg +16 -0
  79. package/dist/templates/map/vendor/lucide/svg/pin.svg +16 -0
  80. package/dist/templates/map/vendor/lucide/svg/restaurant.svg +17 -0
  81. package/dist/templates/map/vendor/lucide/svg/school.svg +20 -0
  82. package/dist/templates/map/vendor/lucide/svg/shop.svg +17 -0
  83. package/dist/templates/map/vendor/lucide/svg/sports.svg +19 -0
  84. package/dist/templates/map/vendor/lucide/svg/star.svg +15 -0
  85. package/dist/templates/map/vendor/lucide/svg/theatre.svg +23 -0
  86. package/dist/templates/map/vendor/lucide/svg/train.svg +20 -0
  87. package/dist/templates/map/vendor/lucide/svg/viewpoint.svg +20 -0
  88. package/dist/templates/map/vendor/lucide/svg/work.svg +18 -0
  89. package/dist/templates/sticky-note/Caveat-Medium.woff2 +0 -0
  90. package/dist/templates/sticky-note/README.md +47 -0
  91. package/dist/templates/sticky-note/THIRD-PARTY-NOTICES.txt +127 -0
  92. package/dist/templates/sticky-note/data.json +1 -0
  93. package/dist/templates/sticky-note/icon.svg +16 -0
  94. package/dist/templates/sticky-note/icons.css +61 -0
  95. package/dist/templates/sticky-note/index.html +31 -0
  96. package/dist/templates/sticky-note/manifest.json +27 -0
  97. package/dist/templates/sticky-note/model.d.ts +33 -0
  98. package/dist/templates/sticky-note/model.js +152 -0
  99. package/dist/templates/sticky-note/page.js +84 -0
  100. package/dist/templates/sticky-note/styles.css +140 -0
  101. package/dist/templates/table/README.md +107 -0
  102. package/dist/templates/table/data.json +4 -0
  103. package/dist/templates/table/icon.svg +6 -0
  104. package/dist/templates/table/index.html +15 -0
  105. package/dist/templates/table/manifest.json +70 -0
  106. package/dist/templates/table/model.d.ts +164 -0
  107. package/dist/templates/table/model.js +395 -0
  108. package/dist/templates/table/page.js +1045 -0
  109. package/dist/templates/table/selection-model.d.ts +67 -0
  110. package/dist/templates/table/selection-model.js +163 -0
  111. package/dist/templates/table/styles.css +522 -0
  112. package/dist/views/markdown/THIRD-PARTY-NOTICES.txt +408 -0
  113. package/dist/views/markdown/index.html +21 -21
  114. package/dist/web/assets/main-CRSNodQt.js +864 -0
  115. package/dist/web/assets/main-DnvQkpg4.css +1 -0
  116. package/dist/web/index.html +2 -2
  117. package/package.json +1 -1
  118. package/dist/skills/tv-calendar/SKILL.md +0 -100
  119. package/dist/skills/tv-calendar/calendar.css +0 -1
  120. package/dist/skills/tv-calendar/calendar.js +0 -400
  121. package/dist/skills/tv-table/SKILL.md +0 -95
  122. package/dist/skills/tv-tasks/SKILL.md +0 -269
  123. package/dist/skills/tv-tasks/task.css +0 -180
  124. package/dist/skills/tv-tasks/task.js +0 -304
  125. package/dist/web/assets/calendar-DToAnkzj.png +0 -0
  126. package/dist/web/assets/main-CPopSWec.js +0 -848
  127. package/dist/web/assets/main-CunC2_Nx.css +0 -1
  128. package/dist/web/assets/markdown-DdDrJuVK.png +0 -0
  129. package/dist/web/assets/table-oeG9uAN1.png +0 -0
  130. package/dist/web/assets/tasks-D4xqXFPl.png +0 -0
@@ -0,0 +1,127 @@
1
+ TELEVISION THIRD-PARTY LICENSING NOTICES
2
+
3
+ This file contains the license terms and attribution notices for third-party software and materials included in Television.
4
+ ================================================================================
5
+ @phosphor-icons/core@2.1.1
6
+ Licensed under MIT.
7
+ --------------------------------------------------------------------------------
8
+ MIT License
9
+
10
+ Copyright (c) 2023 Phosphor Icons
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ ================================================================================
31
+ Caveat Medium font
32
+ Licensed under OFL-1.1.
33
+ --------------------------------------------------------------------------------
34
+ Copyright 2014 The Caveat Project Authors (https://github.com/googlefonts/caveat)
35
+
36
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
37
+ This license is copied below, and is also available with a FAQ at:
38
+ http://scripts.sil.org/OFL
39
+
40
+
41
+ -----------------------------------------------------------
42
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
43
+ -----------------------------------------------------------
44
+
45
+ PREAMBLE
46
+ The goals of the Open Font License (OFL) are to stimulate worldwide
47
+ development of collaborative font projects, to support the font creation
48
+ efforts of academic and linguistic communities, and to provide a free and
49
+ open framework in which fonts may be shared and improved in partnership
50
+ with others.
51
+
52
+ The OFL allows the licensed fonts to be used, studied, modified and
53
+ redistributed freely as long as they are not sold by themselves. The
54
+ fonts, including any derivative works, can be bundled, embedded,
55
+ redistributed and/or sold with any software provided that any reserved
56
+ names are not used by derivative works. The fonts and derivatives,
57
+ however, cannot be released under any other type of license. The
58
+ requirement for fonts to remain under this license does not apply
59
+ to any document created using the fonts or their derivatives.
60
+
61
+ DEFINITIONS
62
+ "Font Software" refers to the set of files released by the Copyright
63
+ Holder(s) under this license and clearly marked as such. This may
64
+ include source files, build scripts and documentation.
65
+
66
+ "Reserved Font Name" refers to any names specified as such after the
67
+ copyright statement(s).
68
+
69
+ "Original Version" refers to the collection of Font Software components as
70
+ distributed by the Copyright Holder(s).
71
+
72
+ "Modified Version" refers to any derivative made by adding to, deleting,
73
+ or substituting -- in part or in whole -- any of the components of the
74
+ Original Version, by changing formats or by porting the Font Software to a
75
+ new environment.
76
+
77
+ "Author" refers to any designer, engineer, programmer, technical
78
+ writer or other person who contributed to the Font Software.
79
+
80
+ PERMISSION & CONDITIONS
81
+ Permission is hereby granted, free of charge, to any person obtaining
82
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
83
+ redistribute, and sell modified and unmodified copies of the Font
84
+ Software, subject to the following conditions:
85
+
86
+ 1) Neither the Font Software nor any of its individual components,
87
+ in Original or Modified Versions, may be sold by itself.
88
+
89
+ 2) Original or Modified Versions of the Font Software may be bundled,
90
+ redistributed and/or sold with any software, provided that each copy
91
+ contains the above copyright notice and this license. These can be
92
+ included either as stand-alone text files, human-readable headers or
93
+ in the appropriate machine-readable metadata fields within text or
94
+ binary files as long as those fields can be easily viewed by the user.
95
+
96
+ 3) No Modified Version of the Font Software may use the Reserved Font
97
+ Name(s) unless explicit written permission is granted by the corresponding
98
+ Copyright Holder. This restriction only applies to the primary font name as
99
+ presented to the users.
100
+
101
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
102
+ Software shall not be used to promote, endorse or advertise any
103
+ Modified Version, except to acknowledge the contribution(s) of the
104
+ Copyright Holder(s) and the Author(s) or with their explicit written
105
+ permission.
106
+
107
+ 5) The Font Software, modified or unmodified, in part or in whole,
108
+ must be distributed entirely under this license, and must not be
109
+ distributed under any other license. The requirement for fonts to
110
+ remain under this license does not apply to any document created
111
+ using the Font Software.
112
+
113
+ TERMINATION
114
+ This license becomes null and void if any of the above conditions are
115
+ not met.
116
+
117
+ DISCLAIMER
118
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
119
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
120
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
121
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
122
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
123
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
124
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
125
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
126
+ OTHER DEALINGS IN THE FONT SOFTWARE.
127
+
@@ -0,0 +1 @@
1
+ {"text":""}
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" width="20" height="20">
2
+ <defs>
3
+ <linearGradient id="paper" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FFF19A"/><stop offset="1" stop-color="#FFD749"/></linearGradient>
4
+ <linearGradient id="flap" x1="1" y1="1" x2="0" y2="0"><stop offset="0" stop-color="#FFF8D6"/><stop offset="1" stop-color="#F3CF4E"/></linearGradient>
5
+ <linearGradient id="shine" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".55"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
6
+ <filter id="drop" x="-20%" y="-20%" width="140%" height="150%"><feDropShadow dx="0" dy="1.2" stdDeviation="1.2" flood-color="#5a4300" flood-opacity=".28"/></filter>
7
+ <filter id="soft" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation=".9"/></filter>
8
+ </defs>
9
+ <g filter="url(#drop)">
10
+ <path d="M9 5h22a4 4 0 0 1 4 4v16.5L25.5 35H9a4 4 0 0 1-4-4V9a4 4 0 0 1 4-4z" fill="url(#paper)"/>
11
+ <path d="M9 5h22a4 4 0 0 1 4 4v3H5V9a4 4 0 0 1 4-4z" fill="url(#shine)"/>
12
+ <path d="M35 25.5c-3.2.5-6.4 1.1-7.4 2.1s-1.6 4.2-2.1 7.4" fill="none" stroke="#7a5a00" stroke-opacity=".35" stroke-width="2" filter="url(#soft)"/>
13
+ <path d="M35 25.5c-3.2.5-6.4 1.1-7.4 2.1s-1.6 4.2-2.1 7.4z" fill="url(#flap)"/>
14
+ </g>
15
+ <path d="M11 16.8c2.6-.9 4.6.6 7.2-.1s4.4-.5 7.6.3M11 22.6c2.4-.8 4.2.5 6.6-.1s2.8-.2 4.4.2" fill="none" stroke="#7C5B0C" stroke-opacity=".9" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"/>
16
+ </svg>
@@ -0,0 +1,61 @@
1
+ /* The icon sizes itself from the text it sits in rather than from a fixed
2
+ pixel size: an icon beside a label should match that label, and an icon in
3
+ a larger control should grow with it, without either one restating a size.
4
+
5
+ Each rule names both scopes this sheet serves — `:host` inside the
6
+ element's shadow root, and `tv-icon:not(:defined)` at document scope,
7
+ where canonical reserves the box before the definition loads so upgrade
8
+ adds a glyph without moving the text around it. In either scope one
9
+ selector of the pair matches nothing, and the box has one authority. */
10
+ :host,
11
+ tv-icon:not(:defined) {
12
+ display: inline-flex;
13
+ flex: none;
14
+ width: 1em;
15
+ height: 1em;
16
+ /* Glyphs are drawn on a square canvas whose visual weight sits below the
17
+ cap height of the text beside them; nudging down aligns their centre with
18
+ the text's rather than with its baseline box. */
19
+ vertical-align: -0.125em;
20
+ }
21
+
22
+ /* An icon that stands alone has no text to take its size from, so `size` names
23
+ one. It sets nothing but the font-size the rule above already reads, so
24
+ there is still one sizing rule — the attribute only changes what its `em`
25
+ resolves against.
26
+
27
+ Whole even pixels rather than a ratio: these are drawings, and a glyph on a
28
+ half-pixel grid blurs in a way a letterform does not. The names match the
29
+ type scale's, though the values deliberately do not — an icon standing on
30
+ its own is larger than the text it would otherwise have sat beside. */
31
+ :host([size="sm"]), tv-icon:not(:defined)[size="sm"] { font-size: 16px; }
32
+ :host([size="md"]), tv-icon:not(:defined)[size="md"] { font-size: 20px; }
33
+ :host([size="lg"]), tv-icon:not(:defined)[size="lg"] { font-size: 24px; }
34
+ :host([size="xl"]), tv-icon:not(:defined)[size="xl"] { font-size: 32px; }
35
+
36
+ /* Phosphor's SVGs already carry fill="currentColor", so colour follows the
37
+ surrounding text with nothing set here. The size does need saying: the
38
+ source has a viewBox and no width or height, so it would otherwise fall
39
+ back to the SVG default rather than filling the element. */
40
+ svg {
41
+ width: 100%;
42
+ height: 100%;
43
+ }
44
+
45
+ /* A spinning icon turns continuously — activity, not decoration. The turn
46
+ is even (linear): any easing reads as the glyph sticking once a second. */
47
+ :host([spinning]) > svg {
48
+ animation: tv-icon-spin 1s linear infinite;
49
+ }
50
+
51
+ @keyframes tv-icon-spin {
52
+ to {
53
+ rotate: 1turn;
54
+ }
55
+ }
56
+
57
+ @media (prefers-reduced-motion: reduce) {
58
+ :host([spinning]) > svg {
59
+ animation: none;
60
+ }
61
+ }
@@ -0,0 +1,31 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Sticky note</title>
7
+ <link rel="stylesheet" href="/canonical/v2/styles.css?authoredForAppVersion=1.5.4">
8
+ <link rel="stylesheet" href="./styles.css">
9
+ </head>
10
+ <body>
11
+ <main class="sticky-note-page">
12
+ <section class="sticky-note">
13
+ <p class="sticky-note-status" role="status"></p>
14
+ </section>
15
+ </main>
16
+ <template id="sticky-note-content">
17
+ <textarea class="sticky-note-text" aria-label="Note" spellcheck="false"></textarea>
18
+ </template>
19
+ <!-- Phosphor Icons, MIT. See THIRD-PARTY-NOTICES.txt for the upstream terms. -->
20
+ <template id="sticky-note-unreadable">
21
+ <div class="sticky-note-unreadable" role="alert">
22
+ <span class="sticky-note-unreadable-icon"><tv-icon name="warning" size="xl"><template shadowrootmode="open" shadowrootserializable="" shadowrootclonable=""><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"></path></svg></template>
23
+
24
+ </tv-icon></span>
25
+ <h1 class="sticky-note-unreadable-title">This note can't be shown</h1>
26
+ <p class="sticky-note-unreadable-text">Its saved data isn't in the form this page reads. Ask your agent to check it.</p>
27
+ </div>
28
+ </template>
29
+ <script type="module" src="./page.js"></script>
30
+ </body>
31
+ </html>
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "Sticky note",
3
+ "description": "A yellow note to type into; an agent can write on it too.",
4
+ "version": "1.0.0",
5
+ "display": {
6
+ "width": 360,
7
+ "height": 360,
8
+ "transparent": true
9
+ },
10
+ "icons": [
11
+ {
12
+ "src": "icon.svg",
13
+ "type": "image/svg+xml"
14
+ }
15
+ ],
16
+ "dataSchema": {
17
+ "type": "object",
18
+ "required": [
19
+ "text"
20
+ ],
21
+ "properties": {
22
+ "text": {
23
+ "type": "string"
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,33 @@
1
+ export interface StickyNoteData {
2
+ text: string;
3
+ [field: string]: unknown;
4
+ }
5
+
6
+ export interface StickyNoteView {
7
+ mode: "loading" | "note" | "unreadable";
8
+ text: string;
9
+ editable: boolean;
10
+ status: string;
11
+ }
12
+
13
+ export interface StickyNoteModel {
14
+ readonly view: StickyNoteView;
15
+ input(text: string): void;
16
+ blur(): void;
17
+ receive(value: unknown): void;
18
+ unavailable(): void;
19
+ accessChanged(access: "read" | "read-write" | null): void;
20
+ connectionChanged(status: "idle" | "connecting" | "connected" | "disconnected"): void;
21
+ dispose(): void;
22
+ }
23
+
24
+ /** Validates the complete root without changing it. */
25
+ export function isStickyNoteData(value: unknown): value is StickyNoteData;
26
+
27
+ /** Keeps local typing until confirmed while the SDK owns stored and optimistic values. */
28
+ export function createStickyNoteModel(dependencies: {
29
+ readAccess(): Promise<"read" | "read-write">;
30
+ readRoot(): Promise<unknown>;
31
+ writeText(text: string): Promise<void>;
32
+ changed(view: StickyNoteView): void;
33
+ }): StickyNoteModel;
@@ -0,0 +1,152 @@
1
+ // The SDK owns stored values, optimistic writes and rollback. A separate draft
2
+ // keeps the latest typing until its particular save has been confirmed.
3
+
4
+ /** Validates the complete root without changing it. */
5
+ export function isStickyNoteData(value) {
6
+ return value !== null && typeof value === "object" && !Array.isArray(value)
7
+ && typeof value.text === "string";
8
+ }
9
+
10
+ /** Coordinates text replacement, the input delay and reconnect checks. */
11
+ export function createStickyNoteModel({ readAccess, readRoot, writeText, changed }) {
12
+ let value;
13
+ let received = false;
14
+ let unreadable = false;
15
+ let access = null;
16
+ let connection = "idle";
17
+ let checked = false;
18
+ let generation = 0;
19
+ let draft = null;
20
+ let inputTimer;
21
+ let failureTimer;
22
+ let failure = false;
23
+ let disposed = false;
24
+ let previousView;
25
+
26
+ function view() {
27
+ const valid = received && !unreadable && isStickyNoteData(value);
28
+ const retain = draft && (!draft.sent || connection !== "connected" || !checked);
29
+ return {
30
+ mode: valid ? "note" : received || unreadable ? "unreadable" : "loading",
31
+ text: valid ? retain ? draft.text : value.text : "",
32
+ editable: valid && access === "read-write",
33
+ status: connection === "disconnected" ? "Reconnecting…" : failure ? "Couldn't save that change." : "",
34
+ };
35
+ }
36
+
37
+ function render() {
38
+ if (disposed) return;
39
+ const next = view();
40
+ if (previousView && Object.keys(next).every(key => next[key] === previousView[key])) return;
41
+ previousView = next;
42
+ changed(next);
43
+ }
44
+
45
+ function discard() {
46
+ clearTimeout(inputTimer);
47
+ draft = null;
48
+ }
49
+
50
+ function receive(next) {
51
+ value = next;
52
+ received = true;
53
+ unreadable = false;
54
+ if (!isStickyNoteData(value)) discard();
55
+ render();
56
+ }
57
+
58
+ function unavailable() {
59
+ unreadable = true;
60
+ discard();
61
+ render();
62
+ }
63
+
64
+ function accessChanged(next) {
65
+ access = next;
66
+ if (access !== "read-write") discard();
67
+ render();
68
+ }
69
+
70
+ function save() {
71
+ if (disposed || !draft || draft.sent || !draft.due || !checked
72
+ || connection !== "connected" || !view().editable) return;
73
+ const saving = draft;
74
+ saving.sent = true;
75
+ // Mark the draft before set publishes its optimistic value. That value,
76
+ // and subsequent SDK values, can then replace the field until more input.
77
+ writeText(saving.text).then(() => {
78
+ if (disposed) return;
79
+ if (draft === saving) draft = null;
80
+ render();
81
+ }, error => {
82
+ if (disposed) return;
83
+ if (error.code === "disconnected") {
84
+ if (draft === saving) saving.sent = false;
85
+ } else {
86
+ discard();
87
+ failure = true;
88
+ clearTimeout(failureTimer);
89
+ failureTimer = setTimeout(() => { failure = false; render(); }, 4000);
90
+ }
91
+ render();
92
+ });
93
+ }
94
+
95
+ async function refresh(currentGeneration) {
96
+ try {
97
+ const level = await readAccess();
98
+ if (disposed || generation !== currentGeneration) return;
99
+ accessChanged(level);
100
+ const current = await readRoot();
101
+ if (disposed || generation !== currentGeneration) return;
102
+ receive(current);
103
+ checked = true;
104
+ save();
105
+ render();
106
+ } catch (error) {
107
+ if (disposed || generation !== currentGeneration) return;
108
+ if (error.code === "no-store") accessChanged(null);
109
+ else if (error.code !== "disconnected") {
110
+ checked = true;
111
+ unavailable();
112
+ }
113
+ }
114
+ }
115
+
116
+ return {
117
+ get view() { return view(); },
118
+ receive,
119
+ unavailable,
120
+ accessChanged,
121
+ input(text) {
122
+ if (!view().editable) return;
123
+ draft = { text, due: false, sent: false };
124
+ clearTimeout(inputTimer);
125
+ inputTimer = setTimeout(() => {
126
+ if (draft) { draft.due = true; save(); }
127
+ }, 400);
128
+ render();
129
+ },
130
+ blur() {
131
+ if (!draft || draft.sent) return;
132
+ clearTimeout(inputTimer);
133
+ draft.due = true;
134
+ save();
135
+ },
136
+ connectionChanged(next) {
137
+ if (connection === next) return;
138
+ connection = next;
139
+ checked = false;
140
+ generation++;
141
+ if (next === "disconnected" && draft) draft.sent = false;
142
+ render();
143
+ if (next === "connected") void refresh(generation);
144
+ },
145
+ dispose() {
146
+ disposed = true;
147
+ generation++;
148
+ clearTimeout(inputTimer);
149
+ clearTimeout(failureTimer);
150
+ },
151
+ };
152
+ }
@@ -0,0 +1,84 @@
1
+ // A native textarea supplies editing, selection, scrolling and undo. The model
2
+ // decides which SDK value or retained draft it should display.
3
+ import {
4
+ getStore, ref, onValue, get, set, getAccess, onAccessChanged,
5
+ getConnectionStatus, onConnectionStatusChanged,
6
+ } from "/sdk/v1/resources.js";
7
+ import { createStickyNoteModel } from "./model.js";
8
+
9
+ const paper = document.querySelector(".sticky-note");
10
+ const status = paper.querySelector(".sticky-note-status");
11
+ const root = ref(getStore());
12
+ const text = ref(getStore(), "text");
13
+ const iconStyles = new CSSStyleSheet();
14
+ iconStyles.replaceSync(await (await fetch("./icons.css")).text());
15
+ let field;
16
+ let unsubscribe;
17
+
18
+ const model = createStickyNoteModel({
19
+ readAccess: getAccess,
20
+ readRoot: async () => (await get(root)).val(),
21
+ writeText: value => set(text, value),
22
+ changed: render,
23
+ });
24
+
25
+ function clone(name) {
26
+ const fragment = document.importNode(document.querySelector(`#sticky-note-${name}`).content, true);
27
+ for (const icon of fragment.querySelectorAll("tv-icon")) {
28
+ const template = icon.querySelector("template");
29
+ const shadow = icon.shadowRoot ?? icon.attachShadow({ mode: "open", clonable: true });
30
+ if (template) {
31
+ shadow.append(template.content);
32
+ template.remove();
33
+ }
34
+ shadow.adoptedStyleSheets = [iconStyles];
35
+ }
36
+ return fragment;
37
+ }
38
+
39
+ function render(view) {
40
+ if (view.mode === "note") {
41
+ paper.querySelector(".sticky-note-unreadable")?.remove();
42
+ if (!field) {
43
+ paper.prepend(clone("content"));
44
+ field = paper.querySelector(".sticky-note-text");
45
+ field.addEventListener("input", () => model.input(field.value));
46
+ field.addEventListener("blur", () => model.blur());
47
+ }
48
+ if (field.readOnly === view.editable) field.readOnly = !view.editable;
49
+ // Resetting even the same placeholder splits Chromium's native undo group.
50
+ if (view.editable && !field.hasAttribute("placeholder")) field.setAttribute("placeholder", "Click here and start typing.");
51
+ else if (!view.editable && field.hasAttribute("placeholder")) field.removeAttribute("placeholder");
52
+ // Assigning even an unchanged textarea value can reset native selection,
53
+ // scrolling and undo. Leave the browser's own edit untouched when it agrees.
54
+ if (field.value !== view.text) field.value = view.text;
55
+ } else {
56
+ field?.remove();
57
+ field = null;
58
+ if (view.mode === "unreadable") {
59
+ if (!paper.querySelector(".sticky-note-unreadable")) paper.prepend(clone("unreadable"));
60
+ } else paper.querySelector(".sticky-note-unreadable")?.remove();
61
+ }
62
+ // The empty status region is already present in the document before the SDK
63
+ // connects, so each message is an update to an established live region.
64
+ if (status.textContent !== view.status) status.textContent = view.status;
65
+ }
66
+
67
+ function subscribe() {
68
+ if (unsubscribe) return;
69
+ unsubscribe = onValue(root, snapshot => model.receive(snapshot.val()), error => {
70
+ unsubscribe = null;
71
+ if (error.code === "unavailable") model.unavailable();
72
+ });
73
+ }
74
+
75
+ onAccessChanged(level => {
76
+ model.accessChanged(level);
77
+ if (level !== null) subscribe();
78
+ });
79
+ onConnectionStatusChanged(connection => {
80
+ if (connection === "connected") subscribe();
81
+ model.connectionChanged(connection);
82
+ });
83
+ subscribe();
84
+ model.connectionChanged(getConnectionStatus());
@@ -0,0 +1,140 @@
1
+ /* Yellow paper and dark ink, surrounded by the transparent document. */
2
+ html,
3
+ body {
4
+ height: 100%;
5
+ margin: 0;
6
+ background: transparent;
7
+ }
8
+
9
+ .sticky-note-page {
10
+ box-sizing: border-box;
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ height: 100vh;
15
+ padding: 24px;
16
+ }
17
+
18
+ .sticky-note {
19
+ position: relative;
20
+ box-sizing: border-box;
21
+ width: min(100%, 520px);
22
+ aspect-ratio: 1 / 1;
23
+ max-height: 100%;
24
+ border-radius: 2px 2px 18px 2px;
25
+ background: linear-gradient(#fff59a, #ffeb6b);
26
+ color: #3b3412;
27
+ color-scheme: light;
28
+ box-shadow: 0 1px 2px rgb(0 0 0 / 12%), 0 10px 24px rgb(0 0 0 / 14%);
29
+ transform: rotate(-1.2deg);
30
+ }
31
+
32
+ .sticky-note::before {
33
+ content: "";
34
+ position: absolute;
35
+ z-index: 2;
36
+ pointer-events: none;
37
+ top: -12px;
38
+ left: 50%;
39
+ width: 120px;
40
+ height: 26px;
41
+ transform: translateX(-50%) rotate(2deg);
42
+ background: rgb(255 255 255 / 55%);
43
+ box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
44
+ }
45
+
46
+ .sticky-note-text {
47
+ position: absolute;
48
+ inset: 0;
49
+ box-sizing: border-box;
50
+ width: 100%;
51
+ height: 100%;
52
+ padding: 40px 32px 28px;
53
+ resize: none;
54
+ border: none;
55
+ border-radius: inherit;
56
+ outline: none;
57
+ background: transparent;
58
+ font: 500 24px/1.35 "Sticky Note Caveat", cursive;
59
+ color: #3b3412;
60
+ overflow-wrap: anywhere;
61
+ overflow-y: auto;
62
+ mask-image: linear-gradient(to bottom, transparent, black 28px, black calc(100% - 28px), transparent);
63
+ }
64
+
65
+ .sticky-note-text::placeholder {
66
+ color: rgb(59 52 18 / 60%);
67
+ opacity: 1;
68
+ }
69
+
70
+ /* Failure messages sit on the paper, above its rounded bottom edge. */
71
+ .sticky-note-status {
72
+ position: absolute;
73
+ inset: auto 0 0;
74
+ z-index: 1;
75
+ margin: 0;
76
+ padding: 8px 16px;
77
+ border-top: 1px solid rgb(59 52 18 / 20%);
78
+ border-radius: 0 0 18px 2px;
79
+ background: #ffeb6b;
80
+ font: 14px/1.3 var(--font-sans, sans-serif);
81
+ color: rgb(59 52 18 / 75%);
82
+ text-align: center;
83
+ }
84
+
85
+ .sticky-note-status:empty {
86
+ padding: 0;
87
+ border: 0;
88
+ }
89
+
90
+ .sticky-note:has(.sticky-note-status:not(:empty)) .sticky-note-text {
91
+ padding-bottom: 64px;
92
+ mask-image: linear-gradient(to bottom, transparent, black 28px, black calc(100% - 64px), transparent calc(100% - 36px));
93
+ }
94
+
95
+ .sticky-note-unreadable {
96
+ position: absolute;
97
+ inset: 0;
98
+ height: 100%;
99
+ padding: 40px 32px 28px;
100
+ display: flex;
101
+ flex-direction: column;
102
+ align-items: center;
103
+ justify-content: center;
104
+ gap: 8px;
105
+ font-family: var(--font-sans, sans-serif);
106
+ color: rgb(59 52 18 / 75%);
107
+ text-align: center;
108
+ }
109
+
110
+ .sticky-note:has(.sticky-note-status:not(:empty)) .sticky-note-unreadable {
111
+ padding-bottom: 64px;
112
+ }
113
+
114
+ .sticky-note-unreadable-icon {
115
+ display: grid;
116
+ flex-shrink: 0;
117
+ margin-bottom: 4px;
118
+ }
119
+
120
+ .sticky-note-unreadable-title {
121
+ margin: 0;
122
+ font-size: 16px;
123
+ font-weight: 600;
124
+ line-height: 1.25;
125
+ }
126
+
127
+ .sticky-note-unreadable-text {
128
+ margin: 0;
129
+ font-size: 14px;
130
+ line-height: 1.3;
131
+ }
132
+ /* Caveat, Copyright 2014 The Caveat Project Authors.
133
+ https://github.com/googlefonts/caveat — SIL OFL 1.1; see THIRD-PARTY-NOTICES.txt. */
134
+ @font-face {
135
+ font-family: "Sticky Note Caveat";
136
+ src: url("./Caveat-Medium.woff2") format("woff2");
137
+ font-style: normal;
138
+ font-weight: 500;
139
+ font-display: block;
140
+ }