@fraqjs/plugin-takumi 0.3.0 → 0.4.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/dist/index.d.mts CHANGED
@@ -8,6 +8,9 @@ interface TakumiServiceOptions {
8
8
  renderDefaults?: RenderOptions;
9
9
  onFontRegisterConflict?: 'error' | 'warn-and-ignore' | 'warn-and-replace';
10
10
  }
11
+ type RenderCallOptions = RenderOptions & {
12
+ emojiType?: EmojiType;
13
+ };
11
14
  interface PathBasedFontDetails {
12
15
  name?: string;
13
16
  path: string;
@@ -24,8 +27,8 @@ declare class TakumiService implements Disposable {
24
27
  private onFontRegisterConflict;
25
28
  constructor(options?: TakumiServiceOptions | undefined, ctx?: Context | undefined);
26
29
  registerFontFamily(family: string, fonts: (string | PathBasedFontDetails | FontLoader)[], signal?: AbortSignal): Promise<void>;
27
- renderJsx(jsx: ReactNode | ReactElementLike, renderOptions?: RenderOptions, signal?: AbortSignal, emojiType?: EmojiType): Promise<Buffer>;
28
- renderHtml(html: string, renderOptions?: RenderOptions, signal?: AbortSignal, emojiType?: EmojiType): Promise<Buffer>;
30
+ renderJsx(jsx: ReactNode | ReactElementLike, options?: RenderCallOptions): Promise<Buffer>;
31
+ renderHtml(html: string, options?: RenderCallOptions): Promise<Buffer>;
29
32
  private renderNode;
30
33
  private mergeRenderOptions;
31
34
  private mergeFonts;
@@ -42,4 +45,4 @@ interface TakumiPluginOptions extends TakumiServiceOptions {
42
45
  declare function loadBuiltinFontsForService(service: TakumiService): Promise<void>;
43
46
  declare const TakumiPlugin: import("@fraqjs/fraq").Plugin<[options?: TakumiPluginOptions | undefined], import("@fraqjs/fraq").Injection | undefined, import("@fraqjs/fraq").Injection | undefined>;
44
47
  //#endregion
45
- export { PathBasedFontDetails, TakumiPlugin, TakumiPlugin as default, TakumiPluginOptions, TakumiService, TakumiServiceOptions, loadBuiltinFontsForService };
48
+ export { PathBasedFontDetails, RenderCallOptions, TakumiPlugin, TakumiPlugin as default, TakumiPluginOptions, TakumiService, TakumiServiceOptions, loadBuiltinFontsForService };
package/dist/index.mjs CHANGED
@@ -13,9 +13,6 @@ function combineAbortSignals(...signals) {
13
13
  if (filteredSignals.length === 1) return filteredSignals[0];
14
14
  return AbortSignal.any(filteredSignals);
15
15
  }
16
- function isRemoteUrl(value) {
17
- return value.startsWith("https://") || value.startsWith("http://");
18
- }
19
16
  function getImageSources(images) {
20
17
  if (!images) return [];
21
18
  if (Array.isArray(images)) return images;
@@ -53,23 +50,23 @@ var TakumiService = class {
53
50
  signal?.throwIfAborted();
54
51
  this.registeredFontFamilies.set(family, fonts.map((font) => this.toFontLoader(family, font)));
55
52
  }
56
- async renderJsx(jsx, renderOptions, signal, emojiType) {
53
+ async renderJsx(jsx, options) {
54
+ const { emojiType, ...renderOptions } = options ?? {};
57
55
  const { node, stylesheets } = await fromJsx(jsx);
58
56
  return await this.renderNode({
59
57
  node,
60
58
  stylesheets,
61
59
  renderOptions,
62
- signal,
63
60
  emojiType
64
61
  });
65
62
  }
66
- async renderHtml(html, renderOptions, signal, emojiType) {
63
+ async renderHtml(html, options) {
64
+ const { emojiType, ...renderOptions } = options ?? {};
67
65
  const { node, stylesheets } = fromHtml(html);
68
66
  return await this.renderNode({
69
67
  node,
70
68
  stylesheets,
71
69
  renderOptions,
72
- signal,
73
70
  emojiType
74
71
  });
75
72
  }
@@ -79,13 +76,12 @@ var TakumiService = class {
79
76
  node,
80
77
  stylesheets: components.stylesheets,
81
78
  userOptions: components.renderOptions,
82
- signal: components.signal,
83
79
  images: components.emojiType !== void 0
84
80
  }));
85
81
  }
86
82
  async mergeRenderOptions(components) {
87
83
  const renderDefaults = this.options?.renderDefaults;
88
- const signal = combineAbortSignals(components.signal, components.userOptions?.signal, this.abortController.signal);
84
+ const signal = combineAbortSignals(components.userOptions?.signal, this.abortController.signal);
89
85
  const images = await this.mergeImages({
90
86
  node: components.node,
91
87
  prepareImages: components.images ?? false,
@@ -137,7 +133,7 @@ var TakumiService = class {
137
133
  }
138
134
  toFontLoader(family, font) {
139
135
  if (typeof font === "string") {
140
- if (isRemoteUrl(font)) return {
136
+ if (font.startsWith("https://") || font.startsWith("http://")) return {
141
137
  ...fontFromUrl(font),
142
138
  name: family
143
139
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fraqjs/plugin-takumi",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "Takumi integration plugin for Fraq",
6
6
  "files": [
7
7
  "dist",
@@ -19,7 +19,7 @@
19
19
  "license": "MIT",
20
20
  "peerDependencies": {
21
21
  "react": "^19.0.0",
22
- "@fraqjs/fraq": "^0.13.0"
22
+ "@fraqjs/fraq": "^0.13.2"
23
23
  },
24
24
  "dependencies": {
25
25
  "@fraqjs/takumi-builtin-fonts": "^1.0.0",