@routevn/creator-model 1.1.3 → 1.1.4
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.
- package/package.json +1 -1
- package/src/index.js +6 -0
- package/src/model.js +12 -4
- package/src/systemVariables.js +42 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/model.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
isPlainObject,
|
|
16
16
|
removeTreeNode,
|
|
17
17
|
} from "./helpers.js";
|
|
18
|
+
import { isSystemVariableId } from "./systemVariables.js";
|
|
18
19
|
|
|
19
20
|
const COLLECTION_KEYS = [
|
|
20
21
|
"scenes",
|
|
@@ -220,6 +221,15 @@ const invalidInvariant = (message, details = {}) =>
|
|
|
220
221
|
details,
|
|
221
222
|
});
|
|
222
223
|
|
|
224
|
+
const isVariableReferenceTarget = (state, variableId) => {
|
|
225
|
+
if (isSystemVariableId(variableId)) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const variable = state.variables.items[variableId];
|
|
230
|
+
return isPlainObject(variable) && variable.type !== "folder";
|
|
231
|
+
};
|
|
232
|
+
|
|
223
233
|
const toDomainErrorDetails = (publicError) => {
|
|
224
234
|
const details = isPlainObject(publicError?.details)
|
|
225
235
|
? { ...publicError.details }
|
|
@@ -3899,8 +3909,7 @@ export const assertInvariants = ({ state }) => {
|
|
|
3899
3909
|
elementId,
|
|
3900
3910
|
targetId,
|
|
3901
3911
|
}) => {
|
|
3902
|
-
|
|
3903
|
-
if (!isPlainObject(variable) || variable.type === "folder") {
|
|
3912
|
+
if (!isVariableReferenceTarget(state, targetId)) {
|
|
3904
3913
|
return invalidInvariant(
|
|
3905
3914
|
`${ownerLabel} element variableId must reference an existing non-folder variable`,
|
|
3906
3915
|
{
|
|
@@ -6511,8 +6520,7 @@ const validateVisualElementReferenceTargets = ({
|
|
|
6511
6520
|
}
|
|
6512
6521
|
|
|
6513
6522
|
if (data.variableId !== undefined) {
|
|
6514
|
-
|
|
6515
|
-
if (!isPlainObject(variable) || variable.type === "folder") {
|
|
6523
|
+
if (!isVariableReferenceTarget(state, data.variableId)) {
|
|
6516
6524
|
return invalidFromErrorFactory(
|
|
6517
6525
|
errorFactory,
|
|
6518
6526
|
`${ownerLabel} element variableId must reference an existing non-folder variable`,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const SYSTEM_VARIABLE_GROUPS = Object.freeze([
|
|
2
|
+
{
|
|
3
|
+
id: "routeEngine",
|
|
4
|
+
name: "Route Engine",
|
|
5
|
+
variables: Object.freeze([
|
|
6
|
+
{
|
|
7
|
+
id: "_skipUnseenText",
|
|
8
|
+
name: "Skip Unseen Text",
|
|
9
|
+
scope: "global-device",
|
|
10
|
+
type: "boolean",
|
|
11
|
+
default: false,
|
|
12
|
+
description:
|
|
13
|
+
"When enabled, skip mode can continue through lines the player has not viewed yet.",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "_dialogueTextSpeed",
|
|
17
|
+
name: "Dialogue Text Speed",
|
|
18
|
+
scope: "global-device",
|
|
19
|
+
type: "number",
|
|
20
|
+
default: 50,
|
|
21
|
+
description:
|
|
22
|
+
"Controls the default dialogue text speed stored for this device.",
|
|
23
|
+
},
|
|
24
|
+
]),
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
export const SYSTEM_VARIABLE_IDS = Object.freeze(
|
|
29
|
+
SYSTEM_VARIABLE_GROUPS.flatMap((group) =>
|
|
30
|
+
(group.variables || []).map((variable) => variable.id),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const SYSTEM_VARIABLE_ID_SET = new Set(SYSTEM_VARIABLE_IDS);
|
|
35
|
+
|
|
36
|
+
export const isSystemVariableId = (value) => {
|
|
37
|
+
return typeof value === "string" && SYSTEM_VARIABLE_ID_SET.has(value);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const getSystemVariableDefinitions = () => {
|
|
41
|
+
return SYSTEM_VARIABLE_GROUPS.flatMap((group) => group.variables || []);
|
|
42
|
+
};
|