@_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.
- package/build/web.js +1201 -0
- package/package.json +1 -1
- package/public/_worker.js +294 -103
- package/public/_worker.js.map +4 -4
- package/public/app/html/index.html +74 -0
- package/public/build.json +1 -1
- package/public/index.js +297 -103
- package/public/index.js.map +4 -4
- package/src/API.ts +1 -0
- package/src/Class/Graph/index.ts +14 -1
- package/src/Class/Graph/interface.ts +7 -0
- package/src/Class/Graph/moveSubgraph.ts +25 -25
- package/src/client/component.ts +18 -7
- package/src/client/extractStyle.ts +161 -0
- package/src/client/isTextLike.ts +16 -0
- package/src/client/platform/web/api/document.ts +3 -0
- package/src/debug/graph/watchGraphInternal.ts +2 -0
- package/src/debug/graph/watchGraphSetUnitPinSetIdEvent.ts +39 -0
- package/src/docs/concept/README.md +8 -2
- package/src/interface.ts +1 -0
- package/src/script/build/client.ts +4 -2
- package/src/spec/Lazy.ts +10 -2
- package/src/spec/util.ts +4 -0
- package/src/system/_classes.ts +2 -2
- package/src/system/_ids.ts +1 -1
- package/src/system/_specs.ts +1 -1
- package/src/system/core/unit/MergeInput/spec.json +1 -1
- package/src/system/globalComponent.ts +29 -0
- package/src/system/platform/api/canvas/AddRect/index.ts +2 -6
- package/src/system/platform/api/canvas/ToBlob/index.ts +5 -1
- package/src/system/platform/api/media/MediaRecorder/index.ts +6 -0
- package/src/system/platform/api/media/RequestPictureInPicture/index.ts +10 -5
- package/src/system/platform/api/media/image/{BlobToBitmap → ImageToBitmap}/index.ts +10 -10
- package/src/system/platform/api/media/image/{BlobToBitmap → ImageToBitmap}/spec.json +9 -18
- package/src/system/platform/component/Iframe/Component.ts +2 -0
- package/src/system/platform/component/Inherit/Component.ts +0 -18
- package/src/system/platform/component/app/Editor/Component.ts +214 -77
- package/src/system/platform/component/app/GUI/Component.ts +19 -4
- package/src/system/platform/component/canvas/Canvas/index.ts +2 -2
- package/src/system/platform/component/media/Video/index.ts +15 -2
- package/src/system/platform/core/SetCurrentTime/spec.json +1 -1
- package/src/system/platform/core/SetScale/spec.json +1 -1
- package/src/system/platform/core/api/location/LocationQuery/spec.json +1 -1
- package/src/system/platform/core/asset/IconNames/spec.json +1 -1
- package/src/system/platform/core/canvas/DownloadBlob/spec.json +1 -1
- package/src/system/platform/core/component/Charcode/spec.json +1 -1
- package/src/system/platform/core/download/DownloadGraph/spec.json +1 -1
- package/src/system/platform/core/math/geometry/trigonometry/Hypotenuse/spec.json +1 -1
- package/src/system/platform/core/math/power/Pow2/spec.json +1 -1
- package/src/system/platform/core/string/RemoveNewLine/spec.json +1 -1
- package/src/test/system/core/MergeSort.ts +1 -1
- package/src/types/GraphSpec.ts +0 -1
- package/src/types/interface/B.ts +3 -1
- package/src/types/interface/G.ts +8 -0
- package/src/types/interface/async/$G.ts +3 -0
- package/src/types/interface/async/AsyncG.ts +10 -0
- package/public/metadata.mp4 +0 -0
|
@@ -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[] = ['
|
|
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
|
|
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.
|
|
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.
|
|
63
|
+
await this._exit_picture_in_picture_promise
|
|
59
64
|
|
|
60
|
-
const
|
|
65
|
+
const globalId = media.getGlobalId()
|
|
61
66
|
|
|
62
67
|
listenGlobalComponent(
|
|
63
68
|
this.__system,
|
|
64
|
-
|
|
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 {
|
|
7
|
+
import { IM } from '../../../../../../types/interface/IM'
|
|
8
|
+
import { ID_IMAGE_TO_BITMAP } from '../../../../../_ids'
|
|
9
9
|
|
|
10
10
|
export type I = {
|
|
11
|
-
|
|
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
|
|
23
|
+
export default class ImageToBitmap extends Functional<I, O> {
|
|
24
24
|
constructor(system: System) {
|
|
25
25
|
super(
|
|
26
26
|
{
|
|
27
|
-
i: ['opt', '
|
|
27
|
+
i: ['opt', 'image', 'rect'],
|
|
28
28
|
o: ['bitmap'],
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
input: {
|
|
32
|
-
|
|
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
|
-
|
|
43
|
+
ID_IMAGE_TO_BITMAP
|
|
44
44
|
)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
async f({ opt, rect,
|
|
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
|
|
56
|
+
const _image = await image.image()
|
|
57
57
|
|
|
58
58
|
let _bitmap: ImageBitmap
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
|
-
_bitmap = await createImageBitmap(
|
|
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": "
|
|
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
|
-
"
|
|
13
|
-
"type": "`
|
|
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
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}
|
|
@@ -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]
|