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.
@@ -3608,7 +3608,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
3608
3608
  const computationStore = createComputationStore();
3609
3609
  return initializeInstance(config, computationStore);
3610
3610
  }
3611
- const Formulize = {
3611
+ const Store = {
3612
3612
  create: create$1
3613
3613
  };
3614
3614
  const CanvasContextMenu = React.memo(({
@@ -17450,9 +17450,9 @@ in order for it to be formatted.`, cliCategory: "Other" }, tabWidth: { type: "in
17450
17450
  transform: "translateX(-50%)"
17451
17451
  } }) });
17452
17452
  });
17453
- const FormulizeContext = React.createContext(null);
17454
- const useFormulize = () => {
17455
- return React.useContext(FormulizeContext);
17453
+ const StoreContext = React.createContext(null);
17454
+ const useStore = () => {
17455
+ return React.useContext(StoreContext);
17456
17456
  };
17457
17457
  const getOrCreateStyleElement = () => {
17458
17458
  let styleElement = document.getElementById("custom-var-styles");
@@ -19222,10 +19222,13 @@ ${rows}
19222
19222
  const setupScaleWrappers = (container, selector, draggingVarIds) => {
19223
19223
  const elements = container.querySelectorAll(selector);
19224
19224
  elements.forEach((element) => {
19225
- var _a2;
19225
+ var _a2, _b;
19226
+ if ((_a2 = element.parentElement) == null ? void 0 : _a2.classList.contains(WRAPPER_CLASS)) {
19227
+ return;
19228
+ }
19226
19229
  const wrapper = document.createElement("span");
19227
19230
  wrapper.className = WRAPPER_CLASS;
19228
- (_a2 = element.parentNode) == null ? void 0 : _a2.insertBefore(wrapper, element);
19231
+ (_b = element.parentNode) == null ? void 0 : _b.insertBefore(wrapper, element);
19229
19232
  wrapper.appendChild(element);
19230
19233
  });
19231
19234
  };
@@ -19254,7 +19257,7 @@ ${rows}
19254
19257
  };
19255
19258
  function updateVariableHoverState(container, highlightedVarIds, useScaleWrappers = false) {
19256
19259
  const highlightedSet = new Set(highlightedVarIds);
19257
- const currentlyHovered = container.querySelectorAll(".hovered");
19260
+ const currentlyHovered = container.querySelectorAll(".var-scale-wrapper .hovered");
19258
19261
  currentlyHovered.forEach((element) => {
19259
19262
  const htmlEl = element;
19260
19263
  if (!highlightedSet.has(htmlEl.id)) {
@@ -19283,7 +19286,7 @@ ${rows}
19283
19286
  }) => {
19284
19287
  var _a2;
19285
19288
  const nodeRef = React.useRef(null);
19286
- const context = useFormulize();
19289
+ const context = useStore();
19287
19290
  const computationStore = context == null ? void 0 : context.computationStore;
19288
19291
  const [isInitialized, setIsInitialized] = React.useState(false);
19289
19292
  React.useEffect(() => {
@@ -19308,7 +19311,11 @@ ${rows}
19308
19311
  };
19309
19312
  await renderFormulaWithMathJax(nodeRef.current, dataWithStores, isInitialized);
19310
19313
  if (nodeRef.current && computationStore) {
19311
- setupScaleWrappers(nodeRef.current, ".var-input, .var-base");
19314
+ setupScaleWrappers(
19315
+ nodeRef.current,
19316
+ ".var-input, .var-base"
19317
+ // computationStore.highlightedVarIds
19318
+ );
19312
19319
  }
19313
19320
  }, [data, computationStore, isInitialized]);
19314
19321
  React.useEffect(() => {
@@ -19423,8 +19430,8 @@ ${rows}
19423
19430
  }) => {
19424
19431
  var _a2, _b;
19425
19432
  const labelRef = React.useRef(null);
19426
- const formulizeContext = useFormulize();
19427
- const labelFontSize = (_b = (_a2 = formulizeContext == null ? void 0 : formulizeContext.computationStore) == null ? void 0 : _a2.environment) == null ? void 0 : _b.labelFontSize;
19433
+ const coreContext = useStore();
19434
+ const labelFontSize = (_b = (_a2 = coreContext == null ? void 0 : coreContext.computationStore) == null ? void 0 : _a2.environment) == null ? void 0 : _b.labelFontSize;
19428
19435
  const fontSize = customFontSize ?? labelFontSize ?? 1;
19429
19436
  React.useEffect(() => {
19430
19437
  let isMounted = true;
@@ -19460,8 +19467,8 @@ ${rows}
19460
19467
  const [svgData, setSvgData] = React.useState(null);
19461
19468
  const [error, setError] = React.useState(null);
19462
19469
  const [isLoading, setIsLoading] = React.useState(false);
19463
- const formulizeContext = useFormulize();
19464
- const computationStore = formulizeContext == null ? void 0 : formulizeContext.computationStore;
19470
+ const coreContext = useStore();
19471
+ const computationStore = coreContext == null ? void 0 : coreContext.computationStore;
19465
19472
  const fontSize = ((_a2 = computationStore == null ? void 0 : computationStore.environment) == null ? void 0 : _a2.fontSize) || 1;
19466
19473
  React.useEffect(() => {
19467
19474
  const loadSVG = async () => {
@@ -19564,7 +19571,7 @@ ${rows}
19564
19571
  variable,
19565
19572
  fontSize
19566
19573
  }) => {
19567
- const context = useFormulize();
19574
+ const context = useStore();
19568
19575
  const computationStore = context == null ? void 0 : context.computationStore;
19569
19576
  const currentValue = typeof variable.value === "number" ? variable.value : 0;
19570
19577
  const displayPrecision = variable.precision ?? INPUT_VARIABLE_DEFAULT.PRECISION;
@@ -19623,7 +19630,7 @@ ${rows}
19623
19630
  varId,
19624
19631
  formulaId
19625
19632
  } = data;
19626
- const context = useFormulize();
19633
+ const context = useStore();
19627
19634
  const computationStore = context == null ? void 0 : context.computationStore;
19628
19635
  const labelFontSize = (_a2 = computationStore == null ? void 0 : computationStore.environment) == null ? void 0 : _a2.labelFontSize;
19629
19636
  const variable = computationStore == null ? void 0 : computationStore.variables.get(varId);
@@ -19753,7 +19760,7 @@ ${rows}
19753
19760
  width,
19754
19761
  height
19755
19762
  } = data;
19756
- const context = useFormulize();
19763
+ const context = useStore();
19757
19764
  const computationStore = context == null ? void 0 : context.computationStore;
19758
19765
  if (!computationStore) {
19759
19766
  return null;
@@ -21183,7 +21190,7 @@ ${rows}
21183
21190
  className = "",
21184
21191
  style = {}
21185
21192
  }) => {
21186
- const context = useFormulize();
21193
+ const context = useStore();
21187
21194
  const instance = context == null ? void 0 : context.instance;
21188
21195
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21189
21196
  const config = context == null ? void 0 : context.config;
@@ -21252,7 +21259,7 @@ ${rows}
21252
21259
  window.MathJax.startup.defaultReady();
21253
21260
  window.MathJax.startup.promise.then(() => {
21254
21261
  var _a2;
21255
- console.log("MathJax loaded and ready by formulize-math with scale 2.0");
21262
+ console.log("MathJax loaded and ready by math-notation with scale 2.0");
21256
21263
  console.log("MathJax chtml config:", (_a2 = window.MathJax.config) == null ? void 0 : _a2.chtml);
21257
21264
  });
21258
21265
  }
@@ -21326,7 +21333,7 @@ ${rows}
21326
21333
  }, children });
21327
21334
  };
21328
21335
  const useMathJax = () => React.useContext(MathJaxContext);
21329
- const FormulizeProviderInner = mobxReactLite.observer(({
21336
+ const ProviderInner = mobxReactLite.observer(({
21330
21337
  config,
21331
21338
  children,
21332
21339
  onError,
@@ -21349,7 +21356,7 @@ ${rows}
21349
21356
  setIsLoading(false);
21350
21357
  return;
21351
21358
  }
21352
- const initializeFormulize = async () => {
21359
+ const initialize = async () => {
21353
21360
  setIsLoading(true);
21354
21361
  setError(null);
21355
21362
  try {
@@ -21360,7 +21367,7 @@ ${rows}
21360
21367
  if (!window.MathJax || !window.MathJax.tex2chtml) {
21361
21368
  throw new Error("MathJax is not properly loaded");
21362
21369
  }
21363
- const newInstance = await Formulize.create(config);
21370
+ const newInstance = await Store.create(config);
21364
21371
  instanceRef.current = newInstance;
21365
21372
  if (config.stepping && newInstance.computationStore) {
21366
21373
  newInstance.computationStore.setStepping(true);
@@ -21381,7 +21388,7 @@ ${rows}
21381
21388
  setIsLoading(false);
21382
21389
  }
21383
21390
  };
21384
- initializeFormulize();
21391
+ initialize();
21385
21392
  return () => {
21386
21393
  if (instanceRef.current) {
21387
21394
  instanceRef.current.destroy();
@@ -21403,10 +21410,10 @@ ${rows}
21403
21410
  computationStore: (instance == null ? void 0 : instance.computationStore) ?? null,
21404
21411
  reinitialize
21405
21412
  }), [instance, config, isLoading, error, reinitialize]);
21406
- return /* @__PURE__ */ jsxRuntime.jsx(FormulizeContext.Provider, { value: contextValue, children });
21413
+ return /* @__PURE__ */ jsxRuntime.jsx(StoreContext.Provider, { value: contextValue, children });
21407
21414
  });
21408
- const FormulizeProvider = (props) => {
21409
- return /* @__PURE__ */ jsxRuntime.jsx(MathJaxLoader, { children: /* @__PURE__ */ jsxRuntime.jsx(FormulizeProviderInner, { ...props }) });
21415
+ const Provider = (props) => {
21416
+ return /* @__PURE__ */ jsxRuntime.jsx(MathJaxLoader, { children: /* @__PURE__ */ jsxRuntime.jsx(ProviderInner, { ...props }) });
21410
21417
  };
21411
21418
  const InlineFormulaInner = mobxReactLite.observer(({
21412
21419
  id,
@@ -21552,7 +21559,7 @@ ${rows}
21552
21559
  style = {},
21553
21560
  scale = 1
21554
21561
  }) => {
21555
- const context = useFormulize();
21562
+ const context = useStore();
21556
21563
  const instance = context == null ? void 0 : context.instance;
21557
21564
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21558
21565
  const computationStore = context == null ? void 0 : context.computationStore;
@@ -21583,7 +21590,7 @@ ${rows}
21583
21590
  const {
21584
21591
  isLoaded: mathJaxLoaded
21585
21592
  } = useMathJax();
21586
- const context = useFormulize();
21593
+ const context = useStore();
21587
21594
  const config = context == null ? void 0 : context.config;
21588
21595
  const getVariable2 = React.useCallback(() => {
21589
21596
  return computationStore.variables.get(id);
@@ -21735,7 +21742,7 @@ ${rows}
21735
21742
  style = {},
21736
21743
  scale = 1
21737
21744
  }) => {
21738
- const context = useFormulize();
21745
+ const context = useStore();
21739
21746
  const instance = context == null ? void 0 : context.instance;
21740
21747
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21741
21748
  const computationStore = context == null ? void 0 : context.computationStore;
@@ -21953,7 +21960,7 @@ ${rows}
21953
21960
  className = "",
21954
21961
  style = {}
21955
21962
  }) => {
21956
- const context = useFormulize();
21963
+ const context = useStore();
21957
21964
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21958
21965
  const computationStore = context == null ? void 0 : context.computationStore;
21959
21966
  if (isLoading || !computationStore) {
@@ -22342,7 +22349,7 @@ ${rows}
22342
22349
  const Canvas = ({
22343
22350
  config
22344
22351
  }) => {
22345
- const context = useFormulize();
22352
+ const context = useStore();
22346
22353
  const computationStore = context == null ? void 0 : context.computationStore;
22347
22354
  const [variables, setVariables] = React.useState({});
22348
22355
  const {
@@ -22570,7 +22577,7 @@ ${rows}
22570
22577
  yAxisHovered = false
22571
22578
  }) => {
22572
22579
  var _a2;
22573
- const context = useFormulize();
22580
+ const context = useStore();
22574
22581
  const computationStore = context == null ? void 0 : context.computationStore;
22575
22582
  if (!computationStore) {
22576
22583
  return null;
@@ -23014,7 +23021,7 @@ ${rows}
23014
23021
  config
23015
23022
  }) => {
23016
23023
  var _a2, _b;
23017
- const context = useFormulize();
23024
+ const context = useStore();
23018
23025
  const computationStore = context == null ? void 0 : context.computationStore;
23019
23026
  const svgRef = React.useRef(null);
23020
23027
  const tooltipRef = React.useRef(null);
@@ -23636,7 +23643,7 @@ ${rows}
23636
23643
  if (!computationStore) {
23637
23644
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "plot2d-loading", children: "Loading plot..." });
23638
23645
  }
23639
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "formulize-plot2d", style: {
23646
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mn-plot2d", style: {
23640
23647
  position: "relative"
23641
23648
  }, children: [
23642
23649
  /* @__PURE__ */ jsxRuntime.jsx("svg", { ref: svgRef, style: {
@@ -24222,7 +24229,7 @@ ${rows}
24222
24229
  const Plot3D = mobxReactLite.observer(({
24223
24230
  config
24224
24231
  }) => {
24225
- const context = useFormulize();
24232
+ const context = useStore();
24226
24233
  const computationStore = context == null ? void 0 : context.computationStore;
24227
24234
  if (!computationStore) {
24228
24235
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "plot3d-loading", children: "Loading plot..." });
@@ -24267,7 +24274,7 @@ ${rows}
24267
24274
  }) => {
24268
24275
  const containerRef = React.useRef(null);
24269
24276
  const [isReady, setIsReady] = React.useState(false);
24270
- const context = useFormulize();
24277
+ const context = useStore();
24271
24278
  const computationStore = context == null ? void 0 : context.computationStore;
24272
24279
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
24273
24280
  const instance = context == null ? void 0 : context.instance;
@@ -24318,7 +24325,7 @@ ${rows}
24318
24325
  const StepControl = mobxReactLite.observer(({
24319
24326
  className = ""
24320
24327
  }) => {
24321
- const context = useFormulize();
24328
+ const context = useStore();
24322
24329
  const computationStore = (context == null ? void 0 : context.computationStore) ?? null;
24323
24330
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
24324
24331
  const containerStyle = {
@@ -24560,11 +24567,11 @@ ${rows}
24560
24567
  exports2.EmbeddedFormula = EmbeddedFormula;
24561
24568
  exports2.Formula = Formula$1;
24562
24569
  exports2.FormulaGenerator = Formula;
24563
- exports2.Formulize = Formulize;
24564
- exports2.FormulizeProvider = FormulizeProvider;
24565
24570
  exports2.InlineFormula = InlineFormula;
24566
24571
  exports2.InlineVariable = InlineVariable;
24572
+ exports2.Provider = Provider;
24567
24573
  exports2.StepControl = StepControl;
24574
+ exports2.Store = Store;
24568
24575
  exports2.Variable = Variable;
24569
24576
  exports2.VisualizationComponent = VisualizationComponent;
24570
24577
  exports2.createComputationStore = createComputationStore;
@@ -24576,7 +24583,7 @@ ${rows}
24576
24583
  exports2.register = register;
24577
24584
  exports2.registerBuiltInComponents = registerBuiltInComponents;
24578
24585
  exports2.unRegister = unRegister;
24579
- exports2.useFormulize = useFormulize;
24586
+ exports2.useStore = useStore;
24580
24587
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
24581
24588
  });
24582
24589
  //# sourceMappingURL=formulize.umd.js.map