@teachinglab/omd 0.5.6 → 0.5.8

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.
Files changed (60) hide show
  1. package/canvas/ui/toolbar.js +6 -9
  2. package/index.js +3 -0
  3. package/npm-docs/DOCUMENTATION_SUMMARY.md +220 -0
  4. package/npm-docs/README.md +251 -0
  5. package/npm-docs/api/api-reference.md +85 -0
  6. package/npm-docs/api/configuration-options.md +198 -0
  7. package/npm-docs/api/eventManager.md +83 -0
  8. package/npm-docs/api/expression-nodes.md +561 -0
  9. package/npm-docs/api/focusFrameManager.md +145 -0
  10. package/npm-docs/api/index.md +106 -0
  11. package/npm-docs/api/main.md +63 -0
  12. package/npm-docs/api/omdBinaryExpressionNode.md +86 -0
  13. package/npm-docs/api/omdCanvas.md +84 -0
  14. package/npm-docs/api/omdConfigManager.md +113 -0
  15. package/npm-docs/api/omdConstantNode.md +53 -0
  16. package/npm-docs/api/omdDisplay.md +87 -0
  17. package/npm-docs/api/omdEquationNode.md +174 -0
  18. package/npm-docs/api/omdEquationSequenceNode.md +259 -0
  19. package/npm-docs/api/omdEquationStack.md +193 -0
  20. package/npm-docs/api/omdFunctionNode.md +83 -0
  21. package/npm-docs/api/omdGroupNode.md +79 -0
  22. package/npm-docs/api/omdHelpers.md +88 -0
  23. package/npm-docs/api/omdLeafNode.md +86 -0
  24. package/npm-docs/api/omdNode.md +202 -0
  25. package/npm-docs/api/omdOperationDisplayNode.md +118 -0
  26. package/npm-docs/api/omdOperatorNode.md +92 -0
  27. package/npm-docs/api/omdParenthesisNode.md +134 -0
  28. package/npm-docs/api/omdPopup.md +192 -0
  29. package/npm-docs/api/omdPowerNode.md +132 -0
  30. package/npm-docs/api/omdRationalNode.md +145 -0
  31. package/npm-docs/api/omdSequenceNode.md +128 -0
  32. package/npm-docs/api/omdSimplification.md +79 -0
  33. package/npm-docs/api/omdSqrtNode.md +144 -0
  34. package/npm-docs/api/omdStepVisualizer.md +147 -0
  35. package/npm-docs/api/omdStepVisualizerHighlighting.md +66 -0
  36. package/npm-docs/api/omdStepVisualizerInteractiveSteps.md +109 -0
  37. package/npm-docs/api/omdStepVisualizerLayout.md +71 -0
  38. package/npm-docs/api/omdStepVisualizerNodeUtils.md +140 -0
  39. package/npm-docs/api/omdStepVisualizerTextBoxes.md +77 -0
  40. package/npm-docs/api/omdToolbar.md +131 -0
  41. package/npm-docs/api/omdTranscriptionService.md +96 -0
  42. package/npm-docs/api/omdTreeDiff.md +170 -0
  43. package/npm-docs/api/omdUnaryExpressionNode.md +137 -0
  44. package/npm-docs/api/omdUtilities.md +83 -0
  45. package/npm-docs/api/omdVariableNode.md +123 -0
  46. package/npm-docs/api/selectTool.md +74 -0
  47. package/npm-docs/api/simplificationEngine.md +98 -0
  48. package/npm-docs/api/simplificationRules.md +77 -0
  49. package/npm-docs/api/simplificationUtils.md +64 -0
  50. package/npm-docs/api/transcribe.md +43 -0
  51. package/npm-docs/guides/equations.md +854 -0
  52. package/npm-docs/guides/factory-functions.md +354 -0
  53. package/npm-docs/guides/getting-started.md +318 -0
  54. package/npm-docs/guides/quick-examples.md +525 -0
  55. package/npm-docs/guides/visualizations.md +682 -0
  56. package/npm-docs/json-schemas.md +826 -0
  57. package/omd/utils/omdTranscriptionService.js +1 -1
  58. package/package.json +2 -1
  59. package/src/index.js +2 -0
  60. package/src/omdFactory.js +150 -0
@@ -10,7 +10,7 @@ export class omdTranscriptionService {
10
10
  this.options = {
11
11
  endpoint: options.endpoint || this._getDefaultEndpoint(),
12
12
  defaultProvider: options.defaultProvider || 'openai',
13
- defaultModel: options.defaultModel || 'gpt-4o-mini',
13
+ defaultModel: options.defaultModel || 'gpt-4o',
14
14
  ...options
15
15
  };
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teachinglab/omd",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "omd",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -14,6 +14,7 @@
14
14
  "src/",
15
15
  "omd/",
16
16
  "docs/",
17
+ "npm-docs/",
17
18
  "canvas/",
18
19
  "jsvg/"
19
20
  ],
package/src/index.js CHANGED
@@ -27,6 +27,8 @@ export { omd } from './omd.js';
27
27
 
28
28
  // OMD Utilities and Helpers
29
29
  export { omdColor } from './omdColor.js';
30
+ export { createFromJSON, getSupportedTypes, isTypeSupported } from './omdFactory.js';
31
+
30
32
  // OMD Shape Classes
