@astryxdesign/cli 0.7.17 → 0.7.18-canary.g6dfc0b6
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 +1 -1
- package/api/discover/_adapter.d.mts +7 -5
- package/api/discover/_adapter.mjs +12 -11
- package/api/doctor/_adapter.d.mts +11 -62
- package/api/doctor/_adapter.mjs +242 -472
- package/api/doctor/doctor.d.mts +1 -1
- package/api/doctor/doctor.mjs +1 -1
- package/api/doctor/theme-checks.mjs +37 -45
- package/api/error.d.mts +21 -0
- package/api/error.mjs +89 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/icon.doc.mjs +1 -1
- package/api/icon/icon.type.mjs +1 -1
- package/api/icon/search/search.d.mts +4 -1
- package/api/icon/search/search.mjs +41 -4
- package/api/render/_adapter.mjs +233 -40
- package/api/render/render.type.d.mts +1 -1
- package/api/render/render.type.mjs +1 -1
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.mjs +32 -8
- package/api/search/_cards.json +1 -1
- package/api/search/_compound.d.mts +0 -1
- package/api/search/_compound.mjs +93 -2
- package/api/search/_lexical.mjs +177 -17
- package/api/search/_order.d.mts +3 -1
- package/api/search/_order.mjs +16 -5
- package/api/search/_result.d.mts +9 -0
- package/api/search/_result.mjs +10 -0
- package/api/search/_score.mjs +21 -3
- package/api/swizzle/_moduleGraph.d.mts +8 -0
- package/api/swizzle/_moduleGraph.mjs +61 -3
- package/api/template/copy/copy.mjs +5 -3
- package/api/theme/_adapter.mjs +48 -12
- package/api/theme/build/build.d.mts +4 -0
- package/api/theme/build/build.mjs +69 -18
- package/api/theme/build/style-keys.mjs +4 -5
- package/api/theme/build/theme-object.mjs +5 -0
- package/api/theme/palette/generate/color.d.mts +47 -0
- package/api/theme/palette/generate/color.mjs +58 -1
- package/api/theme/palette/generate/derive-look.d.mts +293 -0
- package/api/theme/palette/generate/derive-look.mjs +1362 -0
- package/api/theme/palette/generate/editor-look.d.mts +62 -0
- package/api/theme/palette/generate/editor-look.mjs +550 -0
- package/api/theme/palette/generate/mapping.d.mts +94 -9
- package/api/theme/palette/generate/mapping.mjs +94 -22
- package/api/theme-edit/_adapter.mjs +10 -1
- package/api/theme-edit/_catalog.d.mts +13 -13
- package/api/theme-edit/_catalog.mjs +38 -16
- package/api/theme-edit/_check.d.mts +82 -6
- package/api/theme-edit/_check.mjs +1230 -223
- package/api/theme-edit/_color.d.mts +74 -0
- package/api/theme-edit/_color.mjs +168 -3
- package/api/theme-edit/_compiler.d.mts +3 -5
- package/api/theme-edit/_compiler.mjs +122 -23
- package/api/theme-edit/_context.d.mts +46 -5
- package/api/theme-edit/_context.mjs +97 -49
- package/api/theme-edit/_css.d.mts +11 -0
- package/api/theme-edit/_css.mjs +40 -0
- package/api/theme-edit/_edit.d.mts +13 -0
- package/api/theme-edit/_edit.mjs +1450 -128
- package/api/theme-edit/_how-commands.d.mts +12 -0
- package/api/theme-edit/_how-commands.mjs +96 -14
- package/api/theme-edit/_how-question.d.mts +73 -29
- package/api/theme-edit/_how-question.mjs +8131 -1209
- package/api/theme-edit/_how-sides.d.mts +22 -0
- package/api/theme-edit/_how-sides.mjs +173 -0
- package/api/theme-edit/_how-steps.d.mts +42 -0
- package/api/theme-edit/_how-steps.mjs +208 -0
- package/api/theme-edit/_how-values.d.mts +29 -0
- package/api/theme-edit/_how-values.mjs +111 -0
- package/api/theme-edit/_how-words.d.mts +15 -0
- package/api/theme-edit/_how-words.mjs +239 -0
- package/api/theme-edit/_how.d.mts +1 -1
- package/api/theme-edit/_how.mjs +412 -37
- package/api/theme-edit/_missed.d.mts +2 -1
- package/api/theme-edit/_missed.mjs +125 -13
- package/api/theme-edit/_normal.d.mts +5 -3
- package/api/theme-edit/_normal.mjs +54 -14
- package/api/theme-edit/_palette.d.mts +204 -4
- package/api/theme-edit/_palette.mjs +901 -25
- package/api/theme-edit/_part-pieces.d.mts +54 -0
- package/api/theme-edit/_part-pieces.mjs +179 -0
- package/api/theme-edit/_part-words.mjs +33 -5
- package/api/theme-edit/_parts.d.mts +133 -0
- package/api/theme-edit/_parts.mjs +599 -10
- package/api/theme-edit/_picture-traits.d.mts +259 -0
- package/api/theme-edit/_picture-traits.mjs +1030 -0
- package/api/theme-edit/_preview.d.mts +84 -4
- package/api/theme-edit/_preview.mjs +260 -24
- package/api/theme-edit/_project.d.mts +14 -4
- package/api/theme-edit/_project.mjs +95 -26
- package/api/theme-edit/_set-line.d.mts +29 -0
- package/api/theme-edit/_set-line.mjs +100 -0
- package/api/theme-edit/_settings.d.mts +625 -28
- package/api/theme-edit/_settings.mjs +4587 -880
- package/api/theme-edit/_tables.d.mts +25 -1
- package/api/theme-edit/_tables.mjs +115 -11
- package/api/theme-edit/_text-looks.d.mts +78 -0
- package/api/theme-edit/_text-looks.mjs +376 -0
- package/api/theme-edit/_vet.d.mts +3 -26
- package/api/theme-edit/_vet.mjs +5 -89
- package/api/theme-edit/how/how.d.mts +1 -1
- package/api/theme-edit/how/how.mjs +1 -1
- package/api/theme-edit/theme-edit.type.d.mts +54 -1
- package/api/theme-edit/theme-edit.type.mjs +17 -2
- package/api/theme-edit/themeEditHow.doc.mjs +3 -3
- package/api/theme-edit/themeEditNew.doc.mjs +4 -0
- package/api/theme-edit/themeEditSet.doc.mjs +6 -2
- package/api/theme-edit/themeEditShow.doc.mjs +4 -0
- package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/author-a-theme.doc.mjs +7 -4
- package/assets/docs/tree/export-pages.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +89 -17
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/article.doc.mjs +9 -0
- package/assets/icons/template-icons.json +5 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ide/page.tsx +5 -10
- package/assets/templates/pages/payment-form/page.tsx +16 -60
- package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +13 -13
- package/authoring/gap-report/parse.d.mts +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/ensure-core-built.mjs +17 -10
- package/clients/cli/commands/experimental/theme.mjs +46 -6
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
- package/clients/cli/commands/experimental-theme-editor-set.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/hook.mjs +7 -0
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/index.mjs +6 -2
- package/clients/cli/lib/hook-format.mjs +41 -1
- package/clients/cli/lib/json-shim.mjs +34 -14
- package/clients/cli/lib/other-cli-words.mjs +7 -0
- package/clients/cli/lib/unknown-command.mjs +345 -46
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +11 -2
- package/foundation/agent-docs/agent-docs.mjs +51 -8
- package/foundation/config/project.d.mts +11 -1
- package/foundation/config/project.mjs +11 -2
- package/foundation/discovery/component-replacement.d.mts +5 -8
- package/foundation/discovery/component-replacement.mjs +12 -14
- package/foundation/discovery/core-augmentation-points.d.mts +35 -0
- package/foundation/discovery/core-augmentation-points.mjs +410 -9
- package/foundation/discovery/core-elements.d.mts +6 -0
- package/foundation/discovery/core-elements.mjs +10 -2
- package/foundation/discovery/core-prop-types.d.mts +5 -0
- package/foundation/discovery/core-prop-types.mjs +10 -3
- package/foundation/discovery/core-props.d.mts +8 -0
- package/foundation/discovery/core-props.mjs +29 -13
- package/foundation/discovery/official-list.d.mts +17 -0
- package/foundation/discovery/official-list.mjs +77 -0
- package/foundation/discovery/unknown-core-props.d.mts +130 -0
- package/foundation/discovery/unknown-core-props.mjs +601 -0
- package/foundation/discovery/written-prop-values.d.mts +35 -0
- package/foundation/discovery/written-prop-values.mjs +258 -0
- package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
- package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
- package/foundation/fs/package-name.d.mts +10 -0
- package/foundation/fs/package-name.mjs +37 -0
- package/foundation/fs/project-source-files.d.mts +27 -0
- package/foundation/fs/project-source-files.mjs +115 -0
- package/foundation/fs/project-sources.d.mts +25 -0
- package/foundation/fs/project-sources.mjs +83 -0
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +36 -2
- package/foundation/integrations/integration-warnings.d.mts +39 -7
- package/foundation/integrations/integration-warnings.mjs +141 -19
- package/foundation/integrations/missing-dependency.d.mts +11 -0
- package/foundation/integrations/missing-dependency.mjs +20 -5
- package/foundation/release/folder-lock.d.mts +5 -2
- package/foundation/release/folder-lock.mjs +9 -3
- package/foundation/release/notices.mjs +2 -8
- package/foundation/render/cut-short.d.mts +8 -2
- package/foundation/render/cut-short.mjs +50 -5
- package/foundation/render/drawn-contrast.d.mts +38 -0
- package/foundation/render/drawn-contrast.mjs +237 -0
- package/foundation/render/file-header.mjs +4 -0
- package/foundation/render/layers.d.mts +2 -1
- package/foundation/render/layers.mjs +22 -1
- package/foundation/render/page-worker.mjs +83 -18
- package/foundation/render/part-boxes.d.mts +27 -0
- package/foundation/render/part-boxes.mjs +45 -0
- package/foundation/render/picture-chrome.mjs +36 -4
- package/foundation/render/picture-playwright.mjs +26 -2
- package/foundation/render/picture-window.d.mts +29 -2
- package/foundation/render/picture-window.mjs +99 -1
- package/foundation/render/render-page.d.mts +39 -6
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.mjs +2 -1
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/written-string.d.mts +4 -1
- package/foundation/text/written-string.mjs +4 -1
- package/package.json +8 -7
|
@@ -55,7 +55,9 @@ import {importSpecifiers, moduleImports} from './embedded-imports.mjs';
|
|
|
55
55
|
import {sha256} from './source-block.mjs';
|
|
56
56
|
import {BundleError, CARRIED_MODULE, bundleForBrowser} from './client-bundle.mjs';
|
|
57
57
|
import {droppedImports, importUses} from './value-uses.mjs';
|
|
58
|
-
import {coreComponentOf} from '../discovery/core-elements.mjs';
|
|
58
|
+
import {OTHER_JSX_RUNTIME, coreComponentOf} from '../discovery/core-elements.mjs';
|
|
59
|
+
import {corePropUsesOf} from '../discovery/core-props.mjs';
|
|
60
|
+
import {writtenValue} from '../discovery/written-prop-values.mjs';
|
|
59
61
|
import {CHART_GLOBAL, CHART_ROOTS, FOLLOWS_WIDTH, boxHeights, chartDocument, chartDrawings, foldLegends, roundCoordinates, separateIds} from './charts.mjs';
|
|
60
62
|
import {LAYER_GLOBAL, LAYER_PLACEHOLDER, countQueuedImmediates, layerDocument, layerPlaceholder, openLayerMarkup, settled} from './layers.mjs';
|
|
61
63
|
|
|
@@ -183,11 +185,20 @@ const texts = [];
|
|
|
183
185
|
/** @type {Record<string, string[]>} */
|
|
184
186
|
const fnTexts = {};
|
|
185
187
|
/**
|
|
186
|
-
*
|
|
187
|
-
* (`<Button variant="danger"
|
|
188
|
-
*
|
|
188
|
+
* What a page's own file certainly gives a Core component's prop
|
|
189
|
+
* (`<Button variant="danger">`, each branch of
|
|
190
|
+
* `variant={busy ? 'ghost' : 'danger'}`, `status="error"`), for the
|
|
191
|
+
* unknown-prop-value warning.
|
|
192
|
+
* @type {(import('../discovery/written-prop-values.mjs').WrittenValue & {component: string, prop: string, file: string, line: number})[]}
|
|
189
193
|
*/
|
|
190
194
|
const propValues = [];
|
|
195
|
+
/**
|
|
196
|
+
* Each prop a page's own file gives a Core component by name, for the
|
|
197
|
+
* unknown-prop warning; a file that compiles its JSX with another runtime
|
|
198
|
+
* gives none.
|
|
199
|
+
* @type {(import('../discovery/core-props.mjs').CorePropUse & {file: string, element: {line: number, column: number}})[]}
|
|
200
|
+
*/
|
|
201
|
+
const propNames = [];
|
|
191
202
|
/** Each media query the page's own code asks in JavaScript, for the screen-query warning. */
|
|
192
203
|
/** @type {{call: string, file: string, line: number}[]} */
|
|
193
204
|
const screenQueries = [];
|
|
@@ -621,6 +632,49 @@ async function drawCharts(markup, Page) {
|
|
|
621
632
|
};
|
|
622
633
|
}
|
|
623
634
|
|
|
635
|
+
/**
|
|
636
|
+
* The markup of a part's open layers. A layer opened from inside another
|
|
637
|
+
* (its opener, the control naming it in aria-controls, sits in that layer:
|
|
638
|
+
* a submenu's flyout) is drawn once, beside the layer it opens from, in a
|
|
639
|
+
* row with it, as a browser places it; never again inside that layer, where
|
|
640
|
+
* the document holds it too.
|
|
641
|
+
* @param {any[]} open the open layers, in the order they opened
|
|
642
|
+
* @returns {string}
|
|
643
|
+
*/
|
|
644
|
+
function nestedLayers(open) {
|
|
645
|
+
/** @param {any} layer */
|
|
646
|
+
const parentOf = layer => {
|
|
647
|
+
const ids = new Set(
|
|
648
|
+
[layer, ...layer.querySelectorAll('[id]')].map(e => e.id).filter(Boolean),
|
|
649
|
+
);
|
|
650
|
+
return (
|
|
651
|
+
open.find(
|
|
652
|
+
other =>
|
|
653
|
+
other !== layer &&
|
|
654
|
+
!layer.contains(other) &&
|
|
655
|
+
[...other.querySelectorAll('[aria-controls]')].some(c =>
|
|
656
|
+
ids.has(c.getAttribute('aria-controls')),
|
|
657
|
+
),
|
|
658
|
+
) ?? null
|
|
659
|
+
);
|
|
660
|
+
};
|
|
661
|
+
const parents = new Map(open.map(layer => [layer, parentOf(layer)]));
|
|
662
|
+
/** @param {any} layer @returns {string} */
|
|
663
|
+
const draw = layer => {
|
|
664
|
+
const kids = open.filter(o => parents.get(o) === layer);
|
|
665
|
+
if (!kids.length) return layer.outerHTML;
|
|
666
|
+
const own = layer.cloneNode(true);
|
|
667
|
+
for (const inner of own.querySelectorAll('[data-astryx-layer-root]'))
|
|
668
|
+
inner.remove();
|
|
669
|
+
return `<div data-astryx-layer-nest="">${own.outerHTML}${kids.map(draw).join('')}</div>`;
|
|
670
|
+
};
|
|
671
|
+
return open
|
|
672
|
+
.filter(layer => !parents.get(layer))
|
|
673
|
+
.map(draw)
|
|
674
|
+
.join('');
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
|
|
624
678
|
/**
|
|
625
679
|
* Parts the page asked to be drawn, in the order asked: open (`ifOpen`: drawn
|
|
626
680
|
* as nothing when nothing opens), or `mounted`, as the browser shows the part
|
|
@@ -725,10 +779,12 @@ async function drawLayers(markup, server) {
|
|
|
725
779
|
);
|
|
726
780
|
if (open.length) {
|
|
727
781
|
// The part as drawn, then each overlay open now, after it; never a
|
|
728
|
-
// closed one, nor the markers that place them.
|
|
782
|
+
// closed one, nor the markers that place them. A layer opened from
|
|
783
|
+
// inside another (a submenu's flyout) is drawn beside the layer it
|
|
784
|
+
// opens from, as a browser places it.
|
|
729
785
|
const part = host.cloneNode(true);
|
|
730
786
|
for (const layer of part.querySelectorAll('[data-astryx-layer-root]')) layer.remove();
|
|
731
|
-
out = part.innerHTML.replace(/<template><\/template>/g, '') + open
|
|
787
|
+
out = part.innerHTML.replace(/<template><\/template>/g, '') + nestedLayers(open);
|
|
732
788
|
}
|
|
733
789
|
}
|
|
734
790
|
} catch {
|
|
@@ -798,7 +854,11 @@ async function drawOpenLayers(elements, React) {
|
|
|
798
854
|
flushSync(() => root.render(createElement(Alone, null, element)));
|
|
799
855
|
// (A part that opens nothing on a press and holds a layer, a context
|
|
800
856
|
// menu's area, is right-clicked, as one drawn in its own place is.)
|
|
801
|
-
|
|
857
|
+
// A layer opened from inside another is drawn beside it (nestedLayers).
|
|
858
|
+
const box = g.document.createElement('div');
|
|
859
|
+
box.innerHTML = (await openLayerMarkup(host, flushSync)).join('');
|
|
860
|
+
const drawn = nestedLayers([...box.children]);
|
|
861
|
+
if (drawn) layers.push(drawn);
|
|
802
862
|
} catch {
|
|
803
863
|
// A part that cannot be drawn there adds no overlays.
|
|
804
864
|
}
|
|
@@ -1126,8 +1186,11 @@ function carriedName(p, t) {
|
|
|
1126
1186
|
* recorded it already.
|
|
1127
1187
|
* @param {string} filename
|
|
1128
1188
|
* @param {boolean} [browser]
|
|
1189
|
+
* @param {boolean} [reactJsx] whether the module compiles its JSX with
|
|
1190
|
+
* React's runtime, so its Core props are recorded for the unknown-prop
|
|
1191
|
+
* warning
|
|
1129
1192
|
*/
|
|
1130
|
-
function pagePlugin(filename, browser = false) {
|
|
1193
|
+
function pagePlugin(filename, browser = false, reactJsx = true) {
|
|
1131
1194
|
const dir = path.dirname(filename);
|
|
1132
1195
|
/**
|
|
1133
1196
|
* Record an https image address the page builds in code (a template with
|
|
@@ -1319,16 +1382,17 @@ function pagePlugin(filename, browser = false) {
|
|
|
1319
1382
|
if (browser) return;
|
|
1320
1383
|
const component = coreComponentOf(p.node.name, p.scope);
|
|
1321
1384
|
if (!component) return;
|
|
1322
|
-
|
|
1385
|
+
const attrs = p.node.attributes;
|
|
1386
|
+
// A spread after an attribute can replace its value.
|
|
1387
|
+
const lastSpread = attrs.findLastIndex((/** @type {any} */ a) => a.type === 'JSXSpreadAttribute');
|
|
1388
|
+
for (const attr of attrs.slice(lastSpread + 1)) {
|
|
1323
1389
|
if (attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') continue;
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
if (value === null) continue;
|
|
1331
|
-
propValues.push({component, prop: attr.name.name, value, file: filename, line: attr.loc?.start.line ?? 0});
|
|
1390
|
+
const written = writtenValue(attr, p.scope);
|
|
1391
|
+
if (written) propValues.push({component, prop: attr.name.name, ...written, file: filename, line: attr.loc?.start.line ?? 0});
|
|
1392
|
+
}
|
|
1393
|
+
if (reactJsx) {
|
|
1394
|
+
const element = {line: p.node.loc?.start.line ?? 0, column: (p.node.loc?.start.column ?? 0) + 1};
|
|
1395
|
+
for (const use of corePropUsesOf(p)) propNames.push({...use, file: filename, element});
|
|
1332
1396
|
}
|
|
1333
1397
|
},
|
|
1334
1398
|
JSXText(/** @type {any} */ p) {
|
|
@@ -1754,7 +1818,7 @@ function compilePageModule(source, filename, browser = false) {
|
|
|
1754
1818
|
compact: false,
|
|
1755
1819
|
plugins: [
|
|
1756
1820
|
aliasPlugin(),
|
|
1757
|
-
pagePlugin(filename, browser),
|
|
1821
|
+
pagePlugin(filename, browser, !OTHER_JSX_RUNTIME.test(source)),
|
|
1758
1822
|
...(source.includes('stylex') ? [stylexPluginFor(source, filename)] : []),
|
|
1759
1823
|
],
|
|
1760
1824
|
});
|
|
@@ -2585,6 +2649,7 @@ try {
|
|
|
2585
2649
|
remoteNamedOnly: [...namedOnlyLiterals].filter(url => !placedLiterals.has(url)),
|
|
2586
2650
|
builtRemote,
|
|
2587
2651
|
propValues: propValues.map(v => ({...v, file: path.relative(path.dirname(entry), v.file).split(path.sep).join('/')})),
|
|
2652
|
+
propNames,
|
|
2588
2653
|
logs,
|
|
2589
2654
|
script: script?.code ?? null,
|
|
2590
2655
|
scriptModules: script?.modules ?? 0,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The width and height of every drawn element of each part named, in page
|
|
6
|
+
* order, to a hundredth of a pixel. An element that is not drawn (no box,
|
|
7
|
+
* hidden, `display: contents`) is left out.
|
|
8
|
+
* Runs in the page: it uses nothing from outside its own body.
|
|
9
|
+
* @param {string[]} parts
|
|
10
|
+
* @returns {Record<string, Array<[number, number]>>}
|
|
11
|
+
*/
|
|
12
|
+
export function partBoxes(parts: string[]): Record<string, Array<[number, number]>>;
|
|
13
|
+
/**
|
|
14
|
+
* @file The size of each drawn Astryx part on a picture's page, measured in
|
|
15
|
+
* the page.
|
|
16
|
+
* @input None: `partBoxes` runs in the page the picture is taken of.
|
|
17
|
+
* @output `partBoxes`: for each part named, the width and height of every
|
|
18
|
+
* element drawn with its `astryx-<part>` class, in page order;
|
|
19
|
+
* `PART_BOXES_PREFIX`, the line prefix a picture script prints it after.
|
|
20
|
+
* @position run by picture-chrome.mjs and picture-playwright.mjs for a job
|
|
21
|
+
* that names parts to measure, once the page is drawn as the picture shows
|
|
22
|
+
* it; read back by `screenshots` in api/theme-edit/_preview.mjs from the
|
|
23
|
+
* script's stdout. The theme editor compares two pictures' boxes to name
|
|
24
|
+
* what a change of size moves on the page.
|
|
25
|
+
*/
|
|
26
|
+
/** The line prefix a picture script prints the measurement after. */
|
|
27
|
+
export const PART_BOXES_PREFIX: "astryx-part-boxes:";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The size of each drawn Astryx part on a picture's page, measured in
|
|
5
|
+
* the page.
|
|
6
|
+
* @input None: `partBoxes` runs in the page the picture is taken of.
|
|
7
|
+
* @output `partBoxes`: for each part named, the width and height of every
|
|
8
|
+
* element drawn with its `astryx-<part>` class, in page order;
|
|
9
|
+
* `PART_BOXES_PREFIX`, the line prefix a picture script prints it after.
|
|
10
|
+
* @position run by picture-chrome.mjs and picture-playwright.mjs for a job
|
|
11
|
+
* that names parts to measure, once the page is drawn as the picture shows
|
|
12
|
+
* it; read back by `screenshots` in api/theme-edit/_preview.mjs from the
|
|
13
|
+
* script's stdout. The theme editor compares two pictures' boxes to name
|
|
14
|
+
* what a change of size moves on the page.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/* global document, getComputedStyle -- partBoxes runs in the page */
|
|
18
|
+
|
|
19
|
+
/** The line prefix a picture script prints the measurement after. */
|
|
20
|
+
export const PART_BOXES_PREFIX = 'astryx-part-boxes:';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The width and height of every drawn element of each part named, in page
|
|
24
|
+
* order, to a hundredth of a pixel. An element that is not drawn (no box,
|
|
25
|
+
* hidden, `display: contents`) is left out.
|
|
26
|
+
* Runs in the page: it uses nothing from outside its own body.
|
|
27
|
+
* @param {string[]} parts
|
|
28
|
+
* @returns {Record<string, Array<[number, number]>>}
|
|
29
|
+
*/
|
|
30
|
+
export function partBoxes(parts) {
|
|
31
|
+
/** @type {Record<string, Array<[number, number]>>} */
|
|
32
|
+
const out = {};
|
|
33
|
+
const round = (/** @type {number} */ n) => Math.round(n * 100) / 100;
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
out[part] = [];
|
|
36
|
+
for (const el of document.querySelectorAll(`.astryx-${part}`)) {
|
|
37
|
+
const cs = getComputedStyle(el);
|
|
38
|
+
if (cs.display === 'contents' || cs.visibility !== 'visible') continue;
|
|
39
|
+
const r = el.getBoundingClientRect();
|
|
40
|
+
if (!r.width && !r.height) continue;
|
|
41
|
+
out[part].push([round(r.width), round(r.height)]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
@@ -22,8 +22,12 @@ import * as os from 'node:os';
|
|
|
22
22
|
import * as path from 'node:path';
|
|
23
23
|
import {pathToFileURL} from 'node:url';
|
|
24
24
|
import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
|
|
25
|
+
import {LOW_CONTRAST_PREFIX, lowContrastText} from './drawn-contrast.mjs';
|
|
26
|
+
import {PART_BOXES_PREFIX, partBoxes} from './part-boxes.mjs';
|
|
25
27
|
import {NETWORK_URL_PATTERNS, QUIET_BROWSER_ARGS} from './offline.mjs';
|
|
26
28
|
import {
|
|
29
|
+
FIT_CELLS,
|
|
30
|
+
PLACE_LAYERS,
|
|
27
31
|
PICTURE_PAGES_AT_ONCE,
|
|
28
32
|
PICTURE_TAKEN,
|
|
29
33
|
PICTURE_WINDOW,
|
|
@@ -34,7 +38,7 @@ import {
|
|
|
34
38
|
import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
|
|
35
39
|
|
|
36
40
|
const [chrome, batch] = process.argv.slice(2);
|
|
37
|
-
/** @type {Array<{html: string, png: string, mode: string}>} */
|
|
41
|
+
/** @type {Array<{html: string, png: string, mode: string, boxes?: string[]}>} */
|
|
38
42
|
const jobs = JSON.parse(batch);
|
|
39
43
|
/** A line for one job of the batch. @param {number} i @param {string} line */
|
|
40
44
|
const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
|
|
@@ -155,10 +159,10 @@ function event(method, sessionId) {
|
|
|
155
159
|
/**
|
|
156
160
|
* One page of the batch in a tab of its own: drawn, pictured whole, and
|
|
157
161
|
* measured.
|
|
158
|
-
* @param {{html: string, png: string, mode: string}} job
|
|
162
|
+
* @param {{html: string, png: string, mode: string, boxes?: string[]}} job
|
|
159
163
|
* @param {number} i
|
|
160
164
|
*/
|
|
161
|
-
async function picture({html, png, mode}, i) {
|
|
165
|
+
async function picture({html, png, mode, boxes}, i) {
|
|
162
166
|
// Each page in a window of its own: a page in a background tab runs
|
|
163
167
|
// no animation frames, so a chart drawn over frames never finishes.
|
|
164
168
|
const {targetId} = await send('Target.createTarget', {url: 'about:blank', newWindow: true});
|
|
@@ -198,6 +202,10 @@ async function picture({html, png, mode}, i) {
|
|
|
198
202
|
// page loads: it is run to its end, and a looping one held at a frame a
|
|
199
203
|
// person sees (SETTLE_ANIMATIONS), before the picture.
|
|
200
204
|
await send('Runtime.evaluate', {expression: SETTLE_ANIMATIONS}, sessionId);
|
|
205
|
+
// Text a part cuts when narrow gets the room it needs (FIT_CELLS).
|
|
206
|
+
await send('Runtime.evaluate', {expression: FIT_CELLS}, sessionId);
|
|
207
|
+
// An overlay drawn after its part sits under its opener (PLACE_LAYERS).
|
|
208
|
+
await send('Runtime.evaluate', {expression: PLACE_LAYERS}, sessionId);
|
|
201
209
|
const metrics = await send('Page.getLayoutMetrics', {}, sessionId);
|
|
202
210
|
const size = metrics.cssContentSize ?? metrics.contentSize;
|
|
203
211
|
// A picture beyond the window makes the page see a resize; a part that
|
|
@@ -213,7 +221,9 @@ async function picture({html, png, mode}, i) {
|
|
|
213
221
|
clip: {
|
|
214
222
|
x: 0,
|
|
215
223
|
y: 0,
|
|
216
|
-
|
|
224
|
+
// The whole page: a part wider than the window (the page lays it out
|
|
225
|
+
// past the window's edge) is pictured whole, never cut at it.
|
|
226
|
+
width: Math.max(PICTURE_WINDOW.width, Math.ceil(size.width)),
|
|
217
227
|
height: Math.max(1, Math.ceil(size.height)),
|
|
218
228
|
scale: 1,
|
|
219
229
|
},
|
|
@@ -237,6 +247,28 @@ async function picture({html, png, mode}, i) {
|
|
|
237
247
|
).catch(() => null);
|
|
238
248
|
if (Array.isArray(measured?.result?.value) && !measured.exceptionDetails)
|
|
239
249
|
say(i, `${CUT_SHORT_PREFIX}${JSON.stringify(measured.result.value)}`);
|
|
250
|
+
// The text the picture draws too faint to read, measured the same way.
|
|
251
|
+
const faint = await send(
|
|
252
|
+
'Runtime.evaluate',
|
|
253
|
+
{expression: `(${lowContrastText})()`, returnByValue: true},
|
|
254
|
+
sessionId,
|
|
255
|
+
).catch(() => null);
|
|
256
|
+
if (Array.isArray(faint?.result?.value) && !faint.exceptionDetails)
|
|
257
|
+
say(i, `${LOW_CONTRAST_PREFIX}${JSON.stringify(faint.result.value)}`);
|
|
258
|
+
// The size of each part the job names, for a check that compares two
|
|
259
|
+
// pictures' boxes.
|
|
260
|
+
if (boxes?.length) {
|
|
261
|
+
const sized = await send(
|
|
262
|
+
'Runtime.evaluate',
|
|
263
|
+
{
|
|
264
|
+
expression: `(${partBoxes})(${JSON.stringify(boxes)})`,
|
|
265
|
+
returnByValue: true,
|
|
266
|
+
},
|
|
267
|
+
sessionId,
|
|
268
|
+
).catch(() => null);
|
|
269
|
+
if (sized?.result?.value && !sized.exceptionDetails)
|
|
270
|
+
say(i, `${PART_BOXES_PREFIX}${JSON.stringify(sized.result.value)}`);
|
|
271
|
+
}
|
|
240
272
|
await send('Target.closeTarget', {targetId}).catch(() => {});
|
|
241
273
|
say(i, PICTURE_TAKEN);
|
|
242
274
|
}
|
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
import {pathToFileURL} from 'node:url';
|
|
19
19
|
import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
|
|
20
|
+
import {LOW_CONTRAST_PREFIX, lowContrastText} from './drawn-contrast.mjs';
|
|
21
|
+
import {PART_BOXES_PREFIX, partBoxes} from './part-boxes.mjs';
|
|
20
22
|
import {LOCAL_URL, QUIET_BROWSER_ARGS} from './offline.mjs';
|
|
21
23
|
import {
|
|
24
|
+
FIT_CELLS,
|
|
25
|
+
PLACE_LAYERS,
|
|
22
26
|
PICTURE_PAGES_AT_ONCE,
|
|
23
27
|
PICTURE_TAKEN,
|
|
24
28
|
PICTURE_WINDOW,
|
|
@@ -29,7 +33,7 @@ import {
|
|
|
29
33
|
import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
|
|
30
34
|
|
|
31
35
|
const [entry, batch, executablePath] = process.argv.slice(2);
|
|
32
|
-
/** @type {Array<{html: string, png: string, mode: string}>} */
|
|
36
|
+
/** @type {Array<{html: string, png: string, mode: string, boxes?: string[]}>} */
|
|
33
37
|
const jobs = JSON.parse(batch);
|
|
34
38
|
/** A line for one job of the batch. @param {number} i @param {string} line */
|
|
35
39
|
const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
|
|
@@ -46,7 +50,7 @@ try {
|
|
|
46
50
|
await eachAtOnce(
|
|
47
51
|
jobs,
|
|
48
52
|
PICTURE_PAGES_AT_ONCE,
|
|
49
|
-
async ({html, png, mode}, i) => {
|
|
53
|
+
async ({html, png, mode, boxes}, i) => {
|
|
50
54
|
const page = await browser.newPage({
|
|
51
55
|
viewport: {...PICTURE_WINDOW},
|
|
52
56
|
colorScheme: mode === 'dark' ? 'dark' : 'light',
|
|
@@ -68,6 +72,10 @@ try {
|
|
|
68
72
|
// Playwright's own animations: 'disabled' would put a looping one
|
|
69
73
|
// back at its first frame, where a skeleton is faint.
|
|
70
74
|
await page.evaluate(SETTLE_ANIMATIONS);
|
|
75
|
+
// Text a part cuts when narrow gets the room it needs (FIT_CELLS).
|
|
76
|
+
await page.evaluate(FIT_CELLS);
|
|
77
|
+
// An overlay drawn after its part sits under its opener (PLACE_LAYERS).
|
|
78
|
+
await page.evaluate(PLACE_LAYERS);
|
|
71
79
|
// A whole-page picture makes the page see a resize; a part that
|
|
72
80
|
// redraws on it (a responsive chart) would start over and be
|
|
73
81
|
// pictured empty. The page's script is held while it is taken.
|
|
@@ -93,6 +101,22 @@ try {
|
|
|
93
101
|
} catch {
|
|
94
102
|
// Not measured.
|
|
95
103
|
}
|
|
104
|
+
// The text the picture draws too faint to read, the same way.
|
|
105
|
+
try {
|
|
106
|
+
const faint = await page.evaluate(lowContrastText);
|
|
107
|
+
say(i, `${LOW_CONTRAST_PREFIX}${JSON.stringify(faint)}`);
|
|
108
|
+
} catch {
|
|
109
|
+
// Not measured.
|
|
110
|
+
}
|
|
111
|
+
// The size of each part the job names, for a check that compares
|
|
112
|
+
// two pictures' boxes.
|
|
113
|
+
if (boxes?.length)
|
|
114
|
+
try {
|
|
115
|
+
const sized = await page.evaluate(partBoxes, boxes);
|
|
116
|
+
say(i, `${PART_BOXES_PREFIX}${JSON.stringify(sized)}`);
|
|
117
|
+
} catch {
|
|
118
|
+
// Not measured.
|
|
119
|
+
}
|
|
96
120
|
await page.close?.().catch(() => {});
|
|
97
121
|
say(i, PICTURE_TAKEN);
|
|
98
122
|
},
|
|
@@ -41,11 +41,13 @@ export function desktopMatches(query: string, { sure }?: {
|
|
|
41
41
|
/**
|
|
42
42
|
* The script run on a page before its picture: each animation that ends (an
|
|
43
43
|
* overlay's fade-in) is run to its end, so the picture shows the part as it
|
|
44
|
-
* looks once it has played
|
|
44
|
+
* looks once it has played, except a part drawn pressed, whose press
|
|
45
|
+
* animation (a flash that fades) is held at its start, the moment of the
|
|
46
|
+
* press; each that loops (a skeleton's shimmer, a pulsing
|
|
45
47
|
* dot, a spinner) is held at the middle of its first round, a frame a person
|
|
46
48
|
* sees as it plays, never its first frame, where a part can be faint or gone.
|
|
47
49
|
*/
|
|
48
|
-
export const SETTLE_ANIMATIONS: "for (const a of document.getAnimations()) {\n const t = a.effect?.getComputedTiming();\n if (!t) continue;\n if (t.iterations !== Infinity) { a.finish(); continue; }\n a.pause();\n a.currentTime = (Number(a.effect.getTiming().delay) || 0) + (typeof t.duration === 'number' ? t.duration : 0) / 2;\n}";
|
|
50
|
+
export const SETTLE_ANIMATIONS: "for (const a of document.getAnimations()) {\n const t = a.effect?.getComputedTiming();\n if (!t) continue;\n if (typeof CSSAnimation === 'function' && a instanceof CSSAnimation && t.iterations !== Infinity && a.effect.target?.closest?.('[data-astryx-state~=\"active\"]')) { a.pause(); a.currentTime = Number(a.effect.getTiming().delay) || 0; continue; }\n if (t.iterations !== Infinity) { a.finish(); continue; }\n a.pause();\n a.currentTime = (Number(a.effect.getTiming().delay) || 0) + (typeof t.duration === 'number' ? t.duration : 0) / 2;\n}";
|
|
49
51
|
/**
|
|
50
52
|
* The script run before the picture: it waits until the page stops
|
|
51
53
|
* changing, so a part drawn over animation frames (a responsive chart's
|
|
@@ -61,6 +63,31 @@ export const AWAIT_QUIET: "new Promise(resolve => {\n const QUIET_MS = 300;\n
|
|
|
61
63
|
export const PICTURE_TAKEN: "taken";
|
|
62
64
|
/** How many pages of a batch a picture script draws at once. */
|
|
63
65
|
export const PICTURE_PAGES_AT_ONCE: 3;
|
|
66
|
+
/**
|
|
67
|
+
* The script run on a sheet before its picture: text a part cuts with an
|
|
68
|
+
* ellipsis when it is narrow (a stepper's step names, a section heading)
|
|
69
|
+
* gets the room it needs, and so does a row that scrolls sideways (a
|
|
70
|
+
* carousel's slides), so its picture shows every item and cuts none at its
|
|
71
|
+
* edge. Each sheet item holding such text or row grows by what it lacks, a
|
|
72
|
+
* few rounds while the layout settles, up to the room an item has in a cell
|
|
73
|
+
* as wide as the sheet's content box (the sheet's width less its padding,
|
|
74
|
+
* the cell's padding and border, and the item's margins), so a grown cell
|
|
75
|
+
* stays inside the sheet and the picture keeps the window's width. A part
|
|
76
|
+
* whose own width is fixed keeps it, and what it still cuts is the theme's
|
|
77
|
+
* to fix. A page with no sheet items is left as it is.
|
|
78
|
+
*/
|
|
79
|
+
export const FIT_CELLS: "(() => {\n for (let round = 0; round < 4; round++) {\n let grew = false;\n for (const item of document.querySelectorAll('.cs-item')) {\n let need = 0;\n for (const el of item.querySelectorAll('*')) {\n // A text cut by less than a pixel still ends in an ellipsis. Text\n // drawn in no width at all (a label only a screen reader reads) is\n // not cut: no width given to it would show it.\n if (el.clientWidth < 2 || el.scrollWidth <= el.clientWidth) continue;\n const cs = getComputedStyle(el);\n const scrolls = /^(?:auto|scroll)$/.test(cs.overflowX);\n if (cs.textOverflow !== 'ellipsis' && !scrolls) continue;\n need = Math.max(need, el.scrollWidth - el.clientWidth + 1);\n }\n if (!need) continue;\n const width = item.getBoundingClientRect().width;\n const sheet = item.closest('.cs-sheet');\n if (!sheet) continue;\n const sides = (el, a, b) => {\n const s = getComputedStyle(el);\n return (parseFloat(s[a]) || 0) + (parseFloat(s[b]) || 0);\n };\n const cell = item.closest('.cs-cell');\n const most = Math.floor(\n sheet.clientWidth -\n sides(sheet, 'paddingLeft', 'paddingRight') -\n (cell\n ? sides(cell, 'paddingLeft', 'paddingRight') +\n sides(cell, 'borderLeftWidth', 'borderRightWidth')\n : 0) -\n sides(item, 'marginLeft', 'marginRight'),\n );\n const next = Math.min(Math.ceil(width + need), Math.max(most, width));\n if (next > width + 0.5) {\n item.style.minWidth = next + 'px';\n grew = true;\n }\n }\n if (!grew) break;\n }\n})()";
|
|
80
|
+
/**
|
|
81
|
+
* The script run on a sheet before its picture: an overlay drawn open
|
|
82
|
+
* after its part (a toolbar's menu) moves along the row to sit under the
|
|
83
|
+
* control that opens it, as a browser places it, as far as its item has
|
|
84
|
+
* room for what it draws. A flyout drawn beside its menu stays there. A
|
|
85
|
+
* panel as wide as the window is drawn as wide as its cell. A dialog drawn
|
|
86
|
+
* in its cell is not in the top layer, so the browser draws no backdrop
|
|
87
|
+
* for it: one with no background of its own (a lightbox, its controls
|
|
88
|
+
* drawn for the dark backdrop) gets its backdrop's colour as its own.
|
|
89
|
+
*/
|
|
90
|
+
export const PLACE_LAYERS: "(() => {\n for (const layer of document.querySelectorAll('.cs-item [data-astryx-layer-root]')) {\n if (layer.parentElement?.closest('[data-astryx-layer-root], [data-astryx-layer-nest]')) continue;\n const item = layer.closest('.cs-item');\n const ids = [layer, ...layer.querySelectorAll('[id]')].map(e => e.id).filter(Boolean);\n const opener = [...item.querySelectorAll('[aria-controls]')].find(c => !layer.contains(c) && !c.closest('[data-astryx-layer-root]') && ids.includes(c.getAttribute('aria-controls')));\n if (!opener) continue;\n // The layer box spans its row; what it draws is its content, so the\n // room is measured from the content's right edge.\n const at = layer.getBoundingClientRect();\n const drawn = Math.max(at.left, ...[...layer.children].map(c => c.getBoundingClientRect().right));\n const shift = Math.min(opener.getBoundingClientRect().left - at.left, item.getBoundingClientRect().right - drawn);\n if (shift > 0.5) layer.style.setProperty('margin-inline-start', shift + 'px', 'important');\n }\n // A panel as wide as the window (a navigation drawer's dialog) is drawn as\n // wide as its cell: the window's width would stretch the cell, and the\n // page, past it.\n for (const dialog of document.querySelectorAll('.cs-cell dialog')) {\n if (dialog.getBoundingClientRect().width >= window.innerWidth - 0.5)\n dialog.style.setProperty('width', '100%', 'important');\n }\n const clear = color => /^transparent$|rgba\\([^)]*,\\s*0\\)$/.test(color.trim());\n for (const dialog of document.querySelectorAll('.cs-cell dialog')) {\n const backdrop = getComputedStyle(dialog, '::backdrop').backgroundColor;\n if (clear(getComputedStyle(dialog).backgroundColor) && backdrop && !clear(backdrop))\n dialog.style.setProperty('background-color', backdrop, 'important');\n }\n})()";
|
|
64
91
|
export const PICTURE_WINDOW: Readonly<{
|
|
65
92
|
width: 1280;
|
|
66
93
|
height: 900;
|
|
@@ -15,13 +15,16 @@
|
|
|
15
15
|
/**
|
|
16
16
|
* The script run on a page before its picture: each animation that ends (an
|
|
17
17
|
* overlay's fade-in) is run to its end, so the picture shows the part as it
|
|
18
|
-
* looks once it has played
|
|
18
|
+
* looks once it has played, except a part drawn pressed, whose press
|
|
19
|
+
* animation (a flash that fades) is held at its start, the moment of the
|
|
20
|
+
* press; each that loops (a skeleton's shimmer, a pulsing
|
|
19
21
|
* dot, a spinner) is held at the middle of its first round, a frame a person
|
|
20
22
|
* sees as it plays, never its first frame, where a part can be faint or gone.
|
|
21
23
|
*/
|
|
22
24
|
export const SETTLE_ANIMATIONS = `for (const a of document.getAnimations()) {
|
|
23
25
|
const t = a.effect?.getComputedTiming();
|
|
24
26
|
if (!t) continue;
|
|
27
|
+
if (typeof CSSAnimation === 'function' && a instanceof CSSAnimation && t.iterations !== Infinity && a.effect.target?.closest?.('[data-astryx-state~="active"]')) { a.pause(); a.currentTime = Number(a.effect.getTiming().delay) || 0; continue; }
|
|
25
28
|
if (t.iterations !== Infinity) { a.finish(); continue; }
|
|
26
29
|
a.pause();
|
|
27
30
|
a.currentTime = (Number(a.effect.getTiming().delay) || 0) + (typeof t.duration === 'number' ? t.duration : 0) / 2;
|
|
@@ -90,6 +93,101 @@ export async function eachAtOnce(jobs, atOnce, run) {
|
|
|
90
93
|
if (first) throw first.error;
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
/**
|
|
97
|
+
* The script run on a sheet before its picture: text a part cuts with an
|
|
98
|
+
* ellipsis when it is narrow (a stepper's step names, a section heading)
|
|
99
|
+
* gets the room it needs, and so does a row that scrolls sideways (a
|
|
100
|
+
* carousel's slides), so its picture shows every item and cuts none at its
|
|
101
|
+
* edge. Each sheet item holding such text or row grows by what it lacks, a
|
|
102
|
+
* few rounds while the layout settles, up to the room an item has in a cell
|
|
103
|
+
* as wide as the sheet's content box (the sheet's width less its padding,
|
|
104
|
+
* the cell's padding and border, and the item's margins), so a grown cell
|
|
105
|
+
* stays inside the sheet and the picture keeps the window's width. A part
|
|
106
|
+
* whose own width is fixed keeps it, and what it still cuts is the theme's
|
|
107
|
+
* to fix. A page with no sheet items is left as it is.
|
|
108
|
+
*/
|
|
109
|
+
export const FIT_CELLS = `(() => {
|
|
110
|
+
for (let round = 0; round < 4; round++) {
|
|
111
|
+
let grew = false;
|
|
112
|
+
for (const item of document.querySelectorAll('.cs-item')) {
|
|
113
|
+
let need = 0;
|
|
114
|
+
for (const el of item.querySelectorAll('*')) {
|
|
115
|
+
// A text cut by less than a pixel still ends in an ellipsis. Text
|
|
116
|
+
// drawn in no width at all (a label only a screen reader reads) is
|
|
117
|
+
// not cut: no width given to it would show it.
|
|
118
|
+
if (el.clientWidth < 2 || el.scrollWidth <= el.clientWidth) continue;
|
|
119
|
+
const cs = getComputedStyle(el);
|
|
120
|
+
const scrolls = /^(?:auto|scroll)$/.test(cs.overflowX);
|
|
121
|
+
if (cs.textOverflow !== 'ellipsis' && !scrolls) continue;
|
|
122
|
+
need = Math.max(need, el.scrollWidth - el.clientWidth + 1);
|
|
123
|
+
}
|
|
124
|
+
if (!need) continue;
|
|
125
|
+
const width = item.getBoundingClientRect().width;
|
|
126
|
+
const sheet = item.closest('.cs-sheet');
|
|
127
|
+
if (!sheet) continue;
|
|
128
|
+
const sides = (el, a, b) => {
|
|
129
|
+
const s = getComputedStyle(el);
|
|
130
|
+
return (parseFloat(s[a]) || 0) + (parseFloat(s[b]) || 0);
|
|
131
|
+
};
|
|
132
|
+
const cell = item.closest('.cs-cell');
|
|
133
|
+
const most = Math.floor(
|
|
134
|
+
sheet.clientWidth -
|
|
135
|
+
sides(sheet, 'paddingLeft', 'paddingRight') -
|
|
136
|
+
(cell
|
|
137
|
+
? sides(cell, 'paddingLeft', 'paddingRight') +
|
|
138
|
+
sides(cell, 'borderLeftWidth', 'borderRightWidth')
|
|
139
|
+
: 0) -
|
|
140
|
+
sides(item, 'marginLeft', 'marginRight'),
|
|
141
|
+
);
|
|
142
|
+
const next = Math.min(Math.ceil(width + need), Math.max(most, width));
|
|
143
|
+
if (next > width + 0.5) {
|
|
144
|
+
item.style.minWidth = next + 'px';
|
|
145
|
+
grew = true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!grew) break;
|
|
149
|
+
}
|
|
150
|
+
})()`;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The script run on a sheet before its picture: an overlay drawn open
|
|
154
|
+
* after its part (a toolbar's menu) moves along the row to sit under the
|
|
155
|
+
* control that opens it, as a browser places it, as far as its item has
|
|
156
|
+
* room for what it draws. A flyout drawn beside its menu stays there. A
|
|
157
|
+
* panel as wide as the window is drawn as wide as its cell. A dialog drawn
|
|
158
|
+
* in its cell is not in the top layer, so the browser draws no backdrop
|
|
159
|
+
* for it: one with no background of its own (a lightbox, its controls
|
|
160
|
+
* drawn for the dark backdrop) gets its backdrop's colour as its own.
|
|
161
|
+
*/
|
|
162
|
+
export const PLACE_LAYERS = `(() => {
|
|
163
|
+
for (const layer of document.querySelectorAll('.cs-item [data-astryx-layer-root]')) {
|
|
164
|
+
if (layer.parentElement?.closest('[data-astryx-layer-root], [data-astryx-layer-nest]')) continue;
|
|
165
|
+
const item = layer.closest('.cs-item');
|
|
166
|
+
const ids = [layer, ...layer.querySelectorAll('[id]')].map(e => e.id).filter(Boolean);
|
|
167
|
+
const opener = [...item.querySelectorAll('[aria-controls]')].find(c => !layer.contains(c) && !c.closest('[data-astryx-layer-root]') && ids.includes(c.getAttribute('aria-controls')));
|
|
168
|
+
if (!opener) continue;
|
|
169
|
+
// The layer box spans its row; what it draws is its content, so the
|
|
170
|
+
// room is measured from the content's right edge.
|
|
171
|
+
const at = layer.getBoundingClientRect();
|
|
172
|
+
const drawn = Math.max(at.left, ...[...layer.children].map(c => c.getBoundingClientRect().right));
|
|
173
|
+
const shift = Math.min(opener.getBoundingClientRect().left - at.left, item.getBoundingClientRect().right - drawn);
|
|
174
|
+
if (shift > 0.5) layer.style.setProperty('margin-inline-start', shift + 'px', 'important');
|
|
175
|
+
}
|
|
176
|
+
// A panel as wide as the window (a navigation drawer's dialog) is drawn as
|
|
177
|
+
// wide as its cell: the window's width would stretch the cell, and the
|
|
178
|
+
// page, past it.
|
|
179
|
+
for (const dialog of document.querySelectorAll('.cs-cell dialog')) {
|
|
180
|
+
if (dialog.getBoundingClientRect().width >= window.innerWidth - 0.5)
|
|
181
|
+
dialog.style.setProperty('width', '100%', 'important');
|
|
182
|
+
}
|
|
183
|
+
const clear = color => /^transparent$|rgba\\([^)]*,\\s*0\\)$/.test(color.trim());
|
|
184
|
+
for (const dialog of document.querySelectorAll('.cs-cell dialog')) {
|
|
185
|
+
const backdrop = getComputedStyle(dialog, '::backdrop').backgroundColor;
|
|
186
|
+
if (clear(getComputedStyle(dialog).backgroundColor) && backdrop && !clear(backdrop))
|
|
187
|
+
dialog.style.setProperty('background-color', backdrop, 'important');
|
|
188
|
+
}
|
|
189
|
+
})()`;
|
|
190
|
+
|
|
93
191
|
export const PICTURE_WINDOW = Object.freeze({width: 1280, height: 900});
|
|
94
192
|
|
|
95
193
|
/** The pointer of the window a picture is taken in. */
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A warning for each of the first five lines the page printed while it
|
|
6
|
+
* rendered.
|
|
7
|
+
* @param {{level: string, text: string}[]} logs
|
|
8
|
+
* @returns {RenderWarning[]}
|
|
9
|
+
*/
|
|
10
|
+
export function pageOutputWarnings(logs: {
|
|
11
|
+
level: string;
|
|
12
|
+
text: string;
|
|
13
|
+
}[]): RenderWarning[];
|
|
4
14
|
/**
|
|
5
15
|
* An `@import` rule's parts: what it loads, and the layer, supports() and
|
|
6
16
|
* media conditions that scope it.
|
|
@@ -232,9 +242,14 @@ export function renderPage(entry: string, options?: {
|
|
|
232
242
|
}): Promise<RenderedPage>;
|
|
233
243
|
/** How long one page may take to render before it is stopped. */
|
|
234
244
|
export const RENDER_TIMEOUT_MS: 60000;
|
|
245
|
+
/**
|
|
246
|
+
* The console line React prints for a prop that reaches a DOM element it
|
|
247
|
+
* does not know, with the prop's name.
|
|
248
|
+
*/
|
|
249
|
+
export const REACT_UNKNOWN_PROP: RegExp;
|
|
235
250
|
/**
|
|
236
251
|
* @typedef {object} RenderWarning
|
|
237
|
-
* @property {'dropped-children' | 'unknown-prop-value' | 'remote-asset' | 'missing-asset' | 'page-output' | 'page-script' | 'no-astryx-styles' | 'chart-size' | 'screen-query' | 'not-embedded' | 'not-carried' | 'node-crash'} code - What kind of problem.
|
|
252
|
+
* @property {'dropped-children' | 'unknown-prop' | 'props-not-checked' | 'unknown-prop-value' | 'remote-asset' | 'missing-asset' | 'page-output' | 'page-script' | 'no-astryx-styles' | 'chart-size' | 'screen-query' | 'not-embedded' | 'not-carried' | 'node-crash'} code - What kind of problem.
|
|
238
253
|
* @property {string} message - What happened and what to do, in one sentence.
|
|
239
254
|
*/
|
|
240
255
|
/**
|
|
@@ -249,7 +264,9 @@ export const RENDER_TIMEOUT_MS: 60000;
|
|
|
249
264
|
* @property {number} images - Local files inlined as data: URIs.
|
|
250
265
|
* @property {RenderWarning[]} warnings
|
|
251
266
|
* @property {string[]} [notCarried] - Files the page uses that the file does not carry, so experimental import cannot give them back (each also has a warning); present only when there are some.
|
|
252
|
-
* @property {{component: string, prop: string,
|
|
267
|
+
* @property {(import('../discovery/written-prop-values.mjs').WrittenValue & {component: string, prop: string, file: string, line: number})[]} [propValues] - What the page's own files certainly give a Core component's prop (the kinds of value and the strings among them), for the caller to check against the component's docs and types.
|
|
268
|
+
* @property {{level: string, text: string}[]} [logs] - What the page printed while it rendered, of which the `page-output` warnings show the first lines.
|
|
269
|
+
* @property {(import('../discovery/core-props.mjs').CorePropUse & {file: string, element: {line: number, column: number}})[]} [propNames] - Each prop the page's own files give a Core component by name, with the file's absolute path and where its element opens, for the caller to check against the component's docs and types.
|
|
253
270
|
* @property {{name: string, dir: string}[]} fromSet - Packages that came from the package set the CLI runs from, not the page's folder.
|
|
254
271
|
* @property {number} [scriptBytes] - Bytes of the page's script; none in a markup-only render.
|
|
255
272
|
* @property {number} [scriptModules] - The modules the page's script holds; none in a markup-only render.
|
|
@@ -302,7 +319,7 @@ export type RenderWarning = {
|
|
|
302
319
|
/**
|
|
303
320
|
* - What kind of problem.
|
|
304
321
|
*/
|
|
305
|
-
code: "dropped-children" | "unknown-prop-value" | "remote-asset" | "missing-asset" | "page-output" | "page-script" | "no-astryx-styles" | "chart-size" | "screen-query" | "not-embedded" | "not-carried" | "node-crash";
|
|
322
|
+
code: "dropped-children" | "unknown-prop" | "props-not-checked" | "unknown-prop-value" | "remote-asset" | "missing-asset" | "page-output" | "page-script" | "no-astryx-styles" | "chart-size" | "screen-query" | "not-embedded" | "not-carried" | "node-crash";
|
|
306
323
|
/**
|
|
307
324
|
* - What happened and what to do, in one sentence.
|
|
308
325
|
*/
|
|
@@ -347,15 +364,31 @@ export type RenderedPage = {
|
|
|
347
364
|
*/
|
|
348
365
|
notCarried?: string[] | undefined;
|
|
349
366
|
/**
|
|
350
|
-
* -
|
|
367
|
+
* - What the page's own files certainly give a Core component's prop (the kinds of value and the strings among them), for the caller to check against the component's docs and types.
|
|
351
368
|
*/
|
|
352
|
-
propValues?: {
|
|
369
|
+
propValues?: (import("../discovery/written-prop-values.mjs").WrittenValue & {
|
|
353
370
|
component: string;
|
|
354
371
|
prop: string;
|
|
355
|
-
value: string;
|
|
356
372
|
file: string;
|
|
357
373
|
line: number;
|
|
374
|
+
})[] | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* - What the page printed while it rendered, of which the `page-output` warnings show the first lines.
|
|
377
|
+
*/
|
|
378
|
+
logs?: {
|
|
379
|
+
level: string;
|
|
380
|
+
text: string;
|
|
358
381
|
}[] | undefined;
|
|
382
|
+
/**
|
|
383
|
+
* - Each prop the page's own files give a Core component by name, with the file's absolute path and where its element opens, for the caller to check against the component's docs and types.
|
|
384
|
+
*/
|
|
385
|
+
propNames?: (import("../discovery/core-props.mjs").CorePropUse & {
|
|
386
|
+
file: string;
|
|
387
|
+
element: {
|
|
388
|
+
line: number;
|
|
389
|
+
column: number;
|
|
390
|
+
};
|
|
391
|
+
})[] | undefined;
|
|
359
392
|
/**
|
|
360
393
|
* - Packages that came from the package set the CLI runs from, not the page's folder.
|
|
361
394
|
*/
|