mografy 0.1.0 → 0.1.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 +13 -8
- package/lib/node_modules/@mografy/cli/dist/commands/help.js +3 -0
- package/lib/node_modules/@mografy/cli/dist/index.js +29 -5
- package/lib/node_modules/@mografy/cli/dist/project-args.d.ts +4 -3
- package/lib/node_modules/@mografy/cli/dist/project-args.js +7 -4
- package/lib/node_modules/@mografy/cli/dist/project-install.d.ts +27 -0
- package/lib/node_modules/@mografy/cli/dist/project-install.js +112 -0
- package/lib/node_modules/@mografy/cli/package.json +1 -1
- package/lib/node_modules/@mografy/core/package.json +1 -1
- package/lib/node_modules/@mografy/render/dist/ffmpeg.d.ts +1 -1
- package/lib/node_modules/@mografy/render/dist/ffmpeg.js +3 -2
- package/lib/node_modules/@mografy/render/package.json +1 -1
- package/lib/node_modules/@mografy/runtime/package.json +1 -1
- package/lib/node_modules/@mografy/server/dist/index.d.ts +1 -0
- package/lib/node_modules/@mografy/server/dist/index.js +1 -0
- package/lib/node_modules/@mografy/server/dist/workspace.d.ts +5 -0
- package/lib/node_modules/@mografy/server/dist/workspace.js +11 -1
- package/lib/node_modules/@mografy/server/package.json +1 -1
- package/lib/node_modules/@mografy/web/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,15 +4,20 @@ Local Canvas motion design for Claude Code and Codex. Scenes are TypeScript modu
|
|
|
4
4
|
`mografy dev` previews them live and `mografy export` writes MP4, WebM, MOV, Lottie or SVGA.
|
|
5
5
|
|
|
6
6
|
```sh
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
mografy dev
|
|
7
|
+
npx mografy@latest init # creates ./mografy: a project with Mografy and its agent Skill inside
|
|
8
|
+
cd mografy
|
|
9
|
+
npx mografy dev # open the editor (or: npm run dev)
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Then open Claude Code or Codex in the `mografy` folder and describe the animation. Everything lives in that folder:
|
|
13
|
+
nothing is installed globally, and deleting the folder removes it. `npx mografy@latest init my-film` names the folder.
|
|
14
|
+
To update, run `npx mografy@latest` inside it.
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
the
|
|
16
|
-
Templates, helpers and reference films download from GitHub
|
|
16
|
+
You don't install FFmpeg or Chromium: Chrome or Edge renders checks and exports, and FFmpeg downloads into the
|
|
17
|
+
project the first time you export a video (a Chromium shell too, only without Chrome or Edge), or ahead of time with
|
|
18
|
+
`npx mografy setup`. Templates, helpers and reference films download from GitHub
|
|
19
|
+
when `mografy add` needs them.
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
Optional, for every folder: `npm install -g mografy` and `npx skills add mografy/mografy -g`.
|
|
22
|
+
|
|
23
|
+
Documentation and the source: https://github.com/mografy/mografy
|
|
@@ -20,6 +20,9 @@ export function helpText(color) {
|
|
|
20
20
|
return [
|
|
21
21
|
` ${teal('●')} ${bold('Mografy')} ${dim(VERSION)}\n ${dim('Local Canvas animation for Claude Code and Codex. Claude creates. Mografy shows.')}`,
|
|
22
22
|
section('Start', [
|
|
23
|
+
row('npx mografy@latest init [folder]', 'New project in ./mografy (or [folder]) with its own Mografy, no global install'),
|
|
24
|
+
row('npx mografy dev', 'Inside that project (cd mografy): open the player'),
|
|
25
|
+
row('npx mografy@latest', "Inside that project: update its Mografy, then open the player"),
|
|
23
26
|
row('mografy dev', 'Open the player: built-in animations and your projects'),
|
|
24
27
|
row('mografy dev <project>', 'Open a project in the player'),
|
|
25
28
|
]),
|
|
@@ -18,9 +18,13 @@ import { HELP, VERSION, helpText } from './commands/help.js';
|
|
|
18
18
|
import { reviewProject } from './commands/review.js';
|
|
19
19
|
import { setup } from './commands/setup.js';
|
|
20
20
|
import { runMcp } from './mcp/index.js';
|
|
21
|
+
import { installIntoProject, updateProjectCopy, useProjectTools } from './project-install.js';
|
|
22
|
+
import { readFile } from 'node:fs/promises';
|
|
23
|
+
import { join, relative } from 'node:path';
|
|
21
24
|
export { displayPath } from './paths.js';
|
|
22
25
|
export { openBrowser };
|
|
23
26
|
export async function main(argv = process.argv.slice(2)) {
|
|
27
|
+
useProjectTools();
|
|
24
28
|
const { flags, rest } = parse(argv);
|
|
25
29
|
const commands = new Set(['dev', 'init', 'check', 'review', 'export', 'render', 'stop', 'install-command', 'update', 'add', 'setup', 'mcp', 'help']);
|
|
26
30
|
const command = rest[0] && commands.has(rest[0]) ? rest.shift() : 'dev';
|
|
@@ -93,7 +97,8 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
93
97
|
const dir = explicit
|
|
94
98
|
? command === 'init' ? resolve(rest[0]) : await resolveProjectArg(rest[0])
|
|
95
99
|
: command === 'init'
|
|
96
|
-
|
|
100
|
+
// Bare `init`: the current folder when it is already a project (update its Mografy), else a new ./mografy.
|
|
101
|
+
? await hasProject(process.cwd()) ? process.cwd() : resolve('mografy')
|
|
97
102
|
: configured
|
|
98
103
|
? resolve(configured)
|
|
99
104
|
: await implicitProject(command);
|
|
@@ -107,6 +112,9 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
107
112
|
+ ` Open the player: mografy dev (built-in animations and your projects)\n`
|
|
108
113
|
+ ` New animation: ask Claude or Codex`);
|
|
109
114
|
}
|
|
115
|
+
// `npx mografy@latest` inside a project with its own older copy: move that copy to this version first.
|
|
116
|
+
if (!explicit)
|
|
117
|
+
await updateProjectCopy(dir);
|
|
110
118
|
await refreshSkill(workspaceRoot);
|
|
111
119
|
skillHint(dir);
|
|
112
120
|
await ensureAgentFiles(dir);
|
|
@@ -127,11 +135,27 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
127
135
|
}
|
|
128
136
|
return dev(dir, flags);
|
|
129
137
|
}
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
// `mografy init [folder]`: a new project (agents use it too). From the npm package the project also gets its own
|
|
139
|
+
// copy of Mografy, so `npx mografy dev` inside it needs no global install; running init again only updates that copy.
|
|
140
|
+
case 'init': {
|
|
141
|
+
const existed = await hasProject(dir);
|
|
142
|
+
if (existed)
|
|
143
|
+
console.log(`${displayPath(dir)} is already a Mografy project; its scenes and settings stay as they are.`);
|
|
144
|
+
else {
|
|
145
|
+
await createProject(dir);
|
|
146
|
+
console.log(`Created project: ${displayPath(dir)}`);
|
|
147
|
+
}
|
|
148
|
+
const name = JSON.parse(await readFile(join(dir, 'mografy.json'), 'utf8')).name ?? 'mografy-project';
|
|
149
|
+
if (await installIntoProject(dir, name)) {
|
|
150
|
+
const folder = relative(process.cwd(), dir);
|
|
151
|
+
const into = folder ? ` cd ${/\s/.test(folder) ? JSON.stringify(folder) : folder}\n` : '';
|
|
152
|
+
console.log(`\nMografy ${VERSION} and its Skill are installed in this project, not globally. Next:\n${into} npx mografy dev open the player (or: npm run dev)\nThen open Claude Code or Codex in this folder and describe the animation.\nTo update later, run \`npx mografy@latest\` in this folder.`);
|
|
153
|
+
}
|
|
154
|
+
else if (installation.kind !== 'package') {
|
|
155
|
+
console.log(`Run \`mografy dev ${displayPath(dir)}\` to open it, then describe the animation to Claude or Codex.`);
|
|
156
|
+
}
|
|
134
157
|
return;
|
|
158
|
+
}
|
|
135
159
|
case 'check': return checkProject(dir, flags.motion);
|
|
136
160
|
case 'review': return reviewProject(dir, flags.video);
|
|
137
161
|
case 'export':
|
|
@@ -2,9 +2,10 @@ import { isProject as hasProject } from '@mografy/server';
|
|
|
2
2
|
export { hasProject };
|
|
3
3
|
/**
|
|
4
4
|
* Bare project commands are convenient inside Mografy's own workspace, where
|
|
5
|
-
* the player can resume the last library project.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* the player can resume the last library project. Elsewhere a bare `dev` opens
|
|
6
|
+
* the player on the library (its last project, or the built-in components), the
|
|
7
|
+
* way `npx mografy dev` is meant to start; other commands require an actual
|
|
8
|
+
* project context, so none of them can act on a scene from another checkout.
|
|
8
9
|
*/
|
|
9
10
|
export declare function implicitProject(command: string): Promise<string>;
|
|
10
11
|
/** Show a path from the user's home, so it is clear which checkout or repository it is in. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Which project a command means, from its arguments and the current folder.
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
-
import { defaultProject, isProject as hasProject } from '@mografy/server';
|
|
4
|
+
import { defaultProject, isProject as hasProject, libraryProject } from '@mografy/server';
|
|
5
5
|
import { displayPath, workspaceRoot } from './paths.js';
|
|
6
6
|
export { hasProject };
|
|
7
7
|
function isInsideWorkspace(value) {
|
|
@@ -10,9 +10,10 @@ function isInsideWorkspace(value) {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Bare project commands are convenient inside Mografy's own workspace, where
|
|
13
|
-
* the player can resume the last library project.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* the player can resume the last library project. Elsewhere a bare `dev` opens
|
|
14
|
+
* the player on the library (its last project, or the built-in components), the
|
|
15
|
+
* way `npx mografy dev` is meant to start; other commands require an actual
|
|
16
|
+
* project context, so none of them can act on a scene from another checkout.
|
|
16
17
|
*/
|
|
17
18
|
export async function implicitProject(command) {
|
|
18
19
|
const cwd = process.cwd();
|
|
@@ -20,6 +21,8 @@ export async function implicitProject(command) {
|
|
|
20
21
|
return cwd;
|
|
21
22
|
if (isInsideWorkspace(cwd))
|
|
22
23
|
return defaultProject(cwd);
|
|
24
|
+
if (command === 'dev')
|
|
25
|
+
return libraryProject();
|
|
23
26
|
throw new Error(`No mografy.json found in ${displayPath(cwd)}. Run \`mografy ${command} <project>\` or change into a Mografy project.`);
|
|
24
27
|
}
|
|
25
28
|
/** Show a path from the user's home, so it is clear which checkout or repository it is in. */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What `npm install` installs: this exact version, or `MOGRAFY_PACKAGE_SPEC` (a tarball path, for tests). */
|
|
2
|
+
export declare const packageSpec: () => string;
|
|
3
|
+
/** Write or merge the project's package.json: private, with `mografy` as a dev dependency and the shortcuts. */
|
|
4
|
+
export declare function writeProjectManifest(dir: string, name: string, spec?: string): Promise<void>;
|
|
5
|
+
/** Keep node_modules out of Git next to the template's entries. */
|
|
6
|
+
export declare function ignoreNodeModules(dir: string): Promise<void>;
|
|
7
|
+
/** Write this version's Skill into the project for both hosts; links in it point to GitHub. */
|
|
8
|
+
export declare function writeProjectSkill(dir: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Give the project its own copy of Mografy. Returns false (with the reason printed) when npm fails, so `init`
|
|
11
|
+
* still leaves a usable project that `npx mografy@latest dev` can open.
|
|
12
|
+
*/
|
|
13
|
+
export declare function installIntoProject(dir: string, name: string, log?: (line: string) => void): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* `npx mografy@latest` (a bare `dev`) inside a project that has its own copy: when that copy is older than the
|
|
16
|
+
* running version, install this version into the project and say so. Nothing happens from a source checkout, from
|
|
17
|
+
* the project's own copy, or in a project without one.
|
|
18
|
+
*/
|
|
19
|
+
export declare function updateProjectCopy(dir: string, log?: (line: string) => void): Promise<boolean>;
|
|
20
|
+
/** The project whose own copy of Mografy is running (`<project>/node_modules/mografy`), if it is one. */
|
|
21
|
+
export declare function runningProject(root?: string, kind?: "package" | "source"): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* A project's own copy keeps its tools in the project too, untouched by PATH: FFmpeg downloads into
|
|
24
|
+
* node_modules/.cache/mografy/tools (kept across updates, removed with the folder) and PATH's ffmpeg is not used;
|
|
25
|
+
* a Chromium shell, needed only when there is no Chrome or Edge, goes next to it. Explicit settings still win.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useProjectTools(env?: NodeJS.ProcessEnv, project?: string | undefined): boolean;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// `npx mografy@latest init [folder]` without a global install: the project gets its own copy of the `mografy`
|
|
2
|
+
// package, so `npx mografy dev` inside it runs that copy (no download, works offline) and `npm run dev` does the same.
|
|
3
|
+
// Running `npx mografy@latest init` again in the project only moves that copy to the newer version; the scene,
|
|
4
|
+
// mografy.json and the user's files are never touched. The project also gets this version's Skill for both hosts
|
|
5
|
+
// (.agents/skills/mografy for Codex and others, .claude/skills/mografy for Claude Code), so nothing is installed
|
|
6
|
+
// globally. A source checkout has no package to install and its own Skill, so it skips both.
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
import { readFile } from 'node:fs/promises';
|
|
9
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { sharedSkillFiles } from '@mografy/core';
|
|
12
|
+
import { atomicWrite, installation, queueProjectWrite } from '@mografy/server';
|
|
13
|
+
import { VERSION } from './commands/help.js';
|
|
14
|
+
import { newerVersion } from './package-update.js';
|
|
15
|
+
/** The scripts a project gets; existing scripts with the same name are kept. */
|
|
16
|
+
const SCRIPTS = { dev: 'mografy dev', check: 'mografy check', review: 'mografy review', export: 'mografy export' };
|
|
17
|
+
/** What `npm install` installs: this exact version, or `MOGRAFY_PACKAGE_SPEC` (a tarball path, for tests). */
|
|
18
|
+
export const packageSpec = () => process.env.MOGRAFY_PACKAGE_SPEC || `mografy@${VERSION}`;
|
|
19
|
+
/** Write or merge the project's package.json: private, with `mografy` as a dev dependency and the shortcuts. */
|
|
20
|
+
export function writeProjectManifest(dir, name, spec = packageSpec()) {
|
|
21
|
+
return queueProjectWrite(dir, async () => {
|
|
22
|
+
const file = join(dir, 'package.json');
|
|
23
|
+
const current = await readFile(file, 'utf8').then(text => JSON.parse(text), () => undefined);
|
|
24
|
+
const manifest = current ?? { name: npmName(name), private: true };
|
|
25
|
+
manifest.scripts = { ...SCRIPTS, ...manifest.scripts };
|
|
26
|
+
// npm install rewrites the range; a tarball path stays as given.
|
|
27
|
+
manifest.devDependencies = { ...manifest.devDependencies, mografy: spec.startsWith('mografy@') ? VERSION : spec };
|
|
28
|
+
await atomicWrite(file, JSON.stringify(manifest, null, 2) + '\n');
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Keep node_modules out of Git next to the template's entries. */
|
|
32
|
+
export function ignoreNodeModules(dir) {
|
|
33
|
+
return queueProjectWrite(dir, async () => {
|
|
34
|
+
const file = join(dir, '.gitignore');
|
|
35
|
+
const text = await readFile(file, 'utf8').catch(() => '');
|
|
36
|
+
if (text.split(/\r?\n/).some(line => /^\/?node_modules\/?$/.test(line.trim())))
|
|
37
|
+
return;
|
|
38
|
+
await atomicWrite(file, `${text}${text && !text.endsWith('\n') ? '\n' : ''}node_modules/\n`);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** Write this version's Skill into the project for both hosts; links in it point to GitHub. */
|
|
42
|
+
export function writeProjectSkill(dir) {
|
|
43
|
+
return queueProjectWrite(dir, async () => {
|
|
44
|
+
for (const host of ['.agents', '.claude']) {
|
|
45
|
+
for (const [file, contents] of Object.entries(sharedSkillFiles().mografy)) {
|
|
46
|
+
const path = join(dir, host, 'skills', 'mografy', file);
|
|
47
|
+
if (await readFile(path, 'utf8').catch(() => undefined) !== contents)
|
|
48
|
+
await atomicWrite(path, contents);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const npmName = (name) => name.toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[._-]+|-+$/g, '') || 'mografy-project';
|
|
54
|
+
/**
|
|
55
|
+
* Give the project its own copy of Mografy. Returns false (with the reason printed) when npm fails, so `init`
|
|
56
|
+
* still leaves a usable project that `npx mografy@latest dev` can open.
|
|
57
|
+
*/
|
|
58
|
+
export async function installIntoProject(dir, name, log = (line) => console.log(line)) {
|
|
59
|
+
if (installation.kind !== 'package')
|
|
60
|
+
return false;
|
|
61
|
+
const spec = packageSpec();
|
|
62
|
+
await writeProjectSkill(dir);
|
|
63
|
+
await writeProjectManifest(dir, name, spec);
|
|
64
|
+
await ignoreNodeModules(dir);
|
|
65
|
+
log(`Installing ${spec.startsWith('mografy@') ? spec : 'mografy'} into this project (not global)…`);
|
|
66
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
67
|
+
const result = spawnSync(npm, ['install', '--save-dev', '--no-audit', '--no-fund', spec], { cwd: dir, stdio: 'inherit', shell: process.platform === 'win32' });
|
|
68
|
+
if (result.status === 0)
|
|
69
|
+
return true;
|
|
70
|
+
log(`npm install did not finish${result.error ? ` (${result.error.message})` : ''}. The project is ready; run \`npm install\` in it later, or open it with \`npx mografy@latest dev\`.`);
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `npx mografy@latest` (a bare `dev`) inside a project that has its own copy: when that copy is older than the
|
|
75
|
+
* running version, install this version into the project and say so. Nothing happens from a source checkout, from
|
|
76
|
+
* the project's own copy, or in a project without one.
|
|
77
|
+
*/
|
|
78
|
+
export async function updateProjectCopy(dir, log = (line) => console.log(line)) {
|
|
79
|
+
if (installation.kind !== 'package')
|
|
80
|
+
return false;
|
|
81
|
+
const local = join(dir, 'node_modules', 'mografy');
|
|
82
|
+
if (resolve(installation.root) === resolve(local))
|
|
83
|
+
return false;
|
|
84
|
+
const installed = await readFile(join(local, 'package.json'), 'utf8').then(text => JSON.parse(text).version, () => undefined);
|
|
85
|
+
if (!installed || !newerVersion(VERSION, installed))
|
|
86
|
+
return false;
|
|
87
|
+
log(`This project has Mografy ${installed}; updating it to ${VERSION}.`);
|
|
88
|
+
const name = await readFile(join(dir, 'mografy.json'), 'utf8').then(text => JSON.parse(text).name ?? 'mografy-project', () => 'mografy-project');
|
|
89
|
+
return installIntoProject(dir, name, log);
|
|
90
|
+
}
|
|
91
|
+
/** The project whose own copy of Mografy is running (`<project>/node_modules/mografy`), if it is one. */
|
|
92
|
+
export function runningProject(root = installation.root, kind = installation.kind) {
|
|
93
|
+
if (kind !== 'package' || basename(dirname(root)) !== 'node_modules')
|
|
94
|
+
return undefined;
|
|
95
|
+
const project = dirname(dirname(root));
|
|
96
|
+
return existsSync(join(project, 'mografy.json')) ? project : undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A project's own copy keeps its tools in the project too, untouched by PATH: FFmpeg downloads into
|
|
100
|
+
* node_modules/.cache/mografy/tools (kept across updates, removed with the folder) and PATH's ffmpeg is not used;
|
|
101
|
+
* a Chromium shell, needed only when there is no Chrome or Edge, goes next to it. Explicit settings still win.
|
|
102
|
+
*/
|
|
103
|
+
export function useProjectTools(env = process.env, project = runningProject()) {
|
|
104
|
+
if (!project)
|
|
105
|
+
return false;
|
|
106
|
+
const cache = join(project, 'node_modules', '.cache', 'mografy');
|
|
107
|
+
env.MOGRAFY_TOOLS ??= join(cache, 'tools');
|
|
108
|
+
env.MOGRAFY_SYSTEM_FFMPEG ??= '0';
|
|
109
|
+
env.PLAYWRIGHT_BROWSERS_PATH ??= join(cache, 'browsers');
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=project-install.js.map
|
|
@@ -23,7 +23,7 @@ export interface FfmpegChoice {
|
|
|
23
23
|
/**
|
|
24
24
|
* Pick the FFmpeg exports use, downloading Mografy's pinned build only when nothing usable is installed:
|
|
25
25
|
* $MOGRAFY_FFMPEG → an earlier download → a legacy ffmpeg-static binary → ffmpeg on PATH when it has every encoder in
|
|
26
|
-
* REQUIRED_ENCODERS → download. When the download is impossible (offline, or no build for this platform), an incomplete
|
|
26
|
+
* REQUIRED_ENCODERS (unless MOGRAFY_SYSTEM_FFMPEG=0) → download. When the download is impossible (offline, or no build for this platform), an incomplete
|
|
27
27
|
* system FFmpeg is still used (an export that needs a missing encoder then says which). The choice is made once per process.
|
|
28
28
|
*/
|
|
29
29
|
export declare function ensureFfmpeg(options?: ToolOptions): Promise<FfmpegChoice>;
|
|
@@ -61,7 +61,7 @@ let choosing;
|
|
|
61
61
|
/**
|
|
62
62
|
* Pick the FFmpeg exports use, downloading Mografy's pinned build only when nothing usable is installed:
|
|
63
63
|
* $MOGRAFY_FFMPEG → an earlier download → a legacy ffmpeg-static binary → ffmpeg on PATH when it has every encoder in
|
|
64
|
-
* REQUIRED_ENCODERS → download. When the download is impossible (offline, or no build for this platform), an incomplete
|
|
64
|
+
* REQUIRED_ENCODERS (unless MOGRAFY_SYSTEM_FFMPEG=0) → download. When the download is impossible (offline, or no build for this platform), an incomplete
|
|
65
65
|
* system FFmpeg is still used (an export that needs a missing encoder then says which). The choice is made once per process.
|
|
66
66
|
*/
|
|
67
67
|
export function ensureFfmpeg(options = {}) {
|
|
@@ -74,7 +74,8 @@ export function ensureFfmpeg(options = {}) {
|
|
|
74
74
|
const bundled = legacyBundled();
|
|
75
75
|
if (bundled)
|
|
76
76
|
return { path: bundled, source: 'bundled' };
|
|
77
|
-
|
|
77
|
+
// A project's own installation (`npx mografy@latest init`) sets MOGRAFY_SYSTEM_FFMPEG=0: it never uses PATH's ffmpeg.
|
|
78
|
+
const system = process.env.MOGRAFY_SYSTEM_FFMPEG === '0' ? undefined : await listEncoders('ffmpeg');
|
|
78
79
|
const missing = system ? REQUIRED_ENCODERS.filter(name => !system.has(name)) : REQUIRED_ENCODERS;
|
|
79
80
|
if (system && !missing.length)
|
|
80
81
|
return { path: 'ffmpeg', source: 'system' };
|
|
@@ -5,6 +5,11 @@ export * from './components.js';
|
|
|
5
5
|
export * from './project-scaffold.js';
|
|
6
6
|
/** Current project, last opened project, or the bundled component showcase on first launch. */
|
|
7
7
|
export declare function defaultProject(cwd?: string): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* What `mografy dev` opens from a folder that is not a project: the last project when it is in the library
|
|
10
|
+
* (~/Mografy, or projects/ in a checkout), else the built-in components. Never a project from another repository.
|
|
11
|
+
*/
|
|
12
|
+
export declare function libraryProject(): Promise<string>;
|
|
8
13
|
/** Create a project named `name` in the library folder, picking a free folder name. */
|
|
9
14
|
export declare function createInLibrary(name: string, aspectRatio?: AspectRatio): Promise<string>;
|
|
10
15
|
/** Recent projects first, then the library folder, then examples; each project listed once. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Read-only discovery and explicit library-level operations.
|
|
2
2
|
import { projectPaths } from '@mografy/render/fs-util';
|
|
3
3
|
import { mkdir, readdir, readFile, realpath, stat } from 'node:fs/promises';
|
|
4
|
-
import { basename, join, resolve } from 'node:path';
|
|
4
|
+
import { basename, join, resolve, sep } from 'node:path';
|
|
5
5
|
import { validateSceneProject } from '@mografy/core';
|
|
6
6
|
import { EXAMPLES_DIR, libraryDir } from './installation.js';
|
|
7
7
|
import { lastProject, readRecent } from './workspace-state.js';
|
|
@@ -20,6 +20,16 @@ export async function defaultProject(cwd = process.cwd()) {
|
|
|
20
20
|
// Upgrade the former six-in-one showcase without overwriting its scene or user edits.
|
|
21
21
|
return last && resolve(last) !== componentRoot() ? last : await ensureComponentsProject();
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* What `mografy dev` opens from a folder that is not a project: the last project when it is in the library
|
|
25
|
+
* (~/Mografy, or projects/ in a checkout), else the built-in components. Never a project from another repository.
|
|
26
|
+
*/
|
|
27
|
+
export async function libraryProject() {
|
|
28
|
+
const last = await lastProject();
|
|
29
|
+
if (last && resolve(last).startsWith(resolve(libraryDir()) + sep) && resolve(last) !== componentRoot())
|
|
30
|
+
return last;
|
|
31
|
+
return ensureComponentsProject();
|
|
32
|
+
}
|
|
23
33
|
/** Create a project named `name` in the library folder, picking a free folder name. */
|
|
24
34
|
export async function createInLibrary(name, aspectRatio) {
|
|
25
35
|
const base = folderName(name);
|
package/package.json
CHANGED