@aglyn/aglyn 1.20.2 → 1.21.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.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * The Besigner's own way back inside the native apps (AGL-4056).
19
+ *
20
+ * In the apps the editor has no native head and no Done button: the editor's
21
+ * own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and
22
+ * back gesture all press it, so whatever that control does first (a prompt,
23
+ * a save) happens the same for every one of them. The control goes to the
24
+ * document's `/view`, which the apps read as "leave the editor".
25
+ *
26
+ * The apps reach the control by this id: native code clicks it from a script
27
+ * (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's
28
+ * hook clicks it for the keys the web view receives itself.
29
+ */
30
+ export declare const NATIVE_BESIGNER_BACK_CONTROL_ID = "aglyn-besigner-back";
31
+ /** What a key event needs for the decision, so a spec can hand in a plain object. */
32
+ export interface BackKeyEvent {
33
+ key: string;
34
+ metaKey: boolean;
35
+ ctrlKey: boolean;
36
+ altKey: boolean;
37
+ shiftKey: boolean;
38
+ defaultPrevented: boolean;
39
+ target: EventTarget | null;
40
+ }
41
+ /**
42
+ * Whether a key leaves the editor through its back control: Esc on its own
43
+ * when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.
44
+ *
45
+ * Esc never leaves while a field has the focus, while something is open over
46
+ * the editor, or when the page already handled it (a pick in progress, an
47
+ * inline editor reverting): those are the Esc a person meant for them.
48
+ */
49
+ export declare function backKeyLeavesEditor(event: BackKeyEvent, doc: Pick<Document, 'querySelectorAll'>, mac: boolean): boolean;
50
+ /** Presses the editor's back control; false when the page has none. */
51
+ export declare function pressBesignerBack(doc: Pick<Document, 'getElementById'>): boolean;
52
+ /**
53
+ * Inside the apps' web view, Esc and ⌘[ press the editor's back control.
54
+ * Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[
55
+ * exactly as they were.
56
+ *
57
+ * It listens after the page's own handlers (bubbling, on the window), so a
58
+ * handler that took the key first stops it reaching here.
59
+ */
60
+ export declare function useNativeBesignerBackKeys(enabled: boolean): void;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { useEffect } from "react";
17
+ /**
18
+ * The Besigner's own way back inside the native apps (AGL-4056).
19
+ *
20
+ * In the apps the editor has no native head and no Done button: the editor's
21
+ * own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and
22
+ * back gesture all press it, so whatever that control does first (a prompt,
23
+ * a save) happens the same for every one of them. The control goes to the
24
+ * document's `/view`, which the apps read as "leave the editor".
25
+ *
26
+ * The apps reach the control by this id: native code clicks it from a script
27
+ * (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's
28
+ * hook clicks it for the keys the web view receives itself.
29
+ */ export const NATIVE_BESIGNER_BACK_CONTROL_ID = 'aglyn-besigner-back';
30
+ /** Whether `target` takes typing: a field, a select, or editable content. */ function takesTyping(target) {
31
+ const element = target;
32
+ if (!element || typeof element.tagName !== 'string') return false;
33
+ const tag = element.tagName.toLowerCase();
34
+ if (tag === 'input' || tag === 'textarea' || tag === 'select') return true;
35
+ return Boolean(element.isContentEditable) || (element.getAttribute == null ? void 0 : element.getAttribute.call(element, 'contenteditable')) === 'true';
36
+ }
37
+ /**
38
+ * Something open over the editor that Esc should close first: a dialog, a
39
+ * menu, a popover or a picker's list. MUI marks every one of them with these
40
+ * roles; one kept mounted while closed sits inside a hidden modal.
41
+ */ const OPEN_OVER_EDITOR = '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], .MuiPopover-root';
42
+ const CLOSED = '.MuiModal-hidden, [aria-hidden="true"], [hidden]';
43
+ function somethingOpenOverEditor(doc) {
44
+ return Array.from(doc.querySelectorAll(OPEN_OVER_EDITOR)).some((element)=>!element.closest(CLOSED));
45
+ }
46
+ /**
47
+ * Whether a key leaves the editor through its back control: Esc on its own
48
+ * when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.
49
+ *
50
+ * Esc never leaves while a field has the focus, while something is open over
51
+ * the editor, or when the page already handled it (a pick in progress, an
52
+ * inline editor reverting): those are the Esc a person meant for them.
53
+ */ export function backKeyLeavesEditor(event, doc, mac) {
54
+ if (event.defaultPrevented) return false;
55
+ if (event.key === '[') {
56
+ const command = mac ? event.metaKey : event.ctrlKey;
57
+ return command && !event.altKey && !event.shiftKey;
58
+ }
59
+ if (event.key !== 'Escape' && event.key !== 'Esc') return false;
60
+ if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return false;
61
+ if (takesTyping(event.target)) return false;
62
+ return !somethingOpenOverEditor(doc);
63
+ }
64
+ /** Presses the editor's back control; false when the page has none. */ export function pressBesignerBack(doc) {
65
+ const control = doc.getElementById(NATIVE_BESIGNER_BACK_CONTROL_ID);
66
+ if (!control) return false;
67
+ control.click();
68
+ return true;
69
+ }
70
+ /** Whether this browser is on a Mac (where ⌘ is the command key). */ function onMac() {
71
+ if (typeof navigator === 'undefined') return false;
72
+ return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || '');
73
+ }
74
+ /**
75
+ * Inside the apps' web view, Esc and ⌘[ press the editor's back control.
76
+ * Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[
77
+ * exactly as they were.
78
+ *
79
+ * It listens after the page's own handlers (bubbling, on the window), so a
80
+ * handler that took the key first stops it reaching here.
81
+ */ export function useNativeBesignerBackKeys(enabled) {
82
+ useEffect(()=>{
83
+ if (!enabled || typeof window === 'undefined') return;
84
+ const mac = onMac();
85
+ const onKeyDown = (event)=>{
86
+ if (!backKeyLeavesEditor(event, document, mac)) return;
87
+ if (!pressBesignerBack(document)) return;
88
+ event.preventDefault();
89
+ };
90
+ window.addEventListener('keydown', onKeyDown);
91
+ return ()=>window.removeEventListener('keydown', onKeyDown);
92
+ }, [
93
+ enabled
94
+ ]);
95
+ }
96
+
97
+ //# sourceMappingURL=native-besigner-back.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/native-besigner-back.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react'\n\n/**\n * The Besigner's own way back inside the native apps (AGL-4056).\n *\n * In the apps the editor has no native head and no Done button: the editor's\n * own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and\n * back gesture all press it, so whatever that control does first (a prompt,\n * a save) happens the same for every one of them. The control goes to the\n * document's `/view`, which the apps read as \"leave the editor\".\n *\n * The apps reach the control by this id: native code clicks it from a script\n * (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's\n * hook clicks it for the keys the web view receives itself.\n */\nexport const NATIVE_BESIGNER_BACK_CONTROL_ID = 'aglyn-besigner-back'\n\n/** What a key event needs for the decision, so a spec can hand in a plain object. */\nexport interface BackKeyEvent {\n key: string\n metaKey: boolean\n ctrlKey: boolean\n altKey: boolean\n shiftKey: boolean\n defaultPrevented: boolean\n target: EventTarget | null\n}\n\n/** Whether `target` takes typing: a field, a select, or editable content. */\nfunction takesTyping(target: EventTarget | null): boolean {\n const element = target as HTMLElement | null\n if (!element || typeof element.tagName !== 'string') return false\n const tag = element.tagName.toLowerCase()\n if (tag === 'input' || tag === 'textarea' || tag === 'select') return true\n return Boolean(element.isContentEditable) || element.getAttribute?.('contenteditable') === 'true'\n}\n\n/**\n * Something open over the editor that Esc should close first: a dialog, a\n * menu, a popover or a picker's list. MUI marks every one of them with these\n * roles; one kept mounted while closed sits inside a hidden modal.\n */\nconst OPEN_OVER_EDITOR =\n '[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"], .MuiPopover-root'\nconst CLOSED = '.MuiModal-hidden, [aria-hidden=\"true\"], [hidden]'\n\nfunction somethingOpenOverEditor(doc: Pick<Document, 'querySelectorAll'>): boolean {\n return Array.from(doc.querySelectorAll(OPEN_OVER_EDITOR)).some(\n (element) => !element.closest(CLOSED),\n )\n}\n\n/**\n * Whether a key leaves the editor through its back control: Esc on its own\n * when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.\n *\n * Esc never leaves while a field has the focus, while something is open over\n * the editor, or when the page already handled it (a pick in progress, an\n * inline editor reverting): those are the Esc a person meant for them.\n */\nexport function backKeyLeavesEditor(\n event: BackKeyEvent,\n doc: Pick<Document, 'querySelectorAll'>,\n mac: boolean,\n): boolean {\n if (event.defaultPrevented) return false\n if (event.key === '[') {\n const command = mac ? event.metaKey : event.ctrlKey\n return command && !event.altKey && !event.shiftKey\n }\n if (event.key !== 'Escape' && event.key !== 'Esc') return false\n if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return false\n if (takesTyping(event.target)) return false\n return !somethingOpenOverEditor(doc)\n}\n\n/** Presses the editor's back control; false when the page has none. */\nexport function pressBesignerBack(doc: Pick<Document, 'getElementById'>): boolean {\n const control = doc.getElementById(NATIVE_BESIGNER_BACK_CONTROL_ID)\n if (!control) return false\n control.click()\n return true\n}\n\n/** Whether this browser is on a Mac (where ⌘ is the command key). */\nfunction onMac(): boolean {\n if (typeof navigator === 'undefined') return false\n return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || '')\n}\n\n/**\n * Inside the apps' web view, Esc and ⌘[ press the editor's back control.\n * Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[\n * exactly as they were.\n *\n * It listens after the page's own handlers (bubbling, on the window), so a\n * handler that took the key first stops it reaching here.\n */\nexport function useNativeBesignerBackKeys(enabled: boolean): void {\n useEffect(() => {\n if (!enabled || typeof window === 'undefined') return\n const mac = onMac()\n const onKeyDown = (event: KeyboardEvent) => {\n if (!backKeyLeavesEditor(event, document, mac)) return\n if (!pressBesignerBack(document)) return\n event.preventDefault()\n }\n window.addEventListener('keydown', onKeyDown)\n return () => window.removeEventListener('keydown', onKeyDown)\n }, [enabled])\n}\n"],"names":["useEffect","NATIVE_BESIGNER_BACK_CONTROL_ID","takesTyping","target","element","tagName","tag","toLowerCase","Boolean","isContentEditable","getAttribute","OPEN_OVER_EDITOR","CLOSED","somethingOpenOverEditor","doc","Array","from","querySelectorAll","some","closest","backKeyLeavesEditor","event","mac","defaultPrevented","key","command","metaKey","ctrlKey","altKey","shiftKey","pressBesignerBack","control","getElementById","click","onMac","navigator","test","platform","userAgent","useNativeBesignerBackKeys","enabled","window","onKeyDown","document","preventDefault","addEventListener","removeEventListener"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,SAAS,QAAQ,QAAO;AAEjC;;;;;;;;;;;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c,CAAC/B;IACnC,IAAI,CAAC8B,SAAS,OAAO;IACrBA,QAAQE,KAAK;IACb,OAAO;AACT;AAEA,mEAAmE,GACnE,SAASC;IACP,IAAI,OAAOC,cAAc,aAAa,OAAO;IAC7C,OAAO,uBAAuBC,IAAI,CAACD,UAAUE,QAAQ,IAAIF,UAAUG,SAAS,IAAI;AAClF;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,0BAA0BC,OAAgB;IACxDxC,UAAU;QACR,IAAI,CAACwC,WAAW,OAAOC,WAAW,aAAa;QAC/C,MAAMnB,MAAMY;QACZ,MAAMQ,YAAY,CAACrB;YACjB,IAAI,CAACD,oBAAoBC,OAAOsB,UAAUrB,MAAM;YAChD,IAAI,CAACQ,kBAAkBa,WAAW;YAClCtB,MAAMuB,cAAc;QACtB;QACAH,OAAOI,gBAAgB,CAAC,WAAWH;QACnC,OAAO,IAAMD,OAAOK,mBAAmB,CAAC,WAAWJ;IACrD,GAAG;QAACF;KAAQ;AACd"}
@@ -24,6 +24,12 @@ export interface EditorConnectionVariable {
24
24
  label: string;
25
25
  /** The value the last sync wrote, as the published page would print it, or `null` before one. */
26
26
  value: string | null;
27
+ /**
28
+ * Whether the connection has synced at all, so an empty `value` reads as
29
+ * "the service has nothing there" rather than "not synced yet" (a Google
30
+ * profile with no reviews has no rating). Absent from an older provider.
31
+ */
32
+ synced?: boolean;
27
33
  }
