@auscera/design-labs 0.0.0-stage → 0.1.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.
Files changed (57) hide show
  1. package/apps/workspace/.skills/design-labs/SKILL.md +63 -0
  2. package/apps/workspace/.skills/design-labs/references/commands.md +38 -0
  3. package/apps/workspace/AGENTS.md +9 -0
  4. package/apps/workspace/app/(lab)/compare/page.tsx +2 -0
  5. package/apps/workspace/app/(lab)/lab.css +412 -0
  6. package/apps/workspace/app/(lab)/layout.tsx +21 -0
  7. package/apps/workspace/app/(lab)/page.tsx +2 -0
  8. package/apps/workspace/app/api/annotations/route.ts +94 -0
  9. package/apps/workspace/app/api/versions/events/route.ts +63 -0
  10. package/apps/workspace/app/api/versions/route.ts +7 -0
  11. package/apps/workspace/components/animated-icons.tsx +72 -0
  12. package/apps/workspace/components/dotmatrix-loader.css +1228 -0
  13. package/apps/workspace/components/glass-controls.tsx +47 -0
  14. package/apps/workspace/components/lab-providers.tsx +17 -0
  15. package/apps/workspace/components/molecules/brand-lockup.tsx +13 -0
  16. package/apps/workspace/components/molecules/pane-url-popover.css +92 -0
  17. package/apps/workspace/components/molecules/pane-url-popover.tsx +191 -0
  18. package/apps/workspace/components/pane-preferences.tsx +75 -0
  19. package/apps/workspace/components/pane-viewport.css +34 -0
  20. package/apps/workspace/components/pane-viewport.tsx +199 -0
  21. package/apps/workspace/components/preview-pane.css +293 -0
  22. package/apps/workspace/components/preview-pane.tsx +662 -0
  23. package/apps/workspace/components/ui/dotm-triangle-11.tsx +170 -0
  24. package/apps/workspace/components/ui/dotmatrix-core.tsx +1649 -0
  25. package/apps/workspace/components/ui/dotmatrix-hooks.ts +224 -0
  26. package/apps/workspace/components/version-select.tsx +220 -0
  27. package/apps/workspace/components/workspace.tsx +313 -0
  28. package/apps/workspace/eslint.config.mjs +3 -0
  29. package/apps/workspace/lab.config.json +1 -0
  30. package/apps/workspace/lib/annotation-export.ts +28 -0
  31. package/apps/workspace/lib/annotation-types.ts +38 -0
  32. package/apps/workspace/lib/device-presets.ts +103 -0
  33. package/apps/workspace/lib/use-annotation-bridge.ts +130 -0
  34. package/apps/workspace/lib/version-types.ts +12 -0
  35. package/apps/workspace/lib/website-url.ts +78 -0
  36. package/apps/workspace/next-env.d.ts +6 -0
  37. package/apps/workspace/next.config.mjs +1 -0
  38. package/apps/workspace/package.json +35 -0
  39. package/apps/workspace/public/apple-touch-icon.png +0 -0
  40. package/apps/workspace/public/brand/design-labs-script.LICENSE.txt +93 -0
  41. package/apps/workspace/public/brand/design-labs-script.woff2 +0 -0
  42. package/apps/workspace/public/brand/logo.webp +0 -0
  43. package/apps/workspace/public/brand/wordmark.css +42 -0
  44. package/apps/workspace/public/favicon.ico +0 -0
  45. package/apps/workspace/public/icon-192.png +0 -0
  46. package/apps/workspace/public/icon-512.png +0 -0
  47. package/apps/workspace/public/preview-bridge.js +411 -0
  48. package/apps/workspace/public/site.webmanifest +1 -0
  49. package/apps/workspace/scripts/annotation-store.mjs +308 -0
  50. package/apps/workspace/scripts/lab.mjs +414 -0
  51. package/apps/workspace/scripts/migrate.mjs +2 -0
  52. package/apps/workspace/scripts/prepare-preview.mjs +203 -0
  53. package/apps/workspace/tsconfig.json +24 -0
  54. package/package.json +9 -3
  55. package/scripts/install.mjs +67 -0
  56. package/scripts/update.mjs +204 -0
  57. package/README.md +0 -3
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { plan } from "./update.mjs";
6
+ const product = path.resolve(
7
+ path.dirname(fileURLToPath(import.meta.url)),
8
+ "..",
9
+ );
10
+ export function install(workspace) {
11
+ workspace = fs.realpathSync(workspace);
12
+ const pkg = JSON.parse(
13
+ fs.existsSync(path.join(workspace, "package.json"))
14
+ ? fs.readFileSync(path.join(workspace, "package.json"))
15
+ : "{}",
16
+ );
17
+ const mono =
18
+ fs.existsSync(path.join(workspace, "pnpm-workspace.yaml")) ||
19
+ !!pkg.workspaces ||
20
+ fs.existsSync(path.join(workspace, "turbo.json"));
21
+ const dest = path.join(workspace, mono ? "apps/design-lab" : "design-lab");
22
+ if (fs.existsSync(dest))
23
+ throw Error(
24
+ "Design Lab exists; refusing to overwrite. Use the reviewed platform migration workflow.",
25
+ );
26
+ fs.mkdirSync(dest, { recursive: true });
27
+ for (const f of [
28
+ "app",
29
+ "components",
30
+ "lib",
31
+ "scripts",
32
+ "public",
33
+ "package.json",
34
+ "next.config.mjs",
35
+ "tsconfig.json",
36
+ "next-env.d.ts",
37
+ "eslint.config.mjs",
38
+ "lab.config.json",
39
+ "AGENTS.md",
40
+ ".skills",
41
+ ]) {
42
+ const src = path.join(product, "apps/workspace", f);
43
+ if (!fs.existsSync(src)) throw Error(`Distribution file missing: ${f}`);
44
+ fs.cpSync(src, path.join(dest, f), { recursive: true });
45
+ }
46
+ for (const category of ["landing", "dashboard"])
47
+ fs.mkdirSync(path.join(dest, "versions", category), { recursive: true });
48
+ fs.writeFileSync(
49
+ path.join(dest, ".design-labs-install.json"),
50
+ JSON.stringify({ version: 2, files: plan(dest).files }, null, 2),
51
+ );
52
+ return dest;
53
+ }
54
+ if (
55
+ process.argv[1] &&
56
+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
57
+ ) {
58
+ try {
59
+ console.log(install(process.argv[2] || process.cwd()));
60
+ console.log(
61
+ "Read the installed AGENTS.md and skill, install dependencies using the target project's package manager, then run pnpm dev from the installed Lab. Prepare snapshots and previews as described in the skill.",
62
+ );
63
+ } catch (e) {
64
+ console.error(e.message);
65
+ process.exitCode = 1;
66
+ }
67
+ }
@@ -0,0 +1,204 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import crypto from "node:crypto";
5
+ import { fileURLToPath } from "node:url";
6
+ import { migrate } from "../apps/workspace/scripts/migrate.mjs";
7
+ const product = path.resolve(
8
+ path.dirname(fileURLToPath(import.meta.url)),
9
+ "..",
10
+ );
11
+ const managed = [
12
+ "app/(lab)",
13
+ "app/api/versions",
14
+ "app/api/annotations",
15
+ "lib",
16
+ "public/preview-bridge.js",
17
+ "components",
18
+ "scripts",
19
+ "public/brand",
20
+ "public/favicon.ico",
21
+ "public/apple-touch-icon.png",
22
+ "public/site.webmanifest",
23
+ "public/icon-192.png",
24
+ "public/icon-512.png",
25
+ "AGENTS.md",
26
+ ".skills",
27
+ ];
28
+ function list(dir, rel = "") {
29
+ return fs
30
+ .readdirSync(dir, { withFileTypes: true })
31
+ .flatMap((e) =>
32
+ e.isDirectory()
33
+ ? list(path.join(dir, e.name), rel + e.name + "/")
34
+ : [rel + e.name],
35
+ );
36
+ }
37
+ const hash = (p) =>
38
+ fs.existsSync(p)
39
+ ? crypto.createHash("sha256").update(fs.readFileSync(p)).digest("hex")
40
+ : null;
41
+ export function plan(target) {
42
+ target = fs.realpathSync(target);
43
+ const previous = fs.existsSync(path.join(target, ".design-labs-install.json"))
44
+ ? JSON.parse(
45
+ fs.readFileSync(path.join(target, ".design-labs-install.json")),
46
+ )
47
+ : { files: {} };
48
+ const changes = [];
49
+ const files = {};
50
+ for (const entry of managed) {
51
+ const source = path.join(product, "apps/workspace", entry);
52
+ if (!fs.existsSync(source)) continue;
53
+ for (const f of fs.statSync(source).isDirectory()
54
+ ? list(source).map((f) => entry + "/" + f)
55
+ : [entry]) {
56
+ const next = hash(path.join(product, "apps/workspace", f)),
57
+ current = hash(path.join(target, f));
58
+ files[f] = next;
59
+ if (next !== current)
60
+ changes.push({
61
+ file: f,
62
+ current,
63
+ next,
64
+ conflict: !!current && previous.files[f] !== current,
65
+ });
66
+ }
67
+ }
68
+ const report = {
69
+ target,
70
+ changes,
71
+ files,
72
+ configHash: hash(path.join(target, "lab.config.json")),
73
+ packageHash: hash(path.join(target, "package.json")),
74
+ dependencies: JSON.parse(
75
+ fs.readFileSync(path.join(product, "apps/workspace/package.json")),
76
+ ),
77
+ };
78
+ return {
79
+ ...report,
80
+ token: crypto
81
+ .createHash("sha256")
82
+ .update(JSON.stringify(report))
83
+ .digest("hex"),
84
+ };
85
+ }
86
+ export function update(target, token, acceptLocal = false) {
87
+ const p = plan(target);
88
+ if (token !== p.token)
89
+ throw Error("Review the update plan and use its current token");
90
+ if (p.changes.some((c) => c.conflict) && !acceptLocal)
91
+ throw Error(
92
+ "Locally modified or untracked platform files; review before --accept-local",
93
+ );
94
+ const backup = path.join(
95
+ path.dirname(target),
96
+ ".design-labs-backups",
97
+ path.basename(target) + "-" + Date.now(),
98
+ );
99
+ fs.mkdirSync(path.dirname(backup), { recursive: true });
100
+ fs.cpSync(target, backup, {
101
+ recursive: true,
102
+ filter: (src) =>
103
+ !["node_modules", ".next", ".git"].includes(path.basename(src)) &&
104
+ !path.basename(src).startsWith(".env"),
105
+ });
106
+ try {
107
+ for (const c of p.changes) {
108
+ const dst = path.join(target, c.file);
109
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
110
+ fs.copyFileSync(path.join(product, "apps/workspace", c.file), dst);
111
+ }
112
+ const local = JSON.parse(
113
+ fs.readFileSync(path.join(target, "package.json")),
114
+ );
115
+ Object.assign(local.dependencies, p.dependencies.dependencies);
116
+ Object.assign(local.devDependencies, p.dependencies.devDependencies);
117
+ local.scripts.dev = p.dependencies.scripts.dev;
118
+ fs.writeFileSync(
119
+ path.join(target, "package.json"),
120
+ JSON.stringify(local, null, 2) + "\n",
121
+ );
122
+ const moves = migrate(target);
123
+ fs.writeFileSync(
124
+ path.join(target, ".design-labs-install.json"),
125
+ JSON.stringify({ version: 2, files: p.files }, null, 2),
126
+ );
127
+ return {
128
+ backup,
129
+ moves,
130
+ next: "Install workspace dependencies, run types/build/browser checks. If these fail, use rollback.",
131
+ };
132
+ } catch (e) {
133
+ throw Error(`${e.message}; recovery backup: ${backup}`);
134
+ }
135
+ }
136
+ export function rollback(target, backup) {
137
+ if (
138
+ path.dirname(backup) !==
139
+ path.join(path.dirname(target), ".design-labs-backups") ||
140
+ !path.basename(backup).startsWith(path.basename(target) + "-") ||
141
+ !fs.existsSync(backup)
142
+ )
143
+ throw Error("Invalid backup");
144
+ const failed = path.join(
145
+ path.dirname(target),
146
+ ".design-labs-backups",
147
+ path.basename(target) + "-failed-" + Date.now(),
148
+ );
149
+ fs.renameSync(target, failed);
150
+ fs.cpSync(backup, target, { recursive: true });
151
+ // Environments are intentionally absent from portable backups. Preserve
152
+ // local environment files from the failed installation during rollback.
153
+ function restoreEnvironment(dir, relative = "") {
154
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
155
+ if (["node_modules", ".next", ".git"].includes(entry.name)) continue;
156
+ const name = path.join(relative, entry.name);
157
+ if (entry.isDirectory())
158
+ restoreEnvironment(path.join(dir, entry.name), name);
159
+ else if (entry.name.startsWith(".env") && !entry.isSymbolicLink()) {
160
+ const destination = path.join(target, name);
161
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
162
+ fs.copyFileSync(path.join(dir, entry.name), destination);
163
+ }
164
+ }
165
+ }
166
+ restoreEnvironment(failed);
167
+ return {
168
+ restored: target,
169
+ failed,
170
+ next: "Reinstall dependencies before launch",
171
+ };
172
+ }
173
+ if (
174
+ process.argv[1] &&
175
+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
176
+ ) {
177
+ try {
178
+ const [cmd, target, token, ...flags] = process.argv.slice(2);
179
+ console.log(
180
+ JSON.stringify(
181
+ cmd === "plan" || cmd === "fix"
182
+ ? plan(path.resolve(target))
183
+ : cmd === "apply"
184
+ ? update(
185
+ path.resolve(target),
186
+ token,
187
+ flags.includes("--accept-local"),
188
+ )
189
+ : cmd === "rollback"
190
+ ? rollback(path.resolve(target), path.resolve(token))
191
+ : (() => {
192
+ throw Error(
193
+ "Use plan|fix <installed-lab>, apply <lab> <token> [--accept-local], rollback <lab> <backup>",
194
+ );
195
+ })(),
196
+ null,
197
+ 2,
198
+ ),
199
+ );
200
+ } catch (e) {
201
+ console.error(e.message);
202
+ process.exitCode = 1;
203
+ }
204
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.