math-notation 0.1.0 → 0.1.1

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.
@@ -3615,7 +3615,7 @@ async function create$1(config) {
3615
3615
  const computationStore = createComputationStore();
3616
3616
  return initializeInstance(config, computationStore);
3617
3617
  }
3618
- const Formulize = {
3618
+ const Store = {
3619
3619
  create: create$1
3620
3620
  };
3621
3621
  const CanvasContextMenu = React.memo(({
@@ -17457,9 +17457,9 @@ const ExpressionNode = mobxReactLite.observer(({
17457
17457
  transform: "translateX(-50%)"
17458
17458
  } }) });
17459
17459
  });
17460
- const FormulizeContext = React.createContext(null);
17461
- const useFormulize = () => {
17462
- return React.useContext(FormulizeContext);
17460
+ const StoreContext = React.createContext(null);
17461
+ const useStore = () => {
17462
+ return React.useContext(StoreContext);
17463
17463
  };
17464
17464
  const getOrCreateStyleElement = () => {
17465
17465
  let styleElement = document.getElementById("custom-var-styles");
@@ -19229,10 +19229,13 @@ const SCALE_OUT_CLASS = "scale-out";
19229
19229
  const setupScaleWrappers = (container, selector, draggingVarIds) => {
19230
19230
  const elements = container.querySelectorAll(selector);
19231
19231
  elements.forEach((element) => {
19232
- var _a2;
19232
+ var _a2, _b;
19233
+ if ((_a2 = element.parentElement) == null ? void 0 : _a2.classList.contains(WRAPPER_CLASS)) {
19234
+ return;
19235
+ }
19233
19236
  const wrapper = document.createElement("span");
19234
19237
  wrapper.className = WRAPPER_CLASS;
19235
- (_a2 = element.parentNode) == null ? void 0 : _a2.insertBefore(wrapper, element);
19238
+ (_b = element.parentNode) == null ? void 0 : _b.insertBefore(wrapper, element);
19236
19239
  wrapper.appendChild(element);
19237
19240
  });
19238
19241
  };
@@ -19261,7 +19264,7 @@ const deactivateScaleWrapper = (element) => {
19261
19264
  };
19262
19265
  function updateVariableHoverState(container, highlightedVarIds, useScaleWrappers = false) {
19263
19266
  const highlightedSet = new Set(highlightedVarIds);
19264
- const currentlyHovered = container.querySelectorAll(".hovered");
19267
+ const currentlyHovered = container.querySelectorAll(".var-scale-wrapper .hovered");
19265
19268
  currentlyHovered.forEach((element) => {
19266
19269
  const htmlEl = element;
19267
19270
  if (!highlightedSet.has(htmlEl.id)) {
@@ -19290,7 +19293,7 @@ const FormulaNode = mobxReactLite.observer(({
19290
19293
  }) => {
19291
19294
  var _a2;
19292
19295
  const nodeRef = React.useRef(null);
19293
- const context = useFormulize();
19296
+ const context = useStore();
19294
19297
  const computationStore = context == null ? void 0 : context.computationStore;
19295
19298
  const [isInitialized, setIsInitialized] = React.useState(false);
19296
19299
  React.useEffect(() => {
@@ -19315,7 +19318,11 @@ const FormulaNode = mobxReactLite.observer(({
19315
19318
  };
19316
19319
  await renderFormulaWithMathJax(nodeRef.current, dataWithStores, isInitialized);
19317
19320
  if (nodeRef.current && computationStore) {
19318
- setupScaleWrappers(nodeRef.current, ".var-input, .var-base");
19321
+ setupScaleWrappers(
19322
+ nodeRef.current,
19323
+ ".var-input, .var-base"
19324
+ // computationStore.highlightedVarIds
19325
+ );
19319
19326
  }
19320
19327
  }, [data, computationStore, isInitialized]);
19321
19328
  React.useEffect(() => {
@@ -19430,8 +19437,8 @@ const LatexLabel = mobxReactLite.observer(({
19430
19437
  }) => {
19431
19438
  var _a2, _b;
19432
19439
  const labelRef = React.useRef(null);
19433
- const formulizeContext = useFormulize();
19434
- const labelFontSize = (_b = (_a2 = formulizeContext == null ? void 0 : formulizeContext.computationStore) == null ? void 0 : _a2.environment) == null ? void 0 : _b.labelFontSize;
19440
+ const coreContext = useStore();
19441
+ const labelFontSize = (_b = (_a2 = coreContext == null ? void 0 : coreContext.computationStore) == null ? void 0 : _a2.environment) == null ? void 0 : _b.labelFontSize;
19435
19442
  const fontSize = customFontSize ?? labelFontSize ?? 1;
19436
19443
  React.useEffect(() => {
19437
19444
  let isMounted = true;
@@ -19467,8 +19474,8 @@ const SVGLabel = mobxReactLite.observer(({
19467
19474
  const [svgData, setSvgData] = React.useState(null);
19468
19475
  const [error, setError] = React.useState(null);
19469
19476
  const [isLoading, setIsLoading] = React.useState(false);
19470
- const formulizeContext = useFormulize();
19471
- const computationStore = formulizeContext == null ? void 0 : formulizeContext.computationStore;
19477
+ const coreContext = useStore();
19478
+ const computationStore = coreContext == null ? void 0 : coreContext.computationStore;
19472
19479
  const fontSize = ((_a2 = computationStore == null ? void 0 : computationStore.environment) == null ? void 0 : _a2.fontSize) || 1;
19473
19480
  React.useEffect(() => {
19474
19481
  const loadSVG = async () => {
@@ -19571,7 +19578,7 @@ const InlineInput = mobxReactLite.observer(({
19571
19578
  variable,
19572
19579
  fontSize
19573
19580
  }) => {
19574
- const context = useFormulize();
19581
+ const context = useStore();
19575
19582
  const computationStore = context == null ? void 0 : context.computationStore;
19576
19583
  const currentValue = typeof variable.value === "number" ? variable.value : 0;
19577
19584
  const displayPrecision = variable.precision ?? INPUT_VARIABLE_DEFAULT.PRECISION;
@@ -19630,7 +19637,7 @@ const LabelNode = mobxReactLite.observer(({
19630
19637
  varId,
19631
19638
  formulaId
19632
19639
  } = data;
19633
- const context = useFormulize();
19640
+ const context = useStore();
19634
19641
  const computationStore = context == null ? void 0 : context.computationStore;
19635
19642
  const labelFontSize = (_a2 = computationStore == null ? void 0 : computationStore.environment) == null ? void 0 : _a2.labelFontSize;
19636
19643
  const variable = computationStore == null ? void 0 : computationStore.variables.get(varId);
@@ -19760,7 +19767,7 @@ const VariableNode = mobxReactLite.observer(({
19760
19767
  width,
19761
19768
  height
19762
19769
  } = data;
19763
- const context = useFormulize();
19770
+ const context = useStore();
19764
19771
  const computationStore = context == null ? void 0 : context.computationStore;
19765
19772
  if (!computationStore) {
19766
19773
  return null;
@@ -21190,7 +21197,7 @@ const Formula$1 = mobxReactLite.observer(({
21190
21197
  className = "",
21191
21198
  style = {}
21192
21199
  }) => {
21193
- const context = useFormulize();
21200
+ const context = useStore();
21194
21201
  const instance = context == null ? void 0 : context.instance;
21195
21202
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21196
21203
  const config = context == null ? void 0 : context.config;
@@ -21259,7 +21266,7 @@ const MathJaxLoader = ({
21259
21266
  window.MathJax.startup.defaultReady();
21260
21267
  window.MathJax.startup.promise.then(() => {
21261
21268
  var _a2;
21262
- console.log("MathJax loaded and ready by formulize-math with scale 2.0");
21269
+ console.log("MathJax loaded and ready by math-notation with scale 2.0");
21263
21270
  console.log("MathJax chtml config:", (_a2 = window.MathJax.config) == null ? void 0 : _a2.chtml);
21264
21271
  });
21265
21272
  }
@@ -21333,7 +21340,7 @@ const MathJaxLoader = ({
21333
21340
  }, children });
21334
21341
  };
21335
21342
  const useMathJax = () => React.useContext(MathJaxContext);
21336
- const FormulizeProviderInner = mobxReactLite.observer(({
21343
+ const ProviderInner = mobxReactLite.observer(({
21337
21344
  config,
21338
21345
  children,
21339
21346
  onError,
@@ -21356,7 +21363,7 @@ const FormulizeProviderInner = mobxReactLite.observer(({
21356
21363
  setIsLoading(false);
21357
21364
  return;
21358
21365
  }
21359
- const initializeFormulize = async () => {
21366
+ const initialize = async () => {
21360
21367
  setIsLoading(true);
21361
21368
  setError(null);
21362
21369
  try {
@@ -21367,7 +21374,7 @@ const FormulizeProviderInner = mobxReactLite.observer(({
21367
21374
  if (!window.MathJax || !window.MathJax.tex2chtml) {
21368
21375
  throw new Error("MathJax is not properly loaded");
21369
21376
  }
21370
- const newInstance = await Formulize.create(config);
21377
+ const newInstance = await Store.create(config);
21371
21378
  instanceRef.current = newInstance;
21372
21379
  if (config.stepping && newInstance.computationStore) {
21373
21380
  newInstance.computationStore.setStepping(true);
@@ -21388,7 +21395,7 @@ const FormulizeProviderInner = mobxReactLite.observer(({
21388
21395
  setIsLoading(false);
21389
21396
  }
21390
21397
  };
21391
- initializeFormulize();
21398
+ initialize();
21392
21399
  return () => {
21393
21400
  if (instanceRef.current) {
21394
21401
  instanceRef.current.destroy();
@@ -21410,10 +21417,10 @@ const FormulizeProviderInner = mobxReactLite.observer(({
21410
21417
  computationStore: (instance == null ? void 0 : instance.computationStore) ?? null,
21411
21418
  reinitialize
21412
21419
  }), [instance, config, isLoading, error, reinitialize]);
21413
- return /* @__PURE__ */ jsxRuntime.jsx(FormulizeContext.Provider, { value: contextValue, children });
21420
+ return /* @__PURE__ */ jsxRuntime.jsx(StoreContext.Provider, { value: contextValue, children });
21414
21421
  });
21415
- const FormulizeProvider = (props) => {
21416
- return /* @__PURE__ */ jsxRuntime.jsx(MathJaxLoader, { children: /* @__PURE__ */ jsxRuntime.jsx(FormulizeProviderInner, { ...props }) });
21422
+ const Provider = (props) => {
21423
+ return /* @__PURE__ */ jsxRuntime.jsx(MathJaxLoader, { children: /* @__PURE__ */ jsxRuntime.jsx(ProviderInner, { ...props }) });
21417
21424
  };
21418
21425
  const InlineFormulaInner = mobxReactLite.observer(({
21419
21426
  id,
@@ -21559,7 +21566,7 @@ const InlineFormula = mobxReactLite.observer(({
21559
21566
  style = {},
21560
21567
  scale = 1
21561
21568
  }) => {
21562
- const context = useFormulize();
21569
+ const context = useStore();
21563
21570
  const instance = context == null ? void 0 : context.instance;
21564
21571
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21565
21572
  const computationStore = context == null ? void 0 : context.computationStore;
@@ -21590,7 +21597,7 @@ const InlineVariableInner = mobxReactLite.observer(({
21590
21597
  const {
21591
21598
  isLoaded: mathJaxLoaded
21592
21599
  } = useMathJax();
21593
- const context = useFormulize();
21600
+ const context = useStore();
21594
21601
  const config = context == null ? void 0 : context.config;
21595
21602
  const getVariable2 = React.useCallback(() => {
21596
21603
  return computationStore.variables.get(id);
@@ -21742,7 +21749,7 @@ const InlineVariable = mobxReactLite.observer(({
21742
21749
  style = {},
21743
21750
  scale = 1
21744
21751
  }) => {
21745
- const context = useFormulize();
21752
+ const context = useStore();
21746
21753
  const instance = context == null ? void 0 : context.instance;
21747
21754
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21748
21755
  const computationStore = context == null ? void 0 : context.computationStore;
@@ -21960,7 +21967,7 @@ const EmbeddedFormula = mobxReactLite.observer(({
21960
21967
  className = "",
21961
21968
  style = {}
21962
21969
  }) => {
21963
- const context = useFormulize();
21970
+ const context = useStore();
21964
21971
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21965
21972
  const computationStore = context == null ? void 0 : context.computationStore;
21966
21973
  if (isLoading || !computationStore) {
@@ -22349,7 +22356,7 @@ const ErrorDisplay = ({
22349
22356
  const Canvas = ({
22350
22357
  config
22351
22358
  }) => {
22352
- const context = useFormulize();
22359
+ const context = useStore();
22353
22360
  const computationStore = context == null ? void 0 : context.computationStore;
22354
22361
  const [variables, setVariables] = React.useState({});
22355
22362
  const {
@@ -22577,7 +22584,7 @@ const AxisLabels = mobxReactLite.observer(({
22577
22584
  yAxisHovered = false
22578
22585
  }) => {
22579
22586
  var _a2;
22580
- const context = useFormulize();
22587
+ const context = useStore();
22581
22588
  const computationStore = context == null ? void 0 : context.computationStore;
22582
22589
  if (!computationStore) {
22583
22590
  return null;
@@ -23021,7 +23028,7 @@ const Plot2D = mobxReactLite.observer(({
23021
23028
  config
23022
23029
  }) => {
23023
23030
  var _a2, _b;
23024
- const context = useFormulize();
23031
+ const context = useStore();
23025
23032
  const computationStore = context == null ? void 0 : context.computationStore;
23026
23033
  const svgRef = React.useRef(null);
23027
23034
  const tooltipRef = React.useRef(null);
@@ -23643,7 +23650,7 @@ const Plot2D = mobxReactLite.observer(({
23643
23650
  if (!computationStore) {
23644
23651
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "plot2d-loading", children: "Loading plot..." });
23645
23652
  }
23646
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "formulize-plot2d", style: {
23653
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mn-plot2d", style: {
23647
23654
  position: "relative"
23648
23655
  }, children: [
23649
23656
  /* @__PURE__ */ jsxRuntime.jsx("svg", { ref: svgRef, style: {
@@ -24229,7 +24236,7 @@ const Plot3DInner = mobxReactLite.observer(({
24229
24236
  const Plot3D = mobxReactLite.observer(({
24230
24237
  config
24231
24238
  }) => {
24232
- const context = useFormulize();
24239
+ const context = useStore();
24233
24240
  const computationStore = context == null ? void 0 : context.computationStore;
24234
24241
  if (!computationStore) {
24235
24242
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "plot3d-loading", children: "Loading plot..." });
@@ -24274,7 +24281,7 @@ const VisualizationComponent = mobxReactLite.observer(({
24274
24281
  }) => {
24275
24282
  const containerRef = React.useRef(null);
24276
24283
  const [isReady, setIsReady] = React.useState(false);
24277
- const context = useFormulize();
24284
+ const context = useStore();
24278
24285
  const computationStore = context == null ? void 0 : context.computationStore;
24279
24286
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
24280
24287
  const instance = context == null ? void 0 : context.instance;
@@ -24325,7 +24332,7 @@ const Button = ({
24325
24332
  const StepControl = mobxReactLite.observer(({
24326
24333
  className = ""
24327
24334
  }) => {
24328
- const context = useFormulize();
24335
+ const context = useStore();
24329
24336
  const computationStore = (context == null ? void 0 : context.computationStore) ?? null;
24330
24337
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
24331
24338
  const containerStyle = {
@@ -24567,11 +24574,11 @@ exports.ComputationStore = ComputationStore;
24567
24574
  exports.EmbeddedFormula = EmbeddedFormula;
24568
24575
  exports.Formula = Formula$1;
24569
24576
  exports.FormulaGenerator = Formula;
24570
- exports.Formulize = Formulize;
24571
- exports.FormulizeProvider = FormulizeProvider;
24572
24577
  exports.InlineFormula = InlineFormula;
24573
24578
  exports.InlineVariable = InlineVariable;
24579
+ exports.Provider = Provider;
24574
24580
  exports.StepControl = StepControl;
24581
+ exports.Store = Store;
24575
24582
  exports.Variable = Variable2;
24576
24583
  exports.VisualizationComponent = VisualizationComponent;
24577
24584
  exports.createComputationStore = createComputationStore;
@@ -24583,5 +24590,5 @@ exports.mergeVariables = mergeVariables;
24583
24590
  exports.register = register;
24584
24591
  exports.registerBuiltInComponents = registerBuiltInComponents;
24585
24592
  exports.unRegister = unRegister;
24586
- exports.useFormulize = useFormulize;
24593
+ exports.useStore = useStore;
24587
24594
  //# sourceMappingURL=formulize.cjs.js.map