@revideo/vite-plugin 0.4.7-test.1023 → 0.4.7

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.
@@ -1,2 +1,2 @@
1
- import {Plugin} from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  export declare function metaPlugin(): Plugin;
@@ -1,31 +1,28 @@
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.metaPlugin = void 0;
9
- const fs_1 = __importDefault(require('fs'));
10
- const path_1 = __importDefault(require('path'));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
11
9
  function metaPlugin() {
12
- const timeStamps = {};
13
- let config;
14
- return {
15
- name: 'revideo:meta',
16
- configResolved(resolvedConfig) {
17
- config = resolvedConfig;
18
- },
19
- async transform(code, id) {
20
- const [base] = id.split('?');
21
- const {name, ext} = path_1.default.posix.parse(base);
22
- if (ext !== '.meta') {
23
- return;
24
- }
25
- const sourceFile =
26
- config.command === 'build' ? false : JSON.stringify(id);
27
- /* language=typescript */
28
- return `\
10
+ const timeStamps = {};
11
+ let config;
12
+ return {
13
+ name: 'revideo:meta',
14
+ configResolved(resolvedConfig) {
15
+ config = resolvedConfig;
16
+ },
17
+ async transform(code, id) {
18
+ const [base] = id.split('?');
19
+ const { name, ext } = path_1.default.posix.parse(base);
20
+ if (ext !== '.meta') {
21
+ return;
22
+ }
23
+ const sourceFile = config.command === 'build' ? false : JSON.stringify(id);
24
+ /* language=typescript */
25
+ return `\
29
26
  import {MetaFile} from '@revideo/core';
30
27
  let meta;
31
28
  if (import.meta.hot) {
@@ -39,40 +36,34 @@ if (import.meta.hot) {
39
36
  meta.loadData(${code});
40
37
  export default meta;
41
38
  `;
42
- },
43
- configureServer(server) {
44
- server.ws.on('revideo:meta', async ({source, data}, client) => {
45
- // Ignore virtual meta files.
46
- if (source.startsWith('\0')) {
47
- return;
48
- }
49
- timeStamps[source] = Date.now();
50
- if (!process.env.DONT_WRITE_TO_META_FILES) {
51
- await fs_1.default.promises.writeFile(
52
- source,
53
- JSON.stringify(data, undefined, 2),
54
- 'utf8',
55
- );
56
- }
57
- client.send('revideo:meta-ack', {source});
58
- });
59
- },
60
- handleHotUpdate(ctx) {
61
- const now = Date.now();
62
- const modules = [];
63
- for (const module of ctx.modules) {
64
- if (
65
- module.file !== null &&
66
- timeStamps[module.file] &&
67
- timeStamps[module.file] + 1000 > now
68
- ) {
69
- continue;
70
- }
71
- modules.push(module);
72
- }
73
- return modules;
74
- },
75
- };
39
+ },
40
+ configureServer(server) {
41
+ server.ws.on('revideo:meta', async ({ source, data }, client) => {
42
+ // Ignore virtual meta files.
43
+ if (source.startsWith('\0')) {
44
+ return;
45
+ }
46
+ timeStamps[source] = Date.now();
47
+ if (!process.env.DONT_WRITE_TO_META_FILES) {
48
+ await fs_1.default.promises.writeFile(source, JSON.stringify(data, undefined, 2), 'utf8');
49
+ }
50
+ client.send('revideo:meta-ack', { source });
51
+ });
52
+ },
53
+ handleHotUpdate(ctx) {
54
+ const now = Date.now();
55
+ const modules = [];
56
+ for (const module of ctx.modules) {
57
+ if (module.file !== null &&
58
+ timeStamps[module.file] &&
59
+ timeStamps[module.file] + 1000 > now) {
60
+ continue;
61
+ }
62
+ modules.push(module);
63
+ }
64
+ return modules;
65
+ },
66
+ };
76
67
  }
77
68
  exports.metaPlugin = metaPlugin;
78
- //# sourceMappingURL=meta.js.map
69
+ //# sourceMappingURL=meta.js.map
@@ -1,2 +1,2 @@
1
- import {Plugin} from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  export declare function metricsPlugin(): Plugin;
@@ -1,14 +1,14 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', {value: true});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.metricsPlugin = void 0;
4
- const telemetry_1 = require('@revideo/telemetry');
4
+ const telemetry_1 = require("@revideo/telemetry");
5
5
  function metricsPlugin() {
6
- return {
7
- name: 'revideo:metrics',
8
- async configResolved() {
9
- (0, telemetry_1.sendEvent)(telemetry_1.EventName.ServerStarted);
10
- },
11
- };
6
+ return {
7
+ name: 'revideo:metrics',
8
+ async configResolved() {
9
+ (0, telemetry_1.sendEvent)(telemetry_1.EventName.ServerStarted);
10
+ },
11
+ };
12
12
  }
13
13
  exports.metricsPlugin = metricsPlugin;
14
- //# sourceMappingURL=metrics.js.map
14
+ //# sourceMappingURL=metrics.js.map
@@ -1,14 +1,10 @@
1
- import {Plugin} from 'vite';
2
- import {PluginOptions} from '../plugins';
3
- import {Projects} from '../utils';
1
+ import { Plugin } from 'vite';
2
+ import { PluginOptions } from '../plugins';
3
+ import { Projects } from '../utils';
4
4
  interface ProjectPluginConfig {
5
- buildForEditor?: boolean;
6
- plugins: PluginOptions[];
7
- projects: Projects;
5
+ buildForEditor?: boolean;
6
+ plugins: PluginOptions[];
7
+ projects: Projects;
8
8
  }
9
- export declare function projectsPlugin({
10
- buildForEditor,
11
- plugins,
12
- projects,
13
- }: ProjectPluginConfig): Plugin;
9
+ export declare function projectsPlugin({ buildForEditor, plugins, projects, }: ProjectPluginConfig): Plugin;
14
10
  export {};
@@ -1,49 +1,47 @@
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.projectsPlugin = void 0;
9
- const path_1 = __importDefault(require('path'));
10
- const utils_1 = require('../utils');
11
- const versions_1 = require('../versions');
7
+ const path_1 = __importDefault(require("path"));
8
+ const utils_1 = require("../utils");
9
+ const versions_1 = require("../versions");
12
10
  const PROJECT_QUERY_REGEX = /[?&]project\b/;
13
- function projectsPlugin({buildForEditor, plugins, projects}) {
14
- const versions = JSON.stringify((0, versions_1.getVersions)());
15
- let config;
16
- return {
17
- name: 'revideo:project',
18
- configResolved(resolvedConfig) {
19
- config = resolvedConfig;
20
- },
21
- async load(id) {
22
- if (!PROJECT_QUERY_REGEX.test(id)) {
23
- return;
24
- }
25
- const [base] = id.split('?');
26
- const {name, dir} = path_1.default.posix.parse(base);
27
- const runsInEditor = buildForEditor || config.command === 'serve';
28
- const metaFile = `${name}.meta`;
29
- await (0, utils_1.createMeta)(path_1.default.join(dir, metaFile));
30
- const imports = [];
31
- const pluginNames = [];
32
- let index = 0;
33
- for (const plugin of plugins) {
34
- if (plugin.entryPoint) {
35
- const pluginName = `plugin${index}`;
36
- let options = (await plugin.runtimeConfig?.()) ?? '';
37
- if (typeof options !== 'string') {
38
- options = JSON.stringify(options);
39
- }
40
- imports.push(`import ${pluginName} from '${plugin.entryPoint}'`);
41
- pluginNames.push(`${pluginName}(${options})`);
42
- index++;
43
- }
44
- }
45
- /* language=typescript */
46
- return `\
11
+ function projectsPlugin({ buildForEditor, plugins, projects, }) {
12
+ const versions = JSON.stringify((0, versions_1.getVersions)());
13
+ let config;
14
+ return {
15
+ name: 'revideo:project',
16
+ configResolved(resolvedConfig) {
17
+ config = resolvedConfig;
18
+ },
19
+ async load(id) {
20
+ if (!PROJECT_QUERY_REGEX.test(id)) {
21
+ return;
22
+ }
23
+ const [base] = id.split('?');
24
+ const { name, dir } = path_1.default.posix.parse(base);
25
+ const runsInEditor = buildForEditor || config.command === 'serve';
26
+ const metaFile = `${name}.meta`;
27
+ await (0, utils_1.createMeta)(path_1.default.join(dir, metaFile));
28
+ const imports = [];
29
+ const pluginNames = [];
30
+ let index = 0;
31
+ for (const plugin of plugins) {
32
+ if (plugin.entryPoint) {
33
+ const pluginName = `plugin${index}`;
34
+ let options = (await plugin.runtimeConfig?.()) ?? '';
35
+ if (typeof options !== 'string') {
36
+ options = JSON.stringify(options);
37
+ }
38
+ imports.push(`import ${pluginName} from '${plugin.entryPoint}'`);
39
+ pluginNames.push(`${pluginName}(${options})`);
40
+ index++;
41
+ }
42
+ }
43
+ /* language=typescript */
44
+ return `\
47
45
  ${imports.join('\n')}
48
46
  import {${runsInEditor ? 'editorBootstrap' : 'bootstrap'}} from '@revideo/core';
49
47
  import {MetaFile} from '@revideo/core';
@@ -58,36 +56,34 @@ import {MetaFile} from '@revideo/core';
58
56
  metaFile,
59
57
  settings,
60
58
  );`;
61
- },
62
- config(config) {
63
- return {
64
- build: {
65
- target: buildForEditor ? 'esnext' : 'modules',
66
- assetsDir: './',
67
- rollupOptions: {
68
- preserveEntrySignatures: 'strict',
69
- input: Object.fromEntries(
70
- projects.list.map(project => [
71
- project.name,
72
- project.url + '?project',
73
- ]),
74
- ),
75
- },
76
- },
77
- server: {
78
- port: config?.server?.port ?? 9000,
79
- },
80
- esbuild: {
81
- jsx: 'automatic',
82
- jsxImportSource: '@revideo/2d/lib',
83
59
  },
84
- optimizeDeps: {
85
- entries: projects.list.map(project => project.url),
86
- exclude: ['preact', 'preact/*', '@preact/signals'],
60
+ config(config) {
61
+ return {
62
+ build: {
63
+ target: buildForEditor ? 'esnext' : 'modules',
64
+ assetsDir: './',
65
+ rollupOptions: {
66
+ preserveEntrySignatures: 'strict',
67
+ input: Object.fromEntries(projects.list.map(project => [
68
+ project.name,
69
+ project.url + '?project',
70
+ ])),
71
+ },
72
+ },
73
+ server: {
74
+ port: config?.server?.port ?? 9000,
75
+ },
76
+ esbuild: {
77
+ jsx: 'automatic',
78
+ jsxImportSource: '@revideo/2d/lib',
79
+ },
80
+ optimizeDeps: {
81
+ entries: projects.list.map(project => project.url),
82
+ exclude: ['preact', 'preact/*', '@preact/signals'],
83
+ },
84
+ };
87
85
  },
88
- };
89
- },
90
- };
86
+ };
91
87
  }
92
88
  exports.projectsPlugin = projectsPlugin;
93
- //# sourceMappingURL=projects.js.map
89
+ //# sourceMappingURL=projects.js.map
@@ -1,2 +1,2 @@
1
- import {Plugin} from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  export declare function scenesPlugin(): Plugin;
@@ -1,28 +1,26 @@
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.scenesPlugin = void 0;
9
- const path_1 = __importDefault(require('path'));
10
- const utils_1 = require('../utils');
7
+ const path_1 = __importDefault(require("path"));
8
+ const utils_1 = require("../utils");
11
9
  const SCENE_QUERY_REGEX = /[?&]scene\b/;
12
10
  function scenesPlugin() {
13
- return {
14
- name: 'revideo:scene',
15
- async load(id) {
16
- if (!SCENE_QUERY_REGEX.test(id)) {
17
- return;
18
- }
19
- const [base] = id.split('?');
20
- const {name, dir} = path_1.default.posix.parse(base);
21
- const metaFile = `${name}.meta`;
22
- await (0, utils_1.createMeta)(path_1.default.join(dir, metaFile));
23
- const sceneFile = `${name}`;
24
- /* language=typescript */
25
- return `\
11
+ return {
12
+ name: 'revideo:scene',
13
+ async load(id) {
14
+ if (!SCENE_QUERY_REGEX.test(id)) {
15
+ return;
16
+ }
17
+ const [base] = id.split('?');
18
+ const { name, dir } = path_1.default.posix.parse(base);
19
+ const metaFile = `${name}.meta`;
20
+ await (0, utils_1.createMeta)(path_1.default.join(dir, metaFile));
21
+ const sceneFile = `${name}`;
22
+ /* language=typescript */
23
+ return `\
26
24
  import {ValueDispatcher} from '@revideo/core';
27
25
  import metaFile from './${metaFile}';
28
26
  import description from './${sceneFile}';
@@ -42,8 +40,8 @@ if (import.meta.hot) {
42
40
  }
43
41
  export default description;
44
42
  `;
45
- },
46
- };
43
+ },
44
+ };
47
45
  }
48
46
  exports.scenesPlugin = scenesPlugin;
49
- //# sourceMappingURL=scenes.js.map
47
+ //# sourceMappingURL=scenes.js.map
@@ -1,2 +1,2 @@
1
- import {Plugin} from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  export declare function settingsPlugin(): Plugin;
@@ -1,71 +1,66 @@
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.settingsPlugin = void 0;
9
- const fs_1 = __importDefault(require('fs'));
10
- const os_1 = __importDefault(require('os'));
11
- const path_1 = __importDefault(require('path'));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const os_1 = __importDefault(require("os"));
9
+ const path_1 = __importDefault(require("path"));
12
10
  function settingsPlugin() {
13
- const settingsId = 'virtual:settings.meta';
14
- const resolvedSettingsId = '\0' + settingsId;
15
- const settingsPath = path_1.default.resolve(
16
- os_1.default.homedir(),
17
- '.revideo/settings.json',
18
- );
19
- const outputDirectory = path_1.default.dirname(settingsPath);
20
- return {
21
- name: 'revideo:settings',
22
- resolveId(id) {
23
- if (id === settingsId) {
24
- return resolvedSettingsId;
25
- }
26
- },
27
- async load(id) {
28
- if (id === resolvedSettingsId) {
29
- let parsed = {};
30
- try {
31
- parsed = JSON.parse(
32
- await fs_1.default.promises.readFile(settingsPath, 'utf8'),
33
- );
34
- } catch (_) {
35
- // Ignore an invalid settings file
36
- }
37
- return JSON.stringify(parsed);
38
- }
39
- },
40
- configureServer(server) {
41
- server.ws.on('revideo:meta', async ({source, data}, client) => {
42
- if (source !== resolvedSettingsId) {
43
- return;
44
- }
45
- await fs_1.default.promises.mkdir(outputDirectory, {recursive: true});
46
- const newData = JSON.stringify(data, undefined, 2);
47
- let oldData = '';
48
- try {
49
- oldData = await fs_1.default.promises.readFile(settingsPath, 'utf8');
50
- } catch (_) {
51
- // Ignore an invalid settings file
52
- }
53
- if (oldData !== newData) {
54
- await Promise.all([
55
- fs_1.default.promises.writeFile(settingsPath, newData, 'utf8'),
56
- // Invalidate the module so that the settings are up-to-date next
57
- // time the browser is refreshed.
58
- server.moduleGraph.getModuleByUrl(source).then(module => {
59
- if (module) {
60
- server.moduleGraph.invalidateModule(module);
61
- }
62
- }),
63
- ]);
64
- }
65
- client.send('revideo:meta-ack', {source});
66
- });
67
- },
68
- };
11
+ const settingsId = 'virtual:settings.meta';
12
+ const resolvedSettingsId = '\0' + settingsId;
13
+ const settingsPath = path_1.default.resolve(os_1.default.homedir(), '.revideo/settings.json');
14
+ const outputDirectory = path_1.default.dirname(settingsPath);
15
+ return {
16
+ name: 'revideo:settings',
17
+ resolveId(id) {
18
+ if (id === settingsId) {
19
+ return resolvedSettingsId;
20
+ }
21
+ },
22
+ async load(id) {
23
+ if (id === resolvedSettingsId) {
24
+ let parsed = {};
25
+ try {
26
+ parsed = JSON.parse(await fs_1.default.promises.readFile(settingsPath, 'utf8'));
27
+ }
28
+ catch (_) {
29
+ // Ignore an invalid settings file
30
+ }
31
+ return JSON.stringify(parsed);
32
+ }
33
+ },
34
+ configureServer(server) {
35
+ server.ws.on('revideo:meta', async ({ source, data }, client) => {
36
+ if (source !== resolvedSettingsId) {
37
+ return;
38
+ }
39
+ await fs_1.default.promises.mkdir(outputDirectory, { recursive: true });
40
+ const newData = JSON.stringify(data, undefined, 2);
41
+ let oldData = '';
42
+ try {
43
+ oldData = await fs_1.default.promises.readFile(settingsPath, 'utf8');
44
+ }
45
+ catch (_) {
46
+ // Ignore an invalid settings file
47
+ }
48
+ if (oldData !== newData) {
49
+ await Promise.all([
50
+ fs_1.default.promises.writeFile(settingsPath, newData, 'utf8'),
51
+ // Invalidate the module so that the settings are up-to-date next
52
+ // time the browser is refreshed.
53
+ server.moduleGraph.getModuleByUrl(source).then(module => {
54
+ if (module) {
55
+ server.moduleGraph.invalidateModule(module);
56
+ }
57
+ }),
58
+ ]);
59
+ }
60
+ client.send('revideo:meta-ack', { source });
61
+ });
62
+ },
63
+ };
69
64
  }
70
65
  exports.settingsPlugin = settingsPlugin;
71
- //# sourceMappingURL=settings.js.map
66
+ //# sourceMappingURL=settings.js.map
@@ -1,10 +1,10 @@
1
- import {Plugin} from 'vite';
1
+ import { Plugin } from 'vite';
2
2
  declare module 'source-map' {
3
- interface SourceNode {
4
- add(value: string | SourceNode): void;
5
- }
6
- interface SourceMapGenerator {
7
- toJSON(): any;
8
- }
3
+ interface SourceNode {
4
+ add(value: string | SourceNode): void;
5
+ }
6
+ interface SourceMapGenerator {
7
+ toJSON(): any;
8
+ }
9
9
  }
10
10
  export declare function webglPlugin(): Plugin;