28
34
  /**
29
35
  * One declared connection an element can repeat over (AGL-4212): what the
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-connection-editor.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContext } from 'react'\nimport type { PluginConnectionRecordsPageData, PluginConnectionSiteRecord } from './plugin-connection-records'\nimport type { PluginConnectionFieldTypes } from './plugin-connection-repeat'\n\n/*\n * DECLARED CONNECTIONS IN THE EDITOR (AGL-4196).\n *\n * A published page hands each signed element its connection's record with\n * the page (`plugin-connection-records.ts`), and binds each record's summary\n * fields as `{{var:<listingId>__<connectionId>-<field>}}`. The Besigner and\n * Preview render in the console, where there is no page render to ride, so\n * the plugin that runs the connections (the marketplace) provides THIS\n * context to every editor surface instead: which listing a component id's\n * namespace belongs to, each listing's records, and the variables the\n * records give the site. The surfaces turn it into the same\n * `PluginConnectionRecordsContext` value the published page provides, so an\n * element reads its record through the same hook, and the binding picker\n * lists the variables by name.\n *\n * Core declares the seam and never names the plugin that fills it. Absent,\n * every element reads `null` and the picker lists nothing extra: the same\n * answer as a site that has not connected.\n */\n\n/** One `{{var:…}}` a connection's record gives the site, as the binding picker lists it. */\nexport interface EditorConnectionVariable {\n /** The variable id (`pluginConnectionVariableId`): what the token carries. */\n id: string\n /** What a person reads: the connection's label and the field's name, never the id. */\n label: string\n /** The value the last sync wrote, as the published page would print it, or `null` before one. */\n value: string | null\n}\n\n/**\n * One declared connection an element can repeat over (AGL-4212): what the\n * Attributes panel's picker lists, what a `repeatConnection` value's\n * identity resolves to, and the fields its `{{item.*}}` tokens can name.\n */\nexport interface EditorConnectionRepeatable {\n /** `<publisher handle>.<manifest id>`: what a `repeatConnection` value names. */\n identity: string\n listingId: string\n connectionId: string\n /** The connection's own label, as the site's connections card shows it. */\n label: string\n /** The declared type of each summary field and each item field. */\n types: PluginConnectionFieldTypes\n}\n\n/** What the editor knows of the site's declared connections. */\nexport interface EditorPluginConnections {\n /** The listing whose namespace `componentId` is in (`<identity>.<role>`), or `null`. */\n listingFor(componentId: string): string | null\n /** Listing id → connection id → the record its last sync wrote. */\n records: Readonly<Record<string, Readonly<Record<string, PluginConnectionSiteRecord>>>>\n /** Every summary field of every declared connection, as site variables. */\n variables: readonly EditorConnectionVariable[]\n /**\n * Every declared connection of a namespaced install that writes a record,\n * for a repeat over it (AGL-4212). Absent from a provider that predates it,\n * which offers no such repeat.\n */\n repeatables?: readonly EditorConnectionRepeatable[]\n}\n\nexport const EditorPluginConnectionsContext = createContext<EditorPluginConnections | undefined>(undefined)\nEditorPluginConnectionsContext.displayName = 'EditorPluginConnectionsContext'\n\n/** An editor node, as far as attributing it to a listing needs. */\nexport interface EditorConnectionNode {\n $id?: unknown\n componentId?: unknown\n}\n\n/**\n * The `PluginConnectionRecordsContext` value for `nodes` (a page's, or one\n * element's), attributed the way the published page's enricher attributes\n * them: a node whose component id is in a listing's namespace, and only when\n * that listing holds a record. `undefined` when none is.\n */\nexport function editorConnectionRecordsPageData(\n connections: EditorPluginConnections | undefined,\n nodes: Iterable<EditorConnectionNode | null | undefined>,\n): PluginConnectionRecordsPageData | undefined {\n if (!connections) return undefined\n const attributed: Record<string, string> = {}\n const records: PluginConnectionRecordsPageData['records'] = {}\n for (const node of nodes) {\n const nodeId = node?.$id\n const componentId = node?.componentId\n if (typeof nodeId !== 'string' || !nodeId || typeof componentId !== 'string' || !componentId.includes('.')) continue\n const listingId = connections.listingFor(componentId)\n if (!listingId) continue\n const held = connections.records[listingId]\n if (!held || !Object.keys(held).length) continue\n attributed[nodeId] = listingId\n records[listingId] = { ...held }\n }\n return Object.keys(attributed).length ? { nodes: attributed, records } : undefined\n}\n"],"names":["createContext","EditorPluginConnectionsContext","undefined","displayName","editorConnectionRecordsPageData","connections","nodes","attributed","records","node","nodeId","$id","componentId","includes","listingId","listingFor","held","Object","keys","length"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,QAAO;AAkErC,OAAO,MAAMC,iCAAiCD,cAAmDE,WAAU;AAC3GD,+BAA+BE,WAAW,GAAG;AAQ7C;;;;;CAKC,GACD,OAAO,SAASC,gCACdC,WAAgD,EAChDC,KAAwD;IAExD,IAAI,CAACD,aAAa,OAAOH;IACzB,MAAMK,aAAqC,CAAC;IAC5C,MAAMC,UAAsD,CAAC;IAC7D,KAAK,MAAMC,QAAQH,MAAO;QACxB,MAAMI,SAASD,wBAAAA,KAAME,GAAG;QACxB,MAAMC,cAAcH,wBAAAA,KAAMG,WAAW;QACrC,IAAI,OAAOF,WAAW,YAAY,CAACA,UAAU,OAAOE,gBAAgB,YAAY,CAACA,YAAYC,QAAQ,CAAC,MAAM;QAC5G,MAAMC,YAAYT,YAAYU,UAAU,CAACH;QACzC,IAAI,CAACE,WAAW;QAChB,MAAME,OAAOX,YAAYG,OAAO,CAACM,UAAU;QAC3C,IAAI,CAACE,QAAQ,CAACC,OAAOC,IAAI,CAACF,MAAMG,MAAM,EAAE;QACxCZ,UAAU,CAACG,OAAO,GAAGI;QACrBN,OAAO,CAACM,UAAU,GAAG,aAAKE;IAC5B;IACA,OAAOC,OAAOC,IAAI,CAACX,YAAYY,MAAM,GAAG;QAAEb,OAAOC;QAAYC;IAAQ,IAAIN;AAC3E"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-connection-editor.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContext } from 'react'\nimport type { PluginConnectionRecordsPageData, PluginConnectionSiteRecord } from './plugin-connection-records'\nimport type { PluginConnectionFieldTypes } from './plugin-connection-repeat'\n\n/*\n * DECLARED CONNECTIONS IN THE EDITOR (AGL-4196).\n *\n * A published page hands each signed element its connection's record with\n * the page (`plugin-connection-records.ts`), and binds each record's summary\n * fields as `{{var:<listingId>__<connectionId>-<field>}}`. The Besigner and\n * Preview render in the console, where there is no page render to ride, so\n * the plugin that runs the connections (the marketplace) provides THIS\n * context to every editor surface instead: which listing a component id's\n * namespace belongs to, each listing's records, and the variables the\n * records give the site. The surfaces turn it into the same\n * `PluginConnectionRecordsContext` value the published page provides, so an\n * element reads its record through the same hook, and the binding picker\n * lists the variables by name.\n *\n * Core declares the seam and never names the plugin that fills it. Absent,\n * every element reads `null` and the picker lists nothing extra: the same\n * answer as a site that has not connected.\n */\n\n/** One `{{var:…}}` a connection's record gives the site, as the binding picker lists it. */\nexport interface EditorConnectionVariable {\n /** The variable id (`pluginConnectionVariableId`): what the token carries. */\n id: string\n /** What a person reads: the connection's label and the field's name, never the id. */\n label: string\n /** The value the last sync wrote, as the published page would print it, or `null` before one. */\n value: string | null\n /**\n * Whether the connection has synced at all, so an empty `value` reads as\n * \"the service has nothing there\" rather than \"not synced yet\" (a Google\n * profile with no reviews has no rating). Absent from an older provider.\n */\n synced?: boolean\n}\n\n/**\n * One declared connection an element can repeat over (AGL-4212): what the\n * Attributes panel's picker lists, what a `repeatConnection` value's\n * identity resolves to, and the fields its `{{item.*}}` tokens can name.\n */\nexport interface EditorConnectionRepeatable {\n /** `<publisher handle>.<manifest id>`: what a `repeatConnection` value names. */\n identity: string\n listingId: string\n connectionId: string\n /** The connection's own label, as the site's connections card shows it. */\n label: string\n /** The declared type of each summary field and each item field. */\n types: PluginConnectionFieldTypes\n}\n\n/** What the editor knows of the site's declared connections. */\nexport interface EditorPluginConnections {\n /** The listing whose namespace `componentId` is in (`<identity>.<role>`), or `null`. */\n listingFor(componentId: string): string | null\n /** Listing id → connection id → the record its last sync wrote. */\n records: Readonly<Record<string, Readonly<Record<string, PluginConnectionSiteRecord>>>>\n /** Every summary field of every declared connection, as site variables. */\n variables: readonly EditorConnectionVariable[]\n /**\n * Every declared connection of a namespaced install that writes a record,\n * for a repeat over it (AGL-4212). Absent from a provider that predates it,\n * which offers no such repeat.\n */\n repeatables?: readonly EditorConnectionRepeatable[]\n}\n\nexport const EditorPluginConnectionsContext = createContext<EditorPluginConnections | undefined>(undefined)\nEditorPluginConnectionsContext.displayName = 'EditorPluginConnectionsContext'\n\n/** An editor node, as far as attributing it to a listing needs. */\nexport interface EditorConnectionNode {\n $id?: unknown\n componentId?: unknown\n}\n\n/**\n * The `PluginConnectionRecordsContext` value for `nodes` (a page's, or one\n * element's), attributed the way the published page's enricher attributes\n * them: a node whose component id is in a listing's namespace, and only when\n * that listing holds a record. `undefined` when none is.\n */\nexport function editorConnectionRecordsPageData(\n connections: EditorPluginConnections | undefined,\n nodes: Iterable<EditorConnectionNode | null | undefined>,\n): PluginConnectionRecordsPageData | undefined {\n if (!connections) return undefined\n const attributed: Record<string, string> = {}\n const records: PluginConnectionRecordsPageData['records'] = {}\n for (const node of nodes) {\n const nodeId = node?.$id\n const componentId = node?.componentId\n if (typeof nodeId !== 'string' || !nodeId || typeof componentId !== 'string' || !componentId.includes('.')) continue\n const listingId = connections.listingFor(componentId)\n if (!listingId) continue\n const held = connections.records[listingId]\n if (!held || !Object.keys(held).length) continue\n attributed[nodeId] = listingId\n records[listingId] = { ...held }\n }\n return Object.keys(attributed).length ? { nodes: attributed, records } : undefined\n}\n"],"names":["createContext","EditorPluginConnectionsContext","undefined","displayName","editorConnectionRecordsPageData","connections","nodes","attributed","records","node","nodeId","$id","componentId","includes","listingId","listingFor","held","Object","keys","length"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,QAAO;AAwErC,OAAO,MAAMC,iCAAiCD,cAAmDE,WAAU;AAC3GD,+BAA+BE,WAAW,GAAG;AAQ7C;;;;;CAKC,GACD,OAAO,SAASC,gCACdC,WAAgD,EAChDC,KAAwD;IAExD,IAAI,CAACD,aAAa,OAAOH;IACzB,MAAMK,aAAqC,CAAC;IAC5C,MAAMC,UAAsD,CAAC;IAC7D,KAAK,MAAMC,QAAQH,MAAO;QACxB,MAAMI,SAASD,wBAAAA,KAAME,GAAG;QACxB,MAAMC,cAAcH,wBAAAA,KAAMG,WAAW;QACrC,IAAI,OAAOF,WAAW,YAAY,CAACA,UAAU,OAAOE,gBAAgB,YAAY,CAACA,YAAYC,QAAQ,CAAC,MAAM;QAC5G,MAAMC,YAAYT,YAAYU,UAAU,CAACH;QACzC,IAAI,CAACE,WAAW;QAChB,MAAME,OAAOX,YAAYG,OAAO,CAACM,UAAU;QAC3C,IAAI,CAACE,QAAQ,CAACC,OAAOC,IAAI,CAACF,MAAMG,MAAM,EAAE;QACxCZ,UAAU,CAACG,OAAO,GAAGI;QACrBN,OAAO,CAACM,UAAU,GAAG,aAAKE;IAC5B;IACA,OAAOC,OAAOC,IAAI,CAACX,YAAYY,MAAM,GAAG;QAAEb,OAAOC;QAAYC;IAAQ,IAAIN;AAC3E"}
@@ -209,9 +209,12 @@ export const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/;
209
209
  * option lists) pass through untouched; unsafe values in hrefs remain
