@revideo/vite-plugin 0.2.4-alpha.894 → 0.2.4-alpha.895

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/lib/index.js CHANGED
@@ -1,41 +1,23 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (
9
- !desc ||
10
- ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)
11
- ) {
12
- desc = {
13
- enumerable: true,
14
- get: function () {
15
- return m[k];
16
- },
17
- };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }
21
- : function (o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- });
25
- var __exportStar =
26
- (this && this.__exportStar) ||
27
- function (m, exports) {
28
- for (var p in m)
29
- if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
30
- __createBinding(exports, m, p);
31
- };
32
- var __importDefault =
33
- (this && this.__importDefault) ||
34
- function (mod) {
35
- return mod && mod.__esModule ? mod : {default: mod};
36
- };
37
- Object.defineProperty(exports, '__esModule', {value: true});
38
- const main_1 = __importDefault(require('./main'));
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const main_1 = __importDefault(require("./main"));
39
21
  exports.default = main_1.default;
40
- __exportStar(require('./plugins'), exports);
41
- //# sourceMappingURL=index.js.map
22
+ __exportStar(require("./plugins"), exports);
23
+ //# sourceMappingURL=index.js.map
package/lib/main.d.ts CHANGED
@@ -1,89 +1,82 @@
1
- import type {Plugin} from 'vite';
2
- import {CorsProxyPluginConfig} from './partials';
1
+ import type { Plugin } from 'vite';
2
+ import { CorsProxyPluginConfig } from './partials';
3
3
  export interface MotionCanvasPluginConfig {
4
- /**
5
- * The import path of the project file or an array of paths.
6
- * Also supports globs.
7
- *
8
- * @remarks
9
- * Each file must contain a default export exposing an instance of the
10
- * {@link Project} class.
11
- *
12
- * @example
13
- * ```ts
14
- * motionCanvas({
15
- * project: [
16
- * './src/firstProject.ts',
17
- * './src/secondProject.ts',
18
- * ]
19
- * })
20
- * ```
21
- *
22
- * @defaultValue './src/project.ts'
23
- */
24
- project?: string | string[];
25
- /**
26
- * A directory path to which the animation will be rendered.
27
- *
28
- * @defaultValue './output'
29
- */
30
- output?: string;
31
- /**
32
- * Defines which assets should be buffered before being sent to the browser.
33
- *
34
- * @remarks
35
- * Streaming larger assets directly from the drive may cause issues with other
36
- * applications. For instance, if an audio file is being used in the project,
37
- * Adobe Audition will perceive it as "being used by another application"
38
- * and refuse to override it.
39
- *
40
- * Buffered assets are first loaded to the memory and then streamed from
41
- * there. This leaves the original files open for modification with hot module
42
- * replacement still working.
43
- *
44
- * @defaultValue /^$/
45
- */
46
- bufferedAssets?: RegExp | false;
47
- /**
48
- * The import path of the editor package.
49
- *
50
- * @remarks
51
- * This path will be resolved using Node.js module resolution rules.
52
- * It should lead to a directory containing the following files:
53
- * - `editor.html` - The HTML template for the editor.
54
- * - `styles.css` - The editor styles.
55
- * - `main.js` - A module exporting necessary factory functions.
56
- *
57
- * `main.js` should export the following functions:
58
- * - `editor` - Receives the project factory as its first argument and creates
59
- * the user interface.
60
- * - `index` - Receives a list of all projects as its first argument and
61
- * creates the initial page for selecting a project.
62
- *
63
- * @defaultValue '\@revideo/ui'
64
- */
65
- editor?: string;
66
- /**
67
- * Configuration of the Proxy used for remote sources
68
- *
69
- * @remarks
70
- * This passes configuration to Motion Canvas' proxy.
71
- * Note that the proxy is disabled by default.
72
- * You can either pass `true` and a config object
73
- * to enable it.
74
- **/
75
- proxy?: boolean | CorsProxyPluginConfig;
76
- /**
77
- * Build the project to run in the editor.
78
- */
79
- buildForEditor?: boolean;
4
+ /**
5
+ * The import path of the project file or an array of paths.
6
+ * Also supports globs.
7
+ *
8
+ * @remarks
9
+ * Each file must contain a default export exposing an instance of the
10
+ * {@link Project} class.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * motionCanvas({
15
+ * project: [
16
+ * './src/firstProject.ts',
17
+ * './src/secondProject.ts',
18
+ * ]
19
+ * })
20
+ * ```
21
+ *
22
+ * @defaultValue './src/project.ts'
23
+ */
24
+ project?: string | string[];
25
+ /**
26
+ * A directory path to which the animation will be rendered.
27
+ *
28
+ * @defaultValue './output'
29
+ */
30
+ output?: string;
31
+ /**
32
+ * Defines which assets should be buffered before being sent to the browser.
33
+ *
34
+ * @remarks
35
+ * Streaming larger assets directly from the drive may cause issues with other
36
+ * applications. For instance, if an audio file is being used in the project,
37
+ * Adobe Audition will perceive it as "being used by another application"
38
+ * and refuse to override it.
39
+ *
40
+ * Buffered assets are first loaded to the memory and then streamed from
41
+ * there. This leaves the original files open for modification with hot module
42
+ * replacement still working.
43
+ *
44
+ * @defaultValue /^$/
45
+ */
46
+ bufferedAssets?: RegExp | false;
47
+ /**
48
+ * The import path of the editor package.
49
+ *
50
+ * @remarks
51
+ * This path will be resolved using Node.js module resolution rules.
52
+ * It should lead to a directory containing the following files:
53
+ * - `editor.html` - The HTML template for the editor.
54
+ * - `styles.css` - The editor styles.
55
+ * - `main.js` - A module exporting necessary factory functions.
56
+ *
57
+ * `main.js` should export the following functions:
58
+ * - `editor` - Receives the project factory as its first argument and creates
59
+ * the user interface.
60
+ * - `index` - Receives a list of all projects as its first argument and
61
+ * creates the initial page for selecting a project.
62
+ *
63
+ * @defaultValue '\@revideo/ui'
64
+ */
65
+ editor?: string;
66
+ /**
67
+ * Configuration of the Proxy used for remote sources
68
+ *
69
+ * @remarks
70
+ * This passes configuration to Motion Canvas' proxy.
71
+ * Note that the proxy is disabled by default.
72
+ * You can either pass `true` and a config object
73
+ * to enable it.
74
+ **/
75
+ proxy?: boolean | CorsProxyPluginConfig;
76
+ /**
77
+ * Build the project to run in the editor.
78
+ */
79
+ buildForEditor?: boolean;
80
80
  }
