@routevn/creator-model 1.1.1 → 1.1.3

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 (3) hide show
  1. package/README.md +2 -0
  2. package/package.json +1 -1
  3. package/src/model.js +28 -18
package/README.md CHANGED
@@ -85,6 +85,8 @@ Design rules:
85
85
  this package
86
86
  - `project` may start empty; fields like `resolution` are optional until the
87
87
  model starts owning them
88
+ - random ids across RouteVN should use `nanoid` with the RouteVN base58 variant;
89
+ deterministic derived tokens such as partition hashes are a separate case
88
90
 
89
91
  ## File Structure
90
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routevn/creator-model",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/model.js CHANGED
@@ -54,7 +54,7 @@ const normalizeStateCollections = (state) => {
54
54
  const isString = (value) => typeof value === "string";
55
55
  const isHexColor = (value) =>
56
56
  typeof value === "string" && /^#[0-9a-fA-F]{6}$/.test(value);
57
- const LIVE_TWEEN_PROPERTY_KEYS = [
57
+ const UPDATE_TWEEN_PROPERTY_KEYS = [
58
58
  "alpha",
59
59
  "x",
60
60
  "y",
@@ -62,7 +62,7 @@ const LIVE_TWEEN_PROPERTY_KEYS = [
62
62
  "scaleY",
63
63
  "rotation",
64
64
  ];
65
- const REPLACE_TWEEN_PROPERTY_KEYS = [
65
+ const TRANSITION_TWEEN_PROPERTY_KEYS = [
66
66
  "translateX",
67
67
  "translateY",
68
68
  "alpha",
@@ -109,6 +109,7 @@ const VARIABLE_SCOPE_KEYS = ["context", "global-device", "global-account"];
109
109
  const VARIABLE_TYPE_KEYS = ["string", "number", "boolean"];
110
110
  const LAYOUT_TYPE_KEYS = ["normal", "dialogue", "nvl", "choice"];
111
111
  const LAYOUT_ELEMENT_TEXT_STYLE_ALIGN_KEYS = ["left", "center", "right"];
112
+ const LAYOUT_TEXT_REVEAL_EFFECT_KEYS = ["typewriter", "softWipe", "none"];
112
113
  const LAYOUT_ELEMENT_BASE_TYPES = [
113
114
  "folder",
114
115
  "container",
@@ -1325,14 +1326,14 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1325
1326
  );
1326
1327
  }
1327
1328
 
1328
- if (animation.type !== "live" && animation.type !== "replace") {
1329
+ if (animation.type !== "update" && animation.type !== "transition") {
1329
1330
  return invalidFromErrorFactory(
1330
1331
  errorFactory,
1331
- `${path}.type must be 'live' or 'replace'`,
1332
+ `${path}.type must be 'update' or 'transition'`,
1332
1333
  );
1333
1334
  }
1334
1335
 
1335
- if (animation.type === "live") {
1336
+ if (animation.type === "update") {
1336
1337
  if (
1337
1338
  animation.prev !== undefined ||
1338
1339
  animation.next !== undefined ||
@@ -1340,23 +1341,23 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1340
1341
  ) {
1341
1342
  return invalidFromErrorFactory(
1342
1343
  errorFactory,
1343
- `${path}.live animations cannot define prev, next, or mask`,
1344
+ `${path}.update animations cannot define prev, next, or mask`,
1344
1345
  );
1345
1346
  }
1346
1347
 
1347
1348
  if (animation.tween === undefined) {
1348
1349
  return invalidFromErrorFactory(
1349
1350
  errorFactory,
1350
- `${path}.tween is required when ${path}.type is 'live'`,
1351
+ `${path}.tween is required when ${path}.type is 'update'`,
1351
1352
  );
1352
1353
  }
1353
1354
 
1354
1355
  {
1355
1356
  const result = validateTweenDefinition({
1356
1357
  tween: animation.tween,
1357
- allowedProperties: LIVE_TWEEN_PROPERTY_KEYS,
1358
+ allowedProperties: UPDATE_TWEEN_PROPERTY_KEYS,
1358
1359
  path: `${path}.tween`,
1359
- unsupportedMessage: "is not a supported live tween property",
1360
+ unsupportedMessage: "is not a supported update tween property",
1360
1361
  errorFactory,
1361
1362
  });
1362
1363
  if (result?.valid === false) {
@@ -1370,7 +1371,7 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1370
1371
  if (animation.tween !== undefined) {
1371
1372
  return invalidFromErrorFactory(
1372
1373
  errorFactory,
1373
- `${path}.replace animations cannot define tween`,
1374
+ `${path}.transition animations cannot define tween`,
1374
1375
  );
1375
1376
  }
1376
1377
 
@@ -1381,7 +1382,7 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1381
1382
  ) {
1382
1383
  return invalidFromErrorFactory(
1383
1384
  errorFactory,
1384
- `${path} must define at least one of prev, next, or mask when ${path}.type is 'replace'`,
1385
+ `${path} must define at least one of prev, next, or mask when ${path}.type is 'transition'`,
1385
1386
  );
1386
1387
  }
1387
1388
 
@@ -1405,9 +1406,9 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1405
1406
  {
1406
1407
  const result = validateTweenDefinition({
1407
1408
  tween: animation[side].tween,
1408
- allowedProperties: REPLACE_TWEEN_PROPERTY_KEYS,
1409
+ allowedProperties: TRANSITION_TWEEN_PROPERTY_KEYS,
1409
1410
  path: `${path}.${side}.tween`,
1410
- unsupportedMessage: "is not a supported replace tween property",
1411
+ unsupportedMessage: "is not a supported transition tween property",
1411
1412
  errorFactory,
1412
1413
  });
1413
1414
  if (result?.valid === false) {
@@ -2095,11 +2096,7 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
2095
2096
  }
2096
2097
  };
2097
2098
 
2098
- const validateLayoutElementTextStyle = ({
2099
- textStyle,
2100
- path,
2101
- errorFactory,
2102
- }) => {
2099
+ const validateLayoutElementTextStyle = ({ textStyle, path, errorFactory }) => {
2103
2100
  {
2104
2101
  const result = validateAllowedKeys({
2105
2102
  value: textStyle,
@@ -2202,6 +2199,7 @@ const validateLayoutElementData = ({
2202
2199
  "text",
2203
2200
  "textStyle",
2204
2201
  "displaySpeed",
2202
+ "revealEffect",
2205
2203
  "imageId",
2206
2204
  "hoverImageId",
2207
2205
  "clickImageId",
@@ -2314,6 +2312,7 @@ const validateLayoutElementData = ({
2314
2312
  "clickTextStyleId",
2315
2313
  "containerType",
2316
2314
  "variableId",
2315
+ "revealEffect",
2317
2316
  "thumbImageId",
2318
2317
  "barImageId",
2319
2318
  "hoverThumbImageId",
@@ -2335,6 +2334,16 @@ const validateLayoutElementData = ({
2335
2334
  );
2336
2335
  }
2337
2336
 
2337
+ if (
2338
+ data.revealEffect !== undefined &&
2339
+ !LAYOUT_TEXT_REVEAL_EFFECT_KEYS.includes(data.revealEffect)
2340
+ ) {
2341
+ return invalidFromErrorFactory(
2342
+ errorFactory,
2343
+ `${path}.revealEffect must be one of ${LAYOUT_TEXT_REVEAL_EFFECT_KEYS.join(", ")} when provided`,
2344
+ );
2345
+ }
2346
+
2338
2347
  if (
2339
2348
  data.direction !== undefined &&
2340
2349
  data.direction !== "horizontal" &&
@@ -2444,6 +2453,7 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
2444
2453
  "text",
2445
2454
  "textStyle",
2446
2455
  "displaySpeed",
2456
+ "revealEffect",
2447
2457
  "imageId",
2448
2458
  "hoverImageId",
2449
2459
  "clickImageId",