@bigbluebutton/tlschema 2.0.0-alpha.19

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 (261) hide show
  1. package/LICENSE +190 -0
  2. package/dist-cjs/TLStore.js +133 -0
  3. package/dist-cjs/TLStore.js.map +7 -0
  4. package/dist-cjs/assets/TLBaseAsset.js +37 -0
  5. package/dist-cjs/assets/TLBaseAsset.js.map +7 -0
  6. package/dist-cjs/assets/TLBookmarkAsset.js +38 -0
  7. package/dist-cjs/assets/TLBookmarkAsset.js.map +7 -0
  8. package/dist-cjs/assets/TLImageAsset.js +76 -0
  9. package/dist-cjs/assets/TLImageAsset.js.map +7 -0
  10. package/dist-cjs/assets/TLVideoAsset.js +76 -0
  11. package/dist-cjs/assets/TLVideoAsset.js.map +7 -0
  12. package/dist-cjs/createPresenceStateDerivation.js +68 -0
  13. package/dist-cjs/createPresenceStateDerivation.js.map +7 -0
  14. package/dist-cjs/createTLSchema.js +68 -0
  15. package/dist-cjs/createTLSchema.js.map +7 -0
  16. package/dist-cjs/index.d.ts +1414 -0
  17. package/dist-cjs/index.js +142 -0
  18. package/dist-cjs/index.js.map +7 -0
  19. package/dist-cjs/misc/TLColor.js +36 -0
  20. package/dist-cjs/misc/TLColor.js.map +7 -0
  21. package/dist-cjs/misc/TLCursor.js +55 -0
  22. package/dist-cjs/misc/TLCursor.js.map +7 -0
  23. package/dist-cjs/misc/TLHandle.js +36 -0
  24. package/dist-cjs/misc/TLHandle.js.map +7 -0
  25. package/dist-cjs/misc/TLOpacity.js +30 -0
  26. package/dist-cjs/misc/TLOpacity.js.map +7 -0
  27. package/dist-cjs/misc/TLScribble.js +40 -0
  28. package/dist-cjs/misc/TLScribble.js.map +7 -0
  29. package/dist-cjs/misc/geometry-types.js +37 -0
  30. package/dist-cjs/misc/geometry-types.js.map +7 -0
  31. package/dist-cjs/misc/id-validator.js +33 -0
  32. package/dist-cjs/misc/id-validator.js.map +7 -0
  33. package/dist-cjs/records/TLAsset.js +74 -0
  34. package/dist-cjs/records/TLAsset.js.map +7 -0
  35. package/dist-cjs/records/TLCamera.js +74 -0
  36. package/dist-cjs/records/TLCamera.js.map +7 -0
  37. package/dist-cjs/records/TLDocument.js +82 -0
  38. package/dist-cjs/records/TLDocument.js.map +7 -0
  39. package/dist-cjs/records/TLInstance.js +452 -0
  40. package/dist-cjs/records/TLInstance.js.map +7 -0
  41. package/dist-cjs/records/TLPage.js +74 -0
  42. package/dist-cjs/records/TLPage.js.map +7 -0
  43. package/dist-cjs/records/TLPageState.js +209 -0
  44. package/dist-cjs/records/TLPageState.js.map +7 -0
  45. package/dist-cjs/records/TLPointer.js +76 -0
  46. package/dist-cjs/records/TLPointer.js.map +7 -0
  47. package/dist-cjs/records/TLPresence.js +170 -0
  48. package/dist-cjs/records/TLPresence.js.map +7 -0
  49. package/dist-cjs/records/TLRecord.js +17 -0
  50. package/dist-cjs/records/TLRecord.js.map +7 -0
  51. package/dist-cjs/records/TLShape.js +147 -0
  52. package/dist-cjs/records/TLShape.js.map +7 -0
  53. package/dist-cjs/shapes/TLArrowShape.js +156 -0
  54. package/dist-cjs/shapes/TLArrowShape.js.map +7 -0
  55. package/dist-cjs/shapes/TLBaseShape.js +52 -0
  56. package/dist-cjs/shapes/TLBaseShape.js.map +7 -0
  57. package/dist-cjs/shapes/TLBookmarkShape.js +57 -0
  58. package/dist-cjs/shapes/TLBookmarkShape.js.map +7 -0
  59. package/dist-cjs/shapes/TLDrawShape.js +89 -0
  60. package/dist-cjs/shapes/TLDrawShape.js.map +7 -0
  61. package/dist-cjs/shapes/TLEmbedShape.js +709 -0
  62. package/dist-cjs/shapes/TLEmbedShape.js.map +7 -0
  63. package/dist-cjs/shapes/TLFrameShape.js +33 -0
  64. package/dist-cjs/shapes/TLFrameShape.js.map +7 -0
  65. package/dist-cjs/shapes/TLGeoShape.js +230 -0
  66. package/dist-cjs/shapes/TLGeoShape.js.map +7 -0
  67. package/dist-cjs/shapes/TLGroupShape.js +28 -0
  68. package/dist-cjs/shapes/TLGroupShape.js.map +7 -0
  69. package/dist-cjs/shapes/TLHighlightShape.js +38 -0
  70. package/dist-cjs/shapes/TLHighlightShape.js.map +7 -0
  71. package/dist-cjs/shapes/TLImageShape.js +69 -0
  72. package/dist-cjs/shapes/TLImageShape.js.map +7 -0
  73. package/dist-cjs/shapes/TLLineShape.js +70 -0
  74. package/dist-cjs/shapes/TLLineShape.js.map +7 -0
  75. package/dist-cjs/shapes/TLNoteShape.js +144 -0
  76. package/dist-cjs/shapes/TLNoteShape.js.map +7 -0
  77. package/dist-cjs/shapes/TLTextShape.js +67 -0
  78. package/dist-cjs/shapes/TLTextShape.js.map +7 -0
  79. package/dist-cjs/shapes/TLVideoShape.js +53 -0
  80. package/dist-cjs/shapes/TLVideoShape.js.map +7 -0
  81. package/dist-cjs/store-migrations.js +81 -0
  82. package/dist-cjs/store-migrations.js.map +7 -0
  83. package/dist-cjs/styles/StyleProp.js +94 -0
  84. package/dist-cjs/styles/StyleProp.js.map +7 -0
  85. package/dist-cjs/styles/TLColorStyle.js +283 -0
  86. package/dist-cjs/styles/TLColorStyle.js.map +7 -0
  87. package/dist-cjs/styles/TLDashStyle.js +29 -0
  88. package/dist-cjs/styles/TLDashStyle.js.map +7 -0
  89. package/dist-cjs/styles/TLFillStyle.js +29 -0
  90. package/dist-cjs/styles/TLFillStyle.js.map +7 -0
  91. package/dist-cjs/styles/TLFontStyle.js +36 -0
  92. package/dist-cjs/styles/TLFontStyle.js.map +7 -0
  93. package/dist-cjs/styles/TLHorizontalAlignStyle.js +29 -0
  94. package/dist-cjs/styles/TLHorizontalAlignStyle.js.map +7 -0
  95. package/dist-cjs/styles/TLSizeStyle.js +29 -0
  96. package/dist-cjs/styles/TLSizeStyle.js.map +7 -0
  97. package/dist-cjs/styles/TLVerticalAlignStyle.js +29 -0
  98. package/dist-cjs/styles/TLVerticalAlignStyle.js.map +7 -0
  99. package/dist-cjs/translations/languages.js +59 -0
  100. package/dist-cjs/translations/languages.js.map +7 -0
  101. package/dist-cjs/translations/translations.js +63 -0
  102. package/dist-cjs/translations/translations.js.map +7 -0
  103. package/dist-cjs/util-types.js +17 -0
  104. package/dist-cjs/util-types.js.map +7 -0
  105. package/dist-esm/TLStore.mjs +113 -0
  106. package/dist-esm/TLStore.mjs.map +7 -0
  107. package/dist-esm/assets/TLBaseAsset.mjs +17 -0
  108. package/dist-esm/assets/TLBaseAsset.mjs.map +7 -0
  109. package/dist-esm/assets/TLBookmarkAsset.mjs +18 -0
  110. package/dist-esm/assets/TLBookmarkAsset.mjs.map +7 -0
  111. package/dist-esm/assets/TLImageAsset.mjs +56 -0
  112. package/dist-esm/assets/TLImageAsset.mjs.map +7 -0
  113. package/dist-esm/assets/TLVideoAsset.mjs +56 -0
  114. package/dist-esm/assets/TLVideoAsset.mjs.map +7 -0
  115. package/dist-esm/createPresenceStateDerivation.mjs +48 -0
  116. package/dist-esm/createPresenceStateDerivation.mjs.map +7 -0
  117. package/dist-esm/createTLSchema.mjs +48 -0
  118. package/dist-esm/createTLSchema.mjs.map +7 -0
  119. package/dist-esm/index.d.mts +1414 -0
  120. package/dist-esm/index.mjs +193 -0
  121. package/dist-esm/index.mjs.map +7 -0
  122. package/dist-esm/misc/TLColor.mjs +16 -0
  123. package/dist-esm/misc/TLColor.mjs.map +7 -0
  124. package/dist-esm/misc/TLCursor.mjs +35 -0
  125. package/dist-esm/misc/TLCursor.mjs.map +7 -0
  126. package/dist-esm/misc/TLHandle.mjs +16 -0
  127. package/dist-esm/misc/TLHandle.mjs.map +7 -0
  128. package/dist-esm/misc/TLOpacity.mjs +10 -0
  129. package/dist-esm/misc/TLOpacity.mjs.map +7 -0
  130. package/dist-esm/misc/TLScribble.mjs +20 -0
  131. package/dist-esm/misc/TLScribble.mjs.map +7 -0
  132. package/dist-esm/misc/geometry-types.mjs +17 -0
  133. package/dist-esm/misc/geometry-types.mjs.map +7 -0
  134. package/dist-esm/misc/id-validator.mjs +13 -0
  135. package/dist-esm/misc/id-validator.mjs.map +7 -0
  136. package/dist-esm/records/TLAsset.mjs +57 -0
  137. package/dist-esm/records/TLAsset.mjs.map +7 -0
  138. package/dist-esm/records/TLCamera.mjs +54 -0
  139. package/dist-esm/records/TLCamera.mjs.map +7 -0
  140. package/dist-esm/records/TLDocument.mjs +62 -0
  141. package/dist-esm/records/TLDocument.mjs.map +7 -0
  142. package/dist-esm/records/TLInstance.mjs +432 -0
  143. package/dist-esm/records/TLInstance.mjs.map +7 -0
  144. package/dist-esm/records/TLPage.mjs +54 -0
  145. package/dist-esm/records/TLPage.mjs.map +7 -0
  146. package/dist-esm/records/TLPageState.mjs +189 -0
  147. package/dist-esm/records/TLPageState.mjs.map +7 -0
  148. package/dist-esm/records/TLPointer.mjs +56 -0
  149. package/dist-esm/records/TLPointer.mjs.map +7 -0
  150. package/dist-esm/records/TLPresence.mjs +150 -0
  151. package/dist-esm/records/TLPresence.mjs.map +7 -0
  152. package/dist-esm/records/TLRecord.mjs +1 -0
  153. package/dist-esm/records/TLRecord.mjs.map +7 -0
  154. package/dist-esm/records/TLShape.mjs +127 -0
  155. package/dist-esm/records/TLShape.mjs.map +7 -0
  156. package/dist-esm/shapes/TLArrowShape.mjs +136 -0
  157. package/dist-esm/shapes/TLArrowShape.mjs.map +7 -0
  158. package/dist-esm/shapes/TLBaseShape.mjs +32 -0
  159. package/dist-esm/shapes/TLBaseShape.mjs.map +7 -0
  160. package/dist-esm/shapes/TLBookmarkShape.mjs +37 -0
  161. package/dist-esm/shapes/TLBookmarkShape.mjs.map +7 -0
  162. package/dist-esm/shapes/TLDrawShape.mjs +69 -0
  163. package/dist-esm/shapes/TLDrawShape.mjs.map +7 -0
  164. package/dist-esm/shapes/TLEmbedShape.mjs +689 -0
  165. package/dist-esm/shapes/TLEmbedShape.mjs.map +7 -0
  166. package/dist-esm/shapes/TLFrameShape.mjs +13 -0
  167. package/dist-esm/shapes/TLFrameShape.mjs.map +7 -0
  168. package/dist-esm/shapes/TLGeoShape.mjs +212 -0
  169. package/dist-esm/shapes/TLGeoShape.mjs.map +7 -0
  170. package/dist-esm/shapes/TLGroupShape.mjs +8 -0
  171. package/dist-esm/shapes/TLGroupShape.mjs.map +7 -0
  172. package/dist-esm/shapes/TLHighlightShape.mjs +18 -0
  173. package/dist-esm/shapes/TLHighlightShape.mjs.map +7 -0
  174. package/dist-esm/shapes/TLImageShape.mjs +49 -0
  175. package/dist-esm/shapes/TLImageShape.mjs.map +7 -0
  176. package/dist-esm/shapes/TLLineShape.mjs +50 -0
  177. package/dist-esm/shapes/TLLineShape.mjs.map +7 -0
  178. package/dist-esm/shapes/TLNoteShape.mjs +126 -0
  179. package/dist-esm/shapes/TLNoteShape.mjs.map +7 -0
  180. package/dist-esm/shapes/TLTextShape.mjs +47 -0
  181. package/dist-esm/shapes/TLTextShape.mjs.map +7 -0
  182. package/dist-esm/shapes/TLVideoShape.mjs +33 -0
  183. package/dist-esm/shapes/TLVideoShape.mjs.map +7 -0
  184. package/dist-esm/store-migrations.mjs +61 -0
  185. package/dist-esm/store-migrations.mjs.map +7 -0
  186. package/dist-esm/styles/StyleProp.mjs +74 -0
  187. package/dist-esm/styles/StyleProp.mjs.map +7 -0
  188. package/dist-esm/styles/TLColorStyle.mjs +263 -0
  189. package/dist-esm/styles/TLColorStyle.mjs.map +7 -0
  190. package/dist-esm/styles/TLDashStyle.mjs +9 -0
  191. package/dist-esm/styles/TLDashStyle.mjs.map +7 -0
  192. package/dist-esm/styles/TLFillStyle.mjs +9 -0
  193. package/dist-esm/styles/TLFillStyle.mjs.map +7 -0
  194. package/dist-esm/styles/TLFontStyle.mjs +16 -0
  195. package/dist-esm/styles/TLFontStyle.mjs.map +7 -0
  196. package/dist-esm/styles/TLHorizontalAlignStyle.mjs +9 -0
  197. package/dist-esm/styles/TLHorizontalAlignStyle.mjs.map +7 -0
  198. package/dist-esm/styles/TLSizeStyle.mjs +9 -0
  199. package/dist-esm/styles/TLSizeStyle.mjs.map +7 -0
  200. package/dist-esm/styles/TLVerticalAlignStyle.mjs +9 -0
  201. package/dist-esm/styles/TLVerticalAlignStyle.mjs.map +7 -0
  202. package/dist-esm/translations/languages.mjs +39 -0
  203. package/dist-esm/translations/languages.mjs.map +7 -0
  204. package/dist-esm/translations/translations.mjs +43 -0
  205. package/dist-esm/translations/translations.mjs.map +7 -0
  206. package/dist-esm/util-types.mjs +1 -0
  207. package/dist-esm/util-types.mjs.map +7 -0
  208. package/package.json +64 -0
  209. package/src/TLStore.ts +160 -0
  210. package/src/assets/TLBaseAsset.ts +44 -0
  211. package/src/assets/TLBookmarkAsset.ts +31 -0
  212. package/src/assets/TLImageAsset.ts +73 -0
  213. package/src/assets/TLVideoAsset.ts +73 -0
  214. package/src/createPresenceStateDerivation.ts +53 -0
  215. package/src/createTLSchema.ts +65 -0
  216. package/src/index.ts +168 -0
  217. package/src/migrations.test.ts +1768 -0
  218. package/src/misc/TLColor.ts +28 -0
  219. package/src/misc/TLCursor.ts +54 -0
  220. package/src/misc/TLHandle.ts +41 -0
  221. package/src/misc/TLOpacity.ts +11 -0
  222. package/src/misc/TLScribble.ts +39 -0
  223. package/src/misc/geometry-types.ts +37 -0
  224. package/src/misc/id-validator.ts +14 -0
  225. package/src/records/TLAsset.ts +80 -0
  226. package/src/records/TLCamera.ts +74 -0
  227. package/src/records/TLDocument.ts +77 -0
  228. package/src/records/TLInstance.ts +493 -0
  229. package/src/records/TLPage.ts +72 -0
  230. package/src/records/TLPageState.ts +216 -0
  231. package/src/records/TLPointer.ts +74 -0
  232. package/src/records/TLPresence.ts +179 -0
  233. package/src/records/TLRecord.ts +21 -0
  234. package/src/records/TLShape.ts +214 -0
  235. package/src/shapes/TLArrowShape.ts +160 -0
  236. package/src/shapes/TLBaseShape.ts +67 -0
  237. package/src/shapes/TLBookmarkShape.ts +44 -0
  238. package/src/shapes/TLDrawShape.ts +89 -0
  239. package/src/shapes/TLEmbedShape.ts +754 -0
  240. package/src/shapes/TLFrameShape.ts +18 -0
  241. package/src/shapes/TLGeoShape.ts +226 -0
  242. package/src/shapes/TLGroupShape.ts +14 -0
  243. package/src/shapes/TLHighlightShape.ts +24 -0
  244. package/src/shapes/TLImageShape.ts +59 -0
  245. package/src/shapes/TLLineShape.ts +61 -0
  246. package/src/shapes/TLNoteShape.ts +137 -0
  247. package/src/shapes/TLTextShape.ts +55 -0
  248. package/src/shapes/TLVideoShape.ts +40 -0
  249. package/src/store-migrations.ts +63 -0
  250. package/src/styles/StyleProp.ts +105 -0
  251. package/src/styles/TLColorStyle.ts +296 -0
  252. package/src/styles/TLDashStyle.ts +11 -0
  253. package/src/styles/TLFillStyle.ts +11 -0
  254. package/src/styles/TLFontStyle.ts +19 -0
  255. package/src/styles/TLHorizontalAlignStyle.ts +11 -0
  256. package/src/styles/TLSizeStyle.ts +11 -0
  257. package/src/styles/TLVerticalAlignStyle.ts +11 -0
  258. package/src/translations/languages.ts +39 -0
  259. package/src/translations/translations.test.ts +43 -0
  260. package/src/translations/translations.ts +73 -0
  261. package/src/util-types.ts +2 -0
