@getcortexlabs/mavis-core 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (160) hide show
  1. package/README.md +2 -2
  2. package/dist/app-icons.d.ts +27 -0
  3. package/dist/app-icons.d.ts.map +1 -0
  4. package/dist/app-icons.js +42 -0
  5. package/dist/app-icons.js.map +1 -0
  6. package/dist/capabilities.d.ts +119 -0
  7. package/dist/capabilities.d.ts.map +1 -0
  8. package/dist/capabilities.js +144 -0
  9. package/dist/capabilities.js.map +1 -0
  10. package/dist/combobox.d.ts +42 -0
  11. package/dist/combobox.d.ts.map +1 -0
  12. package/dist/combobox.js +159 -0
  13. package/dist/combobox.js.map +1 -0
  14. package/dist/contracts.d.ts +1261 -0
  15. package/dist/contracts.d.ts.map +1 -0
  16. package/dist/contracts.js +249 -0
  17. package/dist/contracts.js.map +1 -0
  18. package/dist/date.d.ts +96 -0
  19. package/dist/date.d.ts.map +1 -0
  20. package/dist/date.js +235 -0
  21. package/dist/date.js.map +1 -0
  22. package/dist/experimental-playback.d.ts +63 -0
  23. package/dist/experimental-playback.d.ts.map +1 -0
  24. package/dist/experimental-playback.js +46 -0
  25. package/dist/experimental-playback.js.map +1 -0
  26. package/dist/experimental-regions.d.ts +154 -0
  27. package/dist/experimental-regions.d.ts.map +1 -0
  28. package/dist/experimental-regions.js +440 -0
  29. package/dist/experimental-regions.js.map +1 -0
  30. package/dist/experimental.d.ts +42 -3
  31. package/dist/experimental.d.ts.map +1 -1
  32. package/dist/experimental.js +200 -30
  33. package/dist/experimental.js.map +1 -1
  34. package/dist/files.d.ts +87 -0
  35. package/dist/files.d.ts.map +1 -0
  36. package/dist/files.js +328 -0
  37. package/dist/files.js.map +1 -0
  38. package/dist/form.d.ts +39 -0
  39. package/dist/form.d.ts.map +1 -0
  40. package/dist/form.js +170 -0
  41. package/dist/form.js.map +1 -0
  42. package/dist/index.d.ts +14 -2
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +11 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/link.d.ts +12 -0
  47. package/dist/link.d.ts.map +1 -0
  48. package/dist/link.js +19 -0
  49. package/dist/link.js.map +1 -0
  50. package/dist/motion.d.ts +29 -4
  51. package/dist/motion.d.ts.map +1 -1
  52. package/dist/motion.js +55 -3
  53. package/dist/motion.js.map +1 -1
  54. package/dist/navigation.d.ts +22 -0
  55. package/dist/navigation.d.ts.map +1 -0
  56. package/dist/navigation.js +54 -0
  57. package/dist/navigation.js.map +1 -0
  58. package/dist/responsive.d.ts +18 -0
  59. package/dist/responsive.d.ts.map +1 -0
  60. package/dist/responsive.js +35 -0
  61. package/dist/responsive.js.map +1 -0
  62. package/dist/theme/themes.js +3 -3
  63. package/dist/theme/themes.js.map +1 -1
  64. package/dist/theme/types.d.ts +12 -3
  65. package/dist/theme/types.d.ts.map +1 -1
  66. package/dist/vue/combobox.d.ts +155 -0
  67. package/dist/vue/combobox.d.ts.map +1 -0
  68. package/dist/vue/combobox.js +195 -0
  69. package/dist/vue/combobox.js.map +1 -0
  70. package/dist/vue/component-props.d.ts +2176 -0
  71. package/dist/vue/component-props.d.ts.map +1 -0
  72. package/dist/vue/component-props.js +18 -0
  73. package/dist/vue/component-props.js.map +1 -0
  74. package/dist/vue/contracts.d.ts +18 -0
  75. package/dist/vue/contracts.d.ts.map +1 -0
  76. package/dist/vue/contracts.js +24 -0
  77. package/dist/vue/contracts.js.map +1 -0
  78. package/dist/vue/date-calendar.d.ts +64 -0
  79. package/dist/vue/date-calendar.d.ts.map +1 -0
  80. package/dist/vue/date-calendar.js +65 -0
  81. package/dist/vue/date-calendar.js.map +1 -0
  82. package/dist/vue/date-picker.d.ts +965 -0
  83. package/dist/vue/date-picker.d.ts.map +1 -0
  84. package/dist/vue/date-picker.js +341 -0
  85. package/dist/vue/date-picker.js.map +1 -0
  86. package/dist/vue/date-props.d.ts +263 -0
  87. package/dist/vue/date-props.d.ts.map +1 -0
  88. package/dist/vue/date-props.js +77 -0
  89. package/dist/vue/date-props.js.map +1 -0
  90. package/dist/vue/files.d.ts +53 -0
  91. package/dist/vue/files.d.ts.map +1 -0
  92. package/dist/vue/files.js +40 -0
  93. package/dist/vue/files.js.map +1 -0
  94. package/dist/vue/forms.d.ts +4 -0
  95. package/dist/vue/forms.d.ts.map +1 -0
  96. package/dist/vue/forms.js +15 -0
  97. package/dist/vue/forms.js.map +1 -0
  98. package/dist/vue/global-components.d.ts +40 -2
  99. package/dist/vue/global-components.d.ts.map +1 -1
  100. package/dist/vue/index.d.ts +15 -3
  101. package/dist/vue/index.d.ts.map +1 -1
  102. package/dist/vue/index.js +12 -2
  103. package/dist/vue/index.js.map +1 -1
  104. package/dist/vue/inline-content.d.ts +3 -1
  105. package/dist/vue/inline-content.d.ts.map +1 -1
  106. package/dist/vue/layout-context.d.ts +4 -2
  107. package/dist/vue/layout-context.d.ts.map +1 -1
  108. package/dist/vue/layout-context.js +7 -2
  109. package/dist/vue/layout-context.js.map +1 -1
  110. package/dist/vue/props.d.ts +1392 -496
  111. package/dist/vue/props.d.ts.map +1 -1
  112. package/dist/vue/props.js +39 -116
  113. package/dist/vue/props.js.map +1 -1
  114. package/dist/vue/reveal-state.d.ts +18 -0
  115. package/dist/vue/reveal-state.d.ts.map +1 -0
  116. package/dist/vue/reveal-state.js +76 -0
  117. package/dist/vue/reveal-state.js.map +1 -0
  118. package/dist/vue/theme.d.ts +42 -0
  119. package/dist/vue/theme.d.ts.map +1 -1
  120. package/dist/vue/workflow-props.d.ts +110 -0
  121. package/dist/vue/workflow-props.d.ts.map +1 -0
  122. package/dist/vue/workflow-props.js +37 -0
  123. package/dist/vue/workflow-props.js.map +1 -0
  124. package/dist/vue/workflows.d.ts +267 -0
  125. package/dist/vue/workflows.d.ts.map +1 -0
  126. package/dist/vue/workflows.js +200 -0
  127. package/dist/vue/workflows.js.map +1 -0
  128. package/package.json +1 -1
  129. package/src/app-icons.ts +57 -0
  130. package/src/capabilities.ts +147 -0
  131. package/src/combobox.ts +198 -0
  132. package/src/contracts.ts +305 -0
  133. package/src/date.ts +280 -0
  134. package/src/experimental-playback.ts +115 -0
  135. package/src/experimental-regions.ts +614 -0
  136. package/src/experimental.ts +239 -25
  137. package/src/files.ts +408 -0
  138. package/src/form.ts +190 -0
  139. package/src/index.ts +23 -1
  140. package/src/link.ts +28 -0
  141. package/src/motion.ts +61 -3
  142. package/src/navigation.ts +61 -0
  143. package/src/responsive.ts +61 -0
  144. package/src/theme/themes.ts +3 -3
  145. package/src/theme/types.ts +13 -1
  146. package/src/vue/combobox.ts +238 -0
  147. package/src/vue/component-props.ts +24 -0
  148. package/src/vue/contracts.ts +39 -0
  149. package/src/vue/date-calendar.ts +76 -0
  150. package/src/vue/date-picker.ts +414 -0
  151. package/src/vue/date-props.ts +84 -0
  152. package/src/vue/files.ts +53 -0
  153. package/src/vue/forms.ts +20 -0
  154. package/src/vue/global-components.ts +49 -3
  155. package/src/vue/index.ts +19 -3
  156. package/src/vue/layout-context.ts +10 -3
  157. package/src/vue/props.ts +57 -127
  158. package/src/vue/reveal-state.ts +83 -0
  159. package/src/vue/workflow-props.ts +41 -0
  160. package/src/vue/workflows.ts +257 -0
