@mocanvas/compat 4.10.0 → 4.10.1
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/dist/index.d.ts +17 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,22 @@ import { BindingUtilConstructor, ShapeUtilConstructor, ArrowBinding, ArrowBindin
|
|
|
3
3
|
export * from '@mocanvas/mocanvas';
|
|
4
4
|
import { SerializedStore } from '@mocanvas/store';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Warn when `compat.css` is missing, for an app that is migrating.
|
|
8
|
+
*
|
|
9
|
+
* The tldraw-compat rules are `calc()` over `--tl-*` variables that this
|
|
10
|
+
* package's stylesheet declares. Without it they resolve to nothing and the
|
|
11
|
+
* `calc()`s collapse: type that should scale with the camera comes out at a
|
|
12
|
+
* constant, tiny size. Nothing throws, so it reads as a rendering bug in the
|
|
13
|
+
* library rather than a missing import — which is exactly how it was found.
|
|
14
|
+
*
|
|
15
|
+
* Opt-in rather than automatic, and not in `<Mocanvas>`: most consumers never
|
|
16
|
+
* load `compat.css` and should not be told to. Call this from a migrating
|
|
17
|
+
* app's dev entry point. Returns whether the stylesheet was found, so a test
|
|
18
|
+
* can assert on it; warns only in development.
|
|
19
|
+
*/
|
|
20
|
+
declare function assertCompatStylesLoaded(): boolean;
|
|
21
|
+
|
|
6
22
|
type TLRecord = EditorRecord;
|
|
7
23
|
type TLStore = EditorStore;
|
|
8
24
|
type TLStoreSnapshot = EditorStoreSnapshot;
|
|
@@ -124,4 +140,4 @@ type TLExternalContent = ExternalContent;
|
|
|
124
140
|
type TLResizeShapeOptions = ResizeShapeOptions;
|
|
125
141
|
type TLSvgExportOptions = SvgExportOptions;
|
|
126
142
|
|
|
127
|
-
export { type TLAnyBindingUtilConstructor, type TLAnyShapeUtilConstructor, type TLArrowBinding, type TLArrowBindingProps, type TLArrowBindings, type TLArrowShape, type TLArrowShapeProps, type TLAsset, type TLAssetContext, type TLAssetId, type TLAssetPartial, type TLAssetStore, type TLBaseAsset, type TLBaseBinding, type TLBaseEventInfo, type TLBaseShape, type TLBinding, type TLBindingCreate, type TLBindingId, type TLBindingUtilConstructor, type TLBookmarkAsset, type TLBookmarkShape, type TLBookmarkShapeProps, type TLCamera, type TLCameraId, type TLCancelEventInfo, type TLClickEventInfo, type TLCompleteEventInfo, type TLCurrentUser, TLDOCUMENT_ID, type TLDefaultColorStyle, type TLDefaultDashStyle, type TLDefaultFillStyle, type TLDefaultFontStyle, type TLDefaultHorizontalAlignStyle, type TLDefaultSizeStyle, type TLDefaultVerticalAlignStyle, type TLDocument, type TLDrawShape, type TLDrawShapeProps, type TLEditor, type TLEditorOptions, type TLEmbedDefinition, type TLEmbedShape, type TLEmbedShapeProps, type TLEventHandlers, type TLEventInfo, type TLExternalContent, type TLFrameShape, type TLFrameShapeProps, type TLGeoShape, type TLGeoShapeGeoStyle, type TLGeoShapeProps, type TLGroupShape, type TLHandle, TLINSTANCE_ID, type TLImageAsset, type TLImageShape, type TLImageShapeProps, type TLInstance, type TLInstanceId, type TLInstancePageState, type TLInstancePageStateId, type TLInstancePresence, type TLInstancePresenceID, type TLInterruptEventInfo, type TLKeyboardEventInfo, type TLKeyboardEventName, type TLLineShape, type TLLineShapeProps, type TLNoteShape, type TLNoteShapeProps, type TLPage, type TLPageId, type TLParentId, type TLPinchEventInfo, type TLPointerEventInfo, type TLPointerEventName, type TLPropsMigration, type TLPropsMigrations, type TLRecord, type TLResizeInfo, type TLResizeShapeOptions, type TLRichText, type TLScribble, type TLSelectionHandle, type TLSerializedStore, type TLShape, type TLShapeCreate, type TLShapeId, type TLShapePartial, type TLShapeUtilConstructor, type TLStateNodeConstructor, type TLStore, type TLStoreSchema, type TLStoreSnapshot, type TLSvgExportOptions, type TLTextShape, type TLTextShapeProps, type TLTickEventInfo, type TLUnknownBinding, type TLUnknownShape, type TLUser, type TLUserId, type TLUserPreferences, type TLUserStore, type TLVideoAsset, type TLVideoShape, type TLVideoShapeProps, type TLWheelEventInfo, Tldraw, TldrawEditor, type TldrawEditorStoreProps, type TldrawProps, createTLSchema, createTLStore, useTldrawCurrentUser };
|
|
143
|
+
export { type TLAnyBindingUtilConstructor, type TLAnyShapeUtilConstructor, type TLArrowBinding, type TLArrowBindingProps, type TLArrowBindings, type TLArrowShape, type TLArrowShapeProps, type TLAsset, type TLAssetContext, type TLAssetId, type TLAssetPartial, type TLAssetStore, type TLBaseAsset, type TLBaseBinding, type TLBaseEventInfo, type TLBaseShape, type TLBinding, type TLBindingCreate, type TLBindingId, type TLBindingUtilConstructor, type TLBookmarkAsset, type TLBookmarkShape, type TLBookmarkShapeProps, type TLCamera, type TLCameraId, type TLCancelEventInfo, type TLClickEventInfo, type TLCompleteEventInfo, type TLCurrentUser, TLDOCUMENT_ID, type TLDefaultColorStyle, type TLDefaultDashStyle, type TLDefaultFillStyle, type TLDefaultFontStyle, type TLDefaultHorizontalAlignStyle, type TLDefaultSizeStyle, type TLDefaultVerticalAlignStyle, type TLDocument, type TLDrawShape, type TLDrawShapeProps, type TLEditor, type TLEditorOptions, type TLEmbedDefinition, type TLEmbedShape, type TLEmbedShapeProps, type TLEventHandlers, type TLEventInfo, type TLExternalContent, type TLFrameShape, type TLFrameShapeProps, type TLGeoShape, type TLGeoShapeGeoStyle, type TLGeoShapeProps, type TLGroupShape, type TLHandle, TLINSTANCE_ID, type TLImageAsset, type TLImageShape, type TLImageShapeProps, type TLInstance, type TLInstanceId, type TLInstancePageState, type TLInstancePageStateId, type TLInstancePresence, type TLInstancePresenceID, type TLInterruptEventInfo, type TLKeyboardEventInfo, type TLKeyboardEventName, type TLLineShape, type TLLineShapeProps, type TLNoteShape, type TLNoteShapeProps, type TLPage, type TLPageId, type TLParentId, type TLPinchEventInfo, type TLPointerEventInfo, type TLPointerEventName, type TLPropsMigration, type TLPropsMigrations, type TLRecord, type TLResizeInfo, type TLResizeShapeOptions, type TLRichText, type TLScribble, type TLSelectionHandle, type TLSerializedStore, type TLShape, type TLShapeCreate, type TLShapeId, type TLShapePartial, type TLShapeUtilConstructor, type TLStateNodeConstructor, type TLStore, type TLStoreSchema, type TLStoreSnapshot, type TLSvgExportOptions, type TLTextShape, type TLTextShapeProps, type TLTickEventInfo, type TLUnknownBinding, type TLUnknownShape, type TLUser, type TLUserId, type TLUserPreferences, type TLUserStore, type TLVideoAsset, type TLVideoShape, type TLVideoShapeProps, type TLWheelEventInfo, Tldraw, TldrawEditor, type TldrawEditorStoreProps, type TldrawProps, assertCompatStylesLoaded, createTLSchema, createTLStore, useTldrawCurrentUser };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,22 @@ import { DOCUMENT_ID, INSTANCE_ID, Mocanvas, Canvas, createSchema, createStore,
|
|
|
2
2
|
export * from '@mocanvas/mocanvas';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
|
+
function assertCompatStylesLoaded() {
|
|
6
|
+
if (typeof document === "undefined" || typeof getComputedStyle !== "function") return true;
|
|
7
|
+
const probe = document.createElement("div");
|
|
8
|
+
probe.className = "mocanvas";
|
|
9
|
+
probe.style.position = "absolute";
|
|
10
|
+
probe.style.visibility = "hidden";
|
|
11
|
+
document.body.appendChild(probe);
|
|
12
|
+
const loaded = getComputedStyle(probe).getPropertyValue("--tl-zoom").trim() !== "";
|
|
13
|
+
probe.remove();
|
|
14
|
+
if (!loaded && process.env["NODE_ENV"] !== "production") {
|
|
15
|
+
console.warn(
|
|
16
|
+
'[mocanvas/compat] compat.css is not loaded, so every --tl-* variable is empty and the rules that use them collapse. Add `import "@mocanvas/compat/compat.css"`.'
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return loaded;
|
|
20
|
+
}
|
|
5
21
|
var Tldraw = Mocanvas;
|
|
6
22
|
var TldrawEditor = Canvas;
|
|
7
23
|
var createTLStore = createStore;
|
|
@@ -10,6 +26,6 @@ var useTldrawCurrentUser = useCurrentUser;
|
|
|
10
26
|
var TLDOCUMENT_ID = DOCUMENT_ID;
|
|
11
27
|
var TLINSTANCE_ID = INSTANCE_ID;
|
|
12
28
|
|
|
13
|
-
export { TLDOCUMENT_ID, TLINSTANCE_ID, Tldraw, TldrawEditor, createTLSchema, createTLStore, useTldrawCurrentUser };
|
|
29
|
+
export { TLDOCUMENT_ID, TLINSTANCE_ID, Tldraw, TldrawEditor, assertCompatStylesLoaded, createTLSchema, createTLStore, useTldrawCurrentUser };
|
|
14
30
|
//# sourceMappingURL=index.js.map
|
|
15
31
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAsLO,IAAM,MAAA,GAAS;AAEf,IAAM,YAAA,GAAe;AACrB,IAAM,aAAA,GAAgB;AACtB,IAAM,cAAA,GAAiB;AAsBvB,IAAM,oBAAA,GAAuB;AAqD7B,IAAM,aAAA,GAAgB;AACtB,IAAM,aAAA,GAAgB","file":"index.js","sourcesContent":["/**\n * Migration aliases. Projects moving from a `TL`-prefixed API can switch their\n * imports to `@mocanvas/compat` first and rename at their own pace.\n *\n * Every alias here is a pure re-export; there is no runtime code.\n */\nexport * from \"@mocanvas/mocanvas\"\n\nimport type {\n ArrowBinding,\n ArrowShape,\n Camera,\n CameraId,\n ClickEventInfo,\n Document,\n DrawShape,\n EditorRecord,\n EditorStore,\n EditorStoreSnapshot,\n EventInfo,\n FrameShape,\n GeoShape,\n GroupShape,\n Instance,\n InstancePageState,\n KeyboardEventInfo,\n LineShape,\n NoteShape,\n Page,\n PageId,\n ParentId,\n PointerEventInfo,\n Shape,\n ShapeCreate,\n ShapeHandle,\n ShapeId,\n ShapePartial,\n ShapeUtilConstructor,\n StateNodeConstructor,\n TextShape,\n UnknownBinding,\n UnknownShape,\n WheelEventInfo,\n BindingId,\n BindingUtilConstructor,\n SelectionHandle,\n ResizeInfo,\n DefaultColorStyle as DefaultColorStyleValue,\n DefaultDashStyle as DefaultDashStyleValue,\n DefaultFillStyle as DefaultFillStyleValue,\n DefaultFontStyle as DefaultFontStyleValue,\n DefaultSizeStyle as DefaultSizeStyleValue,\n DefaultHorizontalAlignStyle as DefaultHorizontalAlignStyleValue,\n DefaultVerticalAlignStyle as DefaultVerticalAlignStyleValue,\n GeoShapeKind,\n} from \"@mocanvas/mocanvas\"\nimport type {\n Asset,\n AssetId,\n AssetStore,\n BaseBinding,\n BaseShape,\n Binding,\n CurrentUser,\n EmbedDefinition,\n InstancePresence,\n InstancePresenceId,\n User,\n UserPreferencesState,\n UserStore,\n ArrowBindingProps,\n ArrowBindings,\n ArrowShapeProps,\n AssetContext,\n AssetPartial,\n BaseAsset,\n BaseEventInfo,\n BindingCreate,\n BookmarkAsset,\n BookmarkShape,\n BookmarkShapeProps,\n CancelEventInfo,\n CompleteEventInfo,\n DrawShapeProps,\n EditorOptions,\n EditorStoreProps,\n EmbedShape,\n EmbedShapeProps,\n EventHandlers,\n ExternalContent,\n FrameShapeProps,\n GeoShapeProps,\n ImageAsset,\n ImageShape,\n ImageShapeProps,\n InstanceId,\n InstancePageStateId,\n InterruptEventInfo,\n KeyboardEventName,\n LineShapeProps,\n MocanvasProps,\n NoteShapeProps,\n PinchEventInfo,\n PointerEventName,\n PropsMigration,\n PropsMigrations,\n ResizeShapeOptions,\n RichText,\n Scribble,\n SvgExportOptions,\n TLSchema,\n TextShapeProps,\n TickEventInfo,\n UserId,\n VideoAsset,\n VideoShape,\n VideoShapeProps,\n} from \"@mocanvas/mocanvas\"\nimport { Mocanvas, createSchema, createStore, Canvas, Editor, useCurrentUser, DOCUMENT_ID, INSTANCE_ID } from \"@mocanvas/mocanvas\"\nimport type { SerializedStore } from \"@mocanvas/store\"\n\n// ---- records ----------------------------------------------------------------\nexport type TLRecord = EditorRecord\nexport type TLStore = EditorStore\nexport type TLStoreSnapshot = EditorStoreSnapshot\n// `never` as the default so a bare `TLShape` is `Shape` itself — the union of\n// registered types. Spelling the default `string` collapsed it to one\n// non-union type and `shape.type === \"note\"` narrowed nothing.\nexport type TLShape<Type extends string = never> = [Type] extends [never] ? Shape : Shape<Type>\nexport type TLUnknownShape = UnknownShape\nexport type TLShapeId = ShapeId\nexport type TLParentId = ParentId\nexport type TLShapePartial<T extends UnknownShape = UnknownShape> = ShapePartial<T>\nexport type TLShapeCreate<T extends UnknownShape = UnknownShape> = ShapeCreate<T>\nexport type TLPage = Page\nexport type TLPageId = PageId\nexport type TLDocument = Document\nexport type TLCamera = Camera\nexport type TLCameraId = CameraId\nexport type TLInstance = Instance\nexport type TLInstancePageState = InstancePageState\nexport type TLBinding<Type extends string = never> = [Type] extends [never] ? Binding : Binding<Type>\nexport type TLBindingId = BindingId\nexport type TLArrowBinding = ArrowBinding\n\n// ---- default shapes ---------------------------------------------------------\nexport type TLGeoShape = GeoShape\nexport type TLDrawShape = DrawShape\nexport type TLLineShape = LineShape\nexport type TLArrowShape = ArrowShape\nexport type TLTextShape = TextShape\nexport type TLNoteShape = NoteShape\nexport type TLFrameShape = FrameShape\nexport type TLGroupShape = GroupShape\nexport type TLGeoShapeGeoStyle = GeoShapeKind\n\n// ---- styles (value types) ---------------------------------------------------\nexport type TLDefaultColorStyle = DefaultColorStyleValue\nexport type TLDefaultDashStyle = DefaultDashStyleValue\nexport type TLDefaultFillStyle = DefaultFillStyleValue\nexport type TLDefaultFontStyle = DefaultFontStyleValue\nexport type TLDefaultSizeStyle = DefaultSizeStyleValue\nexport type TLDefaultHorizontalAlignStyle = DefaultHorizontalAlignStyleValue\nexport type TLDefaultVerticalAlignStyle = DefaultVerticalAlignStyleValue\n\n// ---- events / tools ---------------------------------------------------------\nexport type TLEventInfo = EventInfo\nexport type TLPointerEventInfo = PointerEventInfo\nexport type TLClickEventInfo = ClickEventInfo\nexport type TLKeyboardEventInfo = KeyboardEventInfo\nexport type TLWheelEventInfo = WheelEventInfo\nexport type TLHandle = ShapeHandle\nexport type TLSelectionHandle = SelectionHandle\nexport type TLResizeInfo<T extends UnknownShape> = ResizeInfo<T>\nexport type TLShapeUtilConstructor<T extends UnknownShape = UnknownShape> = ShapeUtilConstructor<T>\nexport type TLStateNodeConstructor = StateNodeConstructor\nexport type TLBindingUtilConstructor = BindingUtilConstructor\nexport type TLAnyShapeUtilConstructor = ShapeUtilConstructor\nexport type TLAnyBindingUtilConstructor = BindingUtilConstructor\n\n// ---- values -----------------------------------------------------------------\n/** The batteries-included component. */\nexport const Tldraw = Mocanvas\n/** The bare canvas (bring your own shapes, tools and UI). */\nexport const TldrawEditor = Canvas\nexport const createTLStore = createStore\nexport const createTLSchema = createSchema\nexport type TLEditor = Editor\n\n// ---- custom shape and binding authoring -------------------------------------\n// The two base types a custom shape/binding is declared with. `Props` is the\n// object registered in `TLGlobalShapePropsMap` / `TLGlobalBindingPropsMap`.\nexport type TLBaseShape<Type extends string, Props extends object> = BaseShape<Type, Props>\nexport type TLBaseBinding<Type extends string, Props extends object> = BaseBinding<Type, Props>\n\n// ---- assets -----------------------------------------------------------------\nexport type TLAsset = Asset\nexport type TLAssetId = AssetId\nexport type TLAssetStore = AssetStore\n\n// ---- users and presence -----------------------------------------------------\nexport type TLUser = User\nexport type TLUserStore = UserStore\nexport type TLCurrentUser = CurrentUser\nexport type TLUserPreferences = UserPreferencesState\nexport type TLInstancePresence = InstancePresence\nexport type TLInstancePresenceID = InstancePresenceId\n/** The `Tldraw`-spelled identity hook. */\nexport const useTldrawCurrentUser = useCurrentUser\n\n// ---- embeds -----------------------------------------------------------------\nexport type TLEmbedDefinition = EmbedDefinition\n\n\n// ---- the documented `TL*` spellings ------------------------------------------\n//\n// Everything below is a name tldraw's reference documents and this package did\n// not carry. Each is a pure alias of a type mocanvas already exports unprefixed:\n// the capability was never missing, only the spelling a migrating codebase\n// imports it by. Kept in step by `pnpm --filter bench api-coverage`.\n\n// ---- events the tools and the editor emit ------------------------------------\nexport type TLBaseEventInfo = BaseEventInfo\nexport type TLCancelEventInfo = CancelEventInfo\nexport type TLCompleteEventInfo = CompleteEventInfo\nexport type TLEventHandlers = EventHandlers\nexport type TLInterruptEventInfo = InterruptEventInfo\nexport type TLKeyboardEventName = KeyboardEventName\nexport type TLPinchEventInfo = PinchEventInfo\nexport type TLPointerEventName = PointerEventName\nexport type TLTickEventInfo = TickEventInfo\n\n// ---- per-shape props ---------------------------------------------------------\nexport type TLArrowShapeProps = ArrowShapeProps\nexport type TLBookmarkShapeProps = BookmarkShapeProps\nexport type TLDrawShapeProps = DrawShapeProps\nexport type TLEmbedShapeProps = EmbedShapeProps\nexport type TLFrameShapeProps = FrameShapeProps\nexport type TLGeoShapeProps = GeoShapeProps\nexport type TLImageShapeProps = ImageShapeProps\nexport type TLLineShapeProps = LineShapeProps\nexport type TLNoteShapeProps = NoteShapeProps\nexport type TLTextShapeProps = TextShapeProps\nexport type TLVideoShapeProps = VideoShapeProps\n\n// ---- shapes ------------------------------------------------------------------\nexport type TLBookmarkShape = BookmarkShape\nexport type TLEmbedShape = EmbedShape\nexport type TLImageShape = ImageShape\nexport type TLVideoShape = VideoShape\n\n// ---- assets ------------------------------------------------------------------\nexport type TLAssetContext = AssetContext\nexport type TLAssetPartial<A extends Asset = Asset> = AssetPartial<A>\nexport type TLBaseAsset<Type extends string, Props extends object> = BaseAsset<Type, Props>\nexport type TLBookmarkAsset = BookmarkAsset\nexport type TLImageAsset = ImageAsset\nexport type TLVideoAsset = VideoAsset\n\n// ---- records and their ids ---------------------------------------------------\nexport type TLBindingCreate<B extends UnknownBinding = UnknownBinding> = BindingCreate<B>\nexport const TLDOCUMENT_ID = DOCUMENT_ID\nexport const TLINSTANCE_ID = INSTANCE_ID\nexport type TLInstanceId = InstanceId\nexport type TLInstancePageStateId = InstancePageStateId\nexport type TLPropsMigration = PropsMigration\nexport type TLPropsMigrations = PropsMigrations\nexport type TLRichText = RichText\nexport type TLScribble = Scribble\nexport type TLSerializedStore = SerializedStore<EditorRecord>\nexport type TLStoreSchema = TLSchema\nexport type TLUnknownBinding = UnknownBinding\nexport type TLUserId = UserId\n\n// ---- options, props and the rest ----------------------------------------\nexport type TLArrowBindingProps = ArrowBindingProps\nexport type TLArrowBindings = ArrowBindings\nexport type TldrawEditorStoreProps = EditorStoreProps\nexport type TldrawProps = MocanvasProps\nexport type TLEditorOptions = EditorOptions\nexport type TLExternalContent = ExternalContent\nexport type TLResizeShapeOptions = ResizeShapeOptions\nexport type TLSvgExportOptions = SvgExportOptions\n\n// `TldrawUiMenuItem` used to be aliased here, back when the flagship only had\n// `MocanvasUiMenuItem`. The UI layer now exports the documented name itself, and\n// an alias here would shadow it — so there is nothing to add.\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAuBO,SAAS,wBAAA,GAAoC;AAClD,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,IAAe,OAAO,gBAAA,KAAqB,YAAY,OAAO,IAAA;AACtF,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AAC1C,EAAA,KAAA,CAAM,SAAA,GAAY,UAAA;AAClB,EAAA,KAAA,CAAM,MAAM,QAAA,GAAW,UAAA;AACvB,EAAA,KAAA,CAAM,MAAM,UAAA,GAAa,QAAA;AACzB,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,KAAK,CAAA;AAC/B,EAAA,MAAM,MAAA,GAAS,iBAAiB,KAAK,CAAA,CAAE,iBAAiB,WAAW,CAAA,CAAE,MAAK,KAAM,EAAA;AAChF,EAAA,KAAA,CAAM,MAAA,EAAO;AACb,EAAA,IAAI,CAAC,MAAA,IAAU,OAAA,CAAQ,GAAA,CAAI,UAAU,MAAM,YAAA,EAAc;AAEvD,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,KAEF;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AAgLO,IAAM,MAAA,GAAS;AAEf,IAAM,YAAA,GAAe;AACrB,IAAM,aAAA,GAAgB;AACtB,IAAM,cAAA,GAAiB;AAsBvB,IAAM,oBAAA,GAAuB;AAqD7B,IAAM,aAAA,GAAgB;AACtB,IAAM,aAAA,GAAgB","file":"index.js","sourcesContent":["/**\n * Migration aliases. Projects moving from a `TL`-prefixed API can switch their\n * imports to `@mocanvas/compat` first and rename at their own pace.\n *\n * Every alias here is a pure re-export. The one function with a body,\n * `assertCompatStylesLoaded`, is opt-in and does nothing unless called.\n */\nexport * from \"@mocanvas/mocanvas\"\n\n/**\n * Warn when `compat.css` is missing, for an app that is migrating.\n *\n * The tldraw-compat rules are `calc()` over `--tl-*` variables that this\n * package's stylesheet declares. Without it they resolve to nothing and the\n * `calc()`s collapse: type that should scale with the camera comes out at a\n * constant, tiny size. Nothing throws, so it reads as a rendering bug in the\n * library rather than a missing import — which is exactly how it was found.\n *\n * Opt-in rather than automatic, and not in `<Mocanvas>`: most consumers never\n * load `compat.css` and should not be told to. Call this from a migrating\n * app's dev entry point. Returns whether the stylesheet was found, so a test\n * can assert on it; warns only in development.\n */\nexport function assertCompatStylesLoaded(): boolean {\n if (typeof document === \"undefined\" || typeof getComputedStyle !== \"function\") return true\n const probe = document.createElement(\"div\")\n probe.className = \"mocanvas\"\n probe.style.position = \"absolute\"\n probe.style.visibility = \"hidden\"\n document.body.appendChild(probe)\n const loaded = getComputedStyle(probe).getPropertyValue(\"--tl-zoom\").trim() !== \"\"\n probe.remove()\n if (!loaded && process.env[\"NODE_ENV\"] !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n \"[mocanvas/compat] compat.css is not loaded, so every --tl-* variable is empty and the rules that \" +\n 'use them collapse. Add `import \"@mocanvas/compat/compat.css\"`.',\n )\n }\n return loaded\n}\n\nimport type {\n ArrowBinding,\n ArrowShape,\n Camera,\n CameraId,\n ClickEventInfo,\n Document,\n DrawShape,\n EditorRecord,\n EditorStore,\n EditorStoreSnapshot,\n EventInfo,\n FrameShape,\n GeoShape,\n GroupShape,\n Instance,\n InstancePageState,\n KeyboardEventInfo,\n LineShape,\n NoteShape,\n Page,\n PageId,\n ParentId,\n PointerEventInfo,\n Shape,\n ShapeCreate,\n ShapeHandle,\n ShapeId,\n ShapePartial,\n ShapeUtilConstructor,\n StateNodeConstructor,\n TextShape,\n UnknownBinding,\n UnknownShape,\n WheelEventInfo,\n BindingId,\n BindingUtilConstructor,\n SelectionHandle,\n ResizeInfo,\n DefaultColorStyle as DefaultColorStyleValue,\n DefaultDashStyle as DefaultDashStyleValue,\n DefaultFillStyle as DefaultFillStyleValue,\n DefaultFontStyle as DefaultFontStyleValue,\n DefaultSizeStyle as DefaultSizeStyleValue,\n DefaultHorizontalAlignStyle as DefaultHorizontalAlignStyleValue,\n DefaultVerticalAlignStyle as DefaultVerticalAlignStyleValue,\n GeoShapeKind,\n} from \"@mocanvas/mocanvas\"\nimport type {\n Asset,\n AssetId,\n AssetStore,\n BaseBinding,\n BaseShape,\n Binding,\n CurrentUser,\n EmbedDefinition,\n InstancePresence,\n InstancePresenceId,\n User,\n UserPreferencesState,\n UserStore,\n ArrowBindingProps,\n ArrowBindings,\n ArrowShapeProps,\n AssetContext,\n AssetPartial,\n BaseAsset,\n BaseEventInfo,\n BindingCreate,\n BookmarkAsset,\n BookmarkShape,\n BookmarkShapeProps,\n CancelEventInfo,\n CompleteEventInfo,\n DrawShapeProps,\n EditorOptions,\n EditorStoreProps,\n EmbedShape,\n EmbedShapeProps,\n EventHandlers,\n ExternalContent,\n FrameShapeProps,\n GeoShapeProps,\n ImageAsset,\n ImageShape,\n ImageShapeProps,\n InstanceId,\n InstancePageStateId,\n InterruptEventInfo,\n KeyboardEventName,\n LineShapeProps,\n MocanvasProps,\n NoteShapeProps,\n PinchEventInfo,\n PointerEventName,\n PropsMigration,\n PropsMigrations,\n ResizeShapeOptions,\n RichText,\n Scribble,\n SvgExportOptions,\n TLSchema,\n TextShapeProps,\n TickEventInfo,\n UserId,\n VideoAsset,\n VideoShape,\n VideoShapeProps,\n} from \"@mocanvas/mocanvas\"\nimport { Mocanvas, createSchema, createStore, Canvas, Editor, useCurrentUser, DOCUMENT_ID, INSTANCE_ID } from \"@mocanvas/mocanvas\"\nimport type { SerializedStore } from \"@mocanvas/store\"\n\n// ---- records ----------------------------------------------------------------\nexport type TLRecord = EditorRecord\nexport type TLStore = EditorStore\nexport type TLStoreSnapshot = EditorStoreSnapshot\n// `never` as the default so a bare `TLShape` is `Shape` itself — the union of\n// registered types. Spelling the default `string` collapsed it to one\n// non-union type and `shape.type === \"note\"` narrowed nothing.\nexport type TLShape<Type extends string = never> = [Type] extends [never] ? Shape : Shape<Type>\nexport type TLUnknownShape = UnknownShape\nexport type TLShapeId = ShapeId\nexport type TLParentId = ParentId\nexport type TLShapePartial<T extends UnknownShape = UnknownShape> = ShapePartial<T>\nexport type TLShapeCreate<T extends UnknownShape = UnknownShape> = ShapeCreate<T>\nexport type TLPage = Page\nexport type TLPageId = PageId\nexport type TLDocument = Document\nexport type TLCamera = Camera\nexport type TLCameraId = CameraId\nexport type TLInstance = Instance\nexport type TLInstancePageState = InstancePageState\nexport type TLBinding<Type extends string = never> = [Type] extends [never] ? Binding : Binding<Type>\nexport type TLBindingId = BindingId\nexport type TLArrowBinding = ArrowBinding\n\n// ---- default shapes ---------------------------------------------------------\nexport type TLGeoShape = GeoShape\nexport type TLDrawShape = DrawShape\nexport type TLLineShape = LineShape\nexport type TLArrowShape = ArrowShape\nexport type TLTextShape = TextShape\nexport type TLNoteShape = NoteShape\nexport type TLFrameShape = FrameShape\nexport type TLGroupShape = GroupShape\nexport type TLGeoShapeGeoStyle = GeoShapeKind\n\n// ---- styles (value types) ---------------------------------------------------\nexport type TLDefaultColorStyle = DefaultColorStyleValue\nexport type TLDefaultDashStyle = DefaultDashStyleValue\nexport type TLDefaultFillStyle = DefaultFillStyleValue\nexport type TLDefaultFontStyle = DefaultFontStyleValue\nexport type TLDefaultSizeStyle = DefaultSizeStyleValue\nexport type TLDefaultHorizontalAlignStyle = DefaultHorizontalAlignStyleValue\nexport type TLDefaultVerticalAlignStyle = DefaultVerticalAlignStyleValue\n\n// ---- events / tools ---------------------------------------------------------\nexport type TLEventInfo = EventInfo\nexport type TLPointerEventInfo = PointerEventInfo\nexport type TLClickEventInfo = ClickEventInfo\nexport type TLKeyboardEventInfo = KeyboardEventInfo\nexport type TLWheelEventInfo = WheelEventInfo\nexport type TLHandle = ShapeHandle\nexport type TLSelectionHandle = SelectionHandle\nexport type TLResizeInfo<T extends UnknownShape> = ResizeInfo<T>\nexport type TLShapeUtilConstructor<T extends UnknownShape = UnknownShape> = ShapeUtilConstructor<T>\nexport type TLStateNodeConstructor = StateNodeConstructor\nexport type TLBindingUtilConstructor = BindingUtilConstructor\nexport type TLAnyShapeUtilConstructor = ShapeUtilConstructor\nexport type TLAnyBindingUtilConstructor = BindingUtilConstructor\n\n// ---- values -----------------------------------------------------------------\n/** The batteries-included component. */\nexport const Tldraw = Mocanvas\n/** The bare canvas (bring your own shapes, tools and UI). */\nexport const TldrawEditor = Canvas\nexport const createTLStore = createStore\nexport const createTLSchema = createSchema\nexport type TLEditor = Editor\n\n// ---- custom shape and binding authoring -------------------------------------\n// The two base types a custom shape/binding is declared with. `Props` is the\n// object registered in `TLGlobalShapePropsMap` / `TLGlobalBindingPropsMap`.\nexport type TLBaseShape<Type extends string, Props extends object> = BaseShape<Type, Props>\nexport type TLBaseBinding<Type extends string, Props extends object> = BaseBinding<Type, Props>\n\n// ---- assets -----------------------------------------------------------------\nexport type TLAsset = Asset\nexport type TLAssetId = AssetId\nexport type TLAssetStore = AssetStore\n\n// ---- users and presence -----------------------------------------------------\nexport type TLUser = User\nexport type TLUserStore = UserStore\nexport type TLCurrentUser = CurrentUser\nexport type TLUserPreferences = UserPreferencesState\nexport type TLInstancePresence = InstancePresence\nexport type TLInstancePresenceID = InstancePresenceId\n/** The `Tldraw`-spelled identity hook. */\nexport const useTldrawCurrentUser = useCurrentUser\n\n// ---- embeds -----------------------------------------------------------------\nexport type TLEmbedDefinition = EmbedDefinition\n\n\n// ---- the documented `TL*` spellings ------------------------------------------\n//\n// Everything below is a name tldraw's reference documents and this package did\n// not carry. Each is a pure alias of a type mocanvas already exports unprefixed:\n// the capability was never missing, only the spelling a migrating codebase\n// imports it by. Kept in step by `pnpm --filter bench api-coverage`.\n\n// ---- events the tools and the editor emit ------------------------------------\nexport type TLBaseEventInfo = BaseEventInfo\nexport type TLCancelEventInfo = CancelEventInfo\nexport type TLCompleteEventInfo = CompleteEventInfo\nexport type TLEventHandlers = EventHandlers\nexport type TLInterruptEventInfo = InterruptEventInfo\nexport type TLKeyboardEventName = KeyboardEventName\nexport type TLPinchEventInfo = PinchEventInfo\nexport type TLPointerEventName = PointerEventName\nexport type TLTickEventInfo = TickEventInfo\n\n// ---- per-shape props ---------------------------------------------------------\nexport type TLArrowShapeProps = ArrowShapeProps\nexport type TLBookmarkShapeProps = BookmarkShapeProps\nexport type TLDrawShapeProps = DrawShapeProps\nexport type TLEmbedShapeProps = EmbedShapeProps\nexport type TLFrameShapeProps = FrameShapeProps\nexport type TLGeoShapeProps = GeoShapeProps\nexport type TLImageShapeProps = ImageShapeProps\nexport type TLLineShapeProps = LineShapeProps\nexport type TLNoteShapeProps = NoteShapeProps\nexport type TLTextShapeProps = TextShapeProps\nexport type TLVideoShapeProps = VideoShapeProps\n\n// ---- shapes ------------------------------------------------------------------\nexport type TLBookmarkShape = BookmarkShape\nexport type TLEmbedShape = EmbedShape\nexport type TLImageShape = ImageShape\nexport type TLVideoShape = VideoShape\n\n// ---- assets ------------------------------------------------------------------\nexport type TLAssetContext = AssetContext\nexport type TLAssetPartial<A extends Asset = Asset> = AssetPartial<A>\nexport type TLBaseAsset<Type extends string, Props extends object> = BaseAsset<Type, Props>\nexport type TLBookmarkAsset = BookmarkAsset\nexport type TLImageAsset = ImageAsset\nexport type TLVideoAsset = VideoAsset\n\n// ---- records and their ids ---------------------------------------------------\nexport type TLBindingCreate<B extends UnknownBinding = UnknownBinding> = BindingCreate<B>\nexport const TLDOCUMENT_ID = DOCUMENT_ID\nexport const TLINSTANCE_ID = INSTANCE_ID\nexport type TLInstanceId = InstanceId\nexport type TLInstancePageStateId = InstancePageStateId\nexport type TLPropsMigration = PropsMigration\nexport type TLPropsMigrations = PropsMigrations\nexport type TLRichText = RichText\nexport type TLScribble = Scribble\nexport type TLSerializedStore = SerializedStore<EditorRecord>\nexport type TLStoreSchema = TLSchema\nexport type TLUnknownBinding = UnknownBinding\nexport type TLUserId = UserId\n\n// ---- options, props and the rest ----------------------------------------\nexport type TLArrowBindingProps = ArrowBindingProps\nexport type TLArrowBindings = ArrowBindings\nexport type TldrawEditorStoreProps = EditorStoreProps\nexport type TldrawProps = MocanvasProps\nexport type TLEditorOptions = EditorOptions\nexport type TLExternalContent = ExternalContent\nexport type TLResizeShapeOptions = ResizeShapeOptions\nexport type TLSvgExportOptions = SvgExportOptions\n\n// `TldrawUiMenuItem` used to be aliased here, back when the flagship only had\n// `MocanvasUiMenuItem`. The UI layer now exports the documented name itself, and\n// an alias here would shadow it — so there is nothing to add.\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mocanvas/compat",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"description": "TL-prefixed aliases over the mocanvas API, for projects migrating an existing tldraw app.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Symbio Digital",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@mocanvas/
|
|
61
|
-
"@mocanvas/
|
|
62
|
-
"@mocanvas/
|
|
63
|
-
"@mocanvas/store": "4.10.
|
|
60
|
+
"@mocanvas/mocanvas": "4.10.1",
|
|
61
|
+
"@mocanvas/editor": "4.10.1",
|
|
62
|
+
"@mocanvas/state": "4.10.1",
|
|
63
|
+
"@mocanvas/store": "4.10.1"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/react": "^19.1.0",
|