zen-fs-config 0.5.21 → 0.5.23
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 +22 -0
- package/README.zh-CN.md +22 -0
- package/dist/index.browser.js +28472 -0
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +172 -30
- package/dist/index.mjs +172 -30
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -26,6 +26,28 @@ npm install zen-fs-config @zenfs/core @zenfs/dom zen-fs-sync
|
|
|
26
26
|
|
|
27
27
|
> `@zenfs/dom` provides the IndexedDB backend (required in browser environments). `zen-fs-cache` is an optional dependency for remote request caching.
|
|
28
28
|
|
|
29
|
+
## Usage via `<script>` tag (no build step)
|
|
30
|
+
|
|
31
|
+
A self-contained browser bundle is published at `dist/index.browser.js`. It bundles **all** dependencies (`@zenfs/core`, `@zenfs/dom`, `zen-fs-sync`, `zen-fs-cache`) and exposes the library on the global `window.ZenFSConfig`. No npm install, no bundler — just drop it into any HTML page:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<script src="https://unpkg.com/zen-fs-config/dist/index.browser.js"></script>
|
|
35
|
+
<script>
|
|
36
|
+
(async () => {
|
|
37
|
+
const { createConfigRepo } = window.ZenFSConfig;
|
|
38
|
+
|
|
39
|
+
// IndexedDB primary backend is created automatically
|
|
40
|
+
const repo = await createConfigRepo('my-app');
|
|
41
|
+
|
|
42
|
+
repo.setConfig('greeting.json', { msg: 'hello' });
|
|
43
|
+
const cfg = await repo.getConfig('greeting.json');
|
|
44
|
+
console.log(cfg); // { msg: 'hello' }
|
|
45
|
+
})();
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> The browser bundle includes a pure-JS SHA-256 fallback, so version tracking works even in non-secure contexts (plain HTTP) where `crypto.subtle` is unavailable.
|
|
50
|
+
|
|
29
51
|
## Quick Start
|
|
30
52
|
|
|
31
53
|
### 1. Initialize (zero-configuration)
|
package/README.zh-CN.md
CHANGED
|
@@ -14,6 +14,28 @@ npm install zen-fs-config @zenfs/core @zenfs/dom zen-fs-sync
|
|
|
14
14
|
|
|
15
15
|
> `@zenfs/dom` 提供 IndexedDB 后端(浏览器环境必需)。`zen-fs-cache` 为可选依赖。
|
|
16
16
|
|
|
17
|
+
## 通过 `<script>` 标签直接使用(无需构建)
|
|
18
|
+
|
|
19
|
+
包内置了一个自包含的浏览器构建 `dist/index.browser.js`,它把**所有**依赖(`@zenfs/core`、`@zenfs/dom`、`zen-fs-sync`、`zen-fs-cache`)打包在一起,并将库挂载到全局变量 `window.ZenFSConfig`。无需 npm install、无需打包工具,直接放入任意 HTML 页面即可:
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<script src="https://unpkg.com/zen-fs-config/dist/index.browser.js"></script>
|
|
23
|
+
<script>
|
|
24
|
+
(async () => {
|
|
25
|
+
const { createConfigRepo } = window.ZenFSConfig;
|
|
26
|
+
|
|
27
|
+
// 自动创建 IndexedDB 主后端
|
|
28
|
+
const repo = await createConfigRepo('my-app');
|
|
29
|
+
|
|
30
|
+
repo.setConfig('greeting.json', { msg: 'hello' });
|
|
31
|
+
const cfg = await repo.getConfig('greeting.json');
|
|
32
|
+
console.log(cfg); // { msg: 'hello' }
|
|
33
|
+
})();
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> 浏览器构建包含纯 JS 实现的 SHA-256 回退,因此即使在 `crypto.subtle` 不可用的非安全上下文(普通 HTTP)中,版本追踪也能正常工作。
|
|
38
|
+
|
|
17
39
|
## 快速开始
|
|
18
40
|
|
|
19
41
|
### 1. 初始化(零参数)
|