alpha
Login
or
Join now
tokono.ma
/
diffuse-applets
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Experiment to rebuild Diffuse using web applets.
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
fix: input/native-fs uri improvements
author
Steven Vandevelde
date
1 year ago
(May 17, 2025, 10:46 PM +0200)
commit
c2bb6b6f
c2bb6b6fe37684ef6f57df6fb263b0fbace4a9d0
parent
a6a05716
a6a057164c6866ad6f62261805618de105325909
+37
-26
4 changed files
Expand all
Collapse all
Unified
Split
deno.lock
package-lock.json
package.json
src
pages
input
native-fs
_applet.astro
+1
deno.lock
Reviewed
···
35
35
"npm:sass@^1.87.0",
36
36
"npm:spellcaster@6",
37
37
"npm:throttle-debounce@^5.0.2",
38
38
+
"npm:uri-js@^4.4.1",
38
39
"npm:xxh32@^2.0.5"
39
40
]
40
41
}
+19
-16
package-lock.json
Reviewed
···
8
8
"@atcute/cid": "^2.2.2",
9
9
"@picocss/pico": "^2.1.1",
10
10
"@web-applets/sdk": "https://gitpkg.vercel.app/unternet-co/web-applets/sdk?feat/child-context&scripts.postinstall=npm%20i%20%40types%2Fnode%20%26%26%20npx%20tsc",
11
11
-
"fast-uri": "^3.0.6",
12
11
"iconoir": "^7.11.0",
13
12
"idb-keyval": "^6.2.1",
14
13
"native-file-system-adapter": "^3.0.1",
15
14
"query-string": "^9.1.2",
16
15
"spellcaster": "^6.0.0",
17
16
"throttle-debounce": "^5.0.2",
17
17
+
"uri-js": "^4.4.1",
18
18
"xxh32": "^2.0.5"
19
19
},
20
20
"devDependencies": {
···
2630
2630
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
2631
2631
"dev": true
2632
2632
},
2633
2633
-
"node_modules/fast-uri": {
2634
2634
-
"version": "3.0.6",
2635
2635
-
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz",
2636
2636
-
"integrity": "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==",
2637
2637
-
"funding": [
2638
2638
-
{
2639
2639
-
"type": "github",
2640
2640
-
"url": "https://github.com/sponsors/fastify"
2641
2641
-
},
2642
2642
-
{
2643
2643
-
"type": "opencollective",
2644
2644
-
"url": "https://opencollective.com/fastify"
2645
2645
-
}
2646
2646
-
]
2647
2647
-
},
2648
2633
"node_modules/fdir": {
2649
2634
"version": "6.4.4",
2650
2635
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz",
···
4514
4499
"url": "https://github.com/sponsors/wooorm"
4515
4500
}
4516
4501
},
4502
4502
+
"node_modules/punycode": {
4503
4503
+
"version": "2.3.1",
4504
4504
+
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
4505
4505
+
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
4506
4506
+
"license": "MIT",
4507
4507
+
"engines": {
4508
4508
+
"node": ">=6"
4509
4509
+
}
4510
4510
+
},
4517
4511
"node_modules/purgecss": {
4518
4512
"version": "7.0.2",
4519
4513
"resolved": "https://registry.npmjs.org/purgecss/-/purgecss-7.0.2.tgz",
···
5545
5539
"uploadthing": {
5546
5540
"optional": true
5547
5541
}
5542
5542
+
}
5543
5543
+
},
5544
5544
+
"node_modules/uri-js": {
5545
5545
+
"version": "4.4.1",
5546
5546
+
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
5547
5547
+
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
5548
5548
+
"license": "BSD-2-Clause",
5549
5549
+
"dependencies": {
5550
5550
+
"punycode": "^2.1.0"
5548
5551
}
5549
5552
},
5550
5553
"node_modules/util-deprecate": {
+1
-1
package.json
Reviewed
···
3
3
"@atcute/cid": "^2.2.2",
4
4
"@picocss/pico": "^2.1.1",
5
5
"@web-applets/sdk": "https://gitpkg.vercel.app/unternet-co/web-applets/sdk?feat/child-context&scripts.postinstall=npm%20i%20%40types%2Fnode%20%26%26%20npx%20tsc",
6
6
-
"fast-uri": "^3.0.6",
7
6
"iconoir": "^7.11.0",
8
7
"idb-keyval": "^6.2.1",
9
8
"native-file-system-adapter": "^3.0.1",
10
9
"query-string": "^9.1.2",
11
10
"spellcaster": "^6.0.0",
12
11
"throttle-debounce": "^5.0.2",
12
12
+
"uri-js": "^4.4.1",
13
13
"xxh32": "^2.0.5"
14
14
},
15
15
"devDependencies": {
+16
-9
src/pages/input/native-fs/_applet.astro
Reviewed
···
3
3
4
4
import { applets } from "@web-applets/sdk";
5
5
import { type FileSystemDirectoryHandle, showDirectoryPicker } from "native-file-system-adapter";
6
6
+
import * as URI from "uri-js";
6
7
import QS from "query-string";
7
7
-
import URI from "fast-uri";
8
8
9
9
import type { Track } from "@applets/core/types.d.ts";
10
10
import { isAudioFile } from "@scripts/inputs/common";
11
11
+
12
12
+
import manifest from "./_manifest.json";
11
13
12
14
type Handles = Record<string, FileSystemDirectoryHandle>;
13
15
···
18
20
////////////////////////////////////////////
19
21
const IDB_PREFIX = "@applets/input/native-fs";
20
22
const IDB_HANDLES = `${IDB_PREFIX}/handles`;
23
23
+
const INPUT_SCHEME = manifest.input_properties.scheme;
21
24
22
25
const context = applets.register();
23
26
···
25
28
// ACTIONS
26
29
////////////////////////////////////////////
27
30
const isAvailable = async (fileUri: string) => {
31
31
+
const isSupported = !!(globalThis as any).showDirectoryPicker;
32
32
+
if (!isSupported) {
33
33
+
console.warn(
34
34
+
"`input/native-fs` is not supported on this platform, missing File System Access API.",
35
35
+
);
36
36
+
return false;
37
37
+
}
38
38
+
28
39
const handles = await fetchHandles();
29
40
const uri = URI.parse(fileUri);
30
41
return uri.host && !!handles[uri.host];
···
79
90
80
91
const resolve = async (fileUri: string) => {
81
92
const uri = URI.parse(fileUri);
82
82
-
if (uri.scheme !== "file+local") return undefined;
93
93
+
if (uri.scheme !== INPUT_SCHEME) return undefined;
83
94
if (!uri.host || !uri.path) return undefined;
84
95
85
96
const handles = await fetchHandles();
86
97
const handle = handles[uri.host];
87
98
if (!handle) return undefined;
88
99
89
89
-
const parts = (uri.path.startsWith("/") ? uri.path.slice(1) : uri.path)
90
90
-
.split("/")
91
91
-
.map((a) => decodeURIComponent(a));
100
100
+
const path = URI.unescapeComponent(uri.path);
101
101
+
const parts = (path.startsWith("/") ? path.slice(1) : path).split("/");
92
102
const filename = parts[parts.length - 1];
93
93
-
94
94
-
console.log(parts);
95
103
96
104
const dirHandle = await parts
97
105
.slice(0, -1)
···
101
109
part: string,
102
110
): Promise<FileSystemDirectoryHandle> => {
103
111
const h = await acc;
104
104
-
console.log("→", part);
105
112
return await h.getDirectoryHandle(part);
106
113
},
107
114
Promise.resolve(handle),
···
168
175
for await (const item of dir.values()) {
169
176
if (item.kind === "file" && isAudioFile(item.name)) {
170
177
const uri = URI.serialize({
171
171
-
scheme: "file+local",
178
178
+
scheme: INPUT_SCHEME,
172
179
host: rootHandleId,
173
180
path: `${path.length ? "/" + path.join("/") : ""}/${item.name}`,
174
181
});