@teachinglab/omd 0.7.34 → 0.7.36

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.
@@ -0,0 +1,90 @@
1
+ // OMD Visualization Components
2
+ export { omdTable } from './omdTable.js';
3
+ export { omdBalanceHanger } from './omdBalanceHanger.js';
4
+ export { omdCoordinatePlane } from './omdCoordinatePlane.js';
5
+ export { omdTapeDiagram } from './omdTapeDiagram.js';
6
+ export { omdDoubleTapeDiagram } from './omdDoubleTapeDiagram.js';
7
+ export { omdTileEquation } from './omdTileEquation.js';
8
+
9
+ // OMD Charts and Diagrams
10
+ export { omdRatioChart } from './omdRatioChart.js';
11
+ export { omdNumberLine } from './omdNumberLine.js';
12
+ export { omdDoubleNumberLine } from './omdDoubleNumberLine.js';
13
+ export { omdNumberTile } from './omdNumberTile.js';
14
+
15
+ // OMD Mathematical Components
16
+ export { omdEquation } from './omdEquation.js';
17
+ export { omdExpression } from './omdExpression.js';
18
+ export { omdTerm } from './omdTerm.js';
19
+ export { omdNumber } from './omdNumber.js';
20
+ export { omdVariable } from './omdVariable.js';
21
+ export { omdPowerExpression } from './omdPowerExpression.js';
22
+ export { omdRationalExpression } from './omdRationalExpression.js';
23
+ export { omdFunction } from './omdFunction.js';
24
+
25
+ // OMD Core Components
26
+ export { omdApp } from './omdApp.js';
27
+ export { omdAppCanvas } from './omdAppCanvas.js';
28
+ export { omd } from './omd.js';
29
+ export { omdDisplay } from '../omd/display/omdDisplay.js';
30
+ export { omdEquationNode } from '../omd/nodes/omdEquationNode.js';
31
+ export { omdEquationStack } from '../omd/core/omdEquationStack.js';
32
+ export { omdEquationSequenceNode } from '../omd/nodes/omdEquationSequenceNode.js';
33
+ export { omdConstantNode } from '../omd/nodes/omdConstantNode.js';
34
+ export { omdNodeOverlay, omdNodeOverlayPresets } from '../omd/utils/omdNodeOverlay.js';
35
+
36
+ // OMD Utilities and Helpers
37
+ export { omdColor } from './omdColor.js';
38
+ export { createFromJSON, getSupportedTypes, isTypeSupported } from './omdFactory.js';
39
+
40
+ // OMD Shape Classes
41
+ export {
42
+ omdRightTriangle,
43
+ omdIsoscelesTriangle,
44
+ omdRectangle,
45
+ omdEllipse,
46
+ omdCircle,
47
+ omdRegularPolygon,
48
+ omdShapeLabelSet
49
+ } from './omdShapes.js';
50
+ export { omdSpinner } from './omdSpinner.js';
51
+ export { omdLabel } from './omdLabel.js';
52
+ export { omdProblem } from './omdProblem.js';
53
+
54
+ // Default export for organized access
55
+ export default {
56
+ // Main visualizations (most commonly used)
57
+ visualizations: {
58
+ omdTable: () => import('./omdTable.js').then(m => m.omdTable),
59
+ omdBalanceHanger: () => import('./omdBalanceHanger.js').then(m => m.omdBalanceHanger),
60
+ omdCoordinatePlane: () => import('./omdCoordinatePlane.js').then(m => m.omdCoordinatePlane),
61
+ omdTapeDiagram: () => import('./omdTapeDiagram.js').then(m => m.omdTapeDiagram),
62
+ omdTileEquation: () => import('./omdTileEquation.js').then(m => m.omdTileEquation),
63
+ omdRatioChart: () => import('./omdRatioChart.js').then(m => m.omdRatioChart),
64
+ omdNumberLine: () => import('./omdNumberLine.js').then(m => m.omdNumberLine),
65
+ omdDoubleNumberLine: () => import('./omdDoubleNumberLine.js').then(m => m.omdDoubleNumberLine)
66
+ },
67
+
68
+ // Mathematical expressions
69
+ expressions: {
70
+ omdExpression: () => import('./omdExpression.js').then(m => m.omdExpression),
71
+ omdEquation: () => import('./omdEquation.js').then(m => m.omdEquation),
72
+ omdMetaExpression: () => import('./omdMetaExpression.js').then(m => m.omdMetaExpression),
73
+ omdNaturalExpression: () => import('./omdNaturalExpression.js').then(m => m.omdNaturalExpression),
74
+ omdPowerExpression: () => import('./omdPowerExpression.js').then(m => m.omdPowerExpression),
75
+ omdRationalExpression: () => import('./omdRationalExpression.js').then(m => m.omdRationalExpression),
76
+ omdFunction: () => import('./omdFunction.js').then(m => m.omdFunction)
77
+ },
78
+
79
+ // Core app components
80
+ app: {
81
+ omdApp: () => import('./omdApp.js').then(m => m.omdApp),
82
+ omdAppCanvas: () => import('./omdAppCanvas.js').then(m => m.omdAppCanvas),
83
+ omd: () => import('./omd.js').then(m => m.omd),
84
+ async createDisplay(container) {
85
+ const { omdDisplay } = await import('../omd/core/index.js');
86
+ return new omdDisplay(container);
87
+ }
88
+ }
89
+ };
90
+ // Force reload
@@ -491,8 +491,7 @@ export class omdEquationStack extends jsvgGroup {
491
491
  let eqIndex = -1;
492
492
  for (let i = seq.steps.length - 1; i >= 0; i--) {
493
493
  const st = seq.steps[i];
494
- const name = st?.constructor?.name;
495
- if (st instanceof omdEquationNode || name === 'omdEquationNode') { eqIndex = i; break; }
494
+ if (st instanceof omdEquationNode || st?.type === 'omdEquationNode') { eqIndex = i; break; }
496
495
  }
497
496
  if (eqIndex === -1) return false;
498
497
 
@@ -500,8 +499,7 @@ export class omdEquationStack extends jsvgGroup {
500
499
  let startIndex = eqIndex;
501
500
  for (let i = eqIndex; i >= 0; i--) {
502
501
  const st = seq.steps[i];
503
- const name = st?.constructor?.name;
504
- if (st instanceof omdOperationDisplayNode || name === 'omdOperationDisplayNode') { startIndex = i; break; }
502
+ if (st instanceof omdOperationDisplayNode || st?.type === 'omdOperationDisplayNode') { startIndex = i; break; }
505
503
  }
506
504
  // Remove DOM children and steps from startIndex to end
507
505
  for (let i = seq.steps.length - 1; i >= startIndex; i--) {
@@ -546,7 +544,7 @@ export class omdEquationStack extends jsvgGroup {
546
544
 
547
545
  // Safety: ensure dot/line counts match equations and prune orphan dots
548
546
  try {
549
- const isEquation = (s) => (s instanceof omdEquationNode) || (s?.constructor?.name === 'omdEquationNode');
547
+ const isEquation = (s) => (s instanceof omdEquationNode) || (s?.type === 'omdEquationNode');
550
548
  const equationsCount = Array.isArray(seq.steps) ? seq.steps.filter(isEquation).length : 0;
551
549
 
552
550
  // Remove dots whose equationRef is no longer present in steps
@@ -535,8 +535,9 @@ export class omdDisplay {
535
535
  // Detect step visualizer directly on node (getSequence returns underlying sequence only)
536
536
  let hasStepVisualizer = false;
537
537
  if (this.node) {
538
- const ctorName = this.node.constructor?.name;
539
- hasStepVisualizer = (ctorName === 'omdStepVisualizer') || this.node.type === 'omdStepVisualizer' || (typeof omdStepVisualizer !== 'undefined' && this.node instanceof omdStepVisualizer);
538
+ hasStepVisualizer =
539
+ this.node.type === 'omdStepVisualizer' ||
540
+ (typeof omdStepVisualizer !== 'undefined' && this.node instanceof omdStepVisualizer);
540
541
  }
541
542
 
542
543
  if (hasStepVisualizer) {
@@ -997,7 +997,7 @@ export class omdEquationSequenceNode extends omdNode {
997
997
  // If visibility is explicitly false, skip
998
998
  if (step.visible === false) continue;
999
999
  // Prefer equation nodes when present
1000
- if (step.constructor?.name === 'omdEquationNode') {
1000
+ if (step instanceof omdEquationNode || step.type === 'omdEquationNode') {
1001
1001
  chosenIndex = i;
1002
1002
  break;
1003
1003
  }
@@ -1278,4 +1278,4 @@ export class omdEquationSequenceNode extends omdNode {
1278
1278
  this.computeDimensions();
1279
1279
  this.updateLayout();
1280
1280
  }
1281
- }
1281
+ }
@@ -388,7 +388,7 @@ export class omdStepVisualizerLayout {
388
388
  // Debug all steps and their properties
389
389
 
390
390
  sv.steps.forEach((step, i) => {
391
- if (step && (step instanceof omdEquationNode || step.constructor.name === 'omdEquationNode')) {
391
+ if (step && (step instanceof omdEquationNode || step.type === 'omdEquationNode')) {
392
392
 
393
393
  } else {
394
394
 
@@ -410,7 +410,7 @@ export class omdStepVisualizerLayout {
410
410
  // Check for hidden intermediate steps between consecutive visible major steps (stepMark = 0)
411
411
  const visibleMajorSteps = [];
412
412
  sv.steps.forEach((step, stepIndex) => {
413
- if (step && (step instanceof omdEquationNode || step.constructor.name === 'omdEquationNode')) {
413
+ if (step && (step instanceof omdEquationNode || step.type === 'omdEquationNode')) {
414
414
  if (step.stepMark === 0 && step.visible === true) {
415
415
  visibleMajorSteps.push(stepIndex);
416
416
 
@@ -431,7 +431,7 @@ export class omdStepVisualizerLayout {
431
431
  let hiddenIntermediateCount = 0;
432
432
  for (let j = previousMajorStepIndex + 1; j < currentMajorStepIndex; j++) {
433
433
  const step = sv.steps[j];
434
- if (step && (step instanceof omdEquationNode || step.constructor.name === 'omdEquationNode')) {
434
+ if (step && (step instanceof omdEquationNode || step.type === 'omdEquationNode')) {
435
435
  if (step.stepMark > 0 && step.visible === false) {
436
436
  hiddenIntermediateCount++;
437
437
 
@@ -498,7 +498,7 @@ export class omdStepVisualizerLayout {
498
498
  // Count intermediate steps between these two major steps
499
499
  for (let i = fromStepIndex + 1; i < toStepIndex; i++) {
500
500
  const step = sv.steps[i];
501
- if (step && (step instanceof omdEquationNode || step.constructor.name === 'omdEquationNode')) {
501
+ if (step && (step instanceof omdEquationNode || step.type === 'omdEquationNode')) {
502
502
  // Count intermediate steps (stepMark > 0) that are currently hidden
503
503
  if (step.stepMark !== undefined && step.stepMark > 0 && step.visible === false) {
504
504
 
@@ -680,7 +680,7 @@ export class omdStepVisualizerLayout {
680
680
  let majorStepAfterIndex = -1;
681
681
  for (let i = lastIntermediateStepIndex + 1; i < sv.steps.length; i++) {
682
682
  const step = sv.steps[i];
683
- if (step && (step instanceof omdEquationNode || step.constructor.name === 'omdEquationNode')) {
683
+ if (step && (step instanceof omdEquationNode || step.type === 'omdEquationNode')) {
684
684
  if (step.stepMark === 0 && step.visible === true) {
685
685
  majorStepAfterIndex = i;
686
686
 
@@ -774,7 +774,7 @@ export class omdStepVisualizerLayout {
774
774
  // Show all intermediate steps between the previous and current major steps
775
775
  for (let i = previousStepIndex + 1; i < majorStepIndex; i++) {
776
776
  const step = sv.steps[i];
777
- if (step && (step instanceof omdEquationNode || step.constructor.name === 'omdEquationNode')) {
777
+ if (step && (step instanceof omdEquationNode || step.type === 'omdEquationNode')) {
778
778
  if (step.stepMark > 0) {
779
779
 
780
780
  this._showStep(step);
@@ -890,4 +890,4 @@ export class omdStepVisualizerLayout {
890
890
 
891
891
 
892
892
  }
893
- }
893
+ }
package/package.json CHANGED
@@ -1,22 +1,28 @@
1
1
  {
2
2
  "name": "@teachinglab/omd",
3
- "version": "0.7.34",
3
+ "version": "0.7.36",
4
4
  "description": "omd",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
7
+ "unpkg": "./dist/omd.global.js",
7
8
  "type": "module",
8
9
  "exports": {
9
10
  ".": "./index.js",
11
+ "./browser": "./dist/omd.browser.js",
12
+ "./browser/global": "./dist/omd.global.js",
10
13
  "./register-math": "./omd/utils/registerMathGlobal.js",
11
14
  "./package.json": "./package.json"
12
15
  },
13
16
  "files": [
14
17
  "index.js",
18
+ "browser/",
15
19
  "src/",
16
20
  "omd/",
17
21
  "docs/",
18
22
  "canvas/",
19
23
  "jsvg/",
24
+ "dist/omd.browser.js",
25
+ "dist/omd.global.js",
20
26
  "npm-docs/",
21
27
  "README.md"
22
28
  ],
@@ -38,7 +44,8 @@
38
44
  },
39
45
  "scripts": {
40
46
  "dev": "npm run build:docs && vite",
41
- "build": "vite build && node copy-static.js && node build-docs.js && node build-npm-docs.js",
47
+ "build": "vite build && npm run build:browser && node copy-static.js && node build-docs.js && node build-npm-docs.js",
48
+ "build:browser": "vite build --config vite.browser.config.js",
42
49
  "build:docs": "node build-docs.js",
43
50
  "build:npm-docs": "node build-npm-docs.js",
44
51
  "build:static": "node copy-static.js",