@_unit/unit 1.0.7 → 1.0.8

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.
Files changed (57) hide show
  1. package/build/web.js +1201 -0
  2. package/package.json +1 -1
  3. package/public/_worker.js +294 -103
  4. package/public/_worker.js.map +4 -4
  5. package/public/app/html/index.html +74 -0
  6. package/public/build.json +1 -1
  7. package/public/index.js +297 -103
  8. package/public/index.js.map +4 -4
  9. package/src/API.ts +1 -0
  10. package/src/Class/Graph/index.ts +14 -1
  11. package/src/Class/Graph/interface.ts +7 -0
  12. package/src/Class/Graph/moveSubgraph.ts +25 -25
  13. package/src/client/component.ts +18 -7
  14. package/src/client/extractStyle.ts +161 -0
  15. package/src/client/isTextLike.ts +16 -0
  16. package/src/client/platform/web/api/document.ts +3 -0
  17. package/src/debug/graph/watchGraphInternal.ts +2 -0
  18. package/src/debug/graph/watchGraphSetUnitPinSetIdEvent.ts +39 -0
  19. package/src/docs/concept/README.md +8 -2
  20. package/src/interface.ts +1 -0
  21. package/src/script/build/client.ts +4 -2
  22. package/src/spec/Lazy.ts +10 -2
  23. package/src/spec/util.ts +4 -0
  24. package/src/system/_classes.ts +2 -2
  25. package/src/system/_ids.ts +1 -1
  26. package/src/system/_specs.ts +1 -1
  27. package/src/system/core/unit/MergeInput/spec.json +1 -1
  28. package/src/system/globalComponent.ts +29 -0
  29. package/src/system/platform/api/canvas/AddRect/index.ts +2 -6
  30. package/src/system/platform/api/canvas/ToBlob/index.ts +5 -1
  31. package/src/system/platform/api/media/MediaRecorder/index.ts +6 -0
  32. package/src/system/platform/api/media/RequestPictureInPicture/index.ts +10 -5
  33. package/src/system/platform/api/media/image/{BlobToBitmap → ImageToBitmap}/index.ts +10 -10
  34. package/src/system/platform/api/media/image/{BlobToBitmap → ImageToBitmap}/spec.json +9 -18
  35. package/src/system/platform/component/Iframe/Component.ts +2 -0
  36. package/src/system/platform/component/Inherit/Component.ts +0 -18
  37. package/src/system/platform/component/app/Editor/Component.ts +214 -77
  38. package/src/system/platform/component/app/GUI/Component.ts +19 -4
  39. package/src/system/platform/component/canvas/Canvas/index.ts +2 -2
  40. package/src/system/platform/component/media/Video/index.ts +15 -2
  41. package/src/system/platform/core/SetCurrentTime/spec.json +1 -1
  42. package/src/system/platform/core/SetScale/spec.json +1 -1
  43. package/src/system/platform/core/api/location/LocationQuery/spec.json +1 -1
  44. package/src/system/platform/core/asset/IconNames/spec.json +1 -1
  45. package/src/system/platform/core/canvas/DownloadBlob/spec.json +1 -1
  46. package/src/system/platform/core/component/Charcode/spec.json +1 -1
  47. package/src/system/platform/core/download/DownloadGraph/spec.json +1 -1
  48. package/src/system/platform/core/math/geometry/trigonometry/Hypotenuse/spec.json +1 -1
  49. package/src/system/platform/core/math/power/Pow2/spec.json +1 -1
  50. package/src/system/platform/core/string/RemoveNewLine/spec.json +1 -1
  51. package/src/test/system/core/MergeSort.ts +1 -1
  52. package/src/types/GraphSpec.ts +0 -1
  53. package/src/types/interface/B.ts +3 -1
  54. package/src/types/interface/G.ts +8 -0
  55. package/src/types/interface/async/$G.ts +3 -0
  56. package/src/types/interface/async/AsyncG.ts +10 -0
  57. package/public/metadata.mp4 +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "type": "`U`&`G`&`C`",
2
+ "type": "`U`&`G`",
3
3
  "name": "merge input",
