@realnation/content-config 0.6.0 → 0.6.2

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
@@ -102,9 +102,9 @@ import { canvasConfig } from '@realnation/content-config/canvas';
102
102
 
103
103
  构建时检查并写 `assets/canvas-config.json`(与 `page-events.js` 同目录),不过关构建失败。规矩:
104
104
 
105
- - 键是 componentName。`kind: 'system'` 是登记在 editor_tabs.components 的;`kind: 'pushed'` 是 page-data 推的,要写 `key`、`type`、英文 `appearsWhen`,可选机器可读的 `when`(`{ 内容配置读回的请求体里的路径: 值 }`,如 `{ 'design.wheelCount': 2 }`)。
105
+ - 键是 componentName。`kind: 'system'` 是登记在 editor_tabs.components 的;`kind: 'pushed'` 是 page-data 推的,要写 `key`、`type`(平台元件类型,按钮是 `image-text`,0.6.2 起认全部类型)、英文 `appearsWhen`,可选机器可读的 `when`(`{ 内容配置读回的请求体里的路径: 值 }`,如 `{ 'design.wheelCount': 2 }`)。
106
106
  - 面板项的类型、默认值、选项、范围不写,以后台登记的 collocation 为准;`properties` 只写模块真读的属性的英文说明(宿主统一套在外框上的位置、大小、颜色、字体不列),`ignores` 列面板上有、模块不读的。
107
- - `layout`、`layoutVariants`、`key` 都从模块代码 import 同一份常量(如 placeholders.ts),不抄数字。`layout` 0.6.0 起可选:位置写在模块代码里的(模块自己会挪元件)才写;只登记在平台(collocation 的 values)的不写,默认位置以登记为准,不抄一份进来。推送元件的 key、componentName 与 `module` 要在构建用到的源码里原样找得到(另加 `src/page-events.ts`),对不上构建失败。
107
+ - `layout`、`layoutVariants`、`key` 都从模块代码 import 同一份常量(如 placeholders.ts),不抄数字。按配置里的列表一条推一个的元件(如 Video Player 每个叠加位一个),`key` 写模板 `vp-slot-{n}`(`{n}` 是模块编的序号数字,多数从 1 起,有的从 0 起,在 appearsWhen 写明),核对时查 `{n}` 前面那一截。`layout` 0.6.0 起可选:位置写在模块代码里的(模块自己会挪元件)才写;只登记在平台(collocation 的 values)的不写,默认位置以登记为准,不抄一份进来。推送元件的 key、componentName 与 `module` 要在构建用到的源码里原样找得到(另加 `src/page-events.ts`),对不上构建失败。
108
108
  - `constraints` 只写模块自己的摆放规矩:`aspect`、`minWidth`、`minHeight`、`anchorsTo`(压在谁的正中)、`overlapAllowed`、`face`(盒子里真正画东西的是贴着远离某条边的正方形,如转盘的圆,`anchorsTo` 对准它的中心,`aspect` 在那条边为左右时宽高对调)。不出屏、不压角标这类平台规矩不写在这里。
109
109
  - 说明文字一律英文。完整样例:体验仓 qiksense-lottery-spin-and-win-experience 的 `src/canvas-config.ts`。
110
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realnation/content-config",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "qiksense 模块内容配置的机器可读说明:构建时导出 content-config.json,并用字段说明校验默认请求体;0.5.0 起另导出画布说明 canvas-config.json(体验端)",
5
5
  "type": "module",