81
- declare const _default: ({
82
- project,
83
- output,
84
- bufferedAssets,
85
- editor,
86
- proxy,
87
- buildForEditor,
88
- }?: MotionCanvasPluginConfig) => Plugin[];
81
+ declare const _default: ({ project, output, bufferedAssets, editor, proxy, buildForEditor, }?: MotionCanvasPluginConfig) => Plugin[];
89
82
  export default _default;
package/lib/main.js CHANGED
@@ -1,53 +1,38 @@
1
- 'use strict';
2
- var __importDefault =
3
- (this && this.__importDefault) ||
4
- function (mod) {
5
- return mod && mod.__esModule ? mod : {default: mod};
6
- };
7
- Object.defineProperty(exports, '__esModule', {value: true});
8
- const path_1 = __importDefault(require('path'));
9
- const partials_1 = require('./partials');
10
- const plugins_1 = require('./plugins');
11
- const utils_1 = require('./utils');
12
- exports.default = ({
13
- project = './src/project.ts',
14
- output = './output',
15
- bufferedAssets = /^$/,
16
- editor = '@revideo/ui',
17
- proxy,
18
- buildForEditor,
19
- } = {}) => {
20
- const plugins = [];
21
- const outputPath = path_1.default.resolve(output);
22
- const projects = (0, utils_1.getProjects)(project);
23
- return [
24
- {
25
- name: 'revideo',
26
- async configResolved(resolvedConfig) {
27
- plugins.push(
28
- ...resolvedConfig.plugins
29
- .filter(plugins_1.isPlugin)
30
- .map(plugin => plugin[plugins_1.PLUGIN_OPTIONS]),
31
- );
32
- await Promise.all(
33
- plugins.map(plugin =>
34
- plugin.config?.({
35
- output: outputPath,
36
- projects: projects.list,
37
- }),
38
- ),
39
- );
40
- },
41
- },
42
- (0, partials_1.metaPlugin)(),
43
- (0, partials_1.settingsPlugin)(),
44
- (0, partials_1.scenesPlugin)(),
45
- (0, partials_1.exporterPlugin)({outputPath}),
46
- (0, partials_1.editorPlugin)({editor, projects}),
47
- (0, partials_1.projectsPlugin)({projects, plugins, buildForEditor}),
48
- (0, partials_1.assetsPlugin)({bufferedAssets}),
49
- (0, partials_1.webglPlugin)(),
50
- (0, partials_1.corsProxyPlugin)(proxy),
51
- ];
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
52
4
  };
