@remotion/studio-server 4.0.495 → 4.0.497

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.
Files changed (32) hide show
  1. package/dist/better-opn/index.d.ts +6 -0
  2. package/dist/better-opn/index.js +46 -18
  3. package/dist/codemods/recast-mods.js +4 -15
  4. package/dist/codemods/strip-parenthesized-extra.d.ts +1 -0
  5. package/dist/codemods/strip-parenthesized-extra.js +16 -0
  6. package/dist/codemods/update-sequence-props/update-sequence-props.js +47 -0
  7. package/dist/helpers/css-shorthand-properties.d.ts +27 -0
  8. package/dist/helpers/css-shorthand-properties.js +43 -0
  9. package/dist/helpers/package-manager-spawn-options.d.ts +2 -0
  10. package/dist/helpers/package-manager-spawn-options.js +7 -0
  11. package/dist/helpers/parse-background-shorthand.d.ts +11 -0
  12. package/dist/helpers/parse-background-shorthand.js +41 -0
  13. package/dist/helpers/parse-border-shorthand.d.ts +6 -0
  14. package/dist/helpers/parse-border-shorthand.js +135 -0
  15. package/dist/helpers/resolve-composition-component.d.ts +3 -1
  16. package/dist/helpers/resolve-composition-component.js +40 -10
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +2 -0
  19. package/dist/open-browser-shortcut.js +26 -16
  20. package/dist/preview-server/routes/can-update-sequence-props.js +54 -3
  21. package/dist/preview-server/routes/download-remote-asset.js +1 -0
  22. package/dist/preview-server/routes/insert-element.js +7 -1
  23. package/dist/preview-server/routes/insert-jsx-element.js +9 -1
  24. package/dist/preview-server/routes/install-dependency.js +5 -1
  25. package/dist/preview-server/routes/save-sequence-props.js +90 -22
  26. package/package.json +6 -6
  27. package/dist/preview-server/routes/delete-effect-keyframe.d.ts +0 -3
  28. package/dist/preview-server/routes/delete-effect-keyframe.js +0 -89
  29. package/dist/preview-server/routes/delete-sequence-keyframe.d.ts +0 -3
  30. package/dist/preview-server/routes/delete-sequence-keyframe.js +0 -82
  31. package/dist/preview-server/routes/save-props-mutex.d.ts +0 -1
  32. package/dist/preview-server/routes/save-props-mutex.js +0 -11
@@ -1,8 +1,14 @@
1
1
  export declare const getChromiumBrowsersToTry: (processes: string) => ("Arc" | "Brave Browser" | "Chromium" | "Google Chrome" | "Google Chrome Canary" | "Microsoft Edge" | "Vivaldi")[];
2
2
  export declare const getFocusBrowserTabAppleScript: (chromiumBrowser: "Arc" | "Brave Browser" | "Chromium" | "Google Chrome" | "Google Chrome Canary" | "Microsoft Edge" | "Vivaldi") => string;
3
+ export declare const getFocusBrowserTabByOriginAppleScript: (chromiumBrowser: "Arc" | "Brave Browser" | "Chromium" | "Google Chrome" | "Google Chrome Canary" | "Microsoft Edge" | "Vivaldi") => string;
3
4
  export declare const focusBrowserTab: ({ url }: {
4
5
  url: string;
5
6
  }) => Promise<boolean>;