package/src/date.ts ADDED
@@ -0,0 +1,280 @@
1
+ /** A proleptic Gregorian civil date, never a timestamp. Runtime APIs validate YYYY-MM-DD. */
2
+ export type CivilDate = `${number}-${number}-${number}`
3
+ export type DateLocale = 'en-US' | 'pt-BR'
4
+ export interface DateRange {
5
+ start: CivilDate | null
6
+ end: CivilDate | null
7
+ }
8
+ export interface DateRangeDraft {
9
+ start: string
10
+ end: string
11
+ }
12
+ export interface DateConstraints {
13
+ min?: CivilDate
14
+ max?: CivilDate
15
+ unavailableDates?: readonly CivilDate[]
16
+ }
17
+ export type DateValidationReason =
18
+ | 'empty'
19
+ | 'partial'
20
+ | 'incomplete'
21
+ | 'invalid'
22
+ | 'before-min'
23
+ | 'after-max'
24
+ | 'unavailable'
25
+ | 'reversed'
26
+ | 'unavailable-range'
27
+ | null
28
+ export interface DateValidation {
29
+ /** Empty values and ranges with one empty endpoint are valid; required belongs to the app. */
30
+ valid: boolean
31
+ complete: boolean
32
+ reason: DateValidationReason
33
+ }
34
+ export interface CivilDateParts {
35
+ year: number
36
+ month: number
37
+ day: number
38
+ }
39
+
40
+ export function daysInMonth(year: number, month: number): number {
41
+ if (month === 2) return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28
42
+ return [4, 6, 9, 11].includes(month) ? 30 : 31
43
+ }
44
+
45
+ export function parseCivilDate(value: unknown): CivilDateParts | null {
46
+ if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null
47
+ const year = Number(value.slice(0, 4))
48
+ const month = Number(value.slice(5, 7))
49
+ const day = Number(value.slice(8, 10))
50
+ return year >= 1 && month >= 1 && month <= 12 && day >= 1 && day <= daysInMonth(year, month)
51
+ ? { year, month, day }
52
+ : null
53
+ }
54
+
55
+ export function isCivilDate(value: unknown): value is CivilDate {
56
+ return parseCivilDate(value) !== null
57
+ }
58
+
59
+ export function civilDate(value: string): CivilDate {
60
+ if (!isCivilDate(value))
61
+ throw new RangeError('A civil date must be Gregorian YYYY-MM-DD (0001–9999)')
62
+ return value
63
+ }
64
+
65
+ export function formatCivilDate({ year, month, day }: CivilDateParts): CivilDate {
66
+ return civilDate(
67
+ `${String(year).padStart(4, '0')}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`,
68
+ )
69
+ }
70
+
71
+ function daysBeforeYear(year: number) {
72
+ const previous = year - 1
73
+ return (
74
+ 365 * previous +
75
+ Math.floor(previous / 4) -
76
+ Math.floor(previous / 100) +
77
+ Math.floor(previous / 400)
78
+ )
79
+ }
80
+ function ordinal(value: CivilDate): number {
81
+ const parts = parseCivilDate(value)
82
+ if (!parts) throw new RangeError('Invalid civil date')
83
+ let result = daysBeforeYear(parts.year) + parts.day - 1
84
+ for (let month = 1; month < parts.month; month++) result += daysInMonth(parts.year, month)
85
+ return result
86
+ }
87
+
88
+ /** Sunday=0. Uses Gregorian arithmetic and is independent of host time zone and DST. */
89
+ export function civilWeekday(value: CivilDate): number {
90
+ return (ordinal(value) + 1) % 7
91
+ }
92
+
93
+ /** Calendar navigation clamps at the supported years, never wrapping to another era. */
94
+ export function addCivilDays(value: CivilDate, amount: number): CivilDate {
95
+ if (!Number.isSafeInteger(amount)) throw new RangeError('Day offset must be an integer')
96
+ const target = Math.max(0, Math.min(daysBeforeYear(10000) - 1, ordinal(value) + amount))
97
+ let low = 1
98
+ let high = 9999
99
+ while (low < high) {
100
+ const middle = Math.ceil((low + high) / 2)
101
+ if (daysBeforeYear(middle) <= target) low = middle
102
+ else high = middle - 1
103
+ }
104
+ let day = target - daysBeforeYear(low) + 1
105
+ let month = 1
106
+ while (day > daysInMonth(low, month)) day -= daysInMonth(low, month++)
107
+ return formatCivilDate({ year: low, month, day })
108
+ }
109
+
110
+ export function addCivilMonths(value: CivilDate, amount: number): CivilDate {
111
+ if (!Number.isSafeInteger(amount)) throw new RangeError('Month offset must be an integer')
112
+ const parts = parseCivilDate(value)
113
+ if (!parts) throw new RangeError('Invalid civil date')
114
+ const target = Math.max(
115
+ 0,
116
+ Math.min(9999 * 12 - 1, (parts.year - 1) * 12 + parts.month - 1 + amount),
117
+ )
118
+ const year = Math.floor(target / 12) + 1
119
+ const month = (target % 12) + 1
120
+ return formatCivilDate({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) })
121
+ }
122
+
123
+ export function validateDateConstraints(options: DateConstraints) {
124
+ if (options.min !== undefined) civilDate(options.min)
125
+ if (options.max !== undefined) civilDate(options.max)
126
+ if (options.min && options.max && options.min > options.max)
127
+ throw new RangeError('Date min must not be after max')
128
+ for (const value of options.unavailableDates ?? []) civilDate(value)
129
+ }
130
+
131
+ export function dateAvailability(value: CivilDate, options: DateConstraints): DateValidationReason {
132
+ if (options.min && value < options.min) return 'before-min'
133
+ if (options.max && value > options.max) return 'after-max'
134
+ if (options.unavailableDates?.includes(value)) return 'unavailable'
135
+ return null
136
+ }
137
+
138
+ export function validateDateDraft(value: string, options: DateConstraints = {}): DateValidation {
139
+ validateDateConstraints(options)
140
+ if (value === '') return { valid: true, complete: false, reason: 'empty' }
141
+ if (!isCivilDate(value)) {
142
+ // Prefixes describe editing, not a second parsing grammar. No trimming or locale guessing.
143
+ const incomplete = /^\d{0,4}(-\d{0,2}(-\d{0,2})?)?$/.test(value) && value.length < 10
144
+ return { valid: false, complete: false, reason: incomplete ? 'incomplete' : 'invalid' }
145
+ }
146
+ const reason = dateAvailability(value, options)
147
+ return { valid: reason === null, complete: true, reason }
148
+ }
149
+
150
+ export function validateDateRangeDraft(
151
+ draft: DateRangeDraft,
152
+ options: DateConstraints = {},
153
+ ): DateValidation {
154
+ const start = validateDateDraft(draft.start, options)
155
+ const end = validateDateDraft(draft.end, options)
156
+ const complete = start.complete && end.complete
157
+ if (!start.valid) return { ...start, complete }
158
+ if (!end.valid) return { ...end, complete }
159
+ if (!draft.start || !draft.end)
160
+ return { valid: true, complete: false, reason: draft.start || draft.end ? 'partial' : 'empty' }
161
+ if (draft.start > draft.end) return { valid: false, complete: true, reason: 'reversed' }
162
+ if (options.unavailableDates?.some((date) => date >= draft.start && date <= draft.end))
163
+ return { valid: false, complete: true, reason: 'unavailable-range' }
164
+ return { valid: true, complete: true, reason: null }
165
+ }
166
+
167
+ export const dateLocales = {
168
+ 'en-US': {
169
+ months: [
170
+ 'January',
171
+ 'February',
172
+ 'March',
173
+ 'April',
174
+ 'May',
175
+ 'June',
176
+ 'July',
177
+ 'August',
178
+ 'September',
179
+ 'October',
180
+ 'November',
181
+ 'December',
182
+ ],
183
+ weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
184
+ shortWeekdays: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
185
+ firstDayOfWeek: 0,
186
+ calendar: 'Choose date',
187
+ previous: 'Previous month',
188
+ next: 'Next month',
189
+ clear: 'Clear dates',
190
+ selected: 'Selected',
191
+ close: 'Close',
192
+ start: 'Start',
193
+ end: 'End',
194
+ format: 'YYYY-MM-DD',
195
+ errors: {
196
+ incomplete: 'Enter a complete date as YYYY-MM-DD.',
197
+ invalid: 'Enter a valid Gregorian date as YYYY-MM-DD.',
198
+ 'before-min': 'This date is before the minimum.',
199
+ 'after-max': 'This date is after the maximum.',
200
+ unavailable: 'This date is unavailable.',
201
+ reversed: 'The end must be on or after the start.',
202
+ 'unavailable-range': 'This range includes an unavailable date.',
203
+ },
204
+ },
205
+ 'pt-BR': {
206
+ months: [
207
+ 'janeiro',
208
+ 'fevereiro',
209
+ 'março',
210
+ 'abril',
211
+ 'maio',
212
+ 'junho',
213
+ 'julho',
214
+ 'agosto',
215
+ 'setembro',
216
+ 'outubro',
217
+ 'novembro',
218
+ 'dezembro',
219
+ ],
220
+ weekdays: [
221
+ 'domingo',
222
+ 'segunda-feira',
223
+ 'terça-feira',
224
+ 'quarta-feira',
225
+ 'quinta-feira',
226
+ 'sexta-feira',
227
+ 'sábado',
228
+ ],
229
+ shortWeekdays: ['Do', 'Se', 'Te', 'Qu', 'Qu', 'Se', 'Sá'],
230
+ firstDayOfWeek: 0,
231
+ calendar: 'Escolher data',
232
+ previous: 'Mês anterior',
233
+ next: 'Próximo mês',
234
+ clear: 'Limpar datas',
235
+ selected: 'Selecionada',
236
+ close: 'Fechar',
237
+ start: 'Início',
238
+ end: 'Fim',
239
+ format: 'AAAA-MM-DD',
240
+ errors: {
241
+ incomplete: 'Informe a data completa no formato AAAA-MM-DD.',
242
+ invalid: 'Informe uma data gregoriana válida no formato AAAA-MM-DD.',
243
+ 'before-min': 'Esta data é anterior ao mínimo.',
244
+ 'after-max': 'Esta data é posterior ao máximo.',
245
+ unavailable: 'Esta data não está disponível.',
246
+ reversed: 'O fim deve ser igual ou posterior ao início.',
247
+ 'unavailable-range': 'Este intervalo inclui uma data indisponível.',
248
+ },
249
+ },
250
+ } as const
251
+
252
+ export function dateValidationMessage(validation: DateValidation, locale: DateLocale): string {
253
+ return validation.valid
254
+ ? ''
255
+ : dateLocales[locale].errors[validation.reason as keyof (typeof dateLocales)['en-US']['errors']]
256
+ }
257
+
258
+ export function calendarMonth(
259
+ value: CivilDate,
260
+ firstDayOfWeek: number,
261
+ ): readonly (CivilDate | null)[] {
262
+ const parts = parseCivilDate(value)
263
+ if (!parts) throw new RangeError('Invalid civil date')
264
+ if (!Number.isInteger(firstDayOfWeek) || firstDayOfWeek < 0 || firstDayOfWeek > 6)
265
+ throw new RangeError('firstDayOfWeek must be an integer from 0 to 6')
266
+ const first = formatCivilDate({ ...parts, day: 1 })
267
+ const offset = (civilWeekday(first) - firstDayOfWeek + 7) % 7
268
+ const count = daysInMonth(parts.year, parts.month)
269
+ return Array.from({ length: Math.ceil((offset + count) / 7) * 7 }, (_, index) => {
270
+ const day = index - offset + 1
271
+ return day > 0 && day <= count ? formatCivilDate({ ...parts, day }) : null
272
+ })
273
+ }
274
+
275
+ export function calendarDayLabel(value: CivilDate, locale: DateLocale): string {
276
+ const parts = parseCivilDate(value)
277
+ if (!parts) throw new RangeError('Invalid civil date')
278
+ const words = dateLocales[locale]
279
+ return `${words.weekdays[civilWeekday(value)]}, ${parts.day} ${words.months[parts.month - 1]} ${parts.year}`
280
+ }
@@ -0,0 +1,115 @@
1
+ import type {
2
+ MotionPlayback,
3
+ MotionFrames,
4
+ MotionOptions,
5
+ MotionSurface,
6
+ MotionSurfaceAdapter,
7
+ MotionValues,
8
+ MotionBinding,
9
+ } from './experimental.js'
10
+
11
+ /** Controls share the engine clock. resume() continues; it never restarts playback. */
12
+ export interface MotionControlledPlayback extends MotionPlayback {
13
+ readonly paused: boolean
14
+ readonly duration: number
15
+ progress: number
16
+ pause(): void
17
+ resume(): void
18
+ }
19
+ export interface MotionTimeline extends MotionPlayback {
20
+ readonly paused: boolean
21
+ readonly duration: number | undefined
22
+ pause(): void
23
+ resume(): void
24
+ }
25
+ export interface MotionValueOptions extends MotionOptions {
26
+ layer?: string
27
+ }
28
+ export interface MotionDecayOptions {
29
+ friction?: number
30
+ snap?: readonly number[] | { x?: readonly number[]; y?: readonly number[] }
31
+ }
32
+ export type MotionPosition = number | '<' | `${'+' | '-'}${number}`
33
+ export type MotionStep<T = MotionSurface> =
34
+ readonly [T, MotionFrames, (MotionOptions & { at?: MotionPosition })?] | (() => MotionPlayback)
35
+ export type MotionTimelineStep<T = MotionSurface> =
36
+ | readonly [T, MotionFrames, (MotionOptions & { at?: MotionPosition })?]
37
+ | (() => MotionControlledPlayback)
38
+ | { at?: MotionPosition; run: () => MotionControlledPlayback }
39
+ export type MotionStateDefinitions<K extends string = string> = Record<
40
+ string,
41
+ Partial<Record<K, MotionValues>>
42
+ >
43
+ export type MotionStateTransition = MotionOptions & { targets?: Record<string, MotionOptions> }
44
+ export interface MotionStates<S extends string = string> extends MotionBinding {
45
+ readonly current: S | undefined
46
+ readonly settled: S | undefined
47
+ readonly paused: boolean
48
+ to(state: S, transition?: MotionStateTransition): MotionPlayback
49
+ pause(): void
50
+ resume(): void
51
+ stop(): void
52
+ }
53
+ export interface MotionStatesAdapter {
54
+ readonly current: string | undefined
55
+ readonly settled: string | undefined
56
+ readonly paused: boolean
57
+ to(state: string, transition?: MotionStateTransition): MotionPlayback
58
+ attach(name: string, surface: MotionSurfaceAdapter | null): void
59
+ pause(): void
60
+ play(): void
61
+ stop(): void
62
+ dispose(): void
63
+ }
64
+
65
+ const originals = new WeakMap<MotionPlayback, MotionPlayback>()
66
+ /** Renderer bridge. Returning the actual handle preserves Jolt's clock and arrival metadata. */
67
+ export function motionPlaybackAdapter(handle: MotionPlayback): MotionPlayback {
68
+ const raw = originals.get(handle)
69
+ if (!raw) throw new TypeError('Use playback returned by a Mavis motion surface or region.')
70
+ return raw
71
+ }
72
+ export function controlledMotionPlayback(
73
+ raw: MotionPlayback,
74
+ live: () => boolean,
75
+ ): MotionControlledPlayback {
76
+ const control = raw as MotionPlayback & {
77
+ pause(): void
78
+ play(): void
79
+ paused: boolean
80
+ duration: number
81
+ progress: number
82
+ }
83
+ const assert = () => {
84
+ if (!live()) throw new Error('This motion presentation is disposed.')
85
+ }
86
+ const result: MotionControlledPlayback = {
87
+ finished: raw.finished,
88
+ stop() {
89
+ if (live()) raw.stop()
90
+ },
91
+ pause() {
92
+ assert()
93
+ control.pause()
94
+ },
95
+ resume() {
96
+ assert()
97
+ control.play()
98
+ },
99
+ get paused() {
100
+ return control.paused
101
+ },
102
+ get duration() {
103
+ return control.duration
104
+ },
105
+ get progress() {
106
+ return control.progress
107
+ },
108
+ set progress(value) {
109
+ assert()
110
+ control.progress = value
111
+ },
112
+ }
113
+ originals.set(result, raw)
114
+ return result
115
+ }