@senlinz/import-export 0.1.2 → 1.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/README.md CHANGED
@@ -10,29 +10,14 @@ High-level browser API for Excel template generation, export, and import.
10
10
  pnpm add @senlinz/import-export
11
11
  ```
12
12
 
13
- ## Choose your mode
13
+ ## WASM loading
14
14
 
15
- ### Default mode (recommended)
16
-
17
- - No setup required.
18
- - `importExcel`, `importExcelDynamic`, `exportExcel`, `fromExcel`, `fromExcelDynamic`, `toExcel`, `downloadExcelTemplate`, and `generateExcelTemplate` automatically initialize the bundled WASM runtime.
19
- - Best for most browser applications.
20
-
21
- ### Advanced mode
22
-
23
- - Call `initializeWasm(...)` yourself before using the Excel APIs.
24
- - Use this when you want custom WASM hosting, bundler control, or to reuse bytes/modules that you loaded elsewhere.
25
- - Supported manual inputs: `source`, `bytes`, or `module`.
26
- - `bundledWasmSource` is also exported for self-contained demos/tests that still want explicit manual initialization.
15
+ - `importExcel`, `importExcelDynamic`, `exportExcel`, `fromExcel`, `fromExcelDynamic`, `toExcel`, `downloadExcelTemplate`, and `generateExcelTemplate` auto-load and initialize the bundled WASM asset on first use.
16
+ - In Vite and other browser ESM bundlers, no manual `initializeWasm(...)` call or `?url` import is required when using the high-level core package.
17
+ - If you need to manage the WASM module yourself, use `@senlinz/import-export-wasm` directly instead of this package.
27
18
 
28
19
  ```ts
29
- import { initializeWasm, toExcel } from '@senlinz/import-export';
30
-
31
- const wasmBytes = new Uint8Array(
32
- await (await fetch('/assets/imexport_wasm_bg.wasm')).arrayBuffer()
33
- );
34
-
35
- initializeWasm({ bytes: wasmBytes });
20
+ import { toExcel } from '@senlinz/import-export';
36
21
 
37
22
  const workbook = await toExcel({
38
23
  name: 'TomAndJerry',
@@ -40,8 +25,6 @@ const workbook = await toExcel({
40
25
  }, [{ name: 'Tom' }]);
41
26
  ```
42
27
 
43
- If you provide invalid manual input, `initializeWasm(...)` throws a clear error immediately.
44
-
45
28
  ## Supported API
46
29
 
47
30
  ### Stable definition fields
@@ -183,12 +166,11 @@ These advanced features are supported and considered part of the public API:
183
166
  - `downloadExcelTemplate`, `exportExcel`, `importExcel`, and `importExcelDynamic` require DOM/browser APIs.
184
167
  - `fromExcel`, `toExcel`, and `generateExcelTemplate` can be used in other runtimes when browser-compatible globals are available.
185
168
  - `fromExcelDynamic` can also be used in other runtimes when browser-compatible globals are available.
186
- - `initializeWasm` can be used to pre-initialize the runtime with caller-managed `source`, `bytes`, or `module`.
169
+ - The core package initializes its emitted bundled WASM asset asynchronously before the first workbook operation.
187
170
 
188
171
  ## Examples
189
172
 
190
173
  - [Basic browser example](./examples/basic-browser.html)
191
- - [Manual WASM browser example](./examples/manual-wasm-browser.html)
192
174
  - [Grouped export example](./examples/grouped-export.html)
193
175
  - [Definition validation example](./examples/definition-errors.html)
194
176
 
package/README.zh.md CHANGED
@@ -10,29 +10,14 @@
10
10
  pnpm add @senlinz/import-export
11
11
  ```
12
12
 
13
- ## 选择使用模式
13
+ ## WASM 加载
14
14
 
15
- ### 默认模式(推荐)
16
-
17
- - 无需额外初始化。
18
- - `importExcel`、`importExcelDynamic`、`exportExcel`、`fromExcel`、`fromExcelDynamic`、`toExcel`、`downloadExcelTemplate`、`generateExcelTemplate` 会自动初始化内置 WASM 运行时。
19
- - 适合绝大多数浏览器场景。
20
-
21
- ### 高级模式
22
-
23
- - 在使用这些 Excel API 之前,先手动调用 `initializeWasm(...)`。
24
- - 适用于自定义 WASM 托管、需要自己控制 bundler 行为,或希望复用已加载 bytes / module 的场景。
25
- - 支持的手动输入:`source`、`bytes`、`module`。
26
- - 同时也导出了 `bundledWasmSource`,方便在自包含 demo / 测试中显式走手动初始化流程。
15
+ - `importExcel`、`importExcelDynamic`、`exportExcel`、`fromExcel`、`fromExcelDynamic`、`toExcel`、`downloadExcelTemplate`、`generateExcelTemplate` 会在首次调用时自动加载并初始化内置 WASM 资源。
16
+ - 在 Vite 和其他浏览器 ESM bundler 中,使用高阶 core 包时不再需要手动调用 `initializeWasm(...)` 或自己处理 `?url`。
17
+ - 如果你需要自行管理 WASM 模块,请直接使用 `@senlinz/import-export-wasm`,而不是这个高阶包。
27
18
 
28
19
  ```ts
29
- import { initializeWasm, toExcel } from '@senlinz/import-export';
30
-
31
- const wasmBytes = new Uint8Array(
32
- await (await fetch('/assets/imexport_wasm_bg.wasm')).arrayBuffer()
33
- );
34
-
35
- initializeWasm({ bytes: wasmBytes });
20
+ import { toExcel } from '@senlinz/import-export';
36
21
 
37
22
  const workbook = await toExcel({
38
23
  name: 'TomAndJerry',
@@ -40,8 +25,6 @@ const workbook = await toExcel({
40
25
  }, [{ name: 'Tom' }]);
41
26
  ```
42
27
 
43
- 如果手动传入的 WASM 输入无效,`initializeWasm(...)` 会立即抛出清晰的错误信息。
44
-
45
28
  ## 支持的 API
46
29
 
47
30
  ### 稳定的 definition 字段
@@ -175,12 +158,11 @@ const result = await fromExcelDynamic(fileBytes, {
175
158
  - 主要面向浏览器 ESM 运行时。
176
159
  - `downloadExcelTemplate`、`exportExcel`、`importExcel`、`importExcelDynamic` 依赖 DOM / 浏览器 API。
177
160
  - 当运行时提供兼容的浏览器全局对象时,也可以使用 `fromExcel`、`fromExcelDynamic`、`toExcel`、`generateExcelTemplate`。
178
- - `initializeWasm` 可用于使用调用方提供的 `source`、`bytes` 或 `module` 预初始化运行时。
161
+ - core 包会在首次执行工作簿操作前,异步初始化构建产物中的内置 WASM 资源。
179
162
 
180
163
  ## 示例
181
164
 
182
165
  - [基础浏览器示例](./examples/basic-browser.html)
183
- - [手动初始化 WASM 的浏览器示例](./examples/manual-wasm-browser.html)
184
166
  - [分组导出示例](./examples/grouped-export.html)
185
167
  - [Definition 校验示例](./examples/definition-errors.html)
186
168