210
210
  * covered by the render-time SAFE_HREF/sanitizer checks.
211
211
  */ export function resolveNodesBindings(nodes, variables, functions = {}) {
212
- if (!Object.keys(variables).length && !Object.keys(functions).length) {
213
- return nodes;
214
- }
212
+ // No early return for a site with no variables: its `{{var:id}}` tokens
213
+ // still have to render EMPTY (a deleted variable, a plugin connection that
214
+ // was disconnected), or the raw token reaches visitors. Only a node whose
215
+ // text actually changes is copied, so a page with nothing to resolve comes
216
+ // back as the same map.
217
+ let anyChanged = false;
215
218
  const next = {};
216
219
  for (const [id, node] of Object.entries(nodes)){
217
220
  const props = node == null ? void 0 : node.props;
@@ -223,15 +226,19 @@ export const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/;
223
226
  const nextProps = _extends({}, props);
224
227
  for (const [key, value] of Object.entries(props)){
225
228
  if (typeof value === 'string' && hasBindings(value)) {
226
- nextProps[key] = resolveBindings(value, variables, functions);
227
- changed = true;
229
+ const resolved = resolveBindings(value, variables, functions);
230
+ if (resolved !== value) {
231
+ nextProps[key] = resolved;
232
+ changed = true;
233
+ }
228
234
  }
229
235
  }
230
236
  next[id] = changed ? _extends({}, node, {
231
237
  props: nextProps
232
238
  }) : node;
239
+ anyChanged = anyChanged || changed;
233
240
  }
234
- return next;
241
+ return anyChanged ? next : nodes;
235
242
  }
236
243
 