6
6
  "exports": {
package/src/canvas.d.ts CHANGED
@@ -14,12 +14,12 @@ export type CanvasWhen = Record<string, string | number | boolean | null>;
14
14
  export interface CanvasElement {
15
15
  /** system:登记在 editor_tabs.components,新建节点就有,不能删、不能复制;pushed:page-data 推出来的,编号 display-<tab>-<key> */
16
16
  kind: 'system' | 'pushed';
17
- /** pushed 必填:page-data 里的 key,引用代码里的常量 */
17
+ /** pushed 必填:page-data 里的 key,引用代码里的常量。按配置里的列表一条推一个的写模板,{n} 是模块编的序号数字(如 'vp-slot-{n}',多数从 1 起,有的从 0 起,在 appearsWhen 写明;0.6.0 起) */
18
18
  key?: string;
19
19
  /** 所在页签 id */
20
20
  tab: string;
21
- /** pushed 必填:page-data 里的 type(平台拼写 compnent) */
22
- type?: 'compnent' | 'image' | 'image-ratio-clip' | 'text' | 'video' | 'button';
21
+ /** pushed 必填:page-data 里的 type,平台元件类型(共用 SDK 的 EditorType:按钮 image-text、热区 button、平台拼写 compnent),另加图片变体 image-ratio、image-clip、image-ratio-clip */
22
+ type?: string;
23
23
  /** 英文,给 AI:访客看到什么、模块拿它做什么、运营通常怎么改 */
24
24
  description: string;
25
25
  /** pushed 必填,英文:什么配置下才推 */
package/src/canvas.mjs CHANGED
@@ -16,7 +16,15 @@ export const CANVAS_FORMAT = 1
16
16
 
17
17
  const KINDS = new Set(['system', 'pushed'])
18
18
  // page-data 里的 type(平台拼写 compnent,别「修正」)
19
- const PUSHED_TYPES = new Set(['compnent', 'image', 'image-ratio-clip', 'text', 'video', 'button'])
19
+ // 推送元件的 type:共用 SDK 的 EditorType 全部取值(平台的元件类型,按钮是 image-text、热区是 button),
20
+ // 加上模块推的图片变体 image-ratio、image-clip、image-ratio-clip(0.6.2 起放开,原来只认六种,AR 的按钮、问答的 formtext 过不了)
21
+ const PUSHED_TYPES = new Set([
22
+ 'text', 'image', 'image-text', 'video', 'bg', 'compnent', 'qr', 'button', 'list', 'rank', 'score', 'timeout',
23
+ 'shape-rect', 'shape-ellipse', 'shape-line', 'short-answer', 'paragraph', 'single-choice', 'multiple-choice', 'dropdown',
24
+ 'linear-scale', 'rating', 'multiple-choice-grid', 'tick-box-grid', 'date', 'time', 'formtext', 'image-frame', 'link',
25
+ 'progress', 'sound-toggle', 'motion-preview', 'cursor-area', 'evoucher-pin', 'evoucher-submit',
26
+ 'image-ratio', 'image-clip', 'image-ratio-clip',
27
+ ])
20
28
  const ELEMENT_KEYS = new Set(['kind', 'key', 'tab', 'type', 'description', 'appearsWhen', 'when', 'layout', 'layoutVariants', 'styleFrom', 'properties', 'ignores', 'assets', 'constraints'])
21
29
  const BOX_KEYS = ['x-position', 'y-position', 'width', 'height']
22
30
  const ASSET_SOURCES = new Set(['from config', 'operator', 'none'])
@@ -175,7 +183,13 @@ export function checkCanvasNames(spec, root, { files = [], exclude = [] } = {})
175
183
  for (const [name, el] of Object.entries(spec.elements ?? {})) {
176
184
  if (el?.kind !== 'pushed') continue
177
185
  if (!has(name)) missing.push(`elements.${name}:推送元件的 componentName 在源码里找不到`)
178
- if (isText(el.key) && !has(el.key)) missing.push(`elements.${name}.key:${el.key} 在源码里找不到`)
186
+ if (!isText(el.key)) continue
187
+ // 0.6.0 起 key 可以是模板(按配置里的列表一条推一个,如 vp-slot-{n}):查 {n} 前面那一截,代码里多半是模板字面量 `vp-slot-${…}`
188
+ const cut = el.key.indexOf('{n}')
189
+ if (cut >= 0) {
190
+ const prefix = el.key.slice(0, cut)
191
+ if (!prefix || !all.includes(prefix)) missing.push(`elements.${name}.key:模板 ${el.key} 的前缀「${prefix}」在源码里找不到`)
192
+ } else if (!has(el.key)) missing.push(`elements.${name}.key:${el.key} 在源码里找不到`)
179
193
  }
180
194
  return missing
181
195
  }