@lvce-editor/virtual-dom 2.17.0 → 3.0.0
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/index.js +77 -2
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/parts/AddPatch/AddPatch.ts +0 -6
- package/src/parts/ApplyDragInfoMaybe/ApplyDragInfoMaybe.ts +0 -20
- package/src/parts/ApplyPatch/ApplyPatch.ts +0 -41
- package/src/parts/AttachEvent/AttachEvent.ts +0 -38
- package/src/parts/AttributePatch/AttributePatch.ts +0 -5
- package/src/parts/ClearNode/ClearNode.ts +0 -3
- package/src/parts/ComponentUid/ComponentUid.ts +0 -19
- package/src/parts/CreateEventListenerFunction/CreateEventListenerFunction.ts +0 -45
- package/src/parts/DomEventType/DomEventType.ts +0 -2
- package/src/parts/DragInfo/DragInfo.ts +0 -13
- package/src/parts/ElementTagMap/ElementTagMap.ts +0 -117
- package/src/parts/ElementTags/ElementTags.ts +0 -55
- package/src/parts/EventState/EventState.ts +0 -13
- package/src/parts/FileHandles/FileHandles.ts +0 -28
- package/src/parts/GetActiveElementInside/GetActiveElementInside.ts +0 -15
- package/src/parts/GetEventListenerArg/GetEventListenerArg.ts +0 -69
- package/src/parts/GetEventListenerArgs/GetEventListenerArgs.ts +0 -12
- package/src/parts/GetEventListenerOptions/GetEventListenerOptions.ts +0 -15
- package/src/parts/GetUidTarget/GetUidTarget.ts +0 -13
- package/src/parts/GetWrappedListener/GetWrappedListener.ts +0 -25
- package/src/parts/Id/Id.ts +0 -5
- package/src/parts/IpcState/IpcState.ts +0 -11
- package/src/parts/IsInputElement/IsInputElement.ts +0 -3
- package/src/parts/ListenerCache/ListenerCache.ts +0 -13
- package/src/parts/Main/Main.ts +0 -16
- package/src/parts/NameAnonymousFunction/NameAnonymousFunction.ts +0 -5
- package/src/parts/NavigateChildPatch/NavigateChildPatch.ts +0 -4
- package/src/parts/NavigateParentPatch/NavigateParentPatch.ts +0 -3
- package/src/parts/NavigateSiblingPatch/NavigateSiblingPatch.ts +0 -4
- package/src/parts/Patch/Patch.ts +0 -22
- package/src/parts/PatchFunctions/PatchFunctions.ts +0 -30
- package/src/parts/PatchType/PatchType.ts +0 -10
- package/src/parts/PreventEventsMaybe/PreventEventsMaybe.ts +0 -14
- package/src/parts/QueryInputs/QueryInputs.ts +0 -3
- package/src/parts/RegisterEventListeners/RegisterEventListeners.ts +0 -17
- package/src/parts/RememberFocus/RememberFocus.ts +0 -97
- package/src/parts/RemoveAttributePatch/RemoveAttributePatch.ts +0 -4
- package/src/parts/RemoveChildPatch/RemoveChildPatch.ts +0 -4
- package/src/parts/RemovePatch/RemovePatch.ts +0 -4
- package/src/parts/RenderInternal/RenderInternal.ts +0 -23
- package/src/parts/ReplacePatch/ReplacePatch.ts +0 -7
- package/src/parts/SetDragImage/SetDragImage.ts +0 -14
- package/src/parts/TextPatch/TextPatch.ts +0 -4
- package/src/parts/UidSymbol/UidSymbol.ts +0 -1
- package/src/parts/VirtualDom/VirtualDom.ts +0 -44
- package/src/parts/VirtualDomElement/VirtualDomElement.ts +0 -32
- package/src/parts/VirtualDomElementProp/VirtualDomElementProp.ts +0 -109
- package/src/parts/VirtualDomElementProps/VirtualDomElementProps.ts +0 -13
- package/src/parts/VirtualDomElements/VirtualDomElements.ts +0 -57
- package/src/parts/VirtualDomNode/VirtualDomNode.ts +0 -4
package/dist/index.js
CHANGED
|
@@ -65,12 +65,13 @@ const Span = 8;
|
|
|
65
65
|
const Table = 9;
|
|
66
66
|
const TBody = 10;
|
|
67
67
|
const Td = 11;
|
|
68
|
-
const Text = 12;
|
|
68
|
+
const Text$1 = 12;
|
|
69
69
|
const Th = 13;
|
|
70
70
|
const THead = 14;
|
|
71
71
|
const Tr = 15;
|
|
72
72
|
const I = 16;
|
|
73
73
|
const Img = 17;
|
|
74
|
+
const Root = 0;
|
|
74
75
|
const Ins = 20;
|
|
75
76
|
const Del = 21;
|
|
76
77
|
const H2 = 22;
|
|
@@ -95,6 +96,7 @@ const Ol = 49;
|
|
|
95
96
|
const P = 50;
|
|
96
97
|
const Pre = 51;
|
|
97
98
|
const A = 53;
|
|
99
|
+
const Abbr = 54;
|
|
98
100
|
const Br = 55;
|
|
99
101
|
const Cite = 56;
|
|
100
102
|
const Data = 57;
|
|
@@ -109,7 +111,68 @@ const Code = 65;
|
|
|
109
111
|
const Label = 66;
|
|
110
112
|
const Dt = 67;
|
|
111
113
|
|
|
112
|
-
const
|
|
114
|
+
const VirtualDomElements = {
|
|
115
|
+
__proto__: null,
|
|
116
|
+
A,
|
|
117
|
+
Abbr,
|
|
118
|
+
Article,
|
|
119
|
+
Aside,
|
|
120
|
+
Audio,
|
|
121
|
+
Br,
|
|
122
|
+
Button,
|
|
123
|
+
Cite,
|
|
124
|
+
Code,
|
|
125
|
+
Col,
|
|
126
|
+
ColGroup,
|
|
127
|
+
Data,
|
|
128
|
+
Dd,
|
|
129
|
+
Del,
|
|
130
|
+
Div,
|
|
131
|
+
Dl,
|
|
132
|
+
Dt,
|
|
133
|
+
Figcaption,
|
|
134
|
+
Figure,
|
|
135
|
+
Footer,
|
|
136
|
+
H1,
|
|
137
|
+
H2,
|
|
138
|
+
H3,
|
|
139
|
+
H4,
|
|
140
|
+
H5,
|
|
141
|
+
H6,
|
|
142
|
+
Header,
|
|
143
|
+
Hr,
|
|
144
|
+
I,
|
|
145
|
+
Img,
|
|
146
|
+
Input,
|
|
147
|
+
Ins,
|
|
148
|
+
Kbd,
|
|
149
|
+
Label,
|
|
150
|
+
Li,
|
|
151
|
+
Nav,
|
|
152
|
+
Ol,
|
|
153
|
+
Option,
|
|
154
|
+
P,
|
|
155
|
+
Pre,
|
|
156
|
+
Root,
|
|
157
|
+
Search,
|
|
158
|
+
Section,
|
|
159
|
+
Select,
|
|
160
|
+
Span,
|
|
161
|
+
TBody,
|
|
162
|
+
THead,
|
|
163
|
+
Table,
|
|
164
|
+
Td,
|
|
165
|
+
Text: Text$1,
|
|
166
|
+
TextArea,
|
|
167
|
+
Tfoot,
|
|
168
|
+
Th,
|
|
169
|
+
Time,
|
|
170
|
+
Tr,
|
|
171
|
+
Ul,
|
|
172
|
+
Video
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const getElementTag$1 = type => {
|
|
113
176
|
switch (type) {
|
|
114
177
|
case Audio:
|
|
115
178
|
return Audio$1;
|
|
@@ -224,6 +287,15 @@ const getElementTag = type => {
|
|
|
224
287
|
}
|
|
225
288
|
};
|
|
226
289
|
|
|
290
|
+
const ElementTagMap = {
|
|
291
|
+
__proto__: null,
|
|
292
|
+
getElementTag: getElementTag$1
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const {
|
|
296
|
+
getElementTag
|
|
297
|
+
} = ElementTagMap;
|
|
298
|
+
|
|
227
299
|
const getEventListenerOptions = (eventName, value) => {
|
|
228
300
|
if (value.passive) {
|
|
229
301
|
return {
|
|
@@ -453,6 +525,9 @@ const setProps = ($Element, props, eventMap, newEventMap) => {
|
|
|
453
525
|
}
|
|
454
526
|
};
|
|
455
527
|
|
|
528
|
+
const {
|
|
529
|
+
Text} = VirtualDomElements;
|
|
530
|
+
|
|
456
531
|
const renderDomTextNode = element => {
|
|
457
532
|
return document.createTextNode(element.text);
|
|
458
533
|
};
|
package/package.json
CHANGED
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './parts/Main/Main.ts'
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getComponentUid } from '../ComponentUid/ComponentUid.ts'
|
|
2
|
-
import { getDragInfo } from '../DragInfo/DragInfo.ts'
|
|
3
|
-
import { setDragImage } from '../SetDragImage/SetDragImage.ts'
|
|
4
|
-
|
|
5
|
-
export const applyDragInfoMaybe = (event: any): void => {
|
|
6
|
-
const { target, dataTransfer } = event
|
|
7
|
-
if (dataTransfer) {
|
|
8
|
-
const uid = getComponentUid(target)
|
|
9
|
-
const dragInfo = getDragInfo(uid)
|
|
10
|
-
if (!dragInfo) {
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
for (const item of dragInfo) {
|
|
14
|
-
dataTransfer.setData(item.type, item.data)
|
|
15
|
-
}
|
|
16
|
-
if (dragInfo.label) {
|
|
17
|
-
setDragImage(dataTransfer, dragInfo.label)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Patch } from '../Patch/Patch.ts'
|
|
2
|
-
import * as PatchFunctions from '../PatchFunctions/PatchFunctions.ts'
|
|
3
|
-
import * as PatchType from '../PatchType/PatchType.ts'
|
|
4
|
-
|
|
5
|
-
export const applyPatch = ($Element: Node, patches: readonly Patch[]): void => {
|
|
6
|
-
let $Current = $Element
|
|
7
|
-
for (const patch of patches) {
|
|
8
|
-
switch (patch.type) {
|
|
9
|
-
case PatchType.SetAttribute:
|
|
10
|
-
PatchFunctions.setAttribute(
|
|
11
|
-
$Current as HTMLElement,
|
|
12
|
-
patch.key,
|
|
13
|
-
patch.value,
|
|
14
|
-
)
|
|
15
|
-
break
|
|
16
|
-
case PatchType.RemoveAttribute:
|
|
17
|
-
PatchFunctions.removeAttribute($Current as HTMLElement, patch.key)
|
|
18
|
-
break
|
|
19
|
-
case PatchType.SetText:
|
|
20
|
-
PatchFunctions.setText($Current as Text, patch.value)
|
|
21
|
-
break
|
|
22
|
-
case PatchType.RemoveChild:
|
|
23
|
-
PatchFunctions.removeChild($Current as HTMLElement, patch.index)
|
|
24
|
-
break
|
|
25
|
-
case PatchType.Add:
|
|
26
|
-
PatchFunctions.add($Current as HTMLElement, patch.nodes)
|
|
27
|
-
break
|
|
28
|
-
case PatchType.NavigateSibling:
|
|
29
|
-
$Current = ($Current.parentNode as HTMLElement).childNodes[patch.index]
|
|
30
|
-
break
|
|
31
|
-
case PatchType.NavigateChild:
|
|
32
|
-
$Current = ($Current as HTMLElement).childNodes[patch.index]
|
|
33
|
-
break
|
|
34
|
-
case PatchType.NavigateParent:
|
|
35
|
-
$Current = $Current.parentNode as HTMLElement
|
|
36
|
-
break
|
|
37
|
-
default:
|
|
38
|
-
break
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as GetEventListenerOptions from '../GetEventListenerOptions/GetEventListenerOptions.ts'
|
|
2
|
-
import * as GetWrappedListener from '../GetWrappedListener/GetWrappedListener.ts'
|
|
3
|
-
|
|
4
|
-
const getOptions = (fn: any): any => {
|
|
5
|
-
if (fn.passive) {
|
|
6
|
-
return {
|
|
7
|
-
passive: true,
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return undefined
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const attachEvent = (
|
|
14
|
-
$Node: HTMLElement,
|
|
15
|
-
eventMap: any,
|
|
16
|
-
key: string,
|
|
17
|
-
value: string,
|
|
18
|
-
newEventMap?: any,
|
|
19
|
-
): void => {
|
|
20
|
-
if (newEventMap && newEventMap[value]) {
|
|
21
|
-
const fn = newEventMap[value]
|
|
22
|
-
const options: any = getOptions(fn)
|
|
23
|
-
// TODO support event listener options
|
|
24
|
-
$Node.addEventListener(key, newEventMap[value], options)
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
const listener = eventMap[value]
|
|
28
|
-
if (!listener) {
|
|
29
|
-
console.warn('listener not found', value)
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
const options = GetEventListenerOptions.getEventListenerOptions(key, value)
|
|
33
|
-
const wrapped = GetWrappedListener.getWrappedListener(
|
|
34
|
-
listener,
|
|
35
|
-
eventMap.returnValue,
|
|
36
|
-
)
|
|
37
|
-
$Node.addEventListener(key, wrapped, options)
|
|
38
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getUidTarget } from '../GetUidTarget/GetUidTarget.ts'
|
|
2
|
-
import { uidSymbol } from '../UidSymbol/UidSymbol.ts'
|
|
3
|
-
|
|
4
|
-
export const setComponentUid = ($Element, uid): void => {
|
|
5
|
-
$Element[uidSymbol] = uid
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const getComponentUid = ($Element): number => {
|
|
9
|
-
const $Target = getUidTarget($Element)
|
|
10
|
-
if (!$Target) {
|
|
11
|
-
return 0
|
|
12
|
-
}
|
|
13
|
-
return $Target[uidSymbol]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const getComponentUidFromEvent = (event): number => {
|
|
17
|
-
const { target, currentTarget } = event
|
|
18
|
-
return getComponentUid(currentTarget || target)
|
|
19
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { applyDragInfoMaybe } from '../ApplyDragInfoMaybe/ApplyDragInfoMaybe.ts'
|
|
2
|
-
import * as ComponentUid from '../ComponentUid/ComponentUid.ts'
|
|
3
|
-
import * as DomEventType from '../DomEventType/DomEventType.ts'
|
|
4
|
-
import * as EventState from '../EventState/EventState.ts'
|
|
5
|
-
import * as GetEventListenerArgs from '../GetEventListenerArgs/GetEventListenerArgs.ts'
|
|
6
|
-
import * as IpcState from '../IpcState/IpcState.ts'
|
|
7
|
-
import * as NameAnonymousFunction from '../NameAnonymousFunction/NameAnonymousFunction.ts'
|
|
8
|
-
import { preventEventsMaybe } from '../PreventEventsMaybe/PreventEventsMaybe.ts'
|
|
9
|
-
|
|
10
|
-
const applyPointerTrackMaybe = (info, map, event): void => {
|
|
11
|
-
const { trackPointerEvents } = info
|
|
12
|
-
if (!trackPointerEvents) {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
const { target, pointerId } = event
|
|
16
|
-
target.setPointerCapture(pointerId)
|
|
17
|
-
const [pointerMoveKey, pointerUpKey] = trackPointerEvents
|
|
18
|
-
target.addEventListener(DomEventType.PointerMove, map[pointerMoveKey])
|
|
19
|
-
// TODO use pointerlost event instead
|
|
20
|
-
target.addEventListener(DomEventType.PointerUp, map[pointerUpKey])
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const createFn = (info, map): any => {
|
|
24
|
-
const fn = (event): void => {
|
|
25
|
-
if (EventState.enabled()) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
const uid = ComponentUid.getComponentUidFromEvent(event)
|
|
29
|
-
const args = GetEventListenerArgs.getEventListenerArgs(info.params, event)
|
|
30
|
-
preventEventsMaybe(info, event)
|
|
31
|
-
applyDragInfoMaybe(event)
|
|
32
|
-
applyPointerTrackMaybe(info, map, event)
|
|
33
|
-
if (args.length === 0) {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
const ipc = IpcState.getIpc()
|
|
37
|
-
ipc.send('Viewlet.executeViewletCommand', uid, ...args)
|
|
38
|
-
}
|
|
39
|
-
NameAnonymousFunction.nameAnonymousFunction(fn, info.name)
|
|
40
|
-
if (info.passive) {
|
|
41
|
-
// TODO avoid mutating function property, maybe return an object with function and options
|
|
42
|
-
fn.passive = true
|
|
43
|
-
}
|
|
44
|
-
return fn
|
|
45
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const dragInfos = Object.create(null)
|
|
2
|
-
|
|
3
|
-
export const setDragInfo = (id: string | number, data: any): void => {
|
|
4
|
-
dragInfos[id] = data
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const getDragInfo = (id: string | number): any => {
|
|
8
|
-
return dragInfos[id]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const removeDragInfo = (id: string | number): void => {
|
|
12
|
-
delete dragInfos[id]
|
|
13
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import * as ElementTag from '../ElementTags/ElementTags.ts'
|
|
2
|
-
import * as VirtualDomElements from '../VirtualDomElements/VirtualDomElements.ts'
|
|
3
|
-
|
|
4
|
-
export const getElementTag = (type: number): string => {
|
|
5
|
-
switch (type) {
|
|
6
|
-
case VirtualDomElements.Audio:
|
|
7
|
-
return ElementTag.Audio
|
|
8
|
-
case VirtualDomElements.H1:
|
|
9
|
-
return ElementTag.H1
|
|
10
|
-
case VirtualDomElements.H2:
|
|
11
|
-
return ElementTag.H2
|
|
12
|
-
case VirtualDomElements.H3:
|
|
13
|
-
return ElementTag.H3
|
|
14
|
-
case VirtualDomElements.H4:
|
|
15
|
-
return ElementTag.H4
|
|
16
|
-
case VirtualDomElements.H5:
|
|
17
|
-
return ElementTag.H5
|
|
18
|
-
case VirtualDomElements.H6:
|
|
19
|
-
return ElementTag.H6
|
|
20
|
-
case VirtualDomElements.Div:
|
|
21
|
-
return ElementTag.Div
|
|
22
|
-
case VirtualDomElements.Kbd:
|
|
23
|
-
return ElementTag.Kbd
|
|
24
|
-
case VirtualDomElements.Table:
|
|
25
|
-
return ElementTag.Table
|
|
26
|
-
case VirtualDomElements.TBody:
|
|
27
|
-
return ElementTag.TBody
|
|
28
|
-
case VirtualDomElements.Th:
|
|
29
|
-
return ElementTag.Th
|
|
30
|
-
case VirtualDomElements.Td:
|
|
31
|
-
return ElementTag.Td
|
|
32
|
-
case VirtualDomElements.THead:
|
|
33
|
-
return ElementTag.THead
|
|
34
|
-
case VirtualDomElements.Tr:
|
|
35
|
-
return ElementTag.Tr
|
|
36
|
-
case VirtualDomElements.Input:
|
|
37
|
-
return ElementTag.Input
|
|
38
|
-
case VirtualDomElements.ColGroup:
|
|
39
|
-
return ElementTag.ColGroup
|
|
40
|
-
case VirtualDomElements.Col:
|
|
41
|
-
return ElementTag.Col
|
|
42
|
-
case VirtualDomElements.Button:
|
|
43
|
-
return ElementTag.Button
|
|
44
|
-
case VirtualDomElements.Span:
|
|
45
|
-
return ElementTag.Span
|
|
46
|
-
case VirtualDomElements.I:
|
|
47
|
-
return ElementTag.I
|
|
48
|
-
case VirtualDomElements.Img:
|
|
49
|
-
return ElementTag.Img
|
|
50
|
-
case VirtualDomElements.Ins:
|
|
51
|
-
return ElementTag.Ins
|
|
52
|
-
case VirtualDomElements.Del:
|
|
53
|
-
return ElementTag.Del
|
|
54
|
-
case VirtualDomElements.Article:
|
|
55
|
-
return ElementTag.Article
|
|
56
|
-
case VirtualDomElements.Aside:
|
|
57
|
-
return ElementTag.Aside
|
|
58
|
-
case VirtualDomElements.Footer:
|
|
59
|
-
return ElementTag.Footer
|
|
60
|
-
case VirtualDomElements.Header:
|
|
61
|
-
return ElementTag.Header
|
|
62
|
-
case VirtualDomElements.Nav:
|
|
63
|
-
return ElementTag.Nav
|
|
64
|
-
case VirtualDomElements.Section:
|
|
65
|
-
return ElementTag.Section
|
|
66
|
-
case VirtualDomElements.Search:
|
|
67
|
-
return ElementTag.Search
|
|
68
|
-
case VirtualDomElements.Dd:
|
|
69
|
-
return ElementTag.Dd
|
|
70
|
-
case VirtualDomElements.Dl:
|
|
71
|
-
return ElementTag.Dl
|
|
72
|
-
case VirtualDomElements.Figcaption:
|
|
73
|
-
return ElementTag.Figcaption
|
|
74
|
-
case VirtualDomElements.Figure:
|
|
75
|
-
return ElementTag.Figure
|
|
76
|
-
case VirtualDomElements.Hr:
|
|
77
|
-
return ElementTag.Hr
|
|
78
|
-
case VirtualDomElements.Li:
|
|
79
|
-
return ElementTag.Li
|
|
80
|
-
case VirtualDomElements.Ol:
|
|
81
|
-
return ElementTag.Ol
|
|
82
|
-
case VirtualDomElements.P:
|
|
83
|
-
return ElementTag.P
|
|
84
|
-
case VirtualDomElements.Pre:
|
|
85
|
-
return ElementTag.Pre
|
|
86
|
-
case VirtualDomElements.A:
|
|
87
|
-
return ElementTag.A
|
|
88
|
-
case VirtualDomElements.Br:
|
|
89
|
-
return ElementTag.Br
|
|
90
|
-
case VirtualDomElements.Cite:
|
|
91
|
-
return ElementTag.Cite
|
|
92
|
-
case VirtualDomElements.Data:
|
|
93
|
-
return ElementTag.Data
|
|
94
|
-
case VirtualDomElements.Time:
|
|
95
|
-
return ElementTag.Time
|
|
96
|
-
case VirtualDomElements.Tfoot:
|
|
97
|
-
return ElementTag.Tfoot
|
|
98
|
-
case VirtualDomElements.Ul:
|
|
99
|
-
return ElementTag.Ul
|
|
100
|
-
case VirtualDomElements.Video:
|
|
101
|
-
return ElementTag.Video
|
|
102
|
-
case VirtualDomElements.TextArea:
|
|
103
|
-
return ElementTag.TextArea
|
|
104
|
-
case VirtualDomElements.Select:
|
|
105
|
-
return ElementTag.Select
|
|
106
|
-
case VirtualDomElements.Option:
|
|
107
|
-
return ElementTag.Option
|
|
108
|
-
case VirtualDomElements.Code:
|
|
109
|
-
return ElementTag.Code
|
|
110
|
-
case VirtualDomElements.Label:
|
|
111
|
-
return ElementTag.Label
|
|
112
|
-
case VirtualDomElements.Dt:
|
|
113
|
-
return ElementTag.Dt
|
|
114
|
-
default:
|
|
115
|
-
throw new Error(`element tag not found ${type}`)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export const Audio = 'audio'
|
|
2
|
-
export const Button = 'button'
|
|
3
|
-
export const Col = 'col'
|
|
4
|
-
export const ColGroup = 'colgroup'
|
|
5
|
-
export const Del = 'del'
|
|
6
|
-
export const Div = 'div'
|
|
7
|
-
export const H1 = 'h1'
|
|
8
|
-
export const H2 = 'h2'
|
|
9
|
-
export const H3 = 'h3'
|
|
10
|
-
export const H4 = 'h4'
|
|
11
|
-
export const H5 = 'h5'
|
|
12
|
-
export const H6 = 'h6'
|
|
13
|
-
export const I = 'i'
|
|
14
|
-
export const Img = 'img'
|
|
15
|
-
export const Input = 'input'
|
|
16
|
-
export const Ins = 'ins'
|
|
17
|
-
export const Kbd = 'kbd'
|
|
18
|
-
export const Span = 'span'
|
|
19
|
-
export const Table = 'table'
|
|
20
|
-
export const TBody = 'tbody'
|
|
21
|
-
export const Td = 'td'
|
|
22
|
-
export const Th = 'th'
|
|
23
|
-
export const THead = 'thead'
|
|
24
|
-
export const Tr = 'tr'
|
|
25
|
-
export const Article = 'article'
|
|
26
|
-
export const Aside = 'aside'
|
|
27
|
-
export const Footer = 'footer'
|
|
28
|
-
export const Header = 'header'
|
|
29
|
-
export const Nav = 'nav'
|
|
30
|
-
export const Section = 'section'
|
|
31
|
-
export const Search = 'search'
|
|
32
|
-
export const Dd = 'dd'
|
|
33
|
-
export const Dl = 'dl'
|
|
34
|
-
export const Figcaption = 'figcaption'
|
|
35
|
-
export const Figure = 'figure'
|
|
36
|
-
export const Hr = 'hr'
|
|
37
|
-
export const Li = 'li'
|
|
38
|
-
export const Ol = 'ol'
|
|
39
|
-
export const P = 'p'
|
|
40
|
-
export const Pre = 'pre'
|
|
41
|
-
export const A = 'a'
|
|
42
|
-
export const Abbr = 'abbr'
|
|
43
|
-
export const Br = 'br'
|
|
44
|
-
export const Cite = 'cite'
|
|
45
|
-
export const Data = 'data'
|
|
46
|
-
export const Time = 'time'
|
|
47
|
-
export const Tfoot = 'tfoot'
|
|
48
|
-
export const Ul = 'ul'
|
|
49
|
-
export const Video = 'video'
|
|
50
|
-
export const TextArea = 'textarea'
|
|
51
|
-
export const Select = 'select'
|
|
52
|
-
export const Option = 'option'
|
|
53
|
-
export const Code = 'code'
|
|
54
|
-
export const Label = 'label'
|
|
55
|
-
export const Dt = 'dt'
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as Id from '../Id/Id.ts'
|
|
2
|
-
|
|
3
|
-
const state: Record<number, Promise<FileSystemHandle>> = Object.create(null)
|
|
4
|
-
|
|
5
|
-
export const acquire = (id: number): Promise<FileSystemHandle> => {
|
|
6
|
-
const promise = state[id]
|
|
7
|
-
delete state[id]
|
|
8
|
-
return promise
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const getFileHandles = async (
|
|
12
|
-
ids: readonly number[],
|
|
13
|
-
): Promise<readonly FileSystemHandle[]> => {
|
|
14
|
-
const promises = ids.map((id) => acquire(id))
|
|
15
|
-
const handles = await Promise.all(promises)
|
|
16
|
-
return handles
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const add = (promise: Promise<FileSystemHandle>): number => {
|
|
20
|
-
const id = Id.create()
|
|
21
|
-
state[id] = promise
|
|
22
|
-
return id
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const addFileHandle = (fileHandle: FileSystemHandle): number => {
|
|
26
|
-
const promise = Promise.resolve(fileHandle)
|
|
27
|
-
return add(promise)
|
|
28
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const getActiveElementInside = (
|
|
2
|
-
$Viewlet: HTMLElement | undefined,
|
|
3
|
-
): HTMLElement | undefined => {
|
|
4
|
-
if (!$Viewlet) {
|
|
5
|
-
return undefined
|
|
6
|
-
}
|
|
7
|
-
const $ActiveElement = document.activeElement as HTMLElement
|
|
8
|
-
if (!$ActiveElement) {
|
|
9
|
-
return undefined
|
|
10
|
-
}
|
|
11
|
-
if (!$Viewlet.contains($ActiveElement)) {
|
|
12
|
-
return undefined
|
|
13
|
-
}
|
|
14
|
-
return $ActiveElement
|
|
15
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as FileHandles from '../FileHandles/FileHandles.ts'
|
|
2
|
-
|
|
3
|
-
const handleDataTransferFiles = (event: any): readonly number[] => {
|
|
4
|
-
const items = [...event.dataTransfer.items]
|
|
5
|
-
const promises = items.map((item) => item.getAsFileSystemHandle())
|
|
6
|
-
const ids = promises.map((promise) => FileHandles.add(promise))
|
|
7
|
-
return ids
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const getEventListenerArg = (param: string, event: any): any => {
|
|
11
|
-
switch (param) {
|
|
12
|
-
case 'event.dataTransfer.files2':
|
|
13
|
-
return handleDataTransferFiles(event)
|
|
14
|
-
case 'event.clientX':
|
|
15
|
-
return event.clientX
|
|
16
|
-
case 'event.x':
|
|
17
|
-
return event.x
|
|
18
|
-
case 'event.clientY':
|
|
19
|
-
return event.clientY
|
|
20
|
-
case 'event.y':
|
|
21
|
-
return event.y
|
|
22
|
-
case 'event.button':
|
|
23
|
-
return event.button
|
|
24
|
-
case 'event.target.value':
|
|
25
|
-
return event.target.value
|
|
26
|
-
case 'event.isTrusted':
|
|
27
|
-
return event.isTrusted
|
|
28
|
-
case 'event.dataTransfer.files':
|
|
29
|
-
return event.dataTransfer.files
|
|
30
|
-
case 'event.target.className':
|
|
31
|
-
return event.target.className
|
|
32
|
-
case 'event.data':
|
|
33
|
-
return event.data
|
|
34
|
-
case 'event.deltaMode':
|
|
35
|
-
return event.deltaMode
|
|
36
|
-
case 'event.deltaX':
|
|
37
|
-
return event.deltaX
|
|
38
|
-
case 'event.deltaY':
|
|
39
|
-
return event.deltaY
|
|
40
|
-
case 'event.target.scrollTop':
|
|
41
|
-
return event.target.scrollTop
|
|
42
|
-
case 'event.detail':
|
|
43
|
-
return event.detail
|
|
44
|
-
case 'event.target.name':
|
|
45
|
-
return event.target.name || ''
|
|
46
|
-
case 'event.target.href':
|
|
47
|
-
return event.target.href
|
|
48
|
-
case 'event.target.src':
|
|
49
|
-
return event.target.src
|
|
50
|
-
case 'event.altKey':
|
|
51
|
-
return event.altKey
|
|
52
|
-
case 'event.key':
|
|
53
|
-
return event.key
|
|
54
|
-
case 'event.ctrlKey':
|
|
55
|
-
return event.ctrlKey
|
|
56
|
-
case 'event.shiftKey':
|
|
57
|
-
return event.shiftKey
|
|
58
|
-
case 'event.inputType':
|
|
59
|
-
return event.inputType
|
|
60
|
-
case 'event.defaultPrevented':
|
|
61
|
-
return event.defaultPrevented
|
|
62
|
-
case 'event.target.dataset.name':
|
|
63
|
-
return event.target.dataset.name
|
|
64
|
-
case 'event.target.dataset.index':
|
|
65
|
-
return event.target.dataset.index
|
|
66
|
-
default:
|
|
67
|
-
return param
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as GetEventListenerArg from '../GetEventListenerArg/GetEventListenerArg.ts'
|
|
2
|
-
|
|
3
|
-
export const getEventListenerArgs = (
|
|
4
|
-
params: readonly string[],
|
|
5
|
-
event: any,
|
|
6
|
-
): readonly any[] => {
|
|
7
|
-
const serialized: any[] = []
|
|
8
|
-
for (const param of params) {
|
|
9
|
-
serialized.push(GetEventListenerArg.getEventListenerArg(param, event))
|
|
10
|
-
}
|
|
11
|
-
return serialized
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const getEventListenerOptions = (eventName: string, value: any): any => {
|
|
2
|
-
if (value.passive) {
|
|
3
|
-
return {
|
|
4
|
-
passive: true,
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
switch (eventName) {
|
|
8
|
-
case 'wheel':
|
|
9
|
-
return {
|
|
10
|
-
passive: true,
|
|
11
|
-
}
|
|
12
|
-
default:
|
|
13
|
-
return undefined
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { uidSymbol } from '../UidSymbol/UidSymbol.ts'
|
|
2
|
-
|
|
3
|
-
export const getUidTarget = (
|
|
4
|
-
$Element: HTMLElement,
|
|
5
|
-
): HTMLElement | undefined => {
|
|
6
|
-
while ($Element) {
|
|
7
|
-
if ($Element[uidSymbol]) {
|
|
8
|
-
return $Element
|
|
9
|
-
}
|
|
10
|
-
$Element = $Element.parentNode as HTMLElement
|
|
11
|
-
}
|
|
12
|
-
return undefined
|
|
13
|
-
}
|