237
244
  //# sourceMappingURL=variables.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/variables.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Token grammar shared with the picker/besigner (AGL-185/194): id-form\n// tokens only — legacy name resolution retired after the production\n// content migration ran clean.\nimport {\n FUNCTION_TOKEN_PATTERN,\n VARIABLE_ID_TOKEN_PATTERN,\n} from './binding-tokens'\nimport {\n evaluateExpression,\n evaluateHostFunction,\n functionReferencedNames,\n type HostFunction,\n} from './functions'\n\n/**\n * Host variables (Component Builder, AGL-91): typed values authored in the\n * console and bound into component text props with `{{name}}` — and, since\n * AGL-93, function results with `{{fn:name(args)}}`. Pure data module\n * shared by the console editor UI and the tenant compose pipeline.\n */\n\n/** Types from the mockup's Edit Variable dialog (\"Function\" lands with AGL-92). */\nexport type HostVariableType =\n | 'date'\n | 'time'\n | 'text'\n | 'number'\n | 'boolean'\n | 'dictionary'\n | 'collection'\n\nexport const HOST_VARIABLE_TYPE_LABELS: Record<HostVariableType, string> = {\n date: 'Date',\n time: 'Time',\n text: 'Plain text',\n number: 'Number',\n boolean: 'True/false (boolean)',\n dictionary: 'Dictionary (key: value)',\n collection: 'Collection list (values)',\n}\n\n/**\n * `hosts/{hostId}/variables/{id}` doc, as far as binding reads it.\n *\n * A COMPUTED variable also carries the reference its computing plugin reads\n * — which record produces its value — and `value` is then the fallback the\n * page shows when that record is gone or fails. Binding never reads the\n * reference; the plugin that computes the value types and reads its own\n * (`plugin-manager/computed-variables`).\n */\nexport interface HostVariable {\n /** Binding identifier — `{{name}}`. */\n name: string\n type: HostVariableType\n /** Persisted as a string; formatted per type at resolve time. */\n value?: string\n}\n\nexport const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/\n\n/** Whether `name` may name a variable or a function's parameter (`VARIABLE_NAME_PATTERN`). */\nexport function isVariableName(name: string): boolean {\n return VARIABLE_NAME_PATTERN.test(name)\n}\n\n/** Human-readable rendering of a variable's value for text interpolation. */\nexport function formatVariableValue(variable: HostVariable): string {\n const raw = variable.value ?? ''\n switch (variable.type) {\n case 'boolean':\n return raw === 'true' ? 'true' : 'false'\n case 'number': {\n const parsed = Number(raw)\n return Number.isFinite(parsed) ? String(parsed) : ''\n }\n case 'date': {\n const parsed = new Date(raw)\n return Number.isNaN(parsed.getTime())\n ? raw\n : parsed.toLocaleDateString(undefined, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n timeZone: 'UTC',\n })\n }\n case 'dictionary':\n case 'collection': {\n // Stored as JSON; render collections comma-joined and dictionaries\n // as `key: value` pairs so a bare {{name}} stays readable.\n try {\n const parsed = JSON.parse(raw)\n if (Array.isArray(parsed)) return parsed.map(String).join(', ')\n if (parsed && typeof parsed === 'object') {\n return Object.entries(parsed)\n .map(([key, value]) => `${key}: ${value}`)\n .join(', ')\n }\n } catch {\n // fall through to the raw string\n }\n return raw\n }\n case 'time':\n case 'text':\n default:\n return raw\n }\n}\n\n/** A function definition lookup keyed by function name (AGL-93). */\nexport type HostFunctionLookup = Record<string, HostFunction>\n\n/**\n * Variable values as an expression scope (numbers stay numeric). Keyed by\n * each doc's NAME regardless of how the lookup map is keyed (AGL-194:\n * maps are id-keyed now, but expressions reference variables by name).\n */\nfunction variableScope(\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope: Record<string, number | string | boolean> = {}\n for (const variable of Object.values(variables)) {\n if (!variable?.name) continue\n if (variable.type === 'number') {\n scope[variable.name] = Number(variable.value ?? 0)\n } else if (variable.type === 'boolean') {\n scope[variable.name] = variable.value === 'true'\n } else {\n scope[variable.name] = variable.value ?? ''\n }\n }\n return scope\n}\n\n/**\n * Replaces binding tokens with values (AGL-91/93/185/194): id forms\n * `{{var:id}}` / `{{fn:id(args)}}` resolve through id-keyed lookup maps.\n * Function args are expressions over literals and variable NAMES (the\n * scope keys by each doc's name). Unknown function refs keep the literal\n * token; unknown variable ids render empty; bare `{{name}}` strings are\n * plain text since the legacy fallback retired.\n */\nexport function resolveBindings(\n text: string,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): string {\n const withVariableIds = text.replace(\n VARIABLE_ID_TOKEN_PATTERN,\n (_token, id) => {\n const variable = variables[String(id)]\n // Unknown ids render EMPTY, not literal (AGL-186): a raw doc id is\n // meaningless to visitors, unlike a readable legacy {{name}} token.\n return variable ? formatVariableValue(variable) : ''\n },\n )\n const withFunctions = withVariableIds.replace(\n FUNCTION_TOKEN_PATTERN,\n (token, rawName, rawArgs) => {\n const definition = functions[String(rawName).trim()]\n if (!definition) return token\n try {\n const scope = variableScope(variables)\n const argValues = String(rawArgs)\n .split(',')\n .map((argument) => argument.trim())\n .filter((argument) => argument.length > 0)\n .map((argument) => evaluateExpression(argument, scope))\n const args: Record<string, unknown> = {}\n definition.parameters?.forEach((parameter, index) => {\n args[parameter.name] = argValues[index]\n })\n // The site's variables are the function's outer scope (AGL-3202),\n // so `{{fn:id(25)}}` can price 25 sites without every rate being\n // passed in by position. Arguments still win over a variable of the\n // same name, as every parameter does.\n const result = evaluateHostFunction(definition, args, {\n globals: scope,\n })\n return result.ok ? String(result.value) : token\n } catch {\n return token\n }\n },\n )\n // Legacy {{name}} resolution retired (AGL-194): the production content\n // migration ran clean, so bare-name tokens are plain text now. Typing\n // them in the editor still works — save-time normalization converts\n // known names to id tokens before they persist.\n return withFunctions\n}\n\n/** Fast pre-check so binding-free content skips the walk entirely. */\nexport function hasBindings(text: string): boolean {\n return /\\{\\{/.test(text)\n}\n\n/**\n * The site variables ONE function reads, by name (AGL-3202).\n *\n * A widget runs in the visitor's browser, so whatever it may read has to be\n * on the page. Handing it the whole variable list would publish every value\n * a site holds to every page that places a calculator; this hands over the\n * names the function's own expressions use and nothing else. A name the\n * function declares itself is not a variable read — its parameter or local\n * shadows the variable — so it is not shipped either.\n */\nexport function functionGlobals(\n definition: HostFunction,\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope = variableScope(variables)\n const globals: Record<string, number | string | boolean> = {}\n for (const name of functionReferencedNames(definition)) {\n if (Object.prototype.hasOwnProperty.call(scope, name)) {\n globals[name] = scope[name]\n }\n }\n return globals\n}\n\n/**\n * Injects each function-running element's definition into its props at\n * compose time (AGL-93): the client runs the shared evaluator locally, so the\n * published page carries the definition instead of calling home. Unknown\n * names leave the node untouched (the element renders its editor\n * placeholder).\n *\n * Which elements run a function is DECLARED (AGL-3393): `bindings` maps a\n * component id to the prop that names its function, collected from each\n * plugin's `contributes.site.functionBindings`. Core names no element, so a\n * marketplace plugin's element is bound exactly as a first-party one is, and\n * an element nobody declared is never handed a definition.\n *\n * With `variables`, the site variables that function reads ride along as\n * `globals` (AGL-3202) — see {@link functionGlobals} for why it is only\n * those. The key is omitted when the function reads none, so a page built\n * before this existed serializes exactly as it did.\n */\nexport function attachFunctionDefinitions<T extends Record<string, any>>(\n nodes: T,\n functions: HostFunctionLookup,\n variables: Record<string, HostVariable>,\n bindings: Readonly<Record<string, string>>,\n): T {\n if (!Object.keys(functions).length || !Object.keys(bindings).length) {\n return nodes\n }\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const componentId = node?.componentId\n const prop =\n typeof componentId === 'string' &&\n Object.prototype.hasOwnProperty.call(bindings, componentId)\n ? bindings[componentId]\n : undefined\n const name = prop ? node?.props?.[prop] : undefined\n const definition = name ? functions[String(name).trim()] : undefined\n if (!definition) {\n next[id] = node\n continue\n }\n const globals = functionGlobals(definition, variables)\n next[id] = {\n ...node,\n props: {\n ...node.props,\n definition,\n ...(Object.keys(globals).length ? { globals } : {}),\n },\n }\n }\n return next as T\n}\n\n/**\n * Applies `resolveBindings` to every string prop across a normalized nodes\n * map (mutating a shallow copy). String props only — objects/arrays (sx,\n * option lists) pass through untouched; unsafe values in hrefs remain\n * covered by the render-time SAFE_HREF/sanitizer checks.\n */\nexport function resolveNodesBindings<T extends Record<string, any>>(\n nodes: T,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): T {\n if (!Object.keys(variables).length && !Object.keys(functions).length) {\n return nodes\n }\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const props = node?.props\n if (!props) {\n next[id] = node\n continue\n }\n let changed = false\n const nextProps: Record<string, unknown> = { ...props }\n for (const [key, value] of Object.entries(props)) {\n if (typeof value === 'string' && hasBindings(value)) {\n nextProps[key] = resolveBindings(value, variables, functions)\n changed = true\n }\n }\n next[id] = changed ? { ...node, props: nextProps } : node\n }\n return next as T\n}\n"],"names":["FUNCTION_TOKEN_PATTERN","VARIABLE_ID_TOKEN_PATTERN","evaluateExpression","evaluateHostFunction","functionReferencedNames","HOST_VARIABLE_TYPE_LABELS","date","time","text","number","boolean","dictionary","collection","VARIABLE_NAME_PATTERN","isVariableName","name","test","formatVariableValue","variable","raw","value","type","parsed","Number","isFinite","String","Date","isNaN","getTime","toLocaleDateString","undefined","year","month","day","timeZone","JSON","parse","Array","isArray","map","join","Object","entries","key","variableScope","variables","scope","values","resolveBindings","functions","withVariableIds","replace","_token","id","withFunctions","token","rawName","rawArgs","definition","trim","argValues","split","argument","filter","length","args","parameters","forEach","parameter","index","result","globals","ok","hasBindings","functionGlobals","prototype","hasOwnProperty","call","attachFunctionDefinitions","nodes","bindings","keys","next","node","componentId","prop","props","resolveNodesBindings","changed","nextProps"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,uEAAuE;AACvE,oEAAoE;AACpE,+BAA+B;AAC/B,SACEA,sBAAsB,EACtBC,yBAAyB,QACpB,sBAAkB;AACzB,SACEC,kBAAkB,EAClBC,oBAAoB,EACpBC,uBAAuB,QAElB,iBAAa;AAmBpB,OAAO,MAAMC,4BAA8D;IACzEC,MAAM;IACNC,MAAM;IACNC,MAAM;IACNC,QAAQ;IACRC,SAAS;IACTC,YAAY;IACZC,YAAY;AACd,EAAC;AAmBD,OAAO,MAAMC,wBAAwB,gCAA+B;AAEpE,4FAA4F,GAC5F,OAAO,SAASC,eAAeC,IAAY;IACzC,OAAOF,sBAAsBG,IAAI,CAACD;AACpC;AAEA,2EAA2E,GAC3E,OAAO,SAASE,oBAAoBC,QAAsB;QAC5CA;IAAZ,MAAMC,OAAMD,kBAAAA,SAASE,KAAK,YAAdF,kBAAkB;IAC9B,OAAQA,SAASG,IAAI;QACnB,KAAK;YACH,OAAOF,QAAQ,SAAS,SAAS;QACnC,KAAK;YAAU;gBACb,MAAMG,SAASC,OAAOJ;gBACtB,OAAOI,OAAOC,QAAQ,CAACF,UAAUG,OAAOH,UAAU;YACpD;QACA,KAAK;YAAQ;gBACX,MAAMA,SAAS,IAAII,KAAKP;gBACxB,OAAOI,OAAOI,KAAK,CAACL,OAAOM,OAAO,MAC9BT,MACAG,OAAOO,kBAAkB,CAACC,WAAW;oBACnCC,MAAM;oBACNC,OAAO;oBACPC,KAAK;oBACLC,UAAU;gBACZ;YACN;QACA,KAAK;QACL,KAAK;YAAc;gBACjB,mEAAmE;gBACnE,2DAA2D;gBAC3D,IAAI;oBACF,MAAMZ,SAASa,KAAKC,KAAK,CAACjB;oBAC1B,IAAIkB,MAAM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AWe,MAAM,EAAE;QACpE,OAAOe;IACT;IACA,MAAMG,OAA4B,CAAC;IACnC,KAAK,MAAM,CAAC7B,IAAI8B,KAAK,IAAI1C,OAAOC,OAAO,CAACqC,OAAQ;QAC9C,MAAMO,QAAQH,wBAAAA,KAAMG,KAAK;QACzB,IAAI,CAACA,OAAO;YACVJ,IAAI,CAAC7B,GAAG,GAAG8B;YACX;QACF;QACA,IAAIK,UAAU;QACd,MAAMC,YAAqC,aAAKH;QAChD,KAAK,MAAM,CAAC3C,KAAKvB,MAAM,IAAIqB,OAAOC,OAAO,CAAC4C,OAAQ;YAChD,IAAI,OAAOlE,UAAU,YAAYqD,YAAYrD,QAAQ;gBACnDqE,SAAS,CAAC9C,IAAI,GAAGK,gBAAgB5B,OAAOyB,WAAWI;gBACnDuC,UAAU;YACZ;QACF;QACAN,IAAI,CAAC7B,GAAG,GAAGmC,UAAU,aAAKL;YAAMG,OAAOG;aAAcN;IACvD;IACA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/variables.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Token grammar shared with the picker/besigner (AGL-185/194): id-form\n// tokens only — legacy name resolution retired after the production\n// content migration ran clean.\nimport {\n FUNCTION_TOKEN_PATTERN,\n VARIABLE_ID_TOKEN_PATTERN,\n} from './binding-tokens'\nimport {\n evaluateExpression,\n evaluateHostFunction,\n functionReferencedNames,\n type HostFunction,\n} from './functions'\n\n/**\n * Host variables (Component Builder, AGL-91): typed values authored in the\n * console and bound into component text props with `{{name}}` — and, since\n * AGL-93, function results with `{{fn:name(args)}}`. Pure data module\n * shared by the console editor UI and the tenant compose pipeline.\n */\n\n/** Types from the mockup's Edit Variable dialog (\"Function\" lands with AGL-92). */\nexport type HostVariableType =\n | 'date'\n | 'time'\n | 'text'\n | 'number'\n | 'boolean'\n | 'dictionary'\n | 'collection'\n\nexport const HOST_VARIABLE_TYPE_LABELS: Record<HostVariableType, string> = {\n date: 'Date',\n time: 'Time',\n text: 'Plain text',\n number: 'Number',\n boolean: 'True/false (boolean)',\n dictionary: 'Dictionary (key: value)',\n collection: 'Collection list (values)',\n}\n\n/**\n * `hosts/{hostId}/variables/{id}` doc, as far as binding reads it.\n *\n * A COMPUTED variable also carries the reference its computing plugin reads\n * — which record produces its value — and `value` is then the fallback the\n * page shows when that record is gone or fails. Binding never reads the\n * reference; the plugin that computes the value types and reads its own\n * (`plugin-manager/computed-variables`).\n */\nexport interface HostVariable {\n /** Binding identifier — `{{name}}`. */\n name: string\n type: HostVariableType\n /** Persisted as a string; formatted per type at resolve time. */\n value?: string\n}\n\nexport const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/\n\n/** Whether `name` may name a variable or a function's parameter (`VARIABLE_NAME_PATTERN`). */\nexport function isVariableName(name: string): boolean {\n return VARIABLE_NAME_PATTERN.test(name)\n}\n\n/** Human-readable rendering of a variable's value for text interpolation. */\nexport function formatVariableValue(variable: HostVariable): string {\n const raw = variable.value ?? ''\n switch (variable.type) {\n case 'boolean':\n return raw === 'true' ? 'true' : 'false'\n case 'number': {\n const parsed = Number(raw)\n return Number.isFinite(parsed) ? String(parsed) : ''\n }\n case 'date': {\n const parsed = new Date(raw)\n return Number.isNaN(parsed.getTime())\n ? raw\n : parsed.toLocaleDateString(undefined, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n timeZone: 'UTC',\n })\n }\n case 'dictionary':\n case 'collection': {\n // Stored as JSON; render collections comma-joined and dictionaries\n // as `key: value` pairs so a bare {{name}} stays readable.\n try {\n const parsed = JSON.parse(raw)\n if (Array.isArray(parsed)) return parsed.map(String).join(', ')\n if (parsed && typeof parsed === 'object') {\n return Object.entries(parsed)\n .map(([key, value]) => `${key}: ${value}`)\n .join(', ')\n }\n } catch {\n // fall through to the raw string\n }\n return raw\n }\n case 'time':\n case 'text':\n default:\n return raw\n }\n}\n\n/** A function definition lookup keyed by function name (AGL-93). */\nexport type HostFunctionLookup = Record<string, HostFunction>\n\n/**\n * Variable values as an expression scope (numbers stay numeric). Keyed by\n * each doc's NAME regardless of how the lookup map is keyed (AGL-194:\n * maps are id-keyed now, but expressions reference variables by name).\n */\nfunction variableScope(\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope: Record<string, number | string | boolean> = {}\n for (const variable of Object.values(variables)) {\n if (!variable?.name) continue\n if (variable.type === 'number') {\n scope[variable.name] = Number(variable.value ?? 0)\n } else if (variable.type === 'boolean') {\n scope[variable.name] = variable.value === 'true'\n } else {\n scope[variable.name] = variable.value ?? ''\n }\n }\n return scope\n}\n\n/**\n * Replaces binding tokens with values (AGL-91/93/185/194): id forms\n * `{{var:id}}` / `{{fn:id(args)}}` resolve through id-keyed lookup maps.\n * Function args are expressions over literals and variable NAMES (the\n * scope keys by each doc's name). Unknown function refs keep the literal\n * token; unknown variable ids render empty; bare `{{name}}` strings are\n * plain text since the legacy fallback retired.\n */\nexport function resolveBindings(\n text: string,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): string {\n const withVariableIds = text.replace(\n VARIABLE_ID_TOKEN_PATTERN,\n (_token, id) => {\n const variable = variables[String(id)]\n // Unknown ids render EMPTY, not literal (AGL-186): a raw doc id is\n // meaningless to visitors, unlike a readable legacy {{name}} token.\n return variable ? formatVariableValue(variable) : ''\n },\n )\n const withFunctions = withVariableIds.replace(\n FUNCTION_TOKEN_PATTERN,\n (token, rawName, rawArgs) => {\n const definition = functions[String(rawName).trim()]\n if (!definition) return token\n try {\n const scope = variableScope(variables)\n const argValues = String(rawArgs)\n .split(',')\n .map((argument) => argument.trim())\n .filter((argument) => argument.length > 0)\n .map((argument) => evaluateExpression(argument, scope))\n const args: Record<string, unknown> = {}\n definition.parameters?.forEach((parameter, index) => {\n args[parameter.name] = argValues[index]\n })\n // The site's variables are the function's outer scope (AGL-3202),\n // so `{{fn:id(25)}}` can price 25 sites without every rate being\n // passed in by position. Arguments still win over a variable of the\n // same name, as every parameter does.\n const result = evaluateHostFunction(definition, args, {\n globals: scope,\n })\n return result.ok ? String(result.value) : token\n } catch {\n return token\n }\n },\n )\n // Legacy {{name}} resolution retired (AGL-194): the production content\n // migration ran clean, so bare-name tokens are plain text now. Typing\n // them in the editor still works — save-time normalization converts\n // known names to id tokens before they persist.\n return withFunctions\n}\n\n/** Fast pre-check so binding-free content skips the walk entirely. */\nexport function hasBindings(text: string): boolean {\n return /\\{\\{/.test(text)\n}\n\n/**\n * The site variables ONE function reads, by name (AGL-3202).\n *\n * A widget runs in the visitor's browser, so whatever it may read has to be\n * on the page. Handing it the whole variable list would publish every value\n * a site holds to every page that places a calculator; this hands over the\n * names the function's own expressions use and nothing else. A name the\n * function declares itself is not a variable read — its parameter or local\n * shadows the variable — so it is not shipped either.\n */\nexport function functionGlobals(\n definition: HostFunction,\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope = variableScope(variables)\n const globals: Record<string, number | string | boolean> = {}\n for (const name of functionReferencedNames(definition)) {\n if (Object.prototype.hasOwnProperty.call(scope, name)) {\n globals[name] = scope[name]\n }\n }\n return globals\n}\n\n/**\n * Injects each function-running element's definition into its props at\n * compose time (AGL-93): the client runs the shared evaluator locally, so the\n * published page carries the definition instead of calling home. Unknown\n * names leave the node untouched (the element renders its editor\n * placeholder).\n *\n * Which elements run a function is DECLARED (AGL-3393): `bindings` maps a\n * component id to the prop that names its function, collected from each\n * plugin's `contributes.site.functionBindings`. Core names no element, so a\n * marketplace plugin's element is bound exactly as a first-party one is, and\n * an element nobody declared is never handed a definition.\n *\n * With `variables`, the site variables that function reads ride along as\n * `globals` (AGL-3202) — see {@link functionGlobals} for why it is only\n * those. The key is omitted when the function reads none, so a page built\n * before this existed serializes exactly as it did.\n */\nexport function attachFunctionDefinitions<T extends Record<string, any>>(\n nodes: T,\n functions: HostFunctionLookup,\n variables: Record<string, HostVariable>,\n bindings: Readonly<Record<string, string>>,\n): T {\n if (!Object.keys(functions).length || !Object.keys(bindings).length) {\n return nodes\n }\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const componentId = node?.componentId\n const prop =\n typeof componentId === 'string' &&\n Object.prototype.hasOwnProperty.call(bindings, componentId)\n ? bindings[componentId]\n : undefined\n const name = prop ? node?.props?.[prop] : undefined\n const definition = name ? functions[String(name).trim()] : undefined\n if (!definition) {\n next[id] = node\n continue\n }\n const globals = functionGlobals(definition, variables)\n next[id] = {\n ...node,\n props: {\n ...node.props,\n definition,\n ...(Object.keys(globals).length ? { globals } : {}),\n },\n }\n }\n return next as T\n}\n\n/**\n * Applies `resolveBindings` to every string prop across a normalized nodes\n * map (mutating a shallow copy). String props only — objects/arrays (sx,\n * option lists) pass through untouched; unsafe values in hrefs remain\n * covered by the render-time SAFE_HREF/sanitizer checks.\n */\nexport function resolveNodesBindings<T extends Record<string, any>>(\n nodes: T,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): T {\n // No early return for a site with no variables: its `{{var:id}}` tokens\n // still have to render EMPTY (a deleted variable, a plugin connection that\n // was disconnected), or the raw token reaches visitors. Only a node whose\n // text actually changes is copied, so a page with nothing to resolve comes\n // back as the same map.\n let anyChanged = false\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const props = node?.props\n if (!props) {\n next[id] = node\n continue\n }\n let changed = false\n const nextProps: Record<string, unknown> = { ...props }\n for (const [key, value] of Object.entries(props)) {\n if (typeof value === 'string' && hasBindings(value)) {\n const resolved = resolveBindings(value, variables, functions)\n if (resolved !== value) {\n nextProps[key] = resolved\n changed = true\n }\n }\n }\n next[id] = changed ? { ...node, props: nextProps } : node\n anyChanged = anyChanged || changed\n }\n return (anyChanged ? next : nodes) as T\n}\n"],"names":["FUNCTION_TOKEN_PATTERN","VARIABLE_ID_TOKEN_PATTERN","evaluateExpression","evaluateHostFunction","functionReferencedNames","HOST_VARIABLE_TYPE_LABELS","date","time","text","number","boolean","dictionary","collection","VARIABLE_NAME_PATTERN","isVariableName","name","test","formatVariableValue","variable","raw","value","type","parsed","Number","isFinite","String","Date","isNaN","getTime","toLocaleDateString","undefined","year","month","day","timeZone","JSON","parse","Array","isArray","map","join","Object","entries","key","variableScope","variables","scope","values","resolveBindings","functions","withVariableIds","replace","_token","id","withFunctions","token","rawName","rawArgs","definition","trim","argValues","split","argument","filter","length","args","parameters","forEach","parameter","index","result","globals","ok","hasBindings","functionGlobals","prototype","hasOwnProperty","call","attachFunctionDefinitions","nodes","bindings","keys","next","node","componentId","prop","props","resolveNodesBindings","anyChanged","changed","nextProps","resolved"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,uEAAuE;AACvE,oEAAoE;AACpE,+BAA+B;AAC/B,SACEA,sBAAsB,EACtBC,yBAAyB,QACpB,sBAAkB;AACzB,SACEC,kBAAkB,EAClBC,oBAAoB,EACpBC,uBAAuB,QAElB,iBAAa;AAmBpB,OAAO,MAAMC,4BAA8D;IACzEC,MAAM;IACNC,MAAM;IACNC,MAAM;IACNC,QAAQ;IACRC,SAAS;IACTC,YAAY;IACZC,YAAY;AACd,EAAC;AAmBD,OAAO,MAAMC,wBAAwB,gCAA+B;AAEpE,4FAA4F,GAC5F,OAAO,SAASC,eAAeC,IAAY;IACzC,OAAOF,sBAAsBG,IAAI,CAACD;AACpC;AAEA,2EAA2E,GAC3E,OAAO,SAASE,oBAAoBC,QAAsB;QAC5CA;IAAZ,MAAMC,OAAMD,kBAAAA,SAASE,KAAK,YAAdF,kBAAkB;IAC9B,OAAQA,SAASG,IAAI;QACnB,KAAK;YACH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everything else.
