@subconverter/browser 0.1.0 → 0.3.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/LICENSE +674 -0
- package/README.md +55 -0
- package/dist/subconverter.global.js +87 -87
- package/dist/subconverter.global.js.map +1 -1
- package/package.json +21 -2
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @subconverter/browser
|
|
2
|
+
|
|
3
|
+
Browser build of [subconverter-ts](https://github.com/jinganix/subconverter): convert
|
|
4
|
+
subscriptions entirely in the page, with no server round trip. Built on
|
|
5
|
+
[`@subconverter/core`](https://npmjs.com/package/@subconverter/core) and shipped as ESM
|
|
6
|
+
plus an IIFE global (`SubConverter`).
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i @subconverter/browser
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { createExtraSettings, loadNodes, toClash } from "@subconverter/browser";
|
|
16
|
+
|
|
17
|
+
const nodes = await loadNodes("https://example.com/sub");
|
|
18
|
+
const clash = toClash(nodes, [], createExtraSettings());
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`loadNodes` fetches and parses in one step; `toClash` / `toSurge` are the bundled
|
|
22
|
+
generators. Everything else (the full `parseSubscription`, `generate`, `TargetFormat`,
|
|
23
|
+
and all type exports) is re-exported from `@subconverter/core`.
|
|
24
|
+
|
|
25
|
+
## Script tag
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<script src="https://unpkg.com/@subconverter/browser/dist/subconverter.global.js"></script>
|
|
29
|
+
<script>
|
|
30
|
+
const nodes = await SubConverter.loadNodes("https://example.com/sub");
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The IIFE bundle exposes `SubConverter` on `window`.
|
|
35
|
+
|
|
36
|
+
## CORS
|
|
37
|
+
|
|
38
|
+
The browser build calls `fetch` directly, so the subscription host must allow cross-origin
|
|
39
|
+
requests. When it does not, run the [server from `@subconverter/node`](https://npmjs.com/package/@subconverter/node)
|
|
40
|
+
and point the browser at your own origin instead.
|
|
41
|
+
|
|
42
|
+
## Package size
|
|
43
|
+
|
|
44
|
+
The IIFE bundle is roughly 160 kB because it contains the whole conversion engine,
|
|
45
|
+
including every parser and generator. Import the ESM entry point to let a bundler drop
|
|
46
|
+
unused targets.
|
|
47
|
+
|
|
48
|
+
## API reference
|
|
49
|
+
|
|
50
|
+
Every public export with its signature, enum members, and interface fields:
|
|
51
|
+
[docs/API.md](https://github.com/jinganix/subconverter/blob/main/docs/API.md).
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
GPL-3.0.
|