53
- //# sourceMappingURL=main.js.map
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = __importDefault(require("path"));
7
+ const partials_1 = require("./partials");
8
+ const plugins_1 = require("./plugins");
9
+ const utils_1 = require("./utils");
10
+ exports.default = ({ project = './src/project.ts', output = './output', bufferedAssets = /^$/, editor = '@revideo/ui', proxy, buildForEditor, } = {}) => {
11
+ const plugins = [];
12
+ const outputPath = path_1.default.resolve(output);
13
+ const projects = (0, utils_1.getProjects)(project);
14
+ return [
15
+ {
16
+ name: 'revideo',
17
+ async configResolved(resolvedConfig) {
18
+ plugins.push(...resolvedConfig.plugins
19
+ .filter(plugins_1.isPlugin)
20
+ .map(plugin => plugin[plugins_1.PLUGIN_OPTIONS]));
21
+ await Promise.all(plugins.map(plugin => plugin.config?.({
22
+ output: outputPath,
23
+ projects: projects.list,
24
+ })));
25
+ },
26
+ },
27
+ (0, partials_1.metaPlugin)(),
28
+ (0, partials_1.settingsPlugin)(),
29
+ (0, partials_1.scenesPlugin)(),
30
+ (0, partials_1.exporterPlugin)({ outputPath }),
31
+ (0, partials_1.editorPlugin)({ editor, projects }),
32
+ (0, partials_1.projectsPlugin)({ projects, plugins, buildForEditor }),
33
+ (0, partials_1.assetsPlugin)({ bufferedAssets }),
34
+ (0, partials_1.webglPlugin)(),
35
+ (0, partials_1.corsProxyPlugin)(proxy),
36
+ ];
37
+ };
38
+ //# sourceMappingURL=main.js.map
@@ -1,44 +1,45 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', {value: true});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.openInExplorer = void 0;
4
- const child_process_1 = require('child_process');
5
- const os_1 = require('os');
4
+ const child_process_1 = require("child_process");
5
+ const os_1 = require("os");
6
6
  function openInExplorer(file) {
7
- let command = null;
8
- let args = [file];
9
- const os = (0, os_1.platform)();
10
- switch (os) {
11
- case 'win32':
12
- command = 'explorer';
13
- break;
14
- case 'linux':
15
- if (isRunningOnWSL()) {
16
- command = 'bash';
17
- args = ['-c', `cd ${file} && explorer.exe .`];
18
- } else {
19
- command = 'xdg-open';
20
- }
21
- break;
22
- case 'darwin':
23
- command = 'open';
24
- break;
25
- }
26
- if (command) {
27
- (0, child_process_1.spawn)(command, args, {detached: true}).unref();
28
- } else {
29
- console.warn(`Unsupported OS: ${os}`);
30
- }
7
+ let command = null;
8
+ let args = [file];
9
+ const os = (0, os_1.platform)();
10
+ switch (os) {
11
+ case 'win32':
12
+ command = 'explorer';
13
+ break;
14
+ case 'linux':
15
+ if (isRunningOnWSL()) {
16
+ command = 'bash';
17
+ args = ['-c', `cd ${file} && explorer.exe .`];
18
+ }
19
+ else {
20
+ command = 'xdg-open';
21
+ }
22
+ break;
23
+ case 'darwin':
24
+ command = 'open';
25
+ break;
26
+ }
27
+ if (command) {
28
+ (0, child_process_1.spawn)(command, args, { detached: true }).unref();
29
+ }
30
+ else {
31
+ console.warn(`Unsupported OS: ${os}`);
32
+ }
31
33
  }
