@yaoxiu/marketing-dsl 1.2.0 → 1.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/README.md CHANGED
@@ -38,6 +38,26 @@ if (!result.valid) {
38
38
  // warnings 不阻断保存,但该提示运营,比如样式属性不在白名单里会被忽略
39
39
  ```
40
40
 
41
+ #### 埋点事件名(`track` 动作的 `event`)有格式要求
42
+
43
+ ```
44
+ ^[a-z][a-z0-9_]{2,63}$
45
+ ```
46
+
47
+ 小写字母开头,之后只能是小写字母、数字、下划线,总长 3~64 个字符。
48
+ 不合规是 **error,直接阻断保存**(导出为 `TRACK_EVENT_PATTERN`,编辑器可复用同一份正则做即时提示)。
49
+
50
+ | ✅ 正确 | ❌ 错误 | 为什么 |
51
+ | -------------------- | -------------------- | -------------------------- |
52
+ | `banner_renew_click` | `续费点击` | 不能用中文 |
53
+ | `popup_show` | `bannerRenewClick` | 不能用驼峰 / 大写字母 |
54
+ | `countdown_end` | `banner-renew-click` | 不能用中划线(下划线分词) |
55
+ | `cta_click_v2` | `cta`(不足 3 字符) | 太短,聚合时看不出是什么 |
56
+
57
+ 建议命名:`坑位_业务_动作`,如 `popup_vip_renew_click`。**不做白名单**——事件名由运营自由定义,
58
+ 只统一格式;后端按前缀聚合,格式乱了就没法分组。这个名字最终会作为 `extra.name` 上报
59
+ (见 platform-adapters 的 `base-service/marketing/README.md`「上报字段契约」)。
60
+
41
61
  ### 2. 渲染
42
62
 
43
63
  一般不直接用,交给框架壳。自己接的话是这样:
@@ -84,7 +104,9 @@ unsubscribe();
84
104
  onMaskClick: fn,
85
105
  layerStyle: {...}, maskStyle: {...}, scrollStyle: {...},
86
106
  stageStyle: {...}, clipStyle: {...},
87
- closeButton: { key, tag, style, onClick, text },
107
+ // 默认图标是内联 SVG 画的两条交叉线('×' 字符的字形偏下,肉眼可见);
108
+ // 运营配了 icon 走 text,配了 image 走 img
109
+ closeButton: { key, tag, style, onClick, children },
88
110
  nodes: [{ key: 'main-0', tag: 'div', style: {...}, onClick: fn, children: [...] }],
89
111
  }],
90
112
  countdownEndTimes: [], // 有倒计时时运行时会自己起定时器
@@ -116,3 +138,23 @@ unsubscribe();
116
138
  ## 完整 DSL 语法
117
139
 
118
140
  见调试台的「开发文档」页,或从那里导出 markdown / AI 提示词。
141
+
142
+ 文档正文本身也在这个包里,走**子路径**引入——正文有几十 KB,业务侧只用运行时,
143
+ 不该背这份体积,所以它不在主入口:
144
+
145
+ ```ts
146
+ import {
147
+ sections,
148
+ meta,
149
+ examples,
150
+ toMarkdown,
151
+ buildAiPrompt,
152
+ } from '@yaoxiu/marketing-dsl/docs';
153
+
154
+ toMarkdown(sections, meta); // 导出 .md
155
+ buildAiPrompt(); // 生成喂给 AI 的提示词
156
+ ```
157
+
158
+ 章节正文是**数据**(`DocBlock` 数组)不是字符串:调试台按块渲染成页面,`toMarkdown` 导出成 markdown,
159
+ 同一份内容两边永远一致。节点类型 / 动作 / 样式白名单 / 埋点事件名正则等清单一律从解释器常量取,
160
+ 并经 `reconcileRows` 对账——解释器加了东西而文档没跟上,会在文档页面上直接标出来。