@stacksjs/components 0.2.975 → 0.2.979
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/dist/SettingsUpdateRow-1gsqj04f.stx +138 -0
- package/dist/{SettingsWindow-q0x86xqb.stx → SettingsWindow-z76981eg.stx} +42 -1
- package/dist/index.js +8 -8
- package/dist/ui/settings/SettingsUpdateRow.d.ts +3 -18
- package/package.json +3 -3
- package/src/ui/settings/SettingsUpdateRow.stx +81 -18
- package/src/ui/settings/SettingsWindow.stx +42 -1
- package/dist/SettingsUpdateRow-92mmxvpd.stx +0 -75
|
@@ -2,24 +2,9 @@ import type { DefineComponent } from '@stacksjs/stx';
|
|
|
2
2
|
declare const __dtsx_component__: __DtsxStxComponentType;
|
|
3
3
|
/*
|
|
4
4
|
* <SettingsUpdateRow>: the row every app that updates itself needs. The app
|
|
5
|
-
* and its version, a sentence about where the update stands,
|
|
6
|
-
* button that moves it on: Check Now,
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* <SettingsGroup header="Software Update">
|
|
10
|
-
* <SettingsUpdateRow appName="Library" :status="status()"
|
|
11
|
-
* @check="craft.updater.check()" @install="craft.updater.install()"
|
|
12
|
-
* @relaunch="craft.updater.relaunch()" />
|
|
13
|
-
* </SettingsGroup>
|
|
14
|
-
*
|
|
15
|
-
* `status` is what the updater reports (`craft.updater`'s `UpdateStatus`, or
|
|
16
|
-
* a web app's own of the same shape). The row does nothing on its own: it
|
|
17
|
-
* says what the status says and emits `check`, `install` or `relaunch`. What
|
|
18
|
-
* it says for each state is `settingsUpdateView` in ./update.
|
|
19
|
-
*
|
|
20
|
-
* It is a <SettingsRow> holding <Button appearance="mac">, so it is the same
|
|
21
|
-
* row on the web and on a native host, and the window's search finds it
|
|
22
|
-
* (`setting`, default `software-update`).
|
|
5
|
+
* and its version, a sentence about where the update stands, download progress,
|
|
6
|
+
* optional release notes, and the one button that moves it on: Check Now,
|
|
7
|
+
* Download and Install, or Restart to Update.
|
|
23
8
|
*/
|
|
24
9
|
export declare const appName: unknown;
|
|
25
10
|
export declare const status: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.979",
|
|
5
5
|
"description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -144,8 +144,8 @@
|
|
|
144
144
|
"dependencies": {
|
|
145
145
|
"@iconify-json/f7": "^1.2.2",
|
|
146
146
|
"@stacksjs/ts-css": "^0.3.11",
|
|
147
|
-
"@stacksjs/stx": "0.2.
|
|
148
|
-
"bun-plugin-stx": "0.2.
|
|
147
|
+
"@stacksjs/stx": "0.2.979",
|
|
148
|
+
"bun-plugin-stx": "0.2.979",
|
|
149
149
|
"ts-syntax-highlighter": "^0.2.20",
|
|
150
150
|
"ts-video-player": "^0.1.11"
|
|
151
151
|
},
|
|
@@ -4,24 +4,9 @@ import { settingsUpdateView } from './update'
|
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* <SettingsUpdateRow>: the row every app that updates itself needs. The app
|
|
7
|
-
* and its version, a sentence about where the update stands,
|
|
8
|
-
* button that moves it on: Check Now,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* <SettingsGroup header="Software Update">
|
|
12
|
-
* <SettingsUpdateRow appName="Library" :status="status()"
|
|
13
|
-
* @check="craft.updater.check()" @install="craft.updater.install()"
|
|
14
|
-
* @relaunch="craft.updater.relaunch()" />
|
|
15
|
-
* </SettingsGroup>
|
|
16
|
-
*
|
|
17
|
-
* `status` is what the updater reports (`craft.updater`'s `UpdateStatus`, or
|
|
18
|
-
* a web app's own of the same shape). The row does nothing on its own: it
|
|
19
|
-
* says what the status says and emits `check`, `install` or `relaunch`. What
|
|
20
|
-
* it says for each state is `settingsUpdateView` in ./update.
|
|
21
|
-
*
|
|
22
|
-
* It is a <SettingsRow> holding <Button appearance="mac">, so it is the same
|
|
23
|
-
* row on the web and on a native host, and the window's search finds it
|
|
24
|
-
* (`setting`, default `software-update`).
|
|
7
|
+
* and its version, a sentence about where the update stands, download progress,
|
|
8
|
+
* optional release notes, and the one button that moves it on: Check Now,
|
|
9
|
+
* Download and Install, or Restart to Update.
|
|
25
10
|
*/
|
|
26
11
|
export const appName = $props.appName || ''
|
|
27
12
|
export const status = $props.status && typeof $props.status === 'object' ? $props.status : null
|
|
@@ -38,13 +23,31 @@ import { settingsUpdateView } from './update'
|
|
|
38
23
|
const emit = defineEmits(['check', 'install', 'relaunch'])
|
|
39
24
|
const current = useReactiveProp('status', {{ status }})
|
|
40
25
|
const name = useReactiveProp('appName', {{ appName }})
|
|
26
|
+
const notesOpen = state(false)
|
|
41
27
|
const view = derived(() => settingsUpdateView(current(), name()))
|
|
28
|
+
const downloading = derived(() => current()?.state === 'downloading')
|
|
29
|
+
const progressWidth = derived(() => {
|
|
30
|
+
const p = Number(current()?.progress)
|
|
31
|
+
if (!Number.isFinite(p)) return '0%'
|
|
32
|
+
return `${Math.round(Math.min(1, Math.max(0, p)) * 100)}%`
|
|
33
|
+
})
|
|
34
|
+
const releaseNotes = derived(() => String(current()?.notes || '').trim())
|
|
35
|
+
const checkedLabel = derived(() => {
|
|
36
|
+
const raw = current()?.lastCheckedAt
|
|
37
|
+
if (!raw || current()?.state !== 'current') return ''
|
|
38
|
+
const when = new Date(raw)
|
|
39
|
+
return Number.isNaN(when.getTime()) ? '' : `Last checked ${when.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`
|
|
40
|
+
})
|
|
42
41
|
|
|
43
42
|
function act(action) {
|
|
44
43
|
// The status may have moved on since the button was drawn.
|
|
45
44
|
if (view().action === action && !view().busy) emit(action)
|
|
46
45
|
}
|
|
47
46
|
|
|
47
|
+
function toggleNotes() {
|
|
48
|
+
notesOpen.update(v => !v)
|
|
49
|
+
}
|
|
50
|
+
|
|
48
51
|
defineExpose({ view })
|
|
49
52
|
</script>
|
|
50
53
|
|
|
@@ -64,6 +67,21 @@ defineExpose({ view })
|
|
|
64
67
|
<Button :if="view().action === 'relaunch'" appearance="mac" variant="primary" :label="view().actionLabel" @click="act('relaunch')" />
|
|
65
68
|
</SettingsRow>
|
|
66
69
|
|
|
70
|
+
@if(!$native)
|
|
71
|
+
<div class="stx-settings-update-meta" :show="downloading() || Boolean(releaseNotes()) || Boolean(checkedLabel())">
|
|
72
|
+
<div class="stx-settings-update-bar" :show="downloading()" role="progressbar" aria-label="Update download progress">
|
|
73
|
+
<div class="stx-settings-update-fill" :style="'width: ' + progressWidth()"></div>
|
|
74
|
+
</div>
|
|
75
|
+
<p class="stx-settings-update-checked" :show="Boolean(checkedLabel())" :text="checkedLabel()"></p>
|
|
76
|
+
<div class="stx-settings-update-notes" :show="Boolean(releaseNotes())">
|
|
77
|
+
<button type="button" class="stx-settings-update-notes-toggle" :aria-expanded="notesOpen() ? 'true' : 'false'" @click="toggleNotes()">
|
|
78
|
+
<span :text="notesOpen() ? 'Hide release notes' : 'Release notes'"></span>
|
|
79
|
+
</button>
|
|
80
|
+
<p class="stx-settings-update-notes-body" :show="notesOpen()" :text="releaseNotes()"></p>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
@endif
|
|
84
|
+
|
|
67
85
|
<style data-native-exclude data-stx-public-style src="../../theme/macos.css"></style>
|
|
68
86
|
<style data-native-exclude>
|
|
69
87
|
.stx-settings-update-progress {
|
|
@@ -72,4 +90,49 @@ defineExpose({ view })
|
|
|
72
90
|
font-variant-numeric: tabular-nums;
|
|
73
91
|
letter-spacing: 0;
|
|
74
92
|
}
|
|
93
|
+
.stx-settings-update-meta {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: 8px;
|
|
97
|
+
padding: 0 var(--stx-mac-row-pad-x, 14px) 12px;
|
|
98
|
+
}
|
|
99
|
+
.stx-settings-update-bar {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 6px;
|
|
102
|
+
border-radius: 999px;
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
background: color-mix(in srgb, var(--stx-mac-ink, #000) 10%, transparent);
|
|
105
|
+
}
|
|
106
|
+
.stx-settings-update-fill {
|
|
107
|
+
height: 100%;
|
|
108
|
+
border-radius: 999px;
|
|
109
|
+
background: var(--stx-mac-accent, #0a84ff);
|
|
110
|
+
transition: width 0.2s ease;
|
|
111
|
+
}
|
|
112
|
+
.stx-settings-update-checked {
|
|
113
|
+
margin: 0;
|
|
114
|
+
font-size: 11px;
|
|
115
|
+
color: var(--stx-mac-ink-secondary);
|
|
116
|
+
}
|
|
117
|
+
.stx-settings-update-notes {
|
|
118
|
+
border-radius: 8px;
|
|
119
|
+
padding: 8px 10px;
|
|
120
|
+
background: color-mix(in srgb, var(--stx-mac-ink, #000) 4%, transparent);
|
|
121
|
+
font-size: 12px;
|
|
122
|
+
line-height: 1.45;
|
|
123
|
+
color: var(--stx-mac-ink-secondary);
|
|
124
|
+
}
|
|
125
|
+
.stx-settings-update-notes-toggle {
|
|
126
|
+
border: 0;
|
|
127
|
+
padding: 0;
|
|
128
|
+
background: none;
|
|
129
|
+
font: inherit;
|
|
130
|
+
font-weight: 500;
|
|
131
|
+
color: var(--stx-mac-ink);
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
}
|
|
134
|
+
.stx-settings-update-notes-body {
|
|
135
|
+
margin: 6px 0 0;
|
|
136
|
+
white-space: pre-wrap;
|
|
137
|
+
}
|
|
75
138
|
</style>
|
|
@@ -79,6 +79,8 @@ const noResults = state(false)
|
|
|
79
79
|
const searchFocus = state(false)
|
|
80
80
|
let stopCommands = null
|
|
81
81
|
let unregister = null
|
|
82
|
+
let paneChannel = null
|
|
83
|
+
let stopDrag = null
|
|
82
84
|
|
|
83
85
|
/*
|
|
84
86
|
* The last open pane, kept under `stx:settings:<key>`: local storage in a
|
|
@@ -167,8 +169,17 @@ onMount(() => {
|
|
|
167
169
|
unregister = registerComponentApi(settingsId, api)
|
|
168
170
|
}
|
|
169
171
|
else {
|
|
172
|
+
let initialPane = asText(openPane())
|
|
173
|
+
if (!initialPane && typeof location !== 'undefined') {
|
|
174
|
+
try {
|
|
175
|
+
const fromQuery = new URLSearchParams(location.search).get('pane')
|
|
176
|
+
if (fromQuery) initialPane = fromQuery
|
|
177
|
+
}
|
|
178
|
+
catch {}
|
|
179
|
+
}
|
|
180
|
+
|
|
170
181
|
settings = new SettingsWindowView(root, {
|
|
171
|
-
pane:
|
|
182
|
+
pane: initialPane,
|
|
172
183
|
storageKey,
|
|
173
184
|
storage: paneStorage,
|
|
174
185
|
globalKeys: {{ globalKeys }},
|
|
@@ -176,6 +187,32 @@ onMount(() => {
|
|
|
176
187
|
failedPane: {{ failedPane }},
|
|
177
188
|
retryPane: {{ retryPane }},
|
|
178
189
|
}, callbacks)
|
|
190
|
+
|
|
191
|
+
if (typeof BroadcastChannel === 'function') {
|
|
192
|
+
try {
|
|
193
|
+
paneChannel = new BroadcastChannel(`stx:settings-window:${storageKey || 'settings'}`)
|
|
194
|
+
paneChannel.onmessage = (event) => {
|
|
195
|
+
const target = typeof event.data === 'string' ? event.data : event.data?.pane
|
|
196
|
+
if (target && settings) settings.showPane(asText(target))
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch {}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if ({{ globalKeys }}) {
|
|
203
|
+
const onMouseDown = (event) => {
|
|
204
|
+
if (event.button !== 0) return
|
|
205
|
+
const drag = globalThis.craft?.window?.startDrag
|
|
206
|
+
if (typeof drag !== 'function') return
|
|
207
|
+
const target = event.target
|
|
208
|
+
if (!(target instanceof Element)) return
|
|
209
|
+
if (!target.closest('[data-settings-toolbar], [data-settings-sidebar]')) return
|
|
210
|
+
if (target.closest('a, button, input, select, textarea, label, [role="tab"], [data-settings-item]')) return
|
|
211
|
+
drag.call(globalThis.craft.window)
|
|
212
|
+
}
|
|
213
|
+
root.addEventListener('mousedown', onMouseDown)
|
|
214
|
+
stopDrag = () => root.removeEventListener('mousedown', onMouseDown)
|
|
215
|
+
}
|
|
179
216
|
}
|
|
180
217
|
|
|
181
218
|
// The first run finds the pane the view just opened, which may be a stored
|
|
@@ -189,8 +226,12 @@ onMount(() => {
|
|
|
189
226
|
onDestroy(() => {
|
|
190
227
|
if (stopCommands) stopCommands()
|
|
191
228
|
if (unregister) unregister()
|
|
229
|
+
if (stopDrag) stopDrag()
|
|
230
|
+
if (paneChannel) { try { paneChannel.close() } catch {} }
|
|
192
231
|
stopCommands = null
|
|
193
232
|
unregister = null
|
|
233
|
+
stopDrag = null
|
|
234
|
+
paneChannel = null
|
|
194
235
|
if (settings) settings.destroy()
|
|
195
236
|
settings = null
|
|
196
237
|
})
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
<script server>
|
|
2
|
-
import { SETTINGS_NATIVE } from './native-theme'
|
|
3
|
-
import { settingsUpdateView } from './update'
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* <SettingsUpdateRow>: the row every app that updates itself needs. The app
|
|
7
|
-
* and its version, a sentence about where the update stands, and the one
|
|
8
|
-
* button that moves it on: Check Now, Download and Install (with its
|
|
9
|
-
* progress), or Restart to Update.
|
|
10
|
-
*
|
|
11
|
-
* <SettingsGroup header="Software Update">
|
|
12
|
-
* <SettingsUpdateRow appName="Library" :status="status()"
|
|
13
|
-
* @check="craft.updater.check()" @install="craft.updater.install()"
|
|
14
|
-
* @relaunch="craft.updater.relaunch()" />
|
|
15
|
-
* </SettingsGroup>
|
|
16
|
-
*
|
|
17
|
-
* `status` is what the updater reports (`craft.updater`'s `UpdateStatus`, or
|
|
18
|
-
* a web app's own of the same shape). The row does nothing on its own: it
|
|
19
|
-
* says what the status says and emits `check`, `install` or `relaunch`. What
|
|
20
|
-
* it says for each state is `settingsUpdateView` in ./update.
|
|
21
|
-
*
|
|
22
|
-
* It is a <SettingsRow> holding <Button appearance="mac">, so it is the same
|
|
23
|
-
* row on the web and on a native host, and the window's search finds it
|
|
24
|
-
* (`setting`, default `software-update`).
|
|
25
|
-
*/
|
|
26
|
-
export const appName = $props.appName || ''
|
|
27
|
-
export const status = $props.status && typeof $props.status === 'object' ? $props.status : null
|
|
28
|
-
export const setting = $props.setting || 'software-update'
|
|
29
|
-
export const keywords = Array.isArray($props.keywords) ? $props.keywords.join(' ') : ($props.keywords || 'update version upgrade release')
|
|
30
|
-
export const className = $props.className || ''
|
|
31
|
-
export const served = settingsUpdateView(status, appName)
|
|
32
|
-
export const progressClasses = $native ? SETTINGS_NATIVE.updateProgress : 'stx-settings-update-progress'
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<script client>
|
|
36
|
-
import { settingsUpdateView } from './update'
|
|
37
|
-
|
|
38
|
-
const emit = defineEmits(['check', 'install', 'relaunch'])
|
|
39
|
-
const current = useReactiveProp('status', {{ status }})
|
|
40
|
-
const name = useReactiveProp('appName', {{ appName }})
|
|
41
|
-
const view = derived(() => settingsUpdateView(current(), name()))
|
|
42
|
-
|
|
43
|
-
function act(action) {
|
|
44
|
-
// The status may have moved on since the button was drawn.
|
|
45
|
-
if (view().action === action && !view().busy) emit(action)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
defineExpose({ view })
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<SettingsRow
|
|
52
|
-
label="{{ served.title }}"
|
|
53
|
-
:label="view().title"
|
|
54
|
-
description="{{ served.sentence }}"
|
|
55
|
-
:description="view().sentence"
|
|
56
|
-
setting="{{ setting }}"
|
|
57
|
-
keywords="{{ keywords }}"
|
|
58
|
-
multiline
|
|
59
|
-
className="{{ className }}"
|
|
60
|
-
>
|
|
61
|
-
<span :show="view().progress" :text="view().progress" class="{{ progressClasses }}" data-settings-update-progress>{{ served.progress }}</span>
|
|
62
|
-
<Button :if="view().action === 'check'" appearance="mac" :label="view().actionLabel" :loading="view().busy" @click="act('check')" />
|
|
63
|
-
<Button :if="view().action === 'install'" appearance="mac" variant="primary" :label="view().actionLabel" :loading="view().busy" @click="act('install')" />
|
|
64
|
-
<Button :if="view().action === 'relaunch'" appearance="mac" variant="primary" :label="view().actionLabel" @click="act('relaunch')" />
|
|
65
|
-
</SettingsRow>
|
|
66
|
-
|
|
67
|
-
<style data-native-exclude data-stx-public-style src="../../theme/macos.css"></style>
|
|
68
|
-
<style data-native-exclude>
|
|
69
|
-
.stx-settings-update-progress {
|
|
70
|
-
color: var(--stx-mac-ink-secondary);
|
|
71
|
-
font-size: var(--stx-mac-font-size-small);
|
|
72
|
-
font-variant-numeric: tabular-nums;
|
|
73
|
-
letter-spacing: 0;
|
|
74
|
-
}
|
|
75
|
-
</style>
|