32
34
  exports.openInExplorer = openInExplorer;
33
35
  function isRunningOnWSL() {
34
- try {
35
- const uname = (0, child_process_1.execSync)('uname -a')
36
- .toString()
37
- .toLowerCase();
38
- return uname.includes('microsoft');
39
- } catch (error) {
40
- console.error(`exec error: ${error}`);
41
- return false;
42
- }
36
+ try {
37
+ const uname = (0, child_process_1.execSync)('uname -a').toString().toLowerCase();
38
+ return uname.includes('microsoft');
39
+ }
40
+ catch (error) {
41
+ console.error(`exec error: ${error}`);
42
+ return false;
43
+ }
43
44
  }
44
- //# sourceMappingURL=openInExplorer.js.map
45
+ //# sourceMappingURL=openInExplorer.js.map
@@ -1,8 +1,6 @@
1
- import {Plugin} from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  interface AssetsPluginConfig {
3
- bufferedAssets: RegExp | false;
3
+ bufferedAssets: RegExp | false;
4
4
  }
5
- export declare function assetsPlugin({
6
- bufferedAssets,
7
- }: AssetsPluginConfig): Plugin;
5
+ export declare function assetsPlugin({ bufferedAssets }: AssetsPluginConfig): Plugin;
8
6
  export {};
@@ -1,54 +1,51 @@
1
- 'use strict';
2
- var __importDefault =
3
- (this && this.__importDefault) ||
4
- function (mod) {
5
- return mod && mod.__esModule ? mod : {default: mod};
6
- };
7
- Object.defineProperty(exports, '__esModule', {value: true});
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
8
6
  exports.assetsPlugin = void 0;
9
- const fs_1 = __importDefault(require('fs'));
10
- const path_1 = __importDefault(require('path'));
11
- const stream_1 = require('stream');
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const stream_1 = require("stream");
12
10
  const AUDIO_EXTENSION_REGEX = /\.(mp3|wav|ogg|aac|flac)(?:$|\?)/;
13
11
  const AUDIO_HMR_DELAY = 1000;
