@open-feishu-card/renderer 0.2.30 → 0.2.31

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.cjs CHANGED
@@ -671,7 +671,8 @@ function resolveImageSrc(p, ctx) {
671
671
  if (p.src) return p.src;
672
672
  if (p.url) return resolveURL(p.url) || null;
673
673
  if (p.img_url) return p.img_url;
674
- if (p.imageID && ctx.options.imageBaseURL) return ctx.options.imageBaseURL + p.imageID;
674
+ const imageId = p.imageID || p.img_key;
675
+ if (imageId && ctx.options.imageBaseURL) return ctx.options.imageBaseURL + imageId;
675
676
  return null;
676
677
  }
677
678
  function resolveMediaSrc(p, kind, ctx) {
@@ -701,6 +702,7 @@ function personAvatarSrc(person, ctx) {
701
702
  const r = ctx.options.resolvePersonAvatar(person);
702
703
  if (r) return r;
703
704
  }
705
+ if (person.avatar_url) return person.avatar_url;
704
706
  if (!person.avatar_key) return null;
705
707
  const base = ctx.options.avatarBaseURL || PERSON_AVATAR_BASE;
706
708
  const suffix = ctx.options.avatarURLSuffix ?? PERSON_AVATAR_SUFFIX;
package/dist/index.d.cts CHANGED
@@ -81,6 +81,8 @@ interface ElementProperty {
81
81
  hoverTips?: CardElement;
82
82
  hasBorder?: boolean;
83
83
  imageID?: string;
84
+ /** DSL 公开字段;dslToRaw 常原样留在 property(未改名为 imageID) */
85
+ img_key?: string;
84
86
  origin_key?: string;
85
87
  src?: string;
86
88
  url?: string | LinkURL;
@@ -291,7 +293,7 @@ interface RenderOptions {
291
293
  /** 音视频地址前缀:最终 src = mediaBaseURL + fileID */
292
294
  mediaBaseURL?: string;
293
295
  /**
294
- * 人员表(open_id -> { content 姓名, avatar_key 头像 })。
296
+ * 人员表(open_id -> { content 姓名, avatar_key / avatar_url 头像 })。
295
297
  * person_v1 / person_list 元素只带 ID,姓名/头像在此反查。
296
298
  * 异步渲染(renderCardToStringAsync)会自动从 json_attachment.persons 填入;
297
299
  * 同步渲染若想出名字/头像,需手动传入。缺省时人员降级为固定头像 +「赵天雄」。
@@ -326,7 +328,8 @@ interface RenderOptions {
326
328
  * 人员信息:person_v1 / person_list / at 元素只带 ID,姓名与头像 key 在这里。
327
329
  * 取自飞书消息 content 的 json_attachment.persons(按 open_id「ou_...」索引);
328
330
  * fetchCardMessage 还会把信封 mentions 与 at_users 合并进来(含 @_user_N 别名键)。
329
- * avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE)。
331
+ * avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE);
332
+ * 本地预览也可用 avatar_url(含 data URI)直接给头像地址。
330
333
  */
331
334
  interface PersonInfo {
332
335
  person_id?: string;
@@ -335,6 +338,11 @@ interface PersonInfo {
335
338
  type?: number;
336
339
  /** 头像图 key(形如 v3_00te_...),拼 avatarBaseURL 取图 */
337
340
  avatar_key?: string;
341
+ /**
342
+ * 直接可用的头像 URL(含 data URI)。
343
+ * 本地预览虚拟用户没有飞书 avatar_key 时用这个;优先级低于 resolvePersonAvatar,高于 avatar_key。
344
+ */
345
+ avatar_url?: string;
338
346
  }
339
347
  /**
340
348
  * 消息信封上的 @ 提及(data.items[0].mentions),不在 body.content 内。
package/dist/index.d.ts CHANGED
@@ -81,6 +81,8 @@ interface ElementProperty {
81
81
  hoverTips?: CardElement;
82
82
  hasBorder?: boolean;
83
83
  imageID?: string;
84
+ /** DSL 公开字段;dslToRaw 常原样留在 property(未改名为 imageID) */
85
+ img_key?: string;
84
86
  origin_key?: string;
85
87
  src?: string;
86
88
  url?: string | LinkURL;
@@ -291,7 +293,7 @@ interface RenderOptions {
291
293
  /** 音视频地址前缀:最终 src = mediaBaseURL + fileID */
292
294
  mediaBaseURL?: string;
293
295
  /**
294
- * 人员表(open_id -> { content 姓名, avatar_key 头像 })。
296
+ * 人员表(open_id -> { content 姓名, avatar_key / avatar_url 头像 })。
295
297
  * person_v1 / person_list 元素只带 ID,姓名/头像在此反查。
296
298
  * 异步渲染(renderCardToStringAsync)会自动从 json_attachment.persons 填入;
297
299
  * 同步渲染若想出名字/头像,需手动传入。缺省时人员降级为固定头像 +「赵天雄」。
@@ -326,7 +328,8 @@ interface RenderOptions {
326
328
  * 人员信息:person_v1 / person_list / at 元素只带 ID,姓名与头像 key 在这里。
327
329
  * 取自飞书消息 content 的 json_attachment.persons(按 open_id「ou_...」索引);
328
330
  * fetchCardMessage 还会把信封 mentions 与 at_users 合并进来(含 @_user_N 别名键)。
329
- * avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE)。
331
+ * avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE);
332
+ * 本地预览也可用 avatar_url(含 data URI)直接给头像地址。
330
333
  */
331
334
  interface PersonInfo {
332
335
  person_id?: string;
@@ -335,6 +338,11 @@ interface PersonInfo {
335
338
  type?: number;
336
339
  /** 头像图 key(形如 v3_00te_...),拼 avatarBaseURL 取图 */
337
340
  avatar_key?: string;
341
+ /**
342
+ * 直接可用的头像 URL(含 data URI)。
343
+ * 本地预览虚拟用户没有飞书 avatar_key 时用这个;优先级低于 resolvePersonAvatar,高于 avatar_key。
344
+ */
345
+ avatar_url?: string;
338
346
  }
339
347
  /**
340
348
  * 消息信封上的 @ 提及(data.items[0].mentions),不在 body.content 内。
package/dist/index.js CHANGED
@@ -670,7 +670,8 @@ function resolveImageSrc(p, ctx) {
670
670
  if (p.src) return p.src;
671
671
  if (p.url) return resolveURL(p.url) || null;
672
672
  if (p.img_url) return p.img_url;
673
- if (p.imageID && ctx.options.imageBaseURL) return ctx.options.imageBaseURL + p.imageID;
673
+ const imageId = p.imageID || p.img_key;
674
+ if (imageId && ctx.options.imageBaseURL) return ctx.options.imageBaseURL + imageId;
674
675
  return null;
675
676
  }
676
677
  function resolveMediaSrc(p, kind, ctx) {
@@ -700,6 +701,7 @@ function personAvatarSrc(person, ctx) {
700
701
  const r = ctx.options.resolvePersonAvatar(person);
701
702
  if (r) return r;
702
703
  }
704
+ if (person.avatar_url) return person.avatar_url;
703
705
  if (!person.avatar_key) return null;
704
706
  const base = ctx.options.avatarBaseURL || PERSON_AVATAR_BASE;
705
707
  const suffix = ctx.options.avatarURLSuffix ?? PERSON_AVATAR_SUFFIX;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-feishu-card/renderer",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "description": "零框架依赖的飞书卡片渲染引擎:Web / DOM / SSR,输入 RAW 或公开 DSL,输出真实 DOM 或 HTML 字符串",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",