@omnimedia/omnitool 1.1.0-20 → 1.1.0-21

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-20",
3
+ "version": "1.1.0-21",
4
4
  "description": "open source video processing tools",
5
5
  "license": "MIT",
6
6
  "author": "Przemysław Gałęzki",
@@ -12,6 +12,7 @@ export enum Kind {
12
12
  Gap,
13
13
  Spatial,
14
14
  Transition,
15
+ TextStyle
15
16
  }
16
17
 
17
18
  export enum Effect {
@@ -19,6 +20,12 @@ export enum Effect {
19
20
  }
20
21
 
21
22
  export namespace Item {
23
+ export type TextStyle = {
24
+ id: Id
25
+ kind: Kind.TextStyle
26
+ style: TextStyleOptions
27
+ }
28
+
22
29
  export type Spatial = {
23
30
  id: Id
24
31
  kind: Kind.Spatial
@@ -68,7 +75,7 @@ export namespace Item {
68
75
  content: string
69
76
  duration: number
70
77
  spatialId?: Id
71
- style: TextStyleOptions
78
+ styleId?: Id
72
79
  }
73
80
 
74
81
  export type Transition = {
@@ -1,3 +1,4 @@
1
+ import {TextStyleOptions} from "pixi.js"
1
2
 
2
3
  import {Media} from "../parts/media.js"
3
4
  import {Id, TimelineFile} from "../parts/basics.js"
@@ -22,6 +23,12 @@ export class O {
22
23
  this.state.project = fn(this.state.project)
23
24
  }
24
25
 
26
+ textStyle = (style: TextStyleOptions): Item.TextStyle => ({
27
+ id: this.#getId(),
28
+ kind: Kind.TextStyle,
29
+ style
30
+ })
31
+
25
32
  spatial = (transform: Transform): Item.Spatial => {
26
33
  const item: Item.Spatial = {
27
34
  id: this.#getId(),
@@ -107,8 +114,7 @@ export class O {
107
114
  id: this.#getId(),
108
115
  content,
109
116
  kind: Kind.Text,
110
- duration: 2000,
111
- style: {}
117
+ duration: 2000
112
118
  })
113
119
 
114
120
  gap = (duration: number): Item.Gap => ({
@@ -147,5 +153,20 @@ export class O {
147
153
  return state
148
154
  })
149
155
  }
156
+
157
+ update = <K extends keyof Item.Any>(itemId: Id, key: K, value: Item.Any[K]) => {
158
+ this.#mutate(project => {
159
+ const newItems = project.items.map(item => {
160
+ if (item.id === itemId) {
161
+ return {
162
+ ...item,
163
+ [key]: value,
164
+ }
165
+ }
166
+ return item
167
+ })
168
+ return {...project, items: newItems}
169
+ })
170
+ }
150
171
  }
151
172