@backmatter/core 0.0.45 → 0.0.47

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/core",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "Experimental Backmatter SDK. APIs will break. Not ready for production.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -13,6 +13,9 @@ export const BLOCK_GALLERY_PROPS_MESSAGE = "backmatter:block-gallery-props";
13
13
  /** Gallery → Studio: the editor asked to open one block example. */
14
14
  export const BLOCK_GALLERY_OPEN_MESSAGE = "backmatter:block-gallery-open";
15
15
 
16
+ /** Gallery → Studio: the single view's content is this many CSS pixels tall. */
17
+ export const BLOCK_GALLERY_SIZE_MESSAGE = "backmatter:block-gallery-size";
18
+
16
19
  const MAX_BLOCKS = 100;
17
20
  const BLOCK_NAME = /^[A-Z][A-Za-z0-9]*$/;
18
21
 
@@ -30,6 +33,11 @@ export type BlockGalleryPropsMessage = {
30
33
  props: Record<string, unknown>;
31
34
  };
32
35
 
36
+ export type BlockGallerySizeMessage = {
37
+ type: typeof BLOCK_GALLERY_SIZE_MESSAGE;
38
+ height: number;
39
+ };
40
+
33
41
  export type BlockGalleryOpenMessage = {
34
42
  type: typeof BLOCK_GALLERY_OPEN_MESSAGE;
35
43
  block: string;
@@ -122,3 +130,13 @@ export function isBlockGalleryOpenMessage(value: unknown): value is BlockGallery
122
130
  value.example >= 0
123
131
  );
124
132
  }
133
+
134
+ export function isBlockGallerySizeMessage(value: unknown): value is BlockGallerySizeMessage {
135
+ return (
136
+ isPlainObject(value) &&
137
+ value.type === BLOCK_GALLERY_SIZE_MESSAGE &&
138
+ typeof value.height === "number" &&
139
+ Number.isFinite(value.height) &&
140
+ value.height >= 0
141
+ );
142
+ }
package/src/index.ts CHANGED
@@ -247,13 +247,16 @@ export {
247
247
  BLOCK_GALLERY_PATH,
248
248
  BLOCK_GALLERY_PROPS_MESSAGE,
249
249
  BLOCK_GALLERY_OPEN_MESSAGE,
250
+ BLOCK_GALLERY_SIZE_MESSAGE,
250
251
  blockGalleryPath,
251
252
  readBlockGalleryQuery,
252
253
  isBlockGalleryPath,
253
254
  isBlockGallerySegments,
254
255
  isBlockGalleryPropsMessage,
255
256
  isBlockGalleryOpenMessage,
257
+ isBlockGallerySizeMessage,
256
258
  type BlockGalleryQuery,
257
259
  type BlockGalleryPropsMessage,
258
260
  type BlockGalleryOpenMessage,
261
+ type BlockGallerySizeMessage,
259
262
  } from "./block-gallery";