synthesisui 0.16.508 → 0.16.510

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,14 +1,27 @@
1
+ import { existsSync } from "node:fs";
1
2
  import { readFile, writeFile } from "node:fs/promises";
2
3
  import { join } from "node:path";
3
4
  import { DEFAULT_CONFIG, resolveRegistry, writeProjectConfig, } from "../config.js";
4
5
  import { readProjectTheme, writeBesideTheirs, writeNewProjectRoot, writeNewProjectTheme, } from "../new-project-theme.js";
5
6
  import { openTheDoor } from "../door.js";
6
7
  import { body, section, snippet } from "../output.js";
7
- import { fetchDesignSystem } from "../registry.js";
8
+ import { fetchDesignSystem, RegistryError } from "../registry.js";
8
9
  import { resolveDeps, stylesFor, tailwindMajor } from "../stack.js";
9
10
  import { formMix, measuredStyle } from "../styles-flavour.js";
10
11
  import { desligarCaptura, ligarCaptura } from "../transcript.js";
11
12
  import { add } from "./add.js";
13
+ /** A recusa de uma pasta sem app: o que falta, quem cria, e o mesmo `init` para depois. */
14
+ export const noAppHere = (ds) => [
15
+ "There is no app here - this folder has no package.json.",
16
+ "init sets SynthesisUI up inside an app that already exists; it does not create one.",
17
+ "Create the Next.js app first, then run init inside it:",
18
+ "",
19
+ " npx create-next-app@latest my-app",
20
+ " cd my-app",
21
+ ` npx synthesisui@latest init${ds ? ` --ds ${ds}` : ""}`,
22
+ "",
23
+ "Nothing was written here.",
24
+ ].join("\n");
12
25
  const whereOf = (answer) => answer === "file" || answer === "1"
13
26
  ? "file"
14
27
  : answer === "separate" || answer === "2"
@@ -51,6 +64,17 @@ async function askWhere(tokensFile, separate, entry, intro) {
51
64
  */
52
65
  export async function init(opts) {
53
66
  const root = opts.dir ?? process.cwd();
67
+ /**
68
+ * SEM APP, O `init` RECUSA ANTES DE ESCREVER - jornada "o CLI na primeira página", E01 (12/10, medido de novo na
69
+ * 0.16.509 em 23/10). Numa pasta vazia, `init --target next --ds moss` escrevia `_synthesisui/`, baixava o sistema e
70
+ * mandava rodar o `connect`, sem dizer que não havia app nenhum. E a pasta que ficava atrás travava o passo que
71
+ * faltava: o `create-next-app` recusa um diretório com arquivos que ele não conhece, e `_synthesisui/` é um deles.
72
+ *
73
+ * O `init` não cria o app - quem cria é o `create-next-app`, e a recusa diz o comando. `--target general` é o caso
74
+ * sem Next, e segue sem `package.json`.
75
+ */
76
+ if (opts.target !== "general" && !existsSync(join(root, "package.json")))
77
+ throw new RegistryError(noAppHere(opts.ds));
54
78
  /**
55
79
  * O SISTEMA EXISTE ANTES DE QUALQUER ARQUIVO - bateria ampliada, item 21 (29/09). `init --ds teste-nunca-existiu`
56
80
  * recusava bem ("No design system ... that this machine can see"), mas só depois de escrever `_synthesisui/config.json`,
package/dist/index.js CHANGED
@@ -172,8 +172,8 @@ Examples:
172
172
  synthesisui adopt # you already have a system: start here
173
173
  synthesisui import --dry # see the census before anything is sent
174
174
  synthesisui login
175
- synthesisui init # an empty project: one command, then ask your agent
176
- synthesisui init --target next --ds halogen bootstrap + bring a system in
175
+ synthesisui init # inside a new app (create-next-app first): one command, then ask your agent
176
+ synthesisui init --ds halogen # the same, with a system from the gallery
177
177
  synthesisui doctor
178
178
  synthesisui doctor apps/web packages/ui # scope the read in a monorepo
179
179
  synthesisui doctor --strict
@@ -144,7 +144,20 @@ export const PAGE_LANGUAGE = `(() => {
144
144
  const contentWidth = content && Number(content[0]) >= 900 ? Number(content[0]) : inset ? innerWidth - 2 * Number(inset[0]) : content ? Number(content[0]) : null;
145
145
  const rhythm = { bands: bands.length, sectionGap: median(gaps.filter((g) => g >= 64)), innerGap: median(gaps.filter((g) => g > 0 && g < 64)), contentWidth };
146
146
 
147
- return { type, components, bars, sections, cards, rhythm, width: innerWidth };
147
+ /* O QUE O SITE TEM E A ENGINE AINDA NÃO LÊ (o placar de fidelidade, E07, 23/10) - contado para a barra do quanto foi
148
+ extraído: cada um só pesa quando o site o usa. */
149
+ const shown = [...document.querySelectorAll("body *")].filter(vis);
150
+ const svgs = shown.filter((e) => e.tagName.toLowerCase() === "svg");
151
+ const unread = {
152
+ animations: document.getAnimations().length,
153
+ transitions: shown.filter((e) => { const d = getComputedStyle(e).transitionDuration; return !!d && d.split(",").some((x) => parseFloat(x) > 0); }).length,
154
+ artwork: svgs.filter((e) => { const q = e.getBoundingClientRect(); return q.width >= 120 && q.height >= 120; }).length + shown.filter((e) => e.tagName === "CANVAS" || e.tagName === "VIDEO").length,
155
+ gradients: shown.filter((e) => /gradient\\(/.test(getComputedStyle(e).backgroundImage)).length,
156
+ photos: shown.filter((e) => e.tagName === "IMG" && e.getBoundingClientRect().width >= 200).length,
157
+ icons: svgs.filter((e) => { const q = e.getBoundingClientRect(); return q.width <= 32 && q.height <= 32; }).length,
158
+ };
159
+
160
+ return { type, components, bars, sections, cards, rhythm, unread, width: innerWidth };
148
161
  })()`;
149
162
  /**
150
163
  * O AVISO DE COOKIES E O MODAL, ESCONDIDOS - só nas fotos: a leitura já foi medida. Medido em 21/10 nos 21 sites: 7 dobras
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synthesisui",
3
- "version": "0.16.508",
3
+ "version": "0.16.510",
4
4
  "description": "Bring SynthesisUI design systems into any project - tokens, typed components, whole pages and an agent-ready CLAUDE.md manifest.",
5
5
  "type": "module",
6
6
  "bin": {