14
- function assetsPlugin({bufferedAssets}) {
15
- let config;
16
- return {
17
- name: 'revideo:assets',
18
- configResolved(resolvedConfig) {
19
- config = resolvedConfig;
20
- },
21
- configureServer(server) {
22
- server.middlewares.use((req, res, next) => {
23
- if (req.url && bufferedAssets && bufferedAssets.test(req.url)) {
24
- const file = fs_1.default.readFileSync(
25
- path_1.default.resolve(config.root, req.url.slice(1)),
26
- );
27
- stream_1.Readable.from(file).pipe(res);
28
- return;
29
- }
30
- next();
31
- });
32
- },
33
- async handleHotUpdate(ctx) {
34
- const urls = [];
35
- const modules = [];
36
- for (const module of ctx.modules) {
37
- urls.push(module.url);
38
- if (!AUDIO_EXTENSION_REGEX.test(module.url)) {
39
- modules.push(module);
40
- } else {
41
- await new Promise(resolve => {
42
- setTimeout(resolve, AUDIO_HMR_DELAY);
43
- });
44
- }
45
- }
46
- if (urls.length > 0) {
47
- ctx.server.ws.send('revideo:assets', {urls});
48
- }
49
- return modules;
50
- },
51
- };
12
+ function assetsPlugin({ bufferedAssets }) {
13
+ let config;
14
+ return {
15
+ name: 'revideo:assets',
16
+ configResolved(resolvedConfig) {
17
+ config = resolvedConfig;
18
+ },
19
+ configureServer(server) {
20
+ server.middlewares.use((req, res, next) => {
21
+ if (req.url && bufferedAssets && bufferedAssets.test(req.url)) {
22
+ const file = fs_1.default.readFileSync(path_1.default.resolve(config.root, req.url.slice(1)));
23
+ stream_1.Readable.from(file).pipe(res);
24
+ return;
25
+ }
26
+ next();
27
+ });
28
+ },
29
+ async handleHotUpdate(ctx) {
30
+ const urls = [];
31
+ const modules = [];
32
+ for (const module of ctx.modules) {
33
+ urls.push(module.url);
34
+ if (!AUDIO_EXTENSION_REGEX.test(module.url)) {
35
+ modules.push(module);
36
+ }
37
+ else {
38
+ await new Promise(resolve => {
39
+ setTimeout(resolve, AUDIO_HMR_DELAY);
40
+ });
41
+ }
42
+ }
43
+ if (urls.length > 0) {
44
+ ctx.server.ws.send('revideo:assets', { urls });
45
+ }
46
+ return modules;
47
+ },
48
+ };
52
49
  }
53
50
  exports.assetsPlugin = assetsPlugin;
54
- //# sourceMappingURL=assets.js.map
51
+ //# sourceMappingURL=assets.js.map
@@ -1,28 +1,28 @@
1
- import {Plugin} from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  /**
3
3
  * Configuration used by the Proxy plugin
4
4
  */
5
5
  export interface CorsProxyPluginConfig {
6
- /**
7
- * Set which types of resources are allowed by default.
8
- *
9
- * @remarks
10
- * Catchall on the right side is supported.
11
- * Pass an empty Array to allow all types of resources, although this is not
12
- * recommended.
13
- *
14
- * @defaultValue ["image/*", "video/*"]
15
- */
16
- allowedMimeTypes?: string[];
17
- /**
18
- * Set which hosts are allowed
19
- *
20
- * @remarks
21
- * Note that the host is everything to the left of the first `/`, and to the
22
- * right of the protocol `https://`. AllowList is not used by default,
23
- * although you should consider setting up just the relevant hosts.
24
- */
25
- allowListHosts?: string[];
6
+ /**
7
+ * Set which types of resources are allowed by default.
8
+ *
9
+ * @remarks
10
+ * Catchall on the right side is supported.
11
+ * Pass an empty Array to allow all types of resources, although this is not
12
+ * recommended.
13
+ *
14
+ * @defaultValue ["image/*", "video/*"]
15
+ */
16
+ allowedMimeTypes?: string[];
17
+ /**
18
+ * Set which hosts are allowed
19
+ *
20
+ * @remarks
21
+ * Note that the host is everything to the left of the first `/`, and to the
22
+ * right of the protocol `https://`. AllowList is not used by default,
23
+ * although you should consider setting up just the relevant hosts.
24
+ */
25
+ allowListHosts?: string[];
26
26
  }
27
27
  /**
28
28
  * This module provides the proxy located at
@@ -40,6 +40,4 @@ export interface CorsProxyPluginConfig {
40
40
  * this way all remote resources are served from the
41
41
  * same host as the main app.
42
42
  */
43
- export declare function corsProxyPlugin(
44
- config?: CorsProxyPluginConfig | boolean,
45
- ): Plugin;
43
+ export declare function corsProxyPlugin(config?: CorsProxyPluginConfig | boolean): Plugin;