31
33
  export {
32
34
  omdRightTriangle,
@@ -0,0 +1,150 @@
1
+ /**
2
+ * OMD Factory - Creates OMD objects from JSON data
3
+ *
4
+ * This factory function creates the appropriate OMD object based on the omdType
5
+ * field in the JSON data, eliminating the need for large switch statements.
6
+ *
7
+ * Usage:
8
+ * import { createFromJSON } from '@teachinglab/omd';
9
+ *
10
+ * const jsonData = { omdType: 'numberLine', min: 0, max: 10 };
11
+ * const omdObject = createFromJSON(jsonData);
12
+ *
13
+ * // Optionally load into existing container
14
+ * const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
15
+ * svg.appendChild(omdObject.svgObject);
16
+ */
17
+
18
+ import { omdBalanceHanger } from './omdBalanceHanger.js';
19
+ import { omdTable } from './omdTable.js';
20
+ import { omdTapeDiagram } from './omdTapeDiagram.js';
21
+ import { omdCoordinatePlane } from './omdCoordinatePlane.js';
22
+ import { omdNumberLine } from './omdNumberLine.js';
23
+ import { omdNumberTile } from './omdNumberTile.js';
24
+ import { omdRatioChart } from './omdRatioChart.js';
25
+ import { omdTileEquation } from './omdTileEquation.js';
26
+ import { omdSpinner } from './omdSpinner.js';
27
+ import { omdEquation } from './omdEquation.js';
28
+ import { omdExpression } from './omdExpression.js';
29
+ import { omdTerm } from './omdTerm.js';
30
+ import { omdNumber } from './omdNumber.js';
31
+ import { omdVariable } from './omdVariable.js';
32
+ import { omdPowerExpression } from './omdPowerExpression.js';
33
+ import { omdRationalExpression } from './omdRationalExpression.js';
34
+ import { omdFunction } from './omdFunction.js';
35
+ import {
36
+ omdRightTriangle,
37
+ omdIsoscelesTriangle,
38
+ omdRectangle,
39
+ omdEllipse,
40
+ omdCircle,
41
+ omdRegularPolygon
42
+ } from './omdShapes.js';
43
+
44
+ /**
45
+ * Map of omdType strings to their corresponding class constructors
46
+ */
47
+ const OMD_TYPE_MAP = {
48
+ 'balanceHanger': omdBalanceHanger,
49
+ 'table': omdTable,
50
+ 'tapeDiagram': omdTapeDiagram,
51
+ 'coordinatePlane': omdCoordinatePlane,
52
+ 'numberLine': omdNumberLine,
53
+ 'numberTile': omdNumberTile,
54
+ 'ratioChart': omdRatioChart,
55
+ 'tileEquation': omdTileEquation,
56
+ 'spinner': omdSpinner,
57
+ 'equation': omdEquation,
58
+ 'expression': omdExpression,
59
+ 'term': omdTerm,
60
+ 'number': omdNumber,
61
+ 'variable': omdVariable,
62
+ 'powerExpression': omdPowerExpression,
63
+ 'rationalExpression': omdRationalExpression,
64
+ 'function': omdFunction,
65
+ 'rightTriangle': omdRightTriangle,
66
+ 'isoscelesTriangle': omdIsoscelesTriangle,
67
+ 'rectangle': omdRectangle,
68
+ 'ellipse': omdEllipse,
69
+ 'circle': omdCircle,
70
+ 'regularPolygon': omdRegularPolygon
71
+ };
72
+
73
+ /**
74
+ * Creates an OMD object from JSON data
75
+ *
76
+ * @param {object} jsonData - The JSON data with an omdType field
77
+ * @returns {object} The created OMD object with data loaded
78
+ * @throws {Error} If omdType is missing or unsupported
79
+ *
80
+ * @example
81
+ * // Create a number line
82
+ * const numberLine = createFromJSON({
83
+ * omdType: 'numberLine',
84
+ * min: 0,
85
+ * max: 10,
86
+ * dotValues: [2, 5, 8]
87
+ * });
88
+ *
89
+ * @example
90
+ * // Create a coordinate plane
91
+ * const plane = createFromJSON({
92
+ * omdType: 'coordinatePlane',
93
+ * xMin: -10,
94
+ * xMax: 10,
95
+ * yMin: -10,
96
+ * yMax: 10,
97
+ * graphEquations: [
98
+ * { equation: 'y = x^2', color: '#e11d48' }
99
+ * ]
100
+ * });
101
+ *
102
+ * @example
103
+ * // Create an equation
104
+ * const equation = createFromJSON({
105
+ * omdType: 'equation',
106
+ * equation: '2x + 3 = 11'
107
+ * });
108
+ */
109
+ export function createFromJSON(jsonData) {
110
+ if (!jsonData || typeof jsonData !== 'object') {
111
+ throw new Error('createFromJSON requires a valid JSON object');
112
+ }
113
+
114
+ const omdType = jsonData.omdType;
115
+
116
+ if (!omdType) {
117
+ throw new Error('JSON data must include an "omdType" field');
118
+ }
119
+
120
+ const Constructor = OMD_TYPE_MAP[omdType];
121
+
122
+ if (!Constructor) {
123
+ throw new Error(`Unsupported omdType: "${omdType}". Supported types: ${Object.keys(OMD_TYPE_MAP).join(', ')}`);
124
+ }
125
+
126
+ // Create instance and load data
127
+ const omdObject = new Constructor();
128
+ omdObject.loadFromJSON(jsonData);
129
+
130
+ return omdObject;
131
+ }
132
+
133
+ /**
134
+ * Gets the list of supported OMD types
135
+ *
136
+ * @returns {string[]} Array of supported omdType strings
137
+ */
138
+ export function getSupportedTypes() {
139
+ return Object.keys(OMD_TYPE_MAP);
140
+ }
141
+
142
+ /**
143
+ * Checks if an omdType is supported
144
+ *
145
+ * @param {string} omdType - The type to check
146
+ * @returns {boolean} True if the type is supported
147
+ */
148
+ export function isTypeSupported(omdType) {
149
+ return omdType in OMD_TYPE_MAP;
150
+ }