@teachinglab/omd 0.1.0 → 0.1.2
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/omd/core/omdEquationStack.js +1 -25
- package/omd/core/omdUtilities.js +0 -1
- package/omd/display/omdDisplay.js +0 -8
- package/omd/display/omdToolbar.js +1 -1
- package/omd/nodes/omdEquationSequenceNode.js +3 -44
- package/omd/simplification/omdSimplification.js +1 -31
- package/omd/step-visualizer/omdStepVisualizer.js +3 -20
- package/omd/utils/omdPopup.js +2 -3
- package/omd/utils/omdStepVisualizerInteractiveSteps.js +0 -9
- package/omd/utils/omdTranscriptionService.js +2 -7
- package/package.json +4 -2
|
@@ -75,11 +75,9 @@ export class omdEquationStack extends jsvgGroup {
|
|
|
75
75
|
if (this.toolbar) {
|
|
76
76
|
if (overlayBottom) {
|
|
77
77
|
// For overlay positioning, add toolbar directly to this (not layoutGroup)
|
|
78
|
-
console.log('[constructor] Adding toolbar as overlay to stack');
|
|
79
78
|
this.addChild(this.toolbar.elements.toolbarGroup);
|
|
80
79
|
} else {
|
|
81
80
|
// For in-flow positioning, add to layout group
|
|
82
|
-
console.log('[constructor] Adding toolbar to layout group');
|
|
83
81
|
this.layoutGroup.addChild(this.toolbar.elements.toolbarGroup);
|
|
84
82
|
}
|
|
85
83
|
}
|
|
@@ -238,16 +236,6 @@ export class omdEquationStack extends jsvgGroup {
|
|
|
238
236
|
const name = st?.constructor?.name;
|
|
239
237
|
if (st instanceof omdOperationDisplayNode || name === 'omdOperationDisplayNode') { startIndex = i; break; }
|
|
240
238
|
}
|
|
241
|
-
|
|
242
|
-
try {
|
|
243
|
-
console.log('[undoLastOperation] before', {
|
|
244
|
-
totalSteps: seq.steps.length,
|
|
245
|
-
eqIndex,
|
|
246
|
-
startIndex,
|
|
247
|
-
stepTypes: seq.steps.map(s => s?.constructor?.name)
|
|
248
|
-
});
|
|
249
|
-
} catch (_) {}
|
|
250
|
-
|
|
251
239
|
// Remove DOM children and steps from startIndex to end
|
|
252
240
|
for (let i = seq.steps.length - 1; i >= startIndex; i--) {
|
|
253
241
|
const step = seq.steps[i];
|
|
@@ -271,7 +259,6 @@ export class omdEquationStack extends jsvgGroup {
|
|
|
271
259
|
// If this is a step visualizer, rebuild its dots/lines
|
|
272
260
|
if (typeof seq.rebuildVisualizer === 'function') {
|
|
273
261
|
try {
|
|
274
|
-
console.log('[undoLastOperation] rebuilding visualizer');
|
|
275
262
|
seq.rebuildVisualizer();
|
|
276
263
|
} catch (_) {}
|
|
277
264
|
} else if (typeof seq._initializeVisualElements === 'function') {
|
|
@@ -286,12 +273,7 @@ export class omdEquationStack extends jsvgGroup {
|
|
|
286
273
|
try {
|
|
287
274
|
const isEquation = (s) => (s instanceof omdEquationNode) || (s?.constructor?.name === 'omdEquationNode');
|
|
288
275
|
const equationsCount = Array.isArray(seq.steps) ? seq.steps.filter(isEquation).length : 0;
|
|
289
|
-
|
|
290
|
-
remainingSteps: seq.steps.length,
|
|
291
|
-
equationsCount,
|
|
292
|
-
dotCount: Array.isArray(seq.stepDots) ? seq.stepDots.length : 'n/a',
|
|
293
|
-
lineCount: Array.isArray(seq.stepLines) ? seq.stepLines.length : 'n/a'
|
|
294
|
-
});
|
|
276
|
+
|
|
295
277
|
// Remove dots whose equationRef is no longer present in steps
|
|
296
278
|
if (Array.isArray(seq.stepDots) && seq.visualContainer) {
|
|
297
279
|
const eqSet = new Set(seq.steps.filter(isEquation));
|
|
@@ -336,12 +318,6 @@ export class omdEquationStack extends jsvgGroup {
|
|
|
336
318
|
|
|
337
319
|
// Refresh stack layout
|
|
338
320
|
this.updateLayout();
|
|
339
|
-
try {
|
|
340
|
-
console.log('[undoLastOperation] done', {
|
|
341
|
-
finalDotCount: Array.isArray(seq.stepDots) ? seq.stepDots.length : 'n/a',
|
|
342
|
-
finalLineCount: Array.isArray(seq.stepLines) ? seq.stepLines.length : 'n/a'
|
|
343
|
-
});
|
|
344
|
-
} catch (_) {}
|
|
345
321
|
return true;
|
|
346
322
|
}
|
|
347
323
|
}
|
package/omd/core/omdUtilities.js
CHANGED
|
@@ -143,7 +143,6 @@ export class omdDisplay {
|
|
|
143
143
|
|
|
144
144
|
fitToContent() {
|
|
145
145
|
if (!this.node) {
|
|
146
|
-
console.log('No node to fit');
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
148
|
|
|
@@ -160,7 +159,6 @@ export class omdDisplay {
|
|
|
160
159
|
if (sequence && sequence.width && sequence.height) {
|
|
161
160
|
sequenceWidth = sequence.width;
|
|
162
161
|
sequenceHeight = sequence.height;
|
|
163
|
-
console.log('Sequence dimensions:', sequenceWidth, 'x', sequenceHeight);
|
|
164
162
|
|
|
165
163
|
// Check current step dimensions too
|
|
166
164
|
if (sequence.getCurrentStep) {
|
|
@@ -168,14 +166,12 @@ export class omdDisplay {
|
|
|
168
166
|
if (currentStep && currentStep.width && currentStep.height) {
|
|
169
167
|
stepWidth = currentStep.width;
|
|
170
168
|
stepHeight = currentStep.height;
|
|
171
|
-
console.log('Current step dimensions:', stepWidth, 'x', stepHeight);
|
|
172
169
|
}
|
|
173
170
|
}
|
|
174
171
|
|
|
175
172
|
// Use the larger of sequence or step dimensions
|
|
176
173
|
actualWidth = Math.max(sequenceWidth, stepWidth);
|
|
177
174
|
actualHeight = Math.max(sequenceHeight, stepHeight);
|
|
178
|
-
console.log('Using maximum dimensions:', actualWidth, 'x', actualHeight);
|
|
179
175
|
}
|
|
180
176
|
}
|
|
181
177
|
|
|
@@ -183,26 +179,22 @@ export class omdDisplay {
|
|
|
183
179
|
if ((actualWidth === 0 || actualHeight === 0) && this.node.width && this.node.height) {
|
|
184
180
|
actualWidth = this.node.width;
|
|
185
181
|
actualHeight = this.node.height;
|
|
186
|
-
console.log('Using node dimensions:', actualWidth, 'x', actualHeight);
|
|
187
182
|
}
|
|
188
183
|
|
|
189
184
|
// Fallback dimensions
|
|
190
185
|
if (actualWidth === 0 || actualHeight === 0) {
|
|
191
186
|
actualWidth = 200;
|
|
192
187
|
actualHeight = 60;
|
|
193
|
-
console.log('Using fallback dimensions:', actualWidth, 'x', actualHeight);
|
|
194
188
|
}
|
|
195
189
|
|
|
196
190
|
const padding = 10; // More comfortable padding to match user expectation
|
|
197
191
|
const newWidth = actualWidth + (padding * 2);
|
|
198
192
|
const newHeight = actualHeight + (padding * 2);
|
|
199
193
|
|
|
200
|
-
console.log('Setting container to:', newWidth, 'x', newHeight);
|
|
201
194
|
|
|
202
195
|
// Position the content at the minimal padding offset FIRST
|
|
203
196
|
if (this.node && this.node.setPosition) {
|
|
204
197
|
this.node.setPosition(padding, padding);
|
|
205
|
-
console.log('Positioning content at:', padding, padding);
|
|
206
198
|
}
|
|
207
199
|
|
|
208
200
|
// Update SVG dimensions with viewBox starting from 0,0 since we repositioned content
|
|
@@ -25,7 +25,7 @@ export class omdToolbar {
|
|
|
25
25
|
inputFontSize: 28, menuFontSize: 24, inputWidth: 120,
|
|
26
26
|
popupDirection: 'below',
|
|
27
27
|
showUndoButton: false,
|
|
28
|
-
undoIconUrl: '
|
|
28
|
+
undoIconUrl: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzciIGhlaWdodD0iNDQiIHZpZXdCb3g9IjAgMCAzNyA0NCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xOC4zNjc2IDQzLjgzMDFDMTMuNTkxMyA0My44MjM3IDkuMDEyNTYgNDEuOTIzNCA1LjYzNTI1IDM4LjU0NTlDMi4yNTc5MiAzNS4xNjg1IDAuMzU3NjYgMzAuNTg5OSAwLjM1MTA3NCAyNS44MTM2QzAuMzUxMDc0IDI1LjMxOTQgMC41NDc0NDEgMjQuODQ1MiAwLjg5Njk2MSAyNC40OTU4QzEuMjQ2NDggMjQuMTQ2MiAxLjcyMDU1IDIzLjk0OTggMi4yMTQ4NSAyMy45NDk4QzIuNzA5MTUgMjMuOTQ5OCAzLjE4MzIyIDI0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TcuNjEgMjAuMDMzNyAxOC4wODM3IDE5LjY4NDYgMTguNDMzMUMxOS41MTI2IDE4LjYwNzMgMTkuMzA3MyAxOC43NDU0IDE5LjA4MTIgMTguODM5NEMxOC44NTUxIDE4LjkzMzMgMTguNjEyNSAxOC45ODEgMTguMzY3NSAxOC45Nzk4WiIgZmlsbD0id2hpdGUiLz4NCjwvc3ZnPg0K',
|
|
29
29
|
onUndo: null,
|
|
30
30
|
...options
|
|
31
31
|
};
|
|
@@ -587,40 +587,22 @@ export class omdEquationSequenceNode extends omdNode {
|
|
|
587
587
|
* @returns {string} result.message - Human-readable description of the result
|
|
588
588
|
*/
|
|
589
589
|
simplify() {
|
|
590
|
-
console.log(`🔍 simplify called`);
|
|
591
|
-
|
|
592
590
|
const currentStep = this.steps[this.steps.length - 1];
|
|
593
591
|
if (!currentStep) {
|
|
594
|
-
console.log(`❌ No current step found`);
|
|
595
592
|
return { success: false, message: 'No expression found to simplify' };
|
|
596
593
|
}
|
|
597
594
|
|
|
598
|
-
console.log(`📋 Current step:`, {
|
|
599
|
-
type: currentStep.type,
|
|
600
|
-
constructorName: currentStep.type,
|
|
601
|
-
toString: currentStep.toString()
|
|
602
|
-
});
|
|
603
|
-
|
|
604
595
|
try {
|
|
605
596
|
const stepToSimplify = currentStep.clone();
|
|
606
|
-
console.log(`🔄 Cloned step for simplification:`, {
|
|
607
|
-
type: stepToSimplify.type,
|
|
608
|
-
constructorName: stepToSimplify.type,
|
|
609
|
-
toString: stepToSimplify.toString()
|
|
610
|
-
});
|
|
611
|
-
|
|
612
597
|
const simplificationResult = simplifyStep(stepToSimplify);
|
|
613
|
-
console.log(`📊 simplifyStep result:`, simplificationResult);
|
|
614
598
|
|
|
615
599
|
if (simplificationResult.foldedCount > 0) {
|
|
616
|
-
console.log(`✅ Simplification successful, handling result...`);
|
|
617
600
|
return this._handleSuccessfulSimplification(currentStep, simplificationResult);
|
|
618
601
|
} else {
|
|
619
|
-
console.log(`❌ No simplifications applied`);
|
|
620
602
|
return { success: false, foldedCount: 0, message: 'No simplifications available' };
|
|
621
603
|
}
|
|
622
604
|
} catch (error) {
|
|
623
|
-
console.error(
|
|
605
|
+
console.error(`Error during simplification:`, error);
|
|
624
606
|
return { success: false, message: `Simplification error: ${error.message}` };
|
|
625
607
|
}
|
|
626
608
|
}
|
|
@@ -665,40 +647,22 @@ export class omdEquationSequenceNode extends omdNode {
|
|
|
665
647
|
* @returns {string} result.message - Human-readable description of the final result
|
|
666
648
|
*/
|
|
667
649
|
simplifyAll(maxIterations = 50) {
|
|
668
|
-
console.log(`🚀 simplifyAll called with maxIterations: ${maxIterations}`);
|
|
669
|
-
console.log(`📋 Current steps:`, {
|
|
670
|
-
stepsLength: this.steps.length,
|
|
671
|
-
steps: this.steps.map((step, i) => ({
|
|
672
|
-
index: i,
|
|
673
|
-
type: step.type,
|
|
674
|
-
constructorName: step.type,
|
|
675
|
-
toString: step.toString()
|
|
676
|
-
}))
|
|
677
|
-
});
|
|
678
|
-
|
|
679
650
|
let iteration = 0;
|
|
680
651
|
let stepsBefore;
|
|
681
652
|
let totalSteps = 0;
|
|
682
653
|
|
|
683
654
|
do {
|
|
684
655
|
stepsBefore = this.steps.length;
|
|
685
|
-
console.log(`🔄 Iteration ${iteration + 1}: starting with ${stepsBefore} steps`);
|
|
686
|
-
|
|
687
656
|
const result = this.simplify();
|
|
688
|
-
console.log(`📊 Iteration ${iteration + 1} result:`, result);
|
|
689
657
|
|
|
690
658
|
if (result.success) {
|
|
691
659
|
totalSteps++;
|
|
692
|
-
console.log(`✅ Iteration ${iteration + 1} successful, totalSteps: ${totalSteps}`);
|
|
693
|
-
} else {
|
|
694
|
-
console.log(`❌ Iteration ${iteration + 1} failed: ${result.message}`);
|
|
695
660
|
}
|
|
696
661
|
|
|
697
662
|
iteration++;
|
|
698
663
|
} while (this.steps.length > stepsBefore && iteration < maxIterations);
|
|
699
664
|
|
|
700
665
|
if (iteration >= maxIterations) {
|
|
701
|
-
console.log(`⚠️ Stopped after ${maxIterations} iterations to avoid infinite loop`);
|
|
702
666
|
return {
|
|
703
667
|
success: false,
|
|
704
668
|
totalSteps,
|
|
@@ -706,11 +670,6 @@ export class omdEquationSequenceNode extends omdNode {
|
|
|
706
670
|
message: `Stopped after ${maxIterations} iterations to avoid an infinite loop.`
|
|
707
671
|
};
|
|
708
672
|
} else {
|
|
709
|
-
console.log(`✅ simplifyAll completed successfully:`, {
|
|
710
|
-
totalSteps,
|
|
711
|
-
iterations: iteration,
|
|
712
|
-
finalStepsLength: this.steps.length
|
|
713
|
-
});
|
|
714
673
|
return {
|
|
715
674
|
success: true,
|
|
716
675
|
totalSteps,
|
|
@@ -738,9 +697,9 @@ export class omdEquationSequenceNode extends omdNode {
|
|
|
738
697
|
if (typeof result === 'object' && result.left !== undefined && result.right !== undefined) {
|
|
739
698
|
const { left, right } = result;
|
|
740
699
|
const isEqual = Math.abs(left - right) < 1e-9;
|
|
741
|
-
|
|
700
|
+
|
|
742
701
|
} else {
|
|
743
|
-
|
|
702
|
+
|
|
744
703
|
}
|
|
745
704
|
} catch (error) {
|
|
746
705
|
console.error("Evaluation failed:", error.message);
|
|
@@ -15,11 +15,6 @@ export function findSimplificationOpportunities(rootNode) {
|
|
|
15
15
|
if (!node || visitedNodes.has(node)) return;
|
|
16
16
|
visitedNodes.add(node);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
if (node.type === 'omdEquationNode') {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
18
|
// Traverse children first (depth-first)
|
|
24
19
|
if (node.childList && node.childList.length > 0) {
|
|
25
20
|
|
|
@@ -43,33 +38,23 @@ export function findSimplificationOpportunities(rootNode) {
|
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
traverse(rootNode);
|
|
46
|
-
console.log(`📊 Total opportunities found: ${opportunities.length}`);
|
|
47
41
|
return opportunities;
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
export function simplifyStep(rootNode) {
|
|
51
|
-
console.log(`🚀 simplifyStep called for root node:`, {
|
|
52
|
-
nodeType: rootNode.type,
|
|
53
|
-
constructorName: rootNode.type,
|
|
54
|
-
nodeId: rootNode.id
|
|
55
|
-
});
|
|
56
|
-
|
|
57
45
|
let foldedCount = 0;
|
|
58
46
|
let newRoot = rootNode;
|
|
59
47
|
let historyEntry = null;
|
|
60
48
|
|
|
61
49
|
// Find all simplification opportunities
|
|
62
50
|
const opportunities = findSimplificationOpportunities(rootNode);
|
|
63
|
-
console.log(`📊 Found ${opportunities.length} simplification opportunities`);
|
|
64
51
|
|
|
65
52
|
if (opportunities.length > 0) {
|
|
66
53
|
// Apply the first opportunity
|
|
67
54
|
const opportunity = opportunities[0];
|
|
68
|
-
console.log(`🔧 Applying simplification rule:`, opportunity.rule.name);
|
|
69
55
|
|
|
70
56
|
try {
|
|
71
57
|
const result = opportunity.rule.apply(opportunity.node, opportunity.ruleData, rootNode);
|
|
72
|
-
console.log(`✅ Rule "${opportunity.rule.name}" applied successfully:`, result);
|
|
73
58
|
|
|
74
59
|
if (result && result.success && result.newRoot) {
|
|
75
60
|
newRoot = result.newRoot;
|
|
@@ -79,27 +64,12 @@ export function simplifyStep(rootNode) {
|
|
|
79
64
|
affectedNodes: [rootNode.id],
|
|
80
65
|
message: `Applied ${opportunity.rule.name}`
|
|
81
66
|
};
|
|
82
|
-
console.log(`✅ Simplification successful! New root:`, {
|
|
83
|
-
nodeType: newRoot.type,
|
|
84
|
-
nodeId: newRoot.id
|
|
85
|
-
});
|
|
86
|
-
} else {
|
|
87
|
-
console.log(`❌ Rule "${opportunity.rule.name}" returned no result`);
|
|
88
67
|
}
|
|
89
68
|
} catch (error) {
|
|
90
|
-
console.error(
|
|
69
|
+
console.error(`Error applying rule '${opportunity.rule.name}':`, error);
|
|
91
70
|
}
|
|
92
|
-
} else {
|
|
93
|
-
console.log(`❌ No simplification opportunities found`);
|
|
94
71
|
}
|
|
95
72
|
|
|
96
|
-
console.log(`📊 simplifyStep result:`, {
|
|
97
|
-
foldedCount,
|
|
98
|
-
hasNewRoot: newRoot !== rootNode,
|
|
99
|
-
newRootType: newRoot.type,
|
|
100
|
-
newRootId: newRoot.id
|
|
101
|
-
});
|
|
102
|
-
|
|
103
73
|
return { newRoot, foldedCount, historyEntry };
|
|
104
74
|
}
|
|
105
75
|
|
|
@@ -45,29 +45,12 @@ export class omdStepVisualizer extends omdEquationSequenceNode {
|
|
|
45
45
|
* Force rebuild visual container (dots/lines) from scratch
|
|
46
46
|
*/
|
|
47
47
|
rebuildVisualizer() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log('[rebuildVisualizer] removing old visualContainer', {
|
|
52
|
-
childCount: Array.isArray(this.visualContainer.childList) ? this.visualContainer.childList.length : 'n/a'
|
|
53
|
-
});
|
|
54
|
-
} catch (_) {}
|
|
55
|
-
this.removeChild(this.visualContainer);
|
|
56
|
-
try {
|
|
57
|
-
const stillAttached = !!(this.visualContainer?.svgObject?.parentNode);
|
|
58
|
-
console.log('[rebuildVisualizer] removed old visualContainer, stillAttached?', stillAttached);
|
|
59
|
-
} catch (_) {}
|
|
60
|
-
}
|
|
61
|
-
} catch (_) {}
|
|
48
|
+
if (this.visualContainer) {
|
|
49
|
+
this.removeChild(this.visualContainer);
|
|
50
|
+
}
|
|
62
51
|
this.visualContainer = new jsvgLayoutGroup();
|
|
63
52
|
this.addChild(this.visualContainer);
|
|
64
53
|
this._initializeVisualElements();
|
|
65
|
-
try {
|
|
66
|
-
console.log('[rebuildVisualizer] new visualContainer', {
|
|
67
|
-
dots: Array.isArray(this.stepDots) ? this.stepDots.length : 'n/a',
|
|
68
|
-
lines: Array.isArray(this.stepLines) ? this.stepLines.length : 'n/a'
|
|
69
|
-
});
|
|
70
|
-
} catch (_) {}
|
|
71
54
|
this.computeDimensions();
|
|
72
55
|
this.updateLayout();
|
|
73
56
|
}
|
package/omd/utils/omdPopup.js
CHANGED
|
@@ -752,8 +752,7 @@ export class omdPopup {
|
|
|
752
752
|
const expr2Trimmed = expr2.trim();
|
|
753
753
|
const node1 = window.math.simplify(expr1Trimmed);
|
|
754
754
|
const node2 = window.math.simplify(expr2Trimmed);
|
|
755
|
-
|
|
756
|
-
console.log('Simplified expressions:', { simplified1: node1.toString(), simplified2: node2.toString() });
|
|
755
|
+
|
|
757
756
|
// If ASTs match, return true
|
|
758
757
|
if (node1.equals(node2)) return true;
|
|
759
758
|
|
|
@@ -1005,7 +1004,7 @@ export class omdPopup {
|
|
|
1005
1004
|
const result = await transcriptionService.transcribeWithFallback(imageBlob, {
|
|
1006
1005
|
prompt: 'Transcribe this handwritten mathematical expression. Return ONLY the pure mathematical expression with no formatting, no LaTeX, no dollar signs, no explanations. Use ^ for powers (e.g., 3^2), use / for fractions (e.g., (2x+1)/(x-3)), use * for multiplication, use + and - for addition/subtraction. Return only the expression.'
|
|
1007
1006
|
});
|
|
1008
|
-
|
|
1007
|
+
|
|
1009
1008
|
if (result.text) {
|
|
1010
1009
|
this._setSubmitButtonLoading(false);
|
|
1011
1010
|
this.flashValidation(true);
|
|
@@ -322,9 +322,6 @@ export class omdStepVisualizerInteractiveSteps {
|
|
|
322
322
|
stepBox.div.style.backgroundColor = omdColor.mediumGray; // Slightly darker version of explainColor
|
|
323
323
|
stepBox.div.style.transform = 'translateX(2px)';
|
|
324
324
|
|
|
325
|
-
// Console logging for hover enter
|
|
326
|
-
|
|
327
|
-
|
|
328
325
|
// Call hover callback if provided
|
|
329
326
|
this.onStepHover?.(stepBox.stepIndex, stepBox.stepMessage, true);
|
|
330
327
|
});
|
|
@@ -333,18 +330,12 @@ export class omdStepVisualizerInteractiveSteps {
|
|
|
333
330
|
stepBox.div.style.backgroundColor = 'transparent';
|
|
334
331
|
stepBox.div.style.transform = 'translateX(0)';
|
|
335
332
|
|
|
336
|
-
// Console logging for hover leave
|
|
337
|
-
|
|
338
|
-
|
|
339
333
|
// Call hover callback if provided
|
|
340
334
|
this.onStepHover?.(stepBox.stepIndex, stepBox.stepMessage, false);
|
|
341
335
|
});
|
|
342
336
|
|
|
343
337
|
// Click interactions
|
|
344
338
|
stepBox.div.addEventListener('click', () => {
|
|
345
|
-
// Console logging for clicks
|
|
346
|
-
|
|
347
|
-
|
|
348
339
|
this.onStepClick?.(stepBox.stepIndex, stepBox.stepMessage);
|
|
349
340
|
});
|
|
350
341
|
}
|
|
@@ -12,11 +12,6 @@ export class omdTranscriptionService {
|
|
|
12
12
|
defaultProvider: options.defaultProvider || 'gemini',
|
|
13
13
|
...options
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
console.log('omdTranscriptionService constructor called with options:', {
|
|
17
|
-
endpoint: this.options.endpoint,
|
|
18
|
-
defaultProvider: this.options.defaultProvider
|
|
19
|
-
});
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
/**
|
|
@@ -52,7 +47,7 @@ export class omdTranscriptionService {
|
|
|
52
47
|
*/
|
|
53
48
|
async transcribe(imageBlob, options = {}) {
|
|
54
49
|
try {
|
|
55
|
-
|
|
50
|
+
|
|
56
51
|
|
|
57
52
|
// Convert blob to base64
|
|
58
53
|
const base64Image = await this._blobToBase64(imageBlob);
|
|
@@ -74,7 +69,7 @@ export class omdTranscriptionService {
|
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
const result = await response.json();
|
|
77
|
-
|
|
72
|
+
|
|
78
73
|
|
|
79
74
|
return {
|
|
80
75
|
text: result.text,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teachinglab/omd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "omd",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -42,5 +42,7 @@
|
|
|
42
42
|
"start": "node --env-file=.env server.js",
|
|
43
43
|
"dev": "node --env-file=.env server.js"
|
|
44
44
|
},
|
|
45
|
-
"publishConfig": {
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
46
48
|
}
|