@remotion/studio-server 4.0.91
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/.eslintrc +13 -0
- package/.turbo/turbo-build.log +4 -0
- package/LICENSE.md +45 -0
- package/README.md +3 -0
- package/dist/ansi-diff.d.ts +41 -0
- package/dist/ansi-diff.js +220 -0
- package/dist/better-opn/index.d.ts +6 -0
- package/dist/better-opn/index.js +202 -0
- package/dist/codemods/update-default-props.d.ts +7 -0
- package/dist/codemods/update-default-props.js +137 -0
- package/dist/file-watcher.d.ts +9 -0
- package/dist/file-watcher.js +35 -0
- package/dist/get-latest-remotion-version.d.ts +1 -0
- package/dist/get-latest-remotion-version.js +31 -0
- package/dist/get-network-address.d.ts +1 -0
- package/dist/get-network-address.js +16 -0
- package/dist/helpers/get-file-source.d.ts +1 -0
- package/dist/helpers/get-file-source.js +22 -0
- package/dist/helpers/open-in-editor.d.ts +16 -0
- package/dist/helpers/open-in-editor.js +503 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +27 -0
- package/dist/max-timeline-tracks.d.ts +2 -0
- package/dist/max-timeline-tracks.js +25 -0
- package/dist/open-directory-in-finder.d.ts +1 -0
- package/dist/open-directory-in-finder.js +49 -0
- package/dist/preview-server/api-routes.d.ts +5 -0
- package/dist/preview-server/api-routes.js +25 -0
- package/dist/preview-server/api-types.d.ts +23 -0
- package/dist/preview-server/api-types.js +2 -0
- package/dist/preview-server/dev-middleware/compatible-api.d.ts +7 -0
- package/dist/preview-server/dev-middleware/compatible-api.js +20 -0
- package/dist/preview-server/dev-middleware/get-paths.d.ts +7 -0
- package/dist/preview-server/dev-middleware/get-paths.js +19 -0
- package/dist/preview-server/dev-middleware/index.d.ts +3 -0
- package/dist/preview-server/dev-middleware/index.js +27 -0
- package/dist/preview-server/dev-middleware/middleware.d.ts +9 -0
- package/dist/preview-server/dev-middleware/middleware.js +222 -0
- package/dist/preview-server/dev-middleware/range-parser.d.ts +15 -0
- package/dist/preview-server/dev-middleware/range-parser.js +96 -0
- package/dist/preview-server/dev-middleware/ready.d.ts +3 -0
- package/dist/preview-server/dev-middleware/ready.js +11 -0
- package/dist/preview-server/dev-middleware/setup-hooks.d.ts +2 -0
- package/dist/preview-server/dev-middleware/setup-hooks.js +52 -0
- package/dist/preview-server/dev-middleware/setup-output-filesystem.d.ts +2 -0
- package/dist/preview-server/dev-middleware/setup-output-filesystem.js +13 -0
- package/dist/preview-server/dev-middleware/types.d.ts +10 -0
- package/dist/preview-server/dev-middleware/types.js +2 -0
- package/dist/preview-server/env-supports-fs-recursive.d.ts +1 -0
- package/dist/preview-server/env-supports-fs-recursive.js +18 -0
- package/dist/preview-server/file-existence-watchers.d.ts +13 -0
- package/dist/preview-server/file-existence-watchers.js +62 -0
- package/dist/preview-server/get-absolute-public-dir.d.ts +4 -0
- package/dist/preview-server/get-absolute-public-dir.js +14 -0
- package/dist/preview-server/get-package-manager.d.ts +10 -0
- package/dist/preview-server/get-package-manager.js +62 -0
- package/dist/preview-server/handler.d.ts +12 -0
- package/dist/preview-server/handler.js +36 -0
- package/dist/preview-server/hot-middleware/index.d.ts +102 -0
- package/dist/preview-server/hot-middleware/index.js +149 -0
- package/dist/preview-server/hot-middleware/types.d.ts +2 -0
- package/dist/preview-server/hot-middleware/types.js +2 -0
- package/dist/preview-server/live-events.d.ts +10 -0
- package/dist/preview-server/live-events.js +76 -0
- package/dist/preview-server/parse-body.d.ts +2 -0
- package/dist/preview-server/parse-body.js +16 -0
- package/dist/preview-server/project-info.d.ts +2 -0
- package/dist/preview-server/project-info.js +32 -0
- package/dist/preview-server/public-folder.d.ts +12 -0
- package/dist/preview-server/public-folder.js +58 -0
- package/dist/preview-server/routes/add-render.d.ts +3 -0
- package/dist/preview-server/routes/add-render.js +122 -0
- package/dist/preview-server/routes/can-update-default-props.d.ts +4 -0
- package/dist/preview-server/routes/can-update-default-props.js +40 -0
- package/dist/preview-server/routes/cancel-render.d.ts +3 -0
- package/dist/preview-server/routes/cancel-render.js +8 -0
- package/dist/preview-server/routes/copy-still-to-clipboard-handler.d.ts +3 -0
- package/dist/preview-server/routes/copy-still-to-clipboard-handler.js +17 -0
- package/dist/preview-server/routes/open-in-file-explorer.d.ts +3 -0
- package/dist/preview-server/routes/open-in-file-explorer.js +8 -0
- package/dist/preview-server/routes/remove-render.d.ts +3 -0
- package/dist/preview-server/routes/remove-render.js +8 -0
- package/dist/preview-server/routes/subscribe-to-file-existence.d.ts +3 -0
- package/dist/preview-server/routes/subscribe-to-file-existence.js +13 -0
- package/dist/preview-server/routes/unsubscribe-from-file-existence.d.ts +3 -0
- package/dist/preview-server/routes/unsubscribe-from-file-existence.js +13 -0
- package/dist/preview-server/routes/update-available.d.ts +3 -0
- package/dist/preview-server/routes/update-available.js +9 -0
- package/dist/preview-server/routes/update-default-props.d.ts +3 -0
- package/dist/preview-server/routes/update-default-props.js +34 -0
- package/dist/preview-server/serve-static.d.ts +14 -0
- package/dist/preview-server/serve-static.js +75 -0
- package/dist/preview-server/start-server.d.ts +31 -0
- package/dist/preview-server/start-server.js +123 -0
- package/dist/preview-server/update-available.d.ts +3 -0
- package/dist/preview-server/update-available.js +47 -0
- package/dist/routes.d.ts +24 -0
- package/dist/routes.js +242 -0
- package/dist/server-ready.d.ts +2 -0
- package/dist/server-ready.js +13 -0
- package/dist/start-studio.d.ts +26 -0
- package/dist/start-studio.js +117 -0
- package/dist/watch-root-file.d.ts +1 -0
- package/dist/watch-root-file.js +22 -0
- package/package.json +54 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/web/beep.wav +0 -0
- package/web/favicon.png +0 -0
package/.eslintrc
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Remotion License
|
|
2
|
+
|
|
3
|
+
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
|
|
4
|
+
|
|
5
|
+
- [Free license](#free-license)
|
|
6
|
+
- [Company license](#company-license)
|
|
7
|
+
|
|
8
|
+
## Free license
|
|
9
|
+
|
|
10
|
+
Copyright © 2023 [Remotion](https://www.remotion.dev)
|
|
11
|
+
|
|
12
|
+
### Eligibility
|
|
13
|
+
|
|
14
|
+
You are eligible to use Remotion for free if you are:
|
|
15
|
+
|
|
16
|
+
- an individual
|
|
17
|
+
- a for-profit organization with up to 3 employees
|
|
18
|
+
- a non-profit or not-for-profit organization
|
|
19
|
+
- evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
|
|
20
|
+
|
|
21
|
+
### Allowed use cases
|
|
22
|
+
|
|
23
|
+
Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
|
|
24
|
+
|
|
25
|
+
### Disallowed use cases
|
|
26
|
+
|
|
27
|
+
It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
|
|
28
|
+
|
|
29
|
+
### Warranty notice
|
|
30
|
+
|
|
31
|
+
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
|
|
32
|
+
|
|
33
|
+
### Support
|
|
34
|
+
|
|
35
|
+
Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
|
|
36
|
+
|
|
37
|
+
## Company license
|
|
38
|
+
|
|
39
|
+
You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](https://www.remotion.dev/docs/support)).
|
|
40
|
+
|
|
41
|
+
Visit [remotion.pro](https://www.remotion.pro/license) for pricing and to buy a license.
|
|
42
|
+
|
|
43
|
+
### FAQs
|
|
44
|
+
|
|
45
|
+
Are you not sure whether you need a company license because of an edge case? Here are some [frequently asked questions](https://www.remotion.pro/faq).
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type Options = {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare class AnsiDiff {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
_buffer: string | null;
|
|
12
|
+
_out: Buffer[];
|
|
13
|
+
_lines: Line[];
|
|
14
|
+
finished: boolean;
|
|
15
|
+
constructor(opts?: Options);
|
|
16
|
+
toString(): string | null;
|
|
17
|
+
finish(): Buffer;
|
|
18
|
+
update(buffer: string | Buffer, opts?: {
|
|
19
|
+
moveTo?: [number, number];
|
|
20
|
+
}): Buffer;
|
|
21
|
+
_clearDown(y: number): void;
|
|
22
|
+
_newline(): void;
|
|
23
|
+
_write(line: Line): void;
|
|
24
|
+
_moveTo(x: number, y: number): void;
|
|
25
|
+
_push: (buf: Buffer) => void;
|
|
26
|
+
}
|
|
27
|
+
declare class Line {
|
|
28
|
+
y: number;
|
|
29
|
+
width: number;
|
|
30
|
+
parts: string[];
|
|
31
|
+
height: number;
|
|
32
|
+
remainder: number;
|
|
33
|
+
raw: string;
|
|
34
|
+
length: number;
|
|
35
|
+
newline: boolean;
|
|
36
|
+
constructor(str: string, y: number, nl: boolean, term: AnsiDiff);
|
|
37
|
+
diffLeft(other: Line): number;
|
|
38
|
+
diffRight(other: Line): number;
|
|
39
|
+
toBuffer(): Buffer;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnsiDiff = void 0;
|
|
4
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
5
|
+
const CLEAR_LINE = Buffer.from([0x1b, 0x5b, 0x30, 0x4b]);
|
|
6
|
+
const NEWLINE = Buffer.from('\n');
|
|
7
|
+
class AnsiDiff {
|
|
8
|
+
constructor(opts) {
|
|
9
|
+
this._push = (buf) => {
|
|
10
|
+
this._out.push(buf);
|
|
11
|
+
};
|
|
12
|
+
this.x = 0;
|
|
13
|
+
this.y = 0;
|
|
14
|
+
this.width = (opts === null || opts === void 0 ? void 0 : opts.width) || Infinity;
|
|
15
|
+
this.height = (opts === null || opts === void 0 ? void 0 : opts.height) || Infinity;
|
|
16
|
+
this._buffer = null;
|
|
17
|
+
this._out = [];
|
|
18
|
+
this._lines = [];
|
|
19
|
+
this.finished = false;
|
|
20
|
+
}
|
|
21
|
+
toString() {
|
|
22
|
+
return this._buffer;
|
|
23
|
+
}
|
|
24
|
+
finish() {
|
|
25
|
+
this.finished = true;
|
|
26
|
+
if (this._out.length === 0) {
|
|
27
|
+
return Buffer.from('');
|
|
28
|
+
}
|
|
29
|
+
if (!this._out[this._out.length - 1].toString().endsWith('\n')) {
|
|
30
|
+
return NEWLINE;
|
|
31
|
+
}
|
|
32
|
+
return Buffer.from('');
|
|
33
|
+
}
|
|
34
|
+
update(buffer, opts) {
|
|
35
|
+
if (this.finished) {
|
|
36
|
+
return Buffer.from('');
|
|
37
|
+
}
|
|
38
|
+
this._buffer = Buffer.isBuffer(buffer) ? buffer.toString() : buffer;
|
|
39
|
+
const other = this._buffer;
|
|
40
|
+
const oldLines = this._lines;
|
|
41
|
+
const lines = split(other, this);
|
|
42
|
+
this._lines = lines;
|
|
43
|
+
this._out = [];
|
|
44
|
+
const min = Math.min(lines.length, oldLines.length);
|
|
45
|
+
let i = 0;
|
|
46
|
+
let a;
|
|
47
|
+
let b;
|
|
48
|
+
let scrub = false;
|
|
49
|
+
for (; i < min; i++) {
|
|
50
|
+
a = lines[i];
|
|
51
|
+
b = oldLines[i];
|
|
52
|
+
if (same(a, b))
|
|
53
|
+
continue;
|
|
54
|
+
// if x === width there is an edgecase with inline diffing
|
|
55
|
+
// easiest solution is just not to do it then! :)
|
|
56
|
+
if (!scrub && this.x !== this.width && inlineDiff(a, b)) {
|
|
57
|
+
const left = a.diffLeft(b);
|
|
58
|
+
const right = a.diffRight(b);
|
|
59
|
+
const slice = a.raw.slice(left, right ? -right : a.length);
|
|
60
|
+
if (left + right > 4 && left + slice.length < this.width - 1) {
|
|
61
|
+
this._moveTo(left, a.y);
|
|
62
|
+
this._push(Buffer.from(slice));
|
|
63
|
+
this.x += slice.length;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this._moveTo(0, a.y);
|
|
68
|
+
this._write(a);
|
|
69
|
+
if (a.y !== b.y || a.height !== b.height)
|
|
70
|
+
scrub = true;
|
|
71
|
+
if (b.length > a.length || scrub)
|
|
72
|
+
this._push(CLEAR_LINE);
|
|
73
|
+
if (a.newline)
|
|
74
|
+
this._newline();
|
|
75
|
+
}
|
|
76
|
+
for (; i < lines.length; i++) {
|
|
77
|
+
a = lines[i];
|
|
78
|
+
this._moveTo(0, a.y);
|
|
79
|
+
this._write(a);
|
|
80
|
+
if (scrub)
|
|
81
|
+
this._push(CLEAR_LINE);
|
|
82
|
+
if (a.newline)
|
|
83
|
+
this._newline();
|
|
84
|
+
}
|
|
85
|
+
const oldLast = top(oldLines);
|
|
86
|
+
const last = top(lines);
|
|
87
|
+
if (oldLast &&
|
|
88
|
+
(!last || last.y + last.height < oldLast.y + oldLast.height)) {
|
|
89
|
+
this._clearDown(oldLast.y + oldLast.height);
|
|
90
|
+
}
|
|
91
|
+
if (opts === null || opts === void 0 ? void 0 : opts.moveTo) {
|
|
92
|
+
this._moveTo(opts.moveTo[0], opts.moveTo[1]);
|
|
93
|
+
}
|
|
94
|
+
else if (last) {
|
|
95
|
+
this._moveTo(last.remainder, last.y + last.height);
|
|
96
|
+
}
|
|
97
|
+
return Buffer.concat(this._out);
|
|
98
|
+
}
|
|
99
|
+
_clearDown(y) {
|
|
100
|
+
let { x } = this;
|
|
101
|
+
for (let i = this.y; i <= y; i++) {
|
|
102
|
+
this._moveTo(x, i);
|
|
103
|
+
this._push(CLEAR_LINE);
|
|
104
|
+
x = 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_newline() {
|
|
108
|
+
this._push(NEWLINE);
|
|
109
|
+
this.x = 0;
|
|
110
|
+
this.y++;
|
|
111
|
+
}
|
|
112
|
+
_write(line) {
|
|
113
|
+
this._out.push(line.toBuffer());
|
|
114
|
+
this.x = line.remainder;
|
|
115
|
+
this.y += line.height;
|
|
116
|
+
}
|
|
117
|
+
_moveTo(x, y) {
|
|
118
|
+
const dx = x - this.x;
|
|
119
|
+
const dy = y - this.y;
|
|
120
|
+
if (dx > 0)
|
|
121
|
+
this._push(moveRight(dx));
|
|
122
|
+
else if (dx < 0)
|
|
123
|
+
this._push(moveLeft(-dx));
|
|
124
|
+
if (dy > 0)
|
|
125
|
+
this._push(moveDown(dy));
|
|
126
|
+
else if (dy < 0)
|
|
127
|
+
this._push(moveUp(-dy));
|
|
128
|
+
this.x = x;
|
|
129
|
+
this.y = y;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.AnsiDiff = AnsiDiff;
|
|
133
|
+
function same(a, b) {
|
|
134
|
+
return (a.y === b.y &&
|
|
135
|
+
a.width === b.width &&
|
|
136
|
+
a.raw === b.raw &&
|
|
137
|
+
a.newline === b.newline);
|
|
138
|
+
}
|
|
139
|
+
function top(list) {
|
|
140
|
+
return list.length ? list[list.length - 1] : null;
|
|
141
|
+
}
|
|
142
|
+
class Line {
|
|
143
|
+
constructor(str, y, nl, term) {
|
|
144
|
+
this.y = y;
|
|
145
|
+
this.width = term.width;
|
|
146
|
+
this.parts = (0, studio_shared_1.splitAnsi)(str);
|
|
147
|
+
this.length = length(this.parts);
|
|
148
|
+
this.raw = str;
|
|
149
|
+
this.newline = nl;
|
|
150
|
+
this.height = Math.floor(this.length / term.width);
|
|
151
|
+
this.remainder = this.length - (this.height && this.height * term.width);
|
|
152
|
+
if (this.height && !this.remainder) {
|
|
153
|
+
this.height--;
|
|
154
|
+
this.remainder = this.width;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
diffLeft(other) {
|
|
158
|
+
let left = 0;
|
|
159
|
+
for (; left < this.length; left++) {
|
|
160
|
+
if (this.raw[left] !== other.raw[left])
|
|
161
|
+
return left;
|
|
162
|
+
}
|
|
163
|
+
return left;
|
|
164
|
+
}
|
|
165
|
+
diffRight(other) {
|
|
166
|
+
let right = 0;
|
|
167
|
+
for (; right < this.length; right++) {
|
|
168
|
+
const r = this.length - right - 1;
|
|
169
|
+
if (this.raw[r] !== other.raw[r])
|
|
170
|
+
return right;
|
|
171
|
+
}
|
|
172
|
+
return right;
|
|
173
|
+
}
|
|
174
|
+
toBuffer() {
|
|
175
|
+
return Buffer.from(this.raw);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function inlineDiff(a, b) {
|
|
179
|
+
return (a.length === b.length &&
|
|
180
|
+
a.parts.length === 1 &&
|
|
181
|
+
b.parts.length === 1 &&
|
|
182
|
+
a.y === b.y &&
|
|
183
|
+
a.newline &&
|
|
184
|
+
b.newline &&
|
|
185
|
+
a.width === b.width);
|
|
186
|
+
}
|
|
187
|
+
function split(str, term) {
|
|
188
|
+
let y = 0;
|
|
189
|
+
const lines = str.split('\n');
|
|
190
|
+
const wrapped = [];
|
|
191
|
+
let line;
|
|
192
|
+
for (let i = 0; i < lines.length; i++) {
|
|
193
|
+
line = new Line(lines[i], y, i < lines.length - 1, term);
|
|
194
|
+
y += line.height + (line.newline ? 1 : 0);
|
|
195
|
+
wrapped.push(line);
|
|
196
|
+
}
|
|
197
|
+
return wrapped;
|
|
198
|
+
}
|
|
199
|
+
function moveUp(n) {
|
|
200
|
+
return Buffer.from('1b5b' + toHex(n) + '41', 'hex');
|
|
201
|
+
}
|
|
202
|
+
function moveDown(n) {
|
|
203
|
+
return Buffer.from('1b5b' + toHex(n) + '42', 'hex');
|
|
204
|
+
}
|
|
205
|
+
function moveRight(n) {
|
|
206
|
+
return Buffer.from('1b5b' + toHex(n) + '43', 'hex');
|
|
207
|
+
}
|
|
208
|
+
function moveLeft(n) {
|
|
209
|
+
return Buffer.from('1b5b' + toHex(n) + '44', 'hex');
|
|
210
|
+
}
|
|
211
|
+
function length(parts) {
|
|
212
|
+
let len = 0;
|
|
213
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
214
|
+
len += parts[i].length;
|
|
215
|
+
}
|
|
216
|
+
return len;
|
|
217
|
+
}
|
|
218
|
+
function toHex(n) {
|
|
219
|
+
return Buffer.from(String(n)).toString('hex');
|
|
220
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copied from https://github.com/michaellzc/better-opn#readme
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.openBrowser = void 0;
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const open = require("open");
|
|
7
|
+
const normalizeURLToMatch = (target) => {
|
|
8
|
+
// We may encounter URL parse error but want to fallback to default behavior
|
|
9
|
+
try {
|
|
10
|
+
// Url module is deprecated on newer version of NodeJS, only use it when URL class is not supported (like Node 8)
|
|
11
|
+
const URL = typeof global.URL === 'undefined' ? require('url').URL : global.URL;
|
|
12
|
+
const url = new URL(target);
|
|
13
|
+
return url.origin;
|
|
14
|
+
}
|
|
15
|
+
catch (_a) {
|
|
16
|
+
return target;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Copy from
|
|
20
|
+
// https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/openBrowser.js#L64
|
|
21
|
+
const startBrowserProcess = async ({ browser, url, args, }) => {
|
|
22
|
+
const tryNewInstance = args.length > 0;
|
|
23
|
+
const shouldTryOpenChromiumWithAppleScript = process.platform === 'darwin' &&
|
|
24
|
+
!tryNewInstance &&
|
|
25
|
+
(typeof browser !== 'string' ||
|
|
26
|
+
browser === 'google chrome' ||
|
|
27
|
+
browser === 'chrome');
|
|
28
|
+
if (shouldTryOpenChromiumWithAppleScript) {
|
|
29
|
+
let appleScriptDenied = false;
|
|
30
|
+
// Will use the first open browser found from list
|
|
31
|
+
const supportedChromiumBrowsers = [
|
|
32
|
+
'Google Chrome',
|
|
33
|
+
'Google Chrome Canary',
|
|
34
|
+
'Microsoft Edge',
|
|
35
|
+
'Brave Browser',
|
|
36
|
+
'Vivaldi',
|
|
37
|
+
'Chromium',
|
|
38
|
+
'Arc',
|
|
39
|
+
];
|
|
40
|
+
const processes = await new Promise((resolve, reject) => {
|
|
41
|
+
(0, node_child_process_1.exec)('ps cax', (err, stdout) => {
|
|
42
|
+
if (err) {
|
|
43
|
+
reject(err);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
resolve(stdout);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
const browsersToTry = supportedChromiumBrowsers.filter((b) => processes.includes(b));
|
|
51
|
+
for (const chromiumBrowser of browsersToTry) {
|
|
52
|
+
if (appleScriptDenied) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
// Try our best to reuse existing tab
|
|
57
|
+
// on OSX Chromium-based browser with AppleScript
|
|
58
|
+
const appleScript = `
|
|
59
|
+
(*
|
|
60
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
61
|
+
This source code is licensed under the MIT license found in the
|
|
62
|
+
LICENSE file in the root directory of this source tree.
|
|
63
|
+
*)
|
|
64
|
+
|
|
65
|
+
property targetTab: null
|
|
66
|
+
property targetTabIndex: -1
|
|
67
|
+
property targetWindow: null
|
|
68
|
+
property theProgram: "${chromiumBrowser}"
|
|
69
|
+
|
|
70
|
+
on run argv
|
|
71
|
+
set theURL to "${encodeURI(url)}"
|
|
72
|
+
set matchURL to "${process.env.OPEN_MATCH_HOST_ONLY === 'true'
|
|
73
|
+
? encodeURI(normalizeURLToMatch(url))
|
|
74
|
+
: encodeURI(url)}"
|
|
75
|
+
|
|
76
|
+
using terms from application "Google Chrome"
|
|
77
|
+
tell application theProgram
|
|
78
|
+
|
|
79
|
+
if (count every window) = 0 then
|
|
80
|
+
make new window
|
|
81
|
+
end if
|
|
82
|
+
|
|
83
|
+
-- 1: Looking for tab running debugger
|
|
84
|
+
-- then, Reload debugging tab if found
|
|
85
|
+
-- then return
|
|
86
|
+
set found to my lookupTabWithUrl(matchURL)
|
|
87
|
+
if found then
|
|
88
|
+
set targetWindow's active tab index to targetTabIndex
|
|
89
|
+
tell targetTab to reload
|
|
90
|
+
tell targetWindow to activate
|
|
91
|
+
set index of targetWindow to 1
|
|
92
|
+
return
|
|
93
|
+
end if
|
|
94
|
+
|
|
95
|
+
-- 2: Looking for Empty tab
|
|
96
|
+
-- In case debugging tab was not found
|
|
97
|
+
-- We try to find an empty tab instead
|
|
98
|
+
set found to my lookupTabWithUrl("chrome://newtab/")
|
|
99
|
+
if found then
|
|
100
|
+
set targetWindow's active tab index to targetTabIndex
|
|
101
|
+
set URL of targetTab to theURL
|
|
102
|
+
tell targetWindow to activate
|
|
103
|
+
return
|
|
104
|
+
end if
|
|
105
|
+
|
|
106
|
+
-- 3: Create new tab
|
|
107
|
+
-- both debugging and empty tab were not found
|
|
108
|
+
-- make a new tab with url
|
|
109
|
+
tell window 1
|
|
110
|
+
activate
|
|
111
|
+
make new tab with properties {URL:theURL}
|
|
112
|
+
end tell
|
|
113
|
+
end tell
|
|
114
|
+
end using terms from
|
|
115
|
+
end run
|
|
116
|
+
|
|
117
|
+
-- Function:
|
|
118
|
+
-- Lookup tab with given url
|
|
119
|
+
-- if found, store tab, index, and window in properties
|
|
120
|
+
-- (properties were declared on top of file)
|
|
121
|
+
on lookupTabWithUrl(lookupUrl)
|
|
122
|
+
using terms from application "Google Chrome"
|
|
123
|
+
tell application theProgram
|
|
124
|
+
-- Find a tab with the given url
|
|
125
|
+
set found to false
|
|
126
|
+
set theTabIndex to -1
|
|
127
|
+
repeat with theWindow in every window
|
|
128
|
+
set theTabIndex to 0
|
|
129
|
+
repeat with theTab in every tab of theWindow
|
|
130
|
+
set theTabIndex to theTabIndex + 1
|
|
131
|
+
if (theTab's URL as string) contains lookupUrl then
|
|
132
|
+
-- assign tab, tab index, and window to properties
|
|
133
|
+
set targetTab to theTab
|
|
134
|
+
set targetTabIndex to theTabIndex
|
|
135
|
+
set targetWindow to theWindow
|
|
136
|
+
set found to true
|
|
137
|
+
exit repeat
|
|
138
|
+
end if
|
|
139
|
+
end repeat
|
|
140
|
+
|
|
141
|
+
if found then
|
|
142
|
+
exit repeat
|
|
143
|
+
end if
|
|
144
|
+
end repeat
|
|
145
|
+
end tell
|
|
146
|
+
end using terms from
|
|
147
|
+
return found
|
|
148
|
+
end lookupTabWithUrl
|
|
149
|
+
`.trim();
|
|
150
|
+
await new Promise((resolve, reject) => {
|
|
151
|
+
const proc = (0, node_child_process_1.exec)(`osascript -`, (error) => {
|
|
152
|
+
if (error) {
|
|
153
|
+
reject(error);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// Ignore errors.
|
|
157
|
+
// It it breaks, it will fallback to `opn` anyway
|
|
158
|
+
resolve();
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
proc.stdin.write(appleScript);
|
|
162
|
+
proc.stdin.end();
|
|
163
|
+
});
|
|
164
|
+
return Promise.resolve(true);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
const appleScriptError = error.message;
|
|
168
|
+
if (appleScriptError
|
|
169
|
+
.toLowerCase()
|
|
170
|
+
.includes('not authorised to send apple events')) {
|
|
171
|
+
appleScriptDenied = true;
|
|
172
|
+
}
|
|
173
|
+
// Ignore errors.
|
|
174
|
+
// It it breaks, it will fallback to `opn` anyway
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Fallback to opn
|
|
179
|
+
// (It will always open new tab)
|
|
180
|
+
return open(url, {
|
|
181
|
+
...(browser ? { app: { name: browser, arguments: args } } : {}),
|
|
182
|
+
newInstance: tryNewInstance,
|
|
183
|
+
wait: false,
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
const getBrowserArgs = (browserArgs) => {
|
|
187
|
+
if (browserArgs) {
|
|
188
|
+
return browserArgs.split(' ');
|
|
189
|
+
}
|
|
190
|
+
if (process.env.BROWSER_ARGS) {
|
|
191
|
+
return process.env.BROWSER_ARGS.split(' ');
|
|
192
|
+
}
|
|
193
|
+
return [];
|
|
194
|
+
};
|
|
195
|
+
const openBrowser = ({ url, browserFlag, browserArgs, }) => {
|
|
196
|
+
return startBrowserProcess({
|
|
197
|
+
browser: browserFlag !== null && browserFlag !== void 0 ? browserFlag : process.env.BROWSER,
|
|
198
|
+
url,
|
|
199
|
+
args: getBrowserArgs(browserArgs),
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
exports.openBrowser = openBrowser;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EnumPath } from '@remotion/studio-shared';
|
|
2
|
+
export declare const updateDefaultProps: ({ input, compositionId, newDefaultProps, enumPaths, }: {
|
|
3
|
+
input: string;
|
|
4
|
+
compositionId: string;
|
|
5
|
+
newDefaultProps: Record<string, unknown>;
|
|
6
|
+
enumPaths: EnumPath[];
|
|
7
|
+
}) => Promise<string>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.updateDefaultProps = void 0;
|
|
27
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
28
|
+
const findStarter = ({ input, compositionId, }) => {
|
|
29
|
+
const format1 = input.indexOf(`id="${compositionId}"`);
|
|
30
|
+
if (format1 > -1) {
|
|
31
|
+
return format1;
|
|
32
|
+
}
|
|
33
|
+
const format2 = input.indexOf(`id='${compositionId}'`);
|
|
34
|
+
if (format2 > -1) {
|
|
35
|
+
return format2;
|
|
36
|
+
}
|
|
37
|
+
const format3 = input.indexOf(`id={'${compositionId}'}`);
|
|
38
|
+
if (format3 > -1) {
|
|
39
|
+
return format3;
|
|
40
|
+
}
|
|
41
|
+
const format4 = input.indexOf(`id={"${compositionId}"}`);
|
|
42
|
+
if (format4 > -1) {
|
|
43
|
+
return format4;
|
|
44
|
+
}
|
|
45
|
+
const format5 = input.indexOf(`id={\`${compositionId}\``);
|
|
46
|
+
if (format5 > -1) {
|
|
47
|
+
return format5;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Could not find composition ID ${compositionId} in file`);
|
|
50
|
+
};
|
|
51
|
+
const findEndPosition = (input, currentPosition) => {
|
|
52
|
+
const asConstVersion = input
|
|
53
|
+
.slice(currentPosition + 1)
|
|
54
|
+
.search(/as\sconst[ \t\n\r]+\}/);
|
|
55
|
+
if (asConstVersion !== -1) {
|
|
56
|
+
const nextEnd = input.indexOf('}', asConstVersion + currentPosition + 1);
|
|
57
|
+
return nextEnd - 1;
|
|
58
|
+
}
|
|
59
|
+
// When updating e.g. `defaultProps={{union: {type: 'car' as const, color: ''}}}`
|
|
60
|
+
const nextTriple = input.indexOf('}}}', currentPosition + 1);
|
|
61
|
+
if (nextTriple !== -1) {
|
|
62
|
+
return nextTriple + 1;
|
|
63
|
+
}
|
|
64
|
+
const nextLinux = input.indexOf('}}\n', currentPosition + 1);
|
|
65
|
+
const nextWindows = input.indexOf('}}\r', currentPosition + 1);
|
|
66
|
+
if (nextLinux !== -1) {
|
|
67
|
+
return nextLinux;
|
|
68
|
+
}
|
|
69
|
+
if (nextWindows !== -1) {
|
|
70
|
+
return nextWindows;
|
|
71
|
+
}
|
|
72
|
+
throw new Error('Could not find end of defaultProps');
|
|
73
|
+
};
|
|
74
|
+
const findEnder = (input, position, maxPosition, compositionId) => {
|
|
75
|
+
let currentPosition = position;
|
|
76
|
+
while (currentPosition < maxPosition) {
|
|
77
|
+
const next = findEndPosition(input, currentPosition);
|
|
78
|
+
currentPosition = next;
|
|
79
|
+
const nextChar = input[next + 1];
|
|
80
|
+
if (nextChar === ',') {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
return [position, currentPosition + 1];
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`No \`defaultProps\` prop found in the <Composition/> tag with the ID "${compositionId}".`);
|
|
86
|
+
};
|
|
87
|
+
const findTerminators = (input, position) => {
|
|
88
|
+
const nextComposition = input.indexOf('<Composition', position);
|
|
89
|
+
if (nextComposition > -1) {
|
|
90
|
+
return nextComposition;
|
|
91
|
+
}
|
|
92
|
+
const nextStill = input.indexOf('<Still', position);
|
|
93
|
+
if (nextStill > -1) {
|
|
94
|
+
return nextStill;
|
|
95
|
+
}
|
|
96
|
+
return Infinity;
|
|
97
|
+
};
|
|
98
|
+
const updateDefaultProps = async ({ input, compositionId, newDefaultProps, enumPaths, }) => {
|
|
99
|
+
const starter = findStarter({ input, compositionId });
|
|
100
|
+
const START_TOKEN = 'defaultProps={';
|
|
101
|
+
const start = input.indexOf(START_TOKEN, starter);
|
|
102
|
+
if (start === -1) {
|
|
103
|
+
throw new Error(`No \`defaultProps\` prop found in the <Composition/> tag with the ID "${compositionId}".`);
|
|
104
|
+
}
|
|
105
|
+
const maxEnd = findTerminators(input, starter);
|
|
106
|
+
const [startPos, endPos] = findEnder(input, start + START_TOKEN.length, maxEnd, compositionId);
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
108
|
+
let prettier = null;
|
|
109
|
+
try {
|
|
110
|
+
prettier = await Promise.resolve().then(() => __importStar(require('prettier')));
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
throw new Error('Prettier cannot be found in the current project.');
|
|
114
|
+
}
|
|
115
|
+
const { format, resolveConfig, resolveConfigFile } = prettier;
|
|
116
|
+
const newFile = input.substring(0, startPos) +
|
|
117
|
+
(0, studio_shared_1.stringifyDefaultProps)({ props: newDefaultProps, enumPaths }) +
|
|
118
|
+
input.substring(endPos);
|
|
119
|
+
const configFilePath = await resolveConfigFile();
|
|
120
|
+
if (!configFilePath) {
|
|
121
|
+
throw new Error('The Prettier config file was not found');
|
|
122
|
+
}
|
|
123
|
+
const prettierConfig = await resolveConfig(configFilePath);
|
|
124
|
+
if (!prettierConfig) {
|
|
125
|
+
throw new Error(`The Prettier config at ${configFilePath} could not be read`);
|
|
126
|
+
}
|
|
127
|
+
const prettified = format(newFile, {
|
|
128
|
+
...prettierConfig,
|
|
129
|
+
rangeStart: startPos,
|
|
130
|
+
rangeEnd: endPos,
|
|
131
|
+
filepath: 'test.tsx',
|
|
132
|
+
plugins: [],
|
|
133
|
+
endOfLine: 'auto',
|
|
134
|
+
});
|
|
135
|
+
return prettified;
|
|
136
|
+
};
|
|
137
|
+
exports.updateDefaultProps = updateDefaultProps;
|