@cliquify.me/state 8.0.6 → 8.1.0
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/dist/index.d.ts +2 -0
- package/dist/index.es.js +722 -695
- package/dist/index.umd.js +2 -2
- package/dist/state.d.ts +1 -1
- package/dist/utils/normalize-design.d.ts +50 -0
- package/package.json +6 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IDesign, ISize } from '@cliquify.me/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bring a design onto the shape the render layer expects.
|
|
5
|
+
*
|
|
6
|
+
* A design can arrive in several historical shapes. Until now every consumer
|
|
7
|
+
* translated between them by hand, which meant three copies of the same logic
|
|
8
|
+
* and one place it was missing:
|
|
9
|
+
*
|
|
10
|
+
* react-editor `src/app.tsx` and `src/appTemplate.tsx`
|
|
11
|
+
* video-renderer-site `src/version2/MyComp.tsx`
|
|
12
|
+
* video-remotion-previewer — nothing, so a generated design crashed it with
|
|
13
|
+
* "undefined is not iterable" before frame 1
|
|
14
|
+
*
|
|
15
|
+
* That last one is why this function exists. `elements-ui`'s caption element
|
|
16
|
+
* reads `details.words`, and `ICaptionDetails.words` is a *required* field, but
|
|
17
|
+
* the editor writes caption words to `metadata.words`. Whoever forgot to bridge
|
|
18
|
+
* the two got a hard crash rather than a missing caption.
|
|
19
|
+
*
|
|
20
|
+
* Call this once, wherever a design enters your process. It is pure: the input
|
|
21
|
+
* is left alone and only the items that actually changed are re-created, so
|
|
22
|
+
* normalising a design that is already normal is close to free.
|
|
23
|
+
*/
|
|
24
|
+
/** What a design may look like on the way in, before normalisation. */
|
|
25
|
+
export interface DenormalizedDesign extends Omit<IDesign, "size"> {
|
|
26
|
+
size?: ISize;
|
|
27
|
+
/** Older payloads carried the canvas size here. */
|
|
28
|
+
frame?: ISize;
|
|
29
|
+
/**
|
|
30
|
+
* Legacy split of item details into a parallel map. Superseded by inline
|
|
31
|
+
* `details` on each track item.
|
|
32
|
+
*/
|
|
33
|
+
trackItemDetailsMap?: Record<string, {
|
|
34
|
+
details?: Record<string, unknown>;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export interface NormalizeDesignOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Ensure every caption has a `details.words` array, inserting an empty one
|
|
40
|
+
* where nothing supplied it. Defaults to true: `ICaptionDetails.words` is
|
|
41
|
+
* required, and the caption element destructures it without a guard.
|
|
42
|
+
*/
|
|
43
|
+
ensureCaptionWords?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns `T` rather than promising a populated `size`: if the input carried
|
|
47
|
+
* neither `size` nor `frame` there is nothing to fill it from, and claiming
|
|
48
|
+
* otherwise in the type would just move the crash somewhere less obvious.
|
|
49
|
+
*/
|
|
50
|
+
export declare function normalizeDesign<T extends DenormalizedDesign>(design: T, options?: NormalizeDesignOptions): T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cliquify.me/state",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"typescript": "5.4.5",
|
|
29
29
|
"vite": "^5.2.0",
|
|
30
30
|
"vite-plugin-dts": "^3.9.1",
|
|
31
|
-
"
|
|
31
|
+
"vitest": "^3.2.7",
|
|
32
|
+
"@cliquify.me/types": "8.0.7",
|
|
32
33
|
"@cliquify.me/typescript-config": "0.0.2"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
@@ -42,11 +43,12 @@
|
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@designcombo/events": "^1.0.2",
|
|
45
|
-
"@cliquify.me/types": "8.0.
|
|
46
|
+
"@cliquify.me/types": "8.0.7"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"dev": "vite",
|
|
49
50
|
"build": "tsc && vite build",
|
|
50
|
-
"format": "prettier --write ."
|
|
51
|
+
"format": "prettier --write .",
|
|
52
|
+
"test": "vitest run"
|
|
51
53
|
}
|
|
52
54
|
}
|