@lark-apaas/miaoda-coding-sdk 0.0.21 → 0.0.22-alpha.20261201140700
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.en-US.md +75 -0
- package/README.md +22 -9
- package/dist/design-runtime.dev.js +639 -140
- package/dist/design-runtime.js +639 -140
- package/dist/design-runtime.min.js +1 -1
- package/dist/doubao-html-runtime.dev.js +1111 -240
- package/dist/doubao-html-runtime.js +1111 -240
- package/dist/doubao-html-runtime.min.js +23 -1
- package/dist/doubao-runtime.dev.js +761 -80
- package/dist/doubao-runtime.js +761 -80
- package/dist/doubao-runtime.min.js +3 -3
- package/dist/runtime.dev.js +747 -202
- package/dist/runtime.js +747 -202
- package/dist/runtime.min.js +3 -3
- package/package.json +5 -4
package/README.en-US.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @lark-apaas/miaoda-coding-sdk
|
|
2
|
+
|
|
3
|
+
[中文](./README.md) | English
|
|
4
|
+
|
|
5
|
+
A CDN-distributed package for the **build-free HTML tech stack**. Each entry is a self-contained IIFE bundle: include it directly in HTML with `<script src>` and it mounts its own global variable, with no build step required.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Reference it unpkg-style (the CDN domain is TBD; the version is part of the URL, so pinning an exact version is recommended):
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Development: unminified, no automatic reporting (NODE_ENV=development), easier to debug -->
|
|
13
|
+
<script src="https://<cdn>/@lark-apaas/miaoda-coding-sdk@0.0.1/dist/runtime.dev.js"></script>
|
|
14
|
+
|
|
15
|
+
<!-- Production: minified, automatically reports one page VIEW on load (NODE_ENV=production) -->
|
|
16
|
+
<script src="https://<cdn>/@lark-apaas/miaoda-coding-sdk@0.0.1/dist/runtime.min.js"></script>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
// Mounted on window.MiaodaRuntime once loaded
|
|
20
|
+
console.log(window.MiaodaRuntime.version);
|
|
21
|
+
// Manually report a custom tracking event
|
|
22
|
+
window.MiaodaRuntime.reportTeaEvent({ trackKey: 'my_event', trackParams: { foo: 'bar' } });
|
|
23
|
+
</script>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> Each entry is built in three variants: `<name>.dev.js` (development, unminified) / `<name>.js` (production, unminified) / `<name>.min.js` (production, minified). `window.collectEvent` (the TEA collection SDK) is injected by the host; if it is not injected, calls are silent no-ops.
|
|
27
|
+
|
|
28
|
+
## Entries
|
|
29
|
+
|
|
30
|
+
| Entry | Files | Global variable | Status |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| runtime | `dist/runtime.dev.js` / `.js` / `.min.js` | `window.MiaodaRuntime` | ✅ TEA event reporting |
|
|
33
|
+
| doubao-runtime | `dist/doubao-runtime.dev.js` / `.js` / `.min.js` | `window.MiaodaRuntime` | ✅ runtime + Doubao watermark |
|
|
34
|
+
|
|
35
|
+
> `runtime` and `doubao-runtime` are **mutually exclusive**: apps originating from Doubao include `doubao-runtime.js` (which additionally injects the 「由 豆包AI 生成」 ("Generated by Doubao AI") watermark in the bottom-right corner); all others include `runtime.js`. Both expose the same API (`window.MiaodaRuntime`).
|
|
36
|
+
>
|
|
37
|
+
> Planned (not yet implemented): business entries such as `performance` / `helm` / `desk`, added as needed (add an item to ENTRIES + create `src/<name>.ts`).
|
|
38
|
+
|
|
39
|
+
## Design Notes
|
|
40
|
+
|
|
41
|
+
- Each entry is **self-contained and independent**: all dependencies are inlined, and each occupies its own global variable (there is no shared namespace).
|
|
42
|
+
- Output is pure **IIFE**, exposed only through globals via `<script>`; no ESM/CJS/UMD builds are provided.
|
|
43
|
+
- Built with `tsup` (an array config, with a separate `globalName` per entry). Each entry produces `.dev.js` / `.js` / `.min.js` (`process.env.NODE_ENV` distinguishes dev/online). No sourcemaps are generated (source maps are not exposed in public distribution).
|
|
44
|
+
- **Adding an entry**: add an item to `ENTRIES` in `tsup.config.ts` and create the corresponding `src/<name>.ts`.
|
|
45
|
+
|
|
46
|
+
See the design doc `docs/superpowers/specs/2026-06-05-miaoda-coding-sdk-design.md` for details.
|
|
47
|
+
|
|
48
|
+
## Brand, Settings and i18n
|
|
49
|
+
|
|
50
|
+
* **Settings read**: the report page, landing page, Doubao download link, image CDN, TEA parameters and the creative-mode Slardar URL come from `@lark-apaas/miaoda-common-settings` (Feishu defaults are built in). Since this package is loaded from a CDN without a build step, injected settings can only be provided by the host page writing `window.MIAODA_APP_SETTINGS` before this package's script (supported by coding-html-devserver; page_server integration is pending).
|
|
51
|
+
|
|
52
|
+
Missing fields use shared defaults; empty URLs below mean explicitly configured empty strings.
|
|
53
|
+
|
|
54
|
+
| Setting | Purpose | When empty |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `domainConf.tnsReportUrl` | Report page opened by "Report" in the watermark menu (with a `lang` parameter for the current language) | Report menu item is hidden |
|
|
57
|
+
| `domainConf.landingUrl` | "Learn about Spark" in the watermark menu | Hide “Learn about Spark” |
|
|
58
|
+
| `domainConf.staticCdn` | CDN prefix for the Miaoda / Doubao logo images on the watermark | Empty image URL |
|
|
59
|
+
| `doubaoConf.name` | Product name on the Doubao watermark (per language: `zh-CN` / `en-US`) | — |
|
|
60
|
+
| `doubaoConf.brandImage` | Brand text image on the Doubao watermark | — |
|
|
61
|
+
| `doubaoConf.downloadUrl` | "Download" in the Doubao watermark menu | Not opened |
|
|
62
|
+
| `apm.tea` | TEA init parameters (`appId`, `channel`) | TEA is not initialized |
|
|
63
|
+
| `apm.slardar.sdkUrl` / `apm.slardar.bid` | Slardar script URL and bid for design-runtime | An empty sdkUrl skips loading if the page has no Slardar instance; an existing instance is initialized, and an empty bid does not control loading |
|
|
64
|
+
|
|
65
|
+
TEA and creative-mode Slardar report the same uppercase label from `readSettings('env')`: `BOE / PRE / ONLINE`.
|
|
66
|
+
|
|
67
|
+
* **Text language**: the only text is the watermark (seen by end users), which follows the UI language: the browser language online, and during preview the `locale` parameter passed by the main site (remembered in localStorage, then the browser language). Whether the page is online is decided by `window.appEnv` (the renderer inlines the same production build for preview and online).
|
|
68
|
+
* **Verification**: `src/__tests__/overseas-feishu.test.ts` (covers Feishu defaults, watermark, links, TEA and Slardar; missing environments and aliases follow the shared rules), `src/__tests__/overseas-lark.test.ts` (no Chinese or domestic addresses in JP with an English UI).
|
|
69
|
+
|
|
70
|
+
## Local Verification
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
yarn workspace @lark-apaas/miaoda-coding-sdk build
|
|
74
|
+
# Open examples/runtime.html in a browser; the console should print the runtime info
|
|
75
|
+
```
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @lark-apaas/miaoda-coding-sdk
|
|
2
2
|
|
|
3
|
+
中文 | [English](./README.en-US.md)
|
|
4
|
+
|
|
3
5
|
面向**无编译 HTML 技术栈**的 CDN 分发包。每个 entry 是一份自包含的 IIFE 产物,HTML 直接通过 `<script src>` 引入即用,挂载为独立的全局变量——无需任何构建步骤。
|
|
4
6
|
|
|
5
7
|
## 用法
|
|
@@ -29,14 +31,12 @@
|
|
|
29
31
|
|---|---|---|---|
|
|
30
32
|
| runtime | `dist/runtime.dev.js` / `.js` / `.min.js` | `window.MiaodaRuntime` | ✅ TEA 埋点上报 |
|
|
31
33
|
| doubao-runtime | `dist/doubao-runtime.dev.js` / `.js` / `.min.js` | `window.MiaodaRuntime` | TEA/PV 埋点、豆包水印、端内 feed 红点消除 |
|
|
32
|
-
| doubao-html-runtime | `dist/doubao-html-runtime.dev.js` / `.js` / `.min.js` | `window.MiaodaRuntime` | 豆包通用能力 + JSX
|
|
34
|
+
| doubao-html-runtime | `dist/doubao-html-runtime.dev.js` / `.js` / `.min.js` | `window.MiaodaRuntime` | 豆包通用能力 + JSX 定位与评论 |
|
|
33
35
|
|
|
34
36
|
> 各 runtime 入口**互斥引用**:豆包 HTML(AppType 9 + ArchType 4)引 `doubao-html-runtime.js`,豆包 jspage 等其他豆包页面继续引 `doubao-runtime.js`,其余引 `runtime.js`。基础 API 均挂在 `window.MiaodaRuntime`,只有豆包 HTML 入口导出 `comments`。历史 7+4 与创意模式的入口选择保持不变。
|
|
35
37
|
>
|
|
36
38
|
> 规划中(尚未实现):`performance` / `helm` / `desk` 等业务 entry,按需新增(ENTRIES 加一项 + 建 `src/<name>.ts`)。
|
|
37
39
|
|
|
38
|
-
豆包 HTML 的 Page Server 只负责创建可信 `/iframe`、下发 `window.appId`、精确的 `window.__miaodaCommentIframeOrigin__` 和服务端票据;`doubao-html-runtime` 仅在精确 origin 存在时接管父页侧的 share ready/init/clip/scroll-lock/login/logout 协议。Page Server 只会在 TCC `doubaoHtmlShareHostEnabled=true` 且专用 runtime 实际拉取成功时下发该 origin;旧版本或旧 runtime 组合不会启用新 bridge。登录 URL 仍由服务端接口生成,runtime 只接受固定 HTTPS OAuth host/path,不在浏览器拼 OAuth 参数。
|
|
39
|
-
|
|
40
40
|
## 设计要点
|
|
41
41
|
|
|
42
42
|
- 每个 entry **自包含、互不依赖**,依赖全部 inline,各占一个独立全局变量(不收口统一命名空间)。
|
|
@@ -46,14 +46,27 @@
|
|
|
46
46
|
|
|
47
47
|
详见设计文档 `docs/superpowers/specs/2026-06-05-miaoda-coding-sdk-design.md`。
|
|
48
48
|
|
|
49
|
-
##
|
|
49
|
+
## 品牌、配置与多语
|
|
50
|
+
|
|
51
|
+
* **读了哪些配置**:举报页、落地页、下载豆包链接、图片 CDN、TEA 参数、创意模式 Slardar 地址取自 `@lark-apaas/miaoda-common-settings` 的配置(飞书默认值内置)。本包从 CDN 加载、不经过构建,下发的配置只能由宿主页面在本包脚本之前写入 `window.MIAODA_APP_SETTINGS`(coding-html-devserver 已支持;page_server 待接入)。
|
|
52
|
+
|
|
53
|
+
缺失字段由基础包补默认值;下面的空地址指显式配置为空字符串。
|
|
54
|
+
|
|
55
|
+
| 配置 | 用途 | 为空时 |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `domainConf.tnsReportUrl` | 水印菜单「投诉与举报」打开的举报页(带 `lang` 参数,按当前语言) | 隐藏举报菜单项 |
|
|
58
|
+
| `domainConf.landingUrl` | 水印菜单「了解妙搭」 | 隐藏「了解妙搭」 |
|
|
59
|
+
| `domainConf.staticCdn` | 水印上妙搭 / 豆包 logo 图片的 CDN 前缀 | 图片地址为空 |
|
|
60
|
+
| `doubaoConf.name` | 豆包水印上的产品名(按语言取 `zh-CN` / `en-US`) | — |
|
|
61
|
+
| `doubaoConf.brandImage` | 豆包水印上的品牌字图 | — |
|
|
62
|
+
| `doubaoConf.downloadUrl` | 豆包水印菜单「下载」 | 不打开 |
|
|
63
|
+
| `apm.tea` | TEA 初始化参数(`appId`、`channel`) | 不初始化 TEA |
|
|
64
|
+
| `apm.slardar.sdkUrl` / `apm.slardar.bid` | design-runtime 的 Slardar 脚本地址和 bid | sdkUrl 为空且页面没有 Slardar 实例时不加载;已有实例继续初始化,bid 为空不控制加载 |
|
|
50
65
|
|
|
51
|
-
|
|
66
|
+
TEA 和创意模式 Slardar 都使用 `readSettings('env')` 对应的大写标签 `BOE / PRE / ONLINE`。
|
|
52
67
|
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
- 同时追加把顶层 `const` / `let` / `class` 降成 `var`、块内函数声明提到外层的插件组:产物靠顶层声明跨脚本共享,只补 targets 会白屏。插件按本体去重,作者写的 `proposal-*` 旧名不会和追加的 `transform-*` 冲突。
|
|
56
|
-
- 未注入、写法不合规、Babel 不认、当前浏览器低于配置的版本、作者已写 `data-targets` / `data-presets`、`data-type="module"` 时都不改,与现状一致。
|
|
68
|
+
* **文案跟随什么语言**:本包只有水印文案(最终用户可见),跟随界面语言:线上看浏览器语言,预览时看主站透传的 `locale` 参数(记到 localStorage,之后再看浏览器语言)。是否线上按 `window.appEnv` 判断(渲染服务预览和线上内联的是同一份生产构建)。
|
|
69
|
+
* **验收**:`src/__tests__/overseas-feishu.test.ts`(覆盖飞书默认水印、跳转、TEA 和 Slardar;缺省环境及别名按基础包统一规则验证)、`src/__tests__/overseas-lark.test.ts`(JP 区域、英文界面下无中文和国内地址)。
|
|
57
70
|
|
|
58
71
|
## 本地验证
|
|
59
72
|
|