@hnode/tidy 0.18.1 → 0.20.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/README.md +33 -13
- package/bin/tidy.js +6 -3
- package/desktop/core.js +112 -0
- package/desktop/index.html +11 -0
- package/desktop/main.js +328 -0
- package/desktop/manage.js +175 -0
- package/desktop/native/macos.swift +110 -0
- package/desktop/native-bridge.js +67 -0
- package/desktop/package-lock.json +161 -0
- package/desktop/package.json +10 -0
- package/desktop/preload.cjs +11 -0
- package/desktop/renderer.js +115 -0
- package/desktop/style.css +25 -0
- package/dist/winubun@winubun.local.shell-extension.zip +0 -0
- package/docs/DEVELOPMENT.md +15 -3
- package/docs/MACOS.md +69 -0
- package/docs/README.en.md +30 -9
- package/docs/RELEASING.md +44 -6
- package/docs/preview.png +0 -0
- package/lib/layouts.js +132 -0
- package/lib/translations.json +20 -5
- package/metadata.json +1 -1
- package/package.json +18 -8
- package/scripts/manage.py +58 -8
package/scripts/manage.py
CHANGED
|
@@ -47,6 +47,47 @@ def set_enabled(uuid, enabled):
|
|
|
47
47
|
raise RuntimeError(_('GNOME could not find the extension: {uuid}', uuid=uuid))
|
|
48
48
|
|
|
49
49
|
|
|
50
|
+
def wait_for_extension(uuid, enabled):
|
|
51
|
+
for attempt in range(50):
|
|
52
|
+
info = extension_info(uuid)
|
|
53
|
+
state = info.get('state')
|
|
54
|
+
if (enabled and state == 1) or (not enabled and (not info or state in (2, 6))):
|
|
55
|
+
return
|
|
56
|
+
if state in (3, 4, 99):
|
|
57
|
+
raise RuntimeError(_('Extension transition failed: {uuid}: {error}',
|
|
58
|
+
uuid=uuid, error=info.get('error') or str(state)))
|
|
59
|
+
time.sleep(0.1)
|
|
60
|
+
raise RuntimeError(_('Extension transition timed out: {uuid}', uuid=uuid))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def extension_installed(uuid):
|
|
64
|
+
directories = [DATA, *(Path(path) for path in GLib.get_system_data_dirs())]
|
|
65
|
+
return any((directory / 'gnome-shell/extensions' / uuid / 'extension.js').is_file()
|
|
66
|
+
for directory in directories)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def enable_after_login(uuid):
|
|
70
|
+
# Removing a user override unregisters the UUID for this session even when
|
|
71
|
+
# a system copy remains. Persist the preference without trying to load JS.
|
|
72
|
+
settings = Gio.Settings.new('org.gnome.shell')
|
|
73
|
+
enabled = settings.get_strv('enabled-extensions')
|
|
74
|
+
disabled = settings.get_strv('disabled-extensions')
|
|
75
|
+
changes = {}
|
|
76
|
+
if uuid not in enabled:
|
|
77
|
+
changes['enabled-extensions'] = [*enabled, uuid]
|
|
78
|
+
if uuid in disabled:
|
|
79
|
+
changes['disabled-extensions'] = [item for item in disabled if item != uuid]
|
|
80
|
+
if any(not settings.is_writable(key) for key in changes):
|
|
81
|
+
raise RuntimeError(_('Extension preferences are read-only: {uuid}', uuid=uuid))
|
|
82
|
+
settings.delay()
|
|
83
|
+
for key, value in changes.items():
|
|
84
|
+
if not settings.set_strv(key, value):
|
|
85
|
+
settings.revert()
|
|
86
|
+
raise RuntimeError(_('Could not save extension preferences: {uuid}', uuid=uuid))
|
|
87
|
+
settings.apply()
|
|
88
|
+
Gio.Settings.sync()
|
|
89
|
+
|
|
90
|
+
|
|
50
91
|
def open_preferences():
|
|
51
92
|
STATE.mkdir(parents=True, exist_ok=True)
|
|
52
93
|
with (STATE / 'preferences.log').open('a') as log:
|
|
@@ -111,7 +152,14 @@ def restore_competitors():
|
|
|
111
152
|
failed = []
|
|
112
153
|
for uuid in pending:
|
|
113
154
|
try:
|
|
114
|
-
|
|
155
|
+
if extension_info(uuid):
|
|
156
|
+
set_enabled(uuid, True)
|
|
157
|
+
wait_for_extension(uuid, True)
|
|
158
|
+
elif extension_installed(uuid):
|
|
159
|
+
enable_after_login(uuid)
|
|
160
|
+
print(_('The previous extension will be restored at the next login: {uuid}', uuid=uuid))
|
|
161
|
+
else:
|
|
162
|
+
print(_('The previous extension is no longer installed; skipping restoration: {uuid}', uuid=uuid))
|
|
115
163
|
except RuntimeError as error:
|
|
116
164
|
failed.append(uuid)
|
|
117
165
|
print(error, file=sys.stderr)
|
|
@@ -147,6 +195,8 @@ def install(archive=None):
|
|
|
147
195
|
DEST.mkdir(parents=True, exist_ok=True)
|
|
148
196
|
with zipfile.ZipFile(archive) as package:
|
|
149
197
|
package.extractall(DEST)
|
|
198
|
+
if 'schemas/gschemas.compiled' not in package.namelist():
|
|
199
|
+
run('glib-compile-schemas', '--strict', str(DEST / 'schemas'))
|
|
150
200
|
install_launcher()
|
|
151
201
|
if not registered or registered.get('version') != metadata['version']:
|
|
152
202
|
schedule_update(metadata['version'])
|
|
@@ -173,12 +223,7 @@ def activate():
|
|
|
173
223
|
try:
|
|
174
224
|
for uuid in competitors:
|
|
175
225
|
set_enabled(uuid, False)
|
|
176
|
-
|
|
177
|
-
if all(extension_info(uuid).get('state') != 1 for uuid in competitors):
|
|
178
|
-
break
|
|
179
|
-
time.sleep(0.1)
|
|
180
|
-
else:
|
|
181
|
-
raise RuntimeError(_('The previous tiling extension did not stop.'))
|
|
226
|
+
wait_for_extension(uuid, False)
|
|
182
227
|
set_enabled(UUID, True)
|
|
183
228
|
for attempt in range(50):
|
|
184
229
|
info = extension_info()
|
|
@@ -210,8 +255,10 @@ def apply_update():
|
|
|
210
255
|
def uninstall():
|
|
211
256
|
if DEST.is_symlink():
|
|
212
257
|
raise RuntimeError(_('Remove symlink installations manually: {path}', path=DEST))
|
|
213
|
-
|
|
258
|
+
registered = extension_info()
|
|
259
|
+
if registered:
|
|
214
260
|
set_enabled(UUID, False)
|
|
261
|
+
wait_for_extension(UUID, False)
|
|
215
262
|
elif DEST.exists():
|
|
216
263
|
print(_('The extension is not registered in this session. Checking settings recovery.'))
|
|
217
264
|
# Also recover settings if a Shell crash prevented disable() from running.
|
|
@@ -221,6 +268,9 @@ def uninstall():
|
|
|
221
268
|
subprocess.run(['gjs', '-m', str(DEST / 'scripts/recover.js')], env=env, check=True)
|
|
222
269
|
restore_competitors()
|
|
223
270
|
finish_update()
|
|
271
|
+
if registered:
|
|
272
|
+
if not shell_call('UninstallExtension', '(s)', (UUID,))[0]:
|
|
273
|
+
raise RuntimeError(_('GNOME could not remove Tidy.'))
|
|
224
274
|
if DEST.exists():
|
|
225
275
|
shutil.rmtree(DEST)
|
|
226
276
|
(DATA / 'applications/winubun.desktop').unlink(missing_ok=True)
|