@drawnagency/primitives 0.1.72 → 0.1.74
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/{chunk-2HZB675H.js → chunk-7T2WQSWF.js} +2 -2
- package/dist/{chunk-7SIZ2LV5.js → chunk-IFHRHV7S.js} +1 -1
- package/dist/{chunk-VHINNGIF.js → chunk-NKVZGPR6.js} +1 -1
- package/dist/{chunk-BTGHF3SW.js → chunk-RIVBCL6U.js} +29 -3
- package/dist/{chunk-TOBPMMRM.js → chunk-S55OZ7F2.js} +8 -0
- package/dist/{chunk-WCALKWPO.js → chunk-T7MP7ANP.js} +11 -7
- package/dist/{chunk-RBTSUR5V.js → chunk-Y4JQGO6G.js} +10 -1
- package/dist/{chunk-UBK2IZ6G.js → chunk-YYDQGA2N.js} +13 -12
- package/dist/components/editor/index.js +3 -3
- package/dist/components/primitives/ResolvedMedia.d.ts.map +1 -1
- package/dist/components/primitives/index.js +4 -4
- package/dist/components/sections/Media/MediaBlock.d.ts.map +1 -1
- package/dist/components/sections/Video/VideoBlock.d.ts +2 -1
- package/dist/components/sections/Video/VideoBlock.d.ts.map +1 -1
- package/dist/components/sections/Video/index.d.ts +2 -1
- package/dist/components/sections/Video/index.d.ts.map +1 -1
- package/dist/components/sections/all-sections.d.ts +2 -1
- package/dist/components/sections/all-sections.d.ts.map +1 -1
- package/dist/components/sections/brand-guide.js +4 -4
- package/dist/components/sections/core-sections.d.ts +2 -1
- package/dist/components/sections/core-sections.d.ts.map +1 -1
- package/dist/components/sections/register-schemas.js +8 -8
- package/dist/components/sections/register.js +8 -8
- package/dist/components/shared/VideoSourceField.d.ts.map +1 -1
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/hooks/useEditorPublish.d.ts +4 -1
- package/dist/hooks/useEditorPublish.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/save-chunks.d.ts +28 -0
- package/dist/lib/save-chunks.d.ts.map +1 -0
- package/dist/lib/video-url.d.ts +10 -1
- package/dist/lib/video-url.d.ts.map +1 -1
- package/dist/lib/video-url.js +1 -1
- package/dist/media/index.js +5 -1
- package/dist/media/resolve.d.ts +14 -0
- package/dist/media/resolve.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/primitives/ResolvedMedia.tsx +10 -5
- package/src/components/sections/Media/MediaBlock.tsx +2 -1
- package/src/components/sections/Video/VideoBlock.tsx +9 -1
- package/src/components/sections/Video/index.tsx +11 -6
- package/src/components/shared/VideoSourceField.tsx +32 -1
- package/src/components/shell/EditorShell.tsx +8 -2
- package/src/hooks/useEditorPublish.ts +134 -50
- package/src/lib/save-chunks.ts +53 -0
- package/src/lib/video-url.ts +18 -5
- package/src/media/resolve.ts +18 -0
package/src/lib/video-url.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type InstagramKind = "post" | "reel" | "tv";
|
|
2
|
+
export type ParsedVideoUrl =
|
|
3
|
+
| { provider: "youtube" | "vimeo"; id: string }
|
|
4
|
+
| { provider: "instagram"; id: string; kind: InstagramKind };
|
|
2
5
|
|
|
3
6
|
const YT_ID = /^[\w-]{6,20}$/;
|
|
4
7
|
|
|
@@ -29,11 +32,21 @@ export function parseVideoUrl(raw: string): ParsedVideoUrl | null {
|
|
|
29
32
|
const m = url.pathname.match(/\/(\d{6,12})$/);
|
|
30
33
|
return m ? { provider: "vimeo", id: m[1] } : null;
|
|
31
34
|
}
|
|
35
|
+
if (host === "instagram.com" || host === "m.instagram.com") {
|
|
36
|
+
// Canonical (/reel/{code}) or username-prefixed (/{user}/p/{code}) URLs.
|
|
37
|
+
// NOT /share/ links — their ids are opaque redirect tokens, not shortcodes.
|
|
38
|
+
const m = url.pathname.match(/^(?:\/([\w.]+))?\/(p|reel|reels|tv)\/([\w-]{5,20})\/?$/);
|
|
39
|
+
if (!m || m[1] === "share") return null;
|
|
40
|
+
const kind: InstagramKind = m[2] === "p" ? "post" : m[2] === "tv" ? "tv" : "reel";
|
|
41
|
+
return { provider: "instagram", id: m[3], kind };
|
|
42
|
+
}
|
|
32
43
|
return null;
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
const IG_PATH: Record<InstagramKind, string> = { post: "p", reel: "reel", tv: "tv" };
|
|
47
|
+
|
|
48
|
+
export function embedUrl(p: { provider: "youtube" | "vimeo" | "instagram"; id: string; kind?: InstagramKind }): string {
|
|
49
|
+
if (p.provider === "youtube") return `https://www.youtube-nocookie.com/embed/${p.id}`;
|
|
50
|
+
if (p.provider === "instagram") return `https://www.instagram.com/${IG_PATH[p.kind ?? "post"]}/${p.id}/embed/`;
|
|
51
|
+
return `https://player.vimeo.com/video/${p.id}`;
|
|
39
52
|
}
|
package/src/media/resolve.ts
CHANGED
|
@@ -68,3 +68,21 @@ export function resolveManifestReferences(
|
|
|
68
68
|
|
|
69
69
|
return content;
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Keys stamped onto media refs by resolveManifestReferences above — derived
|
|
74
|
+
* from the referenced media item, never authored by the editor. Must stay in
|
|
75
|
+
* sync with the `patch` object built in resolveManifestReferences.
|
|
76
|
+
*/
|
|
77
|
+
export const BAKED_MEDIA_KEYS = ["src", "srcset", "alt", "width", "height", "poster"] as const;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Re-point a media ref at a different library item. Drops every baked field so
|
|
81
|
+
* stale values resolved for the PREVIOUS image can't shadow the new one in the
|
|
82
|
+
* editor (ResolvedMedia prefers an explicit src prop over live resolution).
|
|
83
|
+
*/
|
|
84
|
+
export function rebindImageRef<T extends { imageId?: string }>(ref: T, imageId: string): T {
|
|
85
|
+
const fresh = { ...ref, imageId } as Record<string, unknown>;
|
|
86
|
+
for (const key of BAKED_MEDIA_KEYS) delete fresh[key];
|
|
87
|
+
return fresh as T;
|
|
88
|
+
}
|