@omnimedia/omnitool 1.1.0-77 → 1.1.0-78

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/README.md CHANGED
@@ -115,14 +115,12 @@ Filter metadata for UI:
115
115
 
116
116
  ```ts
117
117
  import {
118
- filterTypes,
119
- filterSchemas,
120
- getFilterDefaultParams
118
+ filters
121
119
  } from "@omnimedia/omnitool"
122
120
 
123
- const available = Object.entries(filterTypes)
124
- const schema = filterSchemas.BlurFilter
125
- const defaults = getFilterDefaultParams("BlurFilter")
121
+ const available = Object.entries(filters)
122
+ const blur = filters.blur
123
+ const schema = blur.schema
126
124
  ```
127
125
 
128
126
  ## 🧭 Spatial Transforms
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnimedia/omnitool",
3
- "version": "1.1.0-77",
3
+ "version": "1.1.0-78",
4
4
  "description": "open source video processing tools",
5
5
  "license": "MIT",
6
6
  "author": "Przemysław Gałęzki",
@@ -127,7 +127,7 @@ const defineFilter = <TParams>() =>
127
127
  schema: SchemaFromOptions<TParams> = {},
128
128
  ): FilterDefinition<TType, TParams> => ({type, schema})
129
129
 
130
- export const filterTypes = {
130
+ export const filters = {
131
131
  adjustment: defineFilter<PixiFilters.AdjustmentFilterOptions>()("AdjustmentFilter", {
132
132
  gamma: num(0, 5, 1),
133
133
  saturation: num(0, 5, 1),
@@ -430,7 +430,7 @@ export const filterTypes = {
430
430
  }),
431
431
  } as const
432
432
 
433
- type FilterDefinitions = typeof filterTypes
433
+ type FilterDefinitions = typeof filters
434
434
  type FilterDefinitionParams<T> =
435
435
  T extends FilterDefinition<string, infer TParams>
436
436
  ? TParams
@@ -443,42 +443,11 @@ export type FilterOptions = {
443
443
 
444
444
  export type FilterType = FilterDefinitions[keyof FilterDefinitions]["type"]
445
445
  export type FilterParams<T extends FilterType = FilterType> = FilterOptions[T]
446
- export type FilterSchemas = {
447
- [TName in keyof FilterDefinitions as FilterDefinitions[TName]["type"]]:
448
- FilterDefinitions[TName]["schema"]
449
- }
450
-
451
- export const filterSchemas = Object.fromEntries(
452
- Object.values(filterTypes).map(filter => [filter.type, filter.schema]),
453
- ) as FilterSchemas
454
-
455
- const getDefaultValue =(config: FilterPropertyConfig): unknown => {
456
- switch(config.type) {
457
- case "number":
458
- case "boolean":
459
- case "color":
460
- case "choice":
461
- return config.default
462
-
463
- case "object":
464
- return Object.fromEntries(
465
- Object.entries(config.properties).map(([key, value]) => [key, getDefaultValue(value)]),
466
- )
467
-
468
- case "array":
469
- return config.items.map(getDefaultValue)
470
- }
471
- }
472
-
473
- export const getFilterDefaultParams = <TFilter extends FilterType>(type: TFilter): FilterParams<TFilter> =>
474
- Object.fromEntries(
475
- Object.entries(filterSchemas[type]).map(([key, value]) => [key, getDefaultValue(value)]),
476
- ) as FilterParams<TFilter>
477
446
 
478
447
  export interface FilterAction<TFilter extends FilterType> {
479
448
  <T extends FilterableItem>(item: T, params?: FilterParams<TFilter>): T
480
449
  make(params?: FilterParams<TFilter>): Item.Filter<TFilter>
481
450
  }
482
451
  export type FilterActions = {
483
- [TName in keyof typeof filterTypes]: FilterAction<(typeof filterTypes)[TName]["type"]>
452
+ [TName in keyof typeof filters]: FilterAction<(typeof filters)[TName]["type"]>
484
453
  }
@@ -7,7 +7,7 @@ import {Media} from "../parts/media.js"
7
7
  import {TimelineFile} from "../parts/basics.js"
8
8
  import {FilterAction} from "../parts/filters.js"
9
9
  import {Crop, FilterableItem, Item} from "../parts/item.js"
10
- import {filterTypes, FilterParams, FilterType} from "../parts/filters.js"
10
+ import {filters, FilterParams, FilterType} from "../parts/filters.js"
11
11
 
12
12
  export type Build<T extends Item.Any = Item.Any> = (o: O) => T
13
13
 
@@ -81,7 +81,7 @@ interface BuildFilterAction<TFilter extends FilterType> {
81
81
  }
82
82
 
83
83
  type BuildFilterActions = {
84
- [TName in keyof typeof filterTypes]: BuildFilterAction<(typeof filterTypes)[TName]["type"]>
84
+ [TName in keyof typeof filters]: BuildFilterAction<(typeof filters)[TName]["type"]>
85
85
  }
86
86
 
87
87
  function makeFilter<TFilter extends FilterType>(
@@ -96,7 +96,7 @@ function makeFilter<TFilter extends FilterType>(
96
96
  }
97
97
 
98
98
  function makeFilters(): BuildFilterActions {
99
- const names = Object.keys(filterTypes) as (keyof typeof filterTypes)[]
99
+ const names = Object.keys(filters) as (keyof typeof filters)[]
100
100
  const entries = names.map(name => [
101
101
  name,
102
102
  makeFilter(o => o.filter[name] as FilterAction<any>)
@@ -6,7 +6,7 @@ import {Id, TimelineFile} from "../parts/basics.js"
6
6
  import {Transform, TransformOptions, Vec2} from "../types.js"
7
7
  import {FilterAction, FilterActions} from "../parts/filters.js"
8
8
  import {Crop, Effect, FilterableItem, Item, Kind} from "../parts/item.js"
9
- import {filterTypes, FilterParams, FilterType} from "../parts/filters.js"
9
+ import {filters, FilterParams, FilterType} from "../parts/filters.js"
10
10
 
11
11
  export class O {
12
12
  constructor(public state: {timeline: TimelineFile}) {}
@@ -87,7 +87,7 @@ export class O {
87
87
  }
88
88
 
89
89
  #makeFilters = (): FilterActions => {
90
- const entries = Object.entries(filterTypes)
90
+ const entries = Object.entries(filters)
91
91
  .map(([name, filter]) => [name, this.#makeFilter(filter.type)])
92
92
  return Object.fromEntries(entries) as FilterActions
93
93
  }