@omnimedia/omnitool 1.1.0-7 → 1.1.0-9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnimedia/omnitool",
3
- "version": "1.1.0-7",
3
+ "version": "1.1.0-9",
4
4
  "description": "open source video processing tools",
5
5
  "license": "MIT",
6
6
  "author": "Przemysław Gałęzki",
@@ -1,102 +1,102 @@
1
- import {O} from "./o.js"
2
- import {Id} from "../parts/basics.js"
3
- import {Item} from "../parts/item.js"
4
-
5
- export class TimelineItem {
6
- public readonly id: Id
7
-
8
- constructor(public item: Item.Any) {
9
- this.id = item.id
10
- }
11
-
12
- toJSON() {
13
- return {
14
- ...this.item
15
- }
16
- }
17
- }
18
-
19
- abstract class VisualItem extends TimelineItem {
20
- abstract spatial(spatial: Spatial): TimelineItem
21
- }
22
-
23
- export class Stack extends VisualItem {
24
- constructor(private o: O, public item: Item.Stack) {
25
- super(item)
26
- }
27
-
28
- spatial(spatial: Spatial) {
29
- this.item.spatialId = spatial.item.id
30
- return this
31
- }
32
-
33
- addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
34
- const result = fn(this.o)
35
- const items = Array.isArray(result) ? result : [result]
36
- this.item.childrenIds.push(...items.map(c => c.item.id))
37
- return this
38
- }
39
- }
40
-
41
- export class Spatial extends TimelineItem {
42
- constructor(public item: Item.Spatial) {super(item)}
43
- }
44
-
45
- export class Gap extends TimelineItem {
46
- constructor(public item: Item.Gap) {super(item)}
47
- }
48
-
49
- export class Audio extends TimelineItem {
50
- constructor(public item: Item.Audio) {super(item)}
51
- }
52
-
53
- export class Video extends VisualItem {
54
- constructor(public item: Item.Video) {
55
- super(item)
56
- }
57
-
58
- spatial(spatial: Spatial) {
59
- this.item.spatialId = spatial.item.id
60
- return this
61
- }
62
- }
63
-
64
- export class Text extends VisualItem {
65
- constructor(public item: Item.Text) {
66
- super(item)
67
- }
68
-
69
- color(color: string) {
70
- this.item.color = color
71
- return this
72
- }
73
-
74
- spatial(spatial: Spatial) {
75
- this.item.spatialId = spatial.item.id
76
- return this
77
- }
78
- }
79
-
80
- export class Sequence extends VisualItem {
81
- constructor(private o: O, public item: Item.Sequence) {
82
- super(item)
83
- }
84
-
85
- spatial(spatial: Spatial) {
86
- this.item.spatialId = spatial.item.id
87
- return this
88
- }
89
-
90
- addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
91
- const result = fn(this.o)
92
- const items = Array.isArray(result) ? result : [result]
93
- this.item.childrenIds.push(...items.map(c => c.item.id))
94
- return this
95
- }
96
- }
97
-
98
- export class Transition extends TimelineItem {
99
- constructor(public item: Item.Transition) {
100
- super(item)
101
- }
102
- }
1
+ // import {O} from "./o.js"
2
+ // import {Id} from "../parts/basics.js"
3
+ // import {Item} from "../parts/item.js"
4
+ //
5
+ // export class TimelineItem {
6
+ // public readonly id: Id
7
+ //
8
+ // constructor(public item: Item.Any) {
9
+ // this.id = item.id
10
+ // }
11
+ //
12
+ // toJSON() {
13
+ // return {
14
+ // ...this.item
15
+ // }
16
+ // }
17
+ // }
18
+ //
19
+ // abstract class VisualItem extends TimelineItem {
20
+ // abstract spatial(spatial: Spatial): TimelineItem
21
+ // }
22
+ //
23
+ // export class Stack extends VisualItem {
24
+ // constructor(private o: O, public item: Item.Stack) {
25
+ // super(item)
26
+ // }
27
+ //
28
+ // spatial(spatial: Spatial) {
29
+ // this.item.spatialId = spatial.item.id
30
+ // return this
31
+ // }
32
+ //
33
+ // addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
34
+ // const result = fn(this.o)
35
+ // const items = Array.isArray(result) ? result : [result]
36
+ // this.item.childrenIds.push(...items.map(c => c.item.id))
37
+ // return this
38
+ // }
39
+ // }
40
+ //
41
+ // export class Spatial extends TimelineItem {
42
+ // constructor(public item: Item.Spatial) {super(item)}
43
+ // }
44
+ //
45
+ // export class Gap extends TimelineItem {
46
+ // constructor(public item: Item.Gap) {super(item)}
47
+ // }
48
+ //
49
+ // export class Audio extends TimelineItem {
50
+ // constructor(public item: Item.Audio) {super(item)}
51
+ // }
52
+ //
53
+ // export class Video extends VisualItem {
54
+ // constructor(public item: Item.Video) {
55
+ // super(item)
56
+ // }
57
+ //
58
+ // spatial(spatial: Spatial) {
59
+ // this.item.spatialId = spatial.item.id
60
+ // return this
61
+ // }
62
+ // }
63
+ //
64
+ // export class Text extends VisualItem {
65
+ // constructor(public item: Item.Text) {
66
+ // super(item)
67
+ // }
68
+ //
69
+ // color(color: string) {
70
+ // this.item.color = color
71
+ // return this
72
+ // }
73
+ //
74
+ // spatial(spatial: Spatial) {
75
+ // this.item.spatialId = spatial.item.id
76
+ // return this
77
+ // }
78
+ // }
79
+ //
80
+ // export class Sequence extends VisualItem {
81
+ // constructor(private o: O, public item: Item.Sequence) {
82
+ // super(item)
83
+ // }
84
+ //
85
+ // spatial(spatial: Spatial) {
86
+ // this.item.spatialId = spatial.item.id
87
+ // return this
88
+ // }
89
+ //
90
+ // addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
91
+ // const result = fn(this.o)
92
+ // const items = Array.isArray(result) ? result : [result]
93
+ // this.item.childrenIds.push(...items.map(c => c.item.id))
94
+ // return this
95
+ // }
96
+ // }
97
+ //
98
+ // export class Transition extends TimelineItem {
99
+ // constructor(public item: Item.Transition) {
100
+ // super(item)
101
+ // }
102
+ // }
@@ -1,57 +1,73 @@
1
1
 