156
156
  */
157
157
  positionalChildren?: FEATURE_FLAG;
158
+ /**
159
+ * Component takes its text as a plain string `children`: no child
160
+ * elements and no `<aglyn-text>` wrapper around it. For an element whose
161
+ * DOM allows text and nothing else, such as `<option>`, where React and
162
+ * the browser's parser both drop an element child, and with it the text.
163
+ *
164
+ * Not `selfClosing`, which means a void element (`<img>`) and strips
165
+ * `children` altogether: a Select Option flagged that way rendered every
166
+ * dropdown choice on every published site with no words.
167
+ */
168
+ plainTextChildren?: FEATURE_FLAG;
158
169
  };
159
170
  /**
160
171
  * Preset items are the available items to add to the canvas
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/aglyn/src/lib/foundation/definitions/components.types.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConditionDefinition,\n DataType,\n Validator,\n} from '@data-driven-forms/react-form-renderer'\nimport type {\n FieldActions,\n ResolvePropsFunction,\n} from '@data-driven-forms/react-form-renderer/common-types'\nimport type { SvgIconProps } from '@mui/material'\nimport type { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { CANVAS_ROOT_ELEMENT_ID } from '../constants/canvas'\nimport type { ComponentCategory } from '../constants/components'\nimport type { FEATURE_FLAG, RICH_TEXT_COMMANDS } from '../constants/shared'\nimport type { AGLYN_OF, SYMBOL_TYPE } from '../constants/symbol'\n\nexport enum LinealDirectiveFlag {\n LIMIT_TO = 'limitedTo',\n DISALLOW = 'forbid',\n}\n\nexport type BundleId = string\nexport type PluginId = string\nexport type ComponentId = string\nexport type PresetId = string\nexport type NodeId = string\n\nexport type ComponentsLinealOrder = [\n directiveType: LinealDirectiveFlag,\n directiveDefinition:\n | Array<ComponentId>\n | { plugins?: Array<PluginId>; components: Array<ComponentId> }\n | { plugins: Array<PluginId>; components?: Array<ComponentId> },\n]\n\nexport type AglynNodeItemDenormalized<P = JSX.AnyProps> = AglynNodeSchema<P> & {\n nodes?: AglynNodeItemDenormalized[]\n}\n\nexport type AglynNodesList = Array<AglynNodeItemDenormalized>\n\nexport type AglynNodeHierarchy<$ID extends NodeId = NodeId> = [\n root: CANVAS_ROOT_ELEMENT_ID,\n ...nodes: [...ancestors: NodeId[], element: $ID],\n]\n\nexport interface AglynExoticComponent<PROPS = any, REF = any>\n extends JSX.ForwardRefExoticComponent<\n JSX.PropsWithoutRef<PROPS> & JSX.RefAttributes<REF>\n > {\n [AGLYN_OF]?: SYMBOL_TYPE\n aglyn?: boolean\n schema?: AglynComponentSchema<PROPS>\n}\n\nexport interface AglynComponentSchema<P = any> {\n $id: ComponentId\n pluginId?: BundleId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n\n /**\n * Icon props for display around besigner\n */\n icon?: SvgIconProps\n /**\n * Options to be passed to styled(Component, \\{...styledOptions\\})\n */\n styledOptions?: MuiStyledOptions\n\n /**\n * Define a limitation for nodes allowed as direct descendents\n */\n restrictChildren?: ComponentsLinealOrder\n /**\n * Define a limitation for nodes allowed to be direct ancestors\n */\n restrictParent?: ComponentsLinealOrder\n\n /**\n * Filter props\n */\n resolveProps?: JSX.ResolveProps<AglynNodeItemDenormalized<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AglynAttributeSchema[]\n\n /**\n * Which groups of formatting the inline rich-text toolbar offers for this\n * component (AGL-2557). Read only where `flags.richTextEditable` is on.\n *\n * Omitted means every group, which is what leaves Typography exactly as it\n * was. Naming a subset narrows the toolbar AND the commit: a surface that\n * offers neither lists nor links is phrasing-only, and the sanitizer holds\n * it to that whatever an author pastes in.\n */\n richTextCommands?: RICH_TEXT_COMMANDS[]\n\n /**\n * Feature flags\n */\n flags?: {\n /**\n * Disable the use of emotion styled\n */\n emotion?: FEATURE_FLAG\n /**\n * Can the nodes of this component type be cloned?\n */\n cloning?: FEATURE_FLAG\n /**\n * Allow dragging nodes of this component type\n */\n dragging?: FEATURE_FLAG\n /**\n * Allow dropping nodes inside nodes of this component type\n */\n dropping?: FEATURE_FLAG\n /**\n * Allow editing element attributes of this component type\n */\n editing?: FEATURE_FLAG\n /**\n * Allow removing nodes of this component type\n */\n removing?: FEATURE_FLAG\n /**\n * Describe nodes of this component type to be self-closing\n */\n selfClosing?: FEATURE_FLAG\n /**\n * Component renders its `children` prop as text content the editor may\n * edit directly (Attributes \"Text\" field, inline canvas editing).\n */\n textEditable?: FEATURE_FLAG\n /**\n * Component also accepts basic rich text (AGL-54): sanitized HTML in the\n * `html` prop with `children` as the plain-text fallback.\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * must hand it one React child per node child instead of the single\n * `<Branch>` element it normally passes.\n *\n * MUI's Accordion does `const [summary, ...rest] = Children.toArray(children)`,\n * and `toArray` does not traverse into an element — so with the default\n * wrapping the summary swallowed the whole subtree and the Collapse got\n * nothing. Every accordion on every published site expanded to reveal an\n * empty panel while its content rendered unconditionally inside the\n * summary's `<h3>`.\n *\n * Opt in only for components with this contract; the wrapper is what\n * keeps the Branch/Stem/Leaf seam swappable for everything else.\n */\n positionalChildren?: FEATURE_FLAG\n }\n\n /**\n * Preset items are the available items to add to the canvas\n */\n presets?: AglynNodePresetSchema[]\n}\n\nexport type NodePresetData = Omit<AglynNodeSchema, '$id' | 'nodes'> & {\n $id?: NodeId\n nodes?: NodePresetData[]\n}\n\nexport type AglynNodePresetSchema = {\n $id: PresetId\n label: string\n componentId?: ComponentId\n pluginId?: BundleId\n description?: string\n icon?: SvgIconProps\n category?: string | ComponentCategory\n data: NodePresetData\n}\n\nexport enum FieldComponentType {\n /**\n * Per-breakpoint span editor (AGL-2486): a small row of breakpoint\n * controls (All / xs / sm / md / lg / xl), each offering a column count\n * plus MUI's `auto` and `grow` keywords. The persisted prop is still ONE\n * string in the syntax the Grid element already parses (`\"6\"`, `\"auto\"`,\n * `\"xs:12 md:6\"`) — this is an input affordance, not a shape change, so\n * renderers and existing documents stay untouched. A value the row cannot\n * model (a `{{token}}`, an unknown breakpoint) falls back to free text\n * rather than being clobbered.\n */\n BREAKPOINT_SPAN = 'breakpoint-span',\n BUTTON = 'button',\n BUTTON_GROUP = 'button-group',\n CHECKBOX = 'checkbox',\n COLOR_PICKER = 'color-picker',\n /**\n * Border editor (AGL-2486): a thickness box plus a plain-English line-style\n * picker (solid / dashed / dotted / double / no line). The persisted prop is\n * still ONE CSS shorthand string (`\"1px solid\"`, `\"none\"`, `\"\"`), so\n * renderers and existing documents stay untouched. A value the pair cannot\n * model (`thin solid`, `1px solid #f00`, a binding token) falls back to free\n * text rather than being clobbered, and flips back the moment the text is a\n * plain `<width> <style>` again.\n */\n CSS_BORDER = 'css-border',\n /**\n * CSS length editor (AGL-1219): a number box plus a unit picker sharing\n * the styles panel's unit list. The persisted prop is still ONE CSS\n * string (`\"920px\"`, `\"100%\"`, `\"auto\"`, `\"\"`) — this is an input\n * affordance, not a shape change, so renderers stay untouched. Values\n * the picker can't model (`calc(…)`, a binding token) fall back to free\n * text rather than being clobbered.\n */\n CSS_DIMENSION = 'css-dimension',\n /**\n * Background fill editor (AGL-1331): a fill-type switch (default / solid\n * / linear / radial) over an angle box and a colour-stop list, each stop\n * bindable to a palette token or a literal. The persisted prop is ONE CSS\n * string under `backgroundImage` — a solid fill writes the explicit\n * keyword `none` and leaves `backgroundColor` to do the job, while the\n * default choice writes nothing at all (AGL-1338: the two differ on a\n * component instance, where absence means \"keep the component's fill\") —\n * so renderers stay untouched. Values\n * the editor cannot model (`conic-gradient`, `to bottom right`, a stacked\n * image list) fall back to free text rather than being clobbered.\n */\n CSS_GRADIENT = 'css-gradient',\n /**\n * Row-and-column grid editor for the Table element (AGL-2543).\n *\n * The persisted prop is still ONE string — pipe-delimited rows with the\n * markdown divider carrying per-column alignment — so the renderer and\n * existing documents stay untouched, and a comparison table already\n * authored inside a Markdown element pastes straight in. This is the\n * affordance that makes the element no-code: without it an author edits\n * pipe syntax, which is the audience the besigner exists to spare.\n */\n DATA_TABLE = 'data-table',\n DATE_PICKER = 'date-picker',\n DUAL_LIST_SELECT = 'dual-list-select',\n FIELD_ARRAY = 'field-array',\n ICON_PICKER = 'icon-picker',\n /**\n * markdown-lite document editor (AGL-1616): the WYSIWYG the console\n * already ships for blog entries and marketplace listings, rendered as the\n * attribute's field. The persisted prop is still ONE markdown-lite string,\n * so every renderer stays untouched — this is an input affordance, not a\n * shape change. Declared by an attribute whose value is a whole document\n * rather than a line of text; a plain TEXTAREA meant the Privacy Policy\n * body was edited as a 13 KB raw paste (AGL-1594).\n */\n MARKDOWN = 'markdown',\n INPUT_ADDON_BUTTON_GROUP = 'input-addon-button-group',\n INPUT_ADDON_GROUP = 'input-addon-group',\n PLAIN_TEXT = 'plain-text',\n /**\n * Named-preset picker with a raw escape hatch (AGL-2486): the theme's own\n * answers first, then plain-English presets that PREVIEW themselves, then\n * Custom…. The persisted prop is whatever the property already stored — a\n * number where a bare number is a theme multiple, a CSS string otherwise —\n * and a stored value matching no preset opens the field in its custom state\n * holding that value rather than dropping it.\n */\n PRESET_CHOICE = 'preset-choice',\n RADIO = 'radio',\n /**\n * Select listing the host's screens; the editor resolves the options from\n * the host routing map at render time and writes the chosen screen id.\n */\n SCREEN_SELECT = 'screen-select',\n /**\n * Select listing the canvas's other elements (AGL-557): the editor\n * resolves options from the live canvas at edit time and persists the\n * node id — e.g. the form's reveal-on-submit target.\n */\n NODE_SELECT = 'node-select',\n /**\n * Id-based entity pickers (AGL-343/344): the editor resolves options\n * from EntityPickerContext at edit time and persists the entity id —\n * renames never break the reference.\n */\n /**\n * Select listing the plugins installed for this site (AGL-1030): the editor\n * resolves options from the install set the console publishes and persists\n * the listing id. A picker rather than a typed document id — the same reason\n * every other reference in the designer is one, and here it also removes the\n * \"is this installed?\" question by construction.\n */\n PLUGIN_SELECT = 'plugin-select',\n /**\n * A placed plugin's declared settings, rendered as real fields (AGL-1049).\n * Reads the sibling plugin selection to know which manifest to offer.\n */\n PLUGIN_SETTINGS = 'plugin-settings',\n PRODUCT_SELECT = 'product-select',\n COLLECTION_SELECT = 'collection-select',\n CATEGORY_SELECT = 'category-select',\n DATASET_SELECT = 'dataset-select',\n /**\n * Select listing the model fields of the nearest ancestor node's chosen\n * dataset (AGL-556): the editor resolves options from\n * EntityPickerContext.entityFields using the ancestor's `datasetId`\n * (or legacy `datasetName` matched by label) and persists the stable\n * model fieldId — field renames never break the mapping.\n */\n DATASET_FIELD_SELECT = 'dataset-field-select',\n /**\n * Select listing the host's form entities (`docs/specs/reusable-forms.md`\n * §2c): the editor resolves options from EntityPickerContext.forms and\n * persists the form id. The same id-first reasoning as every picker in this\n * family, and here it is load-bearing rather than convenient — the string\n * it replaces was the form's whole identity, so a rename split the\n * submission history it named.\n */\n FORM_SELECT = 'form-select',\n SELECT = 'select',\n SLIDER = 'slider',\n SUB_FORM = 'sub-form',\n SWITCH = 'switch',\n TAB_ITEM = 'tab-item',\n TABS = 'tabs',\n TEXT_FIELD = 'text-field',\n TEXTAREA = 'textarea',\n /**\n * Theme-scale combo box (AGL-2486): offers the THEME's own scale for a\n * property — `theme.typography` for font size and weight,\n * `theme.zIndex` for stacking — while still accepting any raw value\n * (`18px`, `1.25rem`, `700`, `1400`), because arbitrary values are\n * legitimate. The persisted value is a theme token PATH\n * (`h4.fontSize`, `fontWeightBold`, `appBar`), which MUI's sx system\n * resolves against the active theme exactly as it resolves\n * `color: 'primary.main'` — so the element keeps following the theme\n * instead of freezing the number it had when it was styled.\n */\n THEME_SCALE = 'theme-scale',\n TIME_PICKER = 'time-picker',\n TOGGLE_BUTTON = 'toggle-button',\n WIZARD = 'wizard',\n}\n\nexport enum FieldValidatorType {\n EXACT_LENGTH = 'exact-length',\n MAX_LENGTH = 'max-length',\n MAX_NUMBER_VALUE = 'max-number-value',\n MIN_ITEMS = 'min-items',\n MIN_LENGTH = 'min-length',\n MIN_NUMBER_VALUE = 'min-number-value',\n PATTERN = 'pattern',\n REQUIRED = 'required',\n URL = 'url',\n}\n\nexport type FieldDataType =\n | 'boolean'\n | 'float'\n | 'integer'\n | 'number'\n | 'string'\n\nexport interface AglynAttributeSchema extends Dictionary<any> {\n name: string\n dataType?: DataType\n component: string | FieldComponentType\n validate?: Validator[]\n condition?: ConditionDefinition | ConditionDefinition[]\n initializeOnMount?: boolean\n initialValue?: unknown\n clearedValue?: unknown\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: ResolvePropsFunction\n description?: string\n /**\n * The one kind of media library file this attribute holds (AGL-3716):\n * `image`, `video`, `pdf` or `audio`. Its \"Browse media\" picker lists and\n * uploads only that kind. Read by the editor, never handed to the field.\n */\n mediaKind?: 'image' | 'video' | 'pdf' | 'audio'\n}\n\nexport interface AglynNodeSchema<P = JSX.AnyProps> {\n $id: NodeId\n componentId: ComponentId\n pluginId?: BundleId\n parentId?: NodeId\n sx?: JSX.SxProps\n props?: P\n nodes?: NodeId[] | AglynNodeSchema[]\n}\n"],"names":["LinealDirectiveFlag","FieldComponentType","FieldValidatorType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAkBD,OAAO,IAAA,AAAKA,6CAAAA;;;WAAAA;MAGX;AAwKD,OAAO,IAAA,AAAKC,4CAAAA;IACV;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;IAED;;;;;;;GAOC;IAED;;;;;;;;;;;GAWC;IAED;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;;;;IAKD;;;;;;;GAOC;;IAGD;;;GAGC;IAED;;;;GAIC;IAED;;;;GAIC,GACD;;;;;;GAMC;IAED;;;GAGC;;;;;IAMD;;;;;;GAMC;IAED;;;;;;;GAOC;;;;;;;;;IAUD;;;;;;;;;;GAUC;;;;WA1JSA;MA+JX;AAED,OAAO,IAAA,AAAKC,4CAAAA;;;;;;;;;;WAAAA;MAUX"}
1
+ {"version":3,"sources":["../../../../../../../libs/aglyn/src/lib/foundation/definitions/components.types.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConditionDefinition,\n DataType,\n Validator,\n} from '@data-driven-forms/react-form-renderer'\nimport type {\n FieldActions,\n ResolvePropsFunction,\n} from '@data-driven-forms/react-form-renderer/common-types'\nimport type { SvgIconProps } from '@mui/material'\nimport type { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { CANVAS_ROOT_ELEMENT_ID } from '../constants/canvas'\nimport type { ComponentCategory } from '../constants/components'\nimport type { FEATURE_FLAG, RICH_TEXT_COMMANDS } from '../constants/shared'\nimport type { AGLYN_OF, SYMBOL_TYPE } from '../constants/symbol'\n\nexport enum LinealDirectiveFlag {\n LIMIT_TO = 'limitedTo',\n DISALLOW = 'forbid',\n}\n\nexport type BundleId = string\nexport type PluginId = string\nexport type ComponentId = string\nexport type PresetId = string\nexport type NodeId = string\n\nexport type ComponentsLinealOrder = [\n directiveType: LinealDirectiveFlag,\n directiveDefinition:\n | Array<ComponentId>\n | { plugins?: Array<PluginId>; components: Array<ComponentId> }\n | { plugins: Array<PluginId>; components?: Array<ComponentId> },\n]\n\nexport type AglynNodeItemDenormalized<P = JSX.AnyProps> = AglynNodeSchema<P> & {\n nodes?: AglynNodeItemDenormalized[]\n}\n\nexport type AglynNodesList = Array<AglynNodeItemDenormalized>\n\nexport type AglynNodeHierarchy<$ID extends NodeId = NodeId> = [\n root: CANVAS_ROOT_ELEMENT_ID,\n ...nodes: [...ancestors: NodeId[], element: $ID],\n]\n\nexport interface AglynExoticComponent<PROPS = any, REF = any>\n extends JSX.ForwardRefExoticComponent<\n JSX.PropsWithoutRef<PROPS> & JSX.RefAttributes<REF>\n > {\n [AGLYN_OF]?: SYMBOL_TYPE\n aglyn?: boolean\n schema?: AglynComponentSchema<PROPS>\n}\n\nexport interface AglynComponentSchema<P = any> {\n $id: ComponentId\n pluginId?: BundleId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n\n /**\n * Icon props for display around besigner\n */\n icon?: SvgIconProps\n /**\n * Options to be passed to styled(Component, \\{...styledOptions\\})\n */\n styledOptions?: MuiStyledOptions\n\n /**\n * Define a limitation for nodes allowed as direct descendents\n */\n restrictChildren?: ComponentsLinealOrder\n /**\n * Define a limitation for nodes allowed to be direct ancestors\n */\n restrictParent?: ComponentsLinealOrder\n\n /**\n * Filter props\n */\n resolveProps?: JSX.ResolveProps<AglynNodeItemDenormalized<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AglynAttributeSchema[]\n\n /**\n * Which groups of formatting the inline rich-text toolbar offers for this\n * component (AGL-2557). Read only where `flags.richTextEditable` is on.\n *\n * Omitted means every group, which is what leaves Typography exactly as it\n * was. Naming a subset narrows the toolbar AND the commit: a surface that\n * offers neither lists nor links is phrasing-only, and the sanitizer holds\n * it to that whatever an author pastes in.\n */\n richTextCommands?: RICH_TEXT_COMMANDS[]\n\n /**\n * Feature flags\n */\n flags?: {\n /**\n * Disable the use of emotion styled\n */\n emotion?: FEATURE_FLAG\n /**\n * Can the nodes of this component type be cloned?\n */\n cloning?: FEATURE_FLAG\n /**\n * Allow dragging nodes of this component type\n */\n dragging?: FEATURE_FLAG\n /**\n * Allow dropping nodes inside nodes of this component type\n */\n dropping?: FEATURE_FLAG\n /**\n * Allow editing element attributes of this component type\n */\n editing?: FEATURE_FLAG\n /**\n * Allow removing nodes of this component type\n */\n removing?: FEATURE_FLAG\n /**\n * Describe nodes of this component type to be self-closing\n */\n selfClosing?: FEATURE_FLAG\n /**\n * Component renders its `children` prop as text content the editor may\n * edit directly (Attributes \"Text\" field, inline canvas editing).\n */\n textEditable?: FEATURE_FLAG\n /**\n * Component also accepts basic rich text (AGL-54): sanitized HTML in the\n * `html` prop with `children` as the plain-text fallback.\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * must hand it one React child per node child instead of the single\n * `<Branch>` element it normally passes.\n *\n * MUI's Accordion does `const [summary, ...rest] = Children.toArray(children)`,\n * and `toArray` does not traverse into an element — so with the default\n * wrapping the summary swallowed the whole subtree and the Collapse got\n * nothing. Every accordion on every published site expanded to reveal an\n * empty panel while its content rendered unconditionally inside the\n * summary's `<h3>`.\n *\n * Opt in only for components with this contract; the wrapper is what\n * keeps the Branch/Stem/Leaf seam swappable for everything else.\n */\n positionalChildren?: FEATURE_FLAG\n /**\n * Component takes its text as a plain string `children`: no child\n * elements and no `<aglyn-text>` wrapper around it. For an element whose\n * DOM allows text and nothing else, such as `<option>`, where React and\n * the browser's parser both drop an element child, and with it the text.\n *\n * Not `selfClosing`, which means a void element (`<img>`) and strips\n * `children` altogether: a Select Option flagged that way rendered every\n * dropdown choice on every published site with no words.\n */\n plainTextChildren?: FEATURE_FLAG\n }\n\n /**\n * Preset items are the available items to add to the canvas\n */\n presets?: AglynNodePresetSchema[]\n}\n\nexport type NodePresetData = Omit<AglynNodeSchema, '$id' | 'nodes'> & {\n $id?: NodeId\n nodes?: NodePresetData[]\n}\n\nexport type AglynNodePresetSchema = {\n $id: PresetId\n label: string\n componentId?: ComponentId\n pluginId?: BundleId\n description?: string\n icon?: SvgIconProps\n category?: string | ComponentCategory\n data: NodePresetData\n}\n\nexport enum FieldComponentType {\n /**\n * Per-breakpoint span editor (AGL-2486): a small row of breakpoint\n * controls (All / xs / sm / md / lg / xl), each offering a column count\n * plus MUI's `auto` and `grow` keywords. The persisted prop is still ONE\n * string in the syntax the Grid element already parses (`\"6\"`, `\"auto\"`,\n * `\"xs:12 md:6\"`) — this is an input affordance, not a shape change, so\n * renderers and existing documents stay untouched. A value the row cannot\n * model (a `{{token}}`, an unknown breakpoint) falls back to free text\n * rather than being clobbered.\n */\n BREAKPOINT_SPAN = 'breakpoint-span',\n BUTTON = 'button',\n BUTTON_GROUP = 'button-group',\n CHECKBOX = 'checkbox',\n COLOR_PICKER = 'color-picker',\n /**\n * Border editor (AGL-2486): a thickness box plus a plain-English line-style\n * picker (solid / dashed / dotted / double / no line). The persisted prop is\n * still ONE CSS shorthand string (`\"1px solid\"`, `\"none\"`, `\"\"`), so\n * renderers and existing documents stay untouched. A value the pair cannot\n * model (`thin solid`, `1px solid #f00`, a binding token) falls back to free\n * text rather than being clobbered, and flips back the moment the text is a\n * plain `<width> <style>` again.\n */\n CSS_BORDER = 'css-border',\n /**\n * CSS length editor (AGL-1219): a number box plus a unit picker sharing\n * the styles panel's unit list. The persisted prop is still ONE CSS\n * string (`\"920px\"`, `\"100%\"`, `\"auto\"`, `\"\"`) — this is an input\n * affordance, not a shape change, so renderers stay untouched. Values\n * the picker can't model (`calc(…)`, a binding token) fall back to free\n * text rather than being clobbered.\n */\n CSS_DIMENSION = 'css-dimension',\n /**\n * Background fill editor (AGL-1331): a fill-type switch (default / solid\n * / linear / radial) over an angle box and a colour-stop list, each stop\n * bindable to a palette token or a literal. The persisted prop is ONE CSS\n * string under `backgroundImage` — a solid fill writes the explicit\n * keyword `none` and leaves `backgroundColor` to do the job, while the\n * default choice writes nothing at all (AGL-1338: the two differ on a\n * component instance, where absence means \"keep the component's fill\") —\n * so renderers stay untouched. Values\n * the editor cannot model (`conic-gradient`, `to bottom right`, a stacked\n * image list) fall back to free text rather than being clobbered.\n */\n CSS_GRADIENT = 'css-gradient',\n /**\n * Row-and-column grid editor for the Table element (AGL-2543).\n *\n * The persisted prop is still ONE string — pipe-delimited rows with the\n * markdown divider carrying per-column alignment — so the renderer and\n * existing documents stay untouched, and a comparison table already\n * authored inside a Markdown element pastes straight in. This is the\n * affordance that makes the element no-code: without it an author edits\n * pipe syntax, which is the audience the besigner exists to spare.\n */\n DATA_TABLE = 'data-table',\n DATE_PICKER = 'date-picker',\n DUAL_LIST_SELECT = 'dual-list-select',\n FIELD_ARRAY = 'field-array',\n ICON_PICKER = 'icon-picker',\n /**\n * markdown-lite document editor (AGL-1616): the WYSIWYG the console\n * already ships for blog entries and marketplace listings, rendered as the\n * attribute's field. The persisted prop is still ONE markdown-lite string,\n * so every renderer stays untouched — this is an input affordance, not a\n * shape change. Declared by an attribute whose value is a whole document\n * rather than a line of text; a plain TEXTAREA meant the Privacy Policy\n * body was edited as a 13 KB raw paste (AGL-1594).\n */\n MARKDOWN = 'markdown',\n INPUT_ADDON_BUTTON_GROUP = 'input-addon-button-group',\n INPUT_ADDON_GROUP = 'input-addon-group',\n PLAIN_TEXT = 'plain-text',\n /**\n * Named-preset picker with a raw escape hatch (AGL-2486): the theme's own\n * answers first, then plain-English presets that PREVIEW themselves, then\n * Custom…. The persisted prop is whatever the property already stored — a\n * number where a bare number is a theme multiple, a CSS string otherwise —\n * and a stored value matching no preset opens the field in its custom state\n * holding that value rather than dropping it.\n */\n PRESET_CHOICE = 'preset-choice',\n RADIO = 'radio',\n /**\n * Select listing the host's screens; the editor resolves the options from\n * the host routing map at render time and writes the chosen screen id.\n */\n SCREEN_SELECT = 'screen-select',\n /**\n * Select listing the canvas's other elements (AGL-557): the editor\n * resolves options from the live canvas at edit time and persists the\n * node id — e.g. the form's reveal-on-submit target.\n */\n NODE_SELECT = 'node-select',\n /**\n * Id-based entity pickers (AGL-343/344): the editor resolves options\n * from EntityPickerContext at edit time and persists the entity id —\n * renames never break the reference.\n */\n /**\n * Select listing the plugins installed for this site (AGL-1030): the editor\n * resolves options from the install set the console publishes and persists\n * the listing id. A picker rather than a typed document id — the same reason\n * every other reference in the designer is one, and here it also removes the\n * \"is this installed?\" question by construction.\n */\n PLUGIN_SELECT = 'plugin-select',\n /**\n * A placed plugin's declared settings, rendered as real fields (AGL-1049).\n * Reads the sibling plugin selection to know which manifest to offer.\n */\n PLUGIN_SETTINGS = 'plugin-settings',\n PRODUCT_SELECT = 'product-select',\n COLLECTION_SELECT = 'collection-select',\n CATEGORY_SELECT = 'category-select',\n DATASET_SELECT = 'dataset-select',\n /**\n * Select listing the model fields of the nearest ancestor node's chosen\n * dataset (AGL-556): the editor resolves options from\n * EntityPickerContext.entityFields using the ancestor's `datasetId`\n * (or legacy `datasetName` matched by label) and persists the stable\n * model fieldId — field renames never break the mapping.\n */\n DATASET_FIELD_SELECT = 'dataset-field-select',\n /**\n * Select listing the host's form entities (`docs/specs/reusable-forms.md`\n * §2c): the editor resolves options from EntityPickerContext.forms and\n * persists the form id. The same id-first reasoning as every picker in this\n * family, and here it is load-bearing rather than convenient — the string\n * it replaces was the form's whole identity, so a rename split the\n * submission history it named.\n */\n FORM_SELECT = 'form-select',\n SELECT = 'select',\n SLIDER = 'slider',\n SUB_FORM = 'sub-form',\n SWITCH = 'switch',\n TAB_ITEM = 'tab-item',\n TABS = 'tabs',\n TEXT_FIELD = 'text-field',\n TEXTAREA = 'textarea',\n /**\n * Theme-scale combo box (AGL-2486): offers the THEME's own scale for a\n * property — `theme.typography` for font size and weight,\n * `theme.zIndex` for stacking — while still accepting any raw value\n * (`18px`, `1.25rem`, `700`, `1400`), because arbitrary values are\n * legitimate. The persisted value is a theme token PATH\n * (`h4.fontSize`, `fontWeightBold`, `appBar`), which MUI's sx system\n * resolves against the active theme exactly as it resolves\n * `color: 'primary.main'` — so the element keeps following the theme\n * instead of freezing the number it had when it was styled.\n */\n THEME_SCALE = 'theme-scale',\n TIME_PICKER = 'time-picker',\n TOGGLE_BUTTON = 'toggle-button',\n WIZARD = 'wizard',\n}\n\nexport enum FieldValidatorType {\n EXACT_LENGTH = 'exact-length',\n MAX_LENGTH = 'max-length',\n MAX_NUMBER_VALUE = 'max-number-value',\n MIN_ITEMS = 'min-items',\n MIN_LENGTH = 'min-length',\n MIN_NUMBER_VALUE = 'min-number-value',\n PATTERN = 'pattern',\n REQUIRED = 'required',\n URL = 'url',\n}\n\nexport type FieldDataType =\n | 'boolean'\n | 'float'\n | 'integer'\n | 'number'\n | 'string'\n\nexport interface AglynAttributeSchema extends Dictionary<any> {\n name: string\n dataType?: DataType\n component: string | FieldComponentType\n validate?: Validator[]\n condition?: ConditionDefinition | ConditionDefinition[]\n initializeOnMount?: boolean\n initialValue?: unknown\n clearedValue?: unknown\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: ResolvePropsFunction\n description?: string\n /**\n * The one kind of media library file this attribute holds (AGL-3716):\n * `image`, `video`, `pdf` or `audio`. Its \"Browse media\" picker lists and\n * uploads only that kind. Read by the editor, never handed to the field.\n */\n mediaKind?: 'image' | 'video' | 'pdf' | 'audio'\n}\n\nexport interface AglynNodeSchema<P = JSX.AnyProps> {\n $id: NodeId\n componentId: ComponentId\n pluginId?: BundleId\n parentId?: NodeId\n sx?: JSX.SxProps\n props?: P\n nodes?: NodeId[] | AglynNodeSchema[]\n}\n"],"names":["LinealDirectiveFlag","FieldComponentType","FieldValidatorType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAkBD,OAAO,IAAA,AAAKA,6CAAAA;;;WAAAA;MAGX;AAmLD,OAAO,IAAA,AAAKC,4CAAAA;IACV;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;IAED;;;;;;;GAOC;IAED;;;;;;;;;;;GAWC;IAED;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;;;;IAKD;;;;;;;GAOC;;IAGD;;;GAGC;IAED;;;;GAIC;IAED;;;;GAIC,GACD;;;;;;GAMC;IAED;;;GAGC;;;;;IAMD;;;;;;GAMC;IAED;;;;;;;GAOC;;;;;;;;;IAUD;;;;;;;;;;GAUC;;;;WA1JSA;MA+JX;AAED,OAAO,IAAA,AAAKC,4CAAAA;;;;;;;;;;WAAAA;MAUX"}
@@ -18,8 +18,13 @@ import type { ConditionDefinition, DataType, Validator } from '@data-driven-form
18
18
  import type { FieldActions, ResolvePropsFunction } from '@data-driven-forms/react-form-renderer/common-types';
19
19
  import type { MuiStyledOptions } from '@mui/system/createStyled';
20
20
  import type { SvgIconProps } from '@mui/material/SvgIcon';
21
- /** Minimal icon-props type used in component/preset schemas. Structurally compatible with @aglyn/shared-ui-jsx MdiIconProps. */
22
- export type MdiIconProps<D extends React.ElementType = 'svg', P = object> = SvgIconProps<D, P> & {
21
+ /**
22
+ * Minimal icon-props type used in component/preset schemas. Structurally
23
+ * compatible with @aglyn/shared-ui-jsx MdiIconProps, which draws `path` and
24
+ * takes no ReactNode children (only a `(d) => …` render function), so
25
+ * `children` is left out here too.
26
+ */
27
+ export type MdiIconProps<D extends React.ElementType = 'svg', P = object> = Omit<SvgIconProps<D, P>, 'children'> & {
23
28
  path?: string;
24
29
  };
25
30
  import type { ComponentId, ComponentsLinealOrder, NodeId, PresetId } from '../foundation';
@@ -609,6 +614,17 @@ export interface ComponentSchema<P = any> {
609
614
  * the Branch/Stem/Leaf seam swappable for everything else.
610
615
  */
611
616
  positionalChildren?: FEATURE_FLAG;
617
+ /**
618
+ * Component takes its text as a plain string `children`: no child
619
+ * elements and no `<aglyn-text>` wrapper around it. For an element whose
620
+ * DOM allows text and nothing else, such as `<option>`, where React and
621
+ * the browser's parser both drop an element child, and with it the text.
622
+ *
623
+ * Not `selfClosing`, which means a void element (`<img>`) and strips
624
+ * `children` altogether: a Select Option flagged that way rendered every
625
+ * dropdown choice on every published site with no words.
626
+ */
627
+ plainTextChildren?: FEATURE_FLAG;
612
628
  /**
613
629
  * Nothing this component renders responds to the visitor until it is
614
630
  * hydrated, beyond what its server HTML does on its own — copy, images,