@khanacademy/perseus-editor 30.2.1 → 30.3.0

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/es/index.js CHANGED
@@ -65,7 +65,7 @@ import xIcon from '@phosphor-icons/core/regular/x.svg';
65
65
  import checkIcon from '@phosphor-icons/core/bold/check-bold.svg';
66
66
  import minusCircleIcon from '@phosphor-icons/core/bold/minus-circle-bold.svg';
67
67
 
68
- const libName="@khanacademy/perseus-editor";const libVersion="30.2.1";addLibraryVersionToPerseusDebug(libName,libVersion);
68
+ const libName="@khanacademy/perseus-editor";const libVersion="30.3.0";addLibraryVersionToPerseusDebug(libName,libVersion);
69
69
 
70
70
  var jsxRuntime = {exports: {}};
71
71
 
package/dist/index.js CHANGED
@@ -132,7 +132,7 @@ var xIcon__default = /*#__PURE__*/_interopDefaultCompat(xIcon);
132
132
  var checkIcon__default = /*#__PURE__*/_interopDefaultCompat(checkIcon);
133
133
  var minusCircleIcon__default = /*#__PURE__*/_interopDefaultCompat(minusCircleIcon);
134
134
 
135
- const libName="@khanacademy/perseus-editor";const libVersion="30.2.1";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
135
+ const libName="@khanacademy/perseus-editor";const libVersion="30.3.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
136
136
 
137
137
  var jsxRuntime = {exports: {}};
138
138
 
@@ -5,6 +5,26 @@
5
5
  import type { APIOptions, DeviceType } from "@khanacademy/perseus";
6
6
  import type { Hint, PerseusArticle, PerseusItem } from "@khanacademy/perseus-core";
7
7
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
8
+ /**
9
+ * Constant identifier for all Perseus preview messages
10
+ */
11
+ export declare const PREVIEW_MESSAGE_SOURCE: "perseus-preview";
12
+ /**
13
+ * Base type for all preview messages
14
+ */
15
+ interface PreviewMessageBase {
16
+ source: typeof PREVIEW_MESSAGE_SOURCE;
17
+ }
18
+ /**
19
+ * Base type for messages with iframe ID
20
+ *
21
+ * Note: The ID is primarily used for debugging/logging purposes.
22
+ * Message routing is handled by event.source filtering in the hooks,
23
+ * not by comparing ID strings.
24
+ */
25
+ interface PreviewMessageWithId extends PreviewMessageBase {
26
+ id: string;
27
+ }
8
28
  /**
9
29
  * Data for question preview (full item with question, answer area, and hints)
10
30
  */
@@ -52,3 +72,39 @@ export type PreviewContent = {
52
72
  type: "article-all";
53
73
  data: ArticlePreviewData[];
54
74
  };
75
+ /**
76
+ * Message from parent sending content data to iframe
77
+ */
78
+ type PreviewDataMessage = PreviewMessageWithId & {
79
+ type: "content-data";
80
+ content: PreviewContent;
81
+ };
82
+ /**
83
+ * Union of all messages sent from parent to iframe
84
+ */
85
+ export type ParentToIframeMessage = PreviewDataMessage;
86
+ /**
87
+ * Message from iframe requesting data from parent
88
+ */
89
+ type PreviewDataRequestMessage = PreviewMessageWithId & {
90
+ type: "request-data";
91
+ };
92
+ /**
93
+ * Message from iframe reporting its content height
94
+ */
95
+ type PreviewHeightUpdateMessage = PreviewMessageWithId & {
96
+ type: "height-update";
97
+ height: number;
98
+ };
99
+ /**
100
+ * Message from iframe reporting lint warnings
101
+ */
102
+ type PreviewLintReportMessage = PreviewMessageWithId & {
103
+ type: "lint-report";
104
+ lintWarnings: ReadonlyArray<any>;
105
+ };
106
+ /**
107
+ * Union of all messages sent from iframe to parent
108
+ */
109
+ export type IframeToParentMessage = PreviewDataRequestMessage | PreviewHeightUpdateMessage | PreviewLintReportMessage;
110
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { IframeToParentMessage, ParentToIframeMessage } from "./message-types";
2
+ /**
3
+ * Type guard to check if an object is an {@link IframeToParentMessage} type.
4
+ *
5
+ * This validates that the message has the correct structure and source
6
+ * identifier to be from a Perseus preview iframe.
7
+ *
8
+ * @param message - Unknown message to validate
9
+ * @returns True if message is a valid {@link IframeToParentMessage}
10
+ */
11
+ export declare function isIframeToParentMessage(message: unknown): message is IframeToParentMessage;
12
+ /**
13
+ * Type guard to check if a message is from the Perseus preview system parent.
14
+ *
15
+ * This validates that the message has the correct structure and source
16
+ * identifier to be from a Perseus preview host.
17
+ *
18
+ * @param message - Unknown message to validate
19
+ * @returns True if message is a valid {@link ParentToIframeMessage}
20
+ */
21
+ export declare function isParentToIframeMessage(message: unknown): message is ParentToIframeMessage;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Perseus editors",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "30.2.1",
6
+ "version": "30.3.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -36,13 +36,13 @@
36
36
  "mafs": "^0.19.0",
37
37
  "tiny-invariant": "1.3.1",
38
38
  "@khanacademy/kas": "2.2.1",
39
- "@khanacademy/keypad-context": "3.2.42",
40
- "@khanacademy/kmath": "2.4.0",
41
- "@khanacademy/math-input": "26.4.13",
42
- "@khanacademy/perseus": "77.2.1",
43
- "@khanacademy/perseus-score": "8.6.0",
44
- "@khanacademy/perseus-core": "24.1.0",
45
- "@khanacademy/perseus-linter": "4.9.3",
39
+ "@khanacademy/keypad-context": "3.2.43",
40
+ "@khanacademy/kmath": "2.4.1",
41
+ "@khanacademy/math-input": "26.4.14",
42
+ "@khanacademy/perseus": "77.2.2",
43
+ "@khanacademy/perseus-core": "24.1.1",
44
+ "@khanacademy/perseus-linter": "4.9.4",
45
+ "@khanacademy/perseus-score": "8.6.1",
46
46
  "@khanacademy/perseus-utils": "2.1.5"
47
47
  },
48
48
  "devDependencies": {
@@ -74,8 +74,8 @@
74
74
  "react": "18.2.0",
75
75
  "react-dom": "18.2.0",
76
76
  "underscore": "1.4.4",
77
- "perseus-build-settings": "0.9.0",
78
- "jsdiff": "1.0.2"
77
+ "jsdiff": "1.0.2",
78
+ "perseus-build-settings": "0.9.0"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@khanacademy/mathjax-renderer": "^3.0.0",