@vladimish/motion-canvas-2-vite-plugin 3.17.2

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 (52) hide show
  1. package/lib/index.d.ts +3 -0
  2. package/lib/index.js +23 -0
  3. package/lib/index.js.map +1 -0
  4. package/lib/main.d.ts +82 -0
  5. package/lib/main.js +43 -0
  6. package/lib/main.js.map +1 -0
  7. package/lib/openInExplorer.d.ts +1 -0
  8. package/lib/openInExplorer.js +45 -0
  9. package/lib/openInExplorer.js.map +1 -0
  10. package/lib/partials/assets.d.ts +6 -0
  11. package/lib/partials/assets.js +51 -0
  12. package/lib/partials/assets.js.map +1 -0
  13. package/lib/partials/audio.d.ts +9 -0
  14. package/lib/partials/audio.js +104 -0
  15. package/lib/partials/audio.js.map +1 -0
  16. package/lib/partials/corsProxy.d.ts +43 -0
  17. package/lib/partials/corsProxy.js +219 -0
  18. package/lib/partials/corsProxy.js.map +1 -0
  19. package/lib/partials/editor.d.ts +8 -0
  20. package/lib/partials/editor.js +76 -0
  21. package/lib/partials/editor.js.map +1 -0
  22. package/lib/partials/exporter.d.ts +6 -0
  23. package/lib/partials/exporter.js +49 -0
  24. package/lib/partials/exporter.js.map +1 -0
  25. package/lib/partials/index.d.ts +10 -0
  26. package/lib/partials/index.js +27 -0
  27. package/lib/partials/index.js.map +1 -0
  28. package/lib/partials/meta.d.ts +2 -0
  29. package/lib/partials/meta.js +67 -0
  30. package/lib/partials/meta.js.map +1 -0
  31. package/lib/partials/projects.d.ts +9 -0
  32. package/lib/partials/projects.js +89 -0
  33. package/lib/partials/projects.js.map +1 -0
  34. package/lib/partials/scenes.d.ts +2 -0
  35. package/lib/partials/scenes.js +47 -0
  36. package/lib/partials/scenes.js.map +1 -0
  37. package/lib/partials/settings.d.ts +2 -0
  38. package/lib/partials/settings.js +66 -0
  39. package/lib/partials/settings.js.map +1 -0
  40. package/lib/partials/webgl.d.ts +10 -0
  41. package/lib/partials/webgl.js +89 -0
  42. package/lib/partials/webgl.js.map +1 -0
  43. package/lib/plugins.d.ts +104 -0
  44. package/lib/plugins.js +9 -0
  45. package/lib/plugins.js.map +1 -0
  46. package/lib/utils.d.ts +3 -0
  47. package/lib/utils.js +55 -0
  48. package/lib/utils.js.map +1 -0
  49. package/lib/versions.d.ts +6 -0
  50. package/lib/versions.js +29 -0
  51. package/lib/versions.js.map +1 -0
  52. package/package.json +35 -0
