@tenphi/tasty 0.0.0-snapshot.047dfbb → 0.0.0-snapshot.04fb534

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 (134) hide show
  1. package/README.md +452 -370
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config--0qoqt_P.js +60 -0
  6. package/dist/chunks/build-config--0qoqt_P.js.map +1 -0
  7. package/dist/{collector-J6LwZR0N.js → chunks/collector-zp5BrLF0.js} +68 -101
  8. package/dist/chunks/collector-zp5BrLF0.js.map +1 -0
  9. package/dist/chunks/config-engine-BaLq8HrX.js +272 -0
  10. package/dist/chunks/config-engine-BaLq8HrX.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-CfXZ3tU9.js +910 -0
  14. package/dist/chunks/css-definitions-CfXZ3tU9.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug--OC-WA-Q.js +502 -0
  18. package/dist/chunks/debug--OC-WA-Q.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DnZ6M1Iv.js +691 -0
  24. package/dist/chunks/react-runtime-DnZ6M1Iv.js.map +1 -0
  25. package/dist/chunks/runtime-engine-J9X_h-Pw.js +2435 -0
  26. package/dist/chunks/runtime-engine-J9X_h-Pw.js.map +1 -0
  27. package/dist/chunks/runtime-state-o_v3Bj7b.js +152 -0
  28. package/dist/chunks/runtime-state-o_v3Bj7b.js.map +1 -0
  29. package/dist/{merge-styles-CAdKaHxh.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D6lC3O3G.js +5626 -0
  32. package/dist/chunks/style-engine-D6lC3O3G.js.map +1 -0
  33. package/dist/{css-writer-IC7tdnIf.js → chunks/zero-engine-BnjoV04F.js} +95 -136
  34. package/dist/chunks/zero-engine-BnjoV04F.js.map +1 -0
  35. package/dist/{collector-CddJZDOr.d.ts → collector-D2OT6I2G.d.ts} +64 -8
  36. package/dist/{config-C3SKYuxY.d.ts → config-C4ftFxgI.d.ts} +514 -92
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-ByBYTH9l.d.ts → index-DxQNRj50.d.ts} +586 -400
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -732
  43. package/dist/{merge-styles-CvUi7SOD.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +11 -8
  57. package/dist/ssr/astro-middleware.js +2 -14
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -10
  60. package/dist/ssr/astro.js +160 -86
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +5 -32
  65. package/dist/ssr/index.js +6 -6
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +9 -8
  71. package/dist/ssr/next.js +29 -44
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +8 -9
  74. package/dist/static/index.js +4 -22
  75. package/dist/static/index.js.map +1 -1
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/{index-C5owZ15q.d.ts → types-CYQIhUg1.d.ts} +874 -598
  78. package/dist/zero/babel.d.ts +12 -19
  79. package/dist/zero/babel.js +97 -156
  80. package/dist/zero/babel.js.map +1 -1
  81. package/dist/zero/index.d.ts +76 -7
  82. package/dist/zero/index.js +25 -2
  83. package/dist/zero/index.js.map +1 -0
  84. package/dist/zero/next.d.ts +4 -5
  85. package/dist/zero/next.js +3 -38
  86. package/dist/zero/next.js.map +1 -1
  87. package/docs/README.md +20 -9
  88. package/docs/adoption.md +69 -36
  89. package/docs/ai-agents.md +259 -0
  90. package/docs/comparison.md +77 -47
  91. package/docs/configuration.md +617 -98
  92. package/docs/debug.md +28 -15
  93. package/docs/design-system.md +166 -33
  94. package/docs/dsl.md +637 -205
  95. package/docs/getting-started.md +130 -50
  96. package/docs/injector.md +160 -69
  97. package/docs/llms.txt +31 -0
  98. package/docs/methodology.md +82 -51
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +57 -33
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +215 -50
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +310 -118
  105. package/docs/styles.md +209 -41
  106. package/docs/tasty-static.md +289 -136
  107. package/harness/dev.harnesspm/rules/usage.md +12 -0
  108. package/harness/dev.harnesspm/scripts/render.mjs +441 -0
  109. package/harness/dev.harnesspm/scripts/styles.mjs +412 -0
  110. package/harness/plugin.json +20 -0
  111. package/package.json +148 -49
  112. package/tasty.config.ts +5 -0
  113. package/dist/async-storage-DKK-wTD4.js +0 -44
  114. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  115. package/dist/collector-J6LwZR0N.js.map +0 -1
  116. package/dist/config-C3F4Ogo1.js +0 -10993
  117. package/dist/config-C3F4Ogo1.js.map +0 -1
  118. package/dist/context-CA8YKeMn.js +0 -24
  119. package/dist/context-CA8YKeMn.js.map +0 -1
  120. package/dist/core-DxHmF6S9.js +0 -1598
  121. package/dist/core-DxHmF6S9.js.map +0 -1
  122. package/dist/css-writer-IC7tdnIf.js.map +0 -1
  123. package/dist/format-global-rules-DklyaXv-.js +0 -22
  124. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  125. package/dist/format-rules-DTLY39Hm.js +0 -143
  126. package/dist/format-rules-DTLY39Hm.js.map +0 -1
  127. package/dist/hydrate-8Zglgy_C.js +0 -45
  128. package/dist/hydrate-8Zglgy_C.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/keyframes-DgGkipNK.js +0 -595
  131. package/dist/keyframes-DgGkipNK.js.map +0 -1
  132. package/dist/merge-styles-CAdKaHxh.js.map +0 -1
  133. package/dist/resolve-recipes-BQNdunBd.js +0 -144
  134. package/dist/resolve-recipes-BQNdunBd.js.map +0 -1
@@ -0,0 +1,412 @@
1
+ /**
2
+ * tasty:styles — prints the CSS Tasty generates for a styles object, with the
3
+ * app's configuration loaded first, and reports problems found during rendering.
4
+ */
5
+ import {
6
+ existsSync,
7
+ readFileSync,
8
+ readdirSync,
9
+ realpathSync,
10
+ statSync,
11
+ } from 'node:fs';
12
+ import { createRequire } from 'node:module';
13
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
14
+ import { fileURLToPath, pathToFileURL } from 'node:url';
15
+ import {
16
+ configChanged,
17
+ configFingerprint,
18
+ configSummary,
19
+ describeUnits,
20
+ findIssues,
21
+ formatCss,
22
+ renderCss,
23
+ } from './render.mjs';
24
+
25
+ const USAGE = `Usage: npx harnesspm run tasty:styles '<styles JSON>' [--setup <module>]... [--json]
26
+
27
+ Prints the CSS Tasty generates for a styles object, as tasty() and useStyles()
28
+ render it: recipes resolved, one class per style chunk, and every state as a
29
+ selector or an at-rule. To see what a state key becomes, put it in a state map.
30
+
31
+ <styles JSON> the styles object as JSON, such as '{"fill":"#surface","padding":"2x"}'.
32
+ Use - to read it from stdin.
33
+ --setup a module that configures Tasty, imported before rendering: one that
34
+ calls configure() when imported, or one that default-exports a
35
+ configure() object, such as a tasty-zero.config.ts. A file path, or
36
+ a path inside a package, such as @acme/ui/dist/setup.js. Repeat it
37
+ for several modules. TypeScript needs Node 22.18 or later.
38
+ --json print the result as JSON
39
+
40
+ Run it from the package whose styles you check. Package paths in --setup resolve
41
+ from there, and the CSS comes from the copy of @tenphi/tasty that the setup
42
+ modules configure, which in a monorepo can differ from package to package.
43
+
44
+ When the loaded config defines tokens, the tool warns about unknown #color
45
+ and $token references that still need a value in the generated CSS.
46
+
47
+ Without --setup, the CSS uses Tasty's defaults (x = 8px, r = 6px, ...) and none
48
+ of the app's units, presets, recipes or state aliases.`;
49
+
50
+ const PACKAGE_ROOT = realpathSync(
51
+ fileURLToPath(new URL('../../../', import.meta.url)),
52
+ );
53
+ const BUILD = join(PACKAGE_ROOT, 'dist/core/index.js');
54
+ const cwd = process.cwd();
55
+ const projectDir = process.env.HARNESSPM_PROJECT_DIR || cwd;
56
+
57
+ function fail(message) {
58
+ console.error(`tasty: ${message}`);
59
+ process.exit(2);
60
+ }
61
+
62
+ function parseArgs(argv) {
63
+ const options = { setup: [] };
64
+ const positional = [];
65
+ for (let i = 0; i < argv.length; i++) {
66
+ const arg = argv[i];
67
+ if (arg === '-' || !arg.startsWith('--')) {
68
+ positional.push(arg);
69
+ continue;
70
+ }
71
+ const [key, inline] = arg.slice(2).split(/=(.*)/s);
72
+ if (key === 'json' || key === 'help') options[key] = true;
73
+ else if (key === 'setup') {
74
+ const value = inline ?? argv[++i];
75
+ if (value === undefined) fail('--setup needs a module');
76
+ options.setup.push(value);
77
+ } else fail(`unknown option --${key}`);
78
+ }
79
+ return { options, positional };
80
+ }
81
+
82
+ const { options, positional } = parseArgs(process.argv.slice(2));
83
+ if (options.help || positional.length !== 1) {
84
+ console.log(USAGE);
85
+ process.exit(options.help ? 0 : 2);
86
+ }
87
+
88
+ const source = positional[0] === '-' ? readFileSync(0, 'utf8') : positional[0];
89
+ let styles;
90
+ try {
91
+ styles = JSON.parse(source);
92
+ } catch (error) {
93
+ fail(
94
+ `the styles must be JSON, with keys and strings in double quotes: ${error instanceof Error ? error.message : error}`,
95
+ );
96
+ }
97
+ if (!styles || typeof styles !== 'object' || Array.isArray(styles)) {
98
+ fail('the styles must be a JSON object');
99
+ }
100
+
101
+ if (!existsSync(BUILD)) {
102
+ fail(
103
+ `cannot find the Tasty build at ${BUILD}. In the Tasty repository, run \`pnpm build\` first.`,
104
+ );
105
+ }
106
+
107
+ // Tasty warns only in development, and the warnings are part of the answer.
108
+ process.env.NODE_ENV = 'development';
109
+
110
+ // Tasty reports problems with console.warn, also while a setup module is
111
+ // imported, so collect them from the start.
112
+ const tastyWarnings = [];
113
+ const warn = console.warn;
114
+ console.warn = (...args) => tastyWarnings.push(args.map(String).join(' '));
115
+
116
+ // Every copy of @tenphi/tasty this run can see, by its real folder. A setup
117
+ // module configures the copy it imports, which in a monorepo or with a second
118
+ // version installed need not be this tool's own.
119
+ const copies = new Map();
120
+ const own = await copyAt(PACKAGE_ROOT);
121
+ const appRoot = tastyRootFrom(cwd);
122
+ const app = appRoot === undefined ? undefined : await copyAt(appRoot);
123
+
124
+ const loaded = [];
125
+ for (const spec of options.setup) {
126
+ const file = resolveSetup(spec);
127
+ const nearRoot = tastyRootFrom(dirname(realpathSync(file)));
128
+ const near = nearRoot === undefined ? undefined : await copyAt(nearRoot);
129
+ const before = new Map(
130
+ [...copies.values()].map((c) => [c.root, configFingerprint(c.t)]),
131
+ );
132
+ let mod;
133
+ try {
134
+ mod = await import(pathToFileURL(file).href);
135
+ } catch (error) {
136
+ console.warn = warn;
137
+ fail(`cannot import --setup ${spec}: ${importHint(file, error)}`);
138
+ }
139
+ const config = mod.default;
140
+ const isConfig =
141
+ config !== null &&
142
+ typeof config === 'object' &&
143
+ Object.getPrototypeOf(config) === Object.prototype;
144
+ let changed;
145
+ if (isConfig) {
146
+ const target = near ?? app ?? own;
147
+ try {
148
+ target.t.configure(config);
149
+ } catch (error) {
150
+ console.warn = warn;
151
+ fail(
152
+ `configure() rejected the default export of ${spec}: ${error instanceof Error ? error.message : error}`,
153
+ );
154
+ }
155
+ changed = [target];
156
+ } else {
157
+ changed = [...copies.values()].filter((c) =>
158
+ configChanged(before.get(c.root), configFingerprint(c.t)),
159
+ );
160
+ }
161
+ loaded.push({
162
+ module: spec,
163
+ configured: isConfig
164
+ ? 'default export'
165
+ : changed.length > 0
166
+ ? 'on import'
167
+ : 'nothing',
168
+ tasty: changed.map((c) => ({ version: c.version, path: show(c.root) })),
169
+ });
170
+ for (const c of changed) c.setups.push(spec);
171
+ }
172
+
173
+ const configured = [...copies.values()].filter((c) => c.setups.length > 0);
174
+ const chosen =
175
+ configured.length === 0
176
+ ? (app ?? own)
177
+ : configured.includes(app)
178
+ ? app
179
+ : configured.reduce((a, b) =>
180
+ b.setups.length > a.setups.length ? b : a,
181
+ );
182
+ const t = chosen.t;
183
+ const version = chosen.version;
184
+ const config = configSummary(t);
185
+
186
+ const warnings = [];
187
+ if (loaded.length === 0) {
188
+ const candidates = findSetupCandidates(
189
+ cwd.startsWith(projectDir) ? cwd : projectDir,
190
+ );
191
+ warnings.push(
192
+ candidates.length > 0
193
+ ? `No --setup: this is the CSS for Tasty's defaults, not the app's config. These files configure Tasty: ${candidates.join(', ')}. Run again with --setup <file>.`
194
+ : "No --setup: this is the CSS for Tasty's defaults. No file in this project calls configure() from @tenphi/tasty. If the app configures Tasty elsewhere, such as in a UI library, pass that module with --setup.",
195
+ );
196
+ }
197
+ for (const entry of loaded.filter((l) => l.configured === 'nothing')) {
198
+ warnings.push(
199
+ `--setup ${entry.module} changed no Tasty config this tool can see. It may call configure() only inside a function, or configure a copy of @tenphi/tasty that neither this package nor the other setup modules use.`,
200
+ );
201
+ }
202
+ if (configured.length > 1) {
203
+ const parts = configured.map(
204
+ (c) => `${c.version} (${show(c.root)}) got ${c.setups.join(', ')}`,
205
+ );
206
+ warnings.push(
207
+ `The --setup modules configure ${configured.length} copies of @tenphi/tasty, so this CSS has only part of the config: ${parts.join('; ')}. This CSS comes from ${chosen.version} (${show(chosen.root)}). The app runs these copies too, each with part of the config: make every package use one version of @tenphi/tasty.`,
208
+ );
209
+ }
210
+
211
+ let result;
212
+ try {
213
+ result = renderCss(t, styles);
214
+ } catch (error) {
215
+ console.warn = warn;
216
+ fail(
217
+ `Tasty could not render these styles: ${error instanceof Error ? error.message : error}`,
218
+ );
219
+ }
220
+ warnings.push(...findIssues(t, styles, result.css));
221
+ console.warn = warn;
222
+ warnings.push(
223
+ ...new Set(tastyWarnings.map((w) => w.trim().replace(/\s*\n\s*/g, ' '))),
224
+ );
225
+
226
+ if (options.json) {
227
+ console.log(
228
+ JSON.stringify(
229
+ {
230
+ tasty: { version, path: show(chosen.root) },
231
+ setup: loaded,
232
+ config,
233
+ classNames: result.classNames,
234
+ css: result.css,
235
+ warnings,
236
+ },
237
+ null,
238
+ 2,
239
+ ),
240
+ );
241
+ } else {
242
+ console.log(render());
243
+ }
244
+
245
+ function render() {
246
+ const out = [];
247
+ const setup =
248
+ loaded.length > 0
249
+ ? `setup ${loaded.map((l) => l.module).join(', ')}`
250
+ : 'no setup, Tasty defaults';
251
+ const from = chosen === own ? '' : ` (${show(chosen.root)})`;
252
+ out.push(`Tasty ${version}${from}, ${setup}`);
253
+ const parts = [`units ${describeUnits(config.units)}`];
254
+ if (config.states.length > 0) parts.push(`states ${list(config.states)}`);
255
+ if (config.recipes.length > 0) parts.push(`recipes ${list(config.recipes)}`);
256
+ out.push(`Config: ${parts.join('; ')}`);
257
+ if (result.classNames.length > 0) {
258
+ out.push(
259
+ `Classes: ${result.classNames.join(' ')} (one per style chunk, doubled in selectors as at runtime)`,
260
+ );
261
+ }
262
+ out.push('', result.css ? formatCss(result.css) : '(no CSS)');
263
+ if (warnings.length > 0) {
264
+ out.push('', 'Warnings:', ...warnings.map((w) => `- ${w}`));
265
+ }
266
+ return out.join('\n');
267
+ }
268
+
269
+ function list(names) {
270
+ return names.length <= 8
271
+ ? names.join(', ')
272
+ : `${names.slice(0, 8).join(', ')} and ${names.length - 8} more`;
273
+ }
274
+
275
+ /** A file path, or a path inside a package installed in the project. */
276
+ function resolveSetup(spec) {
277
+ if (
278
+ /(^|\/)tasty\.config\.[cm]?[jt]s$|(^|\/)tasty\.config\.json$/.test(spec)
279
+ ) {
280
+ fail(
281
+ `${spec} only lists names for the ESLint plugin and the editor. Pass the module that calls configure(), or one that default-exports its config.`,
282
+ );
283
+ }
284
+ const asPath = resolve(spec);
285
+ if (spec.startsWith('.') || isAbsolute(spec) || existsSync(asPath)) {
286
+ if (!existsSync(asPath)) fail(`cannot find --setup ${spec}`);
287
+ return asPath;
288
+ }
289
+ // From the current package first: in a monorepo, each package can install
290
+ // its own version.
291
+ for (const base of new Set([cwd, projectDir])) {
292
+ try {
293
+ return createRequire(join(base, 'noop.js')).resolve(spec);
294
+ } catch {
295
+ // A path the package's exports do not list, such as a file in its dist/.
296
+ }
297
+ for (let dir = base; ; dir = dirname(dir)) {
298
+ const candidate = join(dir, 'node_modules', spec);
299
+ if (existsSync(candidate)) return candidate;
300
+ if (dirname(dir) === dir) break;
301
+ }
302
+ }
303
+ return fail(`cannot resolve --setup ${spec} from ${cwd}`);
304
+ }
305
+
306
+ /** The real folder of the @tenphi/tasty that code in `dir` imports. */
307
+ function tastyRootFrom(dir) {
308
+ let entry;
309
+ try {
310
+ entry = createRequire(join(dir, 'noop.js')).resolve('@tenphi/tasty');
311
+ } catch {
312
+ return undefined;
313
+ }
314
+ for (let d = dirname(entry); dirname(d) !== d; d = dirname(d)) {
315
+ const manifest = join(d, 'package.json');
316
+ if (
317
+ existsSync(manifest) &&
318
+ JSON.parse(readFileSync(manifest, 'utf8')).name === '@tenphi/tasty'
319
+ ) {
320
+ return realpathSync(d);
321
+ }
322
+ }
323
+ return undefined;
324
+ }
325
+
326
+ /** Loads a copy of Tasty once; undefined when it has no usable build. */
327
+ async function copyAt(root) {
328
+ if (copies.has(root)) return copies.get(root);
329
+ const build = join(root, 'dist/core/index.js');
330
+ if (!existsSync(build)) return undefined;
331
+ const core = await import(pathToFileURL(build).href);
332
+ if (typeof core.computeStyles !== 'function') return undefined;
333
+ const copy = {
334
+ root,
335
+ version: JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
336
+ .version,
337
+ t: core,
338
+ setups: [],
339
+ };
340
+ copies.set(root, copy);
341
+ return copy;
342
+ }
343
+
344
+ /** A path as the person sees it: relative to the current folder. */
345
+ function show(path) {
346
+ return relative(cwd, path) || '.';
347
+ }
348
+
349
+ function importHint(file, error) {
350
+ const message = error instanceof Error ? error.message : String(error);
351
+ const code = error && typeof error === 'object' ? error.code : undefined;
352
+ if (code === 'ERR_UNKNOWN_FILE_EXTENSION') {
353
+ return `${message}. Node cannot import this file type. Pass a module without JSX, a built .js file, or a .ts file on Node 22.18 or later.`;
354
+ }
355
+ if (code === 'ERR_MODULE_NOT_FOUND' && /\.[cm]?tsx?$/.test(file)) {
356
+ return `${message}. Node needs full file extensions in relative imports, and does not read tsconfig paths.`;
357
+ }
358
+ return message;
359
+ }
360
+
361
+ /** Up to five project files that import Tasty and configure it. */
362
+ function findSetupCandidates(root) {
363
+ const SKIP = new Set([
364
+ 'node_modules',
365
+ 'dist',
366
+ 'build',
367
+ 'out',
368
+ 'coverage',
369
+ 'storybook-static',
370
+ ]);
371
+ const found = [];
372
+ let budget = 5000;
373
+ const walk = (dir, depth) => {
374
+ if (depth > 6 || found.length >= 5) return;
375
+ let entries;
376
+ try {
377
+ entries = readdirSync(dir, { withFileTypes: true });
378
+ } catch {
379
+ return;
380
+ }
381
+ for (const entry of entries) {
382
+ if (found.length >= 5 || --budget < 0) return;
383
+ const path = join(dir, entry.name);
384
+ if (entry.isDirectory()) {
385
+ if (!entry.name.startsWith('.') && !SKIP.has(entry.name)) {
386
+ walk(path, depth + 1);
387
+ }
388
+ } else if (
389
+ /\.[cm]?[jt]sx?$/.test(entry.name) &&
390
+ !/\.(test|spec|stories|d)\.[cm]?[jt]sx?$/.test(entry.name) &&
391
+ !/^tasty\.config\./.test(entry.name)
392
+ ) {
393
+ try {
394
+ if (statSync(path).size > 256 * 1024) continue;
395
+ const text = readFileSync(path, 'utf8');
396
+ if (
397
+ /['"]@tenphi\/tasty(\/[\w/-]*)?['"]/.test(text) &&
398
+ /\b(configure|setGlobalPredefinedStates)\s*\(/.test(text)
399
+ ) {
400
+ found.push(relative(root, path));
401
+ } else if (/^tasty[\w.-]*\.config\.[cm]?[jt]s$/.test(entry.name)) {
402
+ found.push(relative(root, path));
403
+ }
404
+ } catch {
405
+ // Unreadable files are not candidates.
406
+ }
407
+ }
408
+ }
409
+ };
410
+ walk(root, 0);
411
+ return found;
412
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
+ "name": "tasty",
4
+ "description": "Tasty styles: the style rules, the docs of the installed version, and a tool that prints the CSS a styles object produces",
5
+ "homepage": "https://tasty.style",
6
+ "repository": "https://github.com/tenphi/tasty",
7
+ "keywords": ["tasty", "css-in-js", "styles", "design-system", "react"],
8
+ "extensions": {
9
+ "dev.harnesspm": {
10
+ "docs": "../docs",
11
+ "scripts": {
12
+ "styles": {
13
+ "file": "./dev.harnesspm/scripts/styles.mjs",
14
+ "description": "Print the CSS a Tasty styles object produces and report rendering warnings, including unknown token references when the --setup config defines tokens",
15
+ "allow": true
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }