glass-easel-devtools-agent 0.13.0 → 0.17.2
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/backend.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +4 -4
- package/src/backend.ts +15 -11
- package/src/index.ts +7 -6
- package/src/mount_point.ts +48 -48
- package/src/overlay.ts +3 -5
- package/src/protocol/dom.ts +0 -1
- package/src/protocol/var.ts +0 -1
- package/.eslintignore +0 -2
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glass-easel-devtools-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"glass-easel": ">=0.
|
|
6
|
+
"glass-easel": ">=0.17.2"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@csstools/css-tokenizer": "^2.4.1",
|
|
10
10
|
"@csstools/selector-specificity": "^3.1.1",
|
|
11
11
|
"@types/node": "^20.16.5",
|
|
12
12
|
"devtools-protocol": "^0.0.1319565",
|
|
13
|
-
"glass-easel": ">=0.
|
|
14
|
-
"glass-easel-template-compiler": ">=0.
|
|
13
|
+
"glass-easel": ">=0.17.2",
|
|
14
|
+
"glass-easel-template-compiler": ">=0.17.2",
|
|
15
15
|
"postcss-selector-parser": "^6.1.2"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
package/src/backend.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable arrow-body-style */
|
|
2
|
-
|
|
3
1
|
import * as glassEasel from 'glass-easel'
|
|
4
2
|
import parser from 'postcss-selector-parser'
|
|
5
3
|
import { selectorSpecificity, compare as selectorCompare } from '@csstools/selector-specificity'
|
|
@@ -214,7 +212,7 @@ export const getMatchedRules = (
|
|
|
214
212
|
if (peek) {
|
|
215
213
|
i += 1
|
|
216
214
|
const [prefix, name] = peek.split('--', 2)
|
|
217
|
-
if (
|
|
215
|
+
if (prefix !== peek) {
|
|
218
216
|
rule.styleScope = prefix
|
|
219
217
|
tokens[i][1] = name
|
|
220
218
|
}
|
|
@@ -270,7 +268,7 @@ export const getMatchedRules = (
|
|
|
270
268
|
ret.inline = edit.getProps()
|
|
271
269
|
resolve(ret)
|
|
272
270
|
})
|
|
273
|
-
} catch (
|
|
271
|
+
} catch (_err) {
|
|
274
272
|
// this may throw when reading cross-origin stylesheets
|
|
275
273
|
resolve({
|
|
276
274
|
inline: [],
|
|
@@ -322,7 +320,9 @@ export class StyleRuleEdit {
|
|
|
322
320
|
updateWithProps(props: glassEasel.CSSProperty[], inlineStyle?: string) {
|
|
323
321
|
const oldProps = this.props
|
|
324
322
|
this.props =
|
|
325
|
-
inlineStyle === undefined
|
|
323
|
+
inlineStyle === undefined
|
|
324
|
+
? filterCssProperties(props)
|
|
325
|
+
: (parseNameValueStr(inlineStyle) ?? [])
|
|
326
326
|
let i = 0
|
|
327
327
|
oldProps.forEach((prop) => {
|
|
328
328
|
if (prop.disabled) {
|
|
@@ -387,7 +387,10 @@ export class StyleRuleEdit {
|
|
|
387
387
|
|
|
388
388
|
class StyleEditContext {
|
|
389
389
|
inlineStyleMap = new WeakMap<glassEasel.GeneralBackendElement, StyleRuleEdit>()
|
|
390
|
-
ruleMap = new WeakMap<
|
|
390
|
+
ruleMap = new WeakMap<
|
|
391
|
+
glassEasel.GeneralBackendContext,
|
|
392
|
+
Record<string, StyleRuleEdit | undefined>
|
|
393
|
+
>()
|
|
391
394
|
|
|
392
395
|
createOrGetInline(
|
|
393
396
|
elem: glassEasel.GeneralBackendElement,
|
|
@@ -409,7 +412,7 @@ class StyleEditContext {
|
|
|
409
412
|
rule: glassEasel.CSSRule,
|
|
410
413
|
inlineStyle?: string,
|
|
411
414
|
): StyleRuleEdit {
|
|
412
|
-
const key = `${rule.sheetIndex}/${rule.ruleIndex}`
|
|
415
|
+
const key = `${rule.sheetIndex.toString()}/${rule.ruleIndex.toString()}`
|
|
413
416
|
const map = this.ruleMap.get(ctx)
|
|
414
417
|
if (!map) {
|
|
415
418
|
const map = Object.create(null) as Record<string, StyleRuleEdit>
|
|
@@ -438,8 +441,9 @@ class StyleEditContext {
|
|
|
438
441
|
;(elem as glassEasel.domlikeBackend.Element).setAttribute('style', style)
|
|
439
442
|
} else if (ctx.mode === glassEasel.BackendMode.Composed) {
|
|
440
443
|
;(elem as glassEasel.composedBackend.Element).setStyle(style)
|
|
444
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
441
445
|
} else if (ctx.mode === glassEasel.BackendMode.Shadow) {
|
|
442
|
-
;(elem as glassEasel.backend.Element).setStyle(style)
|
|
446
|
+
;(elem as glassEasel.backend.Element).setStyle(style, 0)
|
|
443
447
|
}
|
|
444
448
|
}
|
|
445
449
|
|
|
@@ -449,7 +453,7 @@ class StyleEditContext {
|
|
|
449
453
|
ruleIndex: number,
|
|
450
454
|
f: (edit: StyleRuleEdit) => void,
|
|
451
455
|
): Promise<void> {
|
|
452
|
-
const key = `${sheetIndex}/${ruleIndex}`
|
|
456
|
+
const key = `${sheetIndex.toString()}/${ruleIndex.toString()}`
|
|
453
457
|
const edit = this.ruleMap.get(ctx)?.[key]
|
|
454
458
|
if (!edit) return Promise.resolve()
|
|
455
459
|
f(edit)
|
|
@@ -518,9 +522,9 @@ export class ClassListEdit {
|
|
|
518
522
|
}
|
|
519
523
|
|
|
520
524
|
export class ClassEditContext {
|
|
521
|
-
map = new WeakMap<glassEasel.Element, Record<string, ClassListEdit>>()
|
|
525
|
+
map = new WeakMap<glassEasel.Element, Record<string, ClassListEdit | undefined>>()
|
|
522
526
|
|
|
523
|
-
createOrGet(external: string, elem: glassEasel.Element): ClassListEdit {
|
|
527
|
+
createOrGet(external: string | undefined, elem: glassEasel.Element): ClassListEdit {
|
|
524
528
|
if (!this.map.get(elem)) {
|
|
525
529
|
const group = Object.create(null) as Record<string, ClassListEdit>
|
|
526
530
|
this.map.set(elem, group)
|
package/src/index.ts
CHANGED
|
@@ -18,14 +18,17 @@ export interface MessageChannel {
|
|
|
18
18
|
|
|
19
19
|
export class Connection {
|
|
20
20
|
private messageChannel: MessageChannel
|
|
21
|
-
private requestHandlers = Object.create(null) as Record<
|
|
21
|
+
private requestHandlers = Object.create(null) as Record<
|
|
22
|
+
string,
|
|
23
|
+
((detail: any) => Promise<any>) | undefined
|
|
24
|
+
>
|
|
22
25
|
readonly overlayManager: OverlayManager
|
|
23
26
|
|
|
24
27
|
constructor(messageChannel: MessageChannel) {
|
|
25
28
|
this.messageChannel = messageChannel
|
|
26
29
|
messageChannel.recv((data) => {
|
|
27
30
|
if (data.kind === 'request') {
|
|
28
|
-
debug(`recv request ${data.id}`, data.name, data.detail)
|
|
31
|
+
debug(`recv request ${data.id.toString()}`, data.name, data.detail)
|
|
29
32
|
this.recvRequest(data.id, data.name, data.detail)
|
|
30
33
|
}
|
|
31
34
|
})
|
|
@@ -46,12 +49,12 @@ export class Connection {
|
|
|
46
49
|
handler
|
|
47
50
|
.call(this, detail)
|
|
48
51
|
.then((ret: unknown) => {
|
|
49
|
-
debug(`send response ${id}`, ret)
|
|
52
|
+
debug(`send response ${id.toString()}`, ret)
|
|
50
53
|
const data: AgentSendMessage = { kind: 'response', id, detail: ret }
|
|
51
54
|
this.messageChannel.send(data)
|
|
52
55
|
return undefined
|
|
53
56
|
})
|
|
54
|
-
.catch((err) => {
|
|
57
|
+
.catch((err: unknown) => {
|
|
55
58
|
const data: AgentSendMessage = {
|
|
56
59
|
kind: 'error',
|
|
57
60
|
id,
|
|
@@ -94,13 +97,11 @@ class InspectorDevToolsImpl implements glassEasel.InspectorDevTools {
|
|
|
94
97
|
})
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
// eslint-disable-next-line class-methods-use-this
|
|
98
100
|
addMountPoint(root: glassEasel.Element, env: glassEasel.MountPointEnv): void {
|
|
99
101
|
debug('attach mount point', root)
|
|
100
102
|
this.mountPoints.attach(root, env)
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
// eslint-disable-next-line class-methods-use-this
|
|
104
105
|
removeMountPoint(root: glassEasel.GeneralComponent): void {
|
|
105
106
|
debug('detach mount point', root)
|
|
106
107
|
this.mountPoints.detach(root)
|
package/src/mount_point.ts
CHANGED
|
@@ -63,9 +63,12 @@ export class MountPointsManager {
|
|
|
63
63
|
private conn: Connection
|
|
64
64
|
private nodeIdMap = new WeakMap<glassEasel.Node, NodeId>()
|
|
65
65
|
// active nodes are the nodes that being display and watched
|
|
66
|
-
private activeNodes = Object.create(null) as Record<NodeId, NodeMeta>
|
|
66
|
+
private activeNodes = Object.create(null) as Record<NodeId, NodeMeta | undefined>
|
|
67
67
|
// backend nodes are the nodes that has being transmitted to the client in arguments but not display
|
|
68
|
-
private activeBackendNodes = Object.create(null) as Record<
|
|
68
|
+
private activeBackendNodes = Object.create(null) as Record<
|
|
69
|
+
NodeId,
|
|
70
|
+
WeakRef<glassEasel.Node> | undefined
|
|
71
|
+
>
|
|
69
72
|
readonly documentNodeId = 1
|
|
70
73
|
private nodeIdInc = 2
|
|
71
74
|
private mountPoints: { nodeMeta: NodeMeta; env: glassEasel.MountPointEnv }[] = []
|
|
@@ -204,13 +207,16 @@ export class MountPointsManager {
|
|
|
204
207
|
| null
|
|
205
208
|
| undefined
|
|
206
209
|
if (typeof maybeEventTarget === 'object' && maybeEventTarget !== null) {
|
|
207
|
-
const processListeners = (
|
|
210
|
+
const processListeners = (
|
|
211
|
+
capture: boolean,
|
|
212
|
+
listeners: { [name: string]: EventPoint } | undefined | null,
|
|
213
|
+
) => {
|
|
208
214
|
if (typeof listeners === 'object' && listeners !== null) {
|
|
209
215
|
Object.entries(listeners).forEach(([name, value]) => {
|
|
210
|
-
const count = value
|
|
216
|
+
const count = value.funcArr?._$arr?.length ?? 0
|
|
211
217
|
if (count > 0) {
|
|
212
|
-
const hasCatch = (value
|
|
213
|
-
const hasMutBind = (value
|
|
218
|
+
const hasCatch = (value.finalCount ?? 0) > 0
|
|
219
|
+
const hasMutBind = (value.mutCount ?? 0) > 0
|
|
214
220
|
eventBindings.push({ name, capture, count, hasCatch, hasMutBind })
|
|
215
221
|
}
|
|
216
222
|
})
|
|
@@ -240,20 +246,18 @@ export class MountPointsManager {
|
|
|
240
246
|
properties!.push({ name, value: toGlassEaselVar(comp.data[name]) })
|
|
241
247
|
})
|
|
242
248
|
const ec = comp.getExternalClasses()
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}))
|
|
251
|
-
}
|
|
249
|
+
externalClasses = Object.entries(ec).map(([name, value]) => ({
|
|
250
|
+
name,
|
|
251
|
+
value: backendUtils.classEditContext
|
|
252
|
+
.createOrGet(name, elem)
|
|
253
|
+
.update(value ?? [])
|
|
254
|
+
.getClasses(),
|
|
255
|
+
}))
|
|
252
256
|
}
|
|
253
257
|
|
|
254
258
|
// collect dataset
|
|
255
259
|
const dataset: { name: string; value: GlassEaselVar }[] = []
|
|
256
|
-
Object.entries(elem.dataset
|
|
260
|
+
Object.entries(elem.dataset).forEach(([name, value]) => {
|
|
257
261
|
dataset.push({ name, value: toGlassEaselVar(value) })
|
|
258
262
|
})
|
|
259
263
|
const marks: { name: string; value: GlassEaselVar }[] = []
|
|
@@ -445,8 +449,8 @@ export class MountPointsManager {
|
|
|
445
449
|
|
|
446
450
|
this.conn.setRequestHandler('CSS.getComputedStyleForNode', async ({ nodeId }) => {
|
|
447
451
|
const { node } = this.queryActiveNode(nodeId)
|
|
448
|
-
const ctx = node
|
|
449
|
-
const elem = node
|
|
452
|
+
const ctx = node.getBackendContext()
|
|
453
|
+
const elem = node.getBackendElement()
|
|
450
454
|
if (!ctx || !elem) {
|
|
451
455
|
throw new Error('no such backend node found')
|
|
452
456
|
}
|
|
@@ -460,9 +464,8 @@ export class MountPointsManager {
|
|
|
460
464
|
if (!elem) {
|
|
461
465
|
throw new Error('not an element')
|
|
462
466
|
}
|
|
463
|
-
const { inline, inlineText, rules, crossOriginFailing } =
|
|
464
|
-
elem
|
|
465
|
-
)
|
|
467
|
+
const { inline, inlineText, rules, crossOriginFailing } =
|
|
468
|
+
await backendUtils.getMatchedRules(elem)
|
|
466
469
|
const inlineStyle = { cssProperties: inline, cssText: inlineText }
|
|
467
470
|
const matchedCSSRules = rules.map((rule) => ({
|
|
468
471
|
rule: {
|
|
@@ -482,8 +485,8 @@ export class MountPointsManager {
|
|
|
482
485
|
'CSS.replaceGlassEaselStyleSheetProperty',
|
|
483
486
|
async ({ nodeId, styleSheetId, ruleIndex, propertyIndex, styleText }) => {
|
|
484
487
|
const { node } = this.queryActiveNode(nodeId)
|
|
485
|
-
const ctx = node
|
|
486
|
-
const elem = node
|
|
488
|
+
const ctx = node.getBackendContext()
|
|
489
|
+
const elem = node.getBackendElement()
|
|
487
490
|
if (!ctx || !elem) {
|
|
488
491
|
throw new Error('no such backend node found')
|
|
489
492
|
}
|
|
@@ -503,8 +506,8 @@ export class MountPointsManager {
|
|
|
503
506
|
'CSS.addGlassEaselStyleSheetProperty',
|
|
504
507
|
async ({ nodeId, styleSheetId, ruleIndex, styleText }) => {
|
|
505
508
|
const { node } = this.queryActiveNode(nodeId)
|
|
506
|
-
const ctx = node
|
|
507
|
-
const elem = node
|
|
509
|
+
const ctx = node.getBackendContext()
|
|
510
|
+
const elem = node.getBackendElement()
|
|
508
511
|
if (!ctx || !elem) {
|
|
509
512
|
throw new Error('no such backend node found')
|
|
510
513
|
}
|
|
@@ -524,8 +527,8 @@ export class MountPointsManager {
|
|
|
524
527
|
'CSS.setGlassEaselStyleSheetPropertyDisabled',
|
|
525
528
|
async ({ nodeId, styleSheetId, ruleIndex, propertyIndex, disabled }) => {
|
|
526
529
|
const { node } = this.queryActiveNode(nodeId)
|
|
527
|
-
const ctx = node
|
|
528
|
-
const elem = node
|
|
530
|
+
const ctx = node.getBackendContext()
|
|
531
|
+
const elem = node.getBackendElement()
|
|
529
532
|
if (!ctx || !elem) {
|
|
530
533
|
throw new Error('no such backend node found')
|
|
531
534
|
}
|
|
@@ -597,7 +600,8 @@ export class MountPointsManager {
|
|
|
597
600
|
|
|
598
601
|
attach(root: glassEasel.Element, env: glassEasel.MountPointEnv) {
|
|
599
602
|
const nodeMeta = this.activateNode(root)
|
|
600
|
-
const previousNode =
|
|
603
|
+
const previousNode =
|
|
604
|
+
this.mountPoints.length > 0 ? this.mountPoints[this.mountPoints.length - 1] : null
|
|
601
605
|
const previousNodeId = previousNode ? previousNode.nodeMeta.nodeId : undefined
|
|
602
606
|
this.mountPoints.push({ nodeMeta, env })
|
|
603
607
|
this.conn.sendEvent('DOM.childNodeInserted', {
|
|
@@ -650,11 +654,10 @@ export class MountPointsManager {
|
|
|
650
654
|
return ret
|
|
651
655
|
}
|
|
652
656
|
|
|
653
|
-
// eslint-disable-next-line class-methods-use-this
|
|
654
657
|
private useInConsole(v: unknown): string {
|
|
655
658
|
let i = 0
|
|
656
659
|
while (i <= 0xffffffff) {
|
|
657
|
-
const varName = `temp${i}`
|
|
660
|
+
const varName = `temp${i.toString()}`
|
|
658
661
|
if (!Object.prototype.hasOwnProperty.call(globalThis, varName)) {
|
|
659
662
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
660
663
|
;(globalThis as any)[varName] = v
|
|
@@ -693,17 +696,16 @@ export class MountPointsManager {
|
|
|
693
696
|
|
|
694
697
|
private queryActiveNode(nodeId: NodeId): NodeMeta {
|
|
695
698
|
const nodeMeta = this.activeNodes[nodeId]
|
|
696
|
-
if (!nodeMeta) throw new Error(`no active node found for node id ${nodeId}`)
|
|
699
|
+
if (!nodeMeta) throw new Error(`no active node found for node id ${nodeId.toString()}`)
|
|
697
700
|
return nodeMeta
|
|
698
701
|
}
|
|
699
702
|
|
|
700
703
|
private getMaybeBackendNode(backendNodeId: NodeId): glassEasel.Node | null {
|
|
701
704
|
const nodeMeta = this.activeNodes[backendNodeId]
|
|
702
|
-
if (nodeMeta) return nodeMeta
|
|
705
|
+
if (nodeMeta) return nodeMeta.node
|
|
703
706
|
return this.activeBackendNodes[backendNodeId]?.deref() ?? null
|
|
704
707
|
}
|
|
705
708
|
|
|
706
|
-
// eslint-disable-next-line class-methods-use-this
|
|
707
709
|
private startWatch(node: glassEasel.Node) {
|
|
708
710
|
const observer = glassEasel.MutationObserver.create((ev) => {
|
|
709
711
|
const node = ev.target
|
|
@@ -750,11 +752,9 @@ export class MountPointsManager {
|
|
|
750
752
|
v = marks?.[name.slice(5)]
|
|
751
753
|
} else if (nameType === 'external-class') {
|
|
752
754
|
const external = ev.attributeName ?? ''
|
|
753
|
-
const classes = elem.asGeneralComponent()?.getExternalClasses()
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
v = classes ?? ''
|
|
757
|
-
}
|
|
755
|
+
const classes = elem.asGeneralComponent()?.getExternalClasses()[external]?.join(' ')
|
|
756
|
+
name = external
|
|
757
|
+
v = classes ?? ''
|
|
758
758
|
} else if (ev.attributeName === 'slot') {
|
|
759
759
|
name = ev.attributeName
|
|
760
760
|
v = elem.slot
|
|
@@ -805,7 +805,7 @@ export class MountPointsManager {
|
|
|
805
805
|
if (!parent.isInheritSlots() && composedParent && composedParent !== parent) {
|
|
806
806
|
const composedParentId = this.getActiveNodeId(composedParent)
|
|
807
807
|
if (composedParentId) {
|
|
808
|
-
let prev
|
|
808
|
+
let prev = null as glassEasel.Node | null
|
|
809
809
|
const found = composedParent.forEachComposedChild((c) => {
|
|
810
810
|
if (c === child) return false
|
|
811
811
|
prev = c
|
|
@@ -854,7 +854,6 @@ export class MountPointsManager {
|
|
|
854
854
|
return observer
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
// eslint-disable-next-line class-methods-use-this
|
|
858
857
|
private endWatch(observer: glassEasel.MutationObserver) {
|
|
859
858
|
observer.disconnect()
|
|
860
859
|
}
|
|
@@ -866,6 +865,7 @@ export class MountPointsManager {
|
|
|
866
865
|
*/
|
|
867
866
|
private activateNode(node: glassEasel.Node): NodeMeta {
|
|
868
867
|
const nodeId = this.getNodeId(node)
|
|
868
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
869
869
|
delete this.activeBackendNodes[nodeId]
|
|
870
870
|
if (this.activeNodes[nodeId]) {
|
|
871
871
|
const nodeMeta = this.activeNodes[nodeId]
|
|
@@ -896,12 +896,13 @@ export class MountPointsManager {
|
|
|
896
896
|
}
|
|
897
897
|
const { observer } = this.activeNodes[nodeId]
|
|
898
898
|
this.endWatch(observer)
|
|
899
|
-
const shadowRoot = node.asGeneralComponent()?.getShadowRoot
|
|
899
|
+
const shadowRoot = node.asGeneralComponent()?.getShadowRoot()
|
|
900
900
|
if (shadowRoot) this.deactivateNodeTree(shadowRoot)
|
|
901
|
-
const childNodes: glassEasel.Node[] | undefined =
|
|
901
|
+
const childNodes: glassEasel.Node[] | undefined = node.asElement()?.childNodes
|
|
902
902
|
if (childNodes) {
|
|
903
903
|
childNodes.forEach((node) => this.deactivateNodeTree(node))
|
|
904
904
|
}
|
|
905
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
905
906
|
delete this.activeNodes[nodeId]
|
|
906
907
|
return nodeId
|
|
907
908
|
}
|
|
@@ -921,7 +922,6 @@ export class MountPointsManager {
|
|
|
921
922
|
return this.activateNode(node)
|
|
922
923
|
}
|
|
923
924
|
|
|
924
|
-
// eslint-disable-next-line class-methods-use-this
|
|
925
925
|
private collectNodeBasicInfomation(
|
|
926
926
|
backendNodeId: NodeId,
|
|
927
927
|
node: glassEasel.Node,
|
|
@@ -991,7 +991,7 @@ export class MountPointsManager {
|
|
|
991
991
|
if (name === ':style') attributes.push('style', elem.style)
|
|
992
992
|
if (name === ':name') attributes.push('style', Reflect.get(elem, '_$slotName'))
|
|
993
993
|
} else if (name.startsWith('data:')) {
|
|
994
|
-
const value = elem.dataset
|
|
994
|
+
const value = elem.dataset[name.slice(5)]
|
|
995
995
|
attributes.push(name, glassEaselVarToString(toGlassEaselVar(value)))
|
|
996
996
|
} else if (name.startsWith('mark:')) {
|
|
997
997
|
const marks = Reflect.get(elem, '_$marks') as { [key: string]: unknown } | undefined
|
|
@@ -1036,7 +1036,7 @@ export class MountPointsManager {
|
|
|
1036
1036
|
attributes.push(name, glassEaselVarToString(toGlassEaselVar(value)))
|
|
1037
1037
|
})
|
|
1038
1038
|
}
|
|
1039
|
-
Object.entries(elem.dataset
|
|
1039
|
+
Object.entries(elem.dataset).forEach(([key, value]) => {
|
|
1040
1040
|
const name = `data:${key}`
|
|
1041
1041
|
attributes.push(name, glassEaselVarToString(toGlassEaselVar(value)))
|
|
1042
1042
|
})
|
|
@@ -1056,7 +1056,7 @@ export class MountPointsManager {
|
|
|
1056
1056
|
const nodeMeta = this.activateNode(sr)
|
|
1057
1057
|
const n = this.collectNodeDetails(nodeMeta, depth - 1, false)
|
|
1058
1058
|
n.nodeName = 'shadow-root'
|
|
1059
|
-
|
|
1059
|
+
shadowRoots = [n]
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
1062
|
// collect children
|
|
@@ -1068,7 +1068,7 @@ export class MountPointsManager {
|
|
|
1068
1068
|
elem.childNodes.forEach((child) => {
|
|
1069
1069
|
const nodeMeta = this.activateNode(child)
|
|
1070
1070
|
const n = this.collectNodeDetails(nodeMeta, depth - 1, false)
|
|
1071
|
-
|
|
1071
|
+
children!.push(n)
|
|
1072
1072
|
})
|
|
1073
1073
|
}
|
|
1074
1074
|
|
|
@@ -1081,7 +1081,7 @@ export class MountPointsManager {
|
|
|
1081
1081
|
if (child.parentNode?.isInheritSlots()) return
|
|
1082
1082
|
const nodeId = this.addBackendNode(child)
|
|
1083
1083
|
const n = this.collectNodeBasicInfomation(nodeId, child)
|
|
1084
|
-
|
|
1084
|
+
distributedNodes!.push(n)
|
|
1085
1085
|
})
|
|
1086
1086
|
}
|
|
1087
1087
|
|
package/src/overlay.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as glassEasel from 'glass-easel'
|
|
2
2
|
|
|
3
|
-
// eslint-disable-next-line
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-call
|
|
4
4
|
const wxml = require('./overlay.wxml') as Record<string, unknown>
|
|
5
5
|
|
|
6
6
|
export const enum OverlayState {
|
|
@@ -71,7 +71,6 @@ export const overlayCompDef = space
|
|
|
71
71
|
return
|
|
72
72
|
}
|
|
73
73
|
setData({ selectMoveDetecting: true })
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
75
74
|
elementFromPointInContext(ctx, x, y)
|
|
76
75
|
.then(async (elem) => {
|
|
77
76
|
setData({ selectMoveDetecting: false })
|
|
@@ -135,11 +134,10 @@ const elementFromPointInContext = (
|
|
|
135
134
|
y: number,
|
|
136
135
|
) =>
|
|
137
136
|
new Promise<glassEasel.Element | null>((resolve) => {
|
|
138
|
-
if (!context
|
|
137
|
+
if (!context.elementFromPoint) {
|
|
139
138
|
resolve(null)
|
|
140
139
|
return
|
|
141
140
|
}
|
|
142
|
-
// eslint-disable-next-line
|
|
143
141
|
context.elementFromPoint(x, y, (elem) => {
|
|
144
142
|
resolve(elem)
|
|
145
143
|
})
|
|
@@ -216,10 +214,10 @@ export class OverlayManager {
|
|
|
216
214
|
parentElement = ctx.getRootNode()
|
|
217
215
|
placeholder = ctx.document.createElement('glass-easel-devtools-agent')
|
|
218
216
|
parentElement.appendChild(placeholder)
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
219
218
|
} else if (ctx.mode === glassEasel.BackendMode.Shadow) {
|
|
220
219
|
const sr = ctx.getRootNode()
|
|
221
220
|
parentElement = sr
|
|
222
|
-
if (!sr) throw new Error('the host element should be inside of a shadow tree')
|
|
223
221
|
placeholder = sr.createElement('glass-easel-devtools-agent', 'glass-easel-devtools-agent')
|
|
224
222
|
sr.appendChild(placeholder)
|
|
225
223
|
} else {
|
package/src/protocol/dom.ts
CHANGED
|
@@ -63,7 +63,6 @@ export const glassEaselNodeTypeToCDP = (t: GlassEaselNodeType) => {
|
|
|
63
63
|
if (t === GlassEaselNodeType.Component) return CDPNodeType.ELEMENT_NODE
|
|
64
64
|
if (t === GlassEaselNodeType.VirtualNode) return CDPNodeType.ELEMENT_NODE
|
|
65
65
|
if (t === GlassEaselNodeType.InheritVirtualNode) return CDPNodeType.ELEMENT_NODE
|
|
66
|
-
if (t === GlassEaselNodeType.Unknown) return CDPNodeType.DOCUMENT_NODE
|
|
67
66
|
return CDPNodeType.DOCUMENT_NODE
|
|
68
67
|
}
|
|
69
68
|
|
package/src/protocol/var.ts
CHANGED
|
@@ -32,6 +32,5 @@ export const glassEaselVarToString = (v: GlassEaselVar): string => {
|
|
|
32
32
|
if (v.type === 'symbol') return v.value
|
|
33
33
|
if (v.type === 'function') return '() => {...}'
|
|
34
34
|
if (v.type === 'object') return '{...}'
|
|
35
|
-
if (v.type === 'array') return '[...]'
|
|
36
35
|
return '[unknown]'
|
|
37
36
|
}
|
package/.eslintignore
DELETED