@glissade/vite-plugin 0.2.0 → 0.4.0

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/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @glissade/vite-plugin
2
+
3
+ Dev-server middleware for the studio's persistence: `GET/POST /__glissade/sidecar?scene=…` reads and writes per-scene `*.edits.json` sidecars (editor-owned keyframes merged over the code baseline), and `GET/POST /__glissade/project` serves `glissade.project.json` (shared markers + render presets). Writes are path-confined to the project root.
4
+
5
+ ```sh
6
+ npm i -D @glissade/vite-plugin
7
+ ```
8
+
9
+ ```ts
10
+ // vite.config.ts
11
+ import { glissade } from '@glissade/vite-plugin';
12
+ export default { plugins: [glissade()] };
13
+ ```
14
+
15
+ ## Part of glissade
16
+
17
+ *(glide & slide)* — programmatic motion graphics for TypeScript: realtime-first in any web page, deterministic headless video export from the same code, a visual studio over the same document. No generator functions.
18
+
19
+ - [Repository & full README](https://github.com/tyevco/glissade)
20
+ - [Getting started](https://github.com/tyevco/glissade/blob/main/docs/getting-started.md) · [Concepts](https://github.com/tyevco/glissade/blob/main/docs/concepts.md) · [Interactivity](https://github.com/tyevco/glissade/blob/main/docs/interactivity.md)
21
+
22
+ Apache-2.0.
package/dist/index.d.ts CHANGED
@@ -6,7 +6,22 @@ interface GlissadeSidecarOptions {
6
6
  /** Directory sidecar writes are confined to; defaults to the vite root. */
7
7
  root?: string;
8
8
  }
9
+ /** glissade.project.json (§6.2 decided scope): shared markers + render presets. */
10
+ interface ProjectDoc {
11
+ projectVersion: 1;
12
+ /** Project-wide markers, merged into every scene's ruler. */
13
+ markers?: Array<{
14
+ t: number;
15
+ name: string;
16
+ }>;
17
+ /** Named render settings the export UI offers (consumed by the export surface). */
18
+ renderPresets?: Record<string, {
19
+ fps?: number;
20
+ out?: string;
21
+ range?: [number, number];
22
+ }>;
23
+ }
9
24
  declare function sidecarPathFor(scenePath: string): string;
10
25
  declare function glissade(options?: GlissadeSidecarOptions): Plugin;
11
26
  //#endregion
12
- export { GlissadeSidecarOptions, glissade, sidecarPathFor };
27
+ export { GlissadeSidecarOptions, ProjectDoc, glissade, sidecarPathFor };
package/dist/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
- import { isAbsolute, normalize, resolve, sep } from "node:path";
2
+ import { isAbsolute, join, normalize, resolve, sep } from "node:path";
3
3
  import "vite";
4
4
  //#region src/index.ts
5
5
  /**
6
6
  * @glissade/vite-plugin (DESIGN.md §6.1): dev-server middleware persisting
7
7
  * studio sidecars. GET/POST /__glissade/sidecar?scene=<module-path> reads and
8
8
  * writes `<module>.edits.json` next to the scene module. Writes are confined
9
- * to *.edits.json paths inside the configured root.
9
+ * to *.edits.json paths inside the configured root. GET/POST
10
+ * /__glissade/project reads and writes glissade.project.json at the root —
11
+ * the shared, code-reviewable project file (§6.2: markers + render presets).
10
12
  */
11
13
  function sidecarPathFor(scenePath) {
12
14
  return scenePath.replace(/\.[jt]sx?$/, "") + ".edits.json";
@@ -22,6 +24,41 @@ function glissade(options = {}) {
22
24
  if (abs !== root && !abs.startsWith(root + sep)) return null;
23
25
  return sidecarPathFor(abs);
24
26
  };
27
+ server.middlewares.use("/__glissade/project", (req, res) => {
28
+ const projectPath = join(root, "glissade.project.json");
29
+ if (req.method === "GET") {
30
+ res.setHeader("content-type", "application/json");
31
+ res.end(existsSync(projectPath) ? readFileSync(projectPath, "utf8") : "null");
32
+ return;
33
+ }
34
+ if (req.method === "POST") {
35
+ let body = "";
36
+ req.on("data", (chunk) => {
37
+ body += chunk.toString();
38
+ });
39
+ req.on("end", () => {
40
+ try {
41
+ const doc = JSON.parse(body);
42
+ if (doc === null || doc.projectVersion !== 1) {
43
+ res.statusCode = 422;
44
+ res.end(JSON.stringify({ error: "body must be a projectVersion 1 document" }));
45
+ return;
46
+ }
47
+ writeFileSync(projectPath, JSON.stringify(doc, null, 2) + "\n");
48
+ res.end(JSON.stringify({
49
+ ok: true,
50
+ path: projectPath
51
+ }));
52
+ } catch {
53
+ res.statusCode = 400;
54
+ res.end(JSON.stringify({ error: "invalid JSON body" }));
55
+ }
56
+ });
57
+ return;
58
+ }
59
+ res.statusCode = 405;
60
+ res.end();
61
+ });
25
62
  server.middlewares.use("/__glissade/sidecar", (req, res) => {
26
63
  const sidecarPath = resolveScene(new URL(req.url ?? "/", "http://localhost").searchParams.get("scene"));
27
64
  if (!sidecarPath || !sidecarPath.endsWith(".edits.json")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/vite-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "glissade dev-server integration: sidecar read/write endpoint for the studio (DESIGN.md §6.1).",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
- "@glissade/core": "0.2.0"
18
+ "@glissade/core": "0.4.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "vite": ">=5"