Skip to content

Commit

Permalink
Create utils and cypress-test workspaces (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp authored Sep 2, 2023
1 parent d217db4 commit 0b5da97
Show file tree
Hide file tree
Showing 284 changed files with 1,150 additions and 29,628 deletions.
92 changes: 86 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"version": "1.0.0",
"description": "Monorepo for the DoenetML project",
"workspaces": [
"./packages/ui-components",
"./packages/utils",
"./packages/parser",
"./packages/doenetml-worker",
"./packages/virtual-keyboard",
Expand Down
2 changes: 1 addition & 1 deletion packages/codemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@doenet/codemirror",
"type": "module",
"description": "CodeMirror component for DoenetML",
"version": "0.6.0-alpha3",
"version": "*",
"license": "AGPL-3.0-or-later",
"homepage": "https://github.com/Doenet/DoenetML#readme",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/doenetml-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@doenet/doenetml-worker",
"type": "module",
"description": "Repo for compiled WebWorker code for DoenetML",
"version": "0.6.0-alpha3",
"version": "*",
"license": "AGPL-3.0-or-later",
"homepage": "https://github.com/Doenet/DoenetML#readme",
"private": false,
Expand Down
3 changes: 0 additions & 3 deletions packages/doenetml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
"build": "vite build",
"preview": "vite preview",
"test": "echo \"No tests \"",
"test-cypress": "cypress open",
"test-cypress-all": "cypress run -b 'chrome' --config video=false --headless",
"test-cypress-parallel": "cypress-parallel -s test-cypress-all -t 4 -d cypress/e2e -n ../../node_modules/cypress-multi-reporters",
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0"
},
"peerDependencies": {
Expand Down
56 changes: 25 additions & 31 deletions packages/doenetml/src/Core/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@ import { prng_alea } from "esm-seedrandom";
import me from "math-expressions";
import { createUniqueName, getNamespaceFromName } from "./utils/naming";
import * as serializeFunctions from "./utils/serializedStateProcessing";
import { deepCompare, deepClone } from "./utils/deepFunctions";
import createStateProxyHandler from "./StateProxyHandler";
import {
serializedComponentsReplacer,
serializedComponentsReviver,
deepCompare,
deepClone,
assignDoenetMLRange,
findAllNewlines,
getLineCharRange,
flattenDeep,
} from "@doenet/utils";
import {
convertAttributesForComponentType,
postProcessCopy,
verifyReplacementsMatchSpecifiedType,
} from "./utils/copy";
import { flattenDeep, mapDeep } from "./utils/array";
import { DependencyHandler } from "./Dependencies";
import {
preprocessMathInverseDefinition,
removeFunctionsMathExpressionClass,
} from "./utils/math";
import { returnDefaultGetArrayKeysFromVarName } from "./utils/stateVariables";
import { nanoid } from "nanoid";
import { cidFromText } from "./utils/cid";
import createComponentInfoObjects from "./utils/componentInfoObjects";
import { get as idb_get, set as idb_set } from "idb-keyval";
import axios from "axios";
import { gatherVariantComponents, getNumVariants } from "./utils/variants";
import {
assignDoenetMLRange,
findAllNewlines,
getLineCharRange,
} from "./utils/logging";

// string to componentClass: this.componentInfoObjects.allComponentClasses["string"]
// componentClass to string: componentClass.componentType
Expand Down Expand Up @@ -137,9 +139,9 @@ export default class Core {
stateVariableUpdatesForMissingComponents: JSON.parse(
JSON.stringify(
stateVariableChanges,
serializeFunctions.serializedComponentsReplacer,
serializedComponentsReplacer,
),
serializeFunctions.serializedComponentsReviver,
serializedComponentsReviver,
),
stateVariablesToEvaluate: [],
};
Expand All @@ -151,11 +153,8 @@ export default class Core {
this.newErrorWarning = true;

this.cumulativeStateVariableChanges = JSON.parse(
JSON.stringify(
stateVariableChanges,
serializeFunctions.serializedComponentsReplacer,
),
serializeFunctions.serializedComponentsReviver,
JSON.stringify(stateVariableChanges, serializedComponentsReplacer),
serializedComponentsReviver,
);

this.requestedVariantIndex = requestedVariantIndex;
Expand Down Expand Up @@ -409,13 +408,11 @@ export default class Core {

this.canonicalGeneratedVariantString = JSON.stringify(
await this.document.stateValues.generatedVariantInfo,
serializeFunctions.serializedComponentsReplacer,
serializedComponentsReplacer,
);
this.canonicalItemVariantStrings = (
await this.document.stateValues.itemVariantInfo
).map((x) =>
JSON.stringify(x, serializeFunctions.serializedComponentsReplacer),
);
).map((x) => JSON.stringify(x, serializedComponentsReplacer));

// Note: coreInfo is fixed even though this.rendererTypesInDocument could change
// Note 2: both canonical variant strings and original rendererTypesInDocument
Expand All @@ -431,7 +428,7 @@ export default class Core {

this.coreInfoString = JSON.stringify(
this.coreInfo,
serializeFunctions.serializedComponentsReplacer,
serializedComponentsReplacer,
);

this.messageViewerReady();
Expand Down Expand Up @@ -11178,17 +11175,14 @@ export default class Core {
activityVariantIndex: this.activityVariantIndex,
pageVariantIndex: this.requestedVariant.index,
verb: event.verb,
object: JSON.stringify(
event.object,
serializeFunctions.serializedComponentsReplacer,
),
object: JSON.stringify(event.object, serializedComponentsReplacer),
result: JSON.stringify(
removeFunctionsMathExpressionClass(event.result),
serializeFunctions.serializedComponentsReplacer,
serializedComponentsReplacer,
),
context: JSON.stringify(
event.context,
serializeFunctions.serializedComponentsReplacer,
serializedComponentsReplacer,
),
timestamp: new Date().toISOString().slice(0, 19).replace("T", " "),
version: "0.1.1",
Expand Down Expand Up @@ -12761,11 +12755,11 @@ export default class Core {
coreInfo: this.coreInfoString,
coreState: JSON.stringify(
this.cumulativeStateVariableChanges,
serializeFunctions.serializedComponentsReplacer,
serializedComponentsReplacer,
),
rendererState: JSON.stringify(
this.rendererState,
serializeFunctions.serializedComponentsReplacer,
serializedComponentsReplacer,
),
pageNumber: this.pageNumber,
attemptNumber: this.attemptNumber,
Expand Down Expand Up @@ -12888,15 +12882,15 @@ export default class Core {
{
coreState: JSON.parse(
data.coreState,
serializeFunctions.serializedComponentsReviver,
serializedComponentsReviver,
),
rendererState: JSON.parse(
data.rendererState,
serializeFunctions.serializedComponentsReviver,
serializedComponentsReviver,
),
coreInfo: JSON.parse(
data.coreInfo,
serializeFunctions.serializedComponentsReviver,
serializedComponentsReviver,
),
saveId: data.saveId,
},
Expand Down
10 changes: 6 additions & 4 deletions packages/doenetml/src/Core/Dependencies.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import readOnlyProxyHandler from "./ReadOnlyProxyHandler";
import { deepClone, deepCompare } from "./utils/deepFunctions";
import {
ancestorsIncludingComposites,
gatherDescendants,
} from "./utils/descendants";
import { getLineCharRange } from "./utils/logging";
import { retrieveTextFileForCid } from "./utils/retrieveTextFile";
import { convertComponentTarget } from "./utils/serializedStateProcessing";
import {
retrieveTextFileForCid,
deepClone,
deepCompare,
getLineCharRange,
} from "@doenet/utils";

const dependencyTypeArray = [];

Expand Down
3 changes: 1 addition & 2 deletions packages/doenetml/src/Core/components/Answer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import InlineComponent from "./abstract/InlineComponent";
import { deepCompare } from "../utils/deepFunctions";
import { renameStateVariable } from "../utils/stateVariables";
import {
serializedComponentsReplacer,
serializedComponentsReviver,
} from "../utils/serializedStateProcessing";
} from "@doenet/utils";
import sha1 from "crypto-js/sha1";
import Base64 from "crypto-js/enc-base64";
import stringify from "json-stringify-deterministic";
Expand Down
Loading

0 comments on commit 0b5da97

Please sign in to comment.