4
4
  "units": {
5
5
  "foreachkeyvalue": {
@@ -1,3 +1,4 @@
1
+ import { NOOP } from '../NOOP'
1
2
  import { Component } from '../client/component'
2
3
  import { System } from '../system'
3
4
  import { Callback } from '../types/Callback'
@@ -30,3 +31,31 @@ export function listenGlobalComponent(
30
31
  emitter.removeListener(id, listener)
31
32
  }
32
33
  }
34
+
35
+ export function awaitGlobalComponent(
36
+ system: System,
37
+ id: string,
38
+ callback: Callback<Component>
39
+ ): Unlisten {
40
+ const { emitter } = system
41
+
42
+ const component = getGlobalComponent(system, id)
43
+
44
+ if (component) {
45
+ callback(component)
46
+
47
+ return NOOP
48
+ }
49
+
50
+ const listener = (component: Component) => {
51
+ callback(component)
52
+ }
53
+
54
+ emitter.addListener(id, listener)
55
+
56
+ const unlisten = () => {
57
+ emitter.removeListener(id, listener)
58
+ }
59
+
60
+ return unlisten
61
+ }
@@ -1,16 +1,12 @@
1
1
  import { Functional } from '../../../../../Class/Functional'
2
2
  import { Done } from '../../../../../Class/Functional/Done'
3
+ import { Rect } from '../../../../../client/util/geometry/types'
3
4
  import { System } from '../../../../../system'
4
5
  import { ID_ADD_RECT } from '../../../../_ids'
5
6
 
6
7
  export interface I<T> {
7
8
  d: any[][]
8
- rect: {
9
- x: number
10
- y: number
11
- width: number
12
- height: number
13
- }
9
+ rect: Rect
14
10
  }
15
11
 
16
12
  export interface O<T> {
@@ -46,7 +46,11 @@ export default class ToBlob<T> extends Semifunctional<I<T>, O<T>> {
46
46
  let _blob: Blob
47
47
 
48
48
  const blob = new (class _Blob extends $ implements B {
49
- __: string[] = ['MS']
49
+ __: string[] = ['B', 'IM']
50
+
51
+ async image(): Promise<any> {
52
+ return _blob
53
+ }
50
54
 
51
55
  async blob(): Promise<Blob> {
52
56
  try {
@@ -74,6 +74,12 @@ export default class _MediaRecorder extends Semifunctional<I, O> {
74
74
  const data = new Blob(chunks, { type: 'audio/wav' })
75
75
 
76
76
  const _blob = new (class _Blob extends $ implements B {
77
+ public __: string[] = ['B', 'IM']
78
+
79
+ async image(): Promise<any> {
80
+ return data
81
+ }
82
+
77
83
  async blob(): Promise<Blob> {
78
84
  return data
79
85
  }
@@ -19,7 +19,7 @@ export interface O {}
19
19
  export default class RequestPictureInPicture extends Semifunctional<I, O> {
20
20
  private _picture_in_picture: any
21
21
 
22
- private _exit_picture_in_picture: Promise<any> = Promise.resolve()
22
+ private _exit_picture_in_picture_promise: Promise<any> = Promise.resolve()
23
23
 
24
24
  constructor(system: System) {
25
25
  super(
@@ -42,26 +42,31 @@ export default class RequestPictureInPicture extends Semifunctional<I, O> {
42
42
  private _unlisten: Unlisten
43
43
 
44
44
  private _plunk() {
45
+ const {
46
+ api: {
47
+ document: { exitPictureInPicture },
48
+ },
49
+ } = this.__system
45
50
  if (this._unlisten) {
46
51
  this._unlisten()
47
52
  this._unlisten = undefined
48
53
  }
49
54
 
50
55
  if (this._picture_in_picture) {
51
- this._exit_picture_in_picture = document.exitPictureInPicture()
56
+ this._exit_picture_in_picture_promise = exitPictureInPicture()
52
57
 
53
58
  this._picture_in_picture = undefined
54
59
  }
55
60
  }
56
61
 
57
62
  async f({ media, opt }: I, done: Done<O>): Promise<void> {
58
- await this._exit_picture_in_picture
63
+ await this._exit_picture_in_picture_promise
59
64
 
60
- const global_id = media.getGlobalId()
65
+ const globalId = media.getGlobalId()
61
66
 
62
67
  listenGlobalComponent(
63
68
  this.__system,
64
- global_id,
69
+ globalId,
65
70
  async (component: VideoComp | null): Promise<void> => {
66
71
  if (component === null) {
67
72
  this._plunk()
@@ -3,12 +3,12 @@ import { Functional } from '../../../../../../Class/Functional'
3
3
  import { Done } from '../../../../../../Class/Functional/Done'
4
4
  import { Rect } from '../../../../../../client/util/geometry/types'
5
5
  import { System } from '../../../../../../system'
6
- import { B } from '../../../../../../types/interface/B'
7
6
  import { IB } from '../../../../../../types/interface/IB'
8
- import { ID_BLOB_TO_BITMAP } from '../../../../../_ids'
7
+ import { IM } from '../../../../../../types/interface/IM'
8
+ import { ID_IMAGE_TO_BITMAP } from '../../../../../_ids'
9
9
 
10
10
  export type I = {
11
- blob: B
11
+ image: IM
12
12
  opt: {}
13
13
  rect:
14
14
  | Rect
@@ -20,16 +20,16 @@ export type O = {
20
20
  bitmap: IB
21
21
  }
22
22
 
23
- export default class BlobToBitmap extends Functional<I, O> {
23
+ export default class ImageToBitmap extends Functional<I, O> {
24
24
  constructor(system: System) {
25
25
  super(
26
26
  {
27
- i: ['opt', 'blob', 'rect'],
27
+ i: ['opt', 'image', 'rect'],
28
28
  o: ['bitmap'],
29
29
  },
30
30
  {
31
31
  input: {
32
- blob: {
32
+ image: {
33
33
  ref: true,
34
34
  },
35
35
  },
@@ -40,11 +40,11 @@ export default class BlobToBitmap extends Functional<I, O> {
40
40
  },
41
41
  },
42
42
  system,
43
- ID_BLOB_TO_BITMAP
43
+ ID_IMAGE_TO_BITMAP
44
44
  )
45
45
  }
46
46
 
47
- async f({ opt, rect, blob }: I, done: Done<O>): Promise<void> {
47
+ async f({ opt, rect, image }: I, done: Done<O>): Promise<void> {
48
48
  const {
49
49
  api: {
50
50
  media: {
@@ -53,12 +53,12 @@ export default class BlobToBitmap extends Functional<I, O> {
53
53
  },
54
54
  } = this.__system
55
55
 
56
- const _blob = await blob.blob()
56
+ const _image = await image.image()
57
57
 
58
58
  let _bitmap: ImageBitmap
59
59
 
60
60
  try {
61
- _bitmap = await createImageBitmap(_blob, rect, opt)
61
+ _bitmap = await createImageBitmap(_image, rect, opt)
62
62
  } catch (err) {
63
63
  done(undefined, err.message)
64
64
 
@@ -1,24 +1,20 @@
1
1
  {
2
- "name": "blob to bitmap",
2
+ "name": "image to bitmap",
3
3
  "inputs": {
4
4
  "opt": {
5
5
  "type": "{imageOrientation?:'none'|'flipY',premultiplyAlpha?:'none'|'premultiply'|'default',colorSpaceConversion?:'none'|'default',resizeWidth?:number,resizeHeight?:number,resizeQuality?:'pixelated'|'low'|'medium'}",
6
6
  "metadata": {
7
- "examples": [
8
- "{}"
9
- ]
7
+ "examples": ["{}"]
10
8
  }
11
9
  },
12
- "blob": {
13
- "type": "`B`",
10
+ "image": {
11
+ "type": "`IM`",
14
12
  "ref": true
15
13
  },
16
14
  "rect": {
17
15
  "type": "{x?:number,y?:number,width?:number,height?:number}",
18
16
  "metadata": {
19
- "examples": [
20
- "{}"
21
- ]
17
+ "examples": ["{}"]
22
18
  }
23
19
  }
24
20
  },
@@ -33,15 +29,10 @@
33
29
  "metadata": {
34
30
  "icon": "image",
35
31
  "complexity": 12,
36
- "tags": [
37
- "platform",
38
- "api",
39
- "media"
40
- ],
41
- "globals": [
42
- "MediaRecorder"
43
- ]
32
+ "description": "transform image to bitmap",
33
+ "tags": ["platform", "api", "media"],
34
+ "globals": ["MediaRecorder"]
44
35
  },
45
36
  "type": "`U`",
46
37
  "system": true
47
- }
38
+ }
@@ -75,6 +75,8 @@ export default class Iframe extends Element<
75
75
  iframe_el.srcdoc = srcdoc
76
76
  }
77
77
 
78
+ iframe_el.allowFullscreen = true
79
+
78
80
  this._setSrc(src)
79
81
 
80
82
  applyStyle(iframe_el, { ...DEFAULT_STYLE, ...style })
@@ -34,18 +34,6 @@ export default class Inherit extends Element<HTMLDivElement, Props> {
34
34
  private _registerChild = (child) => {
35
35
  let base = child.getRootBase()
36
36
 
37
- for (const parent_root of child.$parentRoot) {
38
- const parent_child_base = parent_root.getRootBase()
39
-
40
- base = [...base, ...parent_child_base]
41
- }
42
-
43
- for (const parent_child of child.$parentChildren) {
44
- const parent_child_base = parent_child.getRootBase()
45
-
46
- base = [...base, ...parent_child_base]
47
- }
48
-
49
37
  for (const leaf of base) {
50
38
  const [leaf_path, leaf_comp] = leaf
51
39
 
@@ -68,12 +56,6 @@ export default class Inherit extends Element<HTMLDivElement, Props> {
68
56
  private _unregisterChild = (child: Component) => {
69
57
  let base = child.getRootBase()
70
58
 
71
- for (const parent_child of child.$parentChildren) {
72
- const parent_child_base = parent_child.getRootBase()
73
-
74
- base = [...base, ...parent_child_base]
75
- }
76
-
77
59
  const base_length = base.length
78
60
 
79
61
  const first_leaf = base[0]