@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,189 @@
|
|
|
1
|
+
import { createRecordType, defineMigrations } from "@bigbluebutton/store";
|
|
2
|
+
import { T } from "@bigbluebutton/validate";
|
|
3
|
+
import { idValidator } from "../misc/id-validator.mjs";
|
|
4
|
+
import { shapeIdValidator } from "../shapes/TLBaseShape.mjs";
|
|
5
|
+
import { CameraRecordType } from "./TLCamera.mjs";
|
|
6
|
+
import { TLINSTANCE_ID } from "./TLInstance.mjs";
|
|
7
|
+
import { pageIdValidator } from "./TLPage.mjs";
|
|
8
|
+
const instancePageStateValidator = T.model(
|
|
9
|
+
"instance_page_state",
|
|
10
|
+
T.object({
|
|
11
|
+
typeName: T.literal("instance_page_state"),
|
|
12
|
+
id: idValidator("instance_page_state"),
|
|
13
|
+
pageId: pageIdValidator,
|
|
14
|
+
selectedShapeIds: T.arrayOf(shapeIdValidator),
|
|
15
|
+
hintingShapeIds: T.arrayOf(shapeIdValidator),
|
|
16
|
+
erasingShapeIds: T.arrayOf(shapeIdValidator),
|
|
17
|
+
hoveredShapeId: shapeIdValidator.nullable(),
|
|
18
|
+
editingShapeId: shapeIdValidator.nullable(),
|
|
19
|
+
croppingShapeId: shapeIdValidator.nullable(),
|
|
20
|
+
focusedGroupId: shapeIdValidator.nullable(),
|
|
21
|
+
meta: T.jsonValue
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
const instancePageStateVersions = {
|
|
25
|
+
AddCroppingId: 1,
|
|
26
|
+
RemoveInstanceIdAndCameraId: 2,
|
|
27
|
+
AddMeta: 3,
|
|
28
|
+
RenameProperties: 4,
|
|
29
|
+
RenamePropertiesAgain: 5
|
|
30
|
+
};
|
|
31
|
+
const instancePageStateMigrations = defineMigrations({
|
|
32
|
+
currentVersion: instancePageStateVersions.RenamePropertiesAgain,
|
|
33
|
+
migrators: {
|
|
34
|
+
[instancePageStateVersions.AddCroppingId]: {
|
|
35
|
+
up(instance) {
|
|
36
|
+
return { ...instance, croppingShapeId: null };
|
|
37
|
+
},
|
|
38
|
+
down({ croppingShapeId: _croppingShapeId, ...instance }) {
|
|
39
|
+
return instance;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
[instancePageStateVersions.RemoveInstanceIdAndCameraId]: {
|
|
43
|
+
up({ instanceId: _, cameraId: __, ...instance }) {
|
|
44
|
+
return instance;
|
|
45
|
+
},
|
|
46
|
+
down(instance) {
|
|
47
|
+
return {
|
|
48
|
+
...instance,
|
|
49
|
+
instanceId: TLINSTANCE_ID,
|
|
50
|
+
cameraId: CameraRecordType.createId("void")
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[instancePageStateVersions.AddMeta]: {
|
|
55
|
+
up: (record) => {
|
|
56
|
+
return {
|
|
57
|
+
...record,
|
|
58
|
+
meta: {}
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
down: ({ meta: _, ...record }) => {
|
|
62
|
+
return {
|
|
63
|
+
...record
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[instancePageStateVersions.RenameProperties]: {
|
|
68
|
+
// this migration is cursed: it was written wrong and doesn't do anything.
|
|
69
|
+
// rather than replace it, I've added another migration below that fixes it.
|
|
70
|
+
up: (record) => {
|
|
71
|
+
const {
|
|
72
|
+
selectedShapeIds,
|
|
73
|
+
hintingShapeIds,
|
|
74
|
+
erasingShapeIds,
|
|
75
|
+
hoveredShapeId,
|
|
76
|
+
editingShapeId,
|
|
77
|
+
croppingShapeId,
|
|
78
|
+
focusedGroupId,
|
|
79
|
+
...rest
|
|
80
|
+
} = record;
|
|
81
|
+
return {
|
|
82
|
+
selectedShapeIds,
|
|
83
|
+
hintingShapeIds,
|
|
84
|
+
erasingShapeIds,
|
|
85
|
+
hoveredShapeId,
|
|
86
|
+
editingShapeId,
|
|
87
|
+
croppingShapeId,
|
|
88
|
+
focusedGroupId,
|
|
89
|
+
...rest
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
down: (record) => {
|
|
93
|
+
const {
|
|
94
|
+
selectedShapeIds,
|
|
95
|
+
hintingShapeIds,
|
|
96
|
+
erasingShapeIds,
|
|
97
|
+
hoveredShapeId,
|
|
98
|
+
editingShapeId,
|
|
99
|
+
croppingShapeId,
|
|
100
|
+
focusedGroupId,
|
|
101
|
+
...rest
|
|
102
|
+
} = record;
|
|
103
|
+
return {
|
|
104
|
+
selectedShapeIds,
|
|
105
|
+
hintingShapeIds,
|
|
106
|
+
erasingShapeIds,
|
|
107
|
+
hoveredShapeId,
|
|
108
|
+
editingShapeId,
|
|
109
|
+
croppingShapeId,
|
|
110
|
+
focusedGroupId,
|
|
111
|
+
...rest
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
[instancePageStateVersions.RenamePropertiesAgain]: {
|
|
116
|
+
up: (record) => {
|
|
117
|
+
const {
|
|
118
|
+
selectedIds,
|
|
119
|
+
hintingIds,
|
|
120
|
+
erasingIds,
|
|
121
|
+
hoveredId,
|
|
122
|
+
editingId,
|
|
123
|
+
croppingShapeId,
|
|
124
|
+
croppingId,
|
|
125
|
+
focusLayerId,
|
|
126
|
+
...rest
|
|
127
|
+
} = record;
|
|
128
|
+
return {
|
|
129
|
+
...rest,
|
|
130
|
+
selectedShapeIds: selectedIds,
|
|
131
|
+
hintingShapeIds: hintingIds,
|
|
132
|
+
erasingShapeIds: erasingIds,
|
|
133
|
+
hoveredShapeId: hoveredId,
|
|
134
|
+
editingShapeId: editingId,
|
|
135
|
+
croppingShapeId: croppingShapeId ?? croppingId ?? null,
|
|
136
|
+
focusedGroupId: focusLayerId
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
down: (record) => {
|
|
140
|
+
const {
|
|
141
|
+
selectedShapeIds,
|
|
142
|
+
hintingShapeIds,
|
|
143
|
+
erasingShapeIds,
|
|
144
|
+
hoveredShapeId,
|
|
145
|
+
editingShapeId,
|
|
146
|
+
croppingShapeId,
|
|
147
|
+
focusedGroupId,
|
|
148
|
+
...rest
|
|
149
|
+
} = record;
|
|
150
|
+
return {
|
|
151
|
+
...rest,
|
|
152
|
+
selectedIds: selectedShapeIds,
|
|
153
|
+
hintingIds: hintingShapeIds,
|
|
154
|
+
erasingIds: erasingShapeIds,
|
|
155
|
+
hoveredId: hoveredShapeId,
|
|
156
|
+
editingId: editingShapeId,
|
|
157
|
+
croppingId: croppingShapeId,
|
|
158
|
+
focusLayerId: focusedGroupId
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
const InstancePageStateRecordType = createRecordType(
|
|
165
|
+
"instance_page_state",
|
|
166
|
+
{
|
|
167
|
+
migrations: instancePageStateMigrations,
|
|
168
|
+
validator: instancePageStateValidator,
|
|
169
|
+
scope: "session"
|
|
170
|
+
}
|
|
171
|
+
).withDefaultProperties(
|
|
172
|
+
() => ({
|
|
173
|
+
editingShapeId: null,
|
|
174
|
+
croppingShapeId: null,
|
|
175
|
+
selectedShapeIds: [],
|
|
176
|
+
hoveredShapeId: null,
|
|
177
|
+
erasingShapeIds: [],
|
|
178
|
+
hintingShapeIds: [],
|
|
179
|
+
focusedGroupId: null,
|
|
180
|
+
meta: {}
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
export {
|
|
184
|
+
InstancePageStateRecordType,
|
|
185
|
+
instancePageStateMigrations,
|
|
186
|
+
instancePageStateValidator,
|
|
187
|
+
instancePageStateVersions
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=TLPageState.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/records/TLPageState.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseRecord, createRecordType, defineMigrations, RecordId } from '@bigbluebutton/store'\nimport { JsonObject } from '@bigbluebutton/utils'\nimport { T } from '@bigbluebutton/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { shapeIdValidator } from '../shapes/TLBaseShape'\nimport { CameraRecordType } from './TLCamera'\nimport { TLINSTANCE_ID } from './TLInstance'\nimport { pageIdValidator, TLPage } from './TLPage'\nimport { TLShapeId } from './TLShape'\n\n/**\n * TLInstancePageState\n *\n * State that is unique to a particular page of the document in a particular browser tab\n *\n * @public\n */\nexport interface TLInstancePageState\n\textends BaseRecord<'instance_page_state', TLInstancePageStateId> {\n\tpageId: RecordId<TLPage>\n\tselectedShapeIds: TLShapeId[]\n\thintingShapeIds: TLShapeId[]\n\terasingShapeIds: TLShapeId[]\n\thoveredShapeId: TLShapeId | null\n\teditingShapeId: TLShapeId | null\n\tcroppingShapeId: TLShapeId | null\n\tfocusedGroupId: TLShapeId | null\n\tmeta: JsonObject\n}\n\n/** @internal */\nexport const instancePageStateValidator: T.Validator<TLInstancePageState> = T.model(\n\t'instance_page_state',\n\tT.object({\n\t\ttypeName: T.literal('instance_page_state'),\n\t\tid: idValidator<TLInstancePageStateId>('instance_page_state'),\n\t\tpageId: pageIdValidator,\n\t\tselectedShapeIds: T.arrayOf(shapeIdValidator),\n\t\thintingShapeIds: T.arrayOf(shapeIdValidator),\n\t\terasingShapeIds: T.arrayOf(shapeIdValidator),\n\t\thoveredShapeId: shapeIdValidator.nullable(),\n\t\teditingShapeId: shapeIdValidator.nullable(),\n\t\tcroppingShapeId: shapeIdValidator.nullable(),\n\t\tfocusedGroupId: shapeIdValidator.nullable(),\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/** @internal */\nexport const instancePageStateVersions = {\n\tAddCroppingId: 1,\n\tRemoveInstanceIdAndCameraId: 2,\n\tAddMeta: 3,\n\tRenameProperties: 4,\n\tRenamePropertiesAgain: 5,\n} as const\n\n/** @public */\nexport const instancePageStateMigrations = defineMigrations({\n\tcurrentVersion: instancePageStateVersions.RenamePropertiesAgain,\n\tmigrators: {\n\t\t[instancePageStateVersions.AddCroppingId]: {\n\t\t\tup(instance) {\n\t\t\t\treturn { ...instance, croppingShapeId: null }\n\t\t\t},\n\t\t\tdown({ croppingShapeId: _croppingShapeId, ...instance }) {\n\t\t\t\treturn instance\n\t\t\t},\n\t\t},\n\t\t[instancePageStateVersions.RemoveInstanceIdAndCameraId]: {\n\t\t\tup({ instanceId: _, cameraId: __, ...instance }) {\n\t\t\t\treturn instance\n\t\t\t},\n\t\t\tdown(instance) {\n\t\t\t\t// this should never be called since we bump the schema version\n\t\t\t\treturn {\n\t\t\t\t\t...instance,\n\t\t\t\t\tinstanceId: TLINSTANCE_ID,\n\t\t\t\t\tcameraId: CameraRecordType.createId('void'),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[instancePageStateVersions.AddMeta]: {\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tmeta: {},\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ meta: _, ...record }) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[instancePageStateVersions.RenameProperties]: {\n\t\t\t// this migration is cursed: it was written wrong and doesn't do anything.\n\t\t\t// rather than replace it, I've added another migration below that fixes it.\n\t\t\tup: (record) => {\n\t\t\t\tconst {\n\t\t\t\t\tselectedShapeIds,\n\t\t\t\t\thintingShapeIds,\n\t\t\t\t\terasingShapeIds,\n\t\t\t\t\thoveredShapeId,\n\t\t\t\t\teditingShapeId,\n\t\t\t\t\tcroppingShapeId,\n\t\t\t\t\tfocusedGroupId,\n\t\t\t\t\t...rest\n\t\t\t\t} = record\n\t\t\t\treturn {\n\t\t\t\t\tselectedShapeIds: selectedShapeIds,\n\t\t\t\t\thintingShapeIds: hintingShapeIds,\n\t\t\t\t\terasingShapeIds: erasingShapeIds,\n\t\t\t\t\thoveredShapeId: hoveredShapeId,\n\t\t\t\t\teditingShapeId: editingShapeId,\n\t\t\t\t\tcroppingShapeId: croppingShapeId,\n\t\t\t\t\tfocusedGroupId: focusedGroupId,\n\t\t\t\t\t...rest,\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (record) => {\n\t\t\t\tconst {\n\t\t\t\t\tselectedShapeIds,\n\t\t\t\t\thintingShapeIds,\n\t\t\t\t\terasingShapeIds,\n\t\t\t\t\thoveredShapeId,\n\t\t\t\t\teditingShapeId,\n\t\t\t\t\tcroppingShapeId,\n\t\t\t\t\tfocusedGroupId,\n\t\t\t\t\t...rest\n\t\t\t\t} = record\n\t\t\t\treturn {\n\t\t\t\t\tselectedShapeIds: selectedShapeIds,\n\t\t\t\t\thintingShapeIds: hintingShapeIds,\n\t\t\t\t\terasingShapeIds: erasingShapeIds,\n\t\t\t\t\thoveredShapeId: hoveredShapeId,\n\t\t\t\t\teditingShapeId: editingShapeId,\n\t\t\t\t\tcroppingShapeId: croppingShapeId,\n\t\t\t\t\tfocusedGroupId: focusedGroupId,\n\t\t\t\t\t...rest,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[instancePageStateVersions.RenamePropertiesAgain]: {\n\t\t\tup: (record) => {\n\t\t\t\tconst {\n\t\t\t\t\tselectedIds,\n\t\t\t\t\thintingIds,\n\t\t\t\t\terasingIds,\n\t\t\t\t\thoveredId,\n\t\t\t\t\teditingId,\n\t\t\t\t\tcroppingShapeId,\n\t\t\t\t\tcroppingId,\n\t\t\t\t\tfocusLayerId,\n\t\t\t\t\t...rest\n\t\t\t\t} = record\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\tselectedShapeIds: selectedIds,\n\t\t\t\t\thintingShapeIds: hintingIds,\n\t\t\t\t\terasingShapeIds: erasingIds,\n\t\t\t\t\thoveredShapeId: hoveredId,\n\t\t\t\t\teditingShapeId: editingId,\n\t\t\t\t\tcroppingShapeId: croppingShapeId ?? croppingId ?? null,\n\t\t\t\t\tfocusedGroupId: focusLayerId,\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (record) => {\n\t\t\t\tconst {\n\t\t\t\t\tselectedShapeIds,\n\t\t\t\t\thintingShapeIds,\n\t\t\t\t\terasingShapeIds,\n\t\t\t\t\thoveredShapeId,\n\t\t\t\t\teditingShapeId,\n\t\t\t\t\tcroppingShapeId,\n\t\t\t\t\tfocusedGroupId,\n\t\t\t\t\t...rest\n\t\t\t\t} = record\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\tselectedIds: selectedShapeIds,\n\t\t\t\t\thintingIds: hintingShapeIds,\n\t\t\t\t\terasingIds: erasingShapeIds,\n\t\t\t\t\thoveredId: hoveredShapeId,\n\t\t\t\t\teditingId: editingShapeId,\n\t\t\t\t\tcroppingId: croppingShapeId,\n\t\t\t\t\tfocusLayerId: focusedGroupId,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n})\n\n/** @public */\nexport const InstancePageStateRecordType = createRecordType<TLInstancePageState>(\n\t'instance_page_state',\n\t{\n\t\tmigrations: instancePageStateMigrations,\n\t\tvalidator: instancePageStateValidator,\n\t\tscope: 'session',\n\t}\n).withDefaultProperties(\n\t(): Omit<TLInstancePageState, 'id' | 'typeName' | 'pageId'> => ({\n\t\teditingShapeId: null,\n\t\tcroppingShapeId: null,\n\t\tselectedShapeIds: [],\n\t\thoveredShapeId: null,\n\t\terasingShapeIds: [],\n\t\thintingShapeIds: [],\n\t\tfocusedGroupId: null,\n\t\tmeta: {},\n\t})\n)\n\n/** @public */\nexport type TLInstancePageStateId = RecordId<TLInstancePageState>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAqB,kBAAkB,wBAAkC;AAEzE,SAAS,SAAS;AAClB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,uBAA+B;AAwBjC,MAAM,6BAA+D,EAAE;AAAA,EAC7E;AAAA,EACA,EAAE,OAAO;AAAA,IACR,UAAU,EAAE,QAAQ,qBAAqB;AAAA,IACzC,IAAI,YAAmC,qBAAqB;AAAA,IAC5D,QAAQ;AAAA,IACR,kBAAkB,EAAE,QAAQ,gBA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ACb,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,WAAW;AAAA,UACX,WAAW;AAAA,UACX,YAAY;AAAA,UACZ,cAAc;AAAA,QACf;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD,CAAC;AAGM,MAAM,8BAA8B;AAAA,EAC1C;AAAA,EACA;AAAA,IACC,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO;AAAA,EACR;AACD,EAAE;AAAA,EACD,OAAgE;AAAA,IAC/D,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,kBAAkB,CAAC;AAAA,IACnB,gBAAgB;AAAA,IAChB,iBAAiB,CAAC;AAAA,IAClB,iBAAiB,CAAC;AAAA,IAClB,gBAAgB;AAAA,IAChB,MAAM,CAAC;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createRecordType, defineMigrations } from "@bigbluebutton/store";
|
|
2
|
+
import { T } from "@bigbluebutton/validate";
|
|
3
|
+
import { idValidator } from "../misc/id-validator.mjs";
|
|
4
|
+
const pointerValidator = T.model(
|
|
5
|
+
"pointer",
|
|
6
|
+
T.object({
|
|
7
|
+
typeName: T.literal("pointer"),
|
|
8
|
+
id: idValidator("pointer"),
|
|
9
|
+
x: T.number,
|
|
10
|
+
y: T.number,
|
|
11
|
+
lastActivityTimestamp: T.number,
|
|
12
|
+
meta: T.jsonValue
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
const pointerVersions = {
|
|
16
|
+
AddMeta: 1
|
|
17
|
+
};
|
|
18
|
+
const pointerMigrations = defineMigrations({
|
|
19
|
+
currentVersion: pointerVersions.AddMeta,
|
|
20
|
+
migrators: {
|
|
21
|
+
[pointerVersions.AddMeta]: {
|
|
22
|
+
up: (record) => {
|
|
23
|
+
return {
|
|
24
|
+
...record,
|
|
25
|
+
meta: {}
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
down: ({ meta: _, ...record }) => {
|
|
29
|
+
return {
|
|
30
|
+
...record
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const PointerRecordType = createRecordType("pointer", {
|
|
37
|
+
validator: pointerValidator,
|
|
38
|
+
migrations: pointerMigrations,
|
|
39
|
+
scope: "session"
|
|
40
|
+
}).withDefaultProperties(
|
|
41
|
+
() => ({
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0,
|
|
44
|
+
lastActivityTimestamp: 0,
|
|
45
|
+
meta: {}
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
const TLPOINTER_ID = PointerRecordType.createId("pointer");
|
|
49
|
+
export {
|
|
50
|
+
PointerRecordType,
|
|
51
|
+
TLPOINTER_ID,
|
|
52
|
+
pointerMigrations,
|
|
53
|
+
pointerValidator,
|
|
54
|
+
pointerVersions
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=TLPointer.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/records/TLPointer.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseRecord, createRecordType, defineMigrations, RecordId } from '@bigbluebutton/store'\nimport { JsonObject } from '@bigbluebutton/utils'\nimport { T } from '@bigbluebutton/validate'\nimport { idValidator } from '../misc/id-validator'\n\n/**\n * TLPointer\n *\n * @public\n */\nexport interface TLPointer extends BaseRecord<'pointer', TLPointerId> {\n\tx: number\n\ty: number\n\tlastActivityTimestamp: number\n\tmeta: JsonObject\n}\n\n/** @public */\nexport type TLPointerId = RecordId<TLPointer>\n\n/** @internal */\nexport const pointerValidator: T.Validator<TLPointer> = T.model(\n\t'pointer',\n\tT.object({\n\t\ttypeName: T.literal('pointer'),\n\t\tid: idValidator<TLPointerId>('pointer'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\tlastActivityTimestamp: T.number,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/** @internal */\nexport const pointerVersions = {\n\tAddMeta: 1,\n}\n\n/** @internal */\nexport const pointerMigrations = defineMigrations({\n\tcurrentVersion: pointerVersions.AddMeta,\n\tmigrators: {\n\t\t[pointerVersions.AddMeta]: {\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tmeta: {},\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ meta: _, ...record }) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n})\n\n/** @public */\nexport const PointerRecordType = createRecordType<TLPointer>('pointer', {\n\tvalidator: pointerValidator,\n\tmigrations: pointerMigrations,\n\tscope: 'session',\n}).withDefaultProperties(\n\t(): Omit<TLPointer, 'id' | 'typeName'> => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\tlastActivityTimestamp: 0,\n\t\tmeta: {},\n\t})\n)\n\n/** @public */\nexport const TLPOINTER_ID = PointerRecordType.createId('pointer')\n"],
|
|
5
|
+
"mappings": "AAAA,SAAqB,kBAAkB,wBAAkC;AAEzE,SAAS,SAAS;AAClB,SAAS,mBAAmB;AAkBrB,MAAM,mBAA2C,EAAE;AAAA,EACzD;AAAA,EACA,EAAE,OAAO;AAAA,IACR,UAAU,EAAE,QAAQ,SAAS;AAAA,IAC7B,IAAI,YAAyB,SAAS;AAAA,IACtC,GAAG,EAAE;AAAA,IACL,GAAG,EAAE;AAAA,IACL,uBAAuB,EAAE;AAAA,IACzB,MAAM,EAAE;AAAA,EACT,CAAC;AACF;AAGO,MAAM,kBAAkB;AAAA,EAC9B,SAAS;AACV;AAGO,MAAM,oBAAoB,iBAAiB;AAAA,EACjD,gBAAgB,gBAAgB;AAAA,EAChC,WAAW;AAAA,IACV,CAAC,gBAAgB,OAAO,GAAG;AAAA,MAC1B,IAAI,CAAC,WAAW;AACf,eAAO;AAAA,UACN,GAAG;AAAA,UACH,MAAM,CAAC;AAAA,QACR;AAAA,MACD;AAAA,MACA,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,OAAO,MAAM;AACjC,eAAO;AAAA,UACN,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD,CAAC;AAGM,MAAM,oBAAoB,iBAA4B,WAAW;AAAA,EACvE,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AACR,CAAC,EAAE;AAAA,EACF,OAA2C;AAAA,IAC1C,GAAG;AAAA,IACH,GAAG;AAAA,IACH,uBAAuB;AAAA,IACvB,MAAM,CAAC;AAAA,EACR;AACD;AAGO,MAAM,eAAe,kBAAkB,SAAS,SAAS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createRecordType, defineMigrations } from "@bigbluebutton/store";
|
|
2
|
+
import { T } from "@bigbluebutton/validate";
|
|
3
|
+
import { box2dModelValidator } from "../misc/geometry-types.mjs";
|
|
4
|
+
import { idValidator } from "../misc/id-validator.mjs";
|
|
5
|
+
import { cursorTypeValidator } from "../misc/TLCursor.mjs";
|
|
6
|
+
import { scribbleValidator } from "../misc/TLScribble.mjs";
|
|
7
|
+
import { TLINSTANCE_ID } from "./TLInstance.mjs";
|
|
8
|
+
const instancePresenceValidator = T.model(
|
|
9
|
+
"instance_presence",
|
|
10
|
+
T.object({
|
|
11
|
+
typeName: T.literal("instance_presence"),
|
|
12
|
+
id: idValidator("instance_presence"),
|
|
13
|
+
userId: T.string,
|
|
14
|
+
userName: T.string,
|
|
15
|
+
lastActivityTimestamp: T.number,
|
|
16
|
+
followingUserId: T.string.nullable(),
|
|
17
|
+
cursor: T.object({
|
|
18
|
+
x: T.number,
|
|
19
|
+
y: T.number,
|
|
20
|
+
type: cursorTypeValidator,
|
|
21
|
+
rotation: T.number
|
|
22
|
+
}),
|
|
23
|
+
color: T.string,
|
|
24
|
+
camera: T.object({
|
|
25
|
+
x: T.number,
|
|
26
|
+
y: T.number,
|
|
27
|
+
z: T.number
|
|
28
|
+
}),
|
|
29
|
+
screenBounds: box2dModelValidator,
|
|
30
|
+
selectedShapeIds: T.arrayOf(idValidator("shape")),
|
|
31
|
+
currentPageId: idValidator("page"),
|
|
32
|
+
brush: box2dModelValidator.nullable(),
|
|
33
|
+
scribbles: T.arrayOf(scribbleValidator),
|
|
34
|
+
chatMessage: T.string,
|
|
35
|
+
meta: T.jsonValue
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
const instancePresenceVersions = {
|
|
39
|
+
AddScribbleDelay: 1,
|
|
40
|
+
RemoveInstanceId: 2,
|
|
41
|
+
AddChatMessage: 3,
|
|
42
|
+
AddMeta: 4,
|
|
43
|
+
RenameSelectedShapeIds: 5
|
|
44
|
+
};
|
|
45
|
+
const instancePresenceMigrations = defineMigrations({
|
|
46
|
+
currentVersion: instancePresenceVersions.RenameSelectedShapeIds,
|
|
47
|
+
migrators: {
|
|
48
|
+
[instancePresenceVersions.AddScribbleDelay]: {
|
|
49
|
+
up: (instance) => {
|
|
50
|
+
if (instance.scribble !== null) {
|
|
51
|
+
return { ...instance, scribble: { ...instance.scribble, delay: 0 } };
|
|
52
|
+
}
|
|
53
|
+
return { ...instance };
|
|
54
|
+
},
|
|
55
|
+
down: (instance) => {
|
|
56
|
+
if (instance.scribble !== null) {
|
|
57
|
+
const { delay: _delay, ...rest } = instance.scribble;
|
|
58
|
+
return { ...instance, scribble: rest };
|
|
59
|
+
}
|
|
60
|
+
return { ...instance };
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[instancePresenceVersions.RemoveInstanceId]: {
|
|
64
|
+
up: ({ instanceId: _, ...instance }) => {
|
|
65
|
+
return instance;
|
|
66
|
+
},
|
|
67
|
+
down: (instance) => {
|
|
68
|
+
return { ...instance, instanceId: TLINSTANCE_ID };
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[instancePresenceVersions.AddChatMessage]: {
|
|
72
|
+
up: (instance) => {
|
|
73
|
+
return { ...instance, chatMessage: "" };
|
|
74
|
+
},
|
|
75
|
+
down: ({ chatMessage: _, ...instance }) => {
|
|
76
|
+
return instance;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[instancePresenceVersions.AddMeta]: {
|
|
80
|
+
up: (record) => {
|
|
81
|
+
return {
|
|
82
|
+
...record,
|
|
83
|
+
meta: {}
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
down: ({ meta: _, ...record }) => {
|
|
87
|
+
return {
|
|
88
|
+
...record
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[instancePresenceVersions.RenameSelectedShapeIds]: {
|
|
93
|
+
up: (record) => {
|
|
94
|
+
const { selectedShapeIds, ...rest } = record;
|
|
95
|
+
return {
|
|
96
|
+
selectedShapeIds,
|
|
97
|
+
...rest
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
down: (record) => {
|
|
101
|
+
const { selectedShapeIds, ...rest } = record;
|
|
102
|
+
return {
|
|
103
|
+
selectedShapeIds,
|
|
104
|
+
...rest
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const InstancePresenceRecordType = createRecordType(
|
|
111
|
+
"instance_presence",
|
|
112
|
+
{
|
|
113
|
+
migrations: instancePresenceMigrations,
|
|
114
|
+
validator: instancePresenceValidator,
|
|
115
|
+
scope: "presence"
|
|
116
|
+
}
|
|
117
|
+
).withDefaultProperties(() => ({
|
|
118
|
+
lastActivityTimestamp: 0,
|
|
119
|
+
followingUserId: null,
|
|
120
|
+
color: "#FF0000",
|
|
121
|
+
camera: {
|
|
122
|
+
x: 0,
|
|
123
|
+
y: 0,
|
|
124
|
+
z: 1
|
|
125
|
+
},
|
|
126
|
+
cursor: {
|
|
127
|
+
x: 0,
|
|
128
|
+
y: 0,
|
|
129
|
+
type: "default",
|
|
130
|
+
rotation: 0
|
|
131
|
+
},
|
|
132
|
+
screenBounds: {
|
|
133
|
+
x: 0,
|
|
134
|
+
y: 0,
|
|
135
|
+
w: 1,
|
|
136
|
+
h: 1
|
|
137
|
+
},
|
|
138
|
+
selectedShapeIds: [],
|
|
139
|
+
brush: null,
|
|
140
|
+
scribbles: [],
|
|
141
|
+
chatMessage: "",
|
|
142
|
+
meta: {}
|
|
143
|
+
}));
|
|
144
|
+
export {
|
|
145
|
+
InstancePresenceRecordType,
|
|
146
|
+
instancePresenceMigrations,
|
|
147
|
+
instancePresenceValidator,
|
|
148
|
+
instancePresenceVersions
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=TLPresence.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/records/TLPresence.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseRecord, createRecordType, defineMigrations, RecordId } from '@bigbluebutton/store'\nimport { JsonObject } from '@bigbluebutton/utils'\nimport { T } from '@bigbluebutton/validate'\nimport { Box2dModel, box2dModelValidator } from '../misc/geometry-types'\nimport { idValidator } from '../misc/id-validator'\nimport { cursorTypeValidator, TLCursor } from '../misc/TLCursor'\nimport { scribbleValidator, TLScribble } from '../misc/TLScribble'\nimport { TLINSTANCE_ID } from './TLInstance'\nimport { TLPageId } from './TLPage'\nimport { TLShapeId } from './TLShape'\n\n/** @public */\nexport interface TLInstancePresence extends BaseRecord<'instance_presence', TLInstancePresenceID> {\n\tuserId: string\n\tuserName: string\n\tlastActivityTimestamp: number\n\tcolor: string // can be any hex color\n\tcamera: { x: number; y: number; z: number }\n\tselectedShapeIds: TLShapeId[]\n\tcurrentPageId: TLPageId\n\tbrush: Box2dModel | null\n\tscribbles: TLScribble[]\n\tscreenBounds: Box2dModel\n\tfollowingUserId: string | null\n\tcursor: {\n\t\tx: number\n\t\ty: number\n\t\ttype: TLCursor['type']\n\t\trotation: number\n\t}\n\tchatMessage: string\n\tmeta: JsonObject\n}\n\n/** @public */\nexport type TLInstancePresenceID = RecordId<TLInstancePresence>\n\n/** @internal */\nexport const instancePresenceValidator: T.Validator<TLInstancePresence> = T.model(\n\t'instance_presence',\n\tT.object({\n\t\ttypeName: T.literal('instance_presence'),\n\t\tid: idValidator<TLInstancePresenceID>('instance_presence'),\n\t\tuserId: T.string,\n\t\tuserName: T.string,\n\t\tlastActivityTimestamp: T.number,\n\t\tfollowingUserId: T.string.nullable(),\n\t\tcursor: T.object({\n\t\t\tx: T.number,\n\t\t\ty: T.number,\n\t\t\ttype: cursorTypeValidator,\n\t\t\trotation: T.number,\n\t\t}),\n\t\tcolor: T.string,\n\t\tcamera: T.object({\n\t\t\tx: T.number,\n\t\t\ty: T.number,\n\t\t\tz: T.number,\n\t\t}),\n\t\tscreenBounds: box2dModelValidator,\n\t\tselectedShapeIds: T.arrayOf(idValidator<TLShapeId>('shape')),\n\t\tcurrentPageId: idValidator<TLPageId>('page'),\n\t\tbrush: box2dModelValidator.nullable(),\n\t\tscribbles: T.arrayOf(scribbleValidator),\n\t\tchatMessage: T.string,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/** @internal */\nexport const instancePresenceVersions = {\n\tAddScribbleDelay: 1,\n\tRemoveInstanceId: 2,\n\tAddChatMessage: 3,\n\tAddMeta: 4,\n\tRenameSelectedShapeIds: 5,\n} as const\n\nexport const instancePresenceMigrations = defineMigrations({\n\tcurrentVersion: instancePresenceVersions.RenameSelectedShapeIds,\n\tmigrators: {\n\t\t[instancePresenceVersions.AddScribbleDelay]: {\n\t\t\tup: (instance) => {\n\t\t\t\tif (instance.scribble !== null) {\n\t\t\t\t\treturn { ...instance, scribble: { ...instance.scribble, delay: 0 } }\n\t\t\t\t}\n\t\t\t\treturn { ...instance }\n\t\t\t},\n\t\t\tdown: (instance) => {\n\t\t\t\tif (instance.scribble !== null) {\n\t\t\t\t\tconst { delay: _delay, ...rest } = instance.scribble\n\t\t\t\t\treturn { ...instance, scribble: rest }\n\t\t\t\t}\n\t\t\t\treturn { ...instance }\n\t\t\t},\n\t\t},\n\t\t[instancePresenceVersions.RemoveInstanceId]: {\n\t\t\tup: ({ instanceId: _, ...instance }) => {\n\t\t\t\treturn instance\n\t\t\t},\n\t\t\tdown: (instance) => {\n\t\t\t\treturn { ...instance, instanceId: TLINSTANCE_ID }\n\t\t\t},\n\t\t},\n\t\t[instancePresenceVersions.AddChatMessage]: {\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, chatMessage: '' }\n\t\t\t},\n\t\t\tdown: ({ chatMessage: _, ...instance }) => {\n\t\t\t\treturn instance\n\t\t\t},\n\t\t},\n\t\t[instancePresenceVersions.AddMeta]: {\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tmeta: {},\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ meta: _, ...record }) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[instancePresenceVersions.RenameSelectedShapeIds]: {\n\t\t\tup: (record) => {\n\t\t\t\tconst { selectedShapeIds, ...rest } = record\n\t\t\t\treturn {\n\t\t\t\t\tselectedShapeIds: selectedShapeIds,\n\t\t\t\t\t...rest,\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (record) => {\n\t\t\t\tconst { selectedShapeIds, ...rest } = record\n\t\t\t\treturn {\n\t\t\t\t\tselectedShapeIds: selectedShapeIds,\n\t\t\t\t\t...rest,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n})\n\n/** @public */\nexport const InstancePresenceRecordType = createRecordType<TLInstancePresence>(\n\t'instance_presence',\n\t{\n\t\tmigrations: instancePresenceMigrations,\n\t\tvalidator: instancePresenceValidator,\n\t\tscope: 'presence',\n\t}\n).withDefaultProperties(() => ({\n\tlastActivityTimestamp: 0,\n\tfollowingUserId: null,\n\tcolor: '#FF0000',\n\tcamera: {\n\t\tx: 0,\n\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AAM,GAAG,GAAG,OAAO,MAAM;AACjC,eAAO;AAAA,UACN,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC,yBAAyB,sBAAsB,GAAG;AAAA,MAClD,IAAI,CAAC,WAAW;AACf,cAAM,EAAE,kBAAkB,GAAG,KAAK,IAAI;AACtC,eAAO;AAAA,UACN;AAAA,UACA,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,MACA,MAAM,CAAC,WAAW;AACjB,cAAM,EAAE,kBAAkB,GAAG,KAAK,IAAI;AACtC,eAAO;AAAA,UACN;AAAA,UACA,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD,CAAC;AAGM,MAAM,6BAA6B;AAAA,EACzC;AAAA,EACA;AAAA,IACC,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO;AAAA,EACR;AACD,EAAE,sBAAsB,OAAO;AAAA,EAC9B,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,QAAQ;AAAA,IACP,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AAAA,EACA,QAAQ;AAAA,IACP,GAAG;AAAA,IACH,GAAG;AAAA,IACH,MAAM;AAAA,IACN,UAAU;AAAA,EACX;AAAA,EACA,cAAc;AAAA,IACb,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AAAA,EACA,kBAAkB,CAAC;AAAA,EACnB,OAAO;AAAA,EACP,WAAW,CAAC;AAAA,EACZ,aAAa;AAAA,EACb,MAAM,CAAC;AACR,EAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=TLRecord.mjs.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { createRecordType, defineMigrations } from "@bigbluebutton/store";
|
|
2
|
+
import { mapObjectMapValues } from "@bigbluebutton/utils";
|
|
3
|
+
import { T } from "@bigbluebutton/validate";
|
|
4
|
+
import { nanoid } from "nanoid";
|
|
5
|
+
import { createShapeValidator } from "../shapes/TLBaseShape.mjs";
|
|
6
|
+
import { StyleProp } from "../styles/StyleProp.mjs";
|
|
7
|
+
const rootShapeVersions = {
|
|
8
|
+
AddIsLocked: 1,
|
|
9
|
+
HoistOpacity: 2,
|
|
10
|
+
AddMeta: 3
|
|
11
|
+
};
|
|
12
|
+
const rootShapeMigrations = defineMigrations({
|
|
13
|
+
currentVersion: rootShapeVersions.AddMeta,
|
|
14
|
+
migrators: {
|
|
15
|
+
[rootShapeVersions.AddIsLocked]: {
|
|
16
|
+
up: (record) => {
|
|
17
|
+
return {
|
|
18
|
+
...record,
|
|
19
|
+
isLocked: false
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
down: (record) => {
|
|
23
|
+
const { isLocked: _, ...rest } = record;
|
|
24
|
+
return {
|
|
25
|
+
...rest
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
[rootShapeVersions.HoistOpacity]: {
|
|
30
|
+
up: ({ props: { opacity, ...props }, ...record }) => {
|
|
31
|
+
return {
|
|
32
|
+
...record,
|
|
33
|
+
opacity: Number(opacity ?? "1"),
|
|
34
|
+
props
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
down: ({ opacity, ...record }) => {
|
|
38
|
+
return {
|
|
39
|
+
...record,
|
|
40
|
+
props: {
|
|
41
|
+
...record.props,
|
|
42
|
+
opacity: opacity < 0.175 ? "0.1" : opacity < 0.375 ? "0.25" : opacity < 0.625 ? "0.5" : opacity < 0.875 ? "0.75" : "1"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[rootShapeVersions.AddMeta]: {
|
|
48
|
+
up: (record) => {
|
|
49
|
+
return {
|
|
50
|
+
...record,
|
|
51
|
+
meta: {}
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
down: ({ meta: _, ...record }) => {
|
|
55
|
+
return {
|
|
56
|
+
...record
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
function isShape(record) {
|
|
63
|
+
if (!record)
|
|
64
|
+
return false;
|
|
65
|
+
return record.typeName === "shape";
|
|
66
|
+
}
|
|
67
|
+
function isShapeId(id) {
|
|
68
|
+
if (!id)
|
|
69
|
+
return false;
|
|
70
|
+
return id.startsWith("shape:");
|
|
71
|
+
}
|
|
72
|
+
function createShapeId(id) {
|
|
73
|
+
return `shape:${id ?? nanoid()}`;
|
|
74
|
+
}
|
|
75
|
+
function getShapePropKeysByStyle(props) {
|
|
76
|
+
const propKeysByStyle = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const [key, prop] of Object.entries(props)) {
|
|
78
|
+
if (prop instanceof StyleProp) {
|
|
79
|
+
if (propKeysByStyle.has(prop)) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Duplicate style prop ${prop.id}. Each style prop can only be used once within a shape.`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
propKeysByStyle.set(prop, key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return propKeysByStyle;
|
|
88
|
+
}
|
|
89
|
+
function createShapeRecordType(shapes) {
|
|
90
|
+
return createRecordType("shape", {
|
|
91
|
+
migrations: defineMigrations({
|
|
92
|
+
currentVersion: rootShapeMigrations.currentVersion,
|
|
93
|
+
firstVersion: rootShapeMigrations.firstVersion,
|
|
94
|
+
migrators: rootShapeMigrations.migrators,
|
|
95
|
+
subTypeKey: "type",
|
|
96
|
+
subTypeMigrations: mapObjectMapValues(shapes, (_, v) => v.migrations ?? defineMigrations({}))
|
|
97
|
+
}),
|
|
98
|
+
scope: "document",
|
|
99
|
+
validator: T.model(
|
|
100
|
+
"shape",
|
|
101
|
+
T.union(
|
|
102
|
+
"type",
|
|
103
|
+
mapObjectMapValues(
|
|
104
|
+
shapes,
|
|
105
|
+
(type, { props, meta }) => createShapeValidator(type, props, meta)
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
}).withDefaultProperties(() => ({
|
|
110
|
+
x: 0,
|
|
111
|
+
y: 0,
|
|
112
|
+
rotation: 0,
|
|
113
|
+
isLocked: false,
|
|
114
|
+
opacity: 1,
|
|
115
|
+
meta: {}
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
createShapeId,
|
|
120
|
+
createShapeRecordType,
|
|
121
|
+
getShapePropKeysByStyle,
|
|
122
|
+
isShape,
|
|
123
|
+
isShapeId,
|
|
124
|
+
rootShapeMigrations,
|
|
125
|
+
rootShapeVersions
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=TLShape.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/records/TLShape.ts"],
|
|
4
|
+
"sourcesContent": ["import { createRecordType, defineMigrations, RecordId, UnknownRecord } from '@bigbluebutton/store'\nimport { mapObjectMapValues } from '@bigbluebutton/utils'\nimport { T } from '@bigbluebutton/validate'\nimport { nanoid } from 'nanoid'\nimport { SchemaShapeInfo } from '../createTLSchema'\nimport { TLArrowShape } from '../shapes/TLArrowShape'\nimport { createShapeValidator, TLBaseShape } from '../shapes/TLBaseShape'\nimport { TLBookmarkShape } from '../shapes/TLBookmarkShape'\nimport { TLDrawShape } from '../shapes/TLDrawShape'\nimport { TLEmbedShape } from '../shapes/TLEmbedShape'\nimport { TLFrameShape } from '../shapes/TLFrameShape'\nimport { TLGeoShape } from '../shapes/TLGeoShape'\nimport { TLGroupShape } from '../shapes/TLGroupShape'\nimport { TLHighlightShape } from '../shapes/TLHighlightShape'\nimport { TLImageShape } from '../shapes/TLImageShape'\nimport { TLLineShape } from '../shapes/TLLineShape'\nimport { TLNoteShape } from '../shapes/TLNoteShape'\nimport { TLTextShape } from '../shapes/TLTextShape'\nimport { TLVideoShape } from '../shapes/TLVideoShape'\nimport { StyleProp } from '../styles/StyleProp'\nimport { TLPageId } from './TLPage'\n\n/**\n * The default set of shapes that are available in the editor.\n *\n * @public */\nexport type TLDefaultShape =\n\t| TLArrowShape\n\t| TLBookmarkShape\n\t| TLDrawShape\n\t| TLEmbedShape\n\t| TLFrameShape\n\t| TLGeoShape\n\t| TLGroupShape\n\t| TLImageShape\n\t| TLLineShape\n\t| TLNoteShape\n\t| TLTextShape\n\t| TLVideoShape\n\t| TLHighlightShape\n\n/**\n * A type for a shape that is available in the editor but whose type is\n * unknown\u2014either one of the editor's default shapes or else a custom shape.\n *\n * @public */\nexport type TLUnknownShape = TLBaseShape<string, object>\n\n/**\n * The set of all shapes that are available in the editor, including unknown shapes.\n *\n * @public\n */\nexport type TLShape = TLDefaultShape | TLUnknownShape\n\n/** @public */\nexport type TLShapePartial<T extends TLShape = TLShape> = T extends T\n\t? {\n\t\t\tid: TLShapeId\n\t\t\ttype: T['type']\n\t\t\tprops?: Partial<T['props']>\n\t\t\tmeta?: Partial<T['meta']>\n\t } & Partial<Omit<T, 'type' | 'id' | 'props' | 'meta'>>\n\t: never\n\n/** @public */\nexport type TLShapeId = RecordId<TLUnknownShape>\n\n// evil type shit that will get deleted in the next PR\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void\n\t? I\n\t: never\n\ntype Identity<T> = { [K in keyof T]: T[K] }\n\n/** @public */\nexport type TLShapeProps = Identity<UnionToIntersection<TLDefaultShape['props']>>\n\n/** @public */\nexport type TLShapeProp = keyof TLShapeProps\n\n/** @public */\nexport type TLParentId = TLPageId | TLShapeId\n\n/** @internal */\nexport const rootShapeVersions = {\n\tAddIsLocked: 1,\n\tHoistOpacity: 2,\n\tAddMeta: 3,\n} as const\n\n/** @internal */\nexport const rootShapeMigrations = defineMigrations({\n\tcurrentVersion: rootShapeVersions.AddMeta,\n\tmigrators: {\n\t\t[rootShapeVersions.AddIsLocked]: {\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tisLocked: false,\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (record) => {\n\t\t\t\tconst { isLocked: _, ...rest } = record\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[rootShapeVersions.HoistOpacity]: {\n\t\t\tup: ({ props: { opacity, ...props }, ...record }) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\topacity: Number(opacity ?? '1'),\n\t\t\t\t\tprops,\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ opacity, ...record }) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...record.props,\n\t\t\t\t\t\topacity:\n\t\t\t\t\t\t\topacity < 0.175\n\t\t\t\t\t\t\t\t? '0.1'\n\t\t\t\t\t\t\t\t: opacity < 0.375\n\t\t\t\t\t\t\t\t? '0.25'\n\t\t\t\t\t\t\t\t: opacity < 0.625\n\t\t\t\t\t\t\t\t? '0.5'\n\t\t\t\t\t\t\t\t: opacity < 0.875\n\t\t\t\t\t\t\t\t? '0.75'\n\t\t\t\t\t\t\t\t: '1',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[rootShapeVersions.AddMeta]: {\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tmeta: {},\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ meta: _, ...record }) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n})\n\n/** @public */\nexport function isShape(record?: UnknownRecord): record is TLShape {\n\tif (!record) return false\n\treturn record.typeName === 'shape'\n}\n\n/** @public */\nexport function isShapeId(id?: string): id is TLShapeId {\n\tif (!id) return false\n\treturn id.startsWith('shape:')\n}\n\n/** @public */\nexport function createShapeId(id?: string): TLShapeId {\n\treturn `shape:${id ?? nanoid()}` as TLShapeId\n}\n\n/** @internal */\nexport function getShapePropKeysByStyle(props: Record<string, T.Validatable<any>>) {\n\tconst propKeysByStyle = new Map<StyleProp<unknown>, string>()\n\tfor (const [key, prop] of Object.entries(props)) {\n\t\tif (prop instanceof StyleProp) {\n\t\t\tif (propKeysByStyle.has(prop)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Duplicate style prop ${prop.id}. Each style prop can only be used once within a shape.`\n\t\t\t\t)\n\t\t\t}\n\t\t\tpropKeysByStyle.set(prop, key)\n\t\t}\n\t}\n\treturn propKeysByStyle\n}\n\n/** @internal */\nexport function createShapeRecordType(shapes: Record<string, SchemaShapeInfo>) {\n\treturn createRecordType<TLShape>('shape', {\n\t\tmigrations: defineMigrations({\n\t\t\tcurrentVersion: rootShapeMigrations.currentVersion,\n\t\t\tfirstVersion: rootShapeMigrations.firstVersion,\n\t\t\tmigrators: rootShapeMigrations.migrators,\n\t\t\tsubTypeKey: 'type',\n\t\t\tsubTypeMigrations: mapObjectMapValues(shapes, (_, v) => v.migrations ?? defineMigrations({})),\n\t\t}),\n\t\tscope: 'document',\n\t\tvalidator: T.model(\n\t\t\t'shape',\n\t\t\tT.union(\n\t\t\t\t'type',\n\t\t\t\tmapObjectMapValues(shapes, (type, { props, meta }) =>\n\t\t\t\t\tcreateShapeValidator(type, props, meta)\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t}).withDefaultProperties(() => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\trotation: 0,\n\t\tisLocked: false,\n\t\topacity: 1,\n\t\tmeta: {},\n\t}))\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAAkB,wBAAiD;AAC5E,SAAS,0BAA0B;AACnC,SAAS,SAAS;AAClB,SAAS,cAAc;AAGvB,SAAS,4BAAyC;AAalD,SAAS,iBAAiB;AAkEnB,MAAM,oBAAoB;AAAA,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