gwchq-textjam 0.1.113 → 0.1.114

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -370315,7 +370315,7 @@ const PyodideRunner = ({ active, packageApiUrl, }) => {
370315
370315
  destroyAndRecreateWorker();
370316
370316
  dispatch((0, EditorSlice_1.setError)({
370317
370317
  type: Errors_1.ErrorType.RUNTIME_ERROR,
370318
- message: "Execution was force-stopped.",
370318
+ message: "Execution interrupted",
370319
370319
  }));
370320
370320
  dispatch((0, EditorSlice_1.codeRunHandled)());
370321
370321
  };
@@ -373641,6 +373641,7 @@ const useProjectPersistence = ({ user, projectData, hasShownSavePrompt, saveProj
373641
373641
  const saving = (0, stores_1.useAppSelector)((state) => state.editor.saving);
373642
373642
  const justLoaded = (0, stores_1.useAppSelector)((state) => state.editor.justLoaded);
373643
373643
  const leaveFlow = (0, stores_1.useAppSelector)((state) => state.leaveFlow);
373644
+ const codeRunTriggered = (0, stores_1.useAppSelector)((state) => state.editor.codeRunTriggered);
373644
373645
  const dispatch = (0, react_redux_1.useDispatch)();
373645
373646
  const { deleteValueFromCache, upsertCacheValue } = (0, useProjectCache_1.useProjectCache)();
373646
373647
  const handleSave = (0, react_1.useCallback)(async () => {
@@ -373730,10 +373731,14 @@ const useProjectPersistence = ({ user, projectData, hasShownSavePrompt, saveProj
373730
373731
  leaveFlow.status,
373731
373732
  ]);
373732
373733
  (0, react_1.useEffect)(() => {
373733
- if (saveTriggered && saving === types_1.SavingState.IDLE) {
373734
- handleSave();
373734
+ if (!saveTriggered || saving !== types_1.SavingState.IDLE)
373735
+ return;
373736
+ if (codeRunTriggered) {
373737
+ dispatch((0, EditorSlice_1.stopCodeRun)());
373738
+ return;
373735
373739
  }
373736
- }, [saveTriggered, handleSave, saving]);
373740
+ handleSave();
373741
+ }, [saveTriggered, codeRunTriggered, handleSave, saving, dispatch]);
373737
373742
  // Autosave
373738
373743
  (0, react_1.useEffect)(() => {
373739
373744
  const debouncer = setTimeout(() => {
@@ -373780,6 +373785,7 @@ const createProjectArchive_1 = __webpack_require__(46514);
373780
373785
  const useProjectRemix = ({ projectData, saveProject, }) => {
373781
373786
  const project = (0, stores_1.useAppSelector)((state) => state.editor.project);
373782
373787
  const remixTriggered = (0, stores_1.useAppSelector)((state) => state.editor.remixTriggered);
373788
+ const codeRunTriggered = (0, stores_1.useAppSelector)((state) => state.editor.codeRunTriggered);
373783
373789
  const dispatch = (0, react_redux_1.useDispatch)();
373784
373790
  const remixStartedRef = (0, react_1.useRef)(false);
373785
373791
  (0, react_1.useEffect)(() => {
@@ -373787,11 +373793,16 @@ const useProjectRemix = ({ projectData, saveProject, }) => {
373787
373793
  remixStartedRef.current = false;
373788
373794
  return;
373789
373795
  }
373790
- if (remixStartedRef.current)
373791
- return;
373792
373796
  if (!project || Object.keys(project).length === 0)
373793
373797
  return;
373794
- if (!project?.components?.length)
373798
+ if (!project.components?.length)
373799
+ return;
373800
+ if (codeRunTriggered) {
373801
+ dispatch((0, EditorSlice_1.stopCodeRun)());
373802
+ dispatch((0, EditorSlice_1.stopDraw)());
373803
+ return;
373804
+ }
373805
+ if (remixStartedRef.current)
373795
373806
  return;
373796
373807
  remixStartedRef.current = true;
373797
373808
  const run = async () => {
@@ -373805,10 +373816,12 @@ const useProjectRemix = ({ projectData, saveProject, }) => {
373805
373816
  }
373806
373817
  catch (e) {
373807
373818
  console.error(e);
373819
+ remixStartedRef.current = false;
373820
+ dispatch((0, EditorSlice_1.setRemixTriggered)(false));
373808
373821
  }
373809
373822
  };
373810
373823
  run().catch(console.error);
373811
- }, [remixTriggered, project, saveProject]);
373824
+ }, [remixTriggered, codeRunTriggered, project, saveProject, dispatch]);
373812
373825
  (0, react_1.useEffect)(() => {
373813
373826
  if (!remixTriggered)
373814
373827
  return;
@@ -373820,6 +373833,7 @@ const useProjectRemix = ({ projectData, saveProject, }) => {
373820
373833
  dispatch((0, EditorSlice_1.stopDraw)());
373821
373834
  dispatch((0, EditorSlice_1.resetState)());
373822
373835
  dispatch((0, EditorSlice_1.setRemixTriggered)(false));
373836
+ remixStartedRef.current = false;
373823
373837
  }, [dispatch, remixTriggered, project?.identifier, projectData?.identifier]);
373824
373838
  };
373825
373839
  exports.useProjectRemix = useProjectRemix;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gwchq-textjam",
3
3
  "description": "Embeddable React editor used in Raspberry Pi text-based projects.",
4
- "version": "0.1.113",
4
+ "version": "0.1.114",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/GirlsFirst/gwchq-textjam",
7
7
  "author": "Girls Who Code HQ",