2
- import {MapG} from "@e280/stz"
3
- import {Id} from "../parts/basics.js"
4
2
  import {Media} from "../parts/media.js"
3
+ import {Id, TimelineFile} from "../parts/basics.js"
5
4
  import {Effect, Item, Kind} from "../parts/item.js"
6
5
  import {Transform, TransformOptions, Vec2} from "../types.js"
7
- import {Video, Gap, Sequence, Stack, Text, TimelineItem, Spatial, Audio, Transition} from "./builders.js"
8
6
 
9
7
  export class O {
10
8
  #nextId = 0
11
- #items = new MapG<Id, TimelineItem>()
12
9
 
13
- #getId() {
14
- return this.#nextId++
15
- }
10
+ constructor(public state: {project: TimelineFile}) {}
16
11
 
17
- register(item: TimelineItem) {
18
- if (!this.#items.has(item.id))
19
- this.#items.set(item.id, item)
20
- return item.id
21
- }
12
+ require<T extends Item.Any>(id: Id): T {
13
+ const item = this.state.project.items.find(item => item.id === id)
14
+ return item as T
15
+ }
22
16
 
23
- get items() {
24
- return [...this.#items.values()]
17
+ #getId() {
18
+ return this.#nextId++
25
19
  }
26
20
 
27
- get itemsMap() {
28
- return this.#items
29
- }
21
+ #mutate(fn: (project: TimelineFile) => TimelineFile) {
22
+ this.state.project = fn(this.state.project)
23
+ }
30
24
 
31
- spatial = (transform: Transform) => {
25
+ spatial = (transform: Transform): Item.Spatial => {
32
26
  const item: Item.Spatial = {
33
27
  id: this.#getId(),
34
28
  kind: Kind.Spatial,
35
29
  transform
36
30
  }
37
- const spatial = new Spatial(item)
38
- this.register(spatial)
39
- return spatial
31
+ return item
40
32
  }
41
33
 
42
- sequence = (...items: TimelineItem[]) => new Sequence(this, {
43
- id: this.#getId(),
44
- kind: Kind.Sequence,
45
- childrenIds: items.map((item) => this.register(item))
46
- })
34
+ sequence = (...items: Item.Any[]): Item.Any => {
35
+ const item = {
36
+ id: this.#getId(),
37
+ kind: Kind.Sequence,
38
+ childrenIds: items.map(item => item.id)
39
+ } as Item.Sequence
47
40
 
48
- stack = (...items: TimelineItem[]) => new Stack(this, {
49
- kind: Kind.Stack,
50
- id: this.#getId(),
51
- childrenIds: items.map(item => this.register(item))
52
- })
41
+ this.#mutate(state => {
42
+ state.items.push(item, ...items)
43
+ return state
44
+ })
45
+
46
+ return item
47
+ }
48
+
49
+ stack = (...items: Item.Any[]): Item.Any => {
50
+ const item = {
51
+ kind: Kind.Stack,
52
+ id: this.#getId(),
53
+ childrenIds: items.map(item => item.id)
54
+ } as Item.Stack
55
+
56
+ this.#mutate(state => {
57
+ state.items.push(item, ...items)
58
+ return state
59
+ })
60
+
61
+ return item
62
+ }
63
+
64
+ video = (
65
+ media: Media,
66
+ options?: {
67
+ start?: number,
68
+ duration?: number
69
+ }): Item.Video => {
53
70
 
54
- video = (media: Media, options?: {start?: number, duration?: number}) => {
55
71
  if(!media.hasVideo)
56
72
  throw new Error(`Video clip error: media "${media.datafile.filename}" has no video track.`)
57
73
 
@@ -63,10 +79,16 @@ export class O {
63
79
  duration: options?.duration ?? media.duration
64
80
  }
65
81
 
66
- return new Video(item)
82
+ return item
67
83
  }
68
84
 
69
- audio = (media: Media, options?: {start?: number, duration?: number}) => {
85
+ audio = (
86
+ media: Media,
87
+ options?: {
88
+ start?: number,
89
+ duration?: number
90
+ }): Item.Audio => {
91
+
70
92
  if(!media.hasAudio)
71
93
  throw new Error(`Audio clip error: media "${media.datafile.filename}" has no audio track.`)
72
94
 
@@ -78,24 +100,24 @@ export class O {
78
100
  duration: options?.duration ?? media.duration
79
101
  }
80
102
 
81
- return new Audio(item)
103
+ return item
82
104
  }
83
105
 
84
- text = (content: string) => new Text({
106
+ text = (content: string): Item.Text => ({
85
107
  id: this.#getId(),
86
108
  content,
87
109
  kind: Kind.Text,
88
110
  color: "#FFFFF"
89
111
  })
90
112
 
91
- gap = (duration: number) => new Gap({
113
+ gap = (duration: number): Item.Gap => ({
92
114
  id: this.#getId(),
93
115
  kind: Kind.Gap,
94
116
  duration
95
117
  })
96
118
 
97
119
  transition = {
98
- crossfade: (duration: number) => new Transition({
120
+ crossfade: (duration: number): Item.Transition => ({
99
121
  id: this.#getId(),
100
122
  kind: Kind.Transition,
101
123
  effect: Effect.Crossfade,
@@ -115,5 +137,14 @@ export class O {
115
137
  const rotation = options?.rotation ?? 0
116
138
  return [position, scale, rotation]
117
139
  }
140
+
141
+ addChildren(parent: Item.Stack | Item.Sequence, ...items: Item.Any[]) {
142
+ this.#mutate(state => {
143
+ const parentItem = state.items.find(({id}) => id === parent.id) as Item.Stack
144
+ parentItem.childrenIds.push(...items.map(item => item.id))
145
+ state.items.push(...items)
146
+ return state
147
+ })
148
+ }
118
149
  }
119
150
 
@@ -1,8 +1,7 @@
1
1
 
2
2
  import {O} from "./o.js"
3
- import {Timeline} from "../timeline.js"
3
+ import {Item} from "../parts/item.js"
4
4
  import {Media} from "../parts/media.js"
5
- import {TimelineItem} from "./builders.js"
6
5
  import {Datafile} from "../utils/datafile.js"
7
6
  import {TimelineFile} from "../parts/basics.js"
8
7
  import {Export} from "../parts/compositor/export.js"
@@ -19,11 +18,19 @@ export class Omni {
19
18
  ))) as {[K in keyof S]: Media}
20
19
  }
21
20
 
22
- timeline = (fn: (o: O) => TimelineItem): Timeline => {
23
- const o = new O()
21
+ timeline = (fn: (o: O) => Item.Any): TimelineFile => {
22
+ const o = new O({
23
+ project: {
24
+ format: "timeline",
25
+ info: "https://omniclip.app/",
26
+ version: 0,
27
+ items: [],
28
+ rootId: 0
29
+ }
30
+ })
24
31
  const root = fn(o)
25
- o.register(root)
26
- return new Timeline(root, o.itemsMap)
32
+ o.state.project.rootId = root.id
33
+ return o.state.project
27
34
  }
28
35
 
29
36
  render = async (timeline: TimelineFile, config: RenderConfig) => {
package/x/index.html CHANGED
@@ -85,7 +85,7 @@ canvas {
85
85
  <body>
86
86
 
87
87
  <section>
88
- <h1>Omnitool <small>v1.1.0-7</small></h1>
88
+ <h1>Omnitool <small>v1.1.0-9</small></h1>
89
89
  <button class=fetch>fetch</button>
90
90
  <input type="file" class="file-input">
91
91
  <div class=results></div>
@@ -1,96 +1 @@
1
- import { O } from "./o.js";
2
- import { Id } from "../parts/basics.js";
3
- import { Item } from "../parts/item.js";
4
- export declare class TimelineItem {
5
- item: Item.Any;
6
- readonly id: Id;
7
- constructor(item: Item.Any);
8
- toJSON(): {
9
- id: Id;
10
- kind: import("../parts/item.js").Kind.Spatial;
11
- transform: import("../types.js").Transform;
12
- } | {
13
- id: Id;
14
- kind: import("../parts/item.js").Kind.Gap;
15
- duration: number;
16
- } | {
17
- id: Id;
18
- kind: import("../parts/item.js").Kind.Sequence;
19
- childrenIds: Id[];
20
- spatialId?: Id;
21
- } | {
22
- id: Id;
23
- kind: import("../parts/item.js").Kind.Stack;
24
- childrenIds: Id[];
25
- spatialId?: Id;
26
- } | {
27
- id: Id;
28
- kind: import("../parts/item.js").Kind.Video;
29
- mediaHash: import("../parts/basics.js").Hash;
30
- start: number;
31
- duration: number;
32
- spatialId?: Id;
33
- } | {
34
- id: Id;
35
- kind: import("../parts/item.js").Kind.Audio;
36
- mediaHash: import("../parts/basics.js").Hash;
37
- start: number;
38
- duration: number;
39
- } | {
40
- id: Id;
41
- kind: import("../parts/item.js").Kind.Text;
42
- content: string;
43
- spatialId?: Id;
44
- color: string;
45
- } | {
46
- id: Id;
47
- kind: import("../parts/item.js").Kind.Transition;
48
- effect: import("../parts/item.js").Effect.Crossfade;
49
- duration: number;
50
- };
51
- }
52
- declare abstract class VisualItem extends TimelineItem {
53
- abstract spatial(spatial: Spatial): TimelineItem;
54
- }
55
- export declare class Stack extends VisualItem {
56
- private o;
57
- item: Item.Stack;
58
- constructor(o: O, item: Item.Stack);
59
- spatial(spatial: Spatial): this;
60
- addChildren(fn: (o: O) => TimelineItem | TimelineItem[]): this;
61
- }
62
- export declare class Spatial extends TimelineItem {
63
- item: Item.Spatial;
64
- constructor(item: Item.Spatial);
65
- }
66
- export declare class Gap extends TimelineItem {
67
- item: Item.Gap;
68
- constructor(item: Item.Gap);
69
- }
70
- export declare class Audio extends TimelineItem {
71
- item: Item.Audio;
72
- constructor(item: Item.Audio);
73
- }
74
- export declare class Video extends VisualItem {
75
- item: Item.Video;
76
- constructor(item: Item.Video);
77
- spatial(spatial: Spatial): this;
78
- }
79
- export declare class Text extends VisualItem {
80
- item: Item.Text;
81
- constructor(item: Item.Text);
82
- color(color: string): this;
83
- spatial(spatial: Spatial): this;
84
- }
85
- export declare class Sequence extends VisualItem {
86
- private o;
87
- item: Item.Sequence;
88
- constructor(o: O, item: Item.Sequence);
89
- spatial(spatial: Spatial): this;
90
- addChildren(fn: (o: O) => TimelineItem | TimelineItem[]): this;
91
- }
92
- export declare class Transition extends TimelineItem {
93
- item: Item.Transition;
94
- constructor(item: Item.Transition);
95
- }
96
1
  export {};
@@ -1,108 +1,104 @@
1
- export class TimelineItem {
2
- item;
3
- id;
4
- constructor(item) {
5
- this.item = item;
6
- this.id = item.id;
7
- }
8
- toJSON() {
9
- return {
10
- ...this.item
11
- };
12
- }
13
- }
14
- class VisualItem extends TimelineItem {
15
- }
16
- export class Stack extends VisualItem {
17
- o;
18
- item;
19
- constructor(o, item) {
20
- super(item);
21
- this.o = o;
22
- this.item = item;
23
- }
24
- spatial(spatial) {
25
- this.item.spatialId = spatial.item.id;
26
- return this;
27
- }
28
- addChildren(fn) {
29
- const result = fn(this.o);
30
- const items = Array.isArray(result) ? result : [result];
31
- this.item.childrenIds.push(...items.map(c => c.item.id));
32
- return this;
33
- }
34
- }
35
- export class Spatial extends TimelineItem {
36
- item;
37
- constructor(item) {
38
- super(item);
39
- this.item = item;
40
- }
41
- }
42
- export class Gap extends TimelineItem {
43
- item;
44
- constructor(item) {
45
- super(item);
46
- this.item = item;
47
- }
48
- }
49
- export class Audio extends TimelineItem {
50
- item;
51
- constructor(item) {
52
- super(item);
53
- this.item = item;
54
- }
55
- }
56
- export class Video extends VisualItem {
57
- item;
58
- constructor(item) {
59
- super(item);
60
- this.item = item;
61
- }
62
- spatial(spatial) {
63
- this.item.spatialId = spatial.item.id;
64
- return this;
65
- }
66
- }
67
- export class Text extends VisualItem {
68
- item;
69
- constructor(item) {
70
- super(item);
71
- this.item = item;
72
- }
73
- color(color) {
74
- this.item.color = color;
75
- return this;
76
- }
77
- spatial(spatial) {
78
- this.item.spatialId = spatial.item.id;
79
- return this;
80
- }
81
- }
82
- export class Sequence extends VisualItem {
83
- o;
84
- item;
85
- constructor(o, item) {
86
- super(item);
87
- this.o = o;
88
- this.item = item;
89
- }
90
- spatial(spatial) {
91
- this.item.spatialId = spatial.item.id;
92
- return this;
93
- }
94
- addChildren(fn) {
95
- const result = fn(this.o);
96
- const items = Array.isArray(result) ? result : [result];
97
- this.item.childrenIds.push(...items.map(c => c.item.id));
98
- return this;
99
- }
100
- }
101
- export class Transition extends TimelineItem {
102
- item;
103
- constructor(item) {
104
- super(item);
105
- this.item = item;
106
- }
107
- }
1
+ export {};
2
+ // import {O} from "./o.js"
3
+ // import {Id} from "../parts/basics.js"
4
+ // import {Item} from "../parts/item.js"
5
+ //
6
+ // export class TimelineItem {
7
+ // public readonly id: Id
8
+ //
9
+ // constructor(public item: Item.Any) {
10
+ // this.id = item.id
11
+ // }
12
+ //
13
+ // toJSON() {
14
+ // return {
15
+ // ...this.item
16
+ // }
17
+ // }
18
+ // }
19
+ //
20
+ // abstract class VisualItem extends TimelineItem {
21
+ // abstract spatial(spatial: Spatial): TimelineItem
22
+ // }
23
+ //
24
+ // export class Stack extends VisualItem {
25
+ // constructor(private o: O, public item: Item.Stack) {
26
+ // super(item)
27
+ // }
28
+ //
29
+ // spatial(spatial: Spatial) {
30
+ // this.item.spatialId = spatial.item.id
31
+ // return this
32
+ // }
33
+ //
34
+ // addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
35
+ // const result = fn(this.o)
36
+ // const items = Array.isArray(result) ? result : [result]
37
+ // this.item.childrenIds.push(...items.map(c => c.item.id))
38
+ // return this
39
+ // }
40
+ // }
41
+ //
42
+ // export class Spatial extends TimelineItem {
43
+ // constructor(public item: Item.Spatial) {super(item)}
44
+ // }
45
+ //
46
+ // export class Gap extends TimelineItem {
47
+ // constructor(public item: Item.Gap) {super(item)}
48
+ // }
49
+ //
50
+ // export class Audio extends TimelineItem {
51
+ // constructor(public item: Item.Audio) {super(item)}
52
+ // }
53
+ //
54
+ // export class Video extends VisualItem {
55
+ // constructor(public item: Item.Video) {
56
+ // super(item)
57
+ // }
58
+ //
59
+ // spatial(spatial: Spatial) {
60
+ // this.item.spatialId = spatial.item.id
61
+ // return this
62
+ // }
63
+ // }
64
+ //
65
+ // export class Text extends VisualItem {
66
+ // constructor(public item: Item.Text) {
67
+ // super(item)
68
+ // }
69
+ //
70
+ // color(color: string) {
71
+ // this.item.color = color
72
+ // return this
73
+ // }
74
+ //
75
+ // spatial(spatial: Spatial) {
76
+ // this.item.spatialId = spatial.item.id
77
+ // return this
78
+ // }
79
+ // }
80
+ //
81
+ // export class Sequence extends VisualItem {
82
+ // constructor(private o: O, public item: Item.Sequence) {
83
+ // super(item)
84
+ // }
85
+ //
86
+ // spatial(spatial: Spatial) {
87
+ // this.item.spatialId = spatial.item.id
88
+ // return this
89
+ // }
90
+ //
91
+ // addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
92
+ // const result = fn(this.o)
93
+ // const items = Array.isArray(result) ? result : [result]
94
+ // this.item.childrenIds.push(...items.map(c => c.item.id))
95
+ // return this
96
+ // }
97
+ // }
98
+ //
99
+ // export class Transition extends TimelineItem {
100
+ // constructor(public item: Item.Transition) {
101
+ // super(item)
102
+ // }
103
+ // }
108
104
  //# sourceMappingURL=builders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../../s/timeline/sugar/builders.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,YAAY;IAGL;IAFH,EAAE,CAAI;IAEtB,YAAmB,IAAc;QAAd,SAAI,GAAJ,IAAI,CAAU;QAChC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IAClB,CAAC;IAED,MAAM;QACL,OAAO;YACN,GAAG,IAAI,CAAC,IAAI;SACZ,CAAA;IACF,CAAC;CACD;AAED,MAAe,UAAW,SAAQ,YAAY;CAE7C;AAED,MAAM,OAAO,KAAM,SAAQ,UAAU;IACf;IAAa;IAAjC,YAAoB,CAAI,EAAS,IAAgB;QAChD,KAAK,CAAC,IAAI,CAAC,CAAA;QADQ,MAAC,GAAD,CAAC,CAAG;QAAS,SAAI,GAAJ,IAAI,CAAY;IAEjD,CAAC;IAED,OAAO,CAAC,OAAgB;QACvB,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,C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AAC;CACD"}
1
+ {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../../s/timeline/sugar/builders.ts"],"names":[],"mappings":";AAAA,2BAA2B;AAC3B,wCAAwC;AACxC,wCAAwC;AACxC,EAAE;AACF,8BAA8B;AAC9B,0BAA0B;AAC1B,EAAE;AACF,wCAAwC;AACxC,sBAAsB;AACtB,KAAK;AACL,EAAE;AACF,cAAc;AACd,aAAa;AACb,kBAAkB;AAClB,MAAM;AACN,KAAK;AACL,IAAI;AACJ,EAAE;AACF,mDAAmD;AACnD,qDAAqD;AACrD,IAAI;AACJ,EAAE;AACF,0CAA0C;AAC1C,yDAAyD;AACzD,iBAAiB;AACjB,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,EAAE;AACF,+DAA+D;AAC/D,+BAA+B;AAC/B,6DAA6D;AAC7D,+DAA+D;AAC/D,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,8CAA8C;AAC9C,wDAAwD;AACxD,IAAI;AACJ,EAAE;AACF,0CAA0C;AAC1C,oDAAoD;AACpD,IAAI;AACJ,EAAE;AACF,4CAA4C;AAC5C,sDAAsD;AACtD,IAAI;AACJ,EAAE;AACF,0CAA0C;AAC1C,2CAA2C;AAC3C,iBAAiB;AACjB,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,yCAAyC;AACzC,0CAA0C;AAC1C,iBAAiB;AACjB,MAAM;AACN,EAAE;AACF,2BAA2B;AAC3B,6BAA6B;AAC7B,gBAAgB;AAChB,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,6CAA6C;AAC7C,2DAA2D;AAC3D,gBAAgB;AAChB,KAAK;AACL,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,EAAE;AACF,+DAA+D;AAC/D,+BAA+B;AAC/B,6DAA6D;AAC7D,+DAA+D;AAC/D,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,iDAAiD;AACjD,+CAA+C;AAC/C,gBAAgB;AAChB,KAAK;AACL,IAAI"}
@@ -1,27 +1,32 @@
1
- import { MapG } from "@e280/stz";
2
1
  import { Media } from "../parts/media.js";
2
+ import { Id, TimelineFile } from "../parts/basics.js";
3
+ import { Item } from "../parts/item.js";
3
4
  import { Transform, TransformOptions } from "../types.js";
4
- import { Video, Gap, Sequence, Stack, Text, TimelineItem, Spatial, Audio, Transition } from "./builders.js";
5
5
  export declare class O {
6
6
  #private;
7
- register(item: TimelineItem): number;
8
- get items(): TimelineItem[];
9
- get itemsMap(): MapG<number, TimelineItem>;
10
- spatial: (transform: Transform) => Spatial;
11
- sequence: (...items: TimelineItem[]) => Sequence;
12
- stack: (...items: TimelineItem[]) => Stack;
7
+ state: {
8
+ project: TimelineFile;
9
+ };
10
+ constructor(state: {
11
+ project: TimelineFile;
12
+ });
13
+ require<T extends Item.Any>(id: Id): T;
14
+ spatial: (transform: Transform) => Item.Spatial;
15
+ sequence: (...items: Item.Any[]) => Item.Any;
16
+ stack: (...items: Item.Any[]) => Item.Any;
13
17
  video: (media: Media, options?: {
14
18
  start?: number;
15
19
  duration?: number;
16
- }) => Video;
20
+ }) => Item.Video;
17
21
  audio: (media: Media, options?: {
18
22
  start?: number;
19
23
  duration?: number;
20
- }) => Audio;
21
- text: (content: string) => Text;
22
- gap: (duration: number) => Gap;
24
+ }) => Item.Audio;
25
+ text: (content: string) => Item.Text;
26
+ gap: (duration: number) => Item.Gap;
23
27
  transition: {
24
- crossfade: (duration: number) => Transition;
28
+ crossfade: (duration: number) => Item.Transition;
25
29
  };
26
30
  transform: (options?: TransformOptions) => Transform;
31
+ addChildren(parent: Item.Stack | Item.Sequence, ...items: Item.Any[]): void;
27
32
  }
@@ -1,22 +1,19 @@
1
- import { MapG } from "@e280/stz";
2
1
  import { Effect, Kind } from "../parts/item.js";
3
- import { Video, Gap, Sequence, Stack, Text, Spatial, Audio, Transition } from "./builders.js";
4
2
  export class O {
3
+ state;
5
4
  #nextId = 0;
6
- #items = new MapG();
7
- #getId() {
8
- return this.#nextId++;
5
+ constructor(state) {
6
+ this.state = state;
9
7
  }
10
- register(item) {
11
- if (!this.#items.has(item.id))
12
- this.#items.set(item.id, item);
13
- return item.id;
8
+ require(id) {
9
+ const item = this.state.project.items.find(item => item.id === id);
10
+ return item;
14
11
  }
15
- get items() {
16
- return [...this.#items.values()];
12
+ #getId() {
13
+ return this.#nextId++;
17
14
  }
18
- get itemsMap() {
19
- return this.#items;
15
+ #mutate(fn) {
16
+ this.state.project = fn(this.state.project);
20
17
  }
21
18
  spatial = (transform) => {
22
19
  const item = {
@@ -24,20 +21,32 @@ export class O {
24
21
  kind: Kind.Spatial,
25
22
  transform
26
23
  };
27
- const spatial = new Spatial(item);
28
- this.register(spatial);
29
- return spatial;
24
+ return item;
25
+ };
26
+ sequence = (...items) => {
27
+ const item = {
28
+ id: this.#getId(),
29
+ kind: Kind.Sequence,
30
+ childrenIds: items.map(item => item.id)
31
+ };
32
+ this.#mutate(state => {
33
+ state.items.push(item, ...items);
34
+ return state;
35
+ });
36
+ return item;
37
+ };
38
+ stack = (...items) => {
39
+ const item = {
40
+ kind: Kind.Stack,
41
+ id: this.#getId(),
42
+ childrenIds: items.map(item => item.id)
43
+ };
44
+ this.#mutate(state => {
45
+ state.items.push(item, ...items);
46
+ return state;
47
+ });
48
+ return item;
30
49
  };
31
- sequence = (...items) => new Sequence(this, {
32
- id: this.#getId(),
33
- kind: Kind.Sequence,
34
- childrenIds: items.map((item) => this.register(item))
35
- });
36
- stack = (...items) => new Stack(this, {
37
- kind: Kind.Stack,
38
- id: this.#getId(),
39
- childrenIds: items.map(item => this.register(item))
40
- });
41
50
  video = (media, options) => {
42
51
  if (!media.hasVideo)
43
52
  throw new Error(`Video clip error: media "${media.datafile.filename}" has no video track.`);
@@ -48,7 +57,7 @@ export class O {
48
57
  start: options?.start ?? 0,
49
58
  duration: options?.duration ?? media.duration
50
59
  };
51
- return new Video(item);
60
+ return item;
52
61
  };
53
62
  audio = (media, options) => {
54
63
  if (!media.hasAudio)
@@ -60,21 +69,21 @@ export class O {
60
69
  start: options?.start ?? 0,
61
70
  duration: options?.duration ?? media.duration
62
71
  };
63
- return new Audio(item);
72
+ return item;
64
73
  };
65
- text = (content) => new Text({
74
+ text = (content) => ({
66
75
  id: this.#getId(),
67
76
  content,
68
77
  kind: Kind.Text,
69
78
  color: "#FFFFF"
70
79
  });
71
- gap = (duration) => new Gap({
80
+ gap = (duration) => ({
72
81
  id: this.#getId(),
73
82
  kind: Kind.Gap,
74
83
  duration
75
84
  });
76
85
  transition = {
77
- crossfade: (duration) => new Transition({
86
+ crossfade: (duration) => ({
78
87
  id: this.#getId(),
79
88
  kind: Kind.Transition,
80
89
  effect: Effect.Crossfade,
@@ -93,5 +102,13 @@ export class O {
93
102
  const rotation = options?.rotation ?? 0;
94
103
  return [position, scale, rotation];
95
104
  };
105
+ addChildren(parent, ...items) {
106
+ this.#mutate(state => {
107
+ const parentItem = state.items.find(({ id }) => id === parent.id);
108
+ parentItem.childrenIds.push(...items.map(item => item.id));
109
+ state.items.push(...items);
110
+ return state;
111
+ });
112
+ }
96
113
  }
97
114
  //# sourceMappingURL=o.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"o.js","sourceRoot":"","sources":["../../../s/timeline/sugar/o.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAG9B,OAAO,EAAC,MAAM,EAAQ,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAEnD,OAAO,EAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAgB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAC,MAAM,eAAe,CAAA;AAEzG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OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SACxB,CAAA;QACD,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,CAAC,CAAA;QACvC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACpC,CAAC,CAAA;IAED,WAAW,CAAC,MAAkC,EAAE,GAAG,KAAiB;QACpE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACpB,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAe,CAAA;YAC7E,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1D,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;YAC1B,OAAO,KAAK,CAAA;QACb,CAAC,CAAC,CAAA;IACF,CAAC;CACF"}
@@ -1,7 +1,6 @@
1
1
  import { O } from "./o.js";
2
- import { Timeline } from "../timeline.js";
2
+ import { Item } from "../parts/item.js";
3
3
  import { Media } from "../parts/media.js";
4
- import { TimelineItem } from "./builders.js";
5
4
  import { Datafile } from "../utils/datafile.js";
6
5
  import { TimelineFile } from "../parts/basics.js";
7
6
  import { ResourcePool } from "../parts/resource-pool.js";
@@ -10,6 +9,6 @@ export declare class Omni {
10
9
  #private;
11
10
  resources: ResourcePool;
12
11
  load: <S extends Record<string, Promise<Datafile>>>(spec: S) => Promise<{ [K in keyof S]: Media; }>;
13
- timeline: (fn: (o: O) => TimelineItem) => Timeline;
12
+ timeline: (fn: (o: O) => Item.Any) => TimelineFile;
14
13
  render: (timeline: TimelineFile, config: RenderConfig) => Promise<void>;
15
14
  }
@@ -1,5 +1,4 @@
1
1
  import { O } from "./o.js";
2
- import { Timeline } from "../timeline.js";
3
2
  import { Export } from "../parts/compositor/export.js";
4
3
  import { ResourcePool } from "../parts/resource-pool.js";
5
4
  export class Omni {
@@ -9,10 +8,18 @@ export class Omni {
9
8
  return Object.fromEntries(await Promise.all(Object.entries(spec).map(async ([key, value]) => [key, await this.resources.store(await value)])));
10
9
  };
11
10
  timeline = (fn) => {
12
- const o = new O();
11
+ const o = new O({
12
+ project: {
13
+ format: "timeline",
14
+ info: "https://omniclip.app/",
15
+ version: 0,
16
+ items: [],
17
+ rootId: 0
18
+ }
19
+ });
13
20
  const root = fn(o);
14
- o.register(root);
15
- return new Timeline(root, o.itemsMap);
21
+ o.state.project.rootId = root.id;
22
+ return o.state.project;
16
23
  };
17
24
  render = async (timeline, config) => {
18
25
  await this.#export.render(timeline);
@@ -1 +1 @@
1
- {"version":3,"file":"omni.js","sourceRoot":"","sources":["../../../s/timeline/sugar/omni.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AAKvC,OAAO,EAAC,MAAM,EAAC,MAAM,+BAA+B,CAAA;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAA;AAGtD,MAAM,OAAO,IAAI;IAChB,SAAS,GAAG,IAAI,YAAY,EAAE,CAAA;IAC9B,OAAO,GAAG,IAAI,MAAM,EAAE,CAAA;IAEtB,IAAI,GAAG,KAAK,EAA8C,IAAO,EAAE,EAAE;QACpE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CACnE,KAAK,EAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CACrE,CAA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AAC,GAAG,IAAI,CAAC,CAAC;YACf,OAAO,EAAE;gBACR,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,CAAC;aACT;SACD,CAAC,CAAA;QACF,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;QAChC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAA;IACvB,CAAC,CAAA;IAED,MAAM,GAAG,KAAK,EAAE,QAAsB,EAAE,MAAoB,EAAE,EAAE;QAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC,CAAA;CACD"}
@@ -1,22 +0,0 @@
1
- import {TimelineItem} from "./sugar/builders.js"
2
- import {Id, TimelineFile} from "./parts/basics.js"
3
-
4
- export class Timeline {
5
- constructor(public root: TimelineItem, private items: Map<Id, TimelineItem>) {}
6
-
7
- require<T extends TimelineItem>(id: Id): T {
8
- const item = this.items.get(id)
9
- return item as T
10
- }
11
-
12
- toJSON(): TimelineFile {
13
- return {
14
- format: "timeline",
15
- info: "https://omniclip.app/",
16
- version: 0,
17
- rootId: this.root.item.id,
18
- items: Array.from(this.items.values()).map(item => item.toJSON())
19
- }
20
- }
21
- }
22
-
@@ -1,9 +0,0 @@
1
- import { TimelineItem } from "./sugar/builders.js";
2
- import { Id, TimelineFile } from "./parts/basics.js";
3
- export declare class Timeline {
4
- root: TimelineItem;
5
- private items;
6
- constructor(root: TimelineItem, items: Map<Id, TimelineItem>);
7
- require<T extends TimelineItem>(id: Id): T;
8
- toJSON(): TimelineFile;
9
- }
@@ -1,22 +0,0 @@
1
- export class Timeline {
2
- root;
3
- items;
4
- constructor(root, items) {
5
- this.root = root;
6
- this.items = items;
7
- }
8
- require(id) {
9
- const item = this.items.get(id);
10
- return item;
11
- }
12
- toJSON() {
13
- return {
14
- format: "timeline",
15
- info: "https://omniclip.app/",
16
- version: 0,
17
- rootId: this.root.item.id,
18
- items: Array.from(this.items.values()).map(item => item.toJSON())
19
- };
20
- }
21
- }
22
- //# sourceMappingURL=timeline.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../s/timeline/timeline.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,QAAQ;IACA;IAA4B;IAA/C,YAAmB,IAAkB,EAAU,KAA4B;QAAxD,SAAI,GAAJ,IAAI,CAAc;QAAU,UAAK,GAAL,KAAK,CAAuB;IAAG,CAAC;IAE/E,OAAO,CAAyB,EAAM;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC/B,OAAO,IAAS,CAAA;IAClB,CAAC;IAED,MAAM;QACJ,OAAO;YACR,MAAM,EAAE,UAAU;YAClB,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,CAAC;YACV,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACzB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;SAC/D,CAAA;IACH,CAAC;CACF"}