browser-debugger-cli 0.6.7 → 0.6.9
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/dist/__tests__/telemetry/filterDsl.unit.test.d.ts +12 -0
- package/dist/__tests__/telemetry/filterDsl.unit.test.d.ts.map +1 -0
- package/dist/__tests__/telemetry/filterDsl.unit.test.js +374 -0
- package/dist/__tests__/telemetry/filterDsl.unit.test.js.map +1 -0
- package/dist/__tests__/telemetry/filterPresets.unit.test.d.ts +10 -0
- package/dist/__tests__/telemetry/filterPresets.unit.test.d.ts.map +1 -0
- package/dist/__tests__/telemetry/filterPresets.unit.test.js +89 -0
- package/dist/__tests__/telemetry/filterPresets.unit.test.js.map +1 -0
- package/dist/commands/__tests__/console.contract.test.d.ts +9 -0
- package/dist/commands/__tests__/console.contract.test.d.ts.map +1 -0
- package/dist/commands/__tests__/console.contract.test.js +118 -0
- package/dist/commands/__tests__/console.contract.test.js.map +1 -0
- package/dist/commands/cleanup.js +1 -1
- package/dist/commands/cleanup.js.map +1 -1
- package/dist/commands/console.d.ts +26 -0
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +195 -57
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/details.js +1 -1
- package/dist/commands/details.js.map +1 -1
- package/dist/commands/dom/DomElementResolver.js +2 -2
- package/dist/commands/dom/DomElementResolver.js.map +1 -1
- package/dist/commands/dom/a11y.d.ts.map +1 -1
- package/dist/commands/dom/a11y.js +30 -18
- package/dist/commands/dom/a11y.js.map +1 -1
- package/dist/commands/dom/formFillHelpers.d.ts.map +1 -1
- package/dist/commands/dom/formFillHelpers.js +64 -2
- package/dist/commands/dom/formFillHelpers.js.map +1 -1
- package/dist/commands/dom/formInteraction.js +4 -4
- package/dist/commands/dom/formInteraction.js.map +1 -1
- package/dist/commands/dom/helpers.d.ts +1 -1
- package/dist/commands/dom/helpers.d.ts.map +1 -1
- package/dist/commands/dom/helpers.js +3 -3
- package/dist/commands/dom/helpers.js.map +1 -1
- package/dist/commands/dom/index.d.ts.map +1 -1
- package/dist/commands/dom/index.js +4 -1
- package/dist/commands/dom/index.js.map +1 -1
- package/dist/commands/network/har.d.ts +14 -0
- package/dist/commands/network/har.d.ts.map +1 -0
- package/dist/commands/network/har.js +97 -0
- package/dist/commands/network/har.js.map +1 -0
- package/dist/commands/network/index.d.ts +18 -0
- package/dist/commands/network/index.d.ts.map +1 -0
- package/dist/commands/network/index.js +27 -0
- package/dist/commands/network/index.js.map +1 -0
- package/dist/commands/network/list.d.ts +14 -0
- package/dist/commands/network/list.d.ts.map +1 -0
- package/dist/commands/network/list.js +273 -0
- package/dist/commands/network/list.js.map +1 -0
- package/dist/commands/network/shared.d.ts +56 -0
- package/dist/commands/network/shared.d.ts.map +1 -0
- package/dist/commands/network/shared.js +174 -0
- package/dist/commands/network/shared.js.map +1 -0
- package/dist/commands/network.js +4 -4
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +7 -2
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/shared/CommandRunner.d.ts +19 -0
- package/dist/commands/shared/CommandRunner.d.ts.map +1 -1
- package/dist/commands/shared/CommandRunner.js +30 -0
- package/dist/commands/shared/CommandRunner.js.map +1 -1
- package/dist/commands/shared/commonOptions.d.ts +8 -24
- package/dist/commands/shared/commonOptions.d.ts.map +1 -1
- package/dist/commands/shared/commonOptions.js +9 -25
- package/dist/commands/shared/commonOptions.js.map +1 -1
- package/dist/commands/shared/optionTypes.d.ts +42 -4
- package/dist/commands/shared/optionTypes.d.ts.map +1 -1
- package/dist/commands/shared/startHelpers.d.ts +2 -10
- package/dist/commands/shared/startHelpers.d.ts.map +1 -1
- package/dist/commands/shared/startHelpers.js +9 -4
- package/dist/commands/shared/startHelpers.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +3 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/stop.js +1 -1
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/tail.js +1 -1
- package/dist/commands/tail.js.map +1 -1
- package/dist/commands.js +1 -1
- package/dist/commands.js.map +1 -1
- package/dist/constants.d.ts +15 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -1
- package/dist/daemon/__tests__/commandRegistry.contract.test.js +6 -2
- package/dist/daemon/__tests__/commandRegistry.contract.test.js.map +1 -1
- package/dist/daemon/handlers/CommandHandlers.d.ts +5 -0
- package/dist/daemon/handlers/CommandHandlers.d.ts.map +1 -1
- package/dist/daemon/handlers/CommandHandlers.js +6 -1
- package/dist/daemon/handlers/CommandHandlers.js.map +1 -1
- package/dist/daemon/handlers/QueryHandlers.d.ts.map +1 -1
- package/dist/daemon/handlers/QueryHandlers.js +3 -1
- package/dist/daemon/handlers/QueryHandlers.js.map +1 -1
- package/dist/daemon/worker/commandRegistry.d.ts.map +1 -1
- package/dist/daemon/worker/commandRegistry.js +150 -53
- package/dist/daemon/worker/commandRegistry.js.map +1 -1
- package/dist/ipc/client.d.ts +10 -1
- package/dist/ipc/client.d.ts.map +1 -1
- package/dist/ipc/client.js +12 -2
- package/dist/ipc/client.js.map +1 -1
- package/dist/ipc/session/queries.d.ts +2 -0
- package/dist/ipc/session/queries.d.ts.map +1 -1
- package/dist/session/QueryCacheManager.d.ts +1 -1
- package/dist/session/QueryCacheManager.d.ts.map +1 -1
- package/dist/telemetry/__tests__/remoteObject.unit.test.d.ts +2 -0
- package/dist/telemetry/__tests__/remoteObject.unit.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/remoteObject.unit.test.js +261 -0
- package/dist/telemetry/__tests__/remoteObject.unit.test.js.map +1 -0
- package/dist/telemetry/console.d.ts +8 -8
- package/dist/telemetry/console.d.ts.map +1 -1
- package/dist/telemetry/console.js +142 -53
- package/dist/telemetry/console.js.map +1 -1
- package/dist/telemetry/filterDsl.d.ts +45 -0
- package/dist/telemetry/filterDsl.d.ts.map +1 -0
- package/dist/telemetry/filterDsl.js +299 -0
- package/dist/telemetry/filterDsl.js.map +1 -0
- package/dist/telemetry/filterPresets.d.ts +35 -0
- package/dist/telemetry/filterPresets.d.ts.map +1 -0
- package/dist/telemetry/filterPresets.js +76 -0
- package/dist/telemetry/filterPresets.js.map +1 -0
- package/dist/telemetry/network.d.ts.map +1 -1
- package/dist/telemetry/network.js +16 -8
- package/dist/telemetry/network.js.map +1 -1
- package/dist/telemetry/objectExpander.d.ts +35 -0
- package/dist/telemetry/objectExpander.d.ts.map +1 -0
- package/dist/telemetry/objectExpander.js +165 -0
- package/dist/telemetry/objectExpander.js.map +1 -0
- package/dist/telemetry/remoteObject.d.ts +41 -0
- package/dist/telemetry/remoteObject.d.ts.map +1 -0
- package/dist/telemetry/remoteObject.js +193 -0
- package/dist/telemetry/remoteObject.js.map +1 -0
- package/dist/telemetry/remoteObjectUtils.d.ts +40 -0
- package/dist/telemetry/remoteObjectUtils.d.ts.map +1 -0
- package/dist/telemetry/remoteObjectUtils.js +75 -0
- package/dist/telemetry/remoteObjectUtils.js.map +1 -0
- package/dist/telemetry/roleInference.d.ts +1 -1
- package/dist/telemetry/roleInference.d.ts.map +1 -1
- package/dist/types.d.ts +113 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/formatters/a11y.d.ts +1 -1
- package/dist/ui/formatters/a11y.d.ts.map +1 -1
- package/dist/ui/formatters/console.d.ts +143 -0
- package/dist/ui/formatters/console.d.ts.map +1 -0
- package/dist/ui/formatters/console.js +431 -0
- package/dist/ui/formatters/console.js.map +1 -0
- package/dist/ui/formatters/dom.d.ts +4 -4
- package/dist/ui/formatters/dom.d.ts.map +1 -1
- package/dist/ui/formatters/dom.js +5 -5
- package/dist/ui/formatters/dom.js.map +1 -1
- package/dist/ui/formatters/networkList.d.ts +19 -0
- package/dist/ui/formatters/networkList.d.ts.map +1 -0
- package/dist/ui/formatters/networkList.js +86 -0
- package/dist/ui/formatters/networkList.js.map +1 -0
- package/dist/ui/formatters/preview.d.ts +18 -0
- package/dist/ui/formatters/preview.d.ts.map +1 -1
- package/dist/ui/formatters/preview.js +13 -5
- package/dist/ui/formatters/preview.js.map +1 -1
- package/dist/ui/logging/logger.d.ts +1 -1
- package/dist/ui/logging/logger.d.ts.map +1 -1
- package/dist/ui/logging/logger.js.map +1 -1
- package/dist/ui/messages/consoleMessages.d.ts +12 -27
- package/dist/ui/messages/consoleMessages.d.ts.map +1 -1
- package/dist/ui/messages/consoleMessages.js +16 -31
- package/dist/ui/messages/consoleMessages.js.map +1 -1
- package/dist/ui/messages/networkMessages.d.ts +24 -0
- package/dist/ui/messages/networkMessages.d.ts.map +1 -0
- package/dist/ui/messages/networkMessages.js +30 -0
- package/dist/ui/messages/networkMessages.js.map +1 -0
- package/dist/utils/decisionTrees.d.ts.map +1 -1
- package/dist/utils/decisionTrees.js +17 -2
- package/dist/utils/decisionTrees.js.map +1 -1
- package/dist/utils/strings.d.ts +14 -0
- package/dist/utils/strings.d.ts.map +1 -0
- package/dist/utils/strings.js +23 -0
- package/dist/utils/strings.js.map +1 -0
- package/dist/utils/taskMappings.d.ts.map +1 -1
- package/dist/utils/taskMappings.js +18 -3
- package/dist/utils/taskMappings.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object expansion utilities for CDP RemoteObjects.
|
|
3
|
+
*
|
|
4
|
+
* Fetches nested object properties using Runtime.getProperties to provide
|
|
5
|
+
* rich object representations beyond CDP's default shallow preview.
|
|
6
|
+
*/
|
|
7
|
+
import { OBJECT_EXPANSION_MAX_DEPTH, OBJECT_EXPANSION_MAX_PROPERTIES, OBJECT_EXPANSION_FAILURE_THRESHOLD, } from '../constants.js';
|
|
8
|
+
import { createLogger } from '../ui/logging/index.js';
|
|
9
|
+
import { isPrimitiveObject, hasSpecialDescription, getFallbackDescription, formatPrimitiveValue, } from './remoteObjectUtils.js';
|
|
10
|
+
const log = createLogger('object-expander');
|
|
11
|
+
let consecutiveFailures = 0;
|
|
12
|
+
/**
|
|
13
|
+
* Reset the failure counter (useful for testing).
|
|
14
|
+
*/
|
|
15
|
+
export function resetFailureCounter() {
|
|
16
|
+
consecutiveFailures = 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Record an expansion failure and log warning if threshold exceeded.
|
|
20
|
+
*/
|
|
21
|
+
function recordFailure(error) {
|
|
22
|
+
consecutiveFailures++;
|
|
23
|
+
if (consecutiveFailures === OBJECT_EXPANSION_FAILURE_THRESHOLD) {
|
|
24
|
+
log.info(`Object expansion failed ${OBJECT_EXPANSION_FAILURE_THRESHOLD} times consecutively. ` +
|
|
25
|
+
`CDP connection may be unstable. Last error: ${String(error)}`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
log.debug(`Failed to expand object: ${String(error)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Record a successful expansion (resets failure counter).
|
|
33
|
+
*/
|
|
34
|
+
function recordSuccess() {
|
|
35
|
+
consecutiveFailures = 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Format a primitive RemoteObject value for expansion output.
|
|
39
|
+
* Quotes strings to distinguish them from other values in object context.
|
|
40
|
+
*/
|
|
41
|
+
function formatExpandedPrimitive(arg) {
|
|
42
|
+
if (arg.value !== undefined) {
|
|
43
|
+
if (typeof arg.value === 'string') {
|
|
44
|
+
return `"${arg.value}"`;
|
|
45
|
+
}
|
|
46
|
+
return formatPrimitiveValue(arg.value);
|
|
47
|
+
}
|
|
48
|
+
return 'undefined';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fetch object properties from CDP.
|
|
52
|
+
*/
|
|
53
|
+
async function fetchProperties(cdp, objectId) {
|
|
54
|
+
const response = await cdp.send('Runtime.getProperties', {
|
|
55
|
+
objectId,
|
|
56
|
+
ownProperties: true,
|
|
57
|
+
generatePreview: true,
|
|
58
|
+
});
|
|
59
|
+
const result = response;
|
|
60
|
+
return result.result ?? [];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Filter properties to enumerable ones with values.
|
|
64
|
+
*/
|
|
65
|
+
function getEnumerableProperties(properties) {
|
|
66
|
+
return properties
|
|
67
|
+
.filter((p) => p.enumerable && p.value)
|
|
68
|
+
.slice(0, OBJECT_EXPANSION_MAX_PROPERTIES);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if property count exceeds limit.
|
|
72
|
+
*/
|
|
73
|
+
function hasOverflow(properties, filterFn) {
|
|
74
|
+
return properties.filter(filterFn).length > OBJECT_EXPANSION_MAX_PROPERTIES;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Format array items from properties.
|
|
78
|
+
*/
|
|
79
|
+
async function formatArrayItems(cdp, properties, depth) {
|
|
80
|
+
const items = [];
|
|
81
|
+
const ownProps = getEnumerableProperties(properties);
|
|
82
|
+
for (const prop of ownProps) {
|
|
83
|
+
if (!isNaN(Number(prop.name)) && prop.value) {
|
|
84
|
+
const formatted = await expandRemoteObject(cdp, prop.value, depth + 1);
|
|
85
|
+
items.push(formatted);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return items;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Format object pairs from properties.
|
|
92
|
+
*/
|
|
93
|
+
async function formatObjectPairs(cdp, properties, depth) {
|
|
94
|
+
const pairs = [];
|
|
95
|
+
const ownProps = getEnumerableProperties(properties);
|
|
96
|
+
for (const prop of ownProps) {
|
|
97
|
+
if (prop.value) {
|
|
98
|
+
const formatted = await expandRemoteObject(cdp, prop.value, depth + 1);
|
|
99
|
+
pairs.push(`${prop.name}: ${formatted}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return pairs;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Format an array RemoteObject.
|
|
106
|
+
*/
|
|
107
|
+
async function formatArray(cdp, properties, depth) {
|
|
108
|
+
const items = await formatArrayItems(cdp, properties, depth);
|
|
109
|
+
const overflow = hasOverflow(properties, (p) => !isNaN(Number(p.name)));
|
|
110
|
+
return `[${items.join(', ')}${overflow ? ', …' : ''}]`;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Format a regular object RemoteObject.
|
|
114
|
+
*/
|
|
115
|
+
async function formatObject(cdp, properties, depth) {
|
|
116
|
+
const pairs = await formatObjectPairs(cdp, properties, depth);
|
|
117
|
+
const overflow = hasOverflow(properties, (p) => p.enumerable === true);
|
|
118
|
+
return `{${pairs.join(', ')}${overflow ? ', …' : ''}}`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Expand a RemoteObject to get nested property values.
|
|
122
|
+
*
|
|
123
|
+
* Recursively fetches properties up to MAX_DEPTH levels deep,
|
|
124
|
+
* providing rich object representation for console output.
|
|
125
|
+
*
|
|
126
|
+
* @param cdp - CDP connection for property fetching
|
|
127
|
+
* @param arg - RemoteObject to expand
|
|
128
|
+
* @param depth - Current recursion depth
|
|
129
|
+
* @returns Formatted string representation with expanded properties
|
|
130
|
+
*/
|
|
131
|
+
export async function expandRemoteObject(cdp, arg, depth = 0) {
|
|
132
|
+
if (isPrimitiveObject(arg)) {
|
|
133
|
+
return formatExpandedPrimitive(arg);
|
|
134
|
+
}
|
|
135
|
+
if (hasSpecialDescription(arg)) {
|
|
136
|
+
return arg.description ?? getFallbackDescription(arg);
|
|
137
|
+
}
|
|
138
|
+
if (!arg.objectId || depth >= OBJECT_EXPANSION_MAX_DEPTH) {
|
|
139
|
+
return getFallbackDescription(arg);
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const properties = await fetchProperties(cdp, arg.objectId);
|
|
143
|
+
recordSuccess();
|
|
144
|
+
if (arg.subtype === 'array') {
|
|
145
|
+
return await formatArray(cdp, properties, depth);
|
|
146
|
+
}
|
|
147
|
+
return await formatObject(cdp, properties, depth);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
recordFailure(error);
|
|
151
|
+
return getFallbackDescription(arg);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Expand multiple RemoteObjects and format as console message text.
|
|
156
|
+
*
|
|
157
|
+
* @param cdp - CDP connection for property fetching
|
|
158
|
+
* @param args - Array of RemoteObjects to expand
|
|
159
|
+
* @returns Formatted string with expanded objects
|
|
160
|
+
*/
|
|
161
|
+
export async function expandConsoleArgs(cdp, args) {
|
|
162
|
+
const expanded = await Promise.all(args.map((arg) => expandRemoteObject(cdp, arg)));
|
|
163
|
+
return expanded.join(' ');
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=objectExpander.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectExpander.js","sourceRoot":"","sources":["../../src/telemetry/objectExpander.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAKhC,MAAM,GAAG,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAE5C,IAAI,mBAAmB,GAAG,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,mBAAmB,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAc;IACnC,mBAAmB,EAAE,CAAC;IACtB,IAAI,mBAAmB,KAAK,kCAAkC,EAAE,CAAC;QAC/D,GAAG,CAAC,IAAI,CACN,2BAA2B,kCAAkC,wBAAwB;YACnF,+CAA+C,MAAM,CAAC,KAAK,CAAC,EAAE,CACjE,CAAC;IACJ,CAAC;SAAM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,CAAC,CAAC;QAC5D,aAAa,EAAE,CAAC;QAEhB,IAAI,GAAG,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YAC5B,OAAO,MAAM,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,MAAM,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAkB,EAAE,IAAoB;IAC9E,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACpF,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RemoteObject formatting utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to serialize CDP RemoteObject values into human-readable
|
|
5
|
+
* strings, properly handling objects, arrays, and their preview data with
|
|
6
|
+
* recursive nested object expansion.
|
|
7
|
+
*/
|
|
8
|
+
import type { Protocol } from '../connection/typed-cdp.js';
|
|
9
|
+
type RemoteObject = Protocol.Runtime.RemoteObject;
|
|
10
|
+
/**
|
|
11
|
+
* Format a CDP RemoteObject as a human-readable string.
|
|
12
|
+
*
|
|
13
|
+
* Handles all CDP value types including primitives, objects, arrays,
|
|
14
|
+
* errors, null, and undefined. Uses preview data when available for
|
|
15
|
+
* rich object representation with recursive nested object expansion.
|
|
16
|
+
*
|
|
17
|
+
* @param arg - CDP RemoteObject from console arguments
|
|
18
|
+
* @returns Formatted string representation
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* formatRemoteObject({ type: 'string', value: 'hello' }) // 'hello'
|
|
23
|
+
* formatRemoteObject({
|
|
24
|
+
* type: 'object',
|
|
25
|
+
* preview: { properties: [{ name: 'foo', value: 'bar' }] }
|
|
26
|
+
* }) // '{foo: "bar"}'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatRemoteObject(arg: RemoteObject): string;
|
|
30
|
+
/**
|
|
31
|
+
* Format multiple RemoteObjects as console message text.
|
|
32
|
+
*
|
|
33
|
+
* Joins formatted arguments with spaces, similar to how console.log
|
|
34
|
+
* displays multiple arguments.
|
|
35
|
+
*
|
|
36
|
+
* @param args - Array of CDP RemoteObjects
|
|
37
|
+
* @returns Joined formatted string
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatConsoleArgs(args: RemoteObject[]): string;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=remoteObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteObject.d.ts","sourceRoot":"","sources":["../../src/telemetry/remoteObject.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAU1D,KAAK,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;AA6JlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAkB5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RemoteObject formatting utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to serialize CDP RemoteObject values into human-readable
|
|
5
|
+
* strings, properly handling objects, arrays, and their preview data with
|
|
6
|
+
* recursive nested object expansion.
|
|
7
|
+
*/
|
|
8
|
+
import { SPECIAL_DESCRIPTION_SUBTYPES, formatPrimitiveValue, getFallbackDescription, } from './remoteObjectUtils.js';
|
|
9
|
+
/**
|
|
10
|
+
* Check if a property represents a null value.
|
|
11
|
+
*/
|
|
12
|
+
function isNullProperty(prop) {
|
|
13
|
+
return prop.subtype === 'null' || prop.value === 'null';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if a property has a special subtype with meaningful string representation.
|
|
17
|
+
*/
|
|
18
|
+
function hasSpecialSubtype(prop) {
|
|
19
|
+
return prop.subtype === 'date' || prop.subtype === 'regexp';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Format a primitive property value.
|
|
23
|
+
*/
|
|
24
|
+
function formatPrimitiveProperty(prop) {
|
|
25
|
+
if (prop.type === 'string') {
|
|
26
|
+
return `"${prop.value}"`;
|
|
27
|
+
}
|
|
28
|
+
if (prop.type === 'undefined') {
|
|
29
|
+
return 'undefined';
|
|
30
|
+
}
|
|
31
|
+
if (prop.type === 'symbol') {
|
|
32
|
+
return prop.value ?? 'Symbol()';
|
|
33
|
+
}
|
|
34
|
+
if (prop.type === 'function') {
|
|
35
|
+
return prop.value ?? '[Function]';
|
|
36
|
+
}
|
|
37
|
+
return prop.value ?? prop.type;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Format a preview property value, recursively handling nested objects.
|
|
41
|
+
*
|
|
42
|
+
* @param prop - Preview property from CDP
|
|
43
|
+
* @returns Formatted value string
|
|
44
|
+
*/
|
|
45
|
+
function formatPreviewProperty(prop) {
|
|
46
|
+
if (prop.valuePreview) {
|
|
47
|
+
return formatObjectPreview(prop.valuePreview);
|
|
48
|
+
}
|
|
49
|
+
if (isNullProperty(prop)) {
|
|
50
|
+
return 'null';
|
|
51
|
+
}
|
|
52
|
+
if (hasSpecialSubtype(prop)) {
|
|
53
|
+
return prop.value ?? `[${prop.subtype}]`;
|
|
54
|
+
}
|
|
55
|
+
return formatPrimitiveProperty(prop);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Format an entry value from Map/Set preview.
|
|
59
|
+
*
|
|
60
|
+
* @param value - Entry preview value
|
|
61
|
+
* @returns Formatted value string
|
|
62
|
+
*/
|
|
63
|
+
function formatEntryValue(value) {
|
|
64
|
+
if (value.type === 'string') {
|
|
65
|
+
return `"${value.description ?? ''}"`;
|
|
66
|
+
}
|
|
67
|
+
if (value.type === 'object' && value.properties) {
|
|
68
|
+
return formatObjectPreview(value);
|
|
69
|
+
}
|
|
70
|
+
return value.description ?? value.type;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Extract size from description string like "Map(3)" or "Set(5)".
|
|
74
|
+
*/
|
|
75
|
+
function extractSizeFromDescription(description) {
|
|
76
|
+
return description?.match(/\d+/)?.[0] ?? '0';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Format a Map preview.
|
|
80
|
+
*/
|
|
81
|
+
function formatMapPreview(preview, suffix) {
|
|
82
|
+
const entries = preview.entries ?? [];
|
|
83
|
+
if (entries.length === 0) {
|
|
84
|
+
return `Map(${extractSizeFromDescription(preview.description)})`;
|
|
85
|
+
}
|
|
86
|
+
const formattedEntries = entries.map((e) => {
|
|
87
|
+
const key = e.key ? formatEntryValue(e.key) : '?';
|
|
88
|
+
const value = formatEntryValue(e.value);
|
|
89
|
+
return `${key} => ${value}`;
|
|
90
|
+
});
|
|
91
|
+
return `Map(${entries.length}) {${formattedEntries.join(', ')}${suffix}}`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Format a Set preview.
|
|
95
|
+
*/
|
|
96
|
+
function formatSetPreview(preview, suffix) {
|
|
97
|
+
const entries = preview.entries ?? [];
|
|
98
|
+
if (entries.length === 0) {
|
|
99
|
+
return `Set(${extractSizeFromDescription(preview.description)})`;
|
|
100
|
+
}
|
|
101
|
+
const formattedEntries = entries.map((e) => formatEntryValue(e.value));
|
|
102
|
+
return `Set(${entries.length}) {${formattedEntries.join(', ')}${suffix}}`;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Format an array preview.
|
|
106
|
+
*/
|
|
107
|
+
function formatArrayPreview(props, suffix) {
|
|
108
|
+
const values = props
|
|
109
|
+
.filter((p) => !isNaN(Number(p.name)))
|
|
110
|
+
.sort((a, b) => Number(a.name) - Number(b.name))
|
|
111
|
+
.map(formatPreviewProperty);
|
|
112
|
+
return `[${values.join(', ')}${suffix}]`;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Format a regular object preview.
|
|
116
|
+
*/
|
|
117
|
+
function formatRegularObjectPreview(props, suffix) {
|
|
118
|
+
const pairs = props.map((p) => `${p.name}: ${formatPreviewProperty(p)}`);
|
|
119
|
+
return `{${pairs.join(', ')}${suffix}}`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Format object preview as a string representation.
|
|
123
|
+
*
|
|
124
|
+
* Recursively formats nested objects using their valuePreview data,
|
|
125
|
+
* matching Chrome DevTools console output format.
|
|
126
|
+
*
|
|
127
|
+
* @param preview - Object preview from CDP RemoteObject
|
|
128
|
+
* @returns Formatted object string like `{foo: "bar", num: 123}`
|
|
129
|
+
*/
|
|
130
|
+
function formatObjectPreview(preview) {
|
|
131
|
+
const props = preview.properties ?? [];
|
|
132
|
+
const suffix = preview.overflow ? ', …' : '';
|
|
133
|
+
if (SPECIAL_DESCRIPTION_SUBTYPES.has(preview.subtype ?? '')) {
|
|
134
|
+
return preview.description ?? `[${preview.subtype}]`;
|
|
135
|
+
}
|
|
136
|
+
if (preview.subtype === 'map') {
|
|
137
|
+
return formatMapPreview(preview, suffix);
|
|
138
|
+
}
|
|
139
|
+
if (preview.subtype === 'set') {
|
|
140
|
+
return formatSetPreview(preview, suffix);
|
|
141
|
+
}
|
|
142
|
+
if (preview.subtype === 'array') {
|
|
143
|
+
return formatArrayPreview(props, suffix);
|
|
144
|
+
}
|
|
145
|
+
return formatRegularObjectPreview(props, suffix);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Format a CDP RemoteObject as a human-readable string.
|
|
149
|
+
*
|
|
150
|
+
* Handles all CDP value types including primitives, objects, arrays,
|
|
151
|
+
* errors, null, and undefined. Uses preview data when available for
|
|
152
|
+
* rich object representation with recursive nested object expansion.
|
|
153
|
+
*
|
|
154
|
+
* @param arg - CDP RemoteObject from console arguments
|
|
155
|
+
* @returns Formatted string representation
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* formatRemoteObject({ type: 'string', value: 'hello' }) // 'hello'
|
|
160
|
+
* formatRemoteObject({
|
|
161
|
+
* type: 'object',
|
|
162
|
+
* preview: { properties: [{ name: 'foo', value: 'bar' }] }
|
|
163
|
+
* }) // '{foo: "bar"}'
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export function formatRemoteObject(arg) {
|
|
167
|
+
if (arg.value !== undefined) {
|
|
168
|
+
return formatPrimitiveValue(arg.value);
|
|
169
|
+
}
|
|
170
|
+
if (arg.type === 'undefined') {
|
|
171
|
+
return 'undefined';
|
|
172
|
+
}
|
|
173
|
+
if (arg.subtype === 'error' && arg.description) {
|
|
174
|
+
return arg.description;
|
|
175
|
+
}
|
|
176
|
+
if (arg.type === 'object' && arg.preview) {
|
|
177
|
+
return formatObjectPreview(arg.preview);
|
|
178
|
+
}
|
|
179
|
+
return getFallbackDescription(arg);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Format multiple RemoteObjects as console message text.
|
|
183
|
+
*
|
|
184
|
+
* Joins formatted arguments with spaces, similar to how console.log
|
|
185
|
+
* displays multiple arguments.
|
|
186
|
+
*
|
|
187
|
+
* @param args - Array of CDP RemoteObjects
|
|
188
|
+
* @returns Joined formatted string
|
|
189
|
+
*/
|
|
190
|
+
export function formatConsoleArgs(args) {
|
|
191
|
+
return args.map(formatRemoteObject).join(' ');
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=remoteObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteObject.js","sourceRoot":"","sources":["../../src/telemetry/remoteObject.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAMhC;;GAEG;AACH,SAAS,cAAc,CAAC,IAAqB;IAC3C,OAAO,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,IAAqB;IAC9C,OAAO,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,IAAqB;IACpD,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC;IAC3B,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC;IAClC,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,IAAqB;IAClD,IAAI,IAAI,CAAC,YAAY,EAAE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AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAiB;IAClD,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC7B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,GAAG,CAAC,OAAO,KAAK,OAAO,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;QAC/C,OAAO,GAAG,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACzC,OAAO,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAoB;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for RemoteObject type checking and formatting.
|
|
3
|
+
*
|
|
4
|
+
* Provides common predicates and formatters used by both synchronous
|
|
5
|
+
* preview-based formatting and asynchronous CDP-based expansion.
|
|
6
|
+
*/
|
|
7
|
+
import type { Protocol } from '../connection/typed-cdp.js';
|
|
8
|
+
type RemoteObject = Protocol.Runtime.RemoteObject;
|
|
9
|
+
/**
|
|
10
|
+
* Subtypes that have meaningful description strings from CDP.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SPECIAL_DESCRIPTION_SUBTYPES: Set<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a RemoteObject is a primitive that can be formatted directly.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isPrimitiveObject(arg: RemoteObject): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Check if a RemoteObject has a special subtype with meaningful description.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasSpecialDescription(arg: RemoteObject): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get fallback string representation for a RemoteObject.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getFallbackDescription(arg: RemoteObject): string;
|
|
25
|
+
/**
|
|
26
|
+
* Format a primitive value consistently across sync and async paths.
|
|
27
|
+
* Note: String primitives in console output are NOT quoted (matches Chrome DevTools behavior).
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatPrimitiveValue(value: unknown): string;
|
|
30
|
+
/**
|
|
31
|
+
* Check if preview data is fully expanded (not truncated and no shallow nested objects).
|
|
32
|
+
*/
|
|
33
|
+
export declare function isPreviewFullyExpanded(arg: RemoteObject): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if an object needs async expansion.
|
|
36
|
+
* Expand if: has objectId, is not null, and preview is missing, truncated, or has unexpanded nested objects.
|
|
37
|
+
*/
|
|
38
|
+
export declare function needsAsyncExpansion(arg: RemoteObject): boolean;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=remoteObjectUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteObjectUtils.d.ts","sourceRoot":"","sources":["../../src/telemetry/remoteObjectUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,KAAK,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,4BAA4B,aAAkD,CAAC;AAE5F;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAE5D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAW3D;AAWD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAQjE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAK9D"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for RemoteObject type checking and formatting.
|
|
3
|
+
*
|
|
4
|
+
* Provides common predicates and formatters used by both synchronous
|
|
5
|
+
* preview-based formatting and asynchronous CDP-based expansion.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Subtypes that have meaningful description strings from CDP.
|
|
9
|
+
*/
|
|
10
|
+
export const SPECIAL_DESCRIPTION_SUBTYPES = new Set(['date', 'regexp', 'error', 'promise']);
|
|
11
|
+
/**
|
|
12
|
+
* Check if a RemoteObject is a primitive that can be formatted directly.
|
|
13
|
+
*/
|
|
14
|
+
export function isPrimitiveObject(arg) {
|
|
15
|
+
return arg.value !== undefined || arg.type === 'undefined';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if a RemoteObject has a special subtype with meaningful description.
|
|
19
|
+
*/
|
|
20
|
+
export function hasSpecialDescription(arg) {
|
|
21
|
+
return SPECIAL_DESCRIPTION_SUBTYPES.has(arg.subtype ?? '') && arg.description !== undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get fallback string representation for a RemoteObject.
|
|
25
|
+
*/
|
|
26
|
+
export function getFallbackDescription(arg) {
|
|
27
|
+
return arg.description ?? `[${arg.type}]`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format a primitive value consistently across sync and async paths.
|
|
31
|
+
* Note: String primitives in console output are NOT quoted (matches Chrome DevTools behavior).
|
|
32
|
+
*/
|
|
33
|
+
export function formatPrimitiveValue(value) {
|
|
34
|
+
if (typeof value === 'string') {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
38
|
+
return String(value);
|
|
39
|
+
}
|
|
40
|
+
if (value === null) {
|
|
41
|
+
return 'null';
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify(value);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if a preview property has unexpanded nested objects.
|
|
47
|
+
* CDP shows nested objects as just "Object" without valuePreview.
|
|
48
|
+
*/
|
|
49
|
+
function hasUnexpandedNestedObjects(preview) {
|
|
50
|
+
const props = preview.properties ?? [];
|
|
51
|
+
return props.some((p) => p.type === 'object' && !p.valuePreview && p.value === 'Object');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if preview data is fully expanded (not truncated and no shallow nested objects).
|
|
55
|
+
*/
|
|
56
|
+
export function isPreviewFullyExpanded(arg) {
|
|
57
|
+
if (!arg.preview) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (arg.preview.overflow) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return !hasUnexpandedNestedObjects(arg.preview);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if an object needs async expansion.
|
|
67
|
+
* Expand if: has objectId, is not null, and preview is missing, truncated, or has unexpanded nested objects.
|
|
68
|
+
*/
|
|
69
|
+
export function needsAsyncExpansion(arg) {
|
|
70
|
+
if (arg.type !== 'object' || !arg.objectId || arg.subtype === 'null') {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return !isPreviewFullyExpanded(arg);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=remoteObjectUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;AAC3F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAiB;IACtD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAiB;IACnD,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://www.w3.org/TR/html-aria/#docconformance
|
|
8
8
|
*/
|
|
9
|
-
import type { DomContext } from '../types
|
|
9
|
+
import type { DomContext } from '../types.js';
|
|
10
10
|
import type { A11yNode } from '../types.js';
|
|
11
11
|
/**
|
|
12
12
|
* Infers an ARIA role from an HTML tag name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roleInference.d.ts","sourceRoot":"","sources":["../../src/telemetry/roleInference.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"roleInference.d.ts","sourceRoot":"","sources":["../../src/telemetry/roleInference.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAwF3C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGpD;AAiBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CA0BnF"}
|