@homepages/concrete 1.0.3 → 2.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 +97 -0
- package/codemods/manifest.json +8 -0
- package/codemods/unlayer-author-css.mjs +194 -0
- package/dist/artifact/playground/client/assets/index-CW7co-u9.js +1101 -0
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +21 -21
- package/dist/base.css +15 -2
- package/dist/cli/build/static.js +1 -1
- package/dist/cli/dev/server.js +6 -2
- package/dist/cli/dev/vite.js +42 -22
- package/dist/css/compile.js +26 -4
- package/dist/css/rules.js +72 -1
- package/dist/eslint/authoring.js +2 -0
- package/dist/eslint/rules/island-ids.js +39 -0
- package/dist/fixtures/media-plugin.js +32 -17
- package/dist/fixtures/media.js +4 -2
- package/dist/fixtures/property.js +12 -2
- package/dist/fixtures/resolve.js +58 -5
- package/dist/fixtures/rows.js +6 -1
- package/dist/fixtures.d.ts +57 -12
- package/dist/fixtures.js +7 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/islands/island-id.js +8 -0
- package/dist/islands/marker.d.ts +14 -4
- package/dist/islands/marker.js +18 -6
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/island-runtime/dist/index.js +4 -2
- package/dist/packages/internal/island-runtime/dist/island-id-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/use-island-id.d.ts +24 -0
- package/dist/packages/internal/island-runtime/dist/use-island-id.js +44 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +44 -2
- package/dist/rules/registry.js +19 -0
- package/dist/template/logic-shim.d.ts +2 -1
- package/dist/template/logic-shim.js +2 -1
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +4 -1
- package/package.json +1 -1
- package/dist/artifact/playground/client/assets/index-Da8V3M7E.js +0 -1101
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,102 @@
|
|
|
1
1
|
# @homepages/concrete
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 3456711: Manual: replace every `useId()` in a `"use client"` module with an id composed from `useIslandId()` — `` const bodyId = `${useIslandId()}-body`; `` — adding your own suffix per id, and a discriminator from your own data (a row key, a facet name) wherever one component renders more than once inside a single island.
|
|
8
|
+
|
|
9
|
+
BREAKING: `useId` in an island is now the error `concrete/islands/island-ids`, and `useIslandId` outside one is the same rule's other half.
|
|
10
|
+
|
|
11
|
+
An island renders twice — once on the server, inside its whole section, and once in the
|
|
12
|
+
browser, where hydration is rooted at the island itself. React's `useId` counts position
|
|
13
|
+
from the root of the tree it is rendering, so those two renders mint different ids, and
|
|
14
|
+
markup carrying one hydrates into an attribute mismatch reported in every visitor's
|
|
15
|
+
console. Passing a prefix cannot reconcile it; the id has to travel from one render to
|
|
16
|
+
the other as data, which is what `useIslandId` is: the id the server minted for this
|
|
17
|
+
island, read back from its marker when the browser takes over.
|
|
18
|
+
|
|
19
|
+
It is one value per island, at every depth — a nested island reads the id of the island
|
|
20
|
+
that hydrates it — so the part that distinguishes one id from another is yours to add.
|
|
21
|
+
Outside an island it is a fixed constant, which is why the rule's other half keeps
|
|
22
|
+
server-rendered code off it: a section renders once and hydrates never, so it has no id
|
|
23
|
+
to hand out and gives one to the island as a prop instead.
|
|
24
|
+
|
|
25
|
+
The rule finds the calls; most are a one-line change. Ids inside a dialog or a menu the
|
|
26
|
+
server never renders open were never wrong, but they are ported the same way.
|
|
27
|
+
|
|
28
|
+
- c3ac7da: Your CSS is no longer demoted below Tailwind's utilities. `base.css` used to declare
|
|
29
|
+
`@layer theme, base, components, sections, template, utilities`, and a workspace wrapped
|
|
30
|
+
its own rules in `sections.<name>` or `template` to sit in that order — below
|
|
31
|
+
`utilities`, where a declaration lost to any utility setting the same property on the
|
|
32
|
+
same element, however specific its selector, and only on the published page. Those two
|
|
33
|
+
layers are gone. Write a plain rule and it applies: unlayered CSS outranks every layer,
|
|
34
|
+
which is stock Tailwind v4, and where two of your stylesheets meet, specificity and
|
|
35
|
+
import order settle it as they always did.
|
|
36
|
+
|
|
37
|
+
Two things follow. A `:root` token you re-declare inside a section now takes effect
|
|
38
|
+
instead of losing to your entry stylesheet's own `:root`. And a utility you apply
|
|
39
|
+
conditionally — `className={present ? "" : "hidden"}` — no longer outranks a `display`
|
|
40
|
+
your stylesheet sets on that element, so give that property one owner: key the
|
|
41
|
+
stylesheet on a `data-*` attribute rather than toggling a class beside it. Anywhere a
|
|
42
|
+
rule of yours and a utility set the same property, your rule now wins where the utility
|
|
43
|
+
used to; that is the point of the change, and the conditional case is the one worth
|
|
44
|
+
looking at.
|
|
45
|
+
|
|
46
|
+
`concrete upgrade` runs the `unlayer-author-css` codemod, which unwraps your
|
|
47
|
+
`@layer sections.<name>` and `@layer template` blocks, deletes their ordering
|
|
48
|
+
statements, and re-points an `@import … layer(sections.<name>)` at `layer(components)`
|
|
49
|
+
so a third-party sheet stays below your own rules. It does not judge the cascade.
|
|
50
|
+
`concrete check` now refuses either layer name (`css/retired-layer`), because with them
|
|
51
|
+
undeclared a leftover wrapper would sort _after_ the utilities and flip the trap rather
|
|
52
|
+
than close it.
|
|
53
|
+
|
|
54
|
+
### Minor Changes
|
|
55
|
+
|
|
56
|
+
- d1a9bff: A fixture can now state a contact's image on an `image` slot. An image slot can fill from a contact card — `imageAssign({ …, fallback: contactAssign({ field: "logo_dark" }) })` bakes the chosen card's brand mark when no upload is one — but the card's avatar and logos live on the card rather than in a media pool, so no property entry named them and the slot could only be left empty in a fixture. `ImageEntry` now also admits a `ContactImageEntry`, the card plus the field: `content(Overview, { developerLogo: { contact: listingAgent, field: "logo_dark" } })`, where `field` is `avatar`, `logo_dark` or `logo_light`. It resolves to the same `{ asset_id }` the fill's bake writes for that field, so the fixture shows what a real fill of the property shows; a card the property does not carry, or a field the card holds `null`, is a `fixtures/media-not-in-property` check error like any other missing media.
|
|
57
|
+
- a6d2b71: A fixture can now state the fields a fill writes onto a collection-bound record list —
|
|
58
|
+
the residence descriptions, per-unit videos and tour picks a `units` list carries.
|
|
59
|
+
|
|
60
|
+
Such a list was unauthorable: its rows come from the property, so `content()` refused
|
|
61
|
+
the slot outright and the resolver took the bake and looked no further. That is only
|
|
62
|
+
half of what the platform does. A fill originates those rows from the facts and then
|
|
63
|
+
plans every field carrying no `source:` onto them in one call, and the row it stores
|
|
64
|
+
holds both halves — which is why a template that puts its residence copy, its unit
|
|
65
|
+
videos or its tour picks on the units list could not show any of them in `dev`, in the
|
|
66
|
+
playground or in a capture, however the fixture was written.
|
|
67
|
+
|
|
68
|
+
A content entry may now state such a list, and states only the enriched half: the
|
|
69
|
+
bound fields are typed away, the rows merge onto the bake by position, and a field a
|
|
70
|
+
row leaves unstated keeps the blank a fill that abstained would leave. Stating more
|
|
71
|
+
rows than the property carries is the new `fixtures/rows-not-in-property` check error,
|
|
72
|
+
which names the instance and both counts.
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- 93ef972: Image crop: a crop no longer depends on the browser tab that asked for it. The crop is written onto the slot the moment you press Apply, and the image resolver keeps serving what the slot showed before until the cropped pixels exist — so a crop job slower than the editor's watch, a reload, or a closed tab no longer discards it in silence. A crop that genuinely fails is taken back off the slot and reported there; a crop the editor stops watching says it is still processing, rather than clearing as if nothing had happened.
|
|
77
|
+
- d187883: An island's asset imports now name the same URL in `concrete dev` that the server
|
|
78
|
+
render names, so a section hydrates without an attribute mismatch on its own icons.
|
|
79
|
+
`dev` runs a workspace through two module graphs — esbuild for the server render, Vite
|
|
80
|
+
for the islands — and an island is in both, so an asset import had to agree in each.
|
|
81
|
+
It did not: Vite inlined any file under its 4 KB threshold as a `data:` URI and named a
|
|
82
|
+
raster by its workspace path, where the server named both under `/fixture-media/`. React
|
|
83
|
+
reported a hydration mismatch on the element carrying the asset, once per page, in every
|
|
84
|
+
developer's console — a framework error a browser proof over a template's fixtures then
|
|
85
|
+
had to special-case to find a real defect. Both graphs now resolve an asset through one
|
|
86
|
+
function, so there is nothing for them to disagree on. A built artifact was never
|
|
87
|
+
affected: both of its graphs are esbuild's.
|
|
88
|
+
- 6aa9426: A fixture link video or tour now resolves to its provider's embed URL, as the platform's resolvers emit it, so it plays in `concrete dev`, the playground and captures. A Vimeo or YouTube page link (`https://vimeo.com/530991517`, `watch?v=…`) becomes its player URL, and a Matterport share link becomes `show/?m=<sid>&nt=1`. A link that embeds nowhere, such as a Matterport `discover/space` link, resolves with `url: ""`, the renderer's empty branch, where it used to reach the iframe unrewritten. The property entry still keeps the URL as pasted.
|
|
89
|
+
- a22b34f: A Matterport 3D tour now resolves to `show/?m=<sid>&nt=1`, so a visitor on a phone keeps the page the tour is embedded in. Matterport's mobile Showcase navigates the top-level page out of the iframe of its own accord when the visitor taps play, replacing the whole host page with the provider's; `nt=1` is Matterport's own supported setting for opening the tour alongside the page instead. The parameter is mobile-only, so on a desktop the tour still plays inside its container exactly as before. A fixture property entry still keeps the tour link as pasted.
|
|
90
|
+
- 664793f: The fact catalog now grades the property's `narrative` as optional rather than blocking. A template that reads `f.narrative` no longer makes the description a question the property must answer before it can generate — the platform still asks for one on every property, but a listing whose context arrived as uploaded documents is not held back by an empty one. Nothing about how a section reads the fact changes; it can be blank where it could only be blank-and-unfinishable before.
|
|
91
|
+
- 5994cb9: The template stylesheet now resolves `@import "tailwindcss"` from the framework's own
|
|
92
|
+
Tailwind, not from the workspace. Tailwind's compiler already came from the framework,
|
|
93
|
+
and the stylesheet it compiles must match that compiler's version. The old lookup only
|
|
94
|
+
worked when a package manager hoisted `tailwindcss` beside the framework. Where it did
|
|
95
|
+
not, as in a pnpm workspace, `concrete dev` answered `/stylesheets/template.css` with
|
|
96
|
+
an error, so every page and capture frame rendered unstyled, and `check` and `build`
|
|
97
|
+
failed the same way. A workspace installed from npm compiles the same stylesheet as
|
|
98
|
+
before, byte for byte.
|
|
99
|
+
|
|
3
100
|
## 1.0.3
|
|
4
101
|
|
|
5
102
|
### Patch Changes
|
package/codemods/manifest.json
CHANGED
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
"1.0.3": {
|
|
17
17
|
"codemods": [],
|
|
18
18
|
"manual": []
|
|
19
|
+
},
|
|
20
|
+
"2.0.0": {
|
|
21
|
+
"codemods": [
|
|
22
|
+
"unlayer-author-css"
|
|
23
|
+
],
|
|
24
|
+
"manual": [
|
|
25
|
+
"replace every `useId()` in a `\"use client\"` module with an id composed from `useIslandId()` \u2014 `` const bodyId = `${useIslandId()}-body`; `` \u2014 adding your own suffix per id, and a discriminator from your own data (a row key, a facet name) wherever one component renders more than once inside a single island."
|
|
26
|
+
]
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// 2.0.0 — author CSS is no longer layered.
|
|
2
|
+
//
|
|
3
|
+
// `base.css` used to declare `@layer theme, base, components, sections, template,
|
|
4
|
+
// utilities`, and a workspace wrapped its own rules in `sections.<name>` / `template` to
|
|
5
|
+
// sit in that order. Those two layers ranked BELOW `utilities`, so a declaration in one
|
|
6
|
+
// lost to any utility setting the same property on the same element, whatever its
|
|
7
|
+
// selector's specificity. `base.css` no longer declares them, which flips the trap
|
|
8
|
+
// rather than closing it: an undeclared layer is sorted AFTER every declared one, so a
|
|
9
|
+
// leftover wrapper would make the same rule start winning instead. Neither ordering is
|
|
10
|
+
// something an author asked for, so this codemod removes the wrappers and `check`
|
|
11
|
+
// refuses the names from here on.
|
|
12
|
+
//
|
|
13
|
+
// What it does, per `.css` file in the workspace:
|
|
14
|
+
// - unwraps `@layer sections.<name> { … }` and `@layer template { … }`, de-indenting
|
|
15
|
+
// - deletes `@layer sections.a, sections.b;` ordering statements
|
|
16
|
+
// - rewrites `@import "pkg/x.css" layer(sections.<name>)` to `layer(components)`,
|
|
17
|
+
// which still demotes a third-party sheet below your own now-unlayered rules
|
|
18
|
+
//
|
|
19
|
+
// What it does NOT do: judge the cascade. Where a rule of yours and a utility on the
|
|
20
|
+
// same element set the same property, your rule now wins where the utility used to.
|
|
21
|
+
// That is the point of the change, and a handful of those flips are ones you want to
|
|
22
|
+
// look at — a utility applied conditionally (`className={hidden ? "hidden" : ""}`) that
|
|
23
|
+
// was counting on outranking your stylesheet is the shape to check first.
|
|
24
|
+
|
|
25
|
+
import { readdir, readFile, writeFile } from "node:fs/promises";
|
|
26
|
+
import { join, relative } from "node:path";
|
|
27
|
+
|
|
28
|
+
/** The layer names the old build owned. A workspace may not declare either any more. */
|
|
29
|
+
const RETIRED = new Set(["sections", "template"]);
|
|
30
|
+
|
|
31
|
+
const SKIP_DIRS = new Set(["node_modules", ".concrete", ".git", "dist", "build"]);
|
|
32
|
+
|
|
33
|
+
/** Every `.css` file under `root`, absolute, skipping build output and dependencies. */
|
|
34
|
+
async function cssFiles(root) {
|
|
35
|
+
const found = [];
|
|
36
|
+
async function walk(dir) {
|
|
37
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
38
|
+
if (entry.isDirectory()) {
|
|
39
|
+
if (!SKIP_DIRS.has(entry.name)) await walk(join(dir, entry.name));
|
|
40
|
+
} else if (entry.name.endsWith(".css")) {
|
|
41
|
+
found.push(join(dir, entry.name));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
await walk(root);
|
|
46
|
+
return found;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* `css` with every comment and string literal blanked to spaces, newlines kept, so
|
|
51
|
+
* indices still line up with the original. Searching happens here; edits apply to the
|
|
52
|
+
* original — which is how `@layer sections.<name>` written in a comment stays prose.
|
|
53
|
+
*/
|
|
54
|
+
function masked(css) {
|
|
55
|
+
const out = [...css];
|
|
56
|
+
const blank = (from, to) => {
|
|
57
|
+
for (let k = from; k < Math.min(to, css.length); k++) if (out[k] !== "\n") out[k] = " ";
|
|
58
|
+
};
|
|
59
|
+
for (let i = 0; i < css.length; ) {
|
|
60
|
+
if (css[i] === "/" && css[i + 1] === "*") {
|
|
61
|
+
const end = css.indexOf("*/", i + 2);
|
|
62
|
+
const stop = end === -1 ? css.length : end + 2;
|
|
63
|
+
blank(i, stop);
|
|
64
|
+
i = stop;
|
|
65
|
+
} else if (css[i] === '"' || css[i] === "'") {
|
|
66
|
+
const quote = css[i];
|
|
67
|
+
let k = i + 1;
|
|
68
|
+
while (k < css.length && css[k] !== quote) k += css[k] === "\\" ? 2 : 1;
|
|
69
|
+
blank(i, k + 1);
|
|
70
|
+
i = k + 1;
|
|
71
|
+
} else {
|
|
72
|
+
i += 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return out.join("");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** `sections.hero` → `sections`; the root segment is what the order is declared on. */
|
|
79
|
+
const rootOf = (name) => name.trim().split(".")[0].trim();
|
|
80
|
+
|
|
81
|
+
/** Index just past the `}` matching the `{` at `open`, or -1 if the file is unbalanced. */
|
|
82
|
+
function matchBrace(scan, open) {
|
|
83
|
+
let depth = 0;
|
|
84
|
+
for (let i = open; i < scan.length; i++) {
|
|
85
|
+
if (scan[i] === "{") depth += 1;
|
|
86
|
+
else if (scan[i] === "}" && --depth === 0) return i;
|
|
87
|
+
}
|
|
88
|
+
return -1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Start of the line holding `at`, when only whitespace precedes it on that line. */
|
|
92
|
+
function lineStart(css, at) {
|
|
93
|
+
const bol = css.lastIndexOf("\n", at - 1) + 1;
|
|
94
|
+
return css.slice(bol, at).trim() === "" ? bol : at;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** End of the line holding `at`, when only whitespace follows it on that line. */
|
|
98
|
+
function lineEnd(css, at) {
|
|
99
|
+
const eol = css.indexOf("\n", at);
|
|
100
|
+
if (eol === -1) return css.length;
|
|
101
|
+
return css.slice(at, eol).trim() === "" ? eol + 1 : at;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A layer block's body, stripped of the one indent level the wrapper added. */
|
|
105
|
+
function dedent(body) {
|
|
106
|
+
const lines = body.split("\n");
|
|
107
|
+
while (lines.length > 0 && lines[0].trim() === "") lines.shift();
|
|
108
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
|
|
109
|
+
const indents = lines.filter((l) => l.trim() !== "").map((l) => /^[ \t]*/.exec(l)[0].length);
|
|
110
|
+
const strip = indents.length === 0 ? 0 : Math.min(...indents);
|
|
111
|
+
return lines.map((l) => (l.trim() === "" ? "" : l.slice(strip))).join("\n");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* One retired-layer edit, or null when the file holds none left.
|
|
116
|
+
*
|
|
117
|
+
* Exactly one per call so the caller can re-scan between edits: every edit moves the
|
|
118
|
+
* offsets after it, and a nested wrapper would be read against a stale index otherwise.
|
|
119
|
+
*/
|
|
120
|
+
function nextEdit(css) {
|
|
121
|
+
const scan = masked(css);
|
|
122
|
+
|
|
123
|
+
// `@import … layer(sections.<name>)` — the third-party demotion, re-pointed.
|
|
124
|
+
for (const m of scan.matchAll(/\blayer\(\s*([^)]*?)\s*\)/gi)) {
|
|
125
|
+
if (!RETIRED.has(rootOf(m[1]))) continue;
|
|
126
|
+
return { start: m.index, end: m.index + m[0].length, text: "layer(components)" };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (const m of scan.matchAll(/@layer\b/gi)) {
|
|
130
|
+
const at = m.index;
|
|
131
|
+
let i = at + m[0].length;
|
|
132
|
+
while (i < scan.length && scan[i] !== "{" && scan[i] !== ";") i += 1;
|
|
133
|
+
if (i >= scan.length) continue;
|
|
134
|
+
const names = css
|
|
135
|
+
.slice(at + m[0].length, i)
|
|
136
|
+
.split(",")
|
|
137
|
+
.map(rootOf)
|
|
138
|
+
.filter((n) => n !== "");
|
|
139
|
+
if (!names.some((n) => RETIRED.has(n))) continue;
|
|
140
|
+
|
|
141
|
+
// A statement: `@layer a, b;`. Whole thing goes, with its line.
|
|
142
|
+
if (scan[i] === ";") {
|
|
143
|
+
if (!names.every((n) => RETIRED.has(n))) {
|
|
144
|
+
return { mixed: names.filter((n) => !RETIRED.has(n)) };
|
|
145
|
+
}
|
|
146
|
+
return { start: lineStart(css, at), end: lineEnd(css, i + 1), text: "" };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// A block: `@layer sections.hero { … }`. Wrapper goes, body stays, de-indented.
|
|
150
|
+
const close = matchBrace(scan, i);
|
|
151
|
+
if (close === -1) return { unbalanced: names[0] };
|
|
152
|
+
return {
|
|
153
|
+
start: lineStart(css, at),
|
|
154
|
+
end: lineEnd(css, close + 1),
|
|
155
|
+
text: `${dedent(css.slice(i + 1, close))}\n`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Applies every retired-layer edit to one file's text. */
|
|
162
|
+
function unlayer(css) {
|
|
163
|
+
let out = css;
|
|
164
|
+
for (let pass = 0; pass < 500; pass += 1) {
|
|
165
|
+
const edit = nextEdit(out);
|
|
166
|
+
if (edit === null) return { css: out };
|
|
167
|
+
if (edit.mixed !== undefined) {
|
|
168
|
+
return { reason: `an @layer statement names both retired and live layers (${edit.mixed.join(", ")}); split it by hand` };
|
|
169
|
+
}
|
|
170
|
+
if (edit.unbalanced !== undefined) {
|
|
171
|
+
return { reason: `@layer ${edit.unbalanced} is never closed; the file's braces are unbalanced` };
|
|
172
|
+
}
|
|
173
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
174
|
+
}
|
|
175
|
+
return { reason: "more than 500 retired-layer edits in one file, which is not a shape this codemod expects" };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** @param {string} root @returns {Promise<{rewritten: string[], notRewritten: {file: string, reason: string}[]}>} */
|
|
179
|
+
export default async function unlayerAuthorCss(root) {
|
|
180
|
+
const rewritten = [];
|
|
181
|
+
const notRewritten = [];
|
|
182
|
+
for (const file of await cssFiles(root)) {
|
|
183
|
+
const before = await readFile(file, "utf8");
|
|
184
|
+
const name = relative(root, file).split("\\").join("/");
|
|
185
|
+
const result = unlayer(before);
|
|
186
|
+
if (result.reason !== undefined) {
|
|
187
|
+
notRewritten.push({ file: name, reason: result.reason });
|
|
188
|
+
} else if (result.css !== before) {
|
|
189
|
+
await writeFile(file, result.css);
|
|
190
|
+
rewritten.push(name);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return { rewritten, notRewritten };
|
|
194
|
+
}
|