@perkyzz/emvb 1.2.0 → 1.4.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/README.md +2 -2
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/package.json +4 -4
- package/src/admin/bulk-api.ts +5 -1
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +22 -2
- package/src/admin/editor/Timeline.tsx +1 -8
- package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
- package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
- package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
- package/src/admin/editor/canvas/vnode-react.tsx +5 -0
- package/src/admin/editor/co-design.ts +36 -1
- package/src/admin/editor/dnd/dragged-source.ts +22 -0
- package/src/admin/editor/dnd/layer-drop.ts +141 -0
- package/src/admin/editor/dnd/new-element.ts +76 -0
- package/src/admin/editor/editor-css.ts +9 -1
- package/src/admin/editor/element-chrome.ts +34 -0
- package/src/admin/editor/feature-css.ts +22 -0
- package/src/admin/editor/inert-links.ts +8 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/FontFaces.tsx +342 -0
- package/src/admin/editor/panels/LayersPanel.tsx +56 -6
- package/src/admin/editor/panels/LeftPanel.tsx +153 -29
- package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
- package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
- package/src/admin/editor/panels/TokenScales.tsx +2 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
- package/src/admin/editor/panels/VariableSection.tsx +111 -7
- package/src/admin/editor/panels/color-space.ts +71 -6
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +18 -0
- package/src/admin/editor/panels/settings/ItemList.tsx +33 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
- package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
- package/src/admin/editor/panels/settings/style-sections.ts +19 -2
- package/src/admin/editor/panels/url-rules.ts +43 -0
- package/src/admin/editor/panels/use-layers-drop.ts +232 -0
- package/src/admin/editor/store.ts +4 -2
- package/src/admin/editor/useExtensions.ts +3 -1
- package/src/admin/editor/useNodeActions.ts +74 -1
- package/src/admin/editor/useSave.ts +116 -85
- package/src/admin/export-api.ts +25 -2
- package/src/admin/extension-outputs.ts +179 -0
- package/src/admin/font-files-api.ts +38 -0
- package/src/admin/pages/ImportButton.tsx +15 -4
- package/src/admin/pages/ImportElementorDialog.tsx +22 -188
- package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
- package/src/admin/pages/ImportImageCopies.tsx +167 -0
- package/src/admin/pages/ImportReport.tsx +63 -0
- package/src/admin/pages/NewPageDialog.tsx +54 -32
- package/src/admin/pages/PageList.tsx +9 -0
- package/src/admin/pages/ThemePartList.tsx +9 -0
- package/src/astro/EmVBPage.astro +5 -2
- package/src/astro/extension-styles.ts +35 -0
- package/src/astro/forms/EmVBFormsClient.astro +3 -0
- package/src/astro/forms/enhance.ts +107 -0
- package/src/astro/popups/runtime.ts +47 -2
- package/src/astro/render.ts +19 -4
- package/src/astro/request-data.ts +6 -0
- package/src/astro/resolve-theme.ts +11 -4
- package/src/astro/resolve.ts +9 -0
- package/src/astro/widgets/EmVBCountdownRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCounterRuntime.astro +8 -0
- package/src/astro/widgets/EmVBHeadlineRuntime.astro +9 -0
- package/src/astro/widgets/EmVBMapRuntime.astro +8 -0
- package/src/astro/widgets/EmVBShareRuntime.astro +9 -0
- package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
- package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +22 -0
- package/src/astro/widgets/alerts.ts +16 -2
- package/src/astro/widgets/carousel.ts +65 -24
- package/src/astro/widgets/countdown.ts +91 -0
- package/src/astro/widgets/counter.ts +98 -0
- package/src/astro/widgets/extension-runtimes.ts +27 -0
- package/src/astro/widgets/headline.ts +99 -0
- package/src/astro/widgets/map.ts +37 -0
- package/src/astro/widgets/share.ts +21 -0
- package/src/astro/widgets/sticky.ts +87 -0
- package/src/astro/widgets/theme.ts +52 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +177 -6
- package/src/core/arrange.ts +71 -1
- package/src/core/canvas-collections.ts +28 -0
- package/src/core/css/font-face.ts +72 -0
- package/src/core/css/generate.ts +35 -1
- package/src/core/elements/counter-format.ts +15 -0
- package/src/core/elements/form-elements.ts +119 -9
- package/src/core/elements/icon-svg.ts +14 -0
- package/src/core/elements/index.ts +54 -4
- package/src/core/elements/input-limits.ts +44 -0
- package/src/core/elements/marketing.ts +1490 -0
- package/src/core/elements/menu.ts +109 -47
- package/src/core/elements/site.ts +108 -0
- package/src/core/elements/widgets.ts +40 -5
- package/src/core/export/runtimes.generated.ts +10 -3
- package/src/core/export/site.ts +55 -4
- package/src/core/extensions/classes.ts +114 -0
- package/src/core/extensions/index.ts +17 -2
- package/src/core/extensions/normalize.ts +13 -0
- package/src/core/extensions/registry.ts +134 -10
- package/src/core/extensions/render-ext.ts +66 -21
- package/src/core/extensions/safe-nodes.ts +67 -11
- package/src/core/extensions/types.ts +48 -1
- package/src/core/fonts/files.ts +74 -0
- package/src/core/fonts/google.ts +112 -0
- package/src/core/fonts/test-font.ts +9 -0
- package/src/core/import/elementor/context.ts +13 -4
- package/src/core/import/elementor/index.ts +32 -21
- package/src/core/import/elementor/widgets.ts +532 -293
- package/src/core/import/html/blocks.ts +602 -0
- package/src/core/import/html/index.ts +155 -0
- package/src/core/import/html/map.ts +958 -0
- package/src/core/import/html/parse.ts +430 -0
- package/src/core/index.ts +45 -0
- package/src/core/limits.ts +6 -0
- package/src/core/migrate/v18.ts +3 -0
- package/src/core/public-attributes.ts +17 -0
- package/src/core/render/extras.ts +31 -7
- package/src/core/render/form.ts +103 -10
- package/src/core/render/index.ts +172 -16
- package/src/core/render/section.ts +31 -1
- package/src/core/render/spacer-basis.ts +102 -0
- package/src/core/render/theme-boot.ts +16 -0
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +68 -3
- package/src/core/sanitize/motion.ts +12 -0
- package/src/core/schema/design.ts +40 -0
- package/src/core/schema/layout.ts +534 -22
- package/src/core/schema/style.ts +28 -0
- package/src/core/templates/index.ts +218 -0
- package/src/core/templates/pages.ts +29 -0
- package/src/core/templates/sections.ts +794 -0
- package/src/core/templates/types.ts +9 -0
- package/src/core/theme/dynamic.ts +11 -6
- package/src/core/theme/popup-markup.ts +21 -2
- package/src/core/theme/popup-rules.ts +36 -0
- package/src/core/theme/triggers.ts +64 -5
- package/src/core/translatable.ts +5 -2
- package/src/extension-build.ts +331 -0
- package/src/index.ts +25 -3
- package/src/mcp/brief.ts +191 -0
- package/src/mcp/prompts.ts +33 -0
- package/src/mcp/read.ts +29 -1
- package/src/mcp/tools.ts +40 -1
- package/src/mcp/write.ts +41 -1
- package/src/server/extension-routes.ts +73 -0
- package/src/server/font-routes.ts +301 -0
- package/src/server/plugin.ts +11 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** W-1068: a template node as stored: layout JSON whose styles may hold `tpl-*` references. */
|
|
2
|
+
export type TemplateData = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: string;
|
|
5
|
+
props: Record<string, unknown>;
|
|
6
|
+
style?: Record<string, unknown>;
|
|
7
|
+
classes?: string[];
|
|
8
|
+
children?: TemplateData[];
|
|
9
|
+
};
|
|
@@ -70,6 +70,8 @@ export type ThemeDynamicData = {
|
|
|
70
70
|
params?: Readonly<Record<string, string>>;
|
|
71
71
|
/** The page's own origin, e.g. `https://example.com`: URL-parameter links stay on it (W-307). */
|
|
72
72
|
origin?: string;
|
|
73
|
+
/** W-1047: this page's address, without its query, for Share buttons. Hosts fill this. */
|
|
74
|
+
pageUrl?: string;
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
/** Editor canvas placeholders when no live post is bound. */
|
|
@@ -362,15 +364,18 @@ export function collectCollectionLoops(layout: Layout): CollectionLoop[] {
|
|
|
362
364
|
return loops;
|
|
363
365
|
}
|
|
364
366
|
|
|
365
|
-
/**
|
|
367
|
+
/**
|
|
368
|
+
* Collect `section.partId` values so hosts can load Section templates. W-1069: and the Section
|
|
369
|
+
* parts mega menu items show (`menu-item` `panelPartId`).
|
|
370
|
+
*/
|
|
366
371
|
export function collectSectionPartIds(layout: Layout): string[] {
|
|
367
372
|
const ids = new Set<string>();
|
|
368
373
|
const walk = (node: LayoutNode): void => {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
const key =
|
|
375
|
+
node.type === "part-ref" ? "partId" : node.type === "menu-item" ? "panelPartId" : undefined;
|
|
376
|
+
if (key) {
|
|
377
|
+
const value = (node.props as Record<string, unknown>)[key];
|
|
378
|
+
const id = typeof value === "string" ? value.trim() : "";
|
|
374
379
|
if (id) ids.add(id);
|
|
375
380
|
}
|
|
376
381
|
};
|
|
@@ -5,7 +5,9 @@ import type { TriggersDoc } from "./triggers.ts";
|
|
|
5
5
|
/**
|
|
6
6
|
* Minimal chrome styles for public popups (loaded only when popups match). W-758: the close
|
|
7
7
|
* button sticks to the top of a long popup (it scrolled away with the content on phones) and
|
|
8
|
-
* floats, so a long heading wraps beside it instead of running under it.
|
|
8
|
+
* floats, so a long heading wraps beside it instead of running under it. Panels (W-1071) sit at
|
|
9
|
+
* their edge by physical auto margins: flex-start and flex-end follow `dir`, so on a right-to-left
|
|
10
|
+
* site a left panel opened at the right while its slide came from the left.
|
|
9
11
|
*/
|
|
10
12
|
export const POPUP_CHROME_CSS = `
|
|
11
13
|
.emvb-popup{position:fixed;inset:0;z-index:10000;display:flex;align-items:center;justify-content:center;padding:1.5rem;box-sizing:border-box}
|
|
@@ -15,6 +17,16 @@ export const POPUP_CHROME_CSS = `
|
|
|
15
17
|
.emvb-popup__close{position:sticky;top:-1rem;z-index:1;float:right;margin:-1rem -1rem 0 .5rem;width:2rem;height:2rem;border:0;border-radius:999px;background:inherit;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
|
|
16
18
|
.emvb-popup__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
|
|
17
19
|
.emvb-popup__content{min-width:12rem}
|
|
20
|
+
.emvb-popup--panel{padding:0;justify-content:flex-start}
|
|
21
|
+
.emvb-popup--right{justify-content:flex-end}
|
|
22
|
+
.emvb-popup--left .emvb-popup__dialog{margin-right:auto}
|
|
23
|
+
.emvb-popup--right .emvb-popup__dialog{margin-left:auto}
|
|
24
|
+
.emvb-popup--panel .emvb-popup__dialog{box-sizing:border-box;width:min(var(--emvb-panel-w,24rem),calc(100vw - 3rem));max-width:none;height:100%;max-height:none;border-radius:0}
|
|
25
|
+
.emvb-popup--narrow{--emvb-panel-w:20rem}
|
|
26
|
+
.emvb-popup--wide{--emvb-panel-w:32rem}
|
|
27
|
+
@media (prefers-reduced-motion:no-preference){.emvb-popup--left .emvb-popup__dialog{animation:emvb-panel-left .25s ease-out}.emvb-popup--right .emvb-popup__dialog{animation:emvb-panel-right .25s ease-out}}
|
|
28
|
+
@keyframes emvb-panel-left{from{translate:-100% 0}}
|
|
29
|
+
@keyframes emvb-panel-right{from{translate:100% 0}}
|
|
18
30
|
`
|
|
19
31
|
.replace(/\n+/g, "")
|
|
20
32
|
.trim();
|
|
@@ -46,8 +58,15 @@ export function wrapPopupMarkup(
|
|
|
46
58
|
const configJson = escapeAttr(JSON.stringify(config));
|
|
47
59
|
const safeId = escapeAttr(id);
|
|
48
60
|
const titleId = `emvb-popup-title-${safeId}`;
|
|
61
|
+
// W-1071: an off-canvas panel is the same dialog, laid out at an edge.
|
|
62
|
+
const panel = triggers.panel;
|
|
63
|
+
const kind = panel
|
|
64
|
+
? ` emvb-popup--panel emvb-popup--${panel.edge === "right" ? "right" : "left"}${
|
|
65
|
+
panel.size === "narrow" || panel.size === "wide" ? ` emvb-popup--${panel.size}` : ""
|
|
66
|
+
}`
|
|
67
|
+
: "";
|
|
49
68
|
return [
|
|
50
|
-
`<div class="emvb-popup" id="emvb-popup-${safeId}" data-emvb-popup="${safeId}" data-emvb-popup-config="${configJson}" hidden>`,
|
|
69
|
+
`<div class="emvb-popup${kind}" id="emvb-popup-${safeId}" data-emvb-popup="${safeId}" data-emvb-popup-config="${configJson}" hidden>`,
|
|
51
70
|
`<div class="emvb-popup__backdrop" data-emvb-popup-dismiss tabindex="-1"></div>`,
|
|
52
71
|
// W-282: named "Popup" until the runtime points the name at the content's first heading;
|
|
53
72
|
// naming it after the whole content read every word as the dialog's name.
|
|
@@ -98,3 +98,39 @@ export function withinShowTimes(
|
|
|
98
98
|
if (limit === null || limit === undefined) return true;
|
|
99
99
|
return timesShown < limit;
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
/** W-1081: a query parameter name a URL rule can test. */
|
|
103
|
+
export const URL_PARAM_NAME = /^[A-Za-z0-9_.\-[\]]{1,64}$/;
|
|
104
|
+
export const MAX_URL_PARAM_RULES = 5;
|
|
105
|
+
|
|
106
|
+
export type UrlParamRule = { name: string; value?: string | undefined; absent?: true | undefined };
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* W-1081: true when every URL rule holds for the page address's query (`location.search`);
|
|
110
|
+
* no rules always hold.
|
|
111
|
+
*/
|
|
112
|
+
export function matchesUrlParams(
|
|
113
|
+
advanced: { urlParams?: readonly UrlParamRule[] | null | undefined } | undefined,
|
|
114
|
+
search: string,
|
|
115
|
+
): boolean {
|
|
116
|
+
const rules = advanced?.urlParams;
|
|
117
|
+
if (!rules || rules.length === 0) return true;
|
|
118
|
+
const params = new URLSearchParams(search);
|
|
119
|
+
return rules.every((rule) => {
|
|
120
|
+
const values = params.getAll(rule.name);
|
|
121
|
+
const has = rule.value === undefined ? values.length > 0 : values.includes(rule.value);
|
|
122
|
+
return rule.absent ? !has : has;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** W-1081: true from `from` (inclusive) until `until` (exclusive); unset ends are open. */
|
|
127
|
+
export function withinShowDates(
|
|
128
|
+
advanced: { from?: string | null | undefined; until?: string | null | undefined } | undefined,
|
|
129
|
+
now: number,
|
|
130
|
+
): boolean {
|
|
131
|
+
const from = advanced?.from ? Date.parse(advanced.from) : Number.NaN;
|
|
132
|
+
const until = advanced?.until ? Date.parse(advanced.until) : Number.NaN;
|
|
133
|
+
if (!Number.isNaN(from) && now < from) return false;
|
|
134
|
+
if (!Number.isNaN(until) && now >= until) return false;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { boundedArray } from "../bounded-array.ts";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { parseDoc } from "./parse-doc.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { COUNTDOWN_TARGET } from "../schema/layout.ts";
|
|
5
|
+
import {
|
|
6
|
+
MAX_URL_PARAM_RULES,
|
|
7
|
+
POPUP_DEVICES,
|
|
8
|
+
TRIGGER_LIMITS,
|
|
9
|
+
URL_PARAM_NAME,
|
|
10
|
+
} from "./popup-rules.ts";
|
|
5
11
|
|
|
6
12
|
export const TRIGGERS_SCHEMA_VERSION = 1;
|
|
7
13
|
export const MAX_POPUP_TRIGGERS = 8;
|
|
8
14
|
const MAX_CLICK_SELECTOR_LENGTH = TRIGGER_LIMITS.maxClickSelectorLength;
|
|
9
15
|
const MAX_SHOW_TIMES = 100;
|
|
10
16
|
|
|
11
|
-
/** Open triggers (Elementor-inspired).
|
|
17
|
+
/** Open triggers (Elementor-inspired). A/B stays deferred (W-081). */
|
|
12
18
|
const PageLoadTrigger = z.strictObject({ type: z.literal("page_load") });
|
|
13
19
|
const DelayTrigger = z.strictObject({
|
|
14
20
|
type: z.literal("delay"),
|
|
@@ -45,17 +51,70 @@ const DeviceSchema = z.enum(POPUP_DEVICES);
|
|
|
45
51
|
* Advanced rules — MVP-thin (D-TB-11).
|
|
46
52
|
* `showTimes` null = unlimited; `devices` null/empty = all devices.
|
|
47
53
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
/**
|
|
55
|
+
* W-1081: one rule on the page address's query. With `value`, the parameter has that value;
|
|
56
|
+
* without, it is there at all. `absent` turns the rule round: the parameter (or that value) isn't.
|
|
57
|
+
*/
|
|
58
|
+
const UrlParamRuleSchema = z.strictObject({
|
|
59
|
+
name: z.string().regex(URL_PARAM_NAME, "Use letters, digits, - _ . [ or ] (up to 64)"),
|
|
60
|
+
value: z.string().max(200).optional(),
|
|
61
|
+
absent: z.literal(true).optional(),
|
|
51
62
|
});
|
|
52
63
|
|
|
64
|
+
/** W-1081: a date and time with its UTC offset, as for a Countdown. */
|
|
65
|
+
const ShowDate = z
|
|
66
|
+
.string()
|
|
67
|
+
.regex(COUNTDOWN_TARGET, "Use a date, time and UTC offset such as 2026-12-01T09:00-05:00")
|
|
68
|
+
.refine(onTheCalendar, "This date doesn't exist");
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* W-1081: the day exists in its month. `Date.parse` rolls 30 February over to 2 March in Bun and
|
|
72
|
+
* Node, so it can't tell. (A Countdown's target keeps its looser check: tightening it would
|
|
73
|
+
* refuse pages saved by 1.3, D-065.)
|
|
74
|
+
*/
|
|
75
|
+
function onTheCalendar(value: string): boolean {
|
|
76
|
+
const match = COUNTDOWN_TARGET.exec(value);
|
|
77
|
+
if (!match) return false;
|
|
78
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
79
|
+
return day <= new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const AdvancedRulesSchema = z
|
|
83
|
+
.strictObject({
|
|
84
|
+
showTimes: z.number().int().min(1).max(MAX_SHOW_TIMES).nullable().optional(),
|
|
85
|
+
devices: boundedArray(DeviceSchema, 3).nullable().optional(),
|
|
86
|
+
urlParams: boundedArray(UrlParamRuleSchema, MAX_URL_PARAM_RULES).nullable().optional(),
|
|
87
|
+
/** W-1081: shown from this moment on. */
|
|
88
|
+
from: ShowDate.nullable().optional(),
|
|
89
|
+
/** W-1081: no longer shown from this moment. */
|
|
90
|
+
until: ShowDate.nullable().optional(),
|
|
91
|
+
})
|
|
92
|
+
.refine((a) => !a.from || !a.until || Date.parse(a.until) > Date.parse(a.from), {
|
|
93
|
+
message: "The end must come after the start.",
|
|
94
|
+
path: ["until"],
|
|
95
|
+
});
|
|
96
|
+
|
|
53
97
|
export type PopupAdvancedRules = z.infer<typeof AdvancedRulesSchema>;
|
|
54
98
|
|
|
99
|
+
/** W-1071: the edges an off-canvas panel slides in from, and its widths. */
|
|
100
|
+
const PANEL_EDGES = ["left", "right"] as const;
|
|
101
|
+
export const PANEL_SIZES = ["narrow", "medium", "wide"] as const;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* W-1071: shows the popup as an off-canvas panel: full height at the `edge`, sliding in (not for
|
|
105
|
+
* reduced motion), `size` narrow 20rem, medium 24rem (unset) or wide 32rem, never wider than the
|
|
106
|
+
* screen less 3rem. Unset: a centred popup.
|
|
107
|
+
*/
|
|
108
|
+
const PanelSchema = z.strictObject({
|
|
109
|
+
edge: z.enum(PANEL_EDGES),
|
|
110
|
+
size: z.enum(PANEL_SIZES).optional(),
|
|
111
|
+
});
|
|
112
|
+
|
|
55
113
|
const TriggersDocSchema = z.strictObject({
|
|
56
114
|
schemaVersion: z.literal(TRIGGERS_SCHEMA_VERSION),
|
|
57
115
|
open: boundedArray(PopupOpenTriggerSchema, MAX_POPUP_TRIGGERS, 1),
|
|
58
116
|
advanced: AdvancedRulesSchema.default({}),
|
|
117
|
+
panel: PanelSchema.optional(),
|
|
59
118
|
});
|
|
60
119
|
|
|
61
120
|
export type TriggersDoc = z.infer<typeof TriggersDocSchema>;
|
package/src/core/translatable.ts
CHANGED
|
@@ -2,8 +2,11 @@ import { ELEMENT_DESCRIPTORS } from "./elements/index.ts";
|
|
|
2
2
|
import type { Layout, LayoutNode } from "./schema/layout.ts";
|
|
3
3
|
import { forEachNode } from "./tree-ops.ts";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Text fields that name things rather than say things: never offered for translation. A Search
|
|
7
|
+
* form's `action` is an address (W-1073); a translated page sets its own by hand.
|
|
8
|
+
*/
|
|
9
|
+
const NOT_TEXT = new Set(["formId", "field", "action"]);
|
|
7
10
|
|
|
8
11
|
export type TranslatableString = { nodeId: string; key: string; text: string };
|
|
9
12
|
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W-1086: build-time work for `emvb({ extensions })`, run in astro.config (Node or Bun), never at
|
|
3
|
+
* request time.
|
|
4
|
+
*
|
|
5
|
+
* - `css` and `runtime` are files of the extension's own package, relative to its `module`. Their
|
|
6
|
+
* text is read here and travels in the plugin's serialized options, so a Cloudflare Worker or a
|
|
7
|
+
* production server (which have no package files) still has it.
|
|
8
|
+
* - EmDash bundles a plugin through its `entrypoint` only. When extensions name their `module`,
|
|
9
|
+
* this writes a small entry next to the site (`node_modules/.emvb/`) that imports them and
|
|
10
|
+
* re-exports `createPlugin`, so their render functions reach the server build too.
|
|
11
|
+
*
|
|
12
|
+
* Node modules are reached through `process.getBuiltinModule`, so this file adds no `node:`
|
|
13
|
+
* import to the server bundle that also holds `emvb()`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type * as Fs from "node:fs";
|
|
17
|
+
import type * as Path from "node:path";
|
|
18
|
+
import type * as Url from "node:url";
|
|
19
|
+
import type * as Vm from "node:vm";
|
|
20
|
+
import {
|
|
21
|
+
extensionCssIssue,
|
|
22
|
+
extensionRuntimeIssue,
|
|
23
|
+
liveExtension,
|
|
24
|
+
rememberExtensionAssets,
|
|
25
|
+
type ExtensionAssets,
|
|
26
|
+
type ExtensionManifest,
|
|
27
|
+
} from "./core/extensions/index.ts";
|
|
28
|
+
import { MAX_EXTENSION_CSS_BYTES, MAX_EXTENSION_RUNTIME_BYTES } from "./core/extensions/classes.ts";
|
|
29
|
+
import { PACKAGE_NAME } from "./constants.ts";
|
|
30
|
+
|
|
31
|
+
type NodeApis = { fs: typeof Fs; path: typeof Path; url: typeof Url; vm?: typeof Vm };
|
|
32
|
+
|
|
33
|
+
function nodeApis(): NodeApis | undefined {
|
|
34
|
+
const getBuiltin = (globalThis as { process?: { getBuiltinModule?: (id: string) => unknown } })
|
|
35
|
+
.process?.getBuiltinModule;
|
|
36
|
+
if (typeof getBuiltin !== "function") return undefined;
|
|
37
|
+
const fs = getBuiltin("node:fs") as typeof Fs | undefined;
|
|
38
|
+
const path = getBuiltin("node:path") as typeof Path | undefined;
|
|
39
|
+
const url = getBuiltin("node:url") as typeof Url | undefined;
|
|
40
|
+
const vm = getBuiltin("node:vm") as typeof Vm | undefined;
|
|
41
|
+
return fs && path && url ? { fs, path, url, ...(vm ? { vm } : {}) } : undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A relative file path inside the package: `./x.css`, `../styles/x.css`; no scheme, no `\`. */
|
|
45
|
+
const RELATIVE = /^\.{1,2}\/[^\\:?#]+$/;
|
|
46
|
+
|
|
47
|
+
function packageName(text: string): string | undefined {
|
|
48
|
+
try {
|
|
49
|
+
const name = (JSON.parse(text) as { name?: unknown } | null)?.name;
|
|
50
|
+
return typeof name === "string" && name !== "" ? name : undefined;
|
|
51
|
+
} catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The package an extension module belongs to: its folder and unscoped name. */
|
|
57
|
+
function packageOf(apis: NodeApis, file: string): { root: string; name: string } | undefined {
|
|
58
|
+
const { fs, path } = apis;
|
|
59
|
+
let dir = path.dirname(file);
|
|
60
|
+
for (let i = 0; i < 32; i += 1) {
|
|
61
|
+
const manifest = path.join(dir, "package.json");
|
|
62
|
+
// A package.json without a name (dist/esm's `{"type":"module"}`) isn't the package root.
|
|
63
|
+
const name = fs.existsSync(manifest)
|
|
64
|
+
? packageName(fs.readFileSync(manifest, "utf8"))
|
|
65
|
+
: undefined;
|
|
66
|
+
if (name !== undefined) return { root: dir, name: name.replace(/^@[^/]+\//, "") };
|
|
67
|
+
const up = path.dirname(dir);
|
|
68
|
+
if (up === dir) return undefined;
|
|
69
|
+
dir = up;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The real path of a declared asset, or why it is refused. */
|
|
75
|
+
function assetPath(
|
|
76
|
+
apis: NodeApis,
|
|
77
|
+
pkg: { root: string },
|
|
78
|
+
moduleFile: string,
|
|
79
|
+
declared: string,
|
|
80
|
+
extensions: readonly string[],
|
|
81
|
+
maxBytes: number,
|
|
82
|
+
): { file: string } | { issue: string } {
|
|
83
|
+
const { fs, path } = apis;
|
|
84
|
+
if (!RELATIVE.test(declared)) {
|
|
85
|
+
return { issue: `"${declared}" is not a relative path in the package (use "./file")` };
|
|
86
|
+
}
|
|
87
|
+
if (!extensions.includes(path.extname(declared).toLowerCase())) {
|
|
88
|
+
return { issue: `"${declared}" must end in ${extensions.join(" or ")}` };
|
|
89
|
+
}
|
|
90
|
+
let file: string;
|
|
91
|
+
try {
|
|
92
|
+
file = fs.realpathSync(path.resolve(path.dirname(moduleFile), declared));
|
|
93
|
+
} catch {
|
|
94
|
+
return { issue: `"${declared}" was not found` };
|
|
95
|
+
}
|
|
96
|
+
const root = fs.realpathSync(pkg.root);
|
|
97
|
+
if (!file.startsWith(root + path.sep)) {
|
|
98
|
+
return { issue: `"${declared}" is outside the extension's package` };
|
|
99
|
+
}
|
|
100
|
+
const stat = fs.statSync(file);
|
|
101
|
+
if (!stat.isFile()) return { issue: `"${declared}" is not a file` };
|
|
102
|
+
if (stat.size > maxBytes) return { issue: `"${declared}" is larger than ${maxBytes / 1024} KB` };
|
|
103
|
+
return { file };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* What the Astro CLI is doing, read from its arguments: EmDash gives a plugin descriptor no
|
|
108
|
+
* integration hook, so `emvb()` never sees Astro's own `command` or `config.root`. A run that isn't
|
|
109
|
+
* the Astro CLI (a programmatic `build()`) counts as a build when NODE_ENV is production, which
|
|
110
|
+
* Astro's build sets.
|
|
111
|
+
*/
|
|
112
|
+
export function astroCli(
|
|
113
|
+
argv: readonly string[],
|
|
114
|
+
cwd: string,
|
|
115
|
+
nodeEnv: string | undefined,
|
|
116
|
+
): { command: "build" | "other"; root: string } {
|
|
117
|
+
const bin = argv.findIndex((arg) => /(?:^|[\\/])astro(?:\.m?js)?$/.test(arg));
|
|
118
|
+
const args = bin === -1 ? [] : argv.slice(bin + 1);
|
|
119
|
+
let root = cwd;
|
|
120
|
+
let command: string | undefined;
|
|
121
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
122
|
+
const arg = args[i] as string;
|
|
123
|
+
if (arg === "--root" && args[i + 1] !== undefined) {
|
|
124
|
+
root = args[i + 1] as string;
|
|
125
|
+
i += 1;
|
|
126
|
+
} else if (arg.startsWith("--root=")) root = arg.slice("--root=".length);
|
|
127
|
+
else if (!arg.startsWith("-") && command === undefined) command = arg;
|
|
128
|
+
}
|
|
129
|
+
const isBuild =
|
|
130
|
+
command === undefined ? bin === -1 && nodeEnv === "production" : command === "build";
|
|
131
|
+
return { command: isBuild ? "build" : "other", root: joinRoot(cwd, root) };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const joinRoot = (cwd: string, root: string) =>
|
|
135
|
+
/^(?:[A-Za-z]:)?[\\/]/.test(root) ? root : `${cwd.replace(/[\\/]+$/, "")}/${root}`;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* A runtime runs as an inline `<script type="module">` on public pages and as a classic
|
|
139
|
+
* `<script defer>` file in the HTML export (module scripts don't load from `file:` pages, so the
|
|
140
|
+
* export can't use them). It must parse as both: a strict classic script, so no top-level `await`
|
|
141
|
+
* (and no `with` or other sloppy-only syntax). Compiled here, never run.
|
|
142
|
+
*/
|
|
143
|
+
function classicScriptIssue(apis: NodeApis, code: string): string | undefined {
|
|
144
|
+
if (!apis.vm) return undefined;
|
|
145
|
+
try {
|
|
146
|
+
const script = new apis.vm.Script(`"use strict";${code}`);
|
|
147
|
+
return script instanceof apis.vm.Script ? undefined : "the runtime didn't compile";
|
|
148
|
+
} catch (error) {
|
|
149
|
+
const message = error instanceof Error ? error.message : "syntax error";
|
|
150
|
+
return `the runtime must parse as a strict classic script (no top-level await): ${message}`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type ExtensionBuild = {
|
|
155
|
+
/** The generated server entry, when at least one extension named its module. */
|
|
156
|
+
entrypoint?: string;
|
|
157
|
+
/** Problems to show the site owner; the extension still registers without the refused part. */
|
|
158
|
+
warnings: string[];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Read assets and find modules for the extensions `rememberExtensions` accepted. `root` is the
|
|
163
|
+
* site folder (the Astro root); `command: "build"` makes a server entry that can't be written an
|
|
164
|
+
* error, because a production build without it shows placeholders for every extension element.
|
|
165
|
+
*/
|
|
166
|
+
export function prepareExtensionBuild(
|
|
167
|
+
manifests: readonly ExtensionManifest[],
|
|
168
|
+
where: { root?: string; command?: "build" | "other" } = {},
|
|
169
|
+
): ExtensionBuild {
|
|
170
|
+
const warnings: string[] = [];
|
|
171
|
+
const modules: { id: string; file: string }[] = [];
|
|
172
|
+
const wantsFiles = manifests.some((m) => liveExtension(m.id)?.module !== undefined);
|
|
173
|
+
const apis = wantsFiles ? nodeApis() : undefined;
|
|
174
|
+
for (const manifest of manifests) {
|
|
175
|
+
const ext = liveExtension(manifest.id);
|
|
176
|
+
if (!ext) continue;
|
|
177
|
+
const say = (issue: string) => warnings.push(`${ext.id}: ${issue}`);
|
|
178
|
+
if (ext.module === undefined) {
|
|
179
|
+
if (ext.css !== undefined || ext.runtime !== undefined) {
|
|
180
|
+
say("css and runtime need `module: import.meta.url`; they were ignored");
|
|
181
|
+
}
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (!apis) {
|
|
185
|
+
say("css, runtime and module need Node or Bun at build time; they were ignored");
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
let moduleFile: string;
|
|
189
|
+
try {
|
|
190
|
+
const url = new URL(ext.module);
|
|
191
|
+
if (url.protocol !== "file:") throw new Error("not a file");
|
|
192
|
+
moduleFile = apis.fs.realpathSync(apis.url.fileURLToPath(url));
|
|
193
|
+
} catch {
|
|
194
|
+
say("module must be the extension's own `import.meta.url` (a local file: URL)");
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const pkg = packageOf(apis, moduleFile);
|
|
198
|
+
if (!pkg || pkg.name !== ext.id) {
|
|
199
|
+
say(`module must belong to the package named "${ext.id}"`);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
modules.push({ id: ext.id, file: moduleFile });
|
|
203
|
+
const assets: ExtensionAssets = {};
|
|
204
|
+
if (ext.css !== undefined) {
|
|
205
|
+
const found = assetPath(apis, pkg, moduleFile, ext.css, [".css"], MAX_EXTENSION_CSS_BYTES);
|
|
206
|
+
if ("issue" in found) say(`css ${found.issue}`);
|
|
207
|
+
else {
|
|
208
|
+
const css = apis.fs.readFileSync(found.file, "utf8");
|
|
209
|
+
const issue = extensionCssIssue(css);
|
|
210
|
+
if (issue) say(`css refused: ${issue}`);
|
|
211
|
+
else assets.css = css;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (ext.runtime !== undefined) {
|
|
215
|
+
const found = assetPath(
|
|
216
|
+
apis,
|
|
217
|
+
pkg,
|
|
218
|
+
moduleFile,
|
|
219
|
+
ext.runtime,
|
|
220
|
+
[".js", ".mjs"],
|
|
221
|
+
MAX_EXTENSION_RUNTIME_BYTES,
|
|
222
|
+
);
|
|
223
|
+
if ("issue" in found) say(`runtime ${found.issue}`);
|
|
224
|
+
else {
|
|
225
|
+
const code = apis.fs.readFileSync(found.file, "utf8");
|
|
226
|
+
const issue = extensionRuntimeIssue(code) ?? classicScriptIssue(apis, code);
|
|
227
|
+
if (issue) say(`runtime refused: ${issue}`);
|
|
228
|
+
else assets.runtime = code;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
rememberExtensionAssets(ext.id, assets);
|
|
232
|
+
}
|
|
233
|
+
if (modules.length === 0 || !apis) return { warnings };
|
|
234
|
+
const written = writeServerEntry(apis, modules, where.root ?? process.cwd());
|
|
235
|
+
if ("entrypoint" in written) return { entrypoint: written.entrypoint, warnings };
|
|
236
|
+
if (where.command === "build") {
|
|
237
|
+
throw new Error(
|
|
238
|
+
`[emvb] could not write the extensions server entry ${written.file} (${written.reason}). ` +
|
|
239
|
+
`Without it, extension elements render as placeholders in this build. Make the site's ` +
|
|
240
|
+
`node_modules folder writable, or run the build from the site folder (or pass --root).`,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
warnings.push(
|
|
244
|
+
`could not write ${written.file} (${written.reason}); extension elements render only in the dev server's own process`,
|
|
245
|
+
);
|
|
246
|
+
return { warnings };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const posix = (file: string) => file.replaceAll("\\", "/");
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* EmVB's own entry by absolute path, so the generated entry doesn't depend on where it sits (the
|
|
253
|
+
* bare package name only resolves from inside the site's node_modules). The same real file the
|
|
254
|
+
* site's `@perkyzz/emvb` imports resolve to, so the bundle keeps one copy.
|
|
255
|
+
*/
|
|
256
|
+
function emvbEntry(apis: NodeApis | undefined): string {
|
|
257
|
+
try {
|
|
258
|
+
const self = new URL(import.meta.url);
|
|
259
|
+
if (!apis || self.protocol !== "file:") return PACKAGE_NAME;
|
|
260
|
+
// index.ts sits next to this file (a path, not an import: index.ts imports this file).
|
|
261
|
+
const dir = apis.path.dirname(apis.url.fileURLToPath(self));
|
|
262
|
+
return posix(apis.fs.realpathSync(apis.path.join(dir, "index.ts")));
|
|
263
|
+
} catch {
|
|
264
|
+
return PACKAGE_NAME;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** The generated server entry's source: import each extension module, register, re-export. */
|
|
269
|
+
export function serverEntrySource(
|
|
270
|
+
modules: readonly { id: string; file: string }[],
|
|
271
|
+
emvb: string = PACKAGE_NAME,
|
|
272
|
+
): string {
|
|
273
|
+
return [
|
|
274
|
+
"// Generated by @perkyzz/emvb (W-1086) from this site's emvb({ extensions }). Do not edit.",
|
|
275
|
+
`import { registerBundledExtensions } from ${JSON.stringify(emvb)};`,
|
|
276
|
+
...modules.map((m, i) => `import * as ext${i} from ${JSON.stringify(posix(m.file))};`),
|
|
277
|
+
"registerBundledExtensions([",
|
|
278
|
+
...modules.map((m, i) => ` [ext${i}, ${JSON.stringify(m.id)}],`),
|
|
279
|
+
"]);",
|
|
280
|
+
`export { createPlugin } from ${JSON.stringify(emvb)};`,
|
|
281
|
+
"",
|
|
282
|
+
].join("\n");
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Earlier entries (another extension list) and temp files a crashed build left behind. */
|
|
286
|
+
function removeStaleEntries(apis: NodeApis, dir: string, keep: string): void {
|
|
287
|
+
for (const name of apis.fs.readdirSync(dir)) {
|
|
288
|
+
if (name === keep || !name.startsWith("server-entry-")) continue;
|
|
289
|
+
try {
|
|
290
|
+
apis.fs.rmSync(apis.path.join(dir, name), { force: true });
|
|
291
|
+
} catch {
|
|
292
|
+
// Another build may hold it; the next one tries again.
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// oxlint-disable-next-line no-control-regex -- control characters are what this refuses
|
|
298
|
+
const UNSAFE_ENTRY_PATH = /["\\\u0000-\u001f\u007f\u2028\u2029]/;
|
|
299
|
+
|
|
300
|
+
function writeServerEntry(
|
|
301
|
+
apis: NodeApis,
|
|
302
|
+
modules: readonly { id: string; file: string }[],
|
|
303
|
+
root: string,
|
|
304
|
+
): { entrypoint: string } | { file: string; reason: string } {
|
|
305
|
+
const { fs, path } = apis;
|
|
306
|
+
const source = serverEntrySource(modules, emvbEntry(apis));
|
|
307
|
+
let hash = 0;
|
|
308
|
+
for (let i = 0; i < source.length; i += 1) hash = (hash * 31 + source.charCodeAt(i)) >>> 0;
|
|
309
|
+
const dir = path.join(path.resolve(root), "node_modules", ".emvb");
|
|
310
|
+
// A .ts file, so Vite bundles it (and the TypeScript it imports) instead of handing it to Node.
|
|
311
|
+
const file = path.join(dir, `server-entry-${hash.toString(36)}.ts`);
|
|
312
|
+
// EmDash writes the entrypoint into `import … from "<entrypoint>"` without escaping it.
|
|
313
|
+
if (UNSAFE_ENTRY_PATH.test(file.replaceAll("\\", "/"))) {
|
|
314
|
+
return { file, reason: "its path has a quote, backslash or control character" };
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
318
|
+
if (!fs.existsSync(file) || fs.readFileSync(file, "utf8") !== source) {
|
|
319
|
+
// Written beside and renamed into place, so a dev server watching the folder never reads
|
|
320
|
+
// half a file.
|
|
321
|
+
const temp = `${file}.${process.pid}-${Date.now().toString(36)}.tmp`;
|
|
322
|
+
fs.writeFileSync(temp, source);
|
|
323
|
+
fs.renameSync(temp, file);
|
|
324
|
+
}
|
|
325
|
+
removeStaleEntries(apis, dir, path.basename(file));
|
|
326
|
+
return { entrypoint: file.replaceAll("\\", "/") };
|
|
327
|
+
} catch (error) {
|
|
328
|
+
const code = (error as { code?: unknown } | null)?.code;
|
|
329
|
+
return { file, reason: typeof code === "string" ? code : "write failed" };
|
|
330
|
+
}
|
|
331
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -4,10 +4,12 @@ import { canvasCollectionSlugs } from "./core/canvas-collections.ts";
|
|
|
4
4
|
import { canvasStyleUrls } from "./core/canvas-styles.ts";
|
|
5
5
|
import { loopCollectionSlugs } from "./core/loop-collections.ts";
|
|
6
6
|
import {
|
|
7
|
+
listedExtensionManifests,
|
|
7
8
|
rememberExtensions,
|
|
8
9
|
type EmVBExtension,
|
|
9
10
|
type ExtensionManifest,
|
|
10
11
|
} from "./core/extensions/index.ts";
|
|
12
|
+
import { astroCli, prepareExtensionBuild } from "./extension-build.ts";
|
|
11
13
|
import { createPlugin } from "./server/plugin.ts";
|
|
12
14
|
|
|
13
15
|
/** Options a host site passes to `emvb()` in astro.config. */
|
|
@@ -26,7 +28,8 @@ export type EmVBOptions = {
|
|
|
26
28
|
/**
|
|
27
29
|
* Build-time Extensions API v1 packages (W-927, D-066). Only the site owner adds these.
|
|
28
30
|
* Live render/resolve functions are kept in-process; a serializable manifest is what
|
|
29
|
-
* EmDash passes into `createPlugin`.
|
|
31
|
+
* EmDash passes into `createPlugin`. W-1086: an extension that names its `module` is bundled
|
|
32
|
+
* into the server build, and its `css` and `runtime` files are read here, at build time.
|
|
30
33
|
*/
|
|
31
34
|
extensions?: EmVBExtension[];
|
|
32
35
|
/**
|
|
@@ -48,12 +51,26 @@ export type EmVBOptions = {
|
|
|
48
51
|
export function emvb(options: EmVBOptions = {}): PluginDescriptor {
|
|
49
52
|
const canvasStyles = canvasStyleUrls(options.canvasStyles);
|
|
50
53
|
const canvasCollections = canvasCollectionSlugs(options.canvasCollections);
|
|
51
|
-
const
|
|
54
|
+
const accepted = rememberExtensions(options.extensions);
|
|
55
|
+
const build =
|
|
56
|
+
accepted.length > 0
|
|
57
|
+
? prepareExtensionBuild(
|
|
58
|
+
accepted,
|
|
59
|
+
astroCli(process.argv, process.cwd(), process.env["NODE_ENV"]),
|
|
60
|
+
)
|
|
61
|
+
: { warnings: [] };
|
|
62
|
+
for (const warning of build.warnings) {
|
|
63
|
+
// oxlint-disable-next-line no-console -- build-time notice for the site owner (W-1086)
|
|
64
|
+
console.warn(`[emvb] extension ${warning}`);
|
|
65
|
+
}
|
|
66
|
+
const ids = new Set(accepted.map((m) => m.id));
|
|
67
|
+
const extensions = listedExtensionManifests().filter((m) => ids.has(m.id));
|
|
52
68
|
return {
|
|
53
69
|
id: PLUGIN_ID,
|
|
54
70
|
version: PLUGIN_VERSION,
|
|
55
71
|
format: "native",
|
|
56
|
-
|
|
72
|
+
// W-1086: the generated entry re-exports createPlugin after registering the extensions.
|
|
73
|
+
entrypoint: build.entrypoint ?? PACKAGE_NAME,
|
|
57
74
|
adminEntry: ADMIN_ENTRY,
|
|
58
75
|
options: {
|
|
59
76
|
...(canvasStyles.length > 0 ? { canvasStyles } : {}),
|
|
@@ -73,6 +90,9 @@ export function emvb(options: EmVBOptions = {}): PluginDescriptor {
|
|
|
73
90
|
// that repeated it was dropped in 1.2 (W-1011).
|
|
74
91
|
export { createPlugin };
|
|
75
92
|
|
|
93
|
+
/** W-1086: used by the server entry `emvb()` generates for extensions; not for site code. */
|
|
94
|
+
export { registerBundledExtensions } from "./core/extensions/index.ts";
|
|
95
|
+
|
|
76
96
|
export type { EmVBExtension, ExtensionManifest };
|
|
77
97
|
export {
|
|
78
98
|
defineExtension,
|
|
@@ -82,4 +102,6 @@ export {
|
|
|
82
102
|
type ExtensionSource,
|
|
83
103
|
type ExtensionPropSchema,
|
|
84
104
|
type ExtensionField,
|
|
105
|
+
type ExtensionClasses,
|
|
106
|
+
type ExtensionOutputNode,
|
|
85
107
|
} from "./core/extensions/index.ts";
|