@magichourhq/editor-kit 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +65 -2
- package/dist/design-video/index.d.ts +2 -0
- package/dist/design-video/index.js +2 -0
- package/dist/design-video/media.d.ts +7 -0
- package/dist/design-video/media.js +45 -0
- package/dist/design-video/video.d.ts +87 -0
- package/dist/design-video/video.js +316 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/messages.d.ts +181 -0
- package/dist/messages.js +187 -0
- package/package.json +37 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Magic Hour AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Magic Hour Editor Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@magichourhq/editor-kit)
|
|
4
|
+
|
|
5
|
+
The logic of the video generation flow shared by Magic Hour's design editor apps for Framer, Adobe Express and Canva. A person picks an image or writes a brief, the app generates a short video with the [Magic Hour API](https://docs.magichour.ai), and the editor host inserts it into the design. The package has no UI and no CSS. The Framer and Adobe Express apps carry their own plain-HTML panel on top of it. It is built on [`@magichourhq/browser-client`](https://github.com/magichourhq/browser-client).
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @magichourhq/editor-kit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> [!WARNING]
|
|
12
|
+
> The API key is the key of the person using the app, which they enter themselves. Anyone using the page can read it. Never ship a shared key.
|
|
13
|
+
|
|
14
|
+
The accepted project ID is saved before the app waits, so a generation that was interrupted can be resumed without paying again.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
Everything for the video feature lives under the `DesignVideo` namespace, including its types.
|
|
19
|
+
|
|
20
|
+
An app describes its editor with a `DesignVideo.EditorHost`:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { DesignVideo } from "@magichourhq/editor-kit";
|
|
24
|
+
|
|
25
|
+
const host: DesignVideo.EditorHost = {
|
|
26
|
+
name: "Framer", // Used in the project name, "Magic Hour for Framer"
|
|
27
|
+
selectionLabel: "Use selected image",
|
|
28
|
+
// Optional. Returns the image selected in the editor.
|
|
29
|
+
captureImage: async () => ({ blob, label: "Selected image" }),
|
|
30
|
+
// Optional. Throws if the editor can't accept a video, before anything is paid for.
|
|
31
|
+
prepareGeneration: async () => {},
|
|
32
|
+
// Keeps the accepted project ID, for example in the editor's plugin data.
|
|
33
|
+
store: {
|
|
34
|
+
load: async () => localStorage.getItem("project"),
|
|
35
|
+
save: async (id) => (id ? localStorage.setItem("project", id) : localStorage.removeItem("project")),
|
|
36
|
+
},
|
|
37
|
+
// Adds the finished MP4 to the design. Throw a DesignVideo.EditorInsertionError to show a code.
|
|
38
|
+
insertVideo: async ({ blob, url, id, credits, expiresAt }) => {},
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Building a UI
|
|
43
|
+
|
|
44
|
+
`DesignVideo.VideoPanel` holds the state without any UI framework or CSS. Your app builds its own UI on it, for example with React's `useSyncExternalStore`:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const panel = new DesignVideo.VideoPanel(host);
|
|
48
|
+
void panel.init(); // Loads a saved project ID from host.store
|
|
49
|
+
const state = useSyncExternalStore(panel.subscribe, panel.snapshot);
|
|
50
|
+
|
|
51
|
+
await panel.generate(apiKey, { prompt, duration: 5, resolution: "720p", aspectRatio: "16:9" });
|
|
52
|
+
await panel.insert(apiKey);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The state has `ready`, `busy`, `message`, `error`, `savedId`, `source` and `result`. Other methods are `capture()`, `selectFile(file)`, `removeImage()`, `resume(apiKey, projectId)`, `stop()`, `reset()` and `dispose()`. `DesignVideo` also has `VideoService`, `validateImage`, `projectId`, `videoMetadata` and `videoPoster`.
|
|
56
|
+
|
|
57
|
+
## Translations
|
|
58
|
+
|
|
59
|
+
Every message has a fixed `id`. Pass `formatMessage` in the second argument of `DesignVideo.VideoPanel` to translate them, and add `messageCatalog()` to your source-language file so your translators get the strings. Errors from the API come from `@magichourhq/browser-client`, which has its own `messageCatalog()`.
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { messageCatalog } from "@magichourhq/editor-kit";
|
|
63
|
+
import { messageCatalog as clientCatalog } from "@magichourhq/browser-client";
|
|
64
|
+
|
|
65
|
+
const messagesEn = { ...clientCatalog(), ...messageCatalog() };
|
|
66
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type MessageFormatter } from "@magichourhq/browser-client";
|
|
2
|
+
export declare function videoMetadata(blob: Blob, formatMessage?: MessageFormatter): Promise<{
|
|
3
|
+
poster: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function videoPoster(blob: Blob, formatMessage?: MessageFormatter): Promise<string>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { englishMessage } from "@magichourhq/browser-client";
|
|
2
|
+
import { messages } from "../messages.js";
|
|
3
|
+
export async function videoMetadata(blob, formatMessage = englishMessage) {
|
|
4
|
+
const url = URL.createObjectURL(blob), video = document.createElement("video");
|
|
5
|
+
video.muted = true;
|
|
6
|
+
video.preload = "auto";
|
|
7
|
+
try {
|
|
8
|
+
await new Promise((resolve, reject) => {
|
|
9
|
+
const timer = setTimeout(() => reject(new Error(formatMessage(messages.previewTimeout))), 15000);
|
|
10
|
+
const done = () => {
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
video.onloadeddata = null;
|
|
13
|
+
video.onerror = null;
|
|
14
|
+
};
|
|
15
|
+
video.onloadeddata = () => {
|
|
16
|
+
done();
|
|
17
|
+
resolve();
|
|
18
|
+
};
|
|
19
|
+
video.onerror = () => {
|
|
20
|
+
done();
|
|
21
|
+
reject(new Error(formatMessage(messages.previewDecode)));
|
|
22
|
+
};
|
|
23
|
+
video.src = url;
|
|
24
|
+
});
|
|
25
|
+
const canvas = document.createElement("canvas");
|
|
26
|
+
canvas.width = Math.min(640, video.videoWidth);
|
|
27
|
+
canvas.height = Math.round((canvas.width * video.videoHeight) / video.videoWidth);
|
|
28
|
+
if (!canvas.width || !canvas.height)
|
|
29
|
+
throw new Error(formatMessage(messages.noDimensions));
|
|
30
|
+
canvas.getContext("2d").drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
31
|
+
return {
|
|
32
|
+
poster: canvas.toDataURL("image/jpeg", 0.85),
|
|
33
|
+
width: video.videoWidth,
|
|
34
|
+
height: video.videoHeight,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
video.removeAttribute("src");
|
|
39
|
+
video.load();
|
|
40
|
+
URL.revokeObjectURL(url);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export async function videoPoster(blob, formatMessage = englishMessage) {
|
|
44
|
+
return (await videoMetadata(blob, formatMessage)).poster;
|
|
45
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type MessageFormatter } from "@magichourhq/browser-client";
|
|
2
|
+
export type SourceImage = {
|
|
3
|
+
blob: Blob;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
export type VideoOptions = {
|
|
7
|
+
prompt: string;
|
|
8
|
+
duration: number;
|
|
9
|
+
resolution: "480p" | "720p";
|
|
10
|
+
aspectRatio: "16:9" | "1:1" | "9:16";
|
|
11
|
+
};
|
|
12
|
+
export type VideoResult = {
|
|
13
|
+
id: string;
|
|
14
|
+
blob: Blob;
|
|
15
|
+
url: string;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
credits: number;
|
|
18
|
+
};
|
|
19
|
+
export type JobStore = {
|
|
20
|
+
load(): Promise<string | null>;
|
|
21
|
+
save(id: string | null): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
export declare class EditorInsertionError extends Error {
|
|
24
|
+
readonly code: string;
|
|
25
|
+
readonly detail?: string | undefined;
|
|
26
|
+
constructor(code: string, detail?: string | undefined);
|
|
27
|
+
}
|
|
28
|
+
export type EditorHost = {
|
|
29
|
+
name: string;
|
|
30
|
+
selectionLabel: string;
|
|
31
|
+
captureImage?(): Promise<SourceImage>;
|
|
32
|
+
prepareGeneration?(): Promise<void>;
|
|
33
|
+
store: JobStore;
|
|
34
|
+
insertVideo(result: VideoResult): Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
export declare function projectId(value: string, formatMessage?: MessageFormatter): string;
|
|
37
|
+
export declare function validateImage(blob: Blob, formatMessage?: MessageFormatter): Promise<string>;
|
|
38
|
+
export declare class VideoService {
|
|
39
|
+
private readonly settings;
|
|
40
|
+
constructor(settings: {
|
|
41
|
+
apiKey: string;
|
|
42
|
+
formatMessage?: MessageFormatter;
|
|
43
|
+
store: JobStore;
|
|
44
|
+
fetch?: typeof fetch;
|
|
45
|
+
pollIntervalMs?: number;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
platform: string;
|
|
48
|
+
});
|
|
49
|
+
private readonly formatMessage;
|
|
50
|
+
private client;
|
|
51
|
+
generate(options: VideoOptions, source?: SourceImage, abort?: AbortSignal): Promise<VideoResult>;
|
|
52
|
+
retrieve(id: string, abort?: AbortSignal): Promise<VideoResult>;
|
|
53
|
+
}
|
|
54
|
+
export type PanelState = {
|
|
55
|
+
ready: boolean;
|
|
56
|
+
busy: boolean;
|
|
57
|
+
message: string;
|
|
58
|
+
error: boolean;
|
|
59
|
+
savedId: string;
|
|
60
|
+
source?: SourceImage;
|
|
61
|
+
result?: VideoResult;
|
|
62
|
+
};
|
|
63
|
+
export declare class VideoPanel {
|
|
64
|
+
readonly host: EditorHost;
|
|
65
|
+
private readonly transport;
|
|
66
|
+
state: PanelState;
|
|
67
|
+
private abort?;
|
|
68
|
+
private disposed;
|
|
69
|
+
private readonly listeners;
|
|
70
|
+
constructor(host: EditorHost, transport?: Partial<ConstructorParameters<typeof VideoService>[0]>);
|
|
71
|
+
private readonly formatMessage;
|
|
72
|
+
subscribe: (callback: () => void) => () => void;
|
|
73
|
+
snapshot: () => PanelState;
|
|
74
|
+
private update;
|
|
75
|
+
init(): Promise<void>;
|
|
76
|
+
private run;
|
|
77
|
+
capture(): Promise<void>;
|
|
78
|
+
selectFile(file: File): Promise<void>;
|
|
79
|
+
removeImage(): void;
|
|
80
|
+
private service;
|
|
81
|
+
generate(key: string, options: VideoOptions): Promise<void>;
|
|
82
|
+
resume(key: string, id: string): Promise<void>;
|
|
83
|
+
insert(key: string): Promise<void>;
|
|
84
|
+
stop(): void;
|
|
85
|
+
reset(): Promise<void>;
|
|
86
|
+
dispose(): void;
|
|
87
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { MagicHourClient, MagicHourError, englishMessage, } from "@magichourhq/browser-client";
|
|
2
|
+
import { messages } from "../messages.js";
|
|
3
|
+
export class EditorInsertionError extends Error {
|
|
4
|
+
constructor(code, detail) {
|
|
5
|
+
super(code);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.detail = detail;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const extensions = {
|
|
11
|
+
"image/png": "png",
|
|
12
|
+
"image/jpeg": "jpg",
|
|
13
|
+
"image/webp": "webp",
|
|
14
|
+
};
|
|
15
|
+
export function projectId(value, formatMessage = englishMessage) {
|
|
16
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/.test(value))
|
|
17
|
+
throw new Error(formatMessage(messages.invalidProjectId));
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
export async function validateImage(blob, formatMessage = englishMessage) {
|
|
21
|
+
const extension = extensions[blob.type];
|
|
22
|
+
if (!extension || !blob.size || blob.size > 20 * 1024 * 1024)
|
|
23
|
+
throw new Error(formatMessage(messages.invalidImageType));
|
|
24
|
+
const b = new Uint8Array(await blob.slice(0, 12).arrayBuffer());
|
|
25
|
+
const valid = extension === "png"
|
|
26
|
+
? [137, 80, 78, 71, 13, 10, 26, 10].every((v, i) => b[i] === v)
|
|
27
|
+
: extension === "jpg"
|
|
28
|
+
? b[0] === 255 && b[1] === 216 && b[2] === 255
|
|
29
|
+
: String.fromCharCode(...b.slice(0, 4)) === "RIFF" &&
|
|
30
|
+
String.fromCharCode(...b.slice(8, 12)) === "WEBP";
|
|
31
|
+
if (!valid)
|
|
32
|
+
throw new Error(formatMessage(messages.imageBytesMismatch));
|
|
33
|
+
return extension;
|
|
34
|
+
}
|
|
35
|
+
export class VideoService {
|
|
36
|
+
constructor(settings) {
|
|
37
|
+
var _a;
|
|
38
|
+
this.settings = settings;
|
|
39
|
+
this.formatMessage = (_a = settings.formatMessage) !== null && _a !== void 0 ? _a : englishMessage;
|
|
40
|
+
}
|
|
41
|
+
client() {
|
|
42
|
+
return new MagicHourClient({
|
|
43
|
+
...this.settings,
|
|
44
|
+
onProjectCreated: ({ id }) => this.settings.store.save(id),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async generate(options, source, abort) {
|
|
48
|
+
if (!options.prompt.trim() || options.prompt.length > 2000)
|
|
49
|
+
throw new Error(this.formatMessage(messages.invalidPrompt));
|
|
50
|
+
if (!Number.isInteger(options.duration) || options.duration < 1 || options.duration > 10)
|
|
51
|
+
throw new Error(this.formatMessage(messages.invalidDuration));
|
|
52
|
+
if (!["480p", "720p"].includes(options.resolution) ||
|
|
53
|
+
!["16:9", "1:1", "9:16"].includes(options.aspectRatio))
|
|
54
|
+
throw new Error(this.formatMessage(messages.invalidOptions));
|
|
55
|
+
const extension = source ? await validateImage(source.blob, this.formatMessage) : undefined;
|
|
56
|
+
const c = this.client(), signal = c.signal(abort);
|
|
57
|
+
const path = source
|
|
58
|
+
? await c.uploadImage(new Uint8Array(await source.blob.arrayBuffer()), extension, signal)
|
|
59
|
+
: undefined;
|
|
60
|
+
const body = {
|
|
61
|
+
name: `Magic Hour for ${this.settings.platform}`,
|
|
62
|
+
model: "ltx-2.5",
|
|
63
|
+
end_seconds: options.duration,
|
|
64
|
+
resolution: options.resolution,
|
|
65
|
+
style: { prompt: options.prompt.trim() },
|
|
66
|
+
audio: false,
|
|
67
|
+
};
|
|
68
|
+
const id = path
|
|
69
|
+
? await c.create("image-to-video", { ...body, assets: { image_file_path: path } }, signal)
|
|
70
|
+
: await c.create("text-to-video", { ...body, aspect_ratio: options.aspectRatio }, signal);
|
|
71
|
+
return this.retrieve(id, abort);
|
|
72
|
+
}
|
|
73
|
+
async retrieve(id, abort) {
|
|
74
|
+
projectId(id, this.formatMessage);
|
|
75
|
+
const c = this.client(), signal = c.signal(abort);
|
|
76
|
+
const p = await c.wait(id, "video", signal);
|
|
77
|
+
try {
|
|
78
|
+
const bytes = await c.download(p.downloads[0].url, signal);
|
|
79
|
+
if (!bytes.length || bytes.length > 100 * 1024 * 1024)
|
|
80
|
+
throw new Error(this.formatMessage(messages.videoSize));
|
|
81
|
+
if (String.fromCharCode(...bytes.slice(4, 8)) !== "ftyp")
|
|
82
|
+
throw new Error(this.formatMessage(messages.notMp4));
|
|
83
|
+
return {
|
|
84
|
+
id,
|
|
85
|
+
blob: new Blob([bytes], { type: "video/mp4" }),
|
|
86
|
+
url: p.downloads[0].url,
|
|
87
|
+
expiresAt: p.downloads[0].expires_at,
|
|
88
|
+
credits: p.credits_charged,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (_a) {
|
|
92
|
+
throw new MagicHourError(this.formatMessage(messages.downloadFailed), id, undefined, this.formatMessage);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export class VideoPanel {
|
|
97
|
+
constructor(host, transport = {}) {
|
|
98
|
+
var _a;
|
|
99
|
+
this.host = host;
|
|
100
|
+
this.transport = transport;
|
|
101
|
+
this.state = {
|
|
102
|
+
ready: false,
|
|
103
|
+
busy: false,
|
|
104
|
+
message: "",
|
|
105
|
+
error: false,
|
|
106
|
+
savedId: "",
|
|
107
|
+
};
|
|
108
|
+
this.disposed = false;
|
|
109
|
+
this.listeners = new Set();
|
|
110
|
+
this.subscribe = (callback) => {
|
|
111
|
+
this.listeners.add(callback);
|
|
112
|
+
return () => {
|
|
113
|
+
this.listeners.delete(callback);
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
this.snapshot = () => this.state;
|
|
117
|
+
this.formatMessage = (_a = transport.formatMessage) !== null && _a !== void 0 ? _a : englishMessage;
|
|
118
|
+
this.state.message = this.formatMessage(messages.initial);
|
|
119
|
+
}
|
|
120
|
+
update(patch) {
|
|
121
|
+
if (this.disposed)
|
|
122
|
+
return;
|
|
123
|
+
this.state = { ...this.state, ...patch };
|
|
124
|
+
for (const callback of this.listeners)
|
|
125
|
+
callback();
|
|
126
|
+
}
|
|
127
|
+
async init() {
|
|
128
|
+
try {
|
|
129
|
+
const id = await this.host.store.load();
|
|
130
|
+
if (id)
|
|
131
|
+
this.update({
|
|
132
|
+
savedId: projectId(id, this.formatMessage),
|
|
133
|
+
message: this.formatMessage(messages.savedAvailable),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catch (_a) {
|
|
137
|
+
this.update({
|
|
138
|
+
error: true,
|
|
139
|
+
message: this.formatMessage(messages.savedUnreadable),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
this.update({ ready: true });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async run(task) {
|
|
147
|
+
if (this.state.busy)
|
|
148
|
+
return;
|
|
149
|
+
this.abort = new AbortController();
|
|
150
|
+
this.update({ busy: true, error: false });
|
|
151
|
+
try {
|
|
152
|
+
await task();
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
const id = error instanceof MagicHourError ? error.projectId : undefined;
|
|
156
|
+
this.update({
|
|
157
|
+
error: true,
|
|
158
|
+
...(id ? { savedId: id } : {}),
|
|
159
|
+
message: error instanceof MagicHourError
|
|
160
|
+
? error.message
|
|
161
|
+
: error instanceof Error
|
|
162
|
+
? error.message
|
|
163
|
+
: this.formatMessage(messages.operationFailed),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
this.update({ busy: false });
|
|
168
|
+
this.abort = undefined;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async capture() {
|
|
172
|
+
await this.run(async () => {
|
|
173
|
+
if (!this.host.captureImage)
|
|
174
|
+
throw new Error(this.formatMessage(messages.uploadRequired));
|
|
175
|
+
const source = await this.host.captureImage();
|
|
176
|
+
await validateImage(source.blob, this.formatMessage);
|
|
177
|
+
this.update({
|
|
178
|
+
source,
|
|
179
|
+
message: this.formatMessage(messages.imageCaptured),
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
async selectFile(file) {
|
|
184
|
+
await this.run(async () => {
|
|
185
|
+
await validateImage(file, this.formatMessage);
|
|
186
|
+
this.update({
|
|
187
|
+
source: { blob: file, label: file.name },
|
|
188
|
+
message: this.formatMessage(messages.imageSelected),
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
removeImage() {
|
|
193
|
+
if (!this.state.busy)
|
|
194
|
+
this.update({
|
|
195
|
+
source: undefined,
|
|
196
|
+
message: this.formatMessage(messages.imageRemoved),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
service(key) {
|
|
200
|
+
return new VideoService({
|
|
201
|
+
...this.transport,
|
|
202
|
+
apiKey: key,
|
|
203
|
+
platform: this.host.name,
|
|
204
|
+
store: {
|
|
205
|
+
load: () => this.host.store.load(),
|
|
206
|
+
save: async (id) => {
|
|
207
|
+
// Show the accepted ID even if durable storage fails.
|
|
208
|
+
this.update({ savedId: id !== null && id !== void 0 ? id : "" });
|
|
209
|
+
await this.host.store.save(id);
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async generate(key, options) {
|
|
215
|
+
await this.run(async () => {
|
|
216
|
+
var _a, _b;
|
|
217
|
+
if (!this.state.ready)
|
|
218
|
+
throw new Error(this.formatMessage(messages.savedLoading));
|
|
219
|
+
if (this.state.savedId)
|
|
220
|
+
throw new Error(this.formatMessage(messages.savedExists));
|
|
221
|
+
await ((_b = (_a = this.host).prepareGeneration) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
222
|
+
this.update({
|
|
223
|
+
message: this.formatMessage(messages.generating),
|
|
224
|
+
result: undefined,
|
|
225
|
+
});
|
|
226
|
+
const result = await this.service(key).generate(options, this.state.source, this.abort.signal);
|
|
227
|
+
this.update({
|
|
228
|
+
result,
|
|
229
|
+
message: this.formatMessage(messages.videoReady, { credits: result.credits }),
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
async resume(key, id) {
|
|
234
|
+
await this.run(async () => {
|
|
235
|
+
projectId(id, this.formatMessage);
|
|
236
|
+
let saved = true;
|
|
237
|
+
try {
|
|
238
|
+
await this.host.store.save(id);
|
|
239
|
+
}
|
|
240
|
+
catch (_a) {
|
|
241
|
+
saved = false;
|
|
242
|
+
}
|
|
243
|
+
this.update({
|
|
244
|
+
savedId: id,
|
|
245
|
+
message: this.formatMessage(messages.resuming),
|
|
246
|
+
result: undefined,
|
|
247
|
+
});
|
|
248
|
+
const result = await this.service(key).retrieve(id, this.abort.signal);
|
|
249
|
+
this.update({
|
|
250
|
+
result,
|
|
251
|
+
message: saved
|
|
252
|
+
? this.formatMessage(messages.videoRetrieved, { credits: result.credits })
|
|
253
|
+
: this.formatMessage(messages.videoRetrievedUnsaved, { credits: result.credits }),
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
async insert(key) {
|
|
258
|
+
await this.run(async () => {
|
|
259
|
+
const old = this.state.result;
|
|
260
|
+
if (!old)
|
|
261
|
+
throw new Error(this.formatMessage(messages.noVideo));
|
|
262
|
+
// Refresh signed media URLs immediately before the host copies the output.
|
|
263
|
+
const result = await this.service(key).retrieve(old.id, this.abort.signal);
|
|
264
|
+
this.update({
|
|
265
|
+
result,
|
|
266
|
+
message: this.formatMessage(messages.inserting),
|
|
267
|
+
});
|
|
268
|
+
try {
|
|
269
|
+
await this.host.insertVideo(result);
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
throw new Error(this.formatMessage(messages.insertionUnconfirmed) +
|
|
273
|
+
(error instanceof EditorInsertionError
|
|
274
|
+
? " " +
|
|
275
|
+
this.formatMessage(messages.errorCode, { code: error.code }) +
|
|
276
|
+
(error.detail
|
|
277
|
+
? " " +
|
|
278
|
+
this.formatMessage(messages.errorDetail, { detail: error.detail })
|
|
279
|
+
: "")
|
|
280
|
+
: ""));
|
|
281
|
+
}
|
|
282
|
+
this.update({
|
|
283
|
+
message: this.formatMessage(messages.inserted),
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
stop() {
|
|
288
|
+
var _a;
|
|
289
|
+
(_a = this.abort) === null || _a === void 0 ? void 0 : _a.abort();
|
|
290
|
+
}
|
|
291
|
+
async reset() {
|
|
292
|
+
if (this.state.busy)
|
|
293
|
+
return;
|
|
294
|
+
try {
|
|
295
|
+
await this.host.store.save(null);
|
|
296
|
+
this.update({
|
|
297
|
+
savedId: "",
|
|
298
|
+
result: undefined,
|
|
299
|
+
error: false,
|
|
300
|
+
message: this.formatMessage(messages.resetDone),
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
catch (_a) {
|
|
304
|
+
this.update({
|
|
305
|
+
error: true,
|
|
306
|
+
message: this.formatMessage(messages.resetFailed),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
dispose() {
|
|
311
|
+
var _a;
|
|
312
|
+
this.disposed = true;
|
|
313
|
+
(_a = this.abort) === null || _a === void 0 ? void 0 : _a.abort();
|
|
314
|
+
this.listeners.clear();
|
|
315
|
+
}
|
|
316
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { MessageCatalog } from "@magichourhq/browser-client";
|
|
2
|
+
/** IDs are stable so translations in host apps keep matching. */
|
|
3
|
+
export declare const messages: {
|
|
4
|
+
invalidProjectId: {
|
|
5
|
+
id: string;
|
|
6
|
+
defaultMessage: string;
|
|
7
|
+
description: string;
|
|
8
|
+
};
|
|
9
|
+
invalidImageType: {
|
|
10
|
+
id: string;
|
|
11
|
+
defaultMessage: string;
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
imageBytesMismatch: {
|
|
15
|
+
id: string;
|
|
16
|
+
defaultMessage: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
invalidPrompt: {
|
|
20
|
+
id: string;
|
|
21
|
+
defaultMessage: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
invalidDuration: {
|
|
25
|
+
id: string;
|
|
26
|
+
defaultMessage: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
invalidOptions: {
|
|
30
|
+
id: string;
|
|
31
|
+
defaultMessage: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
videoSize: {
|
|
35
|
+
id: string;
|
|
36
|
+
defaultMessage: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
notMp4: {
|
|
40
|
+
id: string;
|
|
41
|
+
defaultMessage: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
downloadFailed: {
|
|
45
|
+
id: string;
|
|
46
|
+
defaultMessage: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
initial: {
|
|
50
|
+
id: string;
|
|
51
|
+
defaultMessage: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
savedAvailable: {
|
|
55
|
+
id: string;
|
|
56
|
+
defaultMessage: string;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
savedUnreadable: {
|
|
60
|
+
id: string;
|
|
61
|
+
defaultMessage: string;
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
operationFailed: {
|
|
65
|
+
id: string;
|
|
66
|
+
defaultMessage: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
uploadRequired: {
|
|
70
|
+
id: string;
|
|
71
|
+
defaultMessage: string;
|
|
72
|
+
description: string;
|
|
73
|
+
};
|
|
74
|
+
imageCaptured: {
|
|
75
|
+
id: string;
|
|
76
|
+
defaultMessage: string;
|
|
77
|
+
description: string;
|
|
78
|
+
};
|
|
79
|
+
imageSelected: {
|
|
80
|
+
id: string;
|
|
81
|
+
defaultMessage: string;
|
|
82
|
+
description: string;
|
|
83
|
+
};
|
|
84
|
+
imageRemoved: {
|
|
85
|
+
id: string;
|
|
86
|
+
defaultMessage: string;
|
|
87
|
+
description: string;
|
|
88
|
+
};
|
|
89
|
+
savedLoading: {
|
|
90
|
+
id: string;
|
|
91
|
+
defaultMessage: string;
|
|
92
|
+
description: string;
|
|
93
|
+
};
|
|
94
|
+
savedExists: {
|
|
95
|
+
id: string;
|
|
96
|
+
defaultMessage: string;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
generating: {
|
|
100
|
+
id: string;
|
|
101
|
+
defaultMessage: string;
|
|
102
|
+
description: string;
|
|
103
|
+
};
|
|
104
|
+
videoReady: {
|
|
105
|
+
id: string;
|
|
106
|
+
defaultMessage: string;
|
|
107
|
+
description: string;
|
|
108
|
+
};
|
|
109
|
+
resuming: {
|
|
110
|
+
id: string;
|
|
111
|
+
defaultMessage: string;
|
|
112
|
+
description: string;
|
|
113
|
+
};
|
|
114
|
+
videoRetrieved: {
|
|
115
|
+
id: string;
|
|
116
|
+
defaultMessage: string;
|
|
117
|
+
description: string;
|
|
118
|
+
};
|
|
119
|
+
videoRetrievedUnsaved: {
|
|
120
|
+
id: string;
|
|
121
|
+
defaultMessage: string;
|
|
122
|
+
description: string;
|
|
123
|
+
};
|
|
124
|
+
noVideo: {
|
|
125
|
+
id: string;
|
|
126
|
+
defaultMessage: string;
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
inserting: {
|
|
130
|
+
id: string;
|
|
131
|
+
defaultMessage: string;
|
|
132
|
+
description: string;
|
|
133
|
+
};
|
|
134
|
+
insertionUnconfirmed: {
|
|
135
|
+
id: string;
|
|
136
|
+
defaultMessage: string;
|
|
137
|
+
description: string;
|
|
138
|
+
};
|
|
139
|
+
errorCode: {
|
|
140
|
+
id: string;
|
|
141
|
+
defaultMessage: string;
|
|
142
|
+
description: string;
|
|
143
|
+
};
|
|
144
|
+
errorDetail: {
|
|
145
|
+
id: string;
|
|
146
|
+
defaultMessage: string;
|
|
147
|
+
description: string;
|
|
148
|
+
};
|
|
149
|
+
inserted: {
|
|
150
|
+
id: string;
|
|
151
|
+
defaultMessage: string;
|
|
152
|
+
description: string;
|
|
153
|
+
};
|
|
154
|
+
resetDone: {
|
|
155
|
+
id: string;
|
|
156
|
+
defaultMessage: string;
|
|
157
|
+
description: string;
|
|
158
|
+
};
|
|
159
|
+
resetFailed: {
|
|
160
|
+
id: string;
|
|
161
|
+
defaultMessage: string;
|
|
162
|
+
description: string;
|
|
163
|
+
};
|
|
164
|
+
previewTimeout: {
|
|
165
|
+
id: string;
|
|
166
|
+
defaultMessage: string;
|
|
167
|
+
description: string;
|
|
168
|
+
};
|
|
169
|
+
previewDecode: {
|
|
170
|
+
id: string;
|
|
171
|
+
defaultMessage: string;
|
|
172
|
+
description: string;
|
|
173
|
+
};
|
|
174
|
+
noDimensions: {
|
|
175
|
+
id: string;
|
|
176
|
+
defaultMessage: string;
|
|
177
|
+
description: string;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
/** Message catalog for hosts that translate this package's messages, such as Canva. */
|
|
181
|
+
export declare function messageCatalog(): MessageCatalog;
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const STATUS = "Status or recovery instruction in the video generation panel.";
|
|
2
|
+
const PREVIEW = "Error when preparing a preview thumbnail from the generated video.";
|
|
3
|
+
/** IDs are stable so translations in host apps keep matching. */
|
|
4
|
+
export const messages = {
|
|
5
|
+
invalidProjectId: {
|
|
6
|
+
id: "+uQJ6m",
|
|
7
|
+
defaultMessage: "Enter a valid Magic Hour video project ID.",
|
|
8
|
+
description: STATUS,
|
|
9
|
+
},
|
|
10
|
+
invalidImageType: {
|
|
11
|
+
id: "UFyz/I",
|
|
12
|
+
defaultMessage: "Choose a PNG, JPEG, or WebP image up to 20 MB.",
|
|
13
|
+
description: STATUS,
|
|
14
|
+
},
|
|
15
|
+
imageBytesMismatch: {
|
|
16
|
+
id: "ZFw9zG",
|
|
17
|
+
defaultMessage: "The image bytes do not match its PNG, JPEG, or WebP type.",
|
|
18
|
+
description: STATUS,
|
|
19
|
+
},
|
|
20
|
+
invalidPrompt: {
|
|
21
|
+
id: "gnSIsq",
|
|
22
|
+
defaultMessage: "Describe the motion in 1–2,000 characters.",
|
|
23
|
+
description: STATUS,
|
|
24
|
+
},
|
|
25
|
+
invalidDuration: {
|
|
26
|
+
id: "ahfrIE",
|
|
27
|
+
defaultMessage: "Choose a duration from 1 to 10 seconds.",
|
|
28
|
+
description: STATUS,
|
|
29
|
+
},
|
|
30
|
+
invalidOptions: {
|
|
31
|
+
id: "1t4/xC",
|
|
32
|
+
defaultMessage: "Choose a supported resolution and aspect ratio.",
|
|
33
|
+
description: STATUS,
|
|
34
|
+
},
|
|
35
|
+
videoSize: {
|
|
36
|
+
id: "EPGtP7",
|
|
37
|
+
defaultMessage: "Video must be nonempty and at most 100 MB.",
|
|
38
|
+
description: STATUS,
|
|
39
|
+
},
|
|
40
|
+
notMp4: {
|
|
41
|
+
id: "8dZXQJ",
|
|
42
|
+
defaultMessage: "The completed output is not an MP4 video.",
|
|
43
|
+
description: STATUS,
|
|
44
|
+
},
|
|
45
|
+
downloadFailed: {
|
|
46
|
+
id: "KEe8C9",
|
|
47
|
+
defaultMessage: "Could not download the completed MP4. Resume to retrieve it again.",
|
|
48
|
+
description: STATUS,
|
|
49
|
+
},
|
|
50
|
+
initial: {
|
|
51
|
+
id: "NuIs9B",
|
|
52
|
+
defaultMessage: "Choose an image or start from a creative brief.",
|
|
53
|
+
description: "Initial instruction for the video generation panel.",
|
|
54
|
+
},
|
|
55
|
+
savedAvailable: {
|
|
56
|
+
id: "jV7hxv",
|
|
57
|
+
defaultMessage: "A saved generation is available. Resume it without another generation charge.",
|
|
58
|
+
description: STATUS,
|
|
59
|
+
},
|
|
60
|
+
savedUnreadable: {
|
|
61
|
+
id: "0DYMZR",
|
|
62
|
+
defaultMessage: "Saved generation could not be read. You can enter its project ID to resume.",
|
|
63
|
+
description: STATUS,
|
|
64
|
+
},
|
|
65
|
+
operationFailed: {
|
|
66
|
+
id: "Q62B3J",
|
|
67
|
+
defaultMessage: "The operation failed. Try again after checking the editor.",
|
|
68
|
+
description: STATUS,
|
|
69
|
+
},
|
|
70
|
+
uploadRequired: {
|
|
71
|
+
id: "/WcueI",
|
|
72
|
+
defaultMessage: "Upload an image to use with this editor.",
|
|
73
|
+
description: STATUS,
|
|
74
|
+
},
|
|
75
|
+
imageCaptured: {
|
|
76
|
+
id: "i3RZZK",
|
|
77
|
+
defaultMessage: "Image ready. Only this captured image will be uploaded when you generate.",
|
|
78
|
+
description: STATUS,
|
|
79
|
+
},
|
|
80
|
+
imageSelected: {
|
|
81
|
+
id: "0zz6+c",
|
|
82
|
+
defaultMessage: "Image ready to animate.",
|
|
83
|
+
description: STATUS,
|
|
84
|
+
},
|
|
85
|
+
imageRemoved: {
|
|
86
|
+
id: "uVs2KL",
|
|
87
|
+
defaultMessage: "Start from a creative brief.",
|
|
88
|
+
description: STATUS,
|
|
89
|
+
},
|
|
90
|
+
savedLoading: {
|
|
91
|
+
id: "rh/64g",
|
|
92
|
+
defaultMessage: "Wait for saved generations to load before generating.",
|
|
93
|
+
description: STATUS,
|
|
94
|
+
},
|
|
95
|
+
savedExists: {
|
|
96
|
+
id: "D6mvMT",
|
|
97
|
+
defaultMessage: "Resume the saved project, or choose New generation before another paid submission.",
|
|
98
|
+
description: STATUS,
|
|
99
|
+
},
|
|
100
|
+
generating: {
|
|
101
|
+
id: "FbNnnY",
|
|
102
|
+
defaultMessage: "Generating with Magic Hour. You may stop waiting and resume later.",
|
|
103
|
+
description: STATUS,
|
|
104
|
+
},
|
|
105
|
+
videoReady: {
|
|
106
|
+
id: "bnMyIi",
|
|
107
|
+
defaultMessage: "Video ready · {credits} Magic Hour credits. Preview it before adding it to your design.",
|
|
108
|
+
description: "Successful video generation with charged credit amount.",
|
|
109
|
+
},
|
|
110
|
+
resuming: {
|
|
111
|
+
id: "W7B/ho",
|
|
112
|
+
defaultMessage: "Retrieving the existing generation. No new generation is submitted.",
|
|
113
|
+
description: STATUS,
|
|
114
|
+
},
|
|
115
|
+
videoRetrieved: {
|
|
116
|
+
id: "liTR0y",
|
|
117
|
+
defaultMessage: "Video ready · original charge {credits} Magic Hour credits.",
|
|
118
|
+
description: "Existing video retrieved without a new charge.",
|
|
119
|
+
},
|
|
120
|
+
videoRetrievedUnsaved: {
|
|
121
|
+
id: "Z7wJK/",
|
|
122
|
+
defaultMessage: "Video ready · original charge {credits} Magic Hour credits. Copy the project ID; local saving is unavailable.",
|
|
123
|
+
description: "Existing video retrieved, but local recovery pointer could not be saved.",
|
|
124
|
+
},
|
|
125
|
+
noVideo: {
|
|
126
|
+
id: "AsYXLo",
|
|
127
|
+
defaultMessage: "Generate or resume a video first.",
|
|
128
|
+
description: STATUS,
|
|
129
|
+
},
|
|
130
|
+
inserting: {
|
|
131
|
+
id: "752heS",
|
|
132
|
+
defaultMessage: "Adding the video to your design…",
|
|
133
|
+
description: STATUS,
|
|
134
|
+
},
|
|
135
|
+
insertionUnconfirmed: {
|
|
136
|
+
id: "OBPLFQ",
|
|
137
|
+
defaultMessage: "The editor could not confirm insertion. Check your design before adding again. Your generation is saved.",
|
|
138
|
+
description: STATUS,
|
|
139
|
+
},
|
|
140
|
+
errorCode: {
|
|
141
|
+
id: "ghHH/N",
|
|
142
|
+
defaultMessage: "Error code: {code}.",
|
|
143
|
+
description: "Safe error code reported by the host editor during video insertion.",
|
|
144
|
+
},
|
|
145
|
+
errorDetail: {
|
|
146
|
+
id: "DmCiga",
|
|
147
|
+
defaultMessage: "Details: {detail}",
|
|
148
|
+
description: "A bounded, redacted explanation of a rejected editor request.",
|
|
149
|
+
},
|
|
150
|
+
inserted: {
|
|
151
|
+
id: "QEuY5P",
|
|
152
|
+
defaultMessage: "Video added to your design.",
|
|
153
|
+
description: STATUS,
|
|
154
|
+
},
|
|
155
|
+
resetDone: {
|
|
156
|
+
id: "TxnZxk",
|
|
157
|
+
defaultMessage: "Ready for a new paid generation. The previous project remains in your Magic Hour account.",
|
|
158
|
+
description: STATUS,
|
|
159
|
+
},
|
|
160
|
+
resetFailed: {
|
|
161
|
+
id: "h/MZQ2",
|
|
162
|
+
defaultMessage: "Could not clear the saved project. Resume it or try New generation again.",
|
|
163
|
+
description: STATUS,
|
|
164
|
+
},
|
|
165
|
+
previewTimeout: {
|
|
166
|
+
id: "N+qxdF",
|
|
167
|
+
defaultMessage: "Video preview timed out. Resume and try again.",
|
|
168
|
+
description: PREVIEW,
|
|
169
|
+
},
|
|
170
|
+
previewDecode: {
|
|
171
|
+
id: "bijDEs",
|
|
172
|
+
defaultMessage: "Could not decode the MP4 preview.",
|
|
173
|
+
description: PREVIEW,
|
|
174
|
+
},
|
|
175
|
+
noDimensions: {
|
|
176
|
+
id: "sVU+/P",
|
|
177
|
+
defaultMessage: "Video dimensions are missing.",
|
|
178
|
+
description: PREVIEW,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
/** Message catalog for hosts that translate this package's messages, such as Canva. */
|
|
182
|
+
export function messageCatalog() {
|
|
183
|
+
const catalog = {};
|
|
184
|
+
for (const { id, defaultMessage, description } of Object.values(messages))
|
|
185
|
+
catalog[id] = { defaultMessage, description };
|
|
186
|
+
return catalog;
|
|
187
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magichourhq/editor-kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared video generation flow for Magic Hour's design editor apps",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"packageManager": "yarn@4.18.0",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/magichourhq/editor-kit.git"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"check": "tsc --noEmit -p tsconfig.test.json",
|
|
26
|
+
"prepack": "yarn build"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@magichourhq/browser-client": "^0.3.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^24.0.0",
|
|
33
|
+
"typescript": "7.0.2",
|
|
34
|
+
"vite": "^8.3.8",
|
|
35
|
+
"vitest": "^5.1.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
6
40
|
}
|