Experiment to rebuild Diffuse using web applets.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: clean up

+18 -6
+1
src/pages/configurator/input/_applet.astro
··· 6 6 </p> 7 7 <div id="options"> 8 8 <p> 9 + <!-- TODO: Need to check if supported on this device --> 9 10 <a href="../../input/native-fs/" class="with-icon"> 10 11 <i class="iconoir-open-in-window"></i> 11 12 <strong>My device</strong>
+16 -4
src/pages/input/native-fs/_applet.astro
··· 92 92 // ACTIONS 93 93 //////////////////////////////////////////// 94 94 const consult = async (fileUriOrScheme: string) => { 95 - const isSupported = !!(globalThis as any).showDirectoryPicker; 96 - if (!isSupported) { 95 + if (!isSupported()) { 97 96 return { supported: false, reason: "File System Access API is not supported" }; 98 97 } 99 98 ··· 109 108 }; 110 109 111 110 const list = async (cachedTracks: Track[] = []) => { 111 + if (!isSupported()) return cachedTracks; 112 + 113 + // Continue if supported 112 114 const handles = await fetchHandlesList(); 115 + 116 + // Recursive listing of all tracks of available handles 113 117 const processed: Track[][] = await Promise.all( 114 118 handles.map(({ id, handle }) => { 115 119 return recursiveList(handle, id, []); 116 120 }), 117 121 ); 118 122 123 + // Group tracks by handle id & index by track uri 119 124 const cache = cachedTracks.reduce( 120 125 (acc: Record<string, Record<string, Track>>, track: Track) => { 121 126 const handleId = trackHandleId(track); ··· 126 131 {}, 127 132 ); 128 133 134 + // Replace indexes in groups of which we have the handle. 135 + // Keeping around tracks with handles we don't have access to, 136 + // and removing tracks that are no longer available (for handles we do have access to). 129 137 const groups = processed.flat(1).reduce( 130 138 (acc, track) => { 131 139 const handleId = trackHandleId(track); ··· 138 146 }, cache), 139 147 ); 140 148 149 + // Transform in track list and sort by uri 141 150 const data = Object.values(groups) 142 151 .map((tracks) => Object.values(tracks)) 143 152 .flat(1) ··· 153 162 }; 154 163 155 164 const resolve = async (fileUri: string) => { 156 - const isSupported = !!(globalThis as any).showDirectoryPicker; 157 - if (!isSupported) return undefined; 165 + if (!isSupported()) return undefined; 158 166 159 167 const uri = URI.parse(fileUri); 160 168 if (uri.scheme !== SCHEME) return undefined; ··· 227 235 return Object.entries(await fetchHandles()).map(([id, handle]) => { 228 236 return { id, handle }; 229 237 }); 238 + } 239 + 240 + function isSupported() { 241 + return !!(globalThis as any).showDirectoryPicker; 230 242 } 231 243 232 244 function trackCid(track: Track): string | undefined {
+1 -2
src/scripts/themes/webamp/index.ts
··· 1 1 import Webamp from "webamp"; 2 - // import "98.css"; 3 2 4 - import type { Output, Track } from "@applets/core/types.d.ts"; 3 + import type { Track } from "@applets/core/types.d.ts"; 5 4 import { applet } from "../../theme.ts"; 6 5 7 6 ////////////////////////////////////////////