@bettercms-ai/convert 0.26.0 → 0.27.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 +19 -0
- package/README.md +40 -0
- package/dist/cli.js +3197 -2830
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +112 -3
- package/dist/index.js +3352 -3038
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -514,9 +514,13 @@ interface DynamicBinding {
|
|
|
514
514
|
* editable and the NUMBER of rows is still the template's — a row added in the CMS does not appear
|
|
515
515
|
* and a deleted one falls back to the template's own copy. The paths are `rewritten` and true; what
|
|
516
516
|
* the note adds is that ceiling. @see bindLists
|
|
517
|
+
*
|
|
518
|
+
* `FIELD_STYLE_SKIPPED` is one element this run stamped `data-bcms-field` on and could NOT give the
|
|
519
|
+
* `data-bcms-style` marker and its style (C3/C9) — its own `style`, a spread, a page it cannot name.
|
|
520
|
+
* The binding is real; the editor just offers no width or spacing handles on it. @see field-styles.ts
|
|
517
521
|
*/
|
|
518
522
|
interface ReceiptNote {
|
|
519
|
-
code: "TSCONFIG_UNREADABLE" | "TSCONFIG_EXTENDS_ONLY" | "PRIMITIVE_LIST";
|
|
523
|
+
code: "TSCONFIG_UNREADABLE" | "TSCONFIG_EXTENDS_ONLY" | "PRIMITIVE_LIST" | "FIELD_STYLE_SKIPPED";
|
|
520
524
|
file: string;
|
|
521
525
|
message: string;
|
|
522
526
|
}
|
|
@@ -957,7 +961,7 @@ declare function attrsFor(path: string, kind: string, props?: AttrBinding[], sco
|
|
|
957
961
|
declare function propsAttribute(props: AttrBinding[]): string;
|
|
958
962
|
|
|
959
963
|
/** Bumped whenever the emitted source changes. `isKnownHelper` upgrades anything older. */
|
|
960
|
-
declare const HELPER_VERSION =
|
|
964
|
+
declare const HELPER_VERSION = 15;
|
|
961
965
|
/** Where each dialect's helper lives. Null = this dialect reads nothing at build time. */
|
|
962
966
|
declare const HELPER_PATH: Record<Dialect, string | null>;
|
|
963
967
|
/** The directory the snapshots live in, at the repository root. */
|
|
@@ -1203,6 +1207,8 @@ interface ImageTarget {
|
|
|
1203
1207
|
/** The brief's `original` — the BUILT url. */
|
|
1204
1208
|
original: string;
|
|
1205
1209
|
slug: string;
|
|
1210
|
+
/** The file already declares this path: only a missing READ is added, and nothing is refused. */
|
|
1211
|
+
declared?: boolean;
|
|
1206
1212
|
}
|
|
1207
1213
|
interface ImageSplice {
|
|
1208
1214
|
start: number;
|
|
@@ -1885,6 +1891,38 @@ interface BcmsBuild {
|
|
|
1885
1891
|
*/
|
|
1886
1892
|
declare function bcmsBuildScript(packageJson: string): BcmsBuild | null;
|
|
1887
1893
|
|
|
1894
|
+
/**
|
|
1895
|
+
* `--upgrade-sections`: give the section roots of a site converted BEFORE helper v10 the
|
|
1896
|
+
* `data-bcms-style` marker, so the editor's section spacing and style handles (C3/C4) turn on.
|
|
1897
|
+
*
|
|
1898
|
+
* The editor shows those handles on a site-rendered page only when EVERY root the page stamps
|
|
1899
|
+
* with `data-bcms-block` also carries `data-bcms-style` — the site's promise that "this root's
|
|
1900
|
+
* inline style is `blockStyleToCss(block.style)`". A conversion made before v10 stamped the block
|
|
1901
|
+
* and never the style, so one unmarked root keeps the whole page off the lane. This pass makes the
|
|
1902
|
+
* promise TRUE before it makes it: a root gets the marker only together with the style that keeps
|
|
1903
|
+
* it, and only where the block that style belongs to can be named.
|
|
1904
|
+
*
|
|
1905
|
+
* Three ways a root can be given its style, chosen per root:
|
|
1906
|
+
*
|
|
1907
|
+
* - `section-prop` — a component `--componentize` wrote (`data-bcms-block={blockId}` in a file with
|
|
1908
|
+
* the section marker). The registry passes each placement's `block.style` as `blockStyle`, so the
|
|
1909
|
+
* root gets exactly what a fresh extraction writes today, the component gains the `blockStyle`
|
|
1910
|
+
* prop, and a registry or `bcms-sections` that predates it is patched to pass it.
|
|
1911
|
+
* - `sectionRootAttrs` — `data-bcms-block={block.id}` in a repository whose SDK exports
|
|
1912
|
+
* `sectionRootAttrs`: the attribute becomes `{...sectionRootAttrs(block)}`, which carries the id,
|
|
1913
|
+
* the marker and the style in one spread.
|
|
1914
|
+
* - `helper` — the same root where the SDK is older: `data-bcms-style="" style={…(block.style)}`
|
|
1915
|
+
* through the committed helper, which this pass upgrades (or adds) for the purpose.
|
|
1916
|
+
*
|
|
1917
|
+
* Everything else is LEFT ALONE and receipted with a reason: a root that already decides its own
|
|
1918
|
+
* inline style (a `style` attribute or a spread — which of two styles wins depends on the dialect),
|
|
1919
|
+
* and a root whose block cannot be named here (only an id string reaches it, a literal id, a
|
|
1920
|
+
* conditional). Marking one of those would paint a capsule the build never ships.
|
|
1921
|
+
*
|
|
1922
|
+
* Nothing else changes: no class, className or existing style token, which `--verify-styles`
|
|
1923
|
+
* checks, and a second run finds every root it marked already marked.
|
|
1924
|
+
*/
|
|
1925
|
+
|
|
1888
1926
|
/** The plan's own file shape, restated rather than imported to keep `index.ts` acyclic. */
|
|
1889
1927
|
interface UpgradeFile {
|
|
1890
1928
|
path: string;
|
|
@@ -1963,6 +2001,77 @@ declare function upgradeSections(sources: readonly SourceFile[], options?: Upgra
|
|
|
1963
2001
|
receipt: SectionUpgradeReceipt;
|
|
1964
2002
|
}>;
|
|
1965
2003
|
|
|
2004
|
+
/** Why a field element was left without the marker. */
|
|
2005
|
+
type FieldStyleSkipReason =
|
|
2006
|
+
/** The element has its own `style` attribute; a second one would be resolved by the dialect. */
|
|
2007
|
+
"OWN_STYLE"
|
|
2008
|
+
/** The element has a spread (`{...rest}`) that may carry a style. */
|
|
2009
|
+
| "SPREAD"
|
|
2010
|
+
/** A component tag other than `astro:assets` / `next/image`: whether it passes `style` on is unknown. */
|
|
2011
|
+
| "NOT_AN_ELEMENT"
|
|
2012
|
+
/** `data-bcms-layout-field`: the shared chrome has no page whose `fieldStyles` it could read. */
|
|
2013
|
+
| "LAYOUT_FIELD"
|
|
2014
|
+
/** An instance's own address (`<blockId>__overrides.<key>`): the section's `bind` owns it. */
|
|
2015
|
+
| "COMPONENT_INSTANCE"
|
|
2016
|
+
/** The address is computed (`{f("hero.title")}`, a prop): no path this pass can repeat. */
|
|
2017
|
+
| "PATH_UNRESOLVABLE"
|
|
2018
|
+
/** `data-bcms-kind` other than text, richtext or image. */
|
|
2019
|
+
| "KIND"
|
|
2020
|
+
/** No page snapshot is imported here, or more than one and the element reads none of them. */
|
|
2021
|
+
| "NO_SNAPSHOT"
|
|
2022
|
+
/** The reader's name already means something else in this file. */
|
|
2023
|
+
| "NAME_TAKEN"
|
|
2024
|
+
/** A dialect this pass does not rewrite (html, vue, svelte). */
|
|
2025
|
+
| "DIALECT_UNSUPPORTED"
|
|
2026
|
+
/** The file did not parse. */
|
|
2027
|
+
| "PARSE_ERROR";
|
|
2028
|
+
interface FieldStyleRef {
|
|
2029
|
+
file: string;
|
|
2030
|
+
/** 1-based line of the element's `<`. */
|
|
2031
|
+
line: number;
|
|
2032
|
+
tag: string;
|
|
2033
|
+
/** The `data-bcms-field` attribute as written: `data-bcms-field="hero-h1"`, `` data-bcms-field={`g[${i}].h3`} ``. */
|
|
2034
|
+
field: string;
|
|
2035
|
+
}
|
|
2036
|
+
interface SkippedFieldStyle extends FieldStyleRef {
|
|
2037
|
+
reason: FieldStyleSkipReason;
|
|
2038
|
+
message: string;
|
|
2039
|
+
}
|
|
2040
|
+
/** The reader each dialect's style attribute calls: a string for Astro, an object for JSX. */
|
|
2041
|
+
declare const FIELD_STYLE_READER: Record<"astro" | "jsx", string>;
|
|
2042
|
+
/**
|
|
2043
|
+
* Mark every page-field element in one parsed file that this pass can keep the promise for.
|
|
2044
|
+
*
|
|
2045
|
+
* `skip` names elements to pass over without a word — the ones a conversion did not stamp itself.
|
|
2046
|
+
*/
|
|
2047
|
+
declare function markFieldStyles(file: string, content: string, dialect: "astro" | "jsx", parsed: ParsedFile, skip?: (field: string) => boolean): {
|
|
2048
|
+
content: string;
|
|
2049
|
+
marked: FieldStyleRef[];
|
|
2050
|
+
alreadyMarked: FieldStyleRef[];
|
|
2051
|
+
skipped: SkippedFieldStyle[];
|
|
2052
|
+
};
|
|
2053
|
+
interface ElementStyleUpgradeReceipt {
|
|
2054
|
+
/** The helper at `src/bcms-content.ts` (and its siblings), when there is one or this pass wrote one. */
|
|
2055
|
+
helpers: SectionUpgradeReceipt["helpers"];
|
|
2056
|
+
fields: {
|
|
2057
|
+
upgraded: (FieldStyleRef & {
|
|
2058
|
+
form: "helper";
|
|
2059
|
+
})[];
|
|
2060
|
+
alreadyMarked: FieldStyleRef[];
|
|
2061
|
+
skipped: SkippedFieldStyle[];
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* `--upgrade-element-styles`: the same marker for a site converted before helper v15, over every
|
|
2066
|
+
* `data-bcms-field` element in the repository, plus the helper upgrade that makes the reader exist.
|
|
2067
|
+
*/
|
|
2068
|
+
declare function upgradeElementStyles(sources: readonly SourceFile[], options?: {
|
|
2069
|
+
overwriteHelper?: boolean;
|
|
2070
|
+
}): Promise<{
|
|
2071
|
+
files: UpgradeFile[];
|
|
2072
|
+
receipt: ElementStyleUpgradeReceipt;
|
|
2073
|
+
}>;
|
|
2074
|
+
|
|
1966
2075
|
/** One file operation, exactly as `src/lib/github/plan-digest.ts` spells it. */
|
|
1967
2076
|
interface PlanFile {
|
|
1968
2077
|
path: string;
|
|
@@ -1997,4 +2106,4 @@ declare function convertSources(briefIn: Brief, sources: SourceFile[], options?:
|
|
|
1997
2106
|
receipt: ConversionReceipt;
|
|
1998
2107
|
}>;
|
|
1999
2108
|
|
|
2000
|
-
export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, type BcmsBuild, type Brief, type BriefForm, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type CanvasResult, type CanvasSource, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, FORM_SCRIPT, type FileDeclaration, type FindSitesResult, type FixAction, FormInvariantError, type FormPendingReason, type FormsReceipt, HELPER_PATH, HELPER_VERSION, type HelperUpgrade, type ImageResult, type ImageTarget, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingFix, type PendingForm, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, SSR_DRAFT_RECIPE, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionUpgradeReceipt, type SectionsReceipt, type Site, type SiteWhere, type SkippedRoot, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, UpgradeError, type UpgradeOptions, type UpgradeRootRef, type UpgradeSkipReason, type UpgradedRoot, type ValidationCode, ValidationError, type Xray, type XrayBucket, aliasesFrom, assertForms, assertReceipt, assertSections, assetCandidates, assetImport, attrsFor, bcmsBuildScript, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, findLiteral, findSites, findSitesTolerant, fixFor, flat, helperSource, helperUpgrades, importsIn, isDecorativeGlyph, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, measureUnaddressable, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeCounts, routeOfFile, stripTags, unreadableConfigs, upgradeSections, walkAst, wireForms };
|
|
2109
|
+
export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, type BcmsBuild, type Brief, type BriefForm, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type CanvasResult, type CanvasSource, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, type ElementStyleUpgradeReceipt, FIELD_STYLE_READER, FORM_SCRIPT, type FieldStyleRef, type FieldStyleSkipReason, type FileDeclaration, type FindSitesResult, type FixAction, FormInvariantError, type FormPendingReason, type FormsReceipt, HELPER_PATH, HELPER_VERSION, type HelperUpgrade, type ImageResult, type ImageTarget, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingFix, type PendingForm, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, SSR_DRAFT_RECIPE, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionUpgradeReceipt, type SectionsReceipt, type Site, type SiteWhere, type SkippedFieldStyle, type SkippedRoot, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, UpgradeError, type UpgradeOptions, type UpgradeRootRef, type UpgradeSkipReason, type UpgradedRoot, type ValidationCode, ValidationError, type Xray, type XrayBucket, aliasesFrom, assertForms, assertReceipt, assertSections, assetCandidates, assetImport, attrsFor, bcmsBuildScript, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, findLiteral, findSites, findSitesTolerant, fixFor, flat, helperSource, helperUpgrades, importsIn, isDecorativeGlyph, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, markFieldStyles, measureUnaddressable, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeCounts, routeOfFile, stripTags, unreadableConfigs, upgradeElementStyles, upgradeSections, walkAst, wireForms };
|