@lvce-editor/virtual-dom 1.0.3 → 1.1.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 CHANGED
@@ -1,8 +1,7 @@
1
- // src/parts/ComponentUid/ComponentUid.ts
1
+ // src/parts/UidSymbol/UidSymbol.ts
2
2
  var uidSymbol = Symbol("uid");
3
- var setComponentUid = ($Element, uid) => {
4
- $Element[uidSymbol] = uid;
5
- };
3
+
4
+ // src/parts/GetUidTarget/GetUidTarget.ts
6
5
  var getUidTarget = ($Element) => {
7
6
  while ($Element) {
8
7
  if ($Element[uidSymbol]) {
@@ -12,6 +11,11 @@ var getUidTarget = ($Element) => {
12
11
  }
13
12
  return void 0;
14
13
  };
14
+
15
+ // src/parts/ComponentUid/ComponentUid.ts
16
+ var setComponentUid = ($Element, uid) => {
17
+ $Element[uidSymbol] = uid;
18
+ };
15
19
  var getComponentUid = ($Element) => {
16
20
  const $Target = getUidTarget($Element);
17
21
  if (!$Target) {
@@ -269,6 +273,18 @@ var getEventListenerOptions = (eventName) => {
269
273
  }
270
274
  };
271
275
 
276
+ // src/parts/ListenerCache/ListenerCache.ts
277
+ var cache = /* @__PURE__ */ new Map();
278
+ var has = (listener) => {
279
+ return cache.has(listener);
280
+ };
281
+ var set = (listener, value) => {
282
+ cache.set(listener, value);
283
+ };
284
+ var get = (listener) => {
285
+ return cache.get(listener);
286
+ };
287
+
272
288
  // src/parts/NameAnonymousFunction/NameAnonymousFunction.ts
273
289
  var nameAnonymousFunction = (fn, name) => {
274
290
  Object.defineProperty(fn, "name", {
@@ -277,12 +293,11 @@ var nameAnonymousFunction = (fn, name) => {
277
293
  };
278
294
 
279
295
  // src/parts/GetWrappedListener/GetWrappedListener.ts
280
- var cache = /* @__PURE__ */ new Map();
281
296
  var getWrappedListener = (listener, returnValue) => {
282
297
  if (!returnValue) {
283
298
  return listener;
284
299
  }
285
- if (!cache.has(listener)) {
300
+ if (!has(listener)) {
286
301
  const wrapped = (event) => {
287
302
  const uid = getComponentUidFromEvent(event);
288
303
  const result = listener(event);
@@ -293,9 +308,9 @@ var getWrappedListener = (listener, returnValue) => {
293
308
  ipc.send("Viewlet.executeViewletCommand", uid, ...result);
294
309
  };
295
310
  nameAnonymousFunction(wrapped, listener.name);
296
- cache.set(listener, wrapped);
311
+ set(listener, wrapped);
297
312
  }
298
- return cache.get(listener);
313
+ return get(listener);
299
314
  };
300
315
 
301
316
  // src/parts/AttachEvent/AttachEvent.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -1,3 +1,3 @@
1
- export const clearNode = ($Node) => {
1
+ export const clearNode = ($Node: HTMLElement): void => {
2
2
  $Node.textContent = ''
3
3
  }
@@ -1,19 +1,10 @@
1
- const uidSymbol = Symbol('uid')
1
+ import { getUidTarget } from '../GetUidTarget/GetUidTarget.ts'
2
+ import { uidSymbol } from '../UidSymbol/UidSymbol.ts'
2
3
 
3
4
  export const setComponentUid = ($Element, uid) => {
4
5
  $Element[uidSymbol] = uid
5
6
  }
6
7
 
7
- const getUidTarget = ($Element) => {
8
- while ($Element) {
9
- if ($Element[uidSymbol]) {
10
- return $Element
11
- }
12
- $Element = $Element.parentNode
13
- }
14
- return undefined
15
- }
16
-
17
8
  export const getComponentUid = ($Element) => {
18
9
  const $Target = getUidTarget($Element)
19
10
  if (!$Target) {
@@ -0,0 +1,11 @@
1
+ import { uidSymbol } from '../UidSymbol/UidSymbol.ts'
2
+
3
+ export const getUidTarget = ($Element) => {
4
+ while ($Element) {
5
+ if ($Element[uidSymbol]) {
6
+ return $Element
7
+ }
8
+ $Element = $Element.parentNode
9
+ }
10
+ return undefined
11
+ }
@@ -1,14 +1,13 @@
1
1
  import * as ComponentUid from '../ComponentUid/ComponentUid.ts'
2
- import * as NameAnonymousFunction from '../NameAnonymousFunction/NameAnonymousFunction.ts'
3
2
  import * as IpcState from '../IpcState/IpcState.ts'
4
-
5
- const cache = new Map()
3
+ import * as ListenerCache from '../ListenerCache/ListenerCache.ts'
4
+ import * as NameAnonymousFunction from '../NameAnonymousFunction/NameAnonymousFunction.ts'
6
5
 
7
6
  export const getWrappedListener = (listener, returnValue) => {
8
7
  if (!returnValue) {
9
8
  return listener
10
9
  }
11
- if (!cache.has(listener)) {
10
+ if (!ListenerCache.has(listener)) {
12
11
  const wrapped = (event) => {
13
12
  const uid = ComponentUid.getComponentUidFromEvent(event)
14
13
  const result = listener(event)
@@ -20,7 +19,7 @@ export const getWrappedListener = (listener, returnValue) => {
20
19
  ipc.send('Viewlet.executeViewletCommand', uid, ...result)
21
20
  }
22
21
  NameAnonymousFunction.nameAnonymousFunction(wrapped, listener.name)
23
- cache.set(listener, wrapped)
22
+ ListenerCache.set(listener, wrapped)
24
23
  }
25
- return cache.get(listener)
24
+ return ListenerCache.get(listener)
26
25
  }
@@ -0,0 +1,13 @@
1
+ const cache = new Map()
2
+
3
+ export const has = (listener) => {
4
+ return cache.has(listener)
5
+ }
6
+
7
+ export const set = (listener, value) => {
8
+ cache.set(listener, value)
9
+ }
10
+
11
+ export const get = (listener) => {
12
+ return cache.get(listener)
13
+ }
@@ -0,0 +1 @@
1
+ export const uidSymbol = Symbol('uid')
@@ -1,6 +1,11 @@
1
1
  import * as AttachEvent from '../AttachEvent/AttachEvent.ts'
2
2
 
3
- export const setProp = ($Element: HTMLElement, key: string, value: any, eventMap: any) => {
3
+ export const setProp = (
4
+ $Element: HTMLElement,
5
+ key: string,
6
+ value: any,
7
+ eventMap: any,
8
+ ) => {
4
9
  switch (key) {
5
10
  case 'maskImage':
6
11
  $Element.style.maskImage = `url('${value}')`