@@ -0,0 +1,18 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { T } from '@bigbluebutton/validate'
3
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
4
+
5
+ /** @public */
6
+ export const frameShapeProps = {
7
+ w: T.nonZeroNumber,
8
+ h: T.nonZeroNumber,
9
+ name: T.string,
10
+ }
11
+
12
+ type TLFrameShapeProps = ShapePropsType<typeof frameShapeProps>
13
+
14
+ /** @public */
15
+ export type TLFrameShape = TLBaseShape<'frame', TLFrameShapeProps>
16
+
17
+ /** @internal */
18
+ export const frameShapeMigrations = defineMigrations({})
@@ -0,0 +1,226 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { T } from '@bigbluebutton/validate'
3
+ import { StyleProp } from '../styles/StyleProp'
4
+ import { DefaultColorStyle, DefaultLabelColorStyle } from '../styles/TLColorStyle'
5
+ import { DefaultDashStyle } from '../styles/TLDashStyle'
6
+ import { DefaultFillStyle } from '../styles/TLFillStyle'
7
+ import { DefaultFontStyle } from '../styles/TLFontStyle'
8
+ import {
9
+ DefaultHorizontalAlignStyle,
10
+ TLDefaultHorizontalAlignStyle,
11
+ } from '../styles/TLHorizontalAlignStyle'
12
+ import { DefaultSizeStyle } from '../styles/TLSizeStyle'
13
+ import { DefaultVerticalAlignStyle } from '../styles/TLVerticalAlignStyle'
14
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
15
+
16
+ /** @public */
17
+ export const GeoShapeGeoStyle = StyleProp.defineEnum('tldraw:geo', {
18
+ defaultValue: 'rectangle',
19
+ values: [
20
+ 'cloud',
21
+ 'rectangle',
22
+ 'ellipse',
23
+ 'triangle',
24
+ 'diamond',
25
+ 'pentagon',
26
+ 'hexagon',
27
+ 'octagon',
28
+ 'star',
29
+ 'rhombus',
30
+ 'rhombus-2',
31
+ 'oval',
32
+ 'trapezoid',
33
+ 'arrow-right',
34
+ 'arrow-left',
35
+ 'arrow-up',
36
+ 'arrow-down',
37
+ 'x-box',
38
+ 'check-box',
39
+ ],
40
+ })
41
+
42
+ /** @public */
43
+ export type TLGeoShapeGeoStyle = T.TypeOf<typeof GeoShapeGeoStyle>
44
+
45
+ /** @public */
46
+ export const geoShapeProps = {
47
+ geo: GeoShapeGeoStyle,
48
+ labelColor: DefaultLabelColorStyle,
49
+ color: DefaultColorStyle,
50
+ fill: DefaultFillStyle,
51
+ dash: DefaultDashStyle,
52
+ size: DefaultSizeStyle,
53
+ font: DefaultFontStyle,
54
+ align: DefaultHorizontalAlignStyle,
55
+ verticalAlign: DefaultVerticalAlignStyle,
56
+ url: T.string,
57
+ w: T.nonZeroNumber,
58
+ h: T.nonZeroNumber,
59
+ growY: T.positiveNumber,
60
+ text: T.string,
61
+ }
62
+
63
+ /** @public */
64
+ export type TLGeoShapeProps = ShapePropsType<typeof geoShapeProps>
65
+
66
+ /** @public */
67
+ export type TLGeoShape = TLBaseShape<'geo', TLGeoShapeProps>
68
+
69
+ const Versions = {
70
+ AddUrlProp: 1,
71
+ AddLabelColor: 2,
72
+ RemoveJustify: 3,
73
+ AddCheckBox: 4,
74
+ AddVerticalAlign: 5,
75
+ MigrateLegacyAlign: 6,
76
+ AddCloud: 7,
77
+ } as const
78
+
79
+ export { Versions as GeoShapeVersions }
80
+
81
+ /** @internal */
82
+ export const geoShapeMigrations = defineMigrations({
83
+ currentVersion: Versions.AddCloud,
84
+ migrators: {
85
+ [Versions.AddUrlProp]: {
86
+ up: (shape) => {
87
+ return { ...shape, props: { ...shape.props, url: '' } }
88
+ },
89
+ down: (shape) => {
90
+ const { url: _, ...props } = shape.props
91
+ return { ...shape, props }
92
+ },
93
+ },
94
+ [Versions.AddLabelColor]: {
95
+ up: (record) => {
96
+ return {
97
+ ...record,
98
+ props: {
99
+ ...record.props,
100
+ labelColor: 'black',
101
+ },
102
+ }
103
+ },
104
+ down: (record) => {
105
+ const { labelColor: _, ...props } = record.props
106
+ return {
107
+ ...record,
108
+ props,
109
+ }
110
+ },
111
+ },
112
+ [Versions.RemoveJustify]: {
113
+ up: (shape) => {
114
+ let newAlign = shape.props.align
115
+ if (newAlign === 'justify') {
116
+ newAlign = 'start'
117
+ }
118
+
119
+ return {
120
+ ...shape,
121
+ props: {
122
+ ...shape.props,
123
+ align: newAlign,
124
+ },
125
+ }
126
+ },
127
+ down: (shape) => {
128
+ return { ...shape }
129
+ },
130
+ },
131
+ [Versions.AddCheckBox]: {
132
+ up: (shape) => {
133
+ return { ...shape }
134
+ },
135
+ down: (shape) => {
136
+ return {
137
+ ...shape,
138
+ props: {
139
+ ...shape.props,
140
+ geo: shape.props.geo === 'check-box' ? 'rectangle' : shape.props.geo,
141
+ },
142
+ }
143
+ },
144
+ },
145
+ [Versions.AddVerticalAlign]: {
146
+ up: (shape) => {
147
+ return {
148
+ ...shape,
149
+ props: {
150
+ ...shape.props,
151
+ verticalAlign: 'middle',
152
+ },
153
+ }
154
+ },
155
+ down: (shape) => {
156
+ const { verticalAlign: _, ...props } = shape.props
157
+ return {
158
+ ...shape,
159
+ props,
160
+ }
161
+ },
162
+ },
163
+ [Versions.MigrateLegacyAlign]: {
164
+ up: (shape) => {
165
+ let newAlign: TLDefaultHorizontalAlignStyle
166
+ switch (shape.props.align) {
167
+ case 'start':
168
+ newAlign = 'start-legacy'
169
+ break
170
+ case 'end':
171
+ newAlign = 'end-legacy'
172
+ break
173
+ default:
174
+ newAlign = 'middle-legacy'
175
+ break
176
+ }
177
+ return {
178
+ ...shape,
179
+ props: {
180
+ ...shape.props,
181
+ align: newAlign,
182
+ },
183
+ }
184
+ },
185
+ down: (shape) => {
186
+ let oldAlign: TLDefaultHorizontalAlignStyle
187
+ switch (shape.props.align) {
188
+ case 'start-legacy':
189
+ oldAlign = 'start'
190
+ break
191
+ case 'end-legacy':
192
+ oldAlign = 'end'
193
+ break
194
+ case 'middle-legacy':
195
+ oldAlign = 'middle'
196
+ break
197
+ default:
198
+ oldAlign = shape.props.align
199
+ }
200
+ return {
201
+ ...shape,
202
+ props: {
203
+ ...shape.props,
204
+ align: oldAlign,
205
+ },
206
+ }
207
+ },
208
+ },
209
+ [Versions.AddCloud]: {
210
+ up: (shape) => {
211
+ return shape
212
+ },
213
+ down: (shape) => {
214
+ if (shape.props.geo === 'cloud') {
215
+ return {
216
+ ...shape,
217
+ props: {
218
+ ...shape.props,
219
+ geo: 'rectangle',
220
+ },
221
+ }
222
+ }
223
+ },
224
+ },
225
+ },
226
+ })
@@ -0,0 +1,14 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { ShapeProps, TLBaseShape } from './TLBaseShape'
3
+
4
+ /** @public */
5
+ export type TLGroupShapeProps = { [key in never]: undefined }
6
+
7
+ /** @public */
8
+ export type TLGroupShape = TLBaseShape<'group', TLGroupShapeProps>
9
+
10
+ /** @internal */
11
+ export const groupShapeProps: ShapeProps<TLGroupShape> = {}
12
+
13
+ /** @internal */
14
+ export const groupShapeMigrations = defineMigrations({})
@@ -0,0 +1,24 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { T } from '@bigbluebutton/validate'
3
+ import { DefaultColorStyle } from '../styles/TLColorStyle'
4
+ import { DefaultSizeStyle } from '../styles/TLSizeStyle'
5
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
6
+ import { DrawShapeSegment } from './TLDrawShape'
7
+
8
+ /** @public */
9
+ export const highlightShapeProps = {
10
+ color: DefaultColorStyle,
11
+ size: DefaultSizeStyle,
12
+ segments: T.arrayOf(DrawShapeSegment),
13
+ isComplete: T.boolean,
14
+ isPen: T.boolean,
15
+ }
16
+
17
+ /** @public */
18
+ export type TLHighlightShapeProps = ShapePropsType<typeof highlightShapeProps>
19
+
20
+ /** @public */
21
+ export type TLHighlightShape = TLBaseShape<'highlight', TLHighlightShapeProps>
22
+
23
+ /** @internal */
24
+ export const highlightShapeMigrations = defineMigrations({})
@@ -0,0 +1,59 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { T } from '@bigbluebutton/validate'
3
+ import { assetIdValidator } from '../assets/TLBaseAsset'
4
+ import { vec2dModelValidator } from '../misc/geometry-types'
5
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
6
+
7
+ /** @public */
8
+ export const ImageShapeCrop = T.object({
9
+ topLeft: vec2dModelValidator,
10
+ bottomRight: vec2dModelValidator,
11
+ })
12
+ /** @public */
13
+ export type TLImageShapeCrop = T.TypeOf<typeof ImageShapeCrop>
14
+
15
+ /** @public */
16
+ export const imageShapeProps = {
17
+ w: T.nonZeroNumber,
18
+ h: T.nonZeroNumber,
19
+ playing: T.boolean,
20
+ url: T.string,
21
+ assetId: assetIdValidator.nullable(),
22
+ crop: ImageShapeCrop.nullable(),
23
+ }
24
+
25
+ /** @public */
26
+ export type TLImageShapeProps = ShapePropsType<typeof imageShapeProps>
27
+
28
+ /** @public */
29
+ export type TLImageShape = TLBaseShape<'image', TLImageShapeProps>
30
+
31
+ const Versions = {
32
+ AddUrlProp: 1,
33
+ AddCropProp: 2,
34
+ } as const
35
+
36
+ /** @internal */
37
+ export const imageShapeMigrations = defineMigrations({
38
+ currentVersion: Versions.AddCropProp,
39
+ migrators: {
40
+ [Versions.AddUrlProp]: {
41
+ up: (shape) => {
42
+ return { ...shape, props: { ...shape.props, url: '' } }
43
+ },
44
+ down: (shape) => {
45
+ const { url: _, ...props } = shape.props
46
+ return { ...shape, props }
47
+ },
48
+ },
49
+ [Versions.AddCropProp]: {
50
+ up: (shape) => {
51
+ return { ...shape, props: { ...shape.props, crop: null } }
52
+ },
53
+ down: (shape) => {
54
+ const { crop: _, ...props } = shape.props
55
+ return { ...shape, props }
56
+ },
57
+ },
58
+ },
59
+ })
@@ -0,0 +1,61 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { deepCopy } from '@bigbluebutton/utils'
3
+ import { T } from '@bigbluebutton/validate'
4
+ import { handleValidator } from '../misc/TLHandle'
5
+ import { StyleProp } from '../styles/StyleProp'
6
+ import { DefaultColorStyle } from '../styles/TLColorStyle'
7
+ import { DefaultDashStyle } from '../styles/TLDashStyle'
8
+ import { DefaultSizeStyle } from '../styles/TLSizeStyle'
9
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
10
+
11
+ /** @public */
12
+ export const LineShapeSplineStyle = StyleProp.defineEnum('tldraw:spline', {
13
+ defaultValue: 'line',
14
+ values: ['cubic', 'line'],
15
+ })
16
+
17
+ /** @public */
18
+ export type TLLineShapeSplineStyle = T.TypeOf<typeof LineShapeSplineStyle>
19
+
20
+ /** @public */
21
+ export const lineShapeProps = {
22
+ color: DefaultColorStyle,
23
+ dash: DefaultDashStyle,
24
+ size: DefaultSizeStyle,
25
+ spline: LineShapeSplineStyle,
26
+ handles: T.dict(T.string, handleValidator),
27
+ }
28
+
29
+ /** @public */
30
+ export type TLLineShapeProps = ShapePropsType<typeof lineShapeProps>
31
+
32
+ /** @public */
33
+ export type TLLineShape = TLBaseShape<'line', TLLineShapeProps>
34
+
35
+ /** @internal */
36
+ export const lineShapeVersions = {
37
+ AddSnapHandles: 1,
38
+ } as const
39
+
40
+ /** @internal */
41
+ export const lineShapeMigrations = defineMigrations({
42
+ currentVersion: lineShapeVersions.AddSnapHandles,
43
+ migrators: {
44
+ [lineShapeVersions.AddSnapHandles]: {
45
+ up: (record: any) => {
46
+ const handles = deepCopy(record.props.handles as Record<string, any>)
47
+ for (const id in handles) {
48
+ handles[id].canSnap = true
49
+ }
50
+ return { ...record, props: { ...record.props, handles } }
51
+ },
52
+ down: (record: any) => {
53
+ const handles = deepCopy(record.props.handles as Record<string, any>)
54
+ for (const id in handles) {
55
+ delete handles[id].canSnap
56
+ }
57
+ return { ...record, props: { ...record.props, handles } }
58
+ },
59
+ },
60
+ },
61
+ })
@@ -0,0 +1,137 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { T } from '@bigbluebutton/validate'
3
+ import { DefaultColorStyle } from '../styles/TLColorStyle'
4
+ import { DefaultFontStyle } from '../styles/TLFontStyle'
5
+ import {
6
+ DefaultHorizontalAlignStyle,
7
+ TLDefaultHorizontalAlignStyle,
8
+ } from '../styles/TLHorizontalAlignStyle'
9
+ import { DefaultSizeStyle } from '../styles/TLSizeStyle'
10
+ import { DefaultVerticalAlignStyle } from '../styles/TLVerticalAlignStyle'
11
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
12
+
13
+ /** @public */
14
+ export const noteShapeProps = {
15
+ color: DefaultColorStyle,
16
+ size: DefaultSizeStyle,
17
+ font: DefaultFontStyle,
18
+ align: DefaultHorizontalAlignStyle,
19
+ verticalAlign: DefaultVerticalAlignStyle,
20
+ growY: T.positiveNumber,
21
+ url: T.string,
22
+ text: T.string,
23
+ }
24
+
25
+ /** @public */
26
+ export type TLNoteShapeProps = ShapePropsType<typeof noteShapeProps>
27
+
28
+ /** @public */
29
+ export type TLNoteShape = TLBaseShape<'note', TLNoteShapeProps>
30
+
31
+ const Versions = {
32
+ AddUrlProp: 1,
33
+ RemoveJustify: 2,
34
+ MigrateLegacyAlign: 3,
35
+ AddVerticalAlign: 4,
36
+ } as const
37
+
38
+ /** @internal */
39
+ export const noteShapeMigrations = defineMigrations({
40
+ currentVersion: Versions.AddVerticalAlign,
41
+ migrators: {
42
+ [Versions.AddUrlProp]: {
43
+ up: (shape) => {
44
+ return { ...shape, props: { ...shape.props, url: '' } }
45
+ },
46
+ down: (shape) => {
47
+ const { url: _, ...props } = shape.props
48
+ return { ...shape, props }
49
+ },
50
+ },
51
+ [Versions.RemoveJustify]: {
52
+ up: (shape) => {
53
+ let newAlign = shape.props.align
54
+ if (newAlign === 'justify') {
55
+ newAlign = 'start'
56
+ }
57
+
58
+ return {
59
+ ...shape,
60
+ props: {
61
+ ...shape.props,
62
+ align: newAlign,
63
+ },
64
+ }
65
+ },
66
+ down: (shape) => {
67
+ return { ...shape }
68
+ },
69
+ },
70
+
71
+ [Versions.MigrateLegacyAlign]: {
72
+ up: (shape) => {
73
+ let newAlign: TLDefaultHorizontalAlignStyle
74
+ switch (shape.props.align) {
75
+ case 'start':
76
+ newAlign = 'start-legacy'
77
+ break
78
+ case 'end':
79
+ newAlign = 'end-legacy'
80
+ break
81
+ default:
82
+ newAlign = 'middle-legacy'
83
+ break
84
+ }
85
+ return {
86
+ ...shape,
87
+ props: {
88
+ ...shape.props,
89
+ align: newAlign,
90
+ },
91
+ }
92
+ },
93
+ down: (shape) => {
94
+ let oldAlign: TLDefaultHorizontalAlignStyle
95
+ switch (shape.props.align) {
96
+ case 'start-legacy':
97
+ oldAlign = 'start'
98
+ break
99
+ case 'end-legacy':
100
+ oldAlign = 'end'
101
+ break
102
+ case 'middle-legacy':
103
+ oldAlign = 'middle'
104
+ break
105
+ default:
106
+ oldAlign = shape.props.align
107
+ }
108
+ return {
109
+ ...shape,
110
+ props: {
111
+ ...shape.props,
112
+ align: oldAlign,
113
+ },
114
+ }
115
+ },
116
+ },
117
+ [Versions.AddVerticalAlign]: {
118
+ up: (shape) => {
119
+ return {
120
+ ...shape,
121
+ props: {
122
+ ...shape.props,
123
+ verticalAlign: 'middle',
124
+ },
125
+ }
126
+ },
127
+ down: (shape) => {
128
+ const { verticalAlign: _, ...props } = shape.props
129
+
130
+ return {
131
+ ...shape,
132
+ props,
133
+ }
134
+ },
135
+ },
136
+ },
137
+ })
@@ -0,0 +1,55 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { T } from '@bigbluebutton/validate'
3
+ import { DefaultColorStyle } from '../styles/TLColorStyle'
4
+ import { DefaultFontStyle } from '../styles/TLFontStyle'
5
+ import { DefaultHorizontalAlignStyle } from '../styles/TLHorizontalAlignStyle'
6
+ import { DefaultSizeStyle } from '../styles/TLSizeStyle'
7
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
8
+
9
+ /** @public */
10
+ export const textShapeProps = {
11
+ color: DefaultColorStyle,
12
+ size: DefaultSizeStyle,
13
+ font: DefaultFontStyle,
14
+ align: DefaultHorizontalAlignStyle,
15
+ w: T.nonZeroNumber,
16
+ text: T.string,
17
+ scale: T.nonZeroNumber,
18
+ autoSize: T.boolean,
19
+ }
20
+
21
+ /** @public */
22
+ export type TLTextShapeProps = ShapePropsType<typeof textShapeProps>
23
+
24
+ /** @public */
25
+ export type TLTextShape = TLBaseShape<'text', TLTextShapeProps>
26
+
27
+ const Versions = {
28
+ RemoveJustify: 1,
29
+ } as const
30
+
31
+ /** @internal */
32
+ export const textShapeMigrations = defineMigrations({
33
+ currentVersion: Versions.RemoveJustify,
34
+ migrators: {
35
+ [Versions.RemoveJustify]: {
36
+ up: (shape) => {
37
+ let newAlign = shape.props.align
38
+ if (newAlign === 'justify') {
39
+ newAlign = 'start'
40
+ }
41
+
42
+ return {
43
+ ...shape,
44
+ props: {
45
+ ...shape.props,
46
+ align: newAlign,
47
+ },
48
+ }
49
+ },
50
+ down: (shape) => {
51
+ return { ...shape }
52
+ },
53
+ },
54
+ },
55
+ })
@@ -0,0 +1,40 @@
1
+ import { defineMigrations } from '@bigbluebutton/store'
2
+ import { T } from '@bigbluebutton/validate'
3
+ import { assetIdValidator } from '../assets/TLBaseAsset'
4
+ import { ShapePropsType, TLBaseShape } from './TLBaseShape'
5
+
6
+ /** @public */
7
+ export const videoShapeProps = {
8
+ w: T.nonZeroNumber,
9
+ h: T.nonZeroNumber,
10
+ time: T.number,
11
+ playing: T.boolean,
12
+ url: T.string,
13
+ assetId: assetIdValidator.nullable(),
14
+ }
15
+
16
+ /** @public */
17
+ export type TLVideoShapeProps = ShapePropsType<typeof videoShapeProps>
18
+
19
+ /** @public */
20
+ export type TLVideoShape = TLBaseShape<'video', TLVideoShapeProps>
21
+
22
+ const Versions = {
23
+ AddUrlProp: 1,
24
+ } as const
25
+
26
+ /** @internal */
27
+ export const videoShapeMigrations = defineMigrations({
28
+ currentVersion: Versions.AddUrlProp,
29
+ migrators: {
30
+ [Versions.AddUrlProp]: {
31
+ up: (shape) => {
32
+ return { ...shape, props: { ...shape.props, url: '' } }
33
+ },
34
+ down: (shape) => {
35
+ const { url: _, ...props } = shape.props
36
+ return { ...shape, props }
37
+ },
38
+ },
39
+ },
40
+ })
@@ -0,0 +1,63 @@
1
+ import { defineMigrations, SerializedStore } from '@bigbluebutton/store'
2
+ import { TLRecord } from './records/TLRecord'
3
+
4
+ const Versions = {
5
+ RemoveCodeAndIconShapeTypes: 1,
6
+ AddInstancePresenceType: 2,
7
+ RemoveTLUserAndPresenceAndAddPointer: 3,
8
+ RemoveUserDocument: 4,
9
+ } as const
10
+
11
+ export { Versions as storeVersions }
12
+
13
+ /** @public */
14
+ export const storeMigrations = defineMigrations({
15
+ currentVersion: Versions.RemoveUserDocument,
16
+ migrators: {
17
+ [Versions.RemoveCodeAndIconShapeTypes]: {
18
+ up: (store: SerializedStore<TLRecord>) => {
19
+ return Object.fromEntries(
20
+ Object.entries(store).filter(
21
+ ([_, v]) => v.typeName !== 'shape' || (v.type !== 'icon' && v.type !== 'code')
22
+ )
23
+ )
24
+ },
25
+ down: (store: SerializedStore<TLRecord>) => {
26
+ // noop
27
+ return store
28
+ },
29
+ },
30
+ [Versions.AddInstancePresenceType]: {
31
+ up: (store: SerializedStore<TLRecord>) => {
32
+ return store
33
+ },
34
+ down: (store: SerializedStore<TLRecord>) => {
35
+ return Object.fromEntries(
36
+ Object.entries(store).filter(([_, v]) => v.typeName !== 'instance_presence')
37
+ )
38
+ },
39
+ },
40
+ [Versions.RemoveTLUserAndPresenceAndAddPointer]: {
41
+ up: (store: SerializedStore<TLRecord>) => {
42
+ return Object.fromEntries(
43
+ Object.entries(store).filter(([_, v]) => !v.typeName.match(/^(user|user_presence)$/))
44
+ )
45
+ },
46
+ down: (store: SerializedStore<TLRecord>) => {
47
+ return Object.fromEntries(
48
+ Object.entries(store).filter(([_, v]) => v.typeName !== 'pointer')
49
+ )
50
+ },
51
+ },
52
+ [Versions.RemoveUserDocument]: {
53
+ up: (store: SerializedStore<TLRecord>) => {
54
+ return Object.fromEntries(
55
+ Object.entries(store).filter(([_, v]) => !v.typeName.match('user_document'))
56
+ )
57
+ },
58
+ down: (store: SerializedStore<TLRecord>) => {
59
+ return store
60
+ },
61
+ },
62
+ },
63
+ })