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.
@@ -3595,7 +3595,7 @@ async function create$1(config) {
3595
3595
  const computationStore = createComputationStore();
3596
3596
  return initializeInstance(config, computationStore);
3597
3597
  }
3598
- const Formulize = {
3598
+ const Store = {
3599
3599
  create: create$1
3600
3600
  };
3601
3601
  const CanvasContextMenu = memo(({
@@ -17437,9 +17437,9 @@ const ExpressionNode = observer(({
17437
17437
  transform: "translateX(-50%)"
17438
17438
  } }) });
17439
17439
  });
17440
- const FormulizeContext = createContext(null);
17441
- const useFormulize = () => {
17442
- return useContext(FormulizeContext);
17440
+ const StoreContext = createContext(null);
17441
+ const useStore = () => {
17442
+ return useContext(StoreContext);
17443
17443
  };
17444
17444
  const getOrCreateStyleElement = () => {
17445
17445
  let styleElement = document.getElementById("custom-var-styles");
@@ -19209,10 +19209,13 @@ const SCALE_OUT_CLASS = "scale-out";
19209
19209
  const setupScaleWrappers = (container, selector, draggingVarIds) => {
19210
19210
  const elements = container.querySelectorAll(selector);
19211
19211
  elements.forEach((element) => {
19212
- var _a2;
19212
+ var _a2, _b;
19213
+ if ((_a2 = element.parentElement) == null ? void 0 : _a2.classList.contains(WRAPPER_CLASS)) {
19214
+ return;
19215
+ }
19213
19216
  const wrapper = document.createElement("span");
19214
19217
  wrapper.className = WRAPPER_CLASS;
19215
- (_a2 = element.parentNode) == null ? void 0 : _a2.insertBefore(wrapper, element);
19218
+ (_b = element.parentNode) == null ? void 0 : _b.insertBefore(wrapper, element);
19216
19219
  wrapper.appendChild(element);
19217
19220
  });
19218
19221
  };
@@ -19241,7 +19244,7 @@ const deactivateScaleWrapper = (element) => {
19241
19244
  };
19242
19245
  function updateVariableHoverState(container, highlightedVarIds, useScaleWrappers = false) {
19243
19246
  const highlightedSet = new Set(highlightedVarIds);
19244
- const currentlyHovered = container.querySelectorAll(".hovered");
19247
+ const currentlyHovered = container.querySelectorAll(".var-scale-wrapper .hovered");
19245
19248
  currentlyHovered.forEach((element) => {
19246
19249
  const htmlEl = element;
19247
19250
  if (!highlightedSet.has(htmlEl.id)) {
@@ -19270,7 +19273,7 @@ const FormulaNode = observer(({
19270
19273
  }) => {
19271
19274
  var _a2;
19272
19275
  const nodeRef = useRef(null);
19273
- const context = useFormulize();
19276
+ const context = useStore();
19274
19277
  const computationStore = context == null ? void 0 : context.computationStore;
19275
19278
  const [isInitialized, setIsInitialized] = useState(false);
19276
19279
  useEffect(() => {
@@ -19295,7 +19298,11 @@ const FormulaNode = observer(({
19295
19298
  };
19296
19299
  await renderFormulaWithMathJax(nodeRef.current, dataWithStores, isInitialized);
19297
19300
  if (nodeRef.current && computationStore) {
19298
- setupScaleWrappers(nodeRef.current, ".var-input, .var-base");
19301
+ setupScaleWrappers(
19302
+ nodeRef.current,
19303
+ ".var-input, .var-base"
19304
+ // computationStore.highlightedVarIds
19305
+ );
19299
19306
  }
19300
19307
  }, [data, computationStore, isInitialized]);
19301
19308
  useEffect(() => {
@@ -19410,8 +19417,8 @@ const LatexLabel = observer(({
19410
19417
  }) => {
19411
19418
  var _a2, _b;
19412
19419
  const labelRef = useRef(null);
19413
- const formulizeContext = useFormulize();
19414
- const labelFontSize = (_b = (_a2 = formulizeContext == null ? void 0 : formulizeContext.computationStore) == null ? void 0 : _a2.environment) == null ? void 0 : _b.labelFontSize;
19420
+ const coreContext = useStore();
19421
+ const labelFontSize = (_b = (_a2 = coreContext == null ? void 0 : coreContext.computationStore) == null ? void 0 : _a2.environment) == null ? void 0 : _b.labelFontSize;
19415
19422
  const fontSize = customFontSize ?? labelFontSize ?? 1;
19416
19423
  useEffect(() => {
19417
19424
  let isMounted = true;
@@ -19447,8 +19454,8 @@ const SVGLabel = observer(({
19447
19454
  const [svgData, setSvgData] = useState(null);
19448
19455
  const [error, setError] = useState(null);
19449
19456
  const [isLoading, setIsLoading] = useState(false);
19450
- const formulizeContext = useFormulize();
19451
- const computationStore = formulizeContext == null ? void 0 : formulizeContext.computationStore;
19457
+ const coreContext = useStore();
19458
+ const computationStore = coreContext == null ? void 0 : coreContext.computationStore;
19452
19459
  const fontSize = ((_a2 = computationStore == null ? void 0 : computationStore.environment) == null ? void 0 : _a2.fontSize) || 1;
19453
19460
  useEffect(() => {
19454
19461
  const loadSVG = async () => {
@@ -19551,7 +19558,7 @@ const InlineInput = observer(({
19551
19558
  variable,
19552
19559
  fontSize
19553
19560
  }) => {
19554
- const context = useFormulize();
19561
+ const context = useStore();
19555
19562
  const computationStore = context == null ? void 0 : context.computationStore;
19556
19563
  const currentValue = typeof variable.value === "number" ? variable.value : 0;
19557
19564
  const displayPrecision = variable.precision ?? INPUT_VARIABLE_DEFAULT.PRECISION;
@@ -19610,7 +19617,7 @@ const LabelNode = observer(({
19610
19617
  varId,
19611
19618
  formulaId
19612
19619
  } = data;
19613
- const context = useFormulize();
19620
+ const context = useStore();
19614
19621
  const computationStore = context == null ? void 0 : context.computationStore;
19615
19622
  const labelFontSize = (_a2 = computationStore == null ? void 0 : computationStore.environment) == null ? void 0 : _a2.labelFontSize;
19616
19623
  const variable = computationStore == null ? void 0 : computationStore.variables.get(varId);
@@ -19740,7 +19747,7 @@ const VariableNode = observer(({
19740
19747
  width,
19741
19748
  height
19742
19749
  } = data;
19743
- const context = useFormulize();
19750
+ const context = useStore();
19744
19751
  const computationStore = context == null ? void 0 : context.computationStore;
19745
19752
  if (!computationStore) {
19746
19753
  return null;
@@ -21170,7 +21177,7 @@ const Formula$1 = observer(({
21170
21177
  className = "",
21171
21178
  style = {}
21172
21179
  }) => {
21173
- const context = useFormulize();
21180
+ const context = useStore();
21174
21181
  const instance = context == null ? void 0 : context.instance;
21175
21182
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21176
21183
  const config = context == null ? void 0 : context.config;
@@ -21239,7 +21246,7 @@ const MathJaxLoader = ({
21239
21246
  window.MathJax.startup.defaultReady();
21240
21247
  window.MathJax.startup.promise.then(() => {
21241
21248
  var _a2;
21242
- console.log("MathJax loaded and ready by formulize-math with scale 2.0");
21249
+ console.log("MathJax loaded and ready by math-notation with scale 2.0");
21243
21250
  console.log("MathJax chtml config:", (_a2 = window.MathJax.config) == null ? void 0 : _a2.chtml);
21244
21251
  });
21245
21252
  }
@@ -21313,7 +21320,7 @@ const MathJaxLoader = ({
21313
21320
  }, children });
21314
21321
  };
21315
21322
  const useMathJax = () => useContext(MathJaxContext);
21316
- const FormulizeProviderInner = observer(({
21323
+ const ProviderInner = observer(({
21317
21324
  config,
21318
21325
  children,
21319
21326
  onError,
@@ -21336,7 +21343,7 @@ const FormulizeProviderInner = observer(({
21336
21343
  setIsLoading(false);
21337
21344
  return;
21338
21345
  }
21339
- const initializeFormulize = async () => {
21346
+ const initialize = async () => {
21340
21347
  setIsLoading(true);
21341
21348
  setError(null);
21342
21349
  try {
@@ -21347,7 +21354,7 @@ const FormulizeProviderInner = observer(({
21347
21354
  if (!window.MathJax || !window.MathJax.tex2chtml) {
21348
21355
  throw new Error("MathJax is not properly loaded");
21349
21356
  }
21350
- const newInstance = await Formulize.create(config);
21357
+ const newInstance = await Store.create(config);
21351
21358
  instanceRef.current = newInstance;
21352
21359
  if (config.stepping && newInstance.computationStore) {
21353
21360
  newInstance.computationStore.setStepping(true);
@@ -21368,7 +21375,7 @@ const FormulizeProviderInner = observer(({
21368
21375
  setIsLoading(false);
21369
21376
  }
21370
21377
  };
21371
- initializeFormulize();
21378
+ initialize();
21372
21379
  return () => {
21373
21380
  if (instanceRef.current) {
21374
21381
  instanceRef.current.destroy();
@@ -21390,10 +21397,10 @@ const FormulizeProviderInner = observer(({
21390
21397
  computationStore: (instance == null ? void 0 : instance.computationStore) ?? null,
21391
21398
  reinitialize
21392
21399
  }), [instance, config, isLoading, error, reinitialize]);
21393
- return /* @__PURE__ */ jsx(FormulizeContext.Provider, { value: contextValue, children });
21400
+ return /* @__PURE__ */ jsx(StoreContext.Provider, { value: contextValue, children });
21394
21401
  });
21395
- const FormulizeProvider = (props) => {
21396
- return /* @__PURE__ */ jsx(MathJaxLoader, { children: /* @__PURE__ */ jsx(FormulizeProviderInner, { ...props }) });
21402
+ const Provider = (props) => {
21403
+ return /* @__PURE__ */ jsx(MathJaxLoader, { children: /* @__PURE__ */ jsx(ProviderInner, { ...props }) });
21397
21404
  };
21398
21405
  const InlineFormulaInner = observer(({
21399
21406
  id,
@@ -21539,7 +21546,7 @@ const InlineFormula = observer(({
21539
21546
  style = {},
21540
21547
  scale = 1
21541
21548
  }) => {
21542
- const context = useFormulize();
21549
+ const context = useStore();
21543
21550
  const instance = context == null ? void 0 : context.instance;
21544
21551
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21545
21552
  const computationStore = context == null ? void 0 : context.computationStore;
@@ -21570,7 +21577,7 @@ const InlineVariableInner = observer(({
21570
21577
  const {
21571
21578
  isLoaded: mathJaxLoaded
21572
21579
  } = useMathJax();
21573
- const context = useFormulize();
21580
+ const context = useStore();
21574
21581
  const config = context == null ? void 0 : context.config;
21575
21582
  const getVariable2 = useCallback(() => {
21576
21583
  return computationStore.variables.get(id);
@@ -21722,7 +21729,7 @@ const InlineVariable = observer(({
21722
21729
  style = {},
21723
21730
  scale = 1
21724
21731
  }) => {
21725
- const context = useFormulize();
21732
+ const context = useStore();
21726
21733
  const instance = context == null ? void 0 : context.instance;
21727
21734
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21728
21735
  const computationStore = context == null ? void 0 : context.computationStore;
@@ -21940,7 +21947,7 @@ const EmbeddedFormula = observer(({
21940
21947
  className = "",
21941
21948
  style = {}
21942
21949
  }) => {
21943
- const context = useFormulize();
21950
+ const context = useStore();
21944
21951
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
21945
21952
  const computationStore = context == null ? void 0 : context.computationStore;
21946
21953
  if (isLoading || !computationStore) {
@@ -22329,7 +22336,7 @@ const ErrorDisplay = ({
22329
22336
  const Canvas = ({
22330
22337
  config
22331
22338
  }) => {
22332
- const context = useFormulize();
22339
+ const context = useStore();
22333
22340
  const computationStore = context == null ? void 0 : context.computationStore;
22334
22341
  const [variables, setVariables] = useState({});
22335
22342
  const {
@@ -22557,7 +22564,7 @@ const AxisLabels = observer(({
22557
22564
  yAxisHovered = false
22558
22565
  }) => {
22559
22566
  var _a2;
22560
- const context = useFormulize();
22567
+ const context = useStore();
22561
22568
  const computationStore = context == null ? void 0 : context.computationStore;
22562
22569
  if (!computationStore) {
22563
22570
  return null;
@@ -23001,7 +23008,7 @@ const Plot2D = observer(({
23001
23008
  config
23002
23009
  }) => {
23003
23010
  var _a2, _b;
23004
- const context = useFormulize();
23011
+ const context = useStore();
23005
23012
  const computationStore = context == null ? void 0 : context.computationStore;
23006
23013
  const svgRef = useRef(null);
23007
23014
  const tooltipRef = useRef(null);
@@ -23623,7 +23630,7 @@ const Plot2D = observer(({
23623
23630
  if (!computationStore) {
23624
23631
  return /* @__PURE__ */ jsx("div", { className: "plot2d-loading", children: "Loading plot..." });
23625
23632
  }
23626
- return /* @__PURE__ */ jsxs("div", { className: "formulize-plot2d", style: {
23633
+ return /* @__PURE__ */ jsxs("div", { className: "mn-plot2d", style: {
23627
23634
  position: "relative"
23628
23635
  }, children: [
23629
23636
  /* @__PURE__ */ jsx("svg", { ref: svgRef, style: {
@@ -24209,7 +24216,7 @@ const Plot3DInner = observer(({
24209
24216
  const Plot3D = observer(({
24210
24217
  config
24211
24218
  }) => {
24212
- const context = useFormulize();
24219
+ const context = useStore();
24213
24220
  const computationStore = context == null ? void 0 : context.computationStore;
24214
24221
  if (!computationStore) {
24215
24222
  return /* @__PURE__ */ jsx("div", { className: "plot3d-loading", children: "Loading plot..." });
@@ -24254,7 +24261,7 @@ const VisualizationComponent = observer(({
24254
24261
  }) => {
24255
24262
  const containerRef = useRef(null);
24256
24263
  const [isReady, setIsReady] = useState(false);
24257
- const context = useFormulize();
24264
+ const context = useStore();
24258
24265
  const computationStore = context == null ? void 0 : context.computationStore;
24259
24266
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
24260
24267
  const instance = context == null ? void 0 : context.instance;
@@ -24305,7 +24312,7 @@ const Button = ({
24305
24312
  const StepControl = observer(({
24306
24313
  className = ""
24307
24314
  }) => {
24308
- const context = useFormulize();
24315
+ const context = useStore();
24309
24316
  const computationStore = (context == null ? void 0 : context.computationStore) ?? null;
24310
24317
  const isLoading = (context == null ? void 0 : context.isLoading) ?? true;
24311
24318
  const containerStyle = {
@@ -24548,11 +24555,11 @@ export {
24548
24555
  EmbeddedFormula,
24549
24556
  Formula$1 as Formula,
24550
24557
  Formula as FormulaGenerator,
24551
- Formulize,
24552
- FormulizeProvider,
24553
24558
  InlineFormula,
24554
24559
  InlineVariable,
24560
+ Provider,
24555
24561
  StepControl,
24562
+ Store,
24556
24563
  Variable2 as Variable,
24557
24564
  VisualizationComponent,
24558
24565
  createComputationStore,
@@ -24564,6 +24571,6 @@ export {
24564
24571
  register,
24565
24572
  registerBuiltInComponents,
24566
24573
  unRegister,
24567
- useFormulize
24574
+ useStore
24568
24575
  };
24569
24576
  //# sourceMappingURL=formulize.es.js.map