@@ -0,0 +1,104 @@
1
+ import { Plugin as VitePlugin } from 'vite';
2
+ /**
3
+ * Represents a Motion Canvas project configured in the Vite plugin.
4
+ */
5
+ export interface ProjectData {
6
+ /**
7
+ * The name of the project.
8
+ */
9
+ name: string;
10
+ /**
11
+ * The file name containing the project.
12
+ */
13
+ fileName: string;
14
+ /**
15
+ * The path to the project file relative to the Vite configuration file.
16
+ */
17
+ filePath: string;
18
+ /**
19
+ * The path to access the project relative to the Host Name.
20
+ */
21
+ url: string;
22
+ }
23
+ /**
24
+ * The Motion Canvas configuration passed to each plugin.
25
+ */
26
+ export interface PluginConfig {
27
+ /**
28
+ * The projects configured in the Vite plugin.
29
+ */
30
+ projects: ProjectData[];
31
+ /**
32
+ * The output path relative to the Vite configuration file.
33
+ */
34
+ output: string;
35
+ }
36
+ export declare const PLUGIN_OPTIONS: unique symbol;
37
+ export interface PluginOptions {
38
+ /**
39
+ * An entry point of the runtime plugin.
40
+ *
41
+ * @remarks
42
+ * While the Vite plugin can extend the backend functionality, this entry
43
+ * point lets you include custom runtime code that will be loaded by the
44
+ * browser.
45
+ *
46
+ * It should be a valid module specifier from which the plugin will be
47
+ * imported. The module should contain a default export of a runtime plugin.
48
+ */
49
+ entryPoint: string;
50
+ /**
51
+ * The configuration hook of the plugin.
52
+ *
53
+ * @remarks
54
+ * Invoked during `configResolved` hook of Vite, contains the Motion Canvas
55
+ * specific configuration. Returned value will be merged with the current
56
+ * configuration.
57
+ *
58
+ * @param config - The configuration passed to the plugin.
59
+ */
60
+ config?(config: PluginConfig): Promise<Partial<PluginConfig> | void>;
61
+ /**
62
+ * Get custom configuration that will be passed to the runtime plugin.
63
+ *
64
+ * @remarks
65
+ * The config will be passed as the first argument to the default export of
66
+ * the runtime plugin. When provided as a string, it will be injected to the
67
+ * code as is, letting you define non-serializable values such as functions.
68
+ *
69
+ * If the returned value is an object, it will be converted to a JavaScript
70
+ * object using JSON serialization.
71
+ *
72
+ * @example
73
+ * Returning an object:
74
+ * ```ts
75
+ * {
76
+ * runtimeConfig: () => ({
77
+ * myText: 'Hello!',
78
+ * myNumber: 42,
79
+ * })
80
+ * }
81
+ * ```
82
+ * Returning a string:
83
+ * ```ts
84
+ * {
85
+ * runtimeConfig: () => `{myRegex: /\\.wav$/}`
86
+ * }
87
+ * ```
88
+ */
89
+ runtimeConfig?(): Promise<any>;
90
+ }
91
+ /**
92
+ * Represents a Motion Canvas plugin.
93
+ *
94
+ * @remarks
95
+ * It's a normal Vite plugin that can provide additional configuration specific
96
+ * to Motion Canvas.
97
+ */
98
+ export type Plugin = VitePlugin & {
99
+ /**
100
+ * The configuration specific to Motion Canvas.
101
+ */
102
+ [PLUGIN_OPTIONS]: PluginOptions;
103
+ };
104
+ export declare function isPlugin(value: any): value is Plugin;
package/lib/plugins.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPlugin = exports.PLUGIN_OPTIONS = void 0;
4
+ exports.PLUGIN_OPTIONS = Symbol.for('@vladimish/motion-canvas-2-vite-plugin/PLUGIN_OPTIONS');
5
+ function isPlugin(value) {
6
+ return value && typeof value === 'object' && exports.PLUGIN_OPTIONS in value;
7
+ }
8
+ exports.isPlugin = isPlugin;
9
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":";;;AAsCa,QAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CACtC,uDAAuD,CACxD,CAAC;AAyEF,SAAgB,QAAQ,CAAC,KAAU;IACjC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,sBAAc,IAAI,KAAK,CAAC;AACvE,CAAC;AAFD,4BAEC"}
package/lib/utils.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { ProjectData } from './plugins';
2
+ export declare function createMeta(metaPath: string): Promise<void>;
3
+ export declare function getProjects(project: string | string[]): ProjectData[];
package/lib/utils.js ADDED
@@ -0,0 +1,55 @@
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 });
6
+ exports.getProjects = exports.createMeta = void 0;
7
+ const fast_glob_1 = __importDefault(require("fast-glob"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ async function createMeta(metaPath) {
11
+ if (!fs_1.default.existsSync(metaPath)) {
12
+ await fs_1.default.promises.writeFile(metaPath, JSON.stringify({ version: 0 }, undefined, 2), 'utf8');
13
+ }
14
+ }
15
+ exports.createMeta = createMeta;
16
+ function getProjects(project) {
17
+ const list = [];
18
+ const projectList = expandFilePaths(project);
19
+ for (const filePath of projectList) {
20
+ const { name, dir } = path_1.default.posix.parse(filePath);
21
+ const metaFile = `${name}.meta`;
22
+ const metaData = getMeta(path_1.default.join(dir, metaFile));
23
+ const url = path_1.default.posix.join(dir, name);
24
+ const data = {
25
+ name: metaData?.name ?? url,
26
+ fileName: name,
27
+ url,
28
+ filePath,
29
+ };
30
+ list.push(data);
31
+ }
32
+ return list;
33
+ }
34
+ exports.getProjects = getProjects;
35
+ function expandFilePaths(filePaths) {
36
+ const expandedFilePaths = [];
37
+ for (const filePath of typeof filePaths === 'string'
38
+ ? [filePaths]
39
+ : filePaths) {
40
+ if (fast_glob_1.default.isDynamicPattern(filePath)) {
41
+ const matchingFilePaths = fast_glob_1.default.sync(filePath, { onlyFiles: true });
42
+ expandedFilePaths.push(...matchingFilePaths);
43
+ }
44
+ else {
45
+ expandedFilePaths.push(filePath);
46
+ }
47
+ }
48
+ return expandedFilePaths;
49
+ }
50
+ function getMeta(metaPath) {
51
+ if (fs_1.default.existsSync(metaPath)) {
52
+ return JSON.parse(fs_1.default.readFileSync(metaPath, 'utf8'));
53
+ }
54
+ }
55
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA2B;AAC3B,4CAAoB;AACpB,gDAAwB;AAGjB,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,QAAQ,EACR,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAC1C,MAAM,CACP,CAAC;IACJ,CAAC;AACH,CAAC;AARD,gCAQC;AAED,SAAgB,WAAW,CAAC,OAA0B;IACpD,MAAM,IAAI,GAAkB,EAAE,CAAC;IAC/B,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC7C,KAAK,MAAM,QAAQ,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,EAAC,IAAI,EAAE,GAAG,EAAC,GAAG,cAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,GAAG,IAAI,OAAO,CAAC;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,GAAG;YAC3B,QAAQ,EAAE,IAAI;YACd,GAAG;YACH,QAAQ;SACT,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,kCAkBC;AAED,SAAS,eAAe,CAAC,SAA4B;IACnD,MAAM,iBAAiB,GAAG,EAAE,CAAC;IAE7B,KAAK,MAAM,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ;QAClD,CAAC,CAAC,CAAC,SAAS,CAAC;QACb,CAAC,CAAC,SAAS,EAAE,CAAC;QACd,IAAI,mBAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,MAAM,iBAAiB,GAAG,mBAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;YAC/D,iBAAiB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,OAAO,CAAC,QAAgB;IAC/B,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function getVersions(): {
2
+ core: string | null;
3
+ two: string | null;
4
+ ui: string | null;
5
+ vitePlugin: string | null;
6
+ };
@@ -0,0 +1,29 @@
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 });
6
+ exports.getVersions = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ function getVersions() {
10
+ return {
11
+ core: loadVersion('@vladimish/motion-canvas-2-core'),
12
+ two: loadVersion('@vladimish/motion-canvas-2-2d'),
13
+ ui: loadVersion('@vladimish/motion-canvas-2-ui'),
14
+ vitePlugin: loadVersion('..'),
15
+ };
16
+ }
17
+ exports.getVersions = getVersions;
18
+ function loadVersion(module) {
19
+ try {
20
+ const modulePath = path_1.default.dirname(require.resolve(`${module}/package.json`));
21
+ const packageJsonPath = path_1.default.resolve(modulePath, 'package.json');
22
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath).toString());
23
+ return packageJson.version ?? null;
24
+ }
25
+ catch (_) {
26
+ return null;
27
+ }
28
+ }
29
+ //# sourceMappingURL=versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,SAAgB,WAAW;IACzB,OAAO;QACL,IAAI,EAAE,WAAW,CAAC,iCAAiC,CAAC;QACpD,GAAG,EAAE,WAAW,CAAC,+BAA+B,CAAC;QACjD,EAAE,EAAE,WAAW,CAAC,+BAA+B,CAAC;QAChD,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC;KAC9B,CAAC;AACJ,CAAC;AAPD,kCAOC;AAED,SAAS,WAAW,CAAC,MAAc;IACjC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,eAAe,CAAC,CAAC,CAAC;QAC3E,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACjE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC5E,OAAO,WAAW,CAAC,OAAO,IAAI,IAAI,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@vladimish/motion-canvas-2-vite-plugin",
3
+ "version": "3.17.2",
4
+ "description": "A Vite plugin for Motion Canvas projects",
5
+ "main": "lib/index.js",
6
+ "author": "motion-canvas",
7
+ "homepage": "https://motioncanvas.io/",
8
+ "bugs": "https://github.com/motion-canvas/motion-canvas/issues",
9
+ "license": "MIT",
10
+ "scripts": {
11
+ "dev": "tsc -w",
12
+ "build": "tsc"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/motion-canvas/motion-canvas.git"
17
+ },
18
+ "files": [
19
+ "lib"
20
+ ],
21
+ "peerDependencies": {
22
+ "vite": "4.x || 5.x"
23
+ },
24
+ "devDependencies": {
25
+ "@types/follow-redirects": "^1.14.1",
26
+ "@types/mime-types": "^2.1.1",
27
+ "@types/node": "^18.14.0"
28
+ },
29
+ "dependencies": {
30
+ "fast-glob": "^3.3.1",
31
+ "follow-redirects": "^1.15.2",
32
+ "mime-types": "^2.1.35",
33
+ "source-map": "^0.6.1"
34
+ }
35
+ }