@vermeulen.solutions/eventual 0.18.2 → 0.18.4

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.
@@ -1,197 +1,222 @@
1
- /**
2
- * Legacy source-install transform for `@vermeulen.solutions/eventual/install`. Registry installs
3
- * never execute this file; the host renders plugin panels directly.
4
- *
5
- * Blocks 1.2-1.3 render a form block as <form> inside the content editor's
6
- * <form>. Blocks 1.4+ render a div[role="group"] with its own Enter handling.
7
- * This patches both shapes plus Eventual-specific form state and date-label
8
- * behaviour that the host renderer does not provide.
9
- */
10
- import { fileURLToPath } from "node:url";
11
- const presentationModule = fileURLToPath(new URL("./editor-i18n.mjs",import.meta.url)).replaceAll("\\","/");
12
- export function patchEmbeddedBlockForms(source) {
13
- const marker = "function FormBlockComponent({ block, onAction }) {";
14
- const start = source.indexOf(marker);
15
- if (start < 0)
16
- throw new Error(
17
- "Unsupported EmDash Block Kit renderer: FormBlockComponent changed.",
18
- );
19
- const end = source.indexOf("\n//#endregion", start);
20
- if (end < 0) throw new Error("Unsupported EmDash Block Kit form boundary.");
21
- let component = source.slice(start, end);
22
- const initializer =
23
- "const [values, setValues] = useState(() => getInitialValues(block.fields));";
24
- if (!component.includes(initializer))
25
- throw new Error("Unsupported EmDash Block Kit form state initializer.");
26
- component = component.replace(
27
- initializer,
28
- initializer +
29
- "\n useEffect(() => setValues(getInitialValues(block.fields)), [block.fields]);",
30
- );
31
- const legacyForm =
32
- component.includes('jsxs("form", {') &&
33
- component.includes("onSubmit: handleSubmit,") &&
34
- component.includes('type: "submit",') &&
35
- component.includes("e.preventDefault();");
36
- const modernForm =
37
- !component.includes('jsxs("form", {') &&
38
- component.includes('role: "group"') &&
39
- component.includes('type: "button"') &&
40
- component.includes("onClick: handleClick");
41
- if (!legacyForm && !modernForm)
42
- throw new Error("Unsupported EmDash Block Kit form renderer.");
43
- const fieldKey = "}, field.action_id);";
44
- if (!component.includes(fieldKey))
45
- throw new Error("Unsupported EmDash Block Kit form field key.");
46
- component = component.replace(
47
- fieldKey,
48
- '}, field.action_id + JSON.stringify(field.initial_value));',
49
- );
50
- if (legacyForm) {
51
- for (const needle of [
52
- "e.preventDefault();",
53
- 'jsxs("form", {',
54
- "onSubmit: handleSubmit,",
55
- 'type: "submit",',
56
- ]) {
57
- if (!component.includes(needle))
58
- throw new Error("Unsupported EmDash Block Kit form: " + needle);
59
- }
60
- component = component.replace(
61
- "e.preventDefault();",
62
- `e.preventDefault();
63
- e.stopPropagation();
64
- const root=e.currentTarget.closest('[data-eventual-block-form]');
65
- const invalid=root?.querySelector(':invalid');
66
- if (invalid) { invalid.reportValidity?.(); return; }`,
67
- );
68
- component = component
69
- .replace('jsxs("form", {', 'jsxs("div", {')
70
- .replace(
71
- "onSubmit: handleSubmit,",
72
- `role: "group",
73
- "data-eventual-block-form": "",
74
- onKeyDown: (event) => {
75
- if (event.key === "Enter" && !event.defaultPrevented && !event.isComposing && event.target.tagName !== "TEXTAREA" && event.target.tagName !== "BUTTON" && event.target.getAttribute("role") !== "combobox") handleSubmit(event);
76
- },`,
77
- )
78
- .replace('type: "submit",', 'type: "button", onClick: handleSubmit,');
79
- }
80
- let patched = source.slice(0, start) + component + source.slice(end);
81
- // The 1.2/1.3 renderer omits the option key, producing warnings on every
82
- // venue choice. Use its stable value, including the empty "no venue" option.
83
- const optionKey = "children: item.label\n\t\t})";
84
- if (patched.includes(optionKey))
85
- patched = patched.replace(
86
- optionKey,
87
- "children: item.label\n\t\t}, item.value)",
88
- );
89
- const dateMarker =
90
- "function DateInputElementComponent({ element, onAction, onChange }) {";
91
- const dateStart = patched.indexOf(dateMarker),
92
- dateEnd = patched.indexOf("\n//#endregion", dateStart);
93
- if (dateStart < 0 || dateEnd < 0)
94
- throw new Error("Unsupported Block Kit date input.");
95
- const date = patched.slice(dateStart, dateEnd);
96
- if (!date.includes('jsx("label", {') || !date.includes('type: "date",'))
97
- throw new Error("Unsupported Block Kit date label.");
98
- patched =
99
- patched.slice(0, dateStart) +
100
- date
101
- .replace(dateMarker, dateMarker + "\n const eventualDateId=useId();")
102
- .replace('jsx("label", {', 'jsx("label", { htmlFor:eventualDateId,')
103
- .replace('type: "date",', 'type: "date", id:eventualDateId,') +
104
- patched.slice(dateEnd);
105
- return addUseIdImport(patched);
106
- }
107
-
108
- function addUseIdImport(source) {
109
- const reactImport = /import \{([^}]+)\} from "react";/;
110
- const match = source.match(reactImport);
111
- if (!match) throw new Error("Unsupported Block Kit React import.");
112
- const names = match[1].split(",").map((name) => name.trim());
113
- if (names.includes("useId")) return source;
114
- names.push("useId");
115
- return source.replace(
116
- reactImport,
117
- `import { ${names.join(", ")} } from "react";`,
118
- );
119
- }
120
- export function eventualEditorCompatibility() {
121
- let command = "serve";
122
- return {
123
- name: "eventual-embedded-block-forms-1.0.1",
124
- enforce: "pre",
125
- config(_config, env = { command: "serve" }) {
126
- command = env.command ?? "serve";
127
- // Keep core's admin prebundle (including its CommonJS dependencies) and
128
- // apply presentation before optimization in dev. Production builds use
129
- // the regular transform below; applying both duplicates the admin module.
130
- return { optimizeDeps: { exclude: ["@emdash-cms/blocks"], rolldownOptions: {plugins:[{name:"eventual-admin-presentation-1.0.1", transform(source,id) {
131
- if (command !== "serve") return null;
132
- if (id.replaceAll("\\", "/").endsWith("/@emdash-cms/admin/dist/index.js")) return {code:patchEventualPresentation(source),map:null};
133
- return null;
134
- }}]} } };
135
- },
136
- transform(source, id) {
137
- const path = id.replaceAll("\\", "/").split("?")[0];
138
- if (path.endsWith("/@emdash-cms/admin/dist/index.js"))
139
- return command === "serve"
140
- ? null
141
- : { code: patchEventualPresentation(source), map: null };
142
- if (
143
- !id
144
- .replaceAll("\\", "/")
145
- .split("?")[0]
146
- .endsWith("/@emdash-cms/blocks/dist/index.js")
147
- )
148
- return null;
149
- return { code: patchEmbeddedBlockForms(source), map: null };
150
- },
151
- };
152
- }
153
-
154
- /** Presentation adapter for the tested admin build. RPC and receipts stay untouched. */
155
- export function patchEventualPresentation(source) {
156
- const original = 'import { BlockRenderer, isSafePluginPagePath, normalizePluginPagePath } from "@emdash-cms/blocks";';
157
- const panel = 'function SandboxedContentEditorPanel({ pluginId, panelId, title, collection, entryId, locale, versionToken, draftAccess, captureDraft, onDraftResponse, onEntryRefresh, reserveHeaderEnd = false }) {';
158
- const fieldLabel = 'return field?.label || slug.charAt(0).toUpperCase() + slug.slice(1);';
159
- const preview = 'function EditorDraftPatchPreview({ operations, fields, currentValues, onApply, onClose }) {';
160
- const editPage = 'function ContentEditPage() {';
161
- if (!source.includes(original) || !source.includes(panel) || !source.includes(fieldLabel) || !source.includes(editPage)) throw new Error("Unsupported EmDash admin presentation adapter. Use the tested compatibility matrix.");
162
- let patched=source.replace(original, original.replace("{ BlockRenderer,", "{ BlockRenderer as EventualOriginalBlockRenderer,") + `
163
- import { localizeEventualBlocks, draftSummary as eventualDraftSummary, editorText as eventualEditorText, loadEditorCatalog as eventualLoadCatalog, onEditorCatalog as eventualOnCatalog } from ${JSON.stringify(presentationModule)};
164
- function BlockRenderer(props) {
165
- const {locale}=useLocale();
166
- const [eventualCatalogTick,eventualSetCatalogTick]=React$1.useState(0);
167
- React$1.useEffect(()=>{ const off=eventualOnCatalog(()=>eventualSetCatalogTick(n=>n+1)); eventualLoadCatalog(locale); return off; },[locale]);
168
- const blocks=React$1.useMemo(()=>localizeEventualBlocks(props.blocks, locale), [props.blocks,locale,eventualCatalogTick]);
169
- return jsx(EventualOriginalBlockRenderer, {...props,blocks});
170
- }`)
171
- .replace(panel, panel + '\n const {locale: eventualUiLocale}=useLocale();\n if(pluginId === "eventual") title=eventualEditorText(title,eventualUiLocale);')
172
- .replace(fieldLabel, 'const label=field?.label || slug.charAt(0).toUpperCase() + slug.slice(1); return field?.options?.eventualEditor ? eventualEditorText(label,i18n.locale) : label;')
173
- // ContentEditPage's local i18n is the content configuration, not Lingui.
174
- .replace(editPage,editPage+'\n const {locale:eventualPageUiLocale}=useLocale();')
175
- .replace('description: error instanceof Error ? error.message : _t4({', 'description: error instanceof Error ? (collectionFields.start?.options?.eventualEditor ? eventualEditorText(error.message,eventualPageUiLocale) : error.message) : _t4({')
176
- .replace(preview, preview + '\n const {locale: eventualPreviewLocale}=useLocale(); const eventualPreview=fields.start?.options?.eventualEditor===true;')
177
- .replace('function EditorDraftPatchPreview({ operations, fields, currentValues, onApply, onClose }) {\n const {locale: eventualPreviewLocale}=useLocale(); const eventualPreview=fields.start?.options?.eventualEditor===true;\n\tconst { _: _t } = useLingui();', preview + '\n const {locale: eventualPreviewLocale}=useLocale(); const eventualPreview=fields.start?.options?.eventualEditor===true;\n const {_: eventualOriginalT}=useLingui(); const _t=eventualPreview ? message=>eventualEditorText(eventualOriginalT(message), eventualPreviewLocale):eventualOriginalT;')
178
- .replace('children: fields[operation.field]?.label ?? operation.field', 'children: eventualPreview ? eventualEditorText(fields[operation.field]?.label ?? operation.field,eventualPreviewLocale) : fields[operation.field]?.label ?? operation.field')
179
- .replace('children: summarize(currentValues[operation.field])', 'children: eventualPreview ? eventualDraftSummary(operation.field,currentValues[operation.field],eventualPreviewLocale,currentValues.timezone) : summarize(currentValues[operation.field])')
180
- .replace('children: summarize(operation.op === "clear" ? null : operation.value)', 'children: eventualPreview ? eventualDraftSummary(operation.field,operation.op === "clear" ? null : operation.value,eventualPreviewLocale,currentValues.timezone) : summarize(operation.op === "clear" ? null : operation.value)');
181
- const editorStart=patched.indexOf('function ContentEditor({'), editorEnd=patched.indexOf('\n//#endregion',editorStart);
182
- if(editorStart<0 || editorEnd<0) throw new Error("Unsupported content editor boundary.");
183
- const editor=patched.slice(editorStart,editorEnd).replaceAll('jsx(PublishActions, {','jsx(PublishActions, { eventualUi:Object.values(fields).some(field=>field.options?.eventualEditor===true),').replaceAll('jsx(SettingsActionBar, {','jsx(SettingsActionBar, { eventualUi:Object.values(fields).some(field=>field.options?.eventualEditor===true),');
184
- patched=patched.slice(0,editorStart)+editor+patched.slice(editorEnd);
185
- // Admin 1.2/1.3 use SettingsActionBar; 1.4 removed it. Patch it only when present.
186
- const barStart=patched.indexOf('function SettingsActionBar({');
187
- if(barStart>=0){
188
- const barEnd=patched.indexOf('\nfunction ',barStart+1);
189
- if(barEnd<0) throw new Error("Unsupported settings action bar boundary.");
190
- patched=patched.slice(0,barStart)+patched.slice(barStart,barEnd).replace('jsx(PublishActions, {','jsx(PublishActions, { eventualUi,')+patched.slice(barEnd);
191
- patched=patched.replace('function SettingsActionBar({ collectionLabel,','function SettingsActionBar({ eventualUi=false, collectionLabel,');
192
- if(!patched.includes('function SettingsActionBar({ eventualUi=false, collectionLabel,')) throw new Error("Unsupported settings action bar signature.");
193
- }
194
- const publishPattern=/function PublishActions\(\{ collectionLabel, (isNew, isLive, hasPendingChanges, publishingState, isPending, disabled, onPublish, onUnpublish, onMenuOpenChange, size, (?:fullWidth|compact)) \}\) \{\n\tconst \{ _: _t4 \} = useLingui\(\);/;
195
- if(!publishPattern.test(patched)) throw new Error("Unsupported publish actions signature.");
196
- return patched.replace(publishPattern, (_match, props) => `function PublishActions({ eventualUi=false, collectionLabel, ${props} }) {\n const {locale: eventualPublishLocale}=useLocale(); const {_:eventualPublishT}=useLingui(); const _t4=eventualUi ? message=>eventualEditorText(eventualPublishT(message),eventualPublishLocale):eventualPublishT;`);
197
- }
1
+ /**
2
+ * Legacy source-install transform for `@vermeulen.solutions/eventual/install`. Registry installs
3
+ * never execute this file; the host renders plugin panels directly.
4
+ *
5
+ * Blocks 1.2-1.3 render a form block as <form> inside the content editor's
6
+ * <form>. Blocks 1.4+ render a div[role="group"] with its own Enter handling.
7
+ * This patches both shapes plus Eventual-specific form state and date-label
8
+ * behaviour that the host renderer does not provide.
9
+ */
10
+ import { fileURLToPath } from "node:url";
11
+ const warned = new Set();
12
+ export function warnOnce(message) {
13
+ if (warned.has(message)) return;
14
+ warned.add(message);
15
+ console.warn("[eventual] " + message);
16
+ }
17
+ const presentationModule = fileURLToPath(new URL("./editor-i18n.mjs",import.meta.url)).replaceAll("\\","/");
18
+ export function patchEmbeddedBlockForms(source) {
19
+ const marker = "function FormBlockComponent({ block, onAction }) {";
20
+ const start = source.indexOf(marker);
21
+ if (start < 0)
22
+ throw new Error(
23
+ "Unsupported EmDash Block Kit renderer: FormBlockComponent changed.",
24
+ );
25
+ const end = source.indexOf("\n//#endregion", start);
26
+ if (end < 0) throw new Error("Unsupported EmDash Block Kit form boundary.");
27
+ let component = source.slice(start, end);
28
+ const initializer =
29
+ "const [values, setValues] = useState(() => getInitialValues(block.fields));";
30
+ if (!component.includes(initializer))
31
+ throw new Error("Unsupported EmDash Block Kit form state initializer.");
32
+ component = component.replace(
33
+ initializer,
34
+ initializer +
35
+ "\n useEffect(() => setValues(getInitialValues(block.fields)), [block.fields]);",
36
+ );
37
+ const legacyForm =
38
+ component.includes('jsxs("form", {') &&
39
+ component.includes("onSubmit: handleSubmit,") &&
40
+ component.includes('type: "submit",') &&
41
+ component.includes("e.preventDefault();");
42
+ const modernForm =
43
+ !component.includes('jsxs("form", {') &&
44
+ component.includes('role: "group"') &&
45
+ component.includes('type: "button"') &&
46
+ component.includes("onClick: handleClick");
47
+ if (!legacyForm && !modernForm)
48
+ throw new Error("Unsupported EmDash Block Kit form renderer.");
49
+ const fieldKey = "}, field.action_id);";
50
+ if (!component.includes(fieldKey))
51
+ throw new Error("Unsupported EmDash Block Kit form field key.");
52
+ component = component.replace(
53
+ fieldKey,
54
+ '}, field.action_id + JSON.stringify(field.initial_value));',
55
+ );
56
+ if (legacyForm) {
57
+ for (const needle of [
58
+ "e.preventDefault();",
59
+ 'jsxs("form", {',
60
+ "onSubmit: handleSubmit,",
61
+ 'type: "submit",',
62
+ ]) {
63
+ if (!component.includes(needle))
64
+ throw new Error("Unsupported EmDash Block Kit form: " + needle);
65
+ }
66
+ component = component.replace(
67
+ "e.preventDefault();",
68
+ `e.preventDefault();
69
+ e.stopPropagation();
70
+ const root=e.currentTarget.closest('[data-eventual-block-form]');
71
+ const invalid=root?.querySelector(':invalid');
72
+ if (invalid) { invalid.reportValidity?.(); return; }`,
73
+ );
74
+ component = component
75
+ .replace('jsxs("form", {', 'jsxs("div", {')
76
+ .replace(
77
+ "onSubmit: handleSubmit,",
78
+ `role: "group",
79
+ "data-eventual-block-form": "",
80
+ onKeyDown: (event) => {
81
+ if (event.key === "Enter" && !event.defaultPrevented && !event.isComposing && event.target.tagName !== "TEXTAREA" && event.target.tagName !== "BUTTON" && event.target.getAttribute("role") !== "combobox") handleSubmit(event);
82
+ },`,
83
+ )
84
+ .replace('type: "submit",', 'type: "button", onClick: handleSubmit,');
85
+ }
86
+ let patched = source.slice(0, start) + component + source.slice(end);
87
+ // The 1.2/1.3 renderer omits the option key, producing warnings on every
88
+ // venue choice. Use its stable value, including the empty "no venue" option.
89
+ const optionKey = "children: item.label\n\t\t})";
90
+ if (patched.includes(optionKey))
91
+ patched = patched.replace(
92
+ optionKey,
93
+ "children: item.label\n\t\t}, item.value)",
94
+ );
95
+ const dateMarker =
96
+ "function DateInputElementComponent({ element, onAction, onChange }) {";
97
+ const dateStart = patched.indexOf(dateMarker),
98
+ dateEnd = patched.indexOf("\n//#endregion", dateStart);
99
+ if (dateStart < 0 || dateEnd < 0)
100
+ throw new Error("Unsupported Block Kit date input.");
101
+ const date = patched.slice(dateStart, dateEnd);
102
+ if (!date.includes('jsx("label", {') || !date.includes('type: "date",'))
103
+ throw new Error("Unsupported Block Kit date label.");
104
+ patched =
105
+ patched.slice(0, dateStart) +
106
+ date
107
+ .replace(dateMarker, dateMarker + "\n const eventualDateId=useId();")
108
+ .replace('jsx("label", {', 'jsx("label", { htmlFor:eventualDateId,')
109
+ .replace('type: "date",', 'type: "date", id:eventualDateId,') +
110
+ patched.slice(dateEnd);
111
+ return addUseIdImport(patched);
112
+ }
113
+
114
+ function addUseIdImport(source) {
115
+ const reactImport = /import \{([^}]+)\} from "react";/;
116
+ const match = source.match(reactImport);
117
+ if (!match) throw new Error("Unsupported Block Kit React import.");
118
+ const names = match[1].split(",").map((name) => name.trim());
119
+ if (names.includes("useId")) return source;
120
+ names.push("useId");
121
+ return source.replace(
122
+ reactImport,
123
+ `import { ${names.join(", ")} } from "react";`,
124
+ );
125
+ }
126
+ /**
127
+ * Apply an adapter patch, or leave the host module untouched when its build is not one we recognise.
128
+ * A newer EmDash then shows stock editor behaviour (untranslated labels, host form handling) instead
129
+ * of failing the whole site build.
130
+ */
131
+ export function patchOrPassThrough(patch, source, what, warn = warnOnce) {
132
+ try { return { code: patch(source), map: null }; }
133
+ catch (error) {
134
+ warn(`${what} did not match this EmDash build (${error.message}); using the stock EmDash editor for it. Check the event editor and report the EmDash version.`);
135
+ return null;
136
+ }
137
+ }
138
+ export function eventualEditorCompatibility() {
139
+ let command = "serve";
140
+ return {
141
+ name: "eventual-embedded-block-forms-1.0.1",
142
+ enforce: "pre",
143
+ config(_config, env = { command: "serve" }) {
144
+ command = env.command ?? "serve";
145
+ // Keep core's admin prebundle (including its CommonJS dependencies) and
146
+ // apply presentation before optimization in dev. Production builds use
147
+ // the regular transform below; applying both duplicates the admin module.
148
+ return { optimizeDeps: { exclude: ["@emdash-cms/blocks"], rolldownOptions: {plugins:[{name:"eventual-admin-presentation-1.0.1", transform(source,id) {
149
+ if (command !== "serve") return null;
150
+ if (id.replaceAll("\\", "/").endsWith("/@emdash-cms/admin/dist/index.js")) return patchOrPassThrough(patchEventualPresentation, source, "Eventual's admin presentation adapter");
151
+ return null;
152
+ }}]} } };
153
+ },
154
+ transform(source, id) {
155
+ const path = id.replaceAll("\\", "/").split("?")[0];
156
+ if (path.endsWith("/@emdash-cms/admin/dist/index.js"))
157
+ return command === "serve"
158
+ ? null
159
+ : patchOrPassThrough(patchEventualPresentation, source, "Eventual's admin presentation adapter");
160
+ if (
161
+ !id
162
+ .replaceAll("\\", "/")
163
+ .split("?")[0]
164
+ .endsWith("/@emdash-cms/blocks/dist/index.js")
165
+ )
166
+ return null;
167
+ return patchOrPassThrough(patchEmbeddedBlockForms, source, "Eventual's Block Kit form adapter");
168
+ },
169
+ };
170
+ }
171
+
172
+ /** Presentation adapter for the tested admin build. RPC and receipts stay untouched. */
173
+ export function patchEventualPresentation(source) {
174
+ const original = 'import { BlockRenderer, isSafePluginPagePath, normalizePluginPagePath } from "@emdash-cms/blocks";';
175
+ // EmDash 1.5 dropped the unused `reserveHeaderEnd` prop from the panel host; accept both builds.
176
+ const panelSignatures = [
177
+ 'function SandboxedContentEditorPanel({ pluginId, panelId, title, collection, entryId, locale, versionToken, draftAccess, captureDraft, onDraftResponse, onEntryRefresh, reserveHeaderEnd = false }) {',
178
+ 'function SandboxedContentEditorPanel({ pluginId, panelId, title, collection, entryId, locale, versionToken, draftAccess, captureDraft, onDraftResponse, onEntryRefresh }) {',
179
+ ];
180
+ const panel = panelSignatures.find(signature => source.includes(signature)) ?? panelSignatures[0];
181
+ const fieldLabel = 'return field?.label || slug.charAt(0).toUpperCase() + slug.slice(1);';
182
+ const preview = 'function EditorDraftPatchPreview({ operations, fields, currentValues, onApply, onClose }) {';
183
+ const editPage = 'function ContentEditPage() {';
184
+ if (!source.includes(original) || !source.includes(panel) || !source.includes(fieldLabel) || !source.includes(editPage)) throw new Error("Unsupported EmDash admin presentation adapter. Use the tested compatibility matrix.");
185
+ let patched=source.replace(original, original.replace("{ BlockRenderer,", "{ BlockRenderer as EventualOriginalBlockRenderer,") + `
186
+ import { localizeEventualBlocks, draftSummary as eventualDraftSummary, editorText as eventualEditorText, loadEditorCatalog as eventualLoadCatalog, onEditorCatalog as eventualOnCatalog } from ${JSON.stringify(presentationModule)};
187
+ function BlockRenderer(props) {
188
+ const {locale}=useLocale();
189
+ const [eventualCatalogTick,eventualSetCatalogTick]=React$1.useState(0);
190
+ React$1.useEffect(()=>{ const off=eventualOnCatalog(()=>eventualSetCatalogTick(n=>n+1)); eventualLoadCatalog(locale); return off; },[locale]);
191
+ const blocks=React$1.useMemo(()=>localizeEventualBlocks(props.blocks, locale), [props.blocks,locale,eventualCatalogTick]);
192
+ return jsx(EventualOriginalBlockRenderer, {...props,blocks});
193
+ }`)
194
+ .replace(panel, panel + '\n const {locale: eventualUiLocale}=useLocale();\n if(pluginId === "eventual") title=eventualEditorText(title,eventualUiLocale);')
195
+ .replace(fieldLabel, 'const label=field?.label || slug.charAt(0).toUpperCase() + slug.slice(1); return field?.options?.eventualEditor ? eventualEditorText(label,i18n.locale) : label;')
196
+ // ContentEditPage's local i18n is the content configuration, not Lingui.
197
+ .replace(editPage,editPage+'\n const {locale:eventualPageUiLocale}=useLocale();')
198
+ .replace('description: error instanceof Error ? error.message : _t4({', 'description: error instanceof Error ? (collectionFields.start?.options?.eventualEditor ? eventualEditorText(error.message,eventualPageUiLocale) : error.message) : _t4({')
199
+ .replace(preview, preview + '\n const {locale: eventualPreviewLocale}=useLocale(); const eventualPreview=fields.start?.options?.eventualEditor===true;')
200
+ .replace('function EditorDraftPatchPreview({ operations, fields, currentValues, onApply, onClose }) {\n const {locale: eventualPreviewLocale}=useLocale(); const eventualPreview=fields.start?.options?.eventualEditor===true;\n\tconst { _: _t } = useLingui();', preview + '\n const {locale: eventualPreviewLocale}=useLocale(); const eventualPreview=fields.start?.options?.eventualEditor===true;\n const {_: eventualOriginalT}=useLingui(); const _t=eventualPreview ? message=>eventualEditorText(eventualOriginalT(message), eventualPreviewLocale):eventualOriginalT;')
201
+ .replace('children: fields[operation.field]?.label ?? operation.field', 'children: eventualPreview ? eventualEditorText(fields[operation.field]?.label ?? operation.field,eventualPreviewLocale) : fields[operation.field]?.label ?? operation.field')
202
+ .replace('children: summarize(currentValues[operation.field])', 'children: eventualPreview ? eventualDraftSummary(operation.field,currentValues[operation.field],eventualPreviewLocale,currentValues.timezone) : summarize(currentValues[operation.field])')
203
+ .replace('children: summarize(operation.op === "clear" ? null : operation.value)', 'children: eventualPreview ? eventualDraftSummary(operation.field,operation.op === "clear" ? null : operation.value,eventualPreviewLocale,currentValues.timezone) : summarize(operation.op === "clear" ? null : operation.value)');
204
+ const editorStart=patched.indexOf('function ContentEditor({'), editorEnd=patched.indexOf('\n//#endregion',editorStart);
205
+ if(editorStart<0 || editorEnd<0) throw new Error("Unsupported content editor boundary.");
206
+ const editor=patched.slice(editorStart,editorEnd).replaceAll('jsx(PublishActions, {','jsx(PublishActions, { eventualUi:Object.values(fields).some(field=>field.options?.eventualEditor===true),').replaceAll('jsx(SettingsActionBar, {','jsx(SettingsActionBar, { eventualUi:Object.values(fields).some(field=>field.options?.eventualEditor===true),');
207
+ patched=patched.slice(0,editorStart)+editor+patched.slice(editorEnd);
208
+ // Admin 1.2/1.3 use SettingsActionBar; 1.4 removed it. Patch it only when present.
209
+ const barStart=patched.indexOf('function SettingsActionBar({');
210
+ if(barStart>=0){
211
+ const barEnd=patched.indexOf('\nfunction ',barStart+1);
212
+ if(barEnd<0) throw new Error("Unsupported settings action bar boundary.");
213
+ patched=patched.slice(0,barStart)+patched.slice(barStart,barEnd).replace('jsx(PublishActions, {','jsx(PublishActions, { eventualUi,')+patched.slice(barEnd);
214
+ patched=patched.replace('function SettingsActionBar({ collectionLabel,','function SettingsActionBar({ eventualUi=false, collectionLabel,');
215
+ if(!patched.includes('function SettingsActionBar({ eventualUi=false, collectionLabel,')) throw new Error("Unsupported settings action bar signature.");
216
+ }
217
+ // Only Eventual's own prop is prepended, so any host prop list is kept as is (1.5 renamed
218
+ // \`disabled\` and added \`revisions\`).
219
+ const publishPattern=/function PublishActions\(\{ collectionLabel, (isNew, [^{}]*?) \}\) \{\r?\n\tconst \{ _: _t4 \} = useLingui\(\);/;
220
+ if(!publishPattern.test(patched)) throw new Error("Unsupported publish actions signature.");
221
+ return patched.replace(publishPattern, (_match, props) => `function PublishActions({ eventualUi=false, collectionLabel, ${props} }) {\n const {locale: eventualPublishLocale}=useLocale(); const {_:eventualPublishT}=useLingui(); const _t4=eventualUi ? message=>eventualEditorText(eventualPublishT(message),eventualPublishLocale):eventualPublishT;`);
222
+ }
package/astro/install.mjs CHANGED
@@ -4,13 +4,14 @@ import { createRequire } from "node:module";
4
4
  import { readFileSync } from "node:fs";
5
5
  import { dirname, join } from "node:path";
6
6
  import { eventualEditor } from "./descriptor.mjs";
7
- import { eventualEditorCompatibility } from "./editor-compat.mjs";
7
+ import { eventualEditorCompatibility, warnOnce } from "./editor-compat.mjs";
8
+ export { warnOnce };
8
9
 
9
10
  const require = createRequire(import.meta.url);
10
11
  export const testedVersions = Object.freeze({
11
- emdash: Object.freeze(["1.2.0", "1.4.0"]),
12
- "@emdash-cms/admin": Object.freeze(["1.2.0", "1.4.0"]),
13
- "@emdash-cms/blocks": Object.freeze(["1.2.0", "1.4.0"]),
12
+ emdash: Object.freeze(["1.2.0", "1.4.0", "1.5.0"]),
13
+ "@emdash-cms/admin": Object.freeze(["1.2.0", "1.4.0", "1.5.0"]),
14
+ "@emdash-cms/blocks": Object.freeze(["1.2.0", "1.4.0", "1.5.0"]),
14
15
  });
15
16
  export const testedToolchain = Object.freeze({astro:"7.3.x-7.4.x (>=7.3.2 <7.5.0)",vite:"8.3.x",react:"19.x"});
16
17
  export function installedVersion(name, resolver = require) {
@@ -25,19 +26,35 @@ export function installedVersion(name, resolver = require) {
25
26
  directory = parent;
26
27
  }
27
28
  }
28
- export function checkEditorVersions(resolveVersion = installedVersion) {
29
+ /** Compare dotted versions numerically; prerelease tags are ignored. */
30
+ export function compareVersions(a, b) {
31
+ const pa = String(a).split("-")[0].split(".").map(Number), pb = String(b).split("-")[0].split(".").map(Number);
32
+ for (let i = 0; i < 3; i++) if ((pa[i] ?? 0) !== (pb[i] ?? 0)) return (pa[i] ?? 0) - (pb[i] ?? 0);
33
+ return 0;
34
+ }
35
+ /**
36
+ * Versions older than the oldest tested release have known-incompatible shapes and are refused.
37
+ * Newer untested releases are allowed with a warning: the editor adapters fall back to stock
38
+ * EmDash behaviour if a build no longer matches, so an EmDash update never blocks a site.
39
+ */
40
+ export function checkEditorVersions(resolveVersion = installedVersion, warn = warnOnce) {
29
41
  const versions = Object.fromEntries(Object.keys(testedVersions).map(name => [name, resolveVersion(name)]));
30
42
  for (const [name, version] of Object.entries(versions)) {
31
43
  const expected = testedVersions[name];
32
- if (!expected.includes(version)) throw new Error(`Eventual editor requires tested ${name} ${expected.join(" or ")}; found ${version}. Use the documented compatibility matrix before upgrading.`);
44
+ if (expected.includes(version)) continue;
45
+ if (compareVersions(version, expected[0]) < 0) throw new Error(`Eventual editor requires ${name} ${expected[0]} or newer; found ${version}. Upgrade EmDash first.`);
46
+ warn(`${name} ${version} has not been tested with this Eventual release (tested: ${expected.join(", ")}). Eventual will run; check the event editor after upgrading and report anything that looks wrong.`);
33
47
  }
34
48
  return versions;
35
49
  }
36
- export function checkToolchainVersions(resolveVersion = installedVersion) {
50
+ const toolchainMinimum = Object.freeze({ astro: "7.3.2", vite: "8.3.0", react: "19.0.0" });
51
+ const toolchainTested = Object.freeze({ astro: v => /^7.[34]./.test(v), vite: v => /^8.3./.test(v), react: v => /^19./.test(v) });
52
+ export function checkToolchainVersions(resolveVersion = installedVersion, warn = warnOnce) {
37
53
  const versions={};
38
54
  for (const [name, range] of Object.entries(testedToolchain)) {
39
55
  const version=resolveVersion(name);
40
- if (!(name === "astro" ? /^7\.[34]\.\d+$/.test(version) && (version.startsWith("7.4.") || Number(version.split(".")[2]) >= 2) : name === "vite" ? /^8\.3\.\d+$/.test(version) : /^19\.\d+\.\d+$/.test(version))) throw new Error(`Eventual editor requires ${name} ${range}; found ${version}. See the editor compatibility matrix.`);
56
+ if (compareVersions(version, toolchainMinimum[name]) < 0) throw new Error(`Eventual editor requires ${name} ${toolchainMinimum[name]} or newer (tested: ${range}); found ${version}. See the editor compatibility matrix.`);
57
+ if (!toolchainTested[name](version)) warn(`${name} ${version} is newer than the tested ${range}. Eventual will run; check the event editor after upgrading.`);
41
58
  versions[name]=version;
42
59
  }
43
60
  return versions;
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  /** @type {import("emdash").PluginDescriptor} */
8
8
  const descriptor = Object.freeze({
9
9
  "id": "eventual",
10
- "version": "0.18.2",
10
+ "version": "0.18.4",
11
11
  "format": "standard",
12
12
  "entrypoint": "@vermeulen.solutions/eventual/sandbox",
13
13
  "capabilities": [