@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,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var TLRecord_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(TLRecord_exports);
|
|
17
|
+
//# sourceMappingURL=TLRecord.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/records/TLRecord.ts"],
|
|
4
|
+
"sourcesContent": ["import { TLAsset } from './TLAsset'\nimport { TLCamera } from './TLCamera'\nimport { TLDocument } from './TLDocument'\nimport { TLInstance } from './TLInstance'\nimport { TLPage } from './TLPage'\nimport { TLInstancePageState } from './TLPageState'\nimport { TLPointer } from './TLPointer'\nimport { TLInstancePresence } from './TLPresence'\nimport { TLShape } from './TLShape'\n\n/** @public */\nexport type TLRecord =\n\t| TLAsset\n\t| TLCamera\n\t| TLDocument\n\t| TLInstance\n\t| TLInstancePageState\n\t| TLPage\n\t| TLShape\n\t| TLInstancePresence\n\t| TLPointer\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var TLShape_exports = {};
|
|
20
|
+
__export(TLShape_exports, {
|
|
21
|
+
createShapeId: () => createShapeId,
|
|
22
|
+
createShapeRecordType: () => createShapeRecordType,
|
|
23
|
+
getShapePropKeysByStyle: () => getShapePropKeysByStyle,
|
|
24
|
+
isShape: () => isShape,
|
|
25
|
+
isShapeId: () => isShapeId,
|
|
26
|
+
rootShapeMigrations: () => rootShapeMigrations,
|
|
27
|
+
rootShapeVersions: () => rootShapeVersions
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(TLShape_exports);
|
|
30
|
+
var import_store = require("@bigbluebutton/store");
|
|
31
|
+
var import_utils = require("@bigbluebutton/utils");
|
|
32
|
+
var import_validate = require("@bigbluebutton/validate");
|
|
33
|
+
var import_nanoid = require("nanoid");
|
|
34
|
+
var import_TLBaseShape = require("../shapes/TLBaseShape");
|
|
35
|
+
var import_StyleProp = require("../styles/StyleProp");
|
|
36
|
+
const rootShapeVersions = {
|
|
37
|
+
AddIsLocked: 1,
|
|
38
|
+
HoistOpacity: 2,
|
|
39
|
+
AddMeta: 3
|
|
40
|
+
};
|
|
41
|
+
const rootShapeMigrations = (0, import_store.defineMigrations)({
|
|
42
|
+
currentVersion: rootShapeVersions.AddMeta,
|
|
43
|
+
migrators: {
|
|
44
|
+
[rootShapeVersions.AddIsLocked]: {
|
|
45
|
+
up: (record) => {
|
|
46
|
+
return {
|
|
47
|
+
...record,
|
|
48
|
+
isLocked: false
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
down: (record) => {
|
|
52
|
+
const { isLocked: _, ...rest } = record;
|
|
53
|
+
return {
|
|
54
|
+
...rest
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
[rootShapeVersions.HoistOpacity]: {
|
|
59
|
+
up: ({ props: { opacity, ...props }, ...record }) => {
|
|
60
|
+
return {
|
|
61
|
+
...record,
|
|
62
|
+
opacity: Number(opacity ?? "1"),
|
|
63
|
+
props
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
down: ({ opacity, ...record }) => {
|
|
67
|
+
return {
|
|
68
|
+
...record,
|
|
69
|
+
props: {
|
|
70
|
+
...record.props,
|
|
71
|
+
opacity: opacity < 0.175 ? "0.1" : opacity < 0.375 ? "0.25" : opacity < 0.625 ? "0.5" : opacity < 0.875 ? "0.75" : "1"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
[rootShapeVersions.AddMeta]: {
|
|
77
|
+
up: (record) => {
|
|
78
|
+
return {
|
|
79
|
+
...record,
|
|
80
|
+
meta: {}
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
down: ({ meta: _, ...record }) => {
|
|
84
|
+
return {
|
|
85
|
+
...record
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
function isShape(record) {
|
|
92
|
+
if (!record)
|
|
93
|
+
return false;
|
|
94
|
+
return record.typeName === "shape";
|
|
95
|
+
}
|
|
96
|
+
function isShapeId(id) {
|
|
97
|
+
if (!id)
|
|
98
|
+
return false;
|
|
99
|
+
return id.startsWith("shape:");
|
|
100
|
+
}
|
|
101
|
+
function createShapeId(id) {
|
|
102
|
+
return `shape:${id ?? (0, import_nanoid.nanoid)()}`;
|
|
103
|
+
}
|
|
104
|
+
function getShapePropKeysByStyle(props) {
|
|
105
|
+
const propKeysByStyle = /* @__PURE__ */ new Map();
|
|
106
|
+
for (const [key, prop] of Object.entries(props)) {
|
|
107
|
+
if (prop instanceof import_StyleProp.StyleProp) {
|
|
108
|
+
if (propKeysByStyle.has(prop)) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
`Duplicate style prop ${prop.id}. Each style prop can only be used once within a shape.`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
propKeysByStyle.set(prop, key);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return propKeysByStyle;
|
|
117
|
+
}
|
|
118
|
+
function createShapeRecordType(shapes) {
|
|
119
|
+
return (0, import_store.createRecordType)("shape", {
|
|
120
|
+
migrations: (0, import_store.defineMigrations)({
|
|
121
|
+
currentVersion: rootShapeMigrations.currentVersion,
|
|
122
|
+
firstVersion: rootShapeMigrations.firstVersion,
|
|
123
|
+
migrators: rootShapeMigrations.migrators,
|
|
124
|
+
subTypeKey: "type",
|
|
125
|
+
subTypeMigrations: (0, import_utils.mapObjectMapValues)(shapes, (_, v) => v.migrations ?? (0, import_store.defineMigrations)({}))
|
|
126
|
+
}),
|
|
127
|
+
scope: "document",
|
|
128
|
+
validator: import_validate.T.model(
|
|
129
|
+
"shape",
|
|
130
|
+
import_validate.T.union(
|
|
131
|
+
"type",
|
|
132
|
+
(0, import_utils.mapObjectMapValues)(
|
|
133
|
+
shapes,
|
|
134
|
+
(type, { props, meta }) => (0, import_TLBaseShape.createShapeValidator)(type, props, meta)
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
}).withDefaultProperties(() => ({
|
|
139
|
+
x: 0,
|
|
140
|
+
y: 0,
|
|
141
|
+
rotation: 0,
|
|
142
|
+
isLocked: false,
|
|
143
|
+
opacity: 1,
|
|
144
|
+
meta: {}
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=TLShape.js.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": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var TLArrowShape_exports = {};
|
|
20
|
+
__export(TLArrowShape_exports, {
|
|
21
|
+
ArrowMigrationVersions: () => ArrowMigrationVersions,
|
|
22
|
+
ArrowShapeArrowheadEndStyle: () => ArrowShapeArrowheadEndStyle,
|
|
23
|
+
ArrowShapeArrowheadStartStyle: () => ArrowShapeArrowheadStartStyle,
|
|
24
|
+
arrowShapeMigrations: () => arrowShapeMigrations,
|
|
25
|
+
arrowShapeProps: () => arrowShapeProps
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(TLArrowShape_exports);
|
|
28
|
+
var import_store = require("@bigbluebutton/store");
|
|
29
|
+
var import_validate = require("@bigbluebutton/validate");
|
|
30
|
+
var import_geometry_types = require("../misc/geometry-types");
|
|
31
|
+
var import_StyleProp = require("../styles/StyleProp");
|
|
32
|
+
var import_TLColorStyle = require("../styles/TLColorStyle");
|
|
33
|
+
var import_TLDashStyle = require("../styles/TLDashStyle");
|
|
34
|
+
var import_TLFillStyle = require("../styles/TLFillStyle");
|
|
35
|
+
var import_TLFontStyle = require("../styles/TLFontStyle");
|
|
36
|
+
var import_TLSizeStyle = require("../styles/TLSizeStyle");
|
|
37
|
+
var import_TLBaseShape = require("./TLBaseShape");
|
|
38
|
+
const arrowheadTypes = [
|
|
39
|
+
"arrow",
|
|
40
|
+
"triangle",
|
|
41
|
+
"square",
|
|
42
|
+
"dot",
|
|
43
|
+
"pipe",
|
|
44
|
+
"diamond",
|
|
45
|
+
"inverted",
|
|
46
|
+
"bar",
|
|
47
|
+
"none"
|
|
48
|
+
];
|
|
49
|
+
const ArrowShapeArrowheadStartStyle = import_StyleProp.StyleProp.defineEnum("tldraw:arrowheadStart", {
|
|
50
|
+
defaultValue: "none",
|
|
51
|
+
values: arrowheadTypes
|
|
52
|
+
});
|
|
53
|
+
const ArrowShapeArrowheadEndStyle = import_StyleProp.StyleProp.defineEnum("tldraw:arrowheadEnd", {
|
|
54
|
+
defaultValue: "arrow",
|
|
55
|
+
values: arrowheadTypes
|
|
56
|
+
});
|
|
57
|
+
const ArrowShapeTerminal = import_validate.T.union("type", {
|
|
58
|
+
binding: import_validate.T.object({
|
|
59
|
+
type: import_validate.T.literal("binding"),
|
|
60
|
+
boundShapeId: import_TLBaseShape.shapeIdValidator,
|
|
61
|
+
normalizedAnchor: import_geometry_types.vec2dModelValidator,
|
|
62
|
+
isExact: import_validate.T.boolean,
|
|
63
|
+
isPrecise: import_validate.T.boolean
|
|
64
|
+
}),
|
|
65
|
+
point: import_validate.T.object({
|
|
66
|
+
type: import_validate.T.literal("point"),
|
|
67
|
+
x: import_validate.T.number,
|
|
68
|
+
y: import_validate.T.number
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
const arrowShapeProps = {
|
|
72
|
+
labelColor: import_TLColorStyle.DefaultLabelColorStyle,
|
|
73
|
+
color: import_TLColorStyle.DefaultColorStyle,
|
|
74
|
+
fill: import_TLFillStyle.DefaultFillStyle,
|
|
75
|
+
dash: import_TLDashStyle.DefaultDashStyle,
|
|
76
|
+
size: import_TLSizeStyle.DefaultSizeStyle,
|
|
77
|
+
arrowheadStart: ArrowShapeArrowheadStartStyle,
|
|
78
|
+
arrowheadEnd: ArrowShapeArrowheadEndStyle,
|
|
79
|
+
font: import_TLFontStyle.DefaultFontStyle,
|
|
80
|
+
start: ArrowShapeTerminal,
|
|
81
|
+
end: ArrowShapeTerminal,
|
|
82
|
+
bend: import_validate.T.number,
|
|
83
|
+
text: import_validate.T.string
|
|
84
|
+
};
|
|
85
|
+
const ArrowMigrationVersions = {
|
|
86
|
+
AddLabelColor: 1,
|
|
87
|
+
AddIsPrecise: 2
|
|
88
|
+
};
|
|
89
|
+
const arrowShapeMigrations = (0, import_store.defineMigrations)({
|
|
90
|
+
currentVersion: ArrowMigrationVersions.AddIsPrecise,
|
|
91
|
+
migrators: {
|
|
92
|
+
[ArrowMigrationVersions.AddLabelColor]: {
|
|
93
|
+
up: (record) => {
|
|
94
|
+
return {
|
|
95
|
+
...record,
|
|
96
|
+
props: {
|
|
97
|
+
...record.props,
|
|
98
|
+
labelColor: "black"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
down: (record) => {
|
|
103
|
+
const { labelColor: _, ...props } = record.props;
|
|
104
|
+
return {
|
|
105
|
+
...record,
|
|
106
|
+
props
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
[ArrowMigrationVersions.AddIsPrecise]: {
|
|
111
|
+
up: (record) => {
|
|
112
|
+
const { start, end } = record.props;
|
|
113
|
+
return {
|
|
114
|
+
...record,
|
|
115
|
+
props: {
|
|
116
|
+
...record.props,
|
|
117
|
+
start: start.type === "binding" ? {
|
|
118
|
+
...start,
|
|
119
|
+
isPrecise: !(start.normalizedAnchor.x === 0.5 && start.normalizedAnchor.y === 0.5)
|
|
120
|
+
} : start,
|
|
121
|
+
end: end.type === "binding" ? {
|
|
122
|
+
...end,
|
|
123
|
+
isPrecise: !(end.normalizedAnchor.x === 0.5 && end.normalizedAnchor.y === 0.5)
|
|
124
|
+
} : end
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
down: (record) => {
|
|
129
|
+
const { start, end } = record.props;
|
|
130
|
+
const nStart = { ...start };
|
|
131
|
+
const nEnd = { ...end };
|
|
132
|
+
if (nStart.type === "binding") {
|
|
133
|
+
if (!nStart.isPrecise) {
|
|
134
|
+
nStart.normalizedAnchor = { x: 0.5, y: 0.5 };
|
|
135
|
+
}
|
|
136
|
+
delete nStart.isPrecise;
|
|
137
|
+
}
|
|
138
|
+
if (nEnd.type === "binding") {
|
|
139
|
+
if (!nEnd.isPrecise) {
|
|
140
|
+
nEnd.normalizedAnchor = { x: 0.5, y: 0.5 };
|
|
141
|
+
}
|
|
142
|
+
delete nEnd.isPrecise;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
...record,
|
|
146
|
+
props: {
|
|
147
|
+
...record.props,
|
|
148
|
+
start: nStart,
|
|
149
|
+
end: nEnd
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=TLArrowShape.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shapes/TLArrowShape.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineMigrations } from '@bigbluebutton/store'\nimport { T } from '@bigbluebutton/validate'\nimport { vec2dModelValidator } from '../misc/geometry-types'\nimport { StyleProp } from '../styles/StyleProp'\nimport { DefaultColorStyle, DefaultLabelColorStyle } from '../styles/TLColorStyle'\nimport { DefaultDashStyle } from '../styles/TLDashStyle'\nimport { DefaultFillStyle } from '../styles/TLFillStyle'\nimport { DefaultFontStyle } from '../styles/TLFontStyle'\nimport { DefaultSizeStyle } from '../styles/TLSizeStyle'\nimport { ShapePropsType, TLBaseShape, shapeIdValidator } from './TLBaseShape'\n\nconst arrowheadTypes = [\n\t'arrow',\n\t'triangle',\n\t'square',\n\t'dot',\n\t'pipe',\n\t'diamond',\n\t'inverted',\n\t'bar',\n\t'none',\n] as const\n\n/** @public */\nexport const ArrowShapeArrowheadStartStyle = StyleProp.defineEnum('tldraw:arrowheadStart', {\n\tdefaultValue: 'none',\n\tvalues: arrowheadTypes,\n})\n\n/** @public */\nexport const ArrowShapeArrowheadEndStyle = StyleProp.defineEnum('tldraw:arrowheadEnd', {\n\tdefaultValue: 'arrow',\n\tvalues: arrowheadTypes,\n})\n\n/** @public */\nexport type TLArrowShapeArrowheadStyle = T.TypeOf<typeof ArrowShapeArrowheadStartStyle>\n\n/** @public */\nconst ArrowShapeTerminal = T.union('type', {\n\tbinding: T.object({\n\t\ttype: T.literal('binding'),\n\t\tboundShapeId: shapeIdValidator,\n\t\tnormalizedAnchor: vec2dModelValidator,\n\t\tisExact: T.boolean,\n\t\tisPrecise: T.boolean,\n\t}),\n\tpoint: T.object({\n\t\ttype: T.literal('point'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t}),\n})\n\n/** @public */\nexport type TLArrowShapeTerminal = T.TypeOf<typeof ArrowShapeTerminal>\n\n/** @public */\nexport const arrowShapeProps = {\n\tlabelColor: DefaultLabelColorStyle,\n\tcolor: DefaultColorStyle,\n\tfill: DefaultFillStyle,\n\tdash: DefaultDashStyle,\n\tsize: DefaultSizeStyle,\n\tarrowheadStart: ArrowShapeArrowheadStartStyle,\n\tarrowheadEnd: ArrowShapeArrowheadEndStyle,\n\tfont: DefaultFontStyle,\n\tstart: ArrowShapeTerminal,\n\tend: ArrowShapeTerminal,\n\tbend: T.number,\n\ttext: T.string,\n}\n\n/** @public */\nexport type TLArrowShapeProps = ShapePropsType<typeof arrowShapeProps>\n\n/** @public */\nexport type TLArrowShape = TLBaseShape<'arrow', TLArrowShapeProps>\n\nexport const ArrowMigrationVersions = {\n\tAddLabelColor: 1,\n\tAddIsPrecise: 2,\n} as const\n\n/** @internal */\nexport const arrowShapeMigrations = defineMigrations({\n\tcurrentVersion: ArrowMigrationVersions.AddIsPrecise,\n\tmigrators: {\n\t\t[ArrowMigrationVersions.AddLabelColor]: {\n\t\t\tup: (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\tlabelColor: 'black',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (record) => {\n\t\t\t\tconst { labelColor: _, ...props } = record.props\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tprops,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[ArrowMigrationVersions.AddIsPrecise]: {\n\t\t\tup: (record) => {\n\t\t\t\tconst { start, end } = record.props\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\tstart:\n\t\t\t\t\t\t\t(start as TLArrowShapeTerminal).type === 'binding'\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t...start,\n\t\t\t\t\t\t\t\t\t\tisPrecise: !(\n\t\t\t\t\t\t\t\t\t\t\tstart.normalizedAnchor.x === 0.5 && start.normalizedAnchor.y === 0.5\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: start,\n\t\t\t\t\t\tend:\n\t\t\t\t\t\t\t(end as TLArrowShapeTerminal).type === 'binding'\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t...end,\n\t\t\t\t\t\t\t\t\t\tisPrecise: !(end.normalizedAnchor.x === 0.5 && end.normalizedAnchor.y === 0.5),\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: end,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (record: any) => {\n\t\t\t\tconst { start, end } = record.props\n\t\t\t\tconst nStart = { ...start }\n\t\t\t\tconst nEnd = { ...end }\n\t\t\t\tif (nStart.type === 'binding') {\n\t\t\t\t\tif (!nStart.isPrecise) {\n\t\t\t\t\t\tnStart.normalizedAnchor = { x: 0.5, y: 0.5 }\n\t\t\t\t\t}\n\t\t\t\t\tdelete nStart.isPrecise\n\t\t\t\t}\n\t\t\t\tif (nEnd.type === 'binding') {\n\t\t\t\t\tif (!nEnd.isPrecise) {\n\t\t\t\t\t\tnEnd.normalizedAnchor = { x: 0.5, y: 0.5 }\n\t\t\t\t\t}\n\t\t\t\t\tdelete nEnd.isPrecise\n\t\t\t\t}\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\tstart: nStart,\n\t\t\t\t\t\tend: nEnd,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n})\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var TLBaseShape_exports = {};
|
|
20
|
+
__export(TLBaseShape_exports, {
|
|
21
|
+
createShapeValidator: () => createShapeValidator,
|
|
22
|
+
parentIdValidator: () => parentIdValidator,
|
|
23
|
+
shapeIdValidator: () => shapeIdValidator
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(TLBaseShape_exports);
|
|
26
|
+
var import_validate = require("@bigbluebutton/validate");
|
|
27
|
+
var import_TLOpacity = require("../misc/TLOpacity");
|
|
28
|
+
var import_id_validator = require("../misc/id-validator");
|
|
29
|
+
const parentIdValidator = import_validate.T.string.refine((id) => {
|
|
30
|
+
if (!id.startsWith("page:") && !id.startsWith("shape:")) {
|
|
31
|
+
throw new Error('Parent ID must start with "page:" or "shape:"');
|
|
32
|
+
}
|
|
33
|
+
return id;
|
|
34
|
+
});
|
|
35
|
+
const shapeIdValidator = (0, import_id_validator.idValidator)("shape");
|
|
36
|
+
function createShapeValidator(type, props, meta) {
|
|
37
|
+
return import_validate.T.object({
|
|
38
|
+
id: shapeIdValidator,
|
|
39
|
+
typeName: import_validate.T.literal("shape"),
|
|
40
|
+
x: import_validate.T.number,
|
|
41
|
+
y: import_validate.T.number,
|
|
42
|
+
rotation: import_validate.T.number,
|
|
43
|
+
index: import_validate.T.string,
|
|
44
|
+
parentId: parentIdValidator,
|
|
45
|
+
type: import_validate.T.literal(type),
|
|
46
|
+
isLocked: import_validate.T.boolean,
|
|
47
|
+
opacity: import_TLOpacity.opacityValidator,
|
|
48
|
+
props: props ? import_validate.T.object(props) : import_validate.T.jsonValue,
|
|
49
|
+
meta: meta ? import_validate.T.object(meta) : import_validate.T.jsonValue
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=TLBaseShape.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shapes/TLBaseShape.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseRecord } from '@bigbluebutton/store'\nimport { Expand, JsonObject } from '@bigbluebutton/utils'\nimport { T } from '@bigbluebutton/validate'\nimport { TLOpacityType, opacityValidator } from '../misc/TLOpacity'\nimport { idValidator } from '../misc/id-validator'\nimport { TLParentId, TLShapeId } from '../records/TLShape'\n\n/** @public */\nexport interface TLBaseShape<Type extends string, Props extends object>\n\textends BaseRecord<'shape', TLShapeId> {\n\ttype: Type\n\tx: number\n\ty: number\n\trotation: number\n\tindex: string\n\tparentId: TLParentId\n\tisLocked: boolean\n\topacity: TLOpacityType\n\tprops: Props\n\tmeta: JsonObject\n}\n\n/** @public */\nexport const parentIdValidator = T.string.refine((id) => {\n\tif (!id.startsWith('page:') && !id.startsWith('shape:')) {\n\t\tthrow new Error('Parent ID must start with \"page:\" or \"shape:\"')\n\t}\n\treturn id as TLParentId\n})\n\n/** @public */\nexport const shapeIdValidator = idValidator<TLShapeId>('shape')\n\n/** @public */\nexport function createShapeValidator<\n\tType extends string,\n\tProps extends JsonObject,\n\tMeta extends JsonObject\n>(\n\ttype: Type,\n\tprops?: { [K in keyof Props]: T.Validatable<Props[K]> },\n\tmeta?: { [K in keyof Meta]: T.Validatable<Meta[K]> }\n) {\n\treturn T.object<TLBaseShape<Type, Props>>({\n\t\tid: shapeIdValidator,\n\t\ttypeName: T.literal('shape'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\trotation: T.number,\n\t\tindex: T.string,\n\t\tparentId: parentIdValidator,\n\t\ttype: T.literal(type),\n\t\tisLocked: T.boolean,\n\t\topacity: opacityValidator,\n\t\tprops: props ? T.object(props) : (T.jsonValue as T.ObjectValidator<Props>),\n\t\tmeta: meta ? T.object(meta) : (T.jsonValue as T.ObjectValidator<Meta>),\n\t})\n}\n\n/** @public */\nexport type ShapeProps<Shape extends TLBaseShape<any, any>> = {\n\t[K in keyof Shape['props']]: T.Validatable<Shape['props'][K]>\n}\n\nexport type ShapePropsType<Config extends Record<string, T.Validatable<any>>> = Expand<{\n\t[K in keyof Config]: T.TypeOf<Config[K]>\n}>\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAkB;AAClB,uBAAgD;AAChD,0BAA4B;AAmBrB,MAAM,oBAAoB,kBAAE,OAAO,OAAO,CAAC,OAAO;AACxD,MAAI,CAAC,GAAG,WAAW,OAAO,KAAK,CAAC,GAAG,WAAW,QAAQ,GAAG;AACxD,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AACA,SAAO;AACR,CAAC;AAGM,MAAM,uBAAmB,iCAAuB,OAAO;AAGvD,SAAS,qBAKf,MACA,OACA,MACC;AACD,SAAO,kBAAE,OAAiC;AAAA,IACzC,IAAI;AAAA,IACJ,UAAU,kBAAE,QAAQ,OAAO;AAAA,IAC3B,GAAG,kBAAE;AAAA,IACL,GAAG,kBAAE;AAAA,IACL,UAAU,kBAAE;AAAA,IACZ,OAAO,kBAAE;AAAA,IACT,UAAU;AAAA,IACV,MAAM,kBAAE,QAAQ,IAAI;AAAA,IACpB,UAAU,kBAAE;AAAA,IACZ,SAAS;AAAA,IACT,OAAO,QAAQ,kBAAE,OAAO,KAAK,IAAK,kBAAE;AAAA,IACpC,MAAM,OAAO,kBAAE,OAAO,IAAI,IAAK,kBAAE;AAAA,EAClC,CAAC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var TLBookmarkShape_exports = {};
|
|
20
|
+
__export(TLBookmarkShape_exports, {
|
|
21
|
+
bookmarkShapeMigrations: () => bookmarkShapeMigrations,
|
|
22
|
+
bookmarkShapeProps: () => bookmarkShapeProps
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(TLBookmarkShape_exports);
|
|
25
|
+
var import_store = require("@bigbluebutton/store");
|
|
26
|
+
var import_validate = require("@bigbluebutton/validate");
|
|
27
|
+
var import_TLBaseAsset = require("../assets/TLBaseAsset");
|
|
28
|
+
const bookmarkShapeProps = {
|
|
29
|
+
w: import_validate.T.nonZeroNumber,
|
|
30
|
+
h: import_validate.T.nonZeroNumber,
|
|
31
|
+
assetId: import_TLBaseAsset.assetIdValidator.nullable(),
|
|
32
|
+
url: import_validate.T.string
|
|
33
|
+
};
|
|
34
|
+
const Versions = {
|
|
35
|
+
NullAssetId: 1
|
|
36
|
+
};
|
|
37
|
+
const bookmarkShapeMigrations = (0, import_store.defineMigrations)({
|
|
38
|
+
currentVersion: Versions.NullAssetId,
|
|
39
|
+
migrators: {
|
|
40
|
+
[Versions.NullAssetId]: {
|
|
41
|
+
up: (shape) => {
|
|
42
|
+
if (shape.props.assetId === void 0) {
|
|
43
|
+
return { ...shape, props: { ...shape.props, assetId: null } };
|
|
44
|
+
}
|
|
45
|
+
return shape;
|
|
46
|
+
},
|
|
47
|
+
down: (shape) => {
|
|
48
|
+
if (shape.props.assetId === null) {
|
|
49
|
+
const { assetId: _, ...props } = shape.props;
|
|
50
|
+
return { ...shape, props };
|
|
51
|
+
}
|
|
52
|
+
return shape;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=TLBookmarkShape.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shapes/TLBookmarkShape.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineMigrations } from '@bigbluebutton/store'\nimport { T } from '@bigbluebutton/validate'\nimport { assetIdValidator } from '../assets/TLBaseAsset'\nimport { ShapePropsType, TLBaseShape } from './TLBaseShape'\n\n/** @public */\nexport const bookmarkShapeProps = {\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\tassetId: assetIdValidator.nullable(),\n\turl: T.string,\n}\n\n/** @public */\nexport type TLBookmarkShapeProps = ShapePropsType<typeof bookmarkShapeProps>\n\n/** @public */\nexport type TLBookmarkShape = TLBaseShape<'bookmark', TLBookmarkShapeProps>\n\nconst Versions = {\n\tNullAssetId: 1,\n} as const\n\n/** @internal */\nexport const bookmarkShapeMigrations = defineMigrations({\n\tcurrentVersion: Versions.NullAssetId,\n\tmigrators: {\n\t\t[Versions.NullAssetId]: {\n\t\t\tup: (shape: TLBookmarkShape) => {\n\t\t\t\tif (shape.props.assetId === undefined) {\n\t\t\t\t\treturn { ...shape, props: { ...shape.props, assetId: null } } as typeof shape\n\t\t\t\t}\n\t\t\t\treturn shape\n\t\t\t},\n\t\t\tdown: (shape: TLBookmarkShape) => {\n\t\t\t\tif (shape.props.assetId === null) {\n\t\t\t\t\tconst { assetId: _, ...props } = shape.props\n\t\t\t\t\treturn { ...shape, props } as typeof shape\n\t\t\t\t}\n\t\t\t\treturn shape\n\t\t\t},\n\t\t},\n\t},\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,sBAAkB;AAClB,yBAAiC;AAI1B,MAAM,qBAAqB;AAAA,EACjC,GAAG,kBAAE;AAAA,EACL,GAAG,kBAAE;AAAA,EACL,SAAS,oCAAiB,SAAS;AAAA,EACnC,KAAK,kBAAE;AACR;AAQA,MAAM,WAAW;AAAA,EAChB,aAAa;AACd;AAGO,MAAM,8BAA0B,+BAAiB;AAAA,EACvD,gBAAgB,SAAS;AAAA,EACzB,WAAW;AAAA,IACV,CAAC,SAAS,WAAW,GAAG;AAAA,MACvB,IAAI,CAAC,UAA2B;AAC/B,YAAI,MAAM,MAAM,YAAY,QAAW;AACtC,iBAAO,EAAE,GAAG,OAAO,OAAO,EAAE,GAAG,MAAM,OAAO,SAAS,KAAK,EAAE;AAAA,QAC7D;AACA,eAAO;AAAA,MACR;AAAA,MACA,MAAM,CAAC,UAA2B;AACjC,YAAI,MAAM,MAAM,YAAY,MAAM;AACjC,gBAAM,EAAE,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM;AACvC,iBAAO,EAAE,GAAG,OAAO,MAAM;AAAA,QAC1B;AACA,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var TLDrawShape_exports = {};
|
|
20
|
+
__export(TLDrawShape_exports, {
|
|
21
|
+
DrawShapeSegment: () => DrawShapeSegment,
|
|
22
|
+
drawShapeMigrations: () => drawShapeMigrations,
|
|
23
|
+
drawShapeProps: () => drawShapeProps
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(TLDrawShape_exports);
|
|
26
|
+
var import_store = require("@bigbluebutton/store");
|
|
27
|
+
var import_validate = require("@bigbluebutton/validate");
|
|
28
|
+
var import_geometry_types = require("../misc/geometry-types");
|
|
29
|
+
var import_TLColorStyle = require("../styles/TLColorStyle");
|
|
30
|
+
var import_TLDashStyle = require("../styles/TLDashStyle");
|
|
31
|
+
var import_TLFillStyle = require("../styles/TLFillStyle");
|
|
32
|
+
var import_TLSizeStyle = require("../styles/TLSizeStyle");
|
|
33
|
+
const DrawShapeSegment = import_validate.T.object({
|
|
34
|
+
type: import_validate.T.literalEnum("free", "straight"),
|
|
35
|
+
points: import_validate.T.arrayOf(import_geometry_types.vec2dModelValidator)
|
|
36
|
+
});
|
|
37
|
+
const drawShapeProps = {
|
|
38
|
+
color: import_TLColorStyle.DefaultColorStyle,
|
|
39
|
+
fill: import_TLFillStyle.DefaultFillStyle,
|
|
40
|
+
dash: import_TLDashStyle.DefaultDashStyle,
|
|
41
|
+
size: import_TLSizeStyle.DefaultSizeStyle,
|
|
42
|
+
segments: import_validate.T.arrayOf(DrawShapeSegment),
|
|
43
|
+
isComplete: import_validate.T.boolean,
|
|
44
|
+
isClosed: import_validate.T.boolean,
|
|
45
|
+
isPen: import_validate.T.boolean
|
|
46
|
+
};
|
|
47
|
+
const Versions = {
|
|
48
|
+
AddInPen: 1
|
|
49
|
+
};
|
|
50
|
+
const drawShapeMigrations = (0, import_store.defineMigrations)({
|
|
51
|
+
currentVersion: Versions.AddInPen,
|
|
52
|
+
migrators: {
|
|
53
|
+
[Versions.AddInPen]: {
|
|
54
|
+
up: (shape) => {
|
|
55
|
+
const { points } = shape.props.segments[0];
|
|
56
|
+
if (points.length === 0) {
|
|
57
|
+
return {
|
|
58
|
+
...shape,
|
|
59
|
+
props: {
|
|
60
|
+
...shape.props,
|
|
61
|
+
isPen: false
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
let isPen = !(points[0].z === 0 || points[0].z === 0.5);
|
|
66
|
+
if (points[1]) {
|
|
67
|
+
isPen = isPen && !(points[1].z === 0 || points[1].z === 0.5);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
...shape,
|
|
71
|
+
props: {
|
|
72
|
+
...shape.props,
|
|
73
|
+
isPen
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
down: (shape) => {
|
|
78
|
+
const { isPen: _isPen, ...propsWithOutIsPen } = shape.props;
|
|
79
|
+
return {
|
|
80
|
+
...shape,
|
|
81
|
+
props: {
|
|
82
|
+
...propsWithOutIsPen
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=TLDrawShape.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shapes/TLDrawShape.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineMigrations } from '@bigbluebutton/store'\nimport { T } from '@bigbluebutton/validate'\nimport { vec2dModelValidator } from '../misc/geometry-types'\nimport { DefaultColorStyle } from '../styles/TLColorStyle'\nimport { DefaultDashStyle } from '../styles/TLDashStyle'\nimport { DefaultFillStyle } from '../styles/TLFillStyle'\nimport { DefaultSizeStyle } from '../styles/TLSizeStyle'\nimport { ShapePropsType, TLBaseShape } from './TLBaseShape'\n\nexport const DrawShapeSegment = T.object({\n\ttype: T.literalEnum('free', 'straight'),\n\tpoints: T.arrayOf(vec2dModelValidator),\n})\n\n/** @public */\nexport type TLDrawShapeSegment = T.TypeOf<typeof DrawShapeSegment>\n\n/** @public */\nexport const drawShapeProps = {\n\tcolor: DefaultColorStyle,\n\tfill: DefaultFillStyle,\n\tdash: DefaultDashStyle,\n\tsize: DefaultSizeStyle,\n\tsegments: T.arrayOf(DrawShapeSegment),\n\tisComplete: T.boolean,\n\tisClosed: T.boolean,\n\tisPen: T.boolean,\n}\n\n/** @public */\nexport type TLDrawShapeProps = ShapePropsType<typeof drawShapeProps>\n\n/** @public */\nexport type TLDrawShape = TLBaseShape<'draw', TLDrawShapeProps>\n\nconst Versions = {\n\tAddInPen: 1,\n} as const\n\n/** @internal */\nexport const drawShapeMigrations = defineMigrations({\n\tcurrentVersion: Versions.AddInPen,\n\tmigrators: {\n\t\t[Versions.AddInPen]: {\n\t\t\tup: (shape) => {\n\t\t\t\t// Rather than checking to see whether the shape is a pen at runtime,\n\t\t\t\t// from now on we're going to use the type of device reported to us\n\t\t\t\t// as well as the pressure data received; but for existing shapes we\n\t\t\t\t// need to check the pressure data to see if it's a pen or not.\n\n\t\t\t\tconst { points } = shape.props.segments[0]\n\n\t\t\t\tif (points.length === 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...shape,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t...shape.props,\n\t\t\t\t\t\t\tisPen: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet isPen = !(points[0].z === 0 || points[0].z === 0.5)\n\n\t\t\t\tif (points[1]) {\n\t\t\t\t\t// Double check if we have a second point (we probably should)\n\t\t\t\t\tisPen = isPen && !(points[1].z === 0 || points[1].z === 0.5)\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...shape,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...shape.props,\n\t\t\t\t\t\tisPen,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (shape) => {\n\t\t\t\tconst { isPen: _isPen, ...propsWithOutIsPen } = shape.props\n\t\t\t\treturn {\n\t\t\t\t\t...shape,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...propsWithOutIsPen,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,sBAAkB;AAClB,4BAAoC;AACpC,0BAAkC;AAClC,yBAAiC;AACjC,yBAAiC;AACjC,yBAAiC;AAG1B,MAAM,mBAAmB,kBAAE,OAAO;AAAA,EACxC,MAAM,kBAAE,YAAY,QAAQ,UAAU;AAAA,EACtC,QAAQ,kBAAE,QAAQ,yCAAmB;AACtC,CAAC;AAMM,MAAM,iBAAiB;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU,kBAAE,QAAQ,gBAAgB;AAAA,EACpC,YAAY,kBAAE;AAAA,EACd,UAAU,kBAAE;AAAA,EACZ,OAAO,kBAAE;AACV;AAQA,MAAM,WAAW;AAAA,EAChB,UAAU;AACX;AAGO,MAAM,0BAAsB,+BAAiB;AAAA,EACnD,gBAAgB,SAAS;AAAA,EACzB,WAAW;AAAA,IACV,CAAC,SAAS,QAAQ,GAAG;AAAA,MACpB,IAAI,CAAC,UAAU;AAMd,cAAM,EAAE,OAAO,IAAI,MAAM,MAAM,SAAS,CAAC;AAEzC,YAAI,OAAO,WAAW,GAAG;AACxB,iBAAO;AAAA,YACN,GAAG;AAAA,YACH,OAAO;AAAA,cACN,GAAG,MAAM;AAAA,cACT,OAAO;AAAA,YACR;AAAA,UACD;AAAA,QACD;AAEA,YAAI,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,EAAE,MAAM;AAEnD,YAAI,OAAO,CAAC,GAAG;AAEd,kBAAQ,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,EAAE,MAAM;AAAA,QACzD;AAEA,eAAO;AAAA,UACN,GAAG;AAAA,UACH,OAAO;AAAA,YACN,GAAG,MAAM;AAAA,YACT;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,MAAM,CAAC,UAAU;AAChB,cAAM,EAAE,OAAO,QAAQ,GAAG,kBAAkB,IAAI,MAAM;AACtD,eAAO;AAAA,UACN,GAAG;AAAA,UACH,OAAO;AAAA,YACN,GAAG;AAAA,UACJ;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|