diff --git a/dist/plugin.js b/dist/plugin.js index b2b0c7f..941990b 100644 --- a/dist/plugin.js +++ b/dist/plugin.js @@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; +function __accessProp(key) { + return this[key]; +} +var __toESMCache_node; +var __toESMCache_esm; var __toESM = (mod, isNodeMode, target) => { + var canCache = mod != null && typeof mod === "object"; + if (canCache) { + var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap; + var cached = cache.get(mod); + if (cached) + return cached; + } target = mod != null ? __create(__getProtoOf(mod)) : {}; const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; for (let key of __getOwnPropNames(mod)) if (!__hasOwnProp.call(to, key)) __defProp(to, key, { - get: () => mod[key], + get: __accessProp.bind(mod, key), enumerable: true }); + if (canCache) + cache.set(mod, to); return to; }; var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); +var __returnValue = (v) => v; +function __exportSetter(name, newValue) { + this[name] = __returnValue.bind(null, newValue); +} var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true, configurable: true, - set: (newValue) => all[name] = () => newValue + set: __exportSetter.bind(all, name) }); }; var __require = /* @__PURE__ */ createRequire(import.meta.url); @@ -13615,7 +13633,7 @@ class JSONSchemaGenerator { if (val === undefined) { if (this.unrepresentable === "throw") { throw new Error("Literal `undefined` cannot be represented in JSON Schema"); - } else {} + } } else if (typeof val === "bigint") { if (this.unrepresentable === "throw") { throw new Error("BigInt literals cannot be represented in JSON Schema"); @@ -15332,8 +15350,26 @@ function walkAXTree(axNode, allNodes, byUid) { const value = axNode.value?.value; const backendNodeId = axNode.backendDOMNodeId ?? 0; const ignored = axNode.ignored; - if (ignored && !name) - return null; + if (ignored && !name) { + const childIds2 = axNode.childIds ?? []; + const children2 = []; + for (const childId of childIds2) { + const childAx = allNodes[childId]; + if (!childAx) + continue; + const childNode = walkAXTree(childAx, allNodes, byUid); + if (childNode) + children2.push(childNode); + } + if (children2.length === 0) + return null; + if (children2.length === 1) + return children2[0]; + const uid2 = nextUid++; + const node2 = { uid: uid2, role: "generic", children: children2 }; + byUid.set(uid2, node2); + return node2; + } const uid = nextUid++; const children = []; const childIds = axNode.childIds ?? []; diff --git a/src/lib/snapshot.ts b/src/lib/snapshot.ts index b99ae46..9bcc844 100644 --- a/src/lib/snapshot.ts +++ b/src/lib/snapshot.ts @@ -32,7 +32,22 @@ function walkAXTree( const backendNodeId = (axNode.backendDOMNodeId as number | undefined) ?? 0; const ignored = axNode.ignored as boolean; - if (ignored && !name) return null; + if (ignored && !name) { + const childIds = (axNode.childIds as string[] | undefined) ?? []; + const children: SnapshotNode[] = []; + for (const childId of childIds) { + const childAx = allNodes[childId]; + if (!childAx) continue; + const childNode = walkAXTree(childAx, allNodes, byUid); + if (childNode) children.push(childNode); + } + if (children.length === 0) return null; + if (children.length === 1) return children[0]; + const uid = nextUid++; + const node: SnapshotNode = { uid, role: "generic", children }; + byUid.set(uid, node); + return node; + } const uid = nextUid++; const children: SnapshotNode[] = [];