takumi-js 2.0.3 → 2.1.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
@@ -4,6 +4,7 @@
4
4
  # takumi-js
5
5
 
6
6
  **Render JSX to SVG or images. Drop-in next/og replacement.**
7
+
7
8
  OG cards, banners, and lightweight animations from one Rust engine, no headless browser required.
8
9
 
9
10
  [Documentation](https://takumi.kane.tw/docs/) · [Playground](https://takumi.kane.tw/playground)
@@ -1,7 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/backend/node.ts
3
- const loadBackend = () => import("@takumi-rs/core").catch((cause) => {
3
+ const loadNative = () => import("@takumi-rs/core").catch((cause) => {
4
4
  throw new Error("Failed to load the native @takumi-rs/core backend. On a runtime without the native addon, pass a `module` (a WASM binary) to render with the WASM backend instead.", { cause });
5
5
  });
6
+ const loadBackend = (module) => typeof process !== "undefined" && process.versions?.webcontainer ? Promise.resolve().then(() => require("./wasm.cjs")).then((backend) => backend.loadBackend(module)) : loadNative(module);
6
7
  //#endregion
7
8
  exports.loadBackend = loadBackend;
@@ -1,6 +1,7 @@
1
1
  //#region src/backend/node.ts
2
- const loadBackend = () => import("@takumi-rs/core").catch((cause) => {
2
+ const loadNative = () => import("@takumi-rs/core").catch((cause) => {
3
3
  throw new Error("Failed to load the native @takumi-rs/core backend. On a runtime without the native addon, pass a `module` (a WASM binary) to render with the WASM backend instead.", { cause });
4
4
  });
5
+ const loadBackend = (module) => typeof process !== "undefined" && process.versions?.webcontainer ? import("./wasm.mjs").then((backend) => backend.loadBackend(module)) : loadNative(module);
5
6
  //#endregion
6
7
  export { loadBackend };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "takumi-js",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "All-in-one Takumi package for Node.js and WebAssembly runtimes.",
5
5
  "keywords": [
6
6
  "css",
@@ -212,9 +212,9 @@
212
212
  "publish-lint": "attw --pack . && publint --strict ."
213
213
  },
214
214
  "dependencies": {
215
- "@takumi-rs/core": "2.0.3",
216
- "@takumi-rs/helpers": "2.0.3",
217
- "@takumi-rs/wasm": "2.0.3"
215
+ "@takumi-rs/core": "2.1.0",
216
+ "@takumi-rs/helpers": "2.1.0",
217
+ "@takumi-rs/wasm": "2.1.0"
218
218
  },
219
219
  "devDependencies": {
220
220
  "@types/bun": "^1.3.14",