@routevn/creator-model 1.12.0 → 1.12.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.
- package/README.md +4 -0
- package/package.json +1 -1
- package/src/model.js +97 -45
package/README.md
CHANGED
|
@@ -294,6 +294,10 @@ Current animation update tween properties support either:
|
|
|
294
294
|
- `keyframes`
|
|
295
295
|
- `auto: { duration, easing }`
|
|
296
296
|
|
|
297
|
+
Transition animation `mask` accepts one mask object or a non-empty ordered
|
|
298
|
+
array. Each mask may define a non-negative safe-integer `delay` in
|
|
299
|
+
milliseconds.
|
|
300
|
+
|
|
297
301
|
## Current Scope
|
|
298
302
|
|
|
299
303
|
Currently implemented command types:
|
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -1930,6 +1930,7 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1930
1930
|
"softness",
|
|
1931
1931
|
"invert",
|
|
1932
1932
|
"sample",
|
|
1933
|
+
"delay",
|
|
1933
1934
|
"progress",
|
|
1934
1935
|
"progressDuration",
|
|
1935
1936
|
"progressEasing",
|
|
@@ -2108,6 +2109,16 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
2108
2109
|
);
|
|
2109
2110
|
}
|
|
2110
2111
|
|
|
2112
|
+
if (
|
|
2113
|
+
mask.delay !== undefined &&
|
|
2114
|
+
(!Number.isSafeInteger(mask.delay) || mask.delay < 0)
|
|
2115
|
+
) {
|
|
2116
|
+
return invalidFromErrorFactory(
|
|
2117
|
+
errorFactory,
|
|
2118
|
+
`${path}.delay must be a non-negative safe integer when provided`,
|
|
2119
|
+
);
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2111
2122
|
if (mask.progress !== undefined) {
|
|
2112
2123
|
{
|
|
2113
2124
|
const result = validateTweenProperty({
|
|
@@ -2171,6 +2182,30 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
2171
2182
|
}
|
|
2172
2183
|
};
|
|
2173
2184
|
|
|
2185
|
+
const validateAnimationMasks = ({ mask, path, errorFactory }) => {
|
|
2186
|
+
if (!Array.isArray(mask)) {
|
|
2187
|
+
return validateMaskDefinition({ mask, path, errorFactory });
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
if (mask.length === 0) {
|
|
2191
|
+
return invalidFromErrorFactory(
|
|
2192
|
+
errorFactory,
|
|
2193
|
+
`${path} must be a non-empty array when provided`,
|
|
2194
|
+
);
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
for (const [index, maskDefinition] of mask.entries()) {
|
|
2198
|
+
const result = validateMaskDefinition({
|
|
2199
|
+
mask: maskDefinition,
|
|
2200
|
+
path: `${path}[${index}]`,
|
|
2201
|
+
errorFactory,
|
|
2202
|
+
});
|
|
2203
|
+
if (result?.valid === false) {
|
|
2204
|
+
return result;
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
|
|
2174
2209
|
const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
|
|
2175
2210
|
{
|
|
2176
2211
|
const result = validateAllowedKeys({
|
|
@@ -2276,7 +2311,7 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
|
|
|
2276
2311
|
|
|
2277
2312
|
if (animation.mask !== undefined) {
|
|
2278
2313
|
{
|
|
2279
|
-
const result =
|
|
2314
|
+
const result = validateAnimationMasks({
|
|
2280
2315
|
mask: animation.mask,
|
|
2281
2316
|
path: `${path}.mask`,
|
|
2282
2317
|
errorFactory,
|
|
@@ -8119,43 +8154,41 @@ const validateAnimationMaskImageReferences = ({
|
|
|
8119
8154
|
details = {},
|
|
8120
8155
|
errorFactory = createPreconditionValidationError,
|
|
8121
8156
|
}) => {
|
|
8122
|
-
if (
|
|
8123
|
-
!isPlainObject(animation) ||
|
|
8124
|
-
animation.type !== "transition" ||
|
|
8125
|
-
!isPlainObject(animation.mask)
|
|
8126
|
-
) {
|
|
8157
|
+
if (!isPlainObject(animation) || animation.type !== "transition") {
|
|
8127
8158
|
return VALID_RESULT;
|
|
8128
8159
|
}
|
|
8129
8160
|
|
|
8130
|
-
const
|
|
8161
|
+
const maskDefinitions = Array.isArray(animation.mask)
|
|
8162
|
+
? animation.mask.map((mask, index) => ({
|
|
8163
|
+
mask,
|
|
8164
|
+
path: `${path}.mask[${index}]`,
|
|
8165
|
+
fieldPrefix: `mask[${index}].`,
|
|
8166
|
+
}))
|
|
8167
|
+
: isPlainObject(animation.mask)
|
|
8168
|
+
? [
|
|
8169
|
+
{
|
|
8170
|
+
mask: animation.mask,
|
|
8171
|
+
path: `${path}.mask`,
|
|
8172
|
+
fieldPrefix: "",
|
|
8173
|
+
},
|
|
8174
|
+
]
|
|
8175
|
+
: [];
|
|
8131
8176
|
|
|
8132
|
-
|
|
8133
|
-
const
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
path: `${path}.mask.imageId`,
|
|
8137
|
-
details: {
|
|
8138
|
-
...details,
|
|
8139
|
-
field: "imageId",
|
|
8140
|
-
imageId: mask.imageId,
|
|
8141
|
-
},
|
|
8142
|
-
errorFactory,
|
|
8143
|
-
});
|
|
8144
|
-
if (!result.valid) {
|
|
8145
|
-
return result;
|
|
8177
|
+
for (const maskDefinition of maskDefinitions) {
|
|
8178
|
+
const { mask, path: maskPath, fieldPrefix } = maskDefinition;
|
|
8179
|
+
if (!isPlainObject(mask)) {
|
|
8180
|
+
continue;
|
|
8146
8181
|
}
|
|
8147
|
-
}
|
|
8148
8182
|
|
|
8149
|
-
|
|
8150
|
-
for (const [index, imageId] of mask.imageIds.entries()) {
|
|
8183
|
+
if (mask.imageId !== undefined) {
|
|
8151
8184
|
const result = validateImageReference({
|
|
8152
8185
|
state,
|
|
8153
|
-
imageId,
|
|
8154
|
-
path: `${
|
|
8186
|
+
imageId: mask.imageId,
|
|
8187
|
+
path: `${maskPath}.imageId`,
|
|
8155
8188
|
details: {
|
|
8156
8189
|
...details,
|
|
8157
|
-
field:
|
|
8158
|
-
imageId,
|
|
8190
|
+
field: `${fieldPrefix}imageId`,
|
|
8191
|
+
imageId: mask.imageId,
|
|
8159
8192
|
},
|
|
8160
8193
|
errorFactory,
|
|
8161
8194
|
});
|
|
@@ -8163,27 +8196,46 @@ const validateAnimationMaskImageReferences = ({
|
|
|
8163
8196
|
return result;
|
|
8164
8197
|
}
|
|
8165
8198
|
}
|
|
8166
|
-
}
|
|
8167
8199
|
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8200
|
+
if (Array.isArray(mask.imageIds)) {
|
|
8201
|
+
for (const [index, imageId] of mask.imageIds.entries()) {
|
|
8202
|
+
const result = validateImageReference({
|
|
8203
|
+
state,
|
|
8204
|
+
imageId,
|
|
8205
|
+
path: `${maskPath}.imageIds[${index}]`,
|
|
8206
|
+
details: {
|
|
8207
|
+
...details,
|
|
8208
|
+
field: `${fieldPrefix}imageIds[${index}]`,
|
|
8209
|
+
imageId,
|
|
8210
|
+
},
|
|
8211
|
+
errorFactory,
|
|
8212
|
+
});
|
|
8213
|
+
if (!result.valid) {
|
|
8214
|
+
return result;
|
|
8215
|
+
}
|
|
8172
8216
|
}
|
|
8217
|
+
}
|
|
8173
8218
|
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8219
|
+
if (Array.isArray(mask.items)) {
|
|
8220
|
+
for (const [index, item] of mask.items.entries()) {
|
|
8221
|
+
if (item?.imageId === undefined) {
|
|
8222
|
+
continue;
|
|
8223
|
+
}
|
|
8224
|
+
|
|
8225
|
+
const result = validateImageReference({
|
|
8226
|
+
state,
|
|
8181
8227
|
imageId: item.imageId,
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8228
|
+
path: `${maskPath}.items[${index}].imageId`,
|
|
8229
|
+
details: {
|
|
8230
|
+
...details,
|
|
8231
|
+
field: `${fieldPrefix}items[${index}].imageId`,
|
|
8232
|
+
imageId: item.imageId,
|
|
8233
|
+
},
|
|
8234
|
+
errorFactory,
|
|
8235
|
+
});
|
|
8236
|
+
if (!result.valid) {
|
|
8237
|
+
return result;
|
|
8238
|
+
}
|
|
8187
8239
|
}
|
|
8188
8240
|
}
|
|
8189
8241
|
}
|