@bettercms-ai/convert 0.22.0 → 0.24.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 +12 -0
- package/README.md +39 -0
- package/dist/cli.js +502 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +96 -2
- package/dist/index.js +455 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -955,7 +955,7 @@ declare function attrsFor(path: string, kind: string, props?: AttrBinding[], sco
|
|
|
955
955
|
declare function propsAttribute(props: AttrBinding[]): string;
|
|
956
956
|
|
|
957
957
|
/** Bumped whenever the emitted source changes. `isKnownHelper` upgrades anything older. */
|
|
958
|
-
declare const HELPER_VERSION =
|
|
958
|
+
declare const HELPER_VERSION = 12;
|
|
959
959
|
/** Where each dialect's helper lives. Null = this dialect reads nothing at build time. */
|
|
960
960
|
declare const HELPER_PATH: Record<Dialect, string | null>;
|
|
961
961
|
/** The directory the snapshots live in, at the repository root. */
|
|
@@ -981,6 +981,22 @@ declare function helperSource(dialect: Dialect): string;
|
|
|
981
981
|
* treats them the same way, because it cannot tell them apart and must not overwrite either.
|
|
982
982
|
*/
|
|
983
983
|
declare function isKnownHelper(content: string, dialect: Dialect): number | null;
|
|
984
|
+
/** One committed helper a build may replace: where it lives, what replaces it, and which bytes qualify. */
|
|
985
|
+
interface HelperUpgrade {
|
|
986
|
+
path: string;
|
|
987
|
+
source: string;
|
|
988
|
+
/** sha256 of every OLDER helper this package wrote at `path`. Anything else is left alone. */
|
|
989
|
+
digests: string[];
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* What a BetterCMS build swaps in for a helper this package wrote at an older version.
|
|
993
|
+
*
|
|
994
|
+
* The hosting builder applies these to its own throwaway checkout — never to the repository — so a
|
|
995
|
+
* site converted before the helper read published content at request time gets that reader on its
|
|
996
|
+
* next build, with no commit and no codemod run. The rule is `isKnownHelper`'s: only bytes this
|
|
997
|
+
* package produced are replaced, so an edited or foreign module at the same path is never touched.
|
|
998
|
+
*/
|
|
999
|
+
declare function helperUpgrades(): HelperUpgrade[];
|
|
984
1000
|
|
|
985
1001
|
/**
|
|
986
1002
|
* The submit runtime, LIFTED VERBATIM from `src/lib/sites/render-page.ts` `FORM_SCRIPT`.
|
|
@@ -1837,6 +1853,84 @@ declare function readBrief(value: unknown): Brief;
|
|
|
1837
1853
|
*/
|
|
1838
1854
|
declare function readPlan(value: unknown): ComponentizePlan;
|
|
1839
1855
|
|
|
1856
|
+
/** The plan's own file shape, restated rather than imported to keep `index.ts` acyclic. */
|
|
1857
|
+
interface UpgradeFile {
|
|
1858
|
+
path: string;
|
|
1859
|
+
operation: "modify" | "add";
|
|
1860
|
+
content: string;
|
|
1861
|
+
}
|
|
1862
|
+
/** Why a root was left without the marker. */
|
|
1863
|
+
type UpgradeSkipReason =
|
|
1864
|
+
/** The root has its own `style` attribute; a second one would be resolved by the dialect. */
|
|
1865
|
+
"OWN_STYLE"
|
|
1866
|
+
/** The root has a spread (`{...rest}`) that may carry a style. */
|
|
1867
|
+
| "SPREAD"
|
|
1868
|
+
/** Only a block ID reaches the root (`{Astro.props.bcmsBlock}`, `{id}`): its style is not in scope. */
|
|
1869
|
+
| "BLOCK_ID_ONLY"
|
|
1870
|
+
/** `data-bcms-block="abc"`: a literal id, with no block object behind it. */
|
|
1871
|
+
| "BLOCK_LITERAL"
|
|
1872
|
+
/** A call, a conditional, anything that does not name one block. */
|
|
1873
|
+
| "BLOCK_UNRESOLVABLE"
|
|
1874
|
+
/** `data-bcms-block` on a component tag is a prop, not an element the editor can find. */
|
|
1875
|
+
| "NOT_AN_ELEMENT"
|
|
1876
|
+
/** A dialect this pass does not rewrite (html, vue, svelte). */
|
|
1877
|
+
| "DIALECT_UNSUPPORTED"
|
|
1878
|
+
/** The name this pass would introduce is already something else in the file. */
|
|
1879
|
+
| "NAME_TAKEN"
|
|
1880
|
+
/** A generated section whose registry or `bcms-sections` no longer has the shape it can patch. */
|
|
1881
|
+
| "REGISTRY_UNRECOGNISED"
|
|
1882
|
+
/** The file did not parse. */
|
|
1883
|
+
| "PARSE_ERROR";
|
|
1884
|
+
interface UpgradeRootRef {
|
|
1885
|
+
file: string;
|
|
1886
|
+
/** 1-based line of the root's `<`. */
|
|
1887
|
+
line: number;
|
|
1888
|
+
tag: string;
|
|
1889
|
+
/** What `data-bcms-block` was given, as written: `{blockId}`, `"abc"`. */
|
|
1890
|
+
block: string;
|
|
1891
|
+
}
|
|
1892
|
+
interface UpgradedRoot extends UpgradeRootRef {
|
|
1893
|
+
form: "section-prop" | "sectionRootAttrs" | "helper";
|
|
1894
|
+
}
|
|
1895
|
+
interface SkippedRoot extends UpgradeRootRef {
|
|
1896
|
+
reason: UpgradeSkipReason;
|
|
1897
|
+
message: string;
|
|
1898
|
+
}
|
|
1899
|
+
interface SectionUpgradeReceipt {
|
|
1900
|
+
/** The helper at `src/bcms-content.ts` (and its siblings), when there is one or this pass wrote one. */
|
|
1901
|
+
helpers: {
|
|
1902
|
+
path: string;
|
|
1903
|
+
from: number | null;
|
|
1904
|
+
to: number;
|
|
1905
|
+
operation: "add" | "modify" | "unchanged" | "foreign";
|
|
1906
|
+
}[];
|
|
1907
|
+
/** Generated registry / `bcms-sections` modules patched to hand `block.style` down. */
|
|
1908
|
+
registry: {
|
|
1909
|
+
path: string;
|
|
1910
|
+
operation: "modify" | "unchanged";
|
|
1911
|
+
}[];
|
|
1912
|
+
roots: {
|
|
1913
|
+
upgraded: UpgradedRoot[];
|
|
1914
|
+
alreadyMarked: UpgradeRootRef[];
|
|
1915
|
+
skipped: SkippedRoot[];
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
interface UpgradeOptions {
|
|
1919
|
+
/** Replace a helper module this package did not write, when a root needs the helper. */
|
|
1920
|
+
overwriteHelper?: boolean;
|
|
1921
|
+
/** The repository's root `package.json`, to tell whether its SDK exports `sectionRootAttrs`. */
|
|
1922
|
+
packageJson?: string;
|
|
1923
|
+
}
|
|
1924
|
+
/** Thrown, like `convertSources`, when the helper is needed and is not ours to replace. */
|
|
1925
|
+
declare class UpgradeError extends Error {
|
|
1926
|
+
readonly code = "HELPER_CONFLICT";
|
|
1927
|
+
constructor(message: string);
|
|
1928
|
+
}
|
|
1929
|
+
declare function upgradeSections(sources: readonly SourceFile[], options?: UpgradeOptions): Promise<{
|
|
1930
|
+
files: UpgradeFile[];
|
|
1931
|
+
receipt: SectionUpgradeReceipt;
|
|
1932
|
+
}>;
|
|
1933
|
+
|
|
1840
1934
|
/** One file operation, exactly as `src/lib/github/plan-digest.ts` spells it. */
|
|
1841
1935
|
interface PlanFile {
|
|
1842
1936
|
path: string;
|
|
@@ -1871,4 +1965,4 @@ declare function convertSources(briefIn: Brief, sources: SourceFile[], options?:
|
|
|
1871
1965
|
receipt: ConversionReceipt;
|
|
1872
1966
|
}>;
|
|
1873
1967
|
|
|
1874
|
-
export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, 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 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 SectionsReceipt, type Site, type SiteWhere, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, type ValidationCode, ValidationError, type Xray, type XrayBucket, aliasesFrom, assertForms, assertReceipt, assertSections, assetCandidates, assetImport, attrsFor, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, findLiteral, findSites, findSitesTolerant, fixFor, flat, helperSource, importsIn, isDecorativeGlyph, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, measureUnaddressable, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeCounts, routeOfFile, stripTags, unreadableConfigs, walkAst, wireForms };
|
|
1968
|
+
export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, 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, 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 };
|