@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.
- package/LICENSE +190 -0
- package/dist-cjs/TLStore.js +133 -0
- package/dist-cjs/TLStore.js.map +7 -0
- package/dist-cjs/assets/TLBaseAsset.js +37 -0
- package/dist-cjs/assets/TLBaseAsset.js.map +7 -0
- package/dist-cjs/assets/TLBookmarkAsset.js +38 -0
- package/dist-cjs/assets/TLBookmarkAsset.js.map +7 -0
- package/dist-cjs/assets/TLImageAsset.js +76 -0
- package/dist-cjs/assets/TLImageAsset.js.map +7 -0
- package/dist-cjs/assets/TLVideoAsset.js +76 -0
- package/dist-cjs/assets/TLVideoAsset.js.map +7 -0
- package/dist-cjs/createPresenceStateDerivation.js +68 -0
- package/dist-cjs/createPresenceStateDerivation.js.map +7 -0
- package/dist-cjs/createTLSchema.js +68 -0
- package/dist-cjs/createTLSchema.js.map +7 -0
- package/dist-cjs/index.d.ts +1414 -0
- package/dist-cjs/index.js +142 -0
- package/dist-cjs/index.js.map +7 -0
- package/dist-cjs/misc/TLColor.js +36 -0
- package/dist-cjs/misc/TLColor.js.map +7 -0
- package/dist-cjs/misc/TLCursor.js +55 -0
- package/dist-cjs/misc/TLCursor.js.map +7 -0
- package/dist-cjs/misc/TLHandle.js +36 -0
- package/dist-cjs/misc/TLHandle.js.map +7 -0
- package/dist-cjs/misc/TLOpacity.js +30 -0
- package/dist-cjs/misc/TLOpacity.js.map +7 -0
- package/dist-cjs/misc/TLScribble.js +40 -0
- package/dist-cjs/misc/TLScribble.js.map +7 -0
- package/dist-cjs/misc/geometry-types.js +37 -0
- package/dist-cjs/misc/geometry-types.js.map +7 -0
- package/dist-cjs/misc/id-validator.js +33 -0
- package/dist-cjs/misc/id-validator.js.map +7 -0
- package/dist-cjs/records/TLAsset.js +74 -0
- package/dist-cjs/records/TLAsset.js.map +7 -0
- package/dist-cjs/records/TLCamera.js +74 -0
- package/dist-cjs/records/TLCamera.js.map +7 -0
- package/dist-cjs/records/TLDocument.js +82 -0
- package/dist-cjs/records/TLDocument.js.map +7 -0
- package/dist-cjs/records/TLInstance.js +452 -0
- package/dist-cjs/records/TLInstance.js.map +7 -0
- package/dist-cjs/records/TLPage.js +74 -0
- package/dist-cjs/records/TLPage.js.map +7 -0
- package/dist-cjs/records/TLPageState.js +209 -0
- package/dist-cjs/records/TLPageState.js.map +7 -0
- package/dist-cjs/records/TLPointer.js +76 -0
- package/dist-cjs/records/TLPointer.js.map +7 -0
- package/dist-cjs/records/TLPresence.js +170 -0
- package/dist-cjs/records/TLPresence.js.map +7 -0
- package/dist-cjs/records/TLRecord.js +17 -0
- package/dist-cjs/records/TLRecord.js.map +7 -0
- package/dist-cjs/records/TLShape.js +147 -0
- package/dist-cjs/records/TLShape.js.map +7 -0
- package/dist-cjs/shapes/TLArrowShape.js +156 -0
- package/dist-cjs/shapes/TLArrowShape.js.map +7 -0
- package/dist-cjs/shapes/TLBaseShape.js +52 -0
- package/dist-cjs/shapes/TLBaseShape.js.map +7 -0
- package/dist-cjs/shapes/TLBookmarkShape.js +57 -0
- package/dist-cjs/shapes/TLBookmarkShape.js.map +7 -0
- package/dist-cjs/shapes/TLDrawShape.js +89 -0
- package/dist-cjs/shapes/TLDrawShape.js.map +7 -0
- package/dist-cjs/shapes/TLEmbedShape.js +709 -0
- package/dist-cjs/shapes/TLEmbedShape.js.map +7 -0
- package/dist-cjs/shapes/TLFrameShape.js +33 -0
- package/dist-cjs/shapes/TLFrameShape.js.map +7 -0
- package/dist-cjs/shapes/TLGeoShape.js +230 -0
- package/dist-cjs/shapes/TLGeoShape.js.map +7 -0
- package/dist-cjs/shapes/TLGroupShape.js +28 -0
- package/dist-cjs/shapes/TLGroupShape.js.map +7 -0
- package/dist-cjs/shapes/TLHighlightShape.js +38 -0
- package/dist-cjs/shapes/TLHighlightShape.js.map +7 -0
- package/dist-cjs/shapes/TLImageShape.js +69 -0
- package/dist-cjs/shapes/TLImageShape.js.map +7 -0
- package/dist-cjs/shapes/TLLineShape.js +70 -0
- package/dist-cjs/shapes/TLLineShape.js.map +7 -0
- package/dist-cjs/shapes/TLNoteShape.js +144 -0
- package/dist-cjs/shapes/TLNoteShape.js.map +7 -0
- package/dist-cjs/shapes/TLTextShape.js +67 -0
- package/dist-cjs/shapes/TLTextShape.js.map +7 -0
- package/dist-cjs/shapes/TLVideoShape.js +53 -0
- package/dist-cjs/shapes/TLVideoShape.js.map +7 -0
- package/dist-cjs/store-migrations.js +81 -0
- package/dist-cjs/store-migrations.js.map +7 -0
- package/dist-cjs/styles/StyleProp.js +94 -0
- package/dist-cjs/styles/StyleProp.js.map +7 -0
- package/dist-cjs/styles/TLColorStyle.js +283 -0
- package/dist-cjs/styles/TLColorStyle.js.map +7 -0
- package/dist-cjs/styles/TLDashStyle.js +29 -0
- package/dist-cjs/styles/TLDashStyle.js.map +7 -0
- package/dist-cjs/styles/TLFillStyle.js +29 -0
- package/dist-cjs/styles/TLFillStyle.js.map +7 -0
- package/dist-cjs/styles/TLFontStyle.js +36 -0
- package/dist-cjs/styles/TLFontStyle.js.map +7 -0
- package/dist-cjs/styles/TLHorizontalAlignStyle.js +29 -0
- package/dist-cjs/styles/TLHorizontalAlignStyle.js.map +7 -0
- package/dist-cjs/styles/TLSizeStyle.js +29 -0
- package/dist-cjs/styles/TLSizeStyle.js.map +7 -0
- package/dist-cjs/styles/TLVerticalAlignStyle.js +29 -0
- package/dist-cjs/styles/TLVerticalAlignStyle.js.map +7 -0
- package/dist-cjs/translations/languages.js +59 -0
- package/dist-cjs/translations/languages.js.map +7 -0
- package/dist-cjs/translations/translations.js +63 -0
- package/dist-cjs/translations/translations.js.map +7 -0
- package/dist-cjs/util-types.js +17 -0
- package/dist-cjs/util-types.js.map +7 -0
- package/dist-esm/TLStore.mjs +113 -0
- package/dist-esm/TLStore.mjs.map +7 -0
- package/dist-esm/assets/TLBaseAsset.mjs +17 -0
- package/dist-esm/assets/TLBaseAsset.mjs.map +7 -0
- package/dist-esm/assets/TLBookmarkAsset.mjs +18 -0
- package/dist-esm/assets/TLBookmarkAsset.mjs.map +7 -0
- package/dist-esm/assets/TLImageAsset.mjs +56 -0
- package/dist-esm/assets/TLImageAsset.mjs.map +7 -0
- package/dist-esm/assets/TLVideoAsset.mjs +56 -0
- package/dist-esm/assets/TLVideoAsset.mjs.map +7 -0
- package/dist-esm/createPresenceStateDerivation.mjs +48 -0
- package/dist-esm/createPresenceStateDerivation.mjs.map +7 -0
- package/dist-esm/createTLSchema.mjs +48 -0
- package/dist-esm/createTLSchema.mjs.map +7 -0
- package/dist-esm/index.d.mts +1414 -0
- package/dist-esm/index.mjs +193 -0
- package/dist-esm/index.mjs.map +7 -0
- package/dist-esm/misc/TLColor.mjs +16 -0
- package/dist-esm/misc/TLColor.mjs.map +7 -0
- package/dist-esm/misc/TLCursor.mjs +35 -0
- package/dist-esm/misc/TLCursor.mjs.map +7 -0
- package/dist-esm/misc/TLHandle.mjs +16 -0
- package/dist-esm/misc/TLHandle.mjs.map +7 -0
- package/dist-esm/misc/TLOpacity.mjs +10 -0
- package/dist-esm/misc/TLOpacity.mjs.map +7 -0
- package/dist-esm/misc/TLScribble.mjs +20 -0
- package/dist-esm/misc/TLScribble.mjs.map +7 -0
- package/dist-esm/misc/geometry-types.mjs +17 -0
- package/dist-esm/misc/geometry-types.mjs.map +7 -0
- package/dist-esm/misc/id-validator.mjs +13 -0
- package/dist-esm/misc/id-validator.mjs.map +7 -0
- package/dist-esm/records/TLAsset.mjs +57 -0
- package/dist-esm/records/TLAsset.mjs.map +7 -0
- package/dist-esm/records/TLCamera.mjs +54 -0
- package/dist-esm/records/TLCamera.mjs.map +7 -0
- package/dist-esm/records/TLDocument.mjs +62 -0
- package/dist-esm/records/TLDocument.mjs.map +7 -0
- package/dist-esm/records/TLInstance.mjs +432 -0
- package/dist-esm/records/TLInstance.mjs.map +7 -0
- package/dist-esm/records/TLPage.mjs +54 -0
- package/dist-esm/records/TLPage.mjs.map +7 -0
- package/dist-esm/records/TLPageState.mjs +189 -0
- package/dist-esm/records/TLPageState.mjs.map +7 -0
- package/dist-esm/records/TLPointer.mjs +56 -0
- package/dist-esm/records/TLPointer.mjs.map +7 -0
- package/dist-esm/records/TLPresence.mjs +150 -0
- package/dist-esm/records/TLPresence.mjs.map +7 -0
- package/dist-esm/records/TLRecord.mjs +1 -0
- package/dist-esm/records/TLRecord.mjs.map +7 -0
- package/dist-esm/records/TLShape.mjs +127 -0
- package/dist-esm/records/TLShape.mjs.map +7 -0
- package/dist-esm/shapes/TLArrowShape.mjs +136 -0
- package/dist-esm/shapes/TLArrowShape.mjs.map +7 -0
- package/dist-esm/shapes/TLBaseShape.mjs +32 -0
- package/dist-esm/shapes/TLBaseShape.mjs.map +7 -0
- package/dist-esm/shapes/TLBookmarkShape.mjs +37 -0
- package/dist-esm/shapes/TLBookmarkShape.mjs.map +7 -0
- package/dist-esm/shapes/TLDrawShape.mjs +69 -0
- package/dist-esm/shapes/TLDrawShape.mjs.map +7 -0
- package/dist-esm/shapes/TLEmbedShape.mjs +689 -0
- package/dist-esm/shapes/TLEmbedShape.mjs.map +7 -0
- package/dist-esm/shapes/TLFrameShape.mjs +13 -0
- package/dist-esm/shapes/TLFrameShape.mjs.map +7 -0
- package/dist-esm/shapes/TLGeoShape.mjs +212 -0
- package/dist-esm/shapes/TLGeoShape.mjs.map +7 -0
- package/dist-esm/shapes/TLGroupShape.mjs +8 -0
- package/dist-esm/shapes/TLGroupShape.mjs.map +7 -0
- package/dist-esm/shapes/TLHighlightShape.mjs +18 -0
- package/dist-esm/shapes/TLHighlightShape.mjs.map +7 -0
- package/dist-esm/shapes/TLImageShape.mjs +49 -0
- package/dist-esm/shapes/TLImageShape.mjs.map +7 -0
- package/dist-esm/shapes/TLLineShape.mjs +50 -0
- package/dist-esm/shapes/TLLineShape.mjs.map +7 -0
- package/dist-esm/shapes/TLNoteShape.mjs +126 -0
- package/dist-esm/shapes/TLNoteShape.mjs.map +7 -0
- package/dist-esm/shapes/TLTextShape.mjs +47 -0
- package/dist-esm/shapes/TLTextShape.mjs.map +7 -0
- package/dist-esm/shapes/TLVideoShape.mjs +33 -0
- package/dist-esm/shapes/TLVideoShape.mjs.map +7 -0
- package/dist-esm/store-migrations.mjs +61 -0
- package/dist-esm/store-migrations.mjs.map +7 -0
- package/dist-esm/styles/StyleProp.mjs +74 -0
- package/dist-esm/styles/StyleProp.mjs.map +7 -0
- package/dist-esm/styles/TLColorStyle.mjs +263 -0
- package/dist-esm/styles/TLColorStyle.mjs.map +7 -0
- package/dist-esm/styles/TLDashStyle.mjs +9 -0
- package/dist-esm/styles/TLDashStyle.mjs.map +7 -0
- package/dist-esm/styles/TLFillStyle.mjs +9 -0
- package/dist-esm/styles/TLFillStyle.mjs.map +7 -0
- package/dist-esm/styles/TLFontStyle.mjs +16 -0
- package/dist-esm/styles/TLFontStyle.mjs.map +7 -0
- package/dist-esm/styles/TLHorizontalAlignStyle.mjs +9 -0
- package/dist-esm/styles/TLHorizontalAlignStyle.mjs.map +7 -0
- package/dist-esm/styles/TLSizeStyle.mjs +9 -0
- package/dist-esm/styles/TLSizeStyle.mjs.map +7 -0
- package/dist-esm/styles/TLVerticalAlignStyle.mjs +9 -0
- package/dist-esm/styles/TLVerticalAlignStyle.mjs.map +7 -0
- package/dist-esm/translations/languages.mjs +39 -0
- package/dist-esm/translations/languages.mjs.map +7 -0
- package/dist-esm/translations/translations.mjs +43 -0
- package/dist-esm/translations/translations.mjs.map +7 -0
- package/dist-esm/util-types.mjs +1 -0
- package/dist-esm/util-types.mjs.map +7 -0
- package/package.json +64 -0
- package/src/TLStore.ts +160 -0
- package/src/assets/TLBaseAsset.ts +44 -0
- package/src/assets/TLBookmarkAsset.ts +31 -0
- package/src/assets/TLImageAsset.ts +73 -0
- package/src/assets/TLVideoAsset.ts +73 -0
- package/src/createPresenceStateDerivation.ts +53 -0
- package/src/createTLSchema.ts +65 -0
- package/src/index.ts +168 -0
- package/src/migrations.test.ts +1768 -0
- package/src/misc/TLColor.ts +28 -0
- package/src/misc/TLCursor.ts +54 -0
- package/src/misc/TLHandle.ts +41 -0
- package/src/misc/TLOpacity.ts +11 -0
- package/src/misc/TLScribble.ts +39 -0
- package/src/misc/geometry-types.ts +37 -0
- package/src/misc/id-validator.ts +14 -0
- package/src/records/TLAsset.ts +80 -0
- package/src/records/TLCamera.ts +74 -0
- package/src/records/TLDocument.ts +77 -0
- package/src/records/TLInstance.ts +493 -0
- package/src/records/TLPage.ts +72 -0
- package/src/records/TLPageState.ts +216 -0
- package/src/records/TLPointer.ts +74 -0
- package/src/records/TLPresence.ts +179 -0
- package/src/records/TLRecord.ts +21 -0
- package/src/records/TLShape.ts +214 -0
- package/src/shapes/TLArrowShape.ts +160 -0
- package/src/shapes/TLBaseShape.ts +67 -0
- package/src/shapes/TLBookmarkShape.ts +44 -0
- package/src/shapes/TLDrawShape.ts +89 -0
- package/src/shapes/TLEmbedShape.ts +754 -0
- package/src/shapes/TLFrameShape.ts +18 -0
- package/src/shapes/TLGeoShape.ts +226 -0
- package/src/shapes/TLGroupShape.ts +14 -0
- package/src/shapes/TLHighlightShape.ts +24 -0
- package/src/shapes/TLImageShape.ts +59 -0
- package/src/shapes/TLLineShape.ts +61 -0
- package/src/shapes/TLNoteShape.ts +137 -0
- package/src/shapes/TLTextShape.ts +55 -0
- package/src/shapes/TLVideoShape.ts +40 -0
- package/src/store-migrations.ts +63 -0
- package/src/styles/StyleProp.ts +105 -0
- package/src/styles/TLColorStyle.ts +296 -0
- package/src/styles/TLDashStyle.ts +11 -0
- package/src/styles/TLFillStyle.ts +11 -0
- package/src/styles/TLFontStyle.ts +19 -0
- package/src/styles/TLHorizontalAlignStyle.ts +11 -0
- package/src/styles/TLSizeStyle.ts +11 -0
- package/src/styles/TLVerticalAlignStyle.ts +11 -0
- package/src/translations/languages.ts +39 -0
- package/src/translations/translations.test.ts +43 -0
- package/src/translations/translations.ts +73 -0
- package/src/util-types.ts +2 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { defineMigrations } from '@bigbluebutton/store'
|
|
2
|
+
import { T } from '@bigbluebutton/validate'
|
|
3
|
+
import { vec2dModelValidator } from '../misc/geometry-types'
|
|
4
|
+
import { StyleProp } from '../styles/StyleProp'
|
|
5
|
+
import { DefaultColorStyle, DefaultLabelColorStyle } from '../styles/TLColorStyle'
|
|
6
|
+
import { DefaultDashStyle } from '../styles/TLDashStyle'
|
|
7
|
+
import { DefaultFillStyle } from '../styles/TLFillStyle'
|
|
8
|
+
import { DefaultFontStyle } from '../styles/TLFontStyle'
|
|
9
|
+
import { DefaultSizeStyle } from '../styles/TLSizeStyle'
|
|
10
|
+
import { ShapePropsType, TLBaseShape, shapeIdValidator } from './TLBaseShape'
|
|
11
|
+
|
|
12
|
+
const arrowheadTypes = [
|
|
13
|
+
'arrow',
|
|
14
|
+
'triangle',
|
|
15
|
+
'square',
|
|
16
|
+
'dot',
|
|
17
|
+
'pipe',
|
|
18
|
+
'diamond',
|
|
19
|
+
'inverted',
|
|
20
|
+
'bar',
|
|
21
|
+
'none',
|
|
22
|
+
] as const
|
|
23
|
+
|
|
24
|
+
/** @public */
|
|
25
|
+
export const ArrowShapeArrowheadStartStyle = StyleProp.defineEnum('tldraw:arrowheadStart', {
|
|
26
|
+
defaultValue: 'none',
|
|
27
|
+
values: arrowheadTypes,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
/** @public */
|
|
31
|
+
export const ArrowShapeArrowheadEndStyle = StyleProp.defineEnum('tldraw:arrowheadEnd', {
|
|
32
|
+
defaultValue: 'arrow',
|
|
33
|
+
values: arrowheadTypes,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
/** @public */
|
|
37
|
+
export type TLArrowShapeArrowheadStyle = T.TypeOf<typeof ArrowShapeArrowheadStartStyle>
|
|
38
|
+
|
|
39
|
+
/** @public */
|
|
40
|
+
const ArrowShapeTerminal = T.union('type', {
|
|
41
|
+
binding: T.object({
|
|
42
|
+
type: T.literal('binding'),
|
|
43
|
+
boundShapeId: shapeIdValidator,
|
|
44
|
+
normalizedAnchor: vec2dModelValidator,
|
|
45
|
+
isExact: T.boolean,
|
|
46
|
+
isPrecise: T.boolean,
|
|
47
|
+
}),
|
|
48
|
+
point: T.object({
|
|
49
|
+
type: T.literal('point'),
|
|
50
|
+
x: T.number,
|
|
51
|
+
y: T.number,
|
|
52
|
+
}),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
/** @public */
|
|
56
|
+
export type TLArrowShapeTerminal = T.TypeOf<typeof ArrowShapeTerminal>
|
|
57
|
+
|
|
58
|
+
/** @public */
|
|
59
|
+
export const arrowShapeProps = {
|
|
60
|
+
labelColor: DefaultLabelColorStyle,
|
|
61
|
+
color: DefaultColorStyle,
|
|
62
|
+
fill: DefaultFillStyle,
|
|
63
|
+
dash: DefaultDashStyle,
|
|
64
|
+
size: DefaultSizeStyle,
|
|
65
|
+
arrowheadStart: ArrowShapeArrowheadStartStyle,
|
|
66
|
+
arrowheadEnd: ArrowShapeArrowheadEndStyle,
|
|
67
|
+
font: DefaultFontStyle,
|
|
68
|
+
start: ArrowShapeTerminal,
|
|
69
|
+
end: ArrowShapeTerminal,
|
|
70
|
+
bend: T.number,
|
|
71
|
+
text: T.string,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** @public */
|
|
75
|
+
export type TLArrowShapeProps = ShapePropsType<typeof arrowShapeProps>
|
|
76
|
+
|
|
77
|
+
/** @public */
|
|
78
|
+
export type TLArrowShape = TLBaseShape<'arrow', TLArrowShapeProps>
|
|
79
|
+
|
|
80
|
+
export const ArrowMigrationVersions = {
|
|
81
|
+
AddLabelColor: 1,
|
|
82
|
+
AddIsPrecise: 2,
|
|
83
|
+
} as const
|
|
84
|
+
|
|
85
|
+
/** @internal */
|
|
86
|
+
export const arrowShapeMigrations = defineMigrations({
|
|
87
|
+
currentVersion: ArrowMigrationVersions.AddIsPrecise,
|
|
88
|
+
migrators: {
|
|
89
|
+
[ArrowMigrationVersions.AddLabelColor]: {
|
|
90
|
+
up: (record) => {
|
|
91
|
+
return {
|
|
92
|
+
...record,
|
|
93
|
+
props: {
|
|
94
|
+
...record.props,
|
|
95
|
+
labelColor: 'black',
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
down: (record) => {
|
|
100
|
+
const { labelColor: _, ...props } = record.props
|
|
101
|
+
return {
|
|
102
|
+
...record,
|
|
103
|
+
props,
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
[ArrowMigrationVersions.AddIsPrecise]: {
|
|
108
|
+
up: (record) => {
|
|
109
|
+
const { start, end } = record.props
|
|
110
|
+
return {
|
|
111
|
+
...record,
|
|
112
|
+
props: {
|
|
113
|
+
...record.props,
|
|
114
|
+
start:
|
|
115
|
+
(start as TLArrowShapeTerminal).type === 'binding'
|
|
116
|
+
? {
|
|
117
|
+
...start,
|
|
118
|
+
isPrecise: !(
|
|
119
|
+
start.normalizedAnchor.x === 0.5 && start.normalizedAnchor.y === 0.5
|
|
120
|
+
),
|
|
121
|
+
}
|
|
122
|
+
: start,
|
|
123
|
+
end:
|
|
124
|
+
(end as TLArrowShapeTerminal).type === 'binding'
|
|
125
|
+
? {
|
|
126
|
+
...end,
|
|
127
|
+
isPrecise: !(end.normalizedAnchor.x === 0.5 && end.normalizedAnchor.y === 0.5),
|
|
128
|
+
}
|
|
129
|
+
: end,
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
down: (record: any) => {
|
|
134
|
+
const { start, end } = record.props
|
|
135
|
+
const nStart = { ...start }
|
|
136
|
+
const nEnd = { ...end }
|
|
137
|
+
if (nStart.type === 'binding') {
|
|
138
|
+
if (!nStart.isPrecise) {
|
|
139
|
+
nStart.normalizedAnchor = { x: 0.5, y: 0.5 }
|
|
140
|
+
}
|
|
141
|
+
delete nStart.isPrecise
|
|
142
|
+
}
|
|
143
|
+
if (nEnd.type === 'binding') {
|
|
144
|
+
if (!nEnd.isPrecise) {
|
|
145
|
+
nEnd.normalizedAnchor = { x: 0.5, y: 0.5 }
|
|
146
|
+
}
|
|
147
|
+
delete nEnd.isPrecise
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
...record,
|
|
151
|
+
props: {
|
|
152
|
+
...record.props,
|
|
153
|
+
start: nStart,
|
|
154
|
+
end: nEnd,
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { BaseRecord } from '@bigbluebutton/store'
|
|
2
|
+
import { Expand, JsonObject } from '@bigbluebutton/utils'
|
|
3
|
+
import { T } from '@bigbluebutton/validate'
|
|
4
|
+
import { TLOpacityType, opacityValidator } from '../misc/TLOpacity'
|
|
5
|
+
import { idValidator } from '../misc/id-validator'
|
|
6
|
+
import { TLParentId, TLShapeId } from '../records/TLShape'
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
export interface TLBaseShape<Type extends string, Props extends object>
|
|
10
|
+
extends BaseRecord<'shape', TLShapeId> {
|
|
11
|
+
type: Type
|
|
12
|
+
x: number
|
|
13
|
+
y: number
|
|
14
|
+
rotation: number
|
|
15
|
+
index: string
|
|
16
|
+
parentId: TLParentId
|
|
17
|
+
isLocked: boolean
|
|
18
|
+
opacity: TLOpacityType
|
|
19
|
+
props: Props
|
|
20
|
+
meta: JsonObject
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** @public */
|
|
24
|
+
export const parentIdValidator = T.string.refine((id) => {
|
|
25
|
+
if (!id.startsWith('page:') && !id.startsWith('shape:')) {
|
|
26
|
+
throw new Error('Parent ID must start with "page:" or "shape:"')
|
|
27
|
+
}
|
|
28
|
+
return id as TLParentId
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
/** @public */
|
|
32
|
+
export const shapeIdValidator = idValidator<TLShapeId>('shape')
|
|
33
|
+
|
|
34
|
+
/** @public */
|
|
35
|
+
export function createShapeValidator<
|
|
36
|
+
Type extends string,
|
|
37
|
+
Props extends JsonObject,
|
|
38
|
+
Meta extends JsonObject
|
|
39
|
+
>(
|
|
40
|
+
type: Type,
|
|
41
|
+
props?: { [K in keyof Props]: T.Validatable<Props[K]> },
|
|
42
|
+
meta?: { [K in keyof Meta]: T.Validatable<Meta[K]> }
|
|
43
|
+
) {
|
|
44
|
+
return T.object<TLBaseShape<Type, Props>>({
|
|
45
|
+
id: shapeIdValidator,
|
|
46
|
+
typeName: T.literal('shape'),
|
|
47
|
+
x: T.number,
|
|
48
|
+
y: T.number,
|
|
49
|
+
rotation: T.number,
|
|
50
|
+
index: T.string,
|
|
51
|
+
parentId: parentIdValidator,
|
|
52
|
+
type: T.literal(type),
|
|
53
|
+
isLocked: T.boolean,
|
|
54
|
+
opacity: opacityValidator,
|
|
55
|
+
props: props ? T.object(props) : (T.jsonValue as T.ObjectValidator<Props>),
|
|
56
|
+
meta: meta ? T.object(meta) : (T.jsonValue as T.ObjectValidator<Meta>),
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @public */
|
|
61
|
+
export type ShapeProps<Shape extends TLBaseShape<any, any>> = {
|
|
62
|
+
[K in keyof Shape['props']]: T.Validatable<Shape['props'][K]>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type ShapePropsType<Config extends Record<string, T.Validatable<any>>> = Expand<{
|
|
66
|
+
[K in keyof Config]: T.TypeOf<Config[K]>
|
|
67
|
+
}>
|
|
@@ -0,0 +1,44 @@
|
|
|
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 bookmarkShapeProps = {
|
|
8
|
+
w: T.nonZeroNumber,
|
|
9
|
+
h: T.nonZeroNumber,
|
|
10
|
+
assetId: assetIdValidator.nullable(),
|
|
11
|
+
url: T.string,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** @public */
|
|
15
|
+
export type TLBookmarkShapeProps = ShapePropsType<typeof bookmarkShapeProps>
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
18
|
+
export type TLBookmarkShape = TLBaseShape<'bookmark', TLBookmarkShapeProps>
|
|
19
|
+
|
|
20
|
+
const Versions = {
|
|
21
|
+
NullAssetId: 1,
|
|
22
|
+
} as const
|
|
23
|
+
|
|
24
|
+
/** @internal */
|
|
25
|
+
export const bookmarkShapeMigrations = defineMigrations({
|
|
26
|
+
currentVersion: Versions.NullAssetId,
|
|
27
|
+
migrators: {
|
|
28
|
+
[Versions.NullAssetId]: {
|
|
29
|
+
up: (shape: TLBookmarkShape) => {
|
|
30
|
+
if (shape.props.assetId === undefined) {
|
|
31
|
+
return { ...shape, props: { ...shape.props, assetId: null } } as typeof shape
|
|
32
|
+
}
|
|
33
|
+
return shape
|
|
34
|
+
},
|
|
35
|
+
down: (shape: TLBookmarkShape) => {
|
|
36
|
+
if (shape.props.assetId === null) {
|
|
37
|
+
const { assetId: _, ...props } = shape.props
|
|
38
|
+
return { ...shape, props } as typeof shape
|
|
39
|
+
}
|
|
40
|
+
return shape
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
})
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { defineMigrations } from '@bigbluebutton/store'
|
|
2
|
+
import { T } from '@bigbluebutton/validate'
|
|
3
|
+
import { vec2dModelValidator } from '../misc/geometry-types'
|
|
4
|
+
import { DefaultColorStyle } from '../styles/TLColorStyle'
|
|
5
|
+
import { DefaultDashStyle } from '../styles/TLDashStyle'
|
|
6
|
+
import { DefaultFillStyle } from '../styles/TLFillStyle'
|
|
7
|
+
import { DefaultSizeStyle } from '../styles/TLSizeStyle'
|
|
8
|
+
import { ShapePropsType, TLBaseShape } from './TLBaseShape'
|
|
9
|
+
|
|
10
|
+
export const DrawShapeSegment = T.object({
|
|
11
|
+
type: T.literalEnum('free', 'straight'),
|
|
12
|
+
points: T.arrayOf(vec2dModelValidator),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
/** @public */
|
|
16
|
+
export type TLDrawShapeSegment = T.TypeOf<typeof DrawShapeSegment>
|
|
17
|
+
|
|
18
|
+
/** @public */
|
|
19
|
+
export const drawShapeProps = {
|
|
20
|
+
color: DefaultColorStyle,
|
|
21
|
+
fill: DefaultFillStyle,
|
|
22
|
+
dash: DefaultDashStyle,
|
|
23
|
+
size: DefaultSizeStyle,
|
|
24
|
+
segments: T.arrayOf(DrawShapeSegment),
|
|
25
|
+
isComplete: T.boolean,
|
|
26
|
+
isClosed: T.boolean,
|
|
27
|
+
isPen: T.boolean,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** @public */
|
|
31
|
+
export type TLDrawShapeProps = ShapePropsType<typeof drawShapeProps>
|
|
32
|
+
|
|
33
|
+
/** @public */
|
|
34
|
+
export type TLDrawShape = TLBaseShape<'draw', TLDrawShapeProps>
|
|
35
|
+
|
|
36
|
+
const Versions = {
|
|
37
|
+
AddInPen: 1,
|
|
38
|
+
} as const
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
export const drawShapeMigrations = defineMigrations({
|
|
42
|
+
currentVersion: Versions.AddInPen,
|
|
43
|
+
migrators: {
|
|
44
|
+
[Versions.AddInPen]: {
|
|
45
|
+
up: (shape) => {
|
|
46
|
+
// Rather than checking to see whether the shape is a pen at runtime,
|
|
47
|
+
// from now on we're going to use the type of device reported to us
|
|
48
|
+
// as well as the pressure data received; but for existing shapes we
|
|
49
|
+
// need to check the pressure data to see if it's a pen or not.
|
|
50
|
+
|
|
51
|
+
const { points } = shape.props.segments[0]
|
|
52
|
+
|
|
53
|
+
if (points.length === 0) {
|
|
54
|
+
return {
|
|
55
|
+
...shape,
|
|
56
|
+
props: {
|
|
57
|
+
...shape.props,
|
|
58
|
+
isPen: false,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let isPen = !(points[0].z === 0 || points[0].z === 0.5)
|
|
64
|
+
|
|
65
|
+
if (points[1]) {
|
|
66
|
+
// Double check if we have a second point (we probably should)
|
|
67
|
+
isPen = isPen && !(points[1].z === 0 || points[1].z === 0.5)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
...shape,
|
|
72
|
+
props: {
|
|
73
|
+
...shape.props,
|
|
74
|
+
isPen,
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
down: (shape) => {
|
|
79
|
+
const { isPen: _isPen, ...propsWithOutIsPen } = shape.props
|
|
80
|
+
return {
|
|
81
|
+
...shape,
|
|
82
|
+
props: {
|
|
83
|
+
...propsWithOutIsPen,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
})
|