7
+ export declare const focusBrowserTabByOrigin: ({ url, browserFlag, browserArgs, }: {
8
+ url: string;
9
+ browserFlag: string | undefined;
10
+ browserArgs: string | undefined;
11
+ }) => false | Promise<boolean>;
6
12
  export declare const openBrowser: ({ url, browserFlag, browserArgs, }: {
7
13
  url: string;
8
14
  browserFlag: string | undefined;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Copied from https://github.com/michaellzc/better-opn#readme
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.openBrowser = exports.focusBrowserTab = exports.getFocusBrowserTabAppleScript = exports.getChromiumBrowsersToTry = void 0;
4
+ exports.openBrowser = exports.focusBrowserTabByOrigin = exports.focusBrowserTab = exports.getFocusBrowserTabByOriginAppleScript = exports.getFocusBrowserTabAppleScript = exports.getChromiumBrowsersToTry = void 0;
5
5
  const node_child_process_1 = require("node:child_process");
6
6
  const open = require("open");
7
7
  const supportedChromiumBrowsers = [
@@ -96,7 +96,21 @@ const normalizeURLToMatch = (target) => {
96
96
  return target;
97
97
  }
98
98
  };
99
- const getFocusBrowserTabAppleScript = (chromiumBrowser) => {
99
+ const getBrowserArgs = (browserArgs) => {
100
+ if (browserArgs) {
101
+ return browserArgs.split(' ');
102
+ }
103
+ if (process.env.BROWSER_ARGS) {
104
+ return process.env.BROWSER_ARGS.split(' ');
105
+ }
106
+ return [];
107
+ };
108
+ const shouldTryOpenChromiumWithAppleScript = ({ browser, args, }) => {
109
+ return (process.platform === 'darwin' &&
110
+ args.length === 0 &&
111
+ (!browser || browser === 'google chrome' || browser === 'chrome'));
112
+ };
113
+ const getFocusBrowserTabAppleScriptWithCondition = (chromiumBrowser, condition) => {
100
114
  return `
101
115
  property targetTabIndex: -1
102
116
  property targetWindow: null
@@ -128,7 +142,7 @@ on lookupTabWithUrl(lookupUrl)
128
142
  set theTabIndex to 0
129
143
  repeat with theTab in every tab of theWindow
130
144
  set theTabIndex to theTabIndex + 1
131
- if (theTab's URL as string) is lookupUrl then
145
+ ${condition}
132
146
  set targetTabIndex to theTabIndex
133
147
  set targetWindow to theWindow
134
148
  set found to true
@@ -146,8 +160,16 @@ on lookupTabWithUrl(lookupUrl)
146
160
  end lookupTabWithUrl
147
161
  `.trim();
148
162
  };
163
+ const getFocusBrowserTabAppleScript = (chromiumBrowser) => {
164
+ return getFocusBrowserTabAppleScriptWithCondition(chromiumBrowser, "if (theTab's URL as string) is lookupUrl then");
165
+ };
149
166
  exports.getFocusBrowserTabAppleScript = getFocusBrowserTabAppleScript;
150
- const focusBrowserTab = async ({ url }) => {
167
+ const getFocusBrowserTabByOriginAppleScript = (chromiumBrowser) => {
168
+ return getFocusBrowserTabAppleScriptWithCondition(chromiumBrowser, `set tabURL to theTab's URL as string
169
+ if tabURL is lookupUrl or tabURL starts with lookupUrl & "/" or tabURL starts with lookupUrl & "?" or tabURL starts with lookupUrl & "#" then`);
170
+ };
171
+ exports.getFocusBrowserTabByOriginAppleScript = getFocusBrowserTabByOriginAppleScript;
172
+ const focusBrowserTabWithAppleScript = async ({ url, getAppleScript, }) => {
151
173
  if (process.platform !== 'darwin') {
152
174
  return false;
153
175
  }
@@ -161,7 +183,7 @@ const focusBrowserTab = async ({ url }) => {
161
183
  for (const chromiumBrowser of browsersToTry) {
162
184
  try {
163
185
  const result = await runAppleScript({
164
- appleScript: (0, exports.getFocusBrowserTabAppleScript)(chromiumBrowser),
186
+ appleScript: getAppleScript(chromiumBrowser),
165
187
  args: [url],
166
188
  });
167
189
  if (result.trim() === 'true') {
@@ -176,15 +198,30 @@ const focusBrowserTab = async ({ url }) => {
176
198
  }
177
199
  return false;
178
200
  };
201
+ const focusBrowserTab = ({ url }) => {
202
+ return focusBrowserTabWithAppleScript({
203
+ url,
204
+ getAppleScript: exports.getFocusBrowserTabAppleScript,
205
+ });
206
+ };
179
207
  exports.focusBrowserTab = focusBrowserTab;
208
+ const focusBrowserTabByOrigin = ({ url, browserFlag, browserArgs, }) => {
209
+ const args = getBrowserArgs(browserArgs);
210
+ const browser = browserFlag !== null && browserFlag !== void 0 ? browserFlag : process.env.BROWSER;
211
+ if (!shouldTryOpenChromiumWithAppleScript({ browser, args })) {
212
+ return false;
213
+ }
214
+ return focusBrowserTabWithAppleScript({
215
+ url: normalizeURLToMatch(url),
216
+ getAppleScript: exports.getFocusBrowserTabByOriginAppleScript,
217
+ });
218
+ };
219
+ exports.focusBrowserTabByOrigin = focusBrowserTabByOrigin;
180
220
  // Copy from
181
221
  // https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/openBrowser.js#L64
182
222
  const startBrowserProcess = async ({ browser, url, args, }) => {
183
223
  const tryNewInstance = args.length > 0;
184
- const shouldTryOpenChromiumWithAppleScript = process.platform === 'darwin' &&
185
- !tryNewInstance &&
186
- (!browser || browser === 'google chrome' || browser === 'chrome');
187
- if (shouldTryOpenChromiumWithAppleScript) {
224
+ if (shouldTryOpenChromiumWithAppleScript({ browser, args })) {
188
225
  let appleScriptDenied = false;
189
226
  // Will use the first open browser found from list
190
227
  const browsersToTry = await getRunningChromiumBrowsers();
@@ -308,15 +345,6 @@ const startBrowserProcess = async ({ browser, url, args, }) => {
308
345
  wait: false,
309
346
  });
310
347
  };
311
- const getBrowserArgs = (browserArgs) => {
312
- if (browserArgs) {
313
- return browserArgs.split(' ');
314
- }
315
- if (process.env.BROWSER_ARGS) {
316
- return process.env.BROWSER_ARGS.split(' ');
317
- }
318
- return [];
319
- };
320
348
  const openBrowser = ({ url, browserFlag, browserArgs, }) => {
321
349
  return startBrowserProcess({
322
350
  browser: browserFlag !== null && browserFlag !== void 0 ? browserFlag : process.env.BROWSER,
@@ -37,6 +37,7 @@ exports.applyCodemod = void 0;
37
37
  const recast = __importStar(require("recast"));
38
38
  const apply_visual_control_1 = require("./apply-visual-control");
39
39
  const delete_jsx_node_1 = require("./delete-jsx-node");
40
+ const strip_parenthesized_extra_1 = require("./strip-parenthesized-extra");
40
41
  const b = recast.types.builders;
41
42
  const applyCodemod = ({ file, codeMod, }) => {
42
43
  const changesMade = [];
@@ -131,25 +132,13 @@ const mapReturnStatement = (statement, transformation, changesMade, parentFolder
131
132
  };
132
133
  };
133
134
  const nullLiteral = () => ({ type: 'NullLiteral' });
134
- // When a node was originally parenthesized (e.g. the `<JSX/>` inside
135
- // `return (<JSX/>)`), Babel records `extra.parenthesized` on it. If we move
136
- // such a node into a JSXFragment without clearing that hint, recast prints
137
- // stray `(` / `)` characters around it as JSX text. Clear the hint so the
138
- // node prints cleanly in its new context.
139
- const stripParenthesizedExtra = (node) => {
140
- if (!node.extra) {
141
- return node;
142
- }
143
- const { parenthesized: _p, parenStart: _ps, ...rest } = node.extra;
144
- return { ...node, extra: rest };
145
- };
146
135
  const wrapInJsxFragment = (children) => ({
147
136
  type: 'JSXFragment',
148
137
  openingFragment: { type: 'JSXOpeningFragment' },
149
138
  closingFragment: { type: 'JSXClosingFragment' },
150
139
  children: children.map((child) => {
151
140
  if (child.type === 'JSXElement' || child.type === 'JSXFragment') {
152
- return stripParenthesizedExtra(child);
141
+ return (0, strip_parenthesized_extra_1.stripParenthesizedExtra)(child);
153
142
  }
154
143
  return child;
155
144
  }),
@@ -292,7 +281,7 @@ const appendCompositionToFolder = ({ compositionElement, folderElement, }) => {
292
281
  type: 'JSXClosingElement',
293
282
  name: folderElement.openingElement.name,
294
283
  };
295
- folderElement.children.push(stripParenthesizedExtra(compositionElement));
284
+ folderElement.children.push((0, strip_parenthesized_extra_1.stripParenthesizedExtra)(compositionElement));
296
285
  };
297
286
  const appendCompositionToRoot = ({ compositionElement, file, }) => {
298
287
  let appended = false;
@@ -307,7 +296,7 @@ const appendCompositionToRoot = ({ compositionElement, file, }) => {
307
296
  return undefined;
308
297
  }
309
298
  if (argument.type === 'JSXFragment') {
310
- argument.children.push(stripParenthesizedExtra(compositionElement));
299
+ argument.children.push((0, strip_parenthesized_extra_1.stripParenthesizedExtra)(compositionElement));
311
300
  }
312
301
  else {
313
302
  astPath.node.argument = wrapInJsxFragment([
@@ -0,0 +1 @@
1
+ export declare const stripParenthesizedExtra: <T extends object>(node: T) => T;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripParenthesizedExtra = void 0;
4
+ // When a node was originally parenthesized (e.g. the `<JSX/>` inside
5
+ // `return (<JSX/>)`), Babel records `extra.parenthesized` on it. If we move
6
+ // such a node into a new JSX parent without clearing that hint, recast prints
7
+ // stray `(` / `)` characters around it as JSX text.
8
+ const stripParenthesizedExtra = (node) => {
9
+ const { extra } = node;
10
+ if (!extra) {
11
+ return node;
12
+ }
13
+ const { parenthesized: _p, parenStart: _ps, ...rest } = extra;
14
+ return { ...node, extra: rest };
15
+ };
16
+ exports.stripParenthesizedExtra = stripParenthesizedExtra;
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.updateSequenceProps = exports.updateMultipleSequenceProps = exports.updateSequencePropsAst = void 0;
37
37
  const recast = __importStar(require("recast"));
38
38
  const no_react_1 = require("remotion/no-react");
39
+ const css_shorthand_properties_1 = require("../../helpers/css-shorthand-properties");
39
40
  const video_config_numeric_expression_1 = require("../../helpers/video-config-numeric-expression");
40
41
  const video_config_values_1 = require("../../helpers/video-config-values");
41
42
  const can_update_sequence_props_1 = require("../../preview-server/routes/can-update-sequence-props");
@@ -474,11 +475,57 @@ const applyGoogleFontSourceEdits = ({ ast, updates, }) => {
474
475
  removeUnusedGoogleFontSourceEdits(ast);
475
476
  }
476
477
  };
478
+ const migrateCssShorthand = ({ node, cssShorthand, }) => {
479
+ var _a, _b, _c;
480
+ var _d;
481
+ const styleAttribute = (_a = node.attributes) === null || _a === void 0 ? void 0 : _a.find((attribute) => attribute.type === 'JSXAttribute' &&
482
+ attribute.name.type === 'JSXIdentifier' &&
483
+ attribute.name.name === 'style');
484
+ if ((styleAttribute === null || styleAttribute === void 0 ? void 0 : styleAttribute.type) !== 'JSXAttribute' ||
485
+ ((_b = styleAttribute.value) === null || _b === void 0 ? void 0 : _b.type) !== 'JSXExpressionContainer' ||
486
+ styleAttribute.value.expression.type !== 'ObjectExpression') {
487
+ return;
488
+ }
489
+ const { properties } = styleAttribute.value.expression;
490
+ for (let index = 0; index < properties.length; index++) {
491
+ const property = properties[index];
492
+ if (property.type !== 'ObjectProperty' ||
493
+ !((property.key.type === 'Identifier' &&
494
+ property.key.name === cssShorthand.shorthand) ||
495
+ (property.key.type === 'StringLiteral' &&
496
+ property.key.value === cssShorthand.shorthand))) {
497
+ continue;
498
+ }
499
+ const shorthandValue = property.value.type === 'StringLiteral'
500
+ ? property.value.value
501
+ : property.value.type === 'TemplateLiteral' &&
502
+ property.value.expressions.length === 0
503
+ ? ((_d = (_c = property.value.quasis[0]) === null || _c === void 0 ? void 0 : _c.value.cooked) !== null && _d !== void 0 ? _d : null)
504
+ : null;
505
+ if (shorthandValue === null) {
506
+ continue;
507
+ }
508
+ const parsed = cssShorthand.parse(shorthandValue);
509
+ if (!parsed) {
510
+ continue;
511
+ }
512
+ properties.splice(index, 1, ...cssShorthand.longhands.map((longhand) => {
513
+ const value = parsed[longhand];
514
+ return b.objectProperty(b.identifier(longhand), typeof value === 'number'
515
+ ? b.numericLiteral(value)
516
+ : b.stringLiteral(value));
517
+ }));
518
+ index += cssShorthand.longhands.length - 1;
519
+ }
520
+ };
477
521
  const updateSequencePropsNode = ({ jsxElement, updates, schema, videoConfigValues, }) => {
478
522
  var _a, _b, _c, _d;
479
523
  var _e, _f;
480
524
  const node = jsxElement.openingElement;
481
525
  const logLine = (_e = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _e !== void 0 ? _e : 1;
526
+ for (const cssShorthand of (0, css_shorthand_properties_1.getCssShorthandsForUpdates)(updates.map((update) => update.key))) {
527
+ migrateCssShorthand({ node, cssShorthand });
528
+ }
482
529
  const oldValueStrings = [];
483
530
  const initialAttrs = snapshotTopLevelAttrs(node);
484
531
  const updatedTopLevelKeys = new Set(updates.map(({ key }) => {
@@ -0,0 +1,27 @@
1
+ type ParsedCssShorthand = Readonly<Record<string, string | number>>;
2
+ export type CssShorthandProperty = {
3
+ readonly parentKey: string;
4
+ readonly shorthand: string;
5
+ readonly longhands: readonly string[];
6
+ readonly parse: (value: string) => ParsedCssShorthand | null;
7
+ readonly isUnsupportedProperty: (propertyName: string) => boolean;
8
+ };
9
+ export declare const cssShorthandProperties: readonly [{
10
+ readonly parentKey: "style";
11
+ readonly shorthand: "background";
12
+ readonly longhands: readonly ["backgroundColor", "backgroundImage", "backgroundPosition", "backgroundSize", "backgroundRepeat", "backgroundOrigin", "backgroundClip", "backgroundAttachment"];
13
+ readonly parse: (value: string) => import("./parse-background-shorthand").ParsedBackgroundShorthand | null;
14
+ readonly isUnsupportedProperty: () => false;
15
+ }, {
16
+ readonly parentKey: "style";
17
+ readonly shorthand: "border";
18
+ readonly longhands: readonly ["borderWidth", "borderStyle", "borderColor"];
19
+ readonly parse: (value: string) => import("./parse-border-shorthand").ParsedBorderShorthand | null;
20
+ readonly isUnsupportedProperty: (propertyName: string) => boolean;
21
+ }];
22
+ export declare const getCssShorthandForLonghand: ({ parentKey, longhand, }: {
23
+ parentKey: string;
24
+ longhand: string;
25
+ }) => CssShorthandProperty | null;
26
+ export declare const getCssShorthandsForUpdates: (updateKeys: readonly string[]) => CssShorthandProperty[];
27
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCssShorthandsForUpdates = exports.getCssShorthandForLonghand = exports.cssShorthandProperties = void 0;
4
+ const parse_background_shorthand_1 = require("./parse-background-shorthand");
5
+ const parse_border_shorthand_1 = require("./parse-border-shorthand");
6
+ const borderSidePropertyRegex = /^border(?:Top|Right|Bottom|Left)(?:Width|Style|Color)?$/;
7
+ const borderShorthand = {
8
+ parentKey: 'style',
9
+ shorthand: 'border',
10
+ longhands: ['borderWidth', 'borderStyle', 'borderColor'],
11
+ parse: parse_border_shorthand_1.parseBorderShorthand,
12
+ isUnsupportedProperty: (propertyName) => borderSidePropertyRegex.test(propertyName),
13
+ };
14
+ const backgroundShorthand = {
15
+ parentKey: 'style',
16
+ shorthand: 'background',
17
+ longhands: [
18
+ 'backgroundColor',
19
+ 'backgroundImage',
20
+ 'backgroundPosition',
21
+ 'backgroundSize',
22
+ 'backgroundRepeat',
23
+ 'backgroundOrigin',
24
+ 'backgroundClip',
25
+ 'backgroundAttachment',
26
+ ],
27
+ parse: parse_background_shorthand_1.parseBackgroundShorthand,
28
+ isUnsupportedProperty: () => false,
29
+ };
30
+ exports.cssShorthandProperties = [
31
+ backgroundShorthand,
32
+ borderShorthand,
33
+ ];
34
+ const getCssShorthandForLonghand = ({ parentKey, longhand, }) => {
35
+ var _a;
36
+ return ((_a = exports.cssShorthandProperties.find((property) => property.parentKey === parentKey &&
37
+ property.longhands.includes(longhand))) !== null && _a !== void 0 ? _a : null);
38
+ };
39
+ exports.getCssShorthandForLonghand = getCssShorthandForLonghand;
40
+ const getCssShorthandsForUpdates = (updateKeys) => {
41
+ return exports.cssShorthandProperties.filter((property) => updateKeys.some((key) => property.longhands.some((longhand) => key === `${property.parentKey}.${longhand}`)));
42
+ };
43
+ exports.getCssShorthandsForUpdates = getCssShorthandsForUpdates;
@@ -0,0 +1,2 @@
1
+ import type { SpawnOptionsWithoutStdio } from 'node:child_process';
2
+ export declare const getPackageManagerSpawnOptions: () => Pick<SpawnOptionsWithoutStdio, "shell">;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageManagerSpawnOptions = void 0;
4
+ const getPackageManagerSpawnOptions = () => {
5
+ return process.platform === 'win32' ? { shell: true } : {};
6
+ };
7
+ exports.getPackageManagerSpawnOptions = getPackageManagerSpawnOptions;
@@ -0,0 +1,11 @@
1
+ export type ParsedBackgroundShorthand = {
2
+ backgroundAttachment: string;
3
+ backgroundClip: string;
4
+ backgroundColor: string;
5
+ backgroundImage: string;
6
+ backgroundOrigin: string;
7
+ backgroundPosition: string;
8
+ backgroundRepeat: string;
9
+ backgroundSize: string;
10
+ };
11
+ export declare const parseBackgroundShorthand: (value: string) => ParsedBackgroundShorthand | null;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseBackgroundShorthand = void 0;
4
+ const no_react_1 = require("remotion/no-react");
5
+ const CSS_WIDE_KEYWORDS = new Set([
6
+ 'inherit',
7
+ 'initial',
8
+ 'revert',
9
+ 'revert-layer',
10
+ 'unset',
11
+ ]);
12
+ const makeColorOnlyBackground = (backgroundColor) => {
13
+ return {
14
+ backgroundColor,
15
+ backgroundImage: 'none',
16
+ backgroundPosition: '0% 0%',
17
+ backgroundSize: 'auto auto',
18
+ backgroundRepeat: 'repeat',
19
+ backgroundOrigin: 'padding-box',
20
+ backgroundClip: 'border-box',
21
+ backgroundAttachment: 'scroll',
22
+ };
23
+ };
24
+ const parseBackgroundShorthand = (value) => {
25
+ const trimmed = value.trim();
26
+ const lowerCaseValue = trimmed.toLowerCase();
27
+ if (trimmed === '' || CSS_WIDE_KEYWORDS.has(lowerCaseValue)) {
28
+ return null;
29
+ }
30
+ if (lowerCaseValue === 'none') {
31
+ return makeColorOnlyBackground('transparent');
32
+ }
33
+ try {
34
+ no_react_1.NoReactInternals.processColor(trimmed);
35
+ return makeColorOnlyBackground(trimmed);
36
+ }
37
+ catch (_a) {
38
+ return null;
39
+ }
40
+ };
41
+ exports.parseBackgroundShorthand = parseBackgroundShorthand;
@@ -0,0 +1,6 @@
1
+ export type ParsedBorderShorthand = {
2
+ borderWidth: number;
3
+ borderStyle: string;
4
+ borderColor: string;
5
+ };
6
+ export declare const parseBorderShorthand: (value: string) => ParsedBorderShorthand | null;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseBorderShorthand = void 0;
4
+ const BORDER_STYLES = new Set([
5
+ 'none',
6
+ 'hidden',
7
+ 'dotted',
8
+ 'dashed',
9
+ 'solid',
10
+ 'double',
11
+ 'groove',
12
+ 'ridge',
13
+ 'inset',
14
+ 'outset',
15
+ ]);
16
+ const CSS_WIDE_KEYWORDS = new Set([
17
+ 'inherit',
18
+ 'initial',
19
+ 'revert',
20
+ 'revert-layer',
21
+ 'unset',
22
+ ]);
23
+ const BORDER_WIDTH_KEYWORDS = {
24
+ // Chromium resolves these CSS keywords to these pixel values.
25
+ thin: 1,
26
+ medium: 3,
27
+ thick: 5,
28
+ };
29
+ const splitCssWhitespace = (value) => {
30
+ const parts = [];
31
+ let current = '';
32
+ let parenthesisDepth = 0;
33
+ let quote = null;
34
+ for (const char of value.trim()) {
35
+ if (quote !== null) {
36
+ current += char;
37
+ if (char === quote) {
38
+ quote = null;
39
+ }
40
+ continue;
41
+ }
42
+ if (char === '"' || char === "'") {
43
+ quote = char;
44
+ current += char;
45
+ continue;
46
+ }
47
+ if (char === '(') {
48
+ parenthesisDepth++;
49
+ current += char;
50
+ continue;
51
+ }
52
+ if (char === ')') {
53
+ parenthesisDepth--;
54
+ if (parenthesisDepth < 0) {
55
+ return null;
56
+ }
57
+ current += char;
58
+ continue;
59
+ }
60
+ if (/\s/.test(char) && parenthesisDepth === 0) {
61
+ if (current !== '') {
62
+ parts.push(current);
63
+ current = '';
64
+ }
65
+ continue;
66
+ }
67
+ current += char;
68
+ }
69
+ if (quote !== null || parenthesisDepth !== 0) {
70
+ return null;
71
+ }
72
+ if (current !== '') {
73
+ parts.push(current);
74
+ }
75
+ return parts;
76
+ };
77
+ const parsePixelWidth = (token) => {
78
+ if (token === '0') {
79
+ return 0;
80
+ }
81
+ const match = token.match(/^(\d+(?:\.\d+)?|\.\d+)px$/i);
82
+ if (!match) {
83
+ return null;
84
+ }
85
+ return Number(match[1]);
86
+ };
87
+ const parseBorderShorthand = (value) => {
88
+ const tokens = splitCssWhitespace(value);
89
+ if (!tokens || tokens.length === 0) {
90
+ return null;
91
+ }
92
+ let borderWidth = null;
93
+ let borderStyle = null;
94
+ let borderColor = null;
95
+ for (const token of tokens) {
96
+ const lowerCaseToken = token.toLowerCase();
97
+ if (CSS_WIDE_KEYWORDS.has(lowerCaseToken)) {
98
+ return null;
99
+ }
100
+ if (BORDER_STYLES.has(lowerCaseToken)) {
101
+ if (borderStyle !== null) {
102
+ return null;
103
+ }
104
+ borderStyle = lowerCaseToken;
105
+ continue;
106
+ }
107
+ const width = parsePixelWidth(token);
108
+ if (width !== null) {
109
+ if (borderWidth !== null) {
110
+ return null;
111
+ }
112
+ borderWidth = width;
113
+ continue;
114
+ }
115
+ const keywordWidth = BORDER_WIDTH_KEYWORDS[lowerCaseToken];
116
+ if (keywordWidth !== undefined) {
117
+ if (borderWidth !== null) {
118
+ return null;
119
+ }
120
+ borderWidth = keywordWidth;
121
+ continue;
122
+ }
123
+ if (borderColor === null) {
124
+ borderColor = token;
125
+ continue;
126
+ }
127
+ return null;
128
+ }
129
+ return {
130
+ borderWidth: borderWidth !== null && borderWidth !== void 0 ? borderWidth : BORDER_WIDTH_KEYWORDS.medium,
131
+ borderStyle: borderStyle !== null && borderStyle !== void 0 ? borderStyle : 'none',
132
+ borderColor: borderColor !== null && borderColor !== void 0 ? borderColor : 'currentColor',
133
+ };
134
+ };
135
+ exports.parseBorderShorthand = parseBorderShorthand;
@@ -19,11 +19,12 @@ export declare const resolveCompositionComponent: ({ remotionRoot, compositionFi
19
19
  compositionFile: string;
20
20
  compositionId: string;
21
21
  }) => Promise<ResolvedCompositionComponent>;
22
- export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositionFile, compositionId, element, prettierConfigOverride, wrapInSequence, }: {
22
+ export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositionFile, compositionId, element, from, prettierConfigOverride, wrapInSequence, }: {
23
23
  remotionRoot: string;
24
24
  compositionFile: string;
25
25
  compositionId: string;
26
26
  element: InsertableCompositionElement;
27
+ from: number | null;
27
28
  prettierConfigOverride: Record<string, unknown> | null;
28
29
  wrapInSequence?: {
29
30
  dimensions: {
@@ -31,6 +32,7 @@ export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositi
31
32
  height: number;
32
33
  } | null;
33
34
  durationInFrames?: number | null | undefined;
35
+ from: number | null;
34
36
  name: string | null;
35
37
  position: InsertableCompositionElementPosition | null;
36
38
  } | null | undefined;