@hoardodile/sdk-web 0.0.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 +18 -0
- package/README.md +47 -0
- package/dist/index.d.ts +727 -0
- package/dist/index.js +683 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
- package/src/bridge.ts +178 -0
- package/src/codecs.ts +54 -0
- package/src/fixtures.ts +154 -0
- package/src/index.ts +92 -0
- package/src/lifecycle.ts +200 -0
- package/src/protocol.ts +448 -0
- package/src/runtime.test.ts +63 -0
- package/src/runtime.ts +279 -0
- package/src/stores.ts +103 -0
- package/src/types.ts +252 -0
- package/src/urls.ts +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wooloo <ayan0312000@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @hoardodile/sdk-web
|
|
2
|
+
|
|
3
|
+
Pure-browser iframe runtime for hoardodile content plugins: the wire
|
|
4
|
+
protocol (single source of truth, versioned via `PROTOCOL_VERSION`), host
|
|
5
|
+
bridge, stores, and theme/font/visibility helpers. No node code — the
|
|
6
|
+
d.ts surface is guarded against node references in CI.
|
|
7
|
+
|
|
8
|
+
Use `@hoardodile/sdk-react` when you build with React; drop to this
|
|
9
|
+
package for framework-agnostic iframe code.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @hoardodile/sdk-web
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What's in it
|
|
18
|
+
|
|
19
|
+
- **`createIframeHostAPI(ctx)`** — the imperative, framework-agnostic
|
|
20
|
+
`WebPluginAPI`: files, messages, danmaku, prefs, cache, invalidation,
|
|
21
|
+
anchor-jump subscription
|
|
22
|
+
- **`mountPlugin(mount)`** — host→plugin communication with a pooled
|
|
23
|
+
iframe lifecycle (rebind without reload)
|
|
24
|
+
- **`createWebPluginAPI(overrides)`** — a stubbed API for render tests
|
|
25
|
+
- **`jsonCodec` / `numberCodec` / `booleanCodec`** — typed pref codecs
|
|
26
|
+
- **`applyTheme` / `applyFonts`** — host theme and font inheritance
|
|
27
|
+
- **`ensureHostBridge`** — low-level postMessage bridge (rarely needed)
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { mountPlugin, createIframeHostAPI } from "@hoardodile/sdk-web"
|
|
33
|
+
|
|
34
|
+
mountPlugin((ctx) => {
|
|
35
|
+
const api = createIframeHostAPI(ctx)
|
|
36
|
+
api.listFiles().then((files) => {
|
|
37
|
+
document.querySelector("#root")!.textContent = files.join(", ")
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Where does the code live?
|
|
43
|
+
|
|
44
|
+
The wire protocol is the contract, defined once in `@hoardodile/sdk-types`
|
|
45
|
+
and re-exported here for a single import root. The browser-side *host*
|
|
46
|
+
runtime (`@hoardodile/host-web`) consumes this protocol — it never
|
|
47
|
+
redefines it.
|