> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 针对自定义 CSS 和 JS 的 Web SDK 1.11 升级检查

> 在 VTEX 中的 Yuno checkout 从 Web SDK 1.6 迁移到 1.11 之前，找出针对旧 yuno-* class 和 id 名称的自定义 checkout CSS 和 JS。

VTEX 中的 Yuno checkout 将从 Web SDK 1.6 迁移到 Web SDK 1.11。自 Web SDK 1.9 起，SDK 渲染的每个 class 和 id 都命名为 `sdk-payments-*`，而不是 `yuno-*` 或 `Yuno-*`。例如，`Yuno-accordion__heading` 变为 `sdk-payments-accordion__heading`。

升级后不会抛出任何错误。针对旧名称的自定义 CSS 和 JS 只是不再生效：隐藏的元素会重新显示，重新设置样式的按钮会恢复默认样式，读取某个元素的脚本什么也找不到。

以下名称仍然有效：

* `window.Yuno` 和 `yuno-sdk-ready` 事件，它们作为别名保留。
* 由 VTEX 层拥有的名称，例如 `yuno-checkout-root`、`yuno-form-root`、`yuno-external-button-root`、`yuno-sdk-web-vtex-app` 以及快捷按钮 class（`yuno-google-pay-button`、`yuno-samsung-pay-button` 及其分组）。

请在升级覆盖您的店铺之前，使用以下三种检查之一。

## 选项 1：在线上 checkout 中运行控制台代码片段

使用此方法检查线上店铺加载的内容，包括来自您的主题和应用的 CSS。

**1. 在支付步骤打开 checkout**

在 Chrome 中打开您店铺的 checkout，进入支付步骤，并确保 Yuno 表单可见。

**2. 将代码片段粘贴到 DevTools 控制台**

打开 DevTools，进入 **Console** 标签页，粘贴代码片段并按 Enter。

**3. 阅读表格**

该代码片段会打印页面上的 SDK 包、一个列出所有使用 `yuno-*` 名称的 CSS 规则和内联脚本的表格，以及在 1.11 上失效的选择器数量。对于已重命名的选择器，`on_1_11` 列显示 `BREAKS -> <new name>`；对于没有对应名称的名称，显示 `BREAKS (removed)`；其他情况下显示 `ok` 或 `not an SDK name`。

```js yuno-upgrade-check.browser.js theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
/* Paste in the DevTools console of the live checkout page (payment step open). Reports the SDK
   version on the page and every same-origin CSS rule / inline script that targets a yuno-* name. */
(async () => {
  const MAP_URL = 'https://docs.y.uno/files/validators/web-sdk-1.11-upgrade-check/rename-map.json';
  let map = null;
  try { const r = await fetch(MAP_URL); if (r.ok) map = await r.json(); } catch {}
  if (!map || !map.names) { console.error('[yuno-check] could not load the rename map from', MAP_URL, ': no verdicts given. Check the network tab (CSP, offline) and run again.'); return; }
  const src = [...document.scripts].map(s => s.src).find(s => /sdk-web[^/]*\.y\.uno\/v\d/.test(s)) || '';
  console.log('[yuno-check] SDK bundle on page:', src || 'none found', '| window.Yuno:', !!window.Yuno, '| SdkPayments:', !!window.SdkPayments);
  const hits = [];
  for (const ss of document.styleSheets) { let rules; try { rules = ss.cssRules; } catch { console.warn('[yuno-check] cannot read (cross-origin), check by hand:', ss.href); continue; }
    for (const r of rules) { const t = r.selectorText || r.cssText; for (const m of (t || '').matchAll(/\b[yY]uno-[A-Za-z0-9_-]+/g)) hits.push({ where: ss.href || 'inline <style>', name: m[0], rule: r.selectorText }); } }
  for (const s of document.scripts) if (!s.src) for (const m of s.textContent.matchAll(/\b[yY]uno-[A-Za-z0-9_-]+/g)) hits.push({ where: 'inline <script>', name: m[0] });
  const names = Object.keys(map.names);
  const verdict = n => { const base = map.names[n] ? n : names.filter(k => n.startsWith(k) && /^(__|--)/.test(n.slice(k.length))).sort((a, b) => b.length - a.length)[0]; const e = base && map.names[base]; return !e ? 'not an SDK name' : e.status === 'renamed' ? 'BREAKS -> ' + n.replace(base, e.to) : e.status === 'removed' ? 'BREAKS (removed)' : 'ok'; };
  console.table(hits.map(h => ({ ...h, on_1_11: verdict(h.name) })));
  console.log('[yuno-check]', hits.filter(h => verdict(h.name).startsWith('BREAKS')).length, 'selectors break on SDK 1.11', '(', hits.length, 'yuno-looking names found )');
})();
```

该代码片段会从 docs.y.uno 获取重命名映射，因此控制台需要能够通过网络访问该主机。如果无法加载映射，它会因错误而停止，而不是报告无问题的结果。

该代码片段无法读取从其他源提供的样式表。它会将每个此类样式表列为警告，因此请手动检查这些文件，或使用下面的扫描器检查。

## 选项 2：在您的文件上运行扫描器

将此方法用于您编辑的文件：`checkout6-custom.css`、`checkout6-custom.js`、主题文件夹或 VTEX IO 应用。它需要 Node.js 18 或更高版本。

**1. 将扫描器保存为文件**

将下面的脚本复制到名为 `yuno-upgrade-check.mjs` 的文件中。它会自行从 docs.y.uno 加载重命名映射；如需离线运行，请将 [重命名映射](https://docs.y.uno/files/validators/web-sdk-1.11-upgrade-check/rename-map.json) 下载到该文件旁边，或将 `YUNO_RENAME_MAP` 指向该文件。

```js yuno-upgrade-check.mjs theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
#!/usr/bin/env node
// Yuno Web SDK 1.6 -> 1.11 pre-upgrade check for merchant custom CSS/JS.
// Usage: node yuno-upgrade-check.mjs <file-or-dir> [...more]
// Scans .css .scss .less .js .mjs .ts .jsx .tsx .html .vue .liquid .hbs for yuno-* / Yuno-* names and
// reports, per hit, what happens to that name on SDK 1.11. Exit code 1 when something breaks.
// The rename map is read from ./rename-map.json next to this script when present, or from
// YUNO_RENAME_MAP, or fetched from docs.y.uno.
import fs from 'node:fs'; import path from 'node:path';
const MAP_URL = 'https://docs.y.uno/files/validators/web-sdk-1.11-upgrade-check/rename-map.json';
async function loadMap() {
  const local = process.env.YUNO_RENAME_MAP || new URL('./rename-map.json', import.meta.url);
  try { return JSON.parse(fs.readFileSync(local, 'utf8')); } catch {}
  const res = await fetch(MAP_URL);
  if (!res.ok) throw new Error(`cannot load the rename map (${res.status}) from ${MAP_URL}; download it next to this script`);
  return res.json();
}
const MAP = await loadMap();
const EXT = new Set(['.css','.scss','.less','.js','.mjs','.ts','.jsx','.tsx','.html','.vue','.liquid','.hbs']);
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'build']);
const files = [];
const walk = (p) => {
  const st = fs.statSync(p);
  if (st.isDirectory()) {
    for (const f of fs.readdirSync(p)) {
      if (SKIP_DIRS.has(f)) continue; // skip only folders inside the argument, never the argument itself
      walk(path.join(p, f));
    }
  } else if (EXT.has(path.extname(p))) files.push(p);
};
process.argv.slice(2).forEach(a => walk(a));
const NAMES = Object.keys(MAP.names);
const lookup = name => {
  if (MAP.names[name]) return [name, MAP.names[name]];
  // BEM modifier or element of a known block: yuno-status__title--small -> yuno-status__title
  const base = NAMES.filter(k => name.startsWith(k) && /^(__|--)/.test(name.slice(k.length))).sort((a, b) => b.length - a.length)[0];
  return base ? [base, MAP.names[base]] : [null, null];
};
const rows = []; const seen = new Set();
for (const f of files) {
  fs.readFileSync(f, 'utf8').split('\n').forEach((line, i) => {
    for (const m of line.matchAll(/\b[yY]uno-[A-Za-z0-9_-]+/g)) {
      const name = m[0]; const [base, entry] = lookup(name);
      let status, action;
      if (!entry) { status = 'not-sdk'; action = 'not a Yuno SDK 1.6 name: likely your own id/class, no change'; }
      else if (entry.status === 'renamed') { status = 'BREAKS'; action = `rename to ${name.replace(base, entry.to)}`; }
      else if (entry.status === 'removed') { status = 'BREAKS'; action = 'element no longer exists under this name in 1.11: re-check the selector on the 1.11 DOM'; }
      else if (entry.status === 'vtex-layer') { status = 'ok'; action = 'VTEX layer name, unchanged'; }
      else { status = 'ok'; action = 'unchanged (alias kept)'; }
      if (entry?.note && status === 'BREAKS') action += ` (${entry.note})`;
      const key = `${f}:${i + 1}:${name}`; if (seen.has(key)) continue; seen.add(key);
      rows.push({ file: f, line: i + 1, name, status, action });
    }
  });
}
const breaks = rows.filter(r => r.status === 'BREAKS');
for (const r of rows) console.log(`${r.status.padEnd(7)} ${r.file}:${r.line}  ${r.name}  ->  ${r.action}`);
console.log(`\n${files.length} files scanned, ${rows.length} Yuno-looking names, ${breaks.length} break on 1.11.`);
console.log(breaks.length ? 'Fix the BREAKS lines before the upgrade, then test on sandbox (SDK 1.11).' : 'Nothing here depends on the old names.');
process.exit(breaks.length ? 1 : 0);
```

**2. 在您的文件或文件夹上运行**

```bash theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
node yuno-upgrade-check.mjs checkout6-custom.css checkout6-custom.js my-theme
```

它会扫描 `.css`、`.scss`、`.less`、`.js`、`.mjs`、`.ts`、`.jsx`、`.tsx`、`.html`、`.vue`、`.liquid` 和 `.hbs` 文件，并跳过您传入路径中的 `node_modules`、`dist` 和 `build` 文件夹（您显式传入的路径始终会被扫描）。仅开头与 SDK 名称相似的商户名称（例如 `yuno-checkout-banner`）会被报告为 `not-sdk`。

**3. 阅读结果**

每一行显示状态、文件和行、名称以及需要执行的操作。当至少有一个名称在 1.11 上失效时，退出码为 `1`，否则为 `0`，因此您可以在 CI 中运行它。

输出示例：

```text theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
ok      store/checkout6-custom.css:1  yuno-checkout-root  ->  VTEX layer name, unchanged
BREAKS  store/checkout6-custom.css:2  Yuno-accordion__heading  ->  rename to sdk-payments-accordion__heading
BREAKS  store/checkout6-custom.css:3  Yuno-apple-pay__button  ->  element no longer exists under this name in 1.11: re-check the selector on the 1.11 DOM
not-sdk store/checkout6-custom.css:4  yuno-my-banner  ->  not a Yuno SDK 1.6 name: likely your own id/class, no change

1 files scanned, 4 Yuno-looking names, 2 break on 1.11.
Fix the BREAKS lines before the upgrade, then test on sandbox (SDK 1.11).
```

## 选项 3：重命名映射

[重命名映射](https://docs.y.uno/files/validators/web-sdk-1.11-upgrade-check/rename-map.json) 是两个工具都会读取的 JSON 文件。您可以用它手动查找名称，或构建您自己的检查。它列出了 Web SDK 1.6 包中找到的 222 个 class 和 id 名称，以及不会变化的 VTEX 层名称：

| 状态 | 数量 | 含义 |
| - | - | - |
| `renamed` | 192 | 该名称在 1.11 中以 `sdk-payments-*` 形式存在。`to` 字段给出新名称。 |
| `removed` | 23 | 1.11 中不存在具有同名对应名称的元素。 |
| `unchanged` | 7 | 该名称在 1.11 中仍然存在。 |
| `vtex-layer` | 45 | 由 VTEX 层拥有，不会变化。 |

不在映射中的名称不是 SDK 1.6 名称。它很可能是您自己的 id 或 class，无需更改。

## 发现匹配项时如何处理

1. **已重命名**：在您的 CSS 或 JS 中将旧名称替换为新名称。需要在升级前后都生效的选择器可以同时列出两个名称，例如 `.Yuno-accordion__heading, .sdk-payments-accordion__heading`。
2. **已移除**：在 sandbox 中打开 Web SDK 1.11 上的 checkout，找到您的规则原本针对的元素，并针对 1.11 DOM 编写选择器。该元素的结构可能不同，也可能已不存在。
3. **在生产环境之前测试**：请您的技术客户经理在 Web SDK 1.11 上、应用您的自定义文件的情况下，对您的 checkout 进行 sandbox 测试。

> [!NOTE]
>
> 同样的重命名适用于任何从 Web SDK 1.6、1.7 或 1.8 迁移到 1.9 或更高版本的商户，无论是否在 VTEX 中。扫描器和重命名映射对这些集成的工作方式相同。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.