@homepages/concrete 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { COMMANDS, globalFlagSpellings, groupMembers, renderUsage, runsCurrencyPreamble, withoutNoAutoUpdateFlag } from "./cli/commands.js";
|
|
3
|
+
import { CONCRETE_CLI_VERSION } from "./cli/version.js";
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/index.ts
|
|
8
|
+
const USAGE = renderUsage(`concrete ${CONCRETE_CLI_VERSION}`);
|
|
9
|
+
/**
|
|
10
|
+
* Refresh the workspace's `@homepages/concrete` when it is behind the published
|
|
11
|
+
* release, before the command's own module is imported.
|
|
12
|
+
*
|
|
13
|
+
* The whole call is guarded because a preamble may never fail the command it precedes —
|
|
14
|
+
* an unreadable workspace or an unreachable registry costs the author nothing.
|
|
15
|
+
*/
|
|
16
|
+
async function refreshWorkspaceFirst(argv, io) {
|
|
17
|
+
try {
|
|
18
|
+
const { enforceCurrency } = await import("./cli/currency/preamble.js");
|
|
19
|
+
await enforceCurrency({
|
|
20
|
+
cliVersion: CONCRETE_CLI_VERSION,
|
|
21
|
+
argv,
|
|
22
|
+
cwd: io.cwd,
|
|
23
|
+
env: io.env,
|
|
24
|
+
sink: io.stderr,
|
|
25
|
+
tty: io.tty
|
|
26
|
+
});
|
|
27
|
+
} catch {}
|
|
28
|
+
}
|
|
29
|
+
/** Import one command's module and run it; a throw from either is the command's exit 1. */
|
|
30
|
+
async function dispatch(name, load, argv, io) {
|
|
31
|
+
try {
|
|
32
|
+
return await (await load())(argv, io);
|
|
33
|
+
} catch (cause) {
|
|
34
|
+
io.stderr.write(`concrete ${name}: ${cause instanceof Error ? cause.message : String(cause)}\n`);
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function main(argv, io) {
|
|
39
|
+
const cmd = argv[0];
|
|
40
|
+
if (cmd !== void 0 && globalFlagSpellings("version").includes(cmd)) {
|
|
41
|
+
io.stdout.write(`${CONCRETE_CLI_VERSION}\n`);
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
if (cmd === void 0 || globalFlagSpellings("help").includes(cmd)) {
|
|
45
|
+
io.stdout.write(USAGE);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
const members = groupMembers(cmd);
|
|
49
|
+
const command = members.length > 0 ? members.find((c) => c.name === `${cmd} ${argv[1] ?? ""}`) : COMMANDS.find((c) => c.name === cmd);
|
|
50
|
+
if (command === void 0) {
|
|
51
|
+
if (members.length === 0) {
|
|
52
|
+
io.stderr.write(`concrete: unknown command '${cmd}'\n\n${USAGE}`);
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
const names = members.map((c) => `\`${c.name}\``).join(", ");
|
|
56
|
+
io.stderr.write(argv[1] === void 0 ? `concrete ${cmd}: name one of its commands — ${names}.\n\n${USAGE}` : `concrete ${cmd}: unknown command '${argv[1]}' — it has ${names}.\n\n${USAGE}`);
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
if (command.reserved !== void 0) {
|
|
60
|
+
io.stderr.write(`concrete ${command.name}: ${command.reserved}\n`);
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
const raw = argv.slice(1);
|
|
64
|
+
const preamble = runsCurrencyPreamble(command.name);
|
|
65
|
+
if (preamble) await refreshWorkspaceFirst(raw, io);
|
|
66
|
+
const args = preamble ? withoutNoAutoUpdateFlag(raw) : raw;
|
|
67
|
+
if (cmd === "dev") return dispatch(cmd, async () => (await import("./cli/dev/index.js")).runDev, args, io);
|
|
68
|
+
if (cmd === "check") return dispatch(cmd, async () => (await import("./cli/check/index.js")).runCheck, args, io);
|
|
69
|
+
if (cmd === "build") return dispatch(cmd, async () => (await import("./cli/build/index.js")).runBuild, args, io);
|
|
70
|
+
if (cmd === "upgrade") return dispatch(cmd, async () => (await import("./cli/upgrade/index.js")).runUpgrade, args, io);
|
|
71
|
+
if (cmd === "publish") return dispatch(cmd, async () => (await import("./cli/publish/index.js")).runPublish, args, io);
|
|
72
|
+
if (cmd === "property") return dispatch(command.name, async () => (await import("./cli/property/index.js")).runProperty, args, io);
|
|
73
|
+
io.stderr.write(`concrete: '${cmd}' is declared but has no dispatch branch.\n`);
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
function invokedAsBin() {
|
|
77
|
+
const argv1 = process.argv[1];
|
|
78
|
+
if (argv1 === void 0) return false;
|
|
79
|
+
try {
|
|
80
|
+
return realpathSync(argv1) === realpathSync(fileURLToPath(import.meta.url));
|
|
81
|
+
} catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (invokedAsBin()) process.exitCode = await main(process.argv.slice(2), {
|
|
86
|
+
cwd: process.cwd(),
|
|
87
|
+
env: process.env,
|
|
88
|
+
stdout: process.stdout,
|
|
89
|
+
stderr: process.stderr,
|
|
90
|
+
tty: process.stdout.isTTY === true
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { CONCRETE_CLI_VERSION, main };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { compileFormatVariantsToCss } from "../design-system/format-variants.js";
|
|
2
|
+
import { collectCssGraph } from "./graph.js";
|
|
3
|
+
import { inlineCssGraph } from "./inline.js";
|
|
4
|
+
import { externalUrlViolations, tailwindImportViolations } from "./rules.js";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { compile, optimize } from "@tailwindcss/node";
|
|
7
|
+
import { Scanner } from "@tailwindcss/oxide";
|
|
8
|
+
|
|
9
|
+
//#region src/css/compile.ts
|
|
10
|
+
/**
|
|
11
|
+
* The Tailwind entry: the inlined graph, then — for a rendered template — one
|
|
12
|
+
* `@custom-variant` per declared format id, so `deck-16x9:p-8` compiles. Tailwind drops
|
|
13
|
+
* a utility with an unknown variant silently, which is why the block is derived here
|
|
14
|
+
* rather than left to the author. A website's entry is the inlined graph unchanged.
|
|
15
|
+
*/
|
|
16
|
+
function buildTailwindEntry(inlinedCss, template) {
|
|
17
|
+
if (template.output === "website") return inlinedCss;
|
|
18
|
+
return `${inlinedCss.trimEnd()}\n\n${compileFormatVariantsToCss(template.formats)}`;
|
|
19
|
+
}
|
|
20
|
+
async function compileTailwind(root, entry) {
|
|
21
|
+
const compiler = await compile(entry, {
|
|
22
|
+
base: root,
|
|
23
|
+
onDependency: () => {}
|
|
24
|
+
});
|
|
25
|
+
const scanner = new Scanner({ sources: [...compiler.root === "none" ? [] : compiler.root === null ? [{
|
|
26
|
+
base: root,
|
|
27
|
+
pattern: "**/*",
|
|
28
|
+
negated: false
|
|
29
|
+
}] : [{
|
|
30
|
+
...compiler.root,
|
|
31
|
+
negated: false
|
|
32
|
+
}], ...compiler.sources] });
|
|
33
|
+
return optimize(compiler.build(scanner.scan()), { minify: true }).code;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Compile a workspace's `template_css`. Violations are `css/tailwind-import` and, for a
|
|
37
|
+
* rendered template, `css/external-url`. Throws when a module or a local `@import` or
|
|
38
|
+
* `url()` in the graph fails to resolve, with esbuild's message.
|
|
39
|
+
*/
|
|
40
|
+
async function compileTemplateCss(input) {
|
|
41
|
+
const graph = await collectCssGraph({
|
|
42
|
+
root: input.root,
|
|
43
|
+
templateFile: input.templateFile
|
|
44
|
+
});
|
|
45
|
+
const inlined = await inlineCssGraph(input.root, graph);
|
|
46
|
+
const importViolations = tailwindImportViolations({
|
|
47
|
+
root: input.root,
|
|
48
|
+
templateFile: input.templateFile,
|
|
49
|
+
importers: inlined.tailwindImporters
|
|
50
|
+
});
|
|
51
|
+
if (importViolations.length > 0) return {
|
|
52
|
+
bundle: null,
|
|
53
|
+
violations: importViolations
|
|
54
|
+
};
|
|
55
|
+
const css = await compileTailwind(input.root, buildTailwindEntry(inlined.css, input.template));
|
|
56
|
+
const violations = input.template.output === "website" ? [] : await externalUrlViolations({
|
|
57
|
+
root: input.root,
|
|
58
|
+
templateFile: input.templateFile,
|
|
59
|
+
css,
|
|
60
|
+
sources: graph
|
|
61
|
+
});
|
|
62
|
+
const bytes = new TextEncoder().encode(css);
|
|
63
|
+
const contentHash = createHash("sha256").update(bytes).digest("hex");
|
|
64
|
+
return {
|
|
65
|
+
bundle: {
|
|
66
|
+
filename: `template-${input.template.key}-${contentHash}.css`,
|
|
67
|
+
contentHash,
|
|
68
|
+
bytes,
|
|
69
|
+
contentType: "text/css; charset=utf-8",
|
|
70
|
+
assets: inlined.assets
|
|
71
|
+
},
|
|
72
|
+
violations
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
export { buildTailwindEntry, compileTemplateCss };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { build } from "esbuild";
|
|
3
|
+
|
|
4
|
+
//#region src/css/graph.ts
|
|
5
|
+
const CSS_NAMESPACE = "concrete-css-graph";
|
|
6
|
+
const UNFOLLOWED_RE = /^(?:react|react-dom)(?:\/.*)?$|^@homepages\/concrete(?:\/(?!.*\.css$).*)?$/;
|
|
7
|
+
const EMPTY_LOADERS = Object.fromEntries([
|
|
8
|
+
".svg",
|
|
9
|
+
".png",
|
|
10
|
+
".jpg",
|
|
11
|
+
".jpeg",
|
|
12
|
+
".gif",
|
|
13
|
+
".webp",
|
|
14
|
+
".avif",
|
|
15
|
+
".ico",
|
|
16
|
+
".woff",
|
|
17
|
+
".woff2",
|
|
18
|
+
".ttf",
|
|
19
|
+
".otf",
|
|
20
|
+
".eot",
|
|
21
|
+
".mp4",
|
|
22
|
+
".webm",
|
|
23
|
+
".mov",
|
|
24
|
+
".mp3",
|
|
25
|
+
".wav",
|
|
26
|
+
".pdf",
|
|
27
|
+
".zip"
|
|
28
|
+
].map((ext) => [ext, "empty"]));
|
|
29
|
+
function isOwnResolve(pluginData) {
|
|
30
|
+
return typeof pluginData === "object" && pluginData !== null && pluginData.concreteCssGraph === true;
|
|
31
|
+
}
|
|
32
|
+
function graphPlugin() {
|
|
33
|
+
return {
|
|
34
|
+
name: "concrete-css-graph",
|
|
35
|
+
setup(api) {
|
|
36
|
+
api.onResolve({ filter: /.*/ }, async (args) => {
|
|
37
|
+
if (args.kind === "entry-point" || isOwnResolve(args.pluginData)) return void 0;
|
|
38
|
+
if (UNFOLLOWED_RE.test(args.path)) return {
|
|
39
|
+
path: args.path,
|
|
40
|
+
external: true
|
|
41
|
+
};
|
|
42
|
+
const resolved = await api.resolve(args.path, {
|
|
43
|
+
kind: args.kind,
|
|
44
|
+
importer: args.importer,
|
|
45
|
+
resolveDir: args.resolveDir,
|
|
46
|
+
pluginData: { concreteCssGraph: true }
|
|
47
|
+
});
|
|
48
|
+
if (resolved.errors.length > 0 || resolved.external) return void 0;
|
|
49
|
+
if (resolved.path.endsWith(".css")) return {
|
|
50
|
+
path: resolved.path,
|
|
51
|
+
namespace: CSS_NAMESPACE,
|
|
52
|
+
sideEffects: true
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
api.onLoad({
|
|
56
|
+
filter: /.*/,
|
|
57
|
+
namespace: CSS_NAMESPACE
|
|
58
|
+
}, () => ({
|
|
59
|
+
contents: "",
|
|
60
|
+
loader: "js"
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function stylesheetsInImportOrder(metafile, entryKey) {
|
|
66
|
+
const order = [];
|
|
67
|
+
const seen = /* @__PURE__ */ new Set();
|
|
68
|
+
const prefix = `${CSS_NAMESPACE}:`;
|
|
69
|
+
const visit = (key) => {
|
|
70
|
+
if (seen.has(key)) return;
|
|
71
|
+
seen.add(key);
|
|
72
|
+
if (key.startsWith(prefix)) {
|
|
73
|
+
order.push(key.slice(prefix.length));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
for (const record of metafile.inputs[key]?.imports ?? []) {
|
|
77
|
+
if (record.external === true) continue;
|
|
78
|
+
visit(record.path);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
visit(entryKey);
|
|
82
|
+
return order;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Every `.css` file reachable by import from `template.ts`, as absolute paths, in import
|
|
86
|
+
* order, each once (at its first reach). Throws with esbuild's own message when a module
|
|
87
|
+
* in the graph fails to resolve or parse — the renderer bundle would fail on the same.
|
|
88
|
+
*/
|
|
89
|
+
async function collectCssGraph(input) {
|
|
90
|
+
const result = await build({
|
|
91
|
+
entryPoints: [input.templateFile],
|
|
92
|
+
absWorkingDir: input.root,
|
|
93
|
+
bundle: true,
|
|
94
|
+
write: false,
|
|
95
|
+
metafile: true,
|
|
96
|
+
format: "esm",
|
|
97
|
+
platform: "browser",
|
|
98
|
+
jsx: "automatic",
|
|
99
|
+
outdir: "out",
|
|
100
|
+
loader: EMPTY_LOADERS,
|
|
101
|
+
plugins: [graphPlugin()],
|
|
102
|
+
logLevel: "silent"
|
|
103
|
+
});
|
|
104
|
+
const entryKey = relative(input.root, input.templateFile).split("\\").join("/");
|
|
105
|
+
return stylesheetsInImportOrder(result.metafile, entryKey);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { collectCssGraph };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { basename, extname, isAbsolute, join } from "node:path";
|
|
2
|
+
import { build } from "esbuild";
|
|
3
|
+
|
|
4
|
+
//#region src/css/inline.ts
|
|
5
|
+
/** Where a hashed asset is served from; the editor, the publisher and the renderer all resolve this path. */
|
|
6
|
+
const ASSET_PUBLIC_PATH = "/section-assets";
|
|
7
|
+
const ASSET_NAMES = "[name]-[hash]";
|
|
8
|
+
const ASSET_MIME = {
|
|
9
|
+
".svg": "image/svg+xml",
|
|
10
|
+
".png": "image/png",
|
|
11
|
+
".jpg": "image/jpeg",
|
|
12
|
+
".jpeg": "image/jpeg",
|
|
13
|
+
".gif": "image/gif",
|
|
14
|
+
".webp": "image/webp",
|
|
15
|
+
".avif": "image/avif",
|
|
16
|
+
".ico": "image/x-icon",
|
|
17
|
+
".woff": "font/woff",
|
|
18
|
+
".woff2": "font/woff2",
|
|
19
|
+
".ttf": "font/ttf",
|
|
20
|
+
".otf": "font/otf",
|
|
21
|
+
".eot": "application/vnd.ms-fontobject",
|
|
22
|
+
".mp4": "video/mp4",
|
|
23
|
+
".webm": "video/webm",
|
|
24
|
+
".mov": "video/quicktime",
|
|
25
|
+
".mp3": "audio/mpeg",
|
|
26
|
+
".wav": "audio/wav",
|
|
27
|
+
".pdf": "application/pdf",
|
|
28
|
+
".zip": "application/zip"
|
|
29
|
+
};
|
|
30
|
+
const REMOTE_RE = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
31
|
+
function importRulePlugin() {
|
|
32
|
+
return {
|
|
33
|
+
name: "concrete-css-inline",
|
|
34
|
+
setup(api) {
|
|
35
|
+
api.onResolve({ filter: /.*/ }, (args) => {
|
|
36
|
+
if (args.kind !== "import-rule") return void 0;
|
|
37
|
+
if (REMOTE_RE.test(args.path)) return {
|
|
38
|
+
path: args.path,
|
|
39
|
+
external: true
|
|
40
|
+
};
|
|
41
|
+
if (args.path.startsWith(".") || isAbsolute(args.path)) return void 0;
|
|
42
|
+
return {
|
|
43
|
+
path: args.path,
|
|
44
|
+
external: true
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function tailwindImportersInOrder(root, metafile) {
|
|
51
|
+
const importers = [];
|
|
52
|
+
const seen = /* @__PURE__ */ new Set();
|
|
53
|
+
const visit = (key) => {
|
|
54
|
+
if (seen.has(key)) return;
|
|
55
|
+
seen.add(key);
|
|
56
|
+
for (const record of metafile.inputs[key]?.imports ?? []) {
|
|
57
|
+
if (record.external === true) {
|
|
58
|
+
if (record.path === "tailwindcss") importers.push(join(root, key));
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
visit(record.path);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
visit("<stdin>");
|
|
65
|
+
return importers;
|
|
66
|
+
}
|
|
67
|
+
const LEADING_IMPORT_RE = /^@import\s[^;]*;\s*$/;
|
|
68
|
+
function hoistRemoteImports(css) {
|
|
69
|
+
const lines = css.split("\n");
|
|
70
|
+
let end = 0;
|
|
71
|
+
while (end < lines.length && (LEADING_IMPORT_RE.test(lines[end]) || lines[end].trim() === "")) end += 1;
|
|
72
|
+
const imports = lines.slice(0, end).filter((line) => line.trim() !== "");
|
|
73
|
+
const remote = imports.filter((line) => /^@import\s+(?:url\(\s*)?["']?(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(line));
|
|
74
|
+
const bare = imports.filter((line) => !remote.includes(line));
|
|
75
|
+
return [
|
|
76
|
+
...remote,
|
|
77
|
+
...bare,
|
|
78
|
+
...lines.slice(end)
|
|
79
|
+
].join("\n");
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Inline the graph's stylesheets (absolute paths, graph order) into one. Throws with
|
|
83
|
+
* esbuild's message when a local `@import` or `url()` does not resolve.
|
|
84
|
+
*/
|
|
85
|
+
async function inlineCssGraph(root, files) {
|
|
86
|
+
if (files.length === 0) return {
|
|
87
|
+
css: "",
|
|
88
|
+
assets: [],
|
|
89
|
+
tailwindImporters: []
|
|
90
|
+
};
|
|
91
|
+
const result = await build({
|
|
92
|
+
stdin: {
|
|
93
|
+
contents: files.map((file) => `@import ${JSON.stringify(file)};`).join("\n"),
|
|
94
|
+
resolveDir: root,
|
|
95
|
+
loader: "css"
|
|
96
|
+
},
|
|
97
|
+
absWorkingDir: root,
|
|
98
|
+
bundle: true,
|
|
99
|
+
write: false,
|
|
100
|
+
metafile: true,
|
|
101
|
+
outdir: "out",
|
|
102
|
+
loader: Object.fromEntries(Object.keys(ASSET_MIME).map((ext) => [ext, "file"])),
|
|
103
|
+
publicPath: ASSET_PUBLIC_PATH,
|
|
104
|
+
assetNames: ASSET_NAMES,
|
|
105
|
+
legalComments: "none",
|
|
106
|
+
plugins: [importRulePlugin()],
|
|
107
|
+
logLevel: "silent"
|
|
108
|
+
});
|
|
109
|
+
let css = "";
|
|
110
|
+
const assets = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const output of result.outputFiles) {
|
|
112
|
+
const ext = extname(output.path).toLowerCase();
|
|
113
|
+
if (ext === ".css") {
|
|
114
|
+
css = output.text;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const filename = basename(output.path);
|
|
118
|
+
assets.set(filename, {
|
|
119
|
+
filename,
|
|
120
|
+
bytes: output.contents,
|
|
121
|
+
contentType: ASSET_MIME[ext] ?? "application/octet-stream"
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
css: hoistRemoteImports(css.replace(/^\/\* [^\n]* \*\/\n/gm, "")),
|
|
126
|
+
assets: [...assets.values()],
|
|
127
|
+
tailwindImporters: tailwindImportersInOrder(root, result.metafile)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
export { ASSET_PUBLIC_PATH, inlineCssGraph };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
//#region src/css/rules.ts
|
|
5
|
+
/** Workspace-relative, `/` separators — the form every violation names a file in. */
|
|
6
|
+
function workspaceRelative(root, file) {
|
|
7
|
+
return relative(root, file).split("\\").join("/");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* `css/tailwind-import`: none, named at `template.ts` (where the entry stylesheet is
|
|
11
|
+
* imported), or a second one, named at the file carrying it. Two double-emit
|
|
12
|
+
* Tailwind's preflight and theme; none leaves every utility uncompiled.
|
|
13
|
+
*/
|
|
14
|
+
function tailwindImportViolations(input) {
|
|
15
|
+
if (input.importers.length === 0) return [{
|
|
16
|
+
rule: "css/tailwind-import",
|
|
17
|
+
file: workspaceRelative(input.root, input.templateFile),
|
|
18
|
+
message: "no stylesheet reachable from template.ts imports \"tailwindcss\". Import it once, at the top of the first stylesheet template.ts imports: @import \"tailwindcss\";"
|
|
19
|
+
}];
|
|
20
|
+
const [first, ...rest] = input.importers.map((file) => workspaceRelative(input.root, file));
|
|
21
|
+
return rest.map((file) => ({
|
|
22
|
+
rule: "css/tailwind-import",
|
|
23
|
+
file,
|
|
24
|
+
message: `a second @import "tailwindcss" (the first is in ${first}). The import graph owns exactly one; remove this one.`
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
const EXTERNAL_RE = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
28
|
+
const INLINE_RE = /^data:/i;
|
|
29
|
+
const URL_FUNCTION_RE = /url\(\s*(['"]?)([^'")\s]+)\1\s*\)/gi;
|
|
30
|
+
const IMPORT_STRING_RE = /@import\s+(['"])([^'"]+)\1/gi;
|
|
31
|
+
/** The external URLs a stylesheet references, each once, in order of appearance. */
|
|
32
|
+
function findExternalUrls(css) {
|
|
33
|
+
const found = /* @__PURE__ */ new Set();
|
|
34
|
+
const matches = [...css.matchAll(URL_FUNCTION_RE), ...css.matchAll(IMPORT_STRING_RE)].sort((a, b) => a.index - b.index);
|
|
35
|
+
for (const match of matches) {
|
|
36
|
+
const value = match[2];
|
|
37
|
+
if (EXTERNAL_RE.test(value) && !INLINE_RE.test(value)) found.add(value);
|
|
38
|
+
}
|
|
39
|
+
return [...found];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `css/external-url`, for a rendered template only: the render worker's page reaches
|
|
43
|
+
* nothing but its own bundle, so a font or image fetched from another host renders as
|
|
44
|
+
* a fallback in the captured artifact. Graded on the compiled stylesheet; each URL is
|
|
45
|
+
* named at the first graph file whose text carries it, else at `template.ts`.
|
|
46
|
+
*/
|
|
47
|
+
async function externalUrlViolations(input) {
|
|
48
|
+
const urls = findExternalUrls(input.css);
|
|
49
|
+
if (urls.length === 0) return [];
|
|
50
|
+
const texts = await Promise.all(input.sources.map(async (file) => ({
|
|
51
|
+
file,
|
|
52
|
+
text: await readFile(file, "utf8")
|
|
53
|
+
})));
|
|
54
|
+
return urls.map((url) => {
|
|
55
|
+
const source = texts.find(({ text }) => text.includes(url));
|
|
56
|
+
return {
|
|
57
|
+
rule: "css/external-url",
|
|
58
|
+
file: workspaceRelative(input.root, source?.file ?? input.templateFile),
|
|
59
|
+
message: `a rendered template's stylesheet references ${url}, which the renderer cannot reach. Put the file in the workspace and reference it by a relative url(); it ships content-hashed with the stylesheet.`
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { externalUrlViolations, findExternalUrls, tailwindImportViolations, workspaceRelative };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//#region src/design-system/format-variants.ts
|
|
2
|
+
const VARIANT_NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
3
|
+
/**
|
|
4
|
+
* Variant names a format id may not shadow: Tailwind's built-ins — its default
|
|
5
|
+
* breakpoints (which the kit leaves untouched), its static variants, and the
|
|
6
|
+
* roots of its functional variants (`group-*`, `data-*`, …). Shadowing one
|
|
7
|
+
* would silently rebind every existing use of that prefix in the section
|
|
8
|
+
* corpus. A template's own `breakpoints` theme tokens are its own namespace;
|
|
9
|
+
* a collision there is the template's to avoid, not parse-refusable here.
|
|
10
|
+
*/
|
|
11
|
+
const RESERVED_FORMAT_VARIANT_NAMES = /* @__PURE__ */ new Set([
|
|
12
|
+
"sm",
|
|
13
|
+
"md",
|
|
14
|
+
"lg",
|
|
15
|
+
"xl",
|
|
16
|
+
"2xl",
|
|
17
|
+
"hover",
|
|
18
|
+
"focus",
|
|
19
|
+
"focus-within",
|
|
20
|
+
"focus-visible",
|
|
21
|
+
"active",
|
|
22
|
+
"visited",
|
|
23
|
+
"target",
|
|
24
|
+
"first",
|
|
25
|
+
"last",
|
|
26
|
+
"only",
|
|
27
|
+
"odd",
|
|
28
|
+
"even",
|
|
29
|
+
"first-of-type",
|
|
30
|
+
"last-of-type",
|
|
31
|
+
"only-of-type",
|
|
32
|
+
"empty",
|
|
33
|
+
"disabled",
|
|
34
|
+
"enabled",
|
|
35
|
+
"checked",
|
|
36
|
+
"indeterminate",
|
|
37
|
+
"default",
|
|
38
|
+
"optional",
|
|
39
|
+
"required",
|
|
40
|
+
"valid",
|
|
41
|
+
"invalid",
|
|
42
|
+
"user-valid",
|
|
43
|
+
"user-invalid",
|
|
44
|
+
"in-range",
|
|
45
|
+
"out-of-range",
|
|
46
|
+
"placeholder-shown",
|
|
47
|
+
"autofill",
|
|
48
|
+
"read-only",
|
|
49
|
+
"open",
|
|
50
|
+
"inert",
|
|
51
|
+
"details-content",
|
|
52
|
+
"before",
|
|
53
|
+
"after",
|
|
54
|
+
"first-letter",
|
|
55
|
+
"first-line",
|
|
56
|
+
"marker",
|
|
57
|
+
"selection",
|
|
58
|
+
"file",
|
|
59
|
+
"backdrop",
|
|
60
|
+
"placeholder",
|
|
61
|
+
"dark",
|
|
62
|
+
"starting",
|
|
63
|
+
"print",
|
|
64
|
+
"noscript",
|
|
65
|
+
"motion-safe",
|
|
66
|
+
"motion-reduce",
|
|
67
|
+
"contrast-more",
|
|
68
|
+
"contrast-less",
|
|
69
|
+
"forced-colors",
|
|
70
|
+
"inverted-colors",
|
|
71
|
+
"pointer-fine",
|
|
72
|
+
"pointer-coarse",
|
|
73
|
+
"pointer-none",
|
|
74
|
+
"any-pointer-fine",
|
|
75
|
+
"any-pointer-coarse",
|
|
76
|
+
"any-pointer-none",
|
|
77
|
+
"portrait",
|
|
78
|
+
"landscape",
|
|
79
|
+
"ltr",
|
|
80
|
+
"rtl",
|
|
81
|
+
"popover-open",
|
|
82
|
+
"group",
|
|
83
|
+
"peer",
|
|
84
|
+
"has",
|
|
85
|
+
"not",
|
|
86
|
+
"in",
|
|
87
|
+
"data",
|
|
88
|
+
"aria",
|
|
89
|
+
"nth",
|
|
90
|
+
"nth-last",
|
|
91
|
+
"nth-of-type",
|
|
92
|
+
"nth-last-of-type",
|
|
93
|
+
"supports",
|
|
94
|
+
"min",
|
|
95
|
+
"max",
|
|
96
|
+
"container"
|
|
97
|
+
]);
|
|
98
|
+
/**
|
|
99
|
+
* Why `id` cannot be a format-variant name, or `null` when it can. One
|
|
100
|
+
* judgment shared by the manifest parse (which refuses the template) and
|
|
101
|
+
* {@link compileFormatVariantsToCss} (which refuses to emit).
|
|
102
|
+
*/
|
|
103
|
+
function formatVariantNameError(id) {
|
|
104
|
+
if (!VARIANT_NAME_RE.test(id)) return `Format id "${id}" cannot become a Tailwind variant: ids are kebab-case — [a-z0-9] groups separated by single hyphens.`;
|
|
105
|
+
if (RESERVED_FORMAT_VARIANT_NAMES.has(id)) return `Format id "${id}" shadows a reserved Tailwind variant name; pick an id that is not a kit breakpoint or Tailwind built-in.`;
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* One `@custom-variant` per declared format id, each scoped to the frame
|
|
110
|
+
* shell's `data-format` stamp (the frame root itself, or anything inside it).
|
|
111
|
+
* Prepend the returned block to the template's Tailwind entry.
|
|
112
|
+
*
|
|
113
|
+
* @throws when a format id fails {@link formatVariantNameError} — the manifest
|
|
114
|
+
* parse enforces the same rule earlier, so a throw here means the caller
|
|
115
|
+
* compiled formats no `defineTemplate` produced.
|
|
116
|
+
*/
|
|
117
|
+
function compileFormatVariantsToCss(formats) {
|
|
118
|
+
return `/* Derived per-format variants — one per declared format id. */\n${formats.map((format) => {
|
|
119
|
+
const error = formatVariantNameError(format.id);
|
|
120
|
+
if (error !== null) throw new Error(error);
|
|
121
|
+
const stamp = `[data-format="${format.id}"]`;
|
|
122
|
+
return `@custom-variant ${format.id} (&:where(${stamp}, ${stamp} *));`;
|
|
123
|
+
}).join("\n")}\n`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { RESERVED_FORMAT_VARIANT_NAMES, compileFormatVariantsToCss, formatVariantNameError };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CONCRETE_RULES } from "../rules/registry.js";
|
|
2
|
+
import { editorDeclaration } from "./rules/editor-declaration.js";
|
|
3
|
+
import { editorReason } from "./rules/editor-reason.js";
|
|
4
|
+
import { noClientRuntime } from "./rules/no-client-runtime.js";
|
|
5
|
+
import { noEditorGlobals } from "./rules/no-editor-globals.js";
|
|
6
|
+
import { noHardCodedColor } from "./rules/no-hard-coded-color.js";
|
|
7
|
+
import { noInlineStyle } from "./rules/no-inline-style.js";
|
|
8
|
+
import { noMarkerLiteral } from "./rules/no-marker-literal.js";
|
|
9
|
+
import { noNondeterminism } from "./rules/no-nondeterminism.js";
|
|
10
|
+
import { noPxBreakpoint } from "./rules/no-px-breakpoint.js";
|
|
11
|
+
import { noRawValues } from "./rules/no-raw-values.js";
|
|
12
|
+
import { serializableProps } from "./rules/serializable-props.js";
|
|
13
|
+
|
|
14
|
+
//#region src/eslint/authoring.ts
|
|
15
|
+
const NAMESPACE = "concrete/";
|
|
16
|
+
const AUTHORING_MODULES = {
|
|
17
|
+
"concrete/server/no-nondeterminism": noNondeterminism,
|
|
18
|
+
"concrete/server/no-client-runtime": noClientRuntime,
|
|
19
|
+
"concrete/server/no-inline-style": noInlineStyle,
|
|
20
|
+
"concrete/islands/serializable-props": serializableProps,
|
|
21
|
+
"concrete/islands/editor-declaration": editorDeclaration,
|
|
22
|
+
"concrete/islands/editor-reason": editorReason,
|
|
23
|
+
"concrete/islands/no-editor-globals": noEditorGlobals,
|
|
24
|
+
"concrete/slots/no-marker-literal": noMarkerLiteral,
|
|
25
|
+
"concrete/slots/no-raw-values": noRawValues,
|
|
26
|
+
"concrete/style/no-hard-coded-color": noHardCodedColor,
|
|
27
|
+
"concrete/style/no-px-breakpoint": noPxBreakpoint
|
|
28
|
+
};
|
|
29
|
+
const registered = CONCRETE_RULES.flatMap((rule) => {
|
|
30
|
+
if (rule.venue !== "eslint" || rule.engineId?.startsWith(NAMESPACE) !== true) return [];
|
|
31
|
+
const module = AUTHORING_MODULES[rule.engineId];
|
|
32
|
+
if (module === void 0) throw new Error(`The rule registry lists ${rule.engineId}, but the authoring tier has no module for it.`);
|
|
33
|
+
const severity = rule.severity ?? "error";
|
|
34
|
+
return [{
|
|
35
|
+
engineId: rule.engineId,
|
|
36
|
+
module,
|
|
37
|
+
severity
|
|
38
|
+
}];
|
|
39
|
+
});
|
|
40
|
+
/** The plugin's rules map, keyed by the name under the `concrete` namespace: every authoring rule the registry lists. */
|
|
41
|
+
const AUTHORING_PLUGIN_RULES = Object.fromEntries(registered.map(({ engineId, module }) => [engineId.slice(9), module]));
|
|
42
|
+
/** The enabled tier: every authoring rule the registry lists, at the severity it lists. */
|
|
43
|
+
const AUTHORING_RULES = Object.fromEntries(registered.map(({ engineId, severity }) => [engineId, severity]));
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { AUTHORING_PLUGIN_RULES, AUTHORING_RULES };
|