@astryxdesign/cli 0.7.16 → 0.7.17-canary.gb36275e
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 +13 -23
- package/api/build/_adapter.d.mts +5 -0
- package/api/build/_adapter.mjs +49 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +2 -1
- package/api/build/kit/rank.mjs +59 -12
- package/api/build/kit/weights.d.mts +16 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +238 -31
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +42 -0
- package/api/build/kit/words.mjs +82 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +46 -5
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +26 -2
- package/api/docs/_adapter.mjs +217 -5
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +77 -6
- package/api/doctor/built-checks.mjs +38 -13
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/render/_adapter.mjs +531 -192
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +30 -0
- package/api/render/render.type.mjs +19 -0
- package/api/search/ORDERING.md +1 -1
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_result.d.mts +5 -5
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +10 -0
- package/api/theme/build/build.d.mts +47 -0
- package/api/theme/build/build.mjs +147 -25
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +48 -0
- package/api/theme-edit/_adapter.mjs +675 -42
- package/api/theme-edit/_check.d.mts +28 -22
- package/api/theme-edit/_check.mjs +1481 -252
- package/api/theme-edit/_color.d.mts +9 -0
- package/api/theme-edit/_color.mjs +41 -1
- package/api/theme-edit/_compiler.mjs +9 -0
- package/api/theme-edit/_context.mjs +60 -3
- package/api/theme-edit/_css.mjs +21 -1
- package/api/theme-edit/_edit.d.mts +22 -0
- package/api/theme-edit/_edit.mjs +1196 -88
- package/api/theme-edit/_how-commands.d.mts +57 -0
- package/api/theme-edit/_how-commands.mjs +536 -1
- package/api/theme-edit/_how-question.d.mts +65 -0
- package/api/theme-edit/_how-question.mjs +4401 -225
- package/api/theme-edit/_how.mjs +104 -4
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_normal.d.mts +153 -0
- package/api/theme-edit/_normal.mjs +661 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +103 -2
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +205 -17
- package/api/theme-edit/_preview.d.mts +64 -8
- package/api/theme-edit/_preview.mjs +447 -89
- package/api/theme-edit/_settings.d.mts +176 -5
- package/api/theme-edit/_settings.mjs +1936 -128
- package/api/theme-edit/_tables.d.mts +6 -0
- package/api/theme-edit/_tables.mjs +32 -1
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/assets/codemods/run-codemod.mjs +73 -6
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +43 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +20 -2
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +22 -14
- package/clients/cli/commands/experimental/render.mjs +32 -1
- package/clients/cli/commands/experimental/theme.mjs +65 -14
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +153 -5
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +27 -2
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +20 -7
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/template-adapter.d.mts +52 -0
- package/foundation/discovery/template-adapter.mjs +173 -10
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/gather-cache.d.mts +25 -4
- package/foundation/fs/gather-cache.mjs +163 -53
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/module-loader.d.mts +18 -2
- package/foundation/fs/module-loader.mjs +92 -20
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/render/embedded-imports.d.mts +5 -4
- package/foundation/render/embedded-imports.mjs +7 -16
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +83 -13
- package/foundation/render/render-page.d.mts +34 -2
- package/foundation/render/render-page.mjs +210 -29
- package/foundation/render/source-block.d.mts +73 -6
- package/foundation/render/source-block.mjs +170 -19
- package/foundation/render/ts-paths.d.mts +53 -6
- package/foundation/render/ts-paths.mjs +286 -41
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +10 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +16 -3
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +13 -0
- package/host/index.mjs +8 -6
- package/package.json +6 -6
package/api/theme-edit/_how.mjs
CHANGED
|
@@ -41,7 +41,7 @@ import {MODAL} from './_compiler.mjs';
|
|
|
41
41
|
import {PALETTE_DIALS, mappingRows, paletteFiles} from './_palette.mjs';
|
|
42
42
|
import {requireProject, context} from './_context.mjs';
|
|
43
43
|
import {checked, exampleStep, howTheme, render} from './_how-commands.mjs';
|
|
44
|
-
import {draftAnswer} from './_how-question.mjs';
|
|
44
|
+
import {draftAnswer, valueAsked} from './_how-question.mjs';
|
|
45
45
|
import {
|
|
46
46
|
getCliInvocation,
|
|
47
47
|
quoteCommandArgument,
|
|
@@ -191,6 +191,16 @@ async function answer(subject, options, cwd) {
|
|
|
191
191
|
// "½rem": a fraction is a number before anything reads the question.
|
|
192
192
|
const t = (subject ?? '')
|
|
193
193
|
.trim()
|
|
194
|
+
// "corners:", "var(--radius-element)": a setting pasted as written is
|
|
195
|
+
// a lookup of it.
|
|
196
|
+
.replace(/^([a-z][a-z -]*):\s*$/i, '$1')
|
|
197
|
+
.replace(/^var\(\s*(--[a-z0-9-]+)\s*\)$/i, '$1')
|
|
198
|
+
// A lone "½" with no unit after it is a share of now ("card padding
|
|
199
|
+
// ½"), never 0.5px.
|
|
200
|
+
.replace(
|
|
201
|
+
/(\d*)(?:½|1\u20442)(?!\s*(?:rem|px|em|%|x\b|×|times\b))/g,
|
|
202
|
+
(_, n) => (n ? `${n}½` : ' half '),
|
|
203
|
+
)
|
|
194
204
|
.replace(/(\d*)(?:½|1\u20442)/g, (_, n) => `${n ? Number(n) + 0.5 : '0.5'}`)
|
|
195
205
|
.replace(
|
|
196
206
|
/(\d*)(?:¼|1\u20444)/g,
|
|
@@ -200,6 +210,12 @@ async function answer(subject, options, cwd) {
|
|
|
200
210
|
/(\d*)(?:¾|3\u20444)/g,
|
|
201
211
|
(_, n) => `${n ? Number(n) + 0.75 : '0.75'}`,
|
|
202
212
|
);
|
|
213
|
+
// "paddingLeft", "borderRadius": a property as JavaScript spells it is
|
|
214
|
+
// that CSS property, as set takes it.
|
|
215
|
+
if (/^[a-z]+(?:[A-Z][a-z]+)+$/.test(t)) {
|
|
216
|
+
const kebab = t.replace(/[A-Z]/g, ch => `-${ch.toLowerCase()}`);
|
|
217
|
+
if (cssProperties().has(kebab)) return answer(kebab, options, cwd);
|
|
218
|
+
}
|
|
203
219
|
// "explain spacing", "tell me about the accent": the lookup of what is
|
|
204
220
|
// named, never a change.
|
|
205
221
|
const explain =
|
|
@@ -214,7 +230,23 @@ async function answer(subject, options, cwd) {
|
|
|
214
230
|
run: [`${HOW} ${t ? JSON.stringify(t) : 'card'}`],
|
|
215
231
|
});
|
|
216
232
|
if (options.theme != null) {
|
|
217
|
-
|
|
233
|
+
try {
|
|
234
|
+
loadTheme(cwd, options.theme);
|
|
235
|
+
} catch (e) {
|
|
236
|
+
// A theme name near the one typed: the same question for it, never
|
|
237
|
+
// only `show` (the question is kept).
|
|
238
|
+
const err = /** @type {any} */ (e);
|
|
239
|
+
// (A name typed in another case or as a path too.)
|
|
240
|
+
if (err?.suggestions)
|
|
241
|
+
for (const s of err.suggestions) {
|
|
242
|
+
const near = / show ([a-z][a-z0-9-]*)$/.exec(
|
|
243
|
+
String(s.name ?? ''),
|
|
244
|
+
)?.[1];
|
|
245
|
+
if (near)
|
|
246
|
+
s.name = `${HOW} ${quoteCommandArgument(t || 'card')} --theme ${near}`;
|
|
247
|
+
}
|
|
248
|
+
throw e;
|
|
249
|
+
}
|
|
218
250
|
// A theme whose source no longer extends its settings takes no setting:
|
|
219
251
|
// an answer would suggest commands that cannot run.
|
|
220
252
|
const broken = themeSourceProblem(cwd, options.theme);
|
|
@@ -510,8 +542,10 @@ async function answer(subject, options, cwd) {
|
|
|
510
542
|
results: tool,
|
|
511
543
|
...unknown,
|
|
512
544
|
};
|
|
513
|
-
// a question about what something is gets the lookup, not a change
|
|
545
|
+
// a question about what something is gets the lookup, not a change; a
|
|
546
|
+
// question about a part's value now gets the value (draftAnswer).
|
|
514
547
|
if (
|
|
548
|
+
!valueAsked(t) &&
|
|
515
549
|
(/^\s*(what|which|where)\b.*\b(variables?|tokens?|do|does|means?|controls?|for)\b|^\s*what('s| is) the (css )?(variable|token|property)/i.test(
|
|
516
550
|
t,
|
|
517
551
|
) ||
|
|
@@ -600,9 +634,74 @@ async function answer(subject, options, cwd) {
|
|
|
600
634
|
function finish(env, drafts) {
|
|
601
635
|
/** @type {Array<{text: string, commands: string[], sequence?: boolean, refused?: Array<{command: string, why: string}>}>} */
|
|
602
636
|
const out = [];
|
|
637
|
+
// The measured check runs first on the drafts that carry what their
|
|
638
|
+
// clause asks; a draft that joins them ("all of it, in order") then keeps
|
|
639
|
+
// only the steps some kept option still has, so it never brings back a
|
|
640
|
+
// step the check left out.
|
|
641
|
+
const key = (/** @type {import('./_how-commands.mjs').Step} */ st) =>
|
|
642
|
+
JSON.stringify([
|
|
643
|
+
st.verb,
|
|
644
|
+
st.thing,
|
|
645
|
+
st.value,
|
|
646
|
+
st.on,
|
|
647
|
+
st.when,
|
|
648
|
+
st.state,
|
|
649
|
+
st.mode,
|
|
650
|
+
]);
|
|
651
|
+
/** @type {Set<string>} */
|
|
652
|
+
const dropped = new Set();
|
|
653
|
+
/** @type {Set<string>} */
|
|
654
|
+
const kept = new Set();
|
|
655
|
+
/** @type {Map<object, string[]>} */
|
|
656
|
+
const unmetOf = new Map();
|
|
657
|
+
if (typeof env.measure === 'function')
|
|
658
|
+
for (const d of drafts) {
|
|
659
|
+
if (!d.intent) continue;
|
|
660
|
+
const intent = d.intent;
|
|
661
|
+
/** @type {string[]} */
|
|
662
|
+
const unmet = [];
|
|
663
|
+
d.options = d.options.filter(o => {
|
|
664
|
+
const why = env.measure(o, intent);
|
|
665
|
+
for (const st of o) (why ? dropped : kept).add(key(st));
|
|
666
|
+
if (why) unmet.push(why);
|
|
667
|
+
return !why;
|
|
668
|
+
});
|
|
669
|
+
unmetOf.set(d, unmet);
|
|
670
|
+
}
|
|
603
671
|
for (const d of drafts) {
|
|
672
|
+
if (!d.intent && dropped.size) {
|
|
673
|
+
d.options = d.options
|
|
674
|
+
.map(o => o.filter(st => !dropped.has(key(st)) || kept.has(key(st))))
|
|
675
|
+
.filter(o => o.length);
|
|
676
|
+
// A joined answer left holding what another answer already says is
|
|
677
|
+
// that answer: it is not given twice (and never as "all of it").
|
|
678
|
+
const same = (/** @type {import('./_how-commands.mjs').Step[]} */ o) =>
|
|
679
|
+
drafts.some(
|
|
680
|
+
x =>
|
|
681
|
+
x !== d &&
|
|
682
|
+
x.options.some(
|
|
683
|
+
y =>
|
|
684
|
+
y.length === o.length &&
|
|
685
|
+
y.every((st, i) => key(st) === key(o[i])),
|
|
686
|
+
),
|
|
687
|
+
);
|
|
688
|
+
if (d.options.length && d.options.every(same)) continue;
|
|
689
|
+
}
|
|
690
|
+
// The measured check: an option whose built result does not do what
|
|
691
|
+
// the question asks is left out, with a plain line saying why.
|
|
692
|
+
const unmet = unmetOf.get(d) ?? [];
|
|
693
|
+
if (unmet.length) {
|
|
694
|
+
if (unmet.length && !d.options.length)
|
|
695
|
+
d.text = `couldn't work out a command that does "${d.text}" as asked: ${[...new Set(unmet)].join('; ')}`;
|
|
696
|
+
else if (unmet.length)
|
|
697
|
+
d.text = `${d.text} (left out: ${[...new Set(unmet)].join('; ')})`;
|
|
698
|
+
}
|
|
604
699
|
const {commands, refused} = checked(env, d.options);
|
|
605
700
|
const lookups = d.lookup ? [d.lookup] : [];
|
|
701
|
+
if (!commands.length && !d.options.length && unmet.length) {
|
|
702
|
+
out.push({text: d.text, commands: lookups});
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
606
705
|
if (!commands.length && d.options.length && !lookups.length) {
|
|
607
706
|
out.push({
|
|
608
707
|
text: `${d.text}: no command does it on ${env.slug}${refused[0] ? `: ${refused[0].why}` : ''}`,
|
|
@@ -1094,7 +1193,8 @@ function toolAnswer(t, env, targets) {
|
|
|
1094
1193
|
},
|
|
1095
1194
|
];
|
|
1096
1195
|
if (
|
|
1097
|
-
|
|
1196
|
+
// A question about a part's value now is answered with that value.
|
|
1197
|
+
(asks && !valueAsked(q)) ||
|
|
1098
1198
|
/^which parts (are|does|do)\b/.test(q) ||
|
|
1099
1199
|
(/^why (is|are|does|do)\b/.test(q) && !/\bnot\b|n'?t\b/.test(q))
|
|
1100
1200
|
) {
|
|
@@ -2,12 +2,38 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* The marks a file's leading comment can carry, and the command it names:
|
|
6
|
+
* `kind` is `build` for a theme build's output, `editor` for a file the theme
|
|
7
|
+
* editor writes (its settings module or app copy); `command` is the words in
|
|
8
|
+
* backquotes after "Written by" or "Generated by" (for a build, the build
|
|
9
|
+
* command). Null for a file without one. One reader for every caller.
|
|
10
|
+
* A mark written before files named their exact command carries the editor
|
|
11
|
+
* group's words alone, which only print its help: given the file's path,
|
|
12
|
+
* the command is the one that writes that theme's files again (`show`, with
|
|
13
|
+
* the theme its folder is named for).
|
|
14
|
+
* @param {string} source the start of the file
|
|
15
|
+
* @param {string} buildMarker the theme build's own marker
|
|
16
|
+
* @param {string} [file] the file's path
|
|
17
|
+
* @returns {{kind: 'build' | 'editor', command: string} | null}
|
|
18
|
+
*/
|
|
19
|
+
export function generatedMark(source: string, buildMarker: string, file?: string): {
|
|
20
|
+
kind: "build" | "editor";
|
|
21
|
+
command: string;
|
|
22
|
+
} | null;
|
|
23
|
+
/**
|
|
24
|
+
* @file The marks the theme editor writes at the top of the files it
|
|
25
|
+
* generates, and the one reader of every generated mark (a theme build's
|
|
26
|
+
* included) that the editor, `theme build` and doctor share.
|
|
7
27
|
*
|
|
8
28
|
* @position api/theme-edit — internal
|
|
9
29
|
*/
|
|
10
30
|
/** The first words of a generated settings module the editor writes. */
|
|
11
|
-
export const EDITOR_GENERATED_MARK: "Generated by `astryx experimental theme editor
|
|
12
|
-
/**
|
|
13
|
-
|
|
31
|
+
export const EDITOR_GENERATED_MARK: "Generated by `astryx experimental theme editor";
|
|
32
|
+
/**
|
|
33
|
+
* The words on every file of a theme's app copy (src/themes/<theme>/): the
|
|
34
|
+
* start of "Written by `<the command that writes it>`", which a reader takes
|
|
35
|
+
* whole. A copy written before the command was named carries the group's
|
|
36
|
+
* words alone; both begin so.
|
|
37
|
+
*/
|
|
38
|
+
export const APP_COPY_MARK: "Written by `astryx experimental theme editor";
|
|
39
|
+
export function appCopyMark(slug: string): string;
|
|
@@ -1,15 +1,67 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file The
|
|
5
|
-
* generates,
|
|
4
|
+
* @file The marks the theme editor writes at the top of the files it
|
|
5
|
+
* generates, and the one reader of every generated mark (a theme build's
|
|
6
|
+
* included) that the editor, `theme build` and doctor share.
|
|
6
7
|
*
|
|
7
8
|
* @position api/theme-edit — internal
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
/** The first words of a generated settings module the editor writes. */
|
|
11
12
|
export const EDITOR_GENERATED_MARK =
|
|
12
|
-
'Generated by `astryx experimental theme editor
|
|
13
|
+
'Generated by `astryx experimental theme editor';
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The words on every file of a theme's app copy (src/themes/<theme>/): the
|
|
17
|
+
* start of "Written by `<the command that writes it>`", which a reader takes
|
|
18
|
+
* whole. A copy written before the command was named carries the group's
|
|
19
|
+
* words alone; both begin so.
|
|
20
|
+
*/
|
|
21
|
+
export const APP_COPY_MARK = 'Written by `astryx experimental theme editor';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The mark an app copy's files carry, naming the command that writes them.
|
|
25
|
+
* @param {string} slug
|
|
26
|
+
*/
|
|
27
|
+
export const appCopyMark = slug =>
|
|
28
|
+
`Written by \`astryx experimental theme editor show ${slug}\``;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The marks a file's leading comment can carry, and the command it names:
|
|
32
|
+
* `kind` is `build` for a theme build's output, `editor` for a file the theme
|
|
33
|
+
* editor writes (its settings module or app copy); `command` is the words in
|
|
34
|
+
* backquotes after "Written by" or "Generated by" (for a build, the build
|
|
35
|
+
* command). Null for a file without one. One reader for every caller.
|
|
36
|
+
* A mark written before files named their exact command carries the editor
|
|
37
|
+
* group's words alone, which only print its help: given the file's path,
|
|
38
|
+
* the command is the one that writes that theme's files again (`show`, with
|
|
39
|
+
* the theme its folder is named for).
|
|
40
|
+
* @param {string} source the start of the file
|
|
41
|
+
* @param {string} buildMarker the theme build's own marker
|
|
42
|
+
* @param {string} [file] the file's path
|
|
43
|
+
* @returns {{kind: 'build' | 'editor', command: string} | null}
|
|
44
|
+
*/
|
|
45
|
+
export function generatedMark(source, buildMarker, file) {
|
|
46
|
+
const leading =
|
|
47
|
+
/^\s*(?:\/\*[\s\S]*?\*\/|(?:\/\/[^\n]*(?:\n|$)\s*)+)/.exec(source)?.[0] ??
|
|
48
|
+
'';
|
|
49
|
+
if (leading.includes(buildMarker))
|
|
50
|
+
return {kind: 'build', command: 'astryx theme build'};
|
|
51
|
+
if (![APP_COPY_MARK, EDITOR_GENERATED_MARK].some(m => leading.includes(m)))
|
|
52
|
+
return null;
|
|
53
|
+
const named = /(?:Written|Generated) by `([^`]+)`/.exec(leading)?.[1];
|
|
54
|
+
const group = 'astryx experimental theme editor';
|
|
55
|
+
if (named && named.trim() !== group) return {kind: 'editor', command: named};
|
|
56
|
+
// A group-only mark: the theme's own command, from its folder's name.
|
|
57
|
+
const slug = file
|
|
58
|
+
? String(file).split(/[\\/]/).filter(Boolean).slice(-2)[0]
|
|
59
|
+
: null;
|
|
60
|
+
return {
|
|
61
|
+
kind: 'editor',
|
|
62
|
+
command:
|
|
63
|
+
slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)
|
|
64
|
+
? `${group} show ${slug}`
|
|
65
|
+
: 'the command that made it',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A value as CSS reads it, for every value type: every Unicode space
|
|
6
|
+
* (no-break, thin, ideographic…) a plain space and zero-width and format
|
|
7
|
+
* characters dropped, and quotes that delimit a value (curly ones, «», ‹›,
|
|
8
|
+
* full-width, backticks) straight. A straight-quoted CSS string keeps what
|
|
9
|
+
* it holds as written (`content: "it’s"`). Curly quotes pair by kind
|
|
10
|
+
* (double with double, single with single, in any of their shapes: „Inter“,
|
|
11
|
+
* ‚Inter‘); one left unpaired is read as the straight quote it stands for.
|
|
12
|
+
* @param {string} v
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export function normalValueText(v: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* A value as meant when typed with escapes or in another notation: CSS
|
|
18
|
+
* function names in lower case (`LIGHT-DARK(` is `light-dark(`, as CSS reads
|
|
19
|
+
* it); a shell or JSON backslash before `#`, a quote or a space taken off;
|
|
20
|
+
* a JavaScript escape in a `content` string written as CSS writes it
|
|
21
|
+
* (`\u2022` is `\2022 `, `\n` a line break, `\t` a tab); and the JSON
|
|
22
|
+
* shapes a design-tokens file or an array writes (`{"$value": "#e11d48"}`,
|
|
23
|
+
* `{"value": 18, "unit": "px"}`, `["#e11d48"]`, `["Inter", "sans-serif"]`).
|
|
24
|
+
* @param {string} thing
|
|
25
|
+
* @param {string} value
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
export function escapesMeant(thing: string, value: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* The thing and value a setting was typed as, put right before any check: a
|
|
31
|
+
* declaration pasted whole or split (`accent: #e11d48`, `--color-accent=red`,
|
|
32
|
+
* `font:inter`, `accent:` with the value next), a token typed with an em or
|
|
33
|
+
* en dash (`—color-accent`) or as `var(--color-accent)`, and the value's
|
|
34
|
+
* Unicode spaces. A thing it cannot read is left as typed.
|
|
35
|
+
* @param {string} thing
|
|
36
|
+
* @param {string | undefined} value
|
|
37
|
+
* @returns {{thing: string, value: string | undefined, dropped?: string}} `dropped`: a second declaration pasted after the first, which is not set
|
|
38
|
+
*/
|
|
39
|
+
export function normalizeEntry(thing: string, value: string | undefined): {
|
|
40
|
+
thing: string;
|
|
41
|
+
value: string | undefined;
|
|
42
|
+
dropped?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* A font stack's pieces, split on the commas outside quotes, with each
|
|
46
|
+
* piece's name and whether it was quoted; null when a quote is left open.
|
|
47
|
+
* @param {string} v
|
|
48
|
+
* @returns {Array<{name: string, quoted: boolean}> | null}
|
|
49
|
+
*/
|
|
50
|
+
export function familyPieces(v: string): Array<{
|
|
51
|
+
name: string;
|
|
52
|
+
quoted: boolean;
|
|
53
|
+
}> | null;
|
|
54
|
+
/**
|
|
55
|
+
* The families a typed font stack names: a trailing comma and empty pieces
|
|
56
|
+
* dropped, and a stack wrapped in one more pair of the quotes it uses
|
|
57
|
+
* inside (`""SF Mono", Monaco, monospace"`, as a JSON string) unwrapped.
|
|
58
|
+
* Null when the stack does not read.
|
|
59
|
+
* @param {string} v
|
|
60
|
+
* @returns {string[] | null}
|
|
61
|
+
*/
|
|
62
|
+
export function familiesOf(v: string): string[] | null;
|
|
63
|
+
/**
|
|
64
|
+
* A value with the debris of a bad copy taken off: a leading `=` or `:`, a
|
|
65
|
+
* trailing comma (a JSON or CSS list), and a quote or a closing bracket left
|
|
66
|
+
* over at either end. A value without any is returned as it was.
|
|
67
|
+
* @param {string} v
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
export function withoutDebris(v: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* A value without a second declaration pasted after it (`#e11d48;
|
|
73
|
+
* text-size: 18`): cut at the first `;` outside quotes that a `name:`
|
|
74
|
+
* follows. A `;` inside a quoted string (`"Tip; note: x"`) is the string's.
|
|
75
|
+
* @param {string} v
|
|
76
|
+
* @returns {string}
|
|
77
|
+
*/
|
|
78
|
+
export function withoutSecondDeclaration(v: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* A saved dial value read as typed input is (invisible or stray spaces,
|
|
81
|
+
* quotes around it, a pasted `corners: pill`, a trailing `;`, other
|
|
82
|
+
* letters): the value the dial may have meant.
|
|
83
|
+
* @param {string} dial
|
|
84
|
+
* @param {string} value
|
|
85
|
+
* @returns {string}
|
|
86
|
+
*/
|
|
87
|
+
export function cleanDialValue(dial: string, value: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* A value with the spaces just inside each straight-quoted string taken off
|
|
90
|
+
* (`" Inter "` is "Inter"), for a font family, whose name holds none there.
|
|
91
|
+
* @param {string} v
|
|
92
|
+
* @returns {string}
|
|
93
|
+
*/
|
|
94
|
+
export function trimInsideQuotes(v: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* The other setting a dial's value is labeled with, when pasted with a
|
|
97
|
+
* label that names a different dial or a token (`neutral: #64748b` given
|
|
98
|
+
* to accent): that label and the value after it, else null. A label that
|
|
99
|
+
* names this dial, or a CSS property (`color: #e11d48`), is no other
|
|
100
|
+
* setting.
|
|
101
|
+
* @param {string} dial
|
|
102
|
+
* @param {string} value
|
|
103
|
+
* @returns {{thing: string, value: string} | null}
|
|
104
|
+
*/
|
|
105
|
+
export function otherSettingLabel(dial: string, value: string): {
|
|
106
|
+
thing: string;
|
|
107
|
+
value: string;
|
|
108
|
+
} | null;
|
|
109
|
+
/**
|
|
110
|
+
* A light and a dark color typed as a pair: labeled (`light: red; dark:
|
|
111
|
+
* blue`), a JSON object (`{"light": "red", "dark": "blue"}`), or two colors
|
|
112
|
+
* with a slash or a comma between (`red / blue`, `red, blue`). Null when the
|
|
113
|
+
* value is no such pair; the caller checks that both are colors.
|
|
114
|
+
* @param {string} value
|
|
115
|
+
* @returns {{light: string, dark: string} | null}
|
|
116
|
+
*/
|
|
117
|
+
export function colorPair(value: string): {
|
|
118
|
+
light: string;
|
|
119
|
+
dark: string;
|
|
120
|
+
} | null;
|
|
121
|
+
/**
|
|
122
|
+
* Whether a suggested value carries what was typed: each of its words and
|
|
123
|
+
* numbers is in the typed text (cleaned: case, quotes, escapes), apart from
|
|
124
|
+
* a unit added to a bare number and the words of the CSS form it is written
|
|
125
|
+
* in (`light-dark()`, `var()`, `calc()`, a generic family). A stock value
|
|
126
|
+
* the input never held (a gray, a violet, `system`, `small`) does not.
|
|
127
|
+
* @param {string} offered
|
|
128
|
+
* @param {string} typed
|
|
129
|
+
*/
|
|
130
|
+
export function carriesTyped(offered: string, typed: string): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Whether a typed word is a typo of a word: both words of four letters or
|
|
133
|
+
* more, within one edit for a typed word of five letters or fewer and two
|
|
134
|
+
* for a longer one (`nnone` is none, `normall` normal; `line` is no none).
|
|
135
|
+
* @param {string} typed
|
|
136
|
+
* @param {string} word
|
|
137
|
+
*/
|
|
138
|
+
export function typoOf(typed: string, word: string): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Whether `word` is within the typo limit of `typed` (two letters swapped
|
|
141
|
+
* count as one edit, as typed: flxe is flex).
|
|
142
|
+
* @param {string} typed
|
|
143
|
+
* @param {string} word
|
|
144
|
+
*/
|
|
145
|
+
export function typoNear(typed: string, word: string): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* The stock values a repair would put in when it could read nothing from
|
|
148
|
+
* the input: the example of each value type, and the dials' defaults. A
|
|
149
|
+
* line with one of these is offered only when the input held it.
|
|
150
|
+
*/
|
|
151
|
+
export const STOCK_VALUES: Set<string>;
|
|
152
|
+
export function offersTyped(offered: string, typed: string): boolean;
|
|
153
|
+
export function typoLimit(typed: string): 1 | 2;
|