@lalalic/markcut 2.8.0 → 2.9.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/README.md +29 -0
- package/package.json +1 -1
- package/skills/markcut/SKILL.md +12 -45
- package/skills/markcut/docs/components.md +46 -0
- package/skills/markcut/docs/markdown-descriptive.md +12 -0
- package/skills/markcut/docs/sound-effects.md +45 -0
- package/src/config.mjs +2 -2
- package/src/descriptive/compiler.ts +4 -0
- package/src/descriptive/markdown.ts +2 -0
- package/src/player/browser.tsx +95 -5
- package/src/player/bundle/player.js +783 -593
- package/src/player/components/EditControls.tsx +6 -3
- package/src/player/components/EditMessagePanel.tsx +96 -0
- package/src/player/components/HeaderBar.tsx +9 -11
- package/src/player/components/index.ts +1 -0
- package/src/player/pipeline.mjs +6 -2
- package/src/player/server-shared.mjs +4 -1
- package/src/player/server.mjs +202 -42
- package/src/render/cli.mjs +1 -1
- package/src/schema/index.ts +2 -0
- package/src/types/Map.tsx +51 -1
- package/tests/tmp/vision-1784830584961/images/.normalized/test-photo_384.jpg +0 -0
- package/tests/tmp/vision-1784830584961/images/metadata.json +0 -8
- package/tests/tmp/vision-1784830584961/images/test-photo.png +0 -0
- package/tmp/frontmatter-test.ts +0 -21
package/src/types/Map.tsx
CHANGED
|
@@ -39,6 +39,15 @@ function resolveApiKey(stream: MapStream): string {
|
|
|
39
39
|
return "";
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function resolveMapLocale(language?: string, region?: string): { language?: string; region?: string } {
|
|
43
|
+
if (!language) return { language: undefined, region };
|
|
44
|
+
const lang = language.trim().toLowerCase();
|
|
45
|
+
if (lang === "zh") return { language: "zh-CN", region: region ?? "CN" };
|
|
46
|
+
if (lang === "en") return { language: "en", region: region ?? "US" };
|
|
47
|
+
if (lang.startsWith("zh-")) return { language, region: region ?? "CN" };
|
|
48
|
+
return { language, region };
|
|
49
|
+
}
|
|
50
|
+
|
|
42
51
|
// ============================================================
|
|
43
52
|
// MapLeaf — entry point, renders each action as a Sequence
|
|
44
53
|
// ============================================================
|
|
@@ -58,13 +67,53 @@ export function MapLeaf({ stream }: { stream: MapStream }) {
|
|
|
58
67
|
const mapType = stream.mapType ?? "roadmap";
|
|
59
68
|
const travelMode = stream.travelMode ?? "DRIVING";
|
|
60
69
|
const markerEmoji = stream.routeMarker ?? "🚗";
|
|
70
|
+
const mapLocale = React.useMemo(
|
|
71
|
+
() => resolveMapLocale(stream.language, stream.region),
|
|
72
|
+
[stream.language, stream.region],
|
|
73
|
+
);
|
|
74
|
+
const mapLoadHandleRef = React.useRef<number | null>(null);
|
|
75
|
+
const mapLoadContinuedRef = React.useRef(false);
|
|
76
|
+
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
mapLoadHandleRef.current = delayRender("Waiting for map tiles to load...");
|
|
79
|
+
mapLoadContinuedRef.current = false;
|
|
80
|
+
|
|
81
|
+
// Avoid hanging indefinitely when map tiles fail to load.
|
|
82
|
+
const fallbackTimer = window.setTimeout(() => {
|
|
83
|
+
if (!mapLoadContinuedRef.current && mapLoadHandleRef.current !== null) {
|
|
84
|
+
continueRender(mapLoadHandleRef.current);
|
|
85
|
+
mapLoadContinuedRef.current = true;
|
|
86
|
+
}
|
|
87
|
+
}, 8000);
|
|
88
|
+
|
|
89
|
+
return () => {
|
|
90
|
+
window.clearTimeout(fallbackTimer);
|
|
91
|
+
if (!mapLoadContinuedRef.current && mapLoadHandleRef.current !== null) {
|
|
92
|
+
continueRender(mapLoadHandleRef.current);
|
|
93
|
+
mapLoadContinuedRef.current = true;
|
|
94
|
+
}
|
|
95
|
+
mapLoadHandleRef.current = null;
|
|
96
|
+
};
|
|
97
|
+
}, [stream.id, start, end]);
|
|
98
|
+
|
|
99
|
+
const handleTilesLoaded = React.useCallback(() => {
|
|
100
|
+
if (!mapLoadContinuedRef.current && mapLoadHandleRef.current !== null) {
|
|
101
|
+
continueRender(mapLoadHandleRef.current);
|
|
102
|
+
mapLoadContinuedRef.current = true;
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
105
|
+
|
|
61
106
|
return (
|
|
62
107
|
<Sequence
|
|
63
108
|
durationInFrames={durFrames}
|
|
64
109
|
from={Math.floor(fps * start)}
|
|
65
110
|
layout="none"
|
|
66
111
|
>
|
|
67
|
-
<APIProvider
|
|
112
|
+
<APIProvider
|
|
113
|
+
apiKey={apiKey}
|
|
114
|
+
language={mapLocale.language}
|
|
115
|
+
region={mapLocale.region}
|
|
116
|
+
>
|
|
68
117
|
<GoogleMap
|
|
69
118
|
mapId={String(stream.id ?? "map")}
|
|
70
119
|
defaultCenter={center}
|
|
@@ -74,6 +123,7 @@ export function MapLeaf({ stream }: { stream: MapStream }) {
|
|
|
74
123
|
disableDefaultUI: true,
|
|
75
124
|
zoomControl: false,
|
|
76
125
|
}}
|
|
126
|
+
onTilesLoaded={handleTilesLoaded}
|
|
77
127
|
style={{ width: "100%", height: "100%", position: "absolute" }}
|
|
78
128
|
>
|
|
79
129
|
<RouteWithMarker
|
|
Binary file
|
|
Binary file
|
package/tmp/frontmatter-test.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { parseMarkdownDescriptive } from '../src/descriptive/markdown';
|
|
2
|
-
import { applyStoryboardOverrides } from '../src/descriptive/resolve';
|
|
3
|
-
import { compileDescriptiveRoot } from '../src/descriptive/compiler';
|
|
4
|
-
|
|
5
|
-
const md = [
|
|
6
|
-
'---',
|
|
7
|
-
'title: "My Book"',
|
|
8
|
-
'author: John Doe',
|
|
9
|
-
'keywords: dog, confidence, training',
|
|
10
|
-
'---',
|
|
11
|
-
'# video',
|
|
12
|
-
'width:1080 height:1920 fps:30',
|
|
13
|
-
'## Test',
|
|
14
|
-
'- image prompt:"a cat" duration:3',
|
|
15
|
-
].join('\n');
|
|
16
|
-
|
|
17
|
-
const root = parseMarkdownDescriptive(md);
|
|
18
|
-
console.log('rawFrontmatter:', (root as any).rawFrontmatter);
|
|
19
|
-
const r = applyStoryboardOverrides(root, { variants: ['default'] });
|
|
20
|
-
const c = compileDescriptiveRoot(r);
|
|
21
|
-
console.log('data:', JSON.stringify(c.children[0].data, null, 2));
|