@aglyn/aglyn 1.17.0 → 1.19.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/package.json +11 -11
- package/src/lib/app-utils/compose-reusable-components.js +7 -3
- package/src/lib/app-utils/compose-reusable-components.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
- package/src/lib/app-utils/docs-help.generated.js +1 -0
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +18 -4
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/element-motion.js +6 -5
- package/src/lib/app-utils/element-motion.js.map +1 -1
- package/src/lib/app-utils/expand-repeatables.d.ts +23 -3
- package/src/lib/app-utils/expand-repeatables.js +61 -7
- package/src/lib/app-utils/expand-repeatables.js.map +1 -1
- package/src/lib/app-utils/plugin-connection-editor.d.ts +22 -0
- package/src/lib/app-utils/plugin-connection-editor.js.map +1 -1
- package/src/lib/app-utils/plugin-connection-repeat.d.ts +82 -0
- package/src/lib/app-utils/plugin-connection-repeat.js +162 -0
- package/src/lib/app-utils/plugin-connection-repeat.js.map +1 -0
- package/src/lib/app-utils/release-flags.js +2 -2
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/repeat-sources.d.ts +33 -1
- package/src/lib/app-utils/repeat-sources.js +27 -3
- package/src/lib/app-utils/repeat-sources.js.map +1 -1
- package/src/lib/app-utils/seo-page-facts.js +3 -6
- package/src/lib/app-utils/seo-page-facts.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +6 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js +8 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/repeat-rows.d.ts +20 -2
- package/src/lib/plugin-manager/repeat-rows.js +42 -16
- package/src/lib/plugin-manager/repeat-rows.js.map +1 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { AglynAttributeSchema } from '../foundation/definitions/components.types';
|
|
18
18
|
import type { EntityPickerKind } from './entity-picker-context';
|
|
19
|
-
import type
|
|
19
|
+
import { type RepeatableDataset } from './expand-repeatables';
|
|
20
20
|
/**
|
|
21
21
|
* Where a repeat's rows come from, for the editor (AGL-3111).
|
|
22
22
|
*
|
|
@@ -64,6 +64,13 @@ export interface RepeatRowsRequest {
|
|
|
64
64
|
/** The key exactly as the node stores it. */
|
|
65
65
|
key: string;
|
|
66
66
|
}
|
|
67
|
+
/** One field a repeat's `{{item.<id>}}` token can name, as the menu lists it. */
|
|
68
|
+
export interface RepeatItemField {
|
|
69
|
+
/** What follows `item.` in the token. */
|
|
70
|
+
id: string;
|
|
71
|
+
/** What a person reads in the insert-token menu. */
|
|
72
|
+
label: string;
|
|
73
|
+
}
|
|
67
74
|
/** One kind of thing an element can repeat over. */
|
|
68
75
|
export interface RepeatSource {
|
|
69
76
|
/** Stable id, e.g. the plugin's name for the kind. */
|
|
@@ -88,6 +95,20 @@ export interface RepeatSource {
|
|
|
88
95
|
* menu offers no item tokens and authors type them.
|
|
89
96
|
*/
|
|
90
97
|
entityKind?: EntityPickerKind;
|
|
98
|
+
/**
|
|
99
|
+
* The fields a key's rows hold, for a source whose keys are no entity the
|
|
100
|
+
* picker lists (AGL-4212). With it, the insert-token menu inside the repeat
|
|
101
|
+
* offers `{{item.<id>}}` for each; `undefined` for a key it does not know.
|
|
102
|
+
* Plain, not a hook: a source whose fields depend on the site is
|
|
103
|
+
* registered again when they change, which the registry announces.
|
|
104
|
+
*/
|
|
105
|
+
fields?(key: string): readonly RepeatItemField[] | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* `false` while the source has nothing this site can pick (AGL-4212): the
|
|
108
|
+
* Attributes panel then draws its key field only on an element that already
|
|
109
|
+
* repeats over one of its keys, so it can be cleared. Absent means offered.
|
|
110
|
+
*/
|
|
111
|
+
offered?: boolean;
|
|
91
112
|
/**
|
|
92
113
|
* Reads one key's rows for the besigner's canvas preview and badge. A React
|
|
93
114
|
* hook: the editor mounts one reader per key and calls it unconditionally,
|
|
@@ -118,8 +139,19 @@ export declare function getRepeatSourcesVersion(): number;
|
|
|
118
139
|
/**
|
|
119
140
|
* The registered source a node repeats over, and the key it names, trimmed.
|
|
120
141
|
* `undefined` for a node that repeats over nothing a registered source owns.
|
|
142
|
+
*
|
|
143
|
+
* A node carrying two sources' keys repeats over the one the published page
|
|
144
|
+
* expands it by (`repeatKey`, AGL-4212), so the canvas never previews rows
|
|
145
|
+
* the page does not render.
|
|
121
146
|
*/
|
|
122
147
|
export declare function repeatSourceOf(node: unknown): {
|
|
123
148
|
source: RepeatSource;
|
|
124
149
|
key: string;
|
|
125
150
|
} | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* What a source's own picker calls `key`, read off its key attribute's
|
|
153
|
+
* `options`, or `undefined` when the attribute lists none that matches
|
|
154
|
+
* (AGL-4212). How a sentence or a menu names a repeat whose key is no entity
|
|
155
|
+
* the picker lists, without printing the stored value.
|
|
156
|
+
*/
|
|
157
|
+
export declare function repeatKeyOptionLabel(source: Pick<RepeatSource, 'keyAttribute'>, key: string): string | undefined;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/
|
|
16
|
+
*/ import { REPEAT_CONNECTION_KEY_PREFIX, REPEAT_CONNECTION_PROP, repeatKey } from "./expand-repeatables.js";
|
|
17
|
+
const sources = new Map();
|
|
17
18
|
const listeners = new Set();
|
|
18
19
|
let version = 0;
|
|
19
20
|
/**
|
|
@@ -69,18 +70,41 @@ const notify = ()=>{
|
|
|
69
70
|
/**
|
|
70
71
|
* The registered source a node repeats over, and the key it names, trimmed.
|
|
71
72
|
* `undefined` for a node that repeats over nothing a registered source owns.
|
|
73
|
+
*
|
|
74
|
+
* A node carrying two sources' keys repeats over the one the published page
|
|
75
|
+
* expands it by (`repeatKey`, AGL-4212), so the canvas never previews rows
|
|
76
|
+
* the page does not render.
|
|
72
77
|
*/ export function repeatSourceOf(node) {
|
|
73
78
|
const props = node == null ? void 0 : node.props;
|
|
74
79
|
if (!props) return undefined;
|
|
80
|
+
const expandedBy = repeatKey(node);
|
|
81
|
+
let first;
|
|
75
82
|
for (const source of sources.values()){
|
|
76
83
|
const value = props[source.keyProp];
|
|
77
84
|
const key = typeof value === 'string' ? value.trim() : '';
|
|
78
|
-
if (key)
|
|
85
|
+
if (!key) continue;
|
|
86
|
+
const asExpanded = source.keyProp === REPEAT_CONNECTION_PROP ? `${REPEAT_CONNECTION_KEY_PREFIX}${key}` : key;
|
|
87
|
+
if (asExpanded === expandedBy) return {
|
|
88
|
+
source,
|
|
89
|
+
key
|
|
90
|
+
};
|
|
91
|
+
first != null ? first : first = {
|
|
79
92
|
source,
|
|
80
93
|
key
|
|
81
94
|
};
|
|
82
95
|
}
|
|
83
|
-
return
|
|
96
|
+
return first;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* What a source's own picker calls `key`, read off its key attribute's
|
|
100
|
+
* `options`, or `undefined` when the attribute lists none that matches
|
|
101
|
+
* (AGL-4212). How a sentence or a menu names a repeat whose key is no entity
|
|
102
|
+
* the picker lists, without printing the stored value.
|
|
103
|
+
*/ export function repeatKeyOptionLabel(source, key) {
|
|
104
|
+
const options = source.keyAttribute.options;
|
|
105
|
+
if (!Array.isArray(options)) return undefined;
|
|
106
|
+
const match = options.find((option)=>Boolean(option) && typeof option === 'object' && option.value === key);
|
|
107
|
+
return typeof (match == null ? void 0 : match.label) === 'string' && match.label ? match.label : undefined;
|
|
84
108
|
}
|
|
85
109
|
|
|
86
110
|
//# sourceMappingURL=repeat-sources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/repeat-sources.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 { AglynAttributeSchema } from '../foundation/definitions/components.types'\nimport type { EntityPickerKind } from './entity-picker-context'\nimport type { RepeatableDataset } from './expand-repeatables'\n\n/**\n * Where a repeat's rows come from, for the editor (AGL-3111).\n *\n * Any element can repeat, and the platform decides what a repeat MEANS — the\n * scope, the copies, the bounds (`expand-repeatables.ts`). What it does not\n * decide is what an element repeats OVER. That belongs to the plugin that owns\n * the rows, which registers a source here from the registration function its\n * loader calls by name. Core names no source.\n *\n * Reached by path, never through a barrel: nothing on a published page asks\n * where rows come from, so nothing here is in a published page's download.\n */\n\n/**\n * What a source answers for one key.\n *\n * - `loading` — no answer yet.\n * - `missing` — the key names nothing this site may use. The published page\n * renders no copies of the element (AGL-3496); the canvas keeps the\n * template and flags it on the badge.\n * - `error` — the read failed. Nothing is known about the rows.\n * - `ready` — the rows, read and bounded exactly as the published page's\n * composition reads them.\n */\nexport type RepeatRowsAnswer =\n | { status: 'loading' }\n | { status: 'missing' }\n | { status: 'error' }\n | {\n status: 'ready'\n /** The name authors know the entry by, for the canvas badge. */\n label: string\n /**\n * The rows under every key the expansion looks them up by: the key as\n * the node stores it, the entry's id, and each entry a one-hop reference\n * in the rows reads (`{{item.ref.field}}`).\n */\n rowsByKey: Readonly<Record<string, RepeatableDataset>>\n }\n\n/** One read a source is asked for. */\nexport interface RepeatRowsRequest {\n /** The site the canvas edits. A source answers only what it may show. */\n hostId: string\n /** The key exactly as the node stores it. */\n key: string\n}\n\n/** One kind of thing an element can repeat over. */\nexport interface RepeatSource {\n /** Stable id, e.g. the plugin's name for the kind. */\n id: string\n /** What the Attributes panel calls the kind. */\n label: string\n /**\n * The node prop the chosen key persists under. Persisted in documents, so a\n * source never renames it.\n */\n keyProp: string\n /**\n * The attribute that picks a key, drawn by the Attributes panel as any\n * component attribute is. The panel names the field after `keyProp`.\n */\n keyAttribute: Omit<AglynAttributeSchema, 'name'>\n /**\n * The entity picker kind a key names, when a key is an entity the picker\n * lists. With it, the insert-token menu inside the repeat names the entity\n * through the picker and offers `{{item.<field>}}` for each field the\n * entity declares (`EntityPickerContextValue.entityFields`). Without it the\n * menu offers no item tokens and authors type them.\n */\n entityKind?: EntityPickerKind\n /**\n * Reads one key's rows for the besigner's canvas preview and badge. A React\n * hook: the editor mounts one reader per key and calls it unconditionally,\n * so its identity must not change after registration.\n */\n useRows(request: RepeatRowsRequest): RepeatRowsAnswer\n}\n\nconst sources = new Map<string, RepeatSource>()\nconst listeners = new Set<() => void>()\nlet version = 0\n/**\n * Replaced only when the registered set changes, never rebuilt per call: it is\n * the snapshot `useSyncExternalStore` compares, and a fresh array every time\n * is a render loop rather than a wasted allocation.\n */\nlet snapshot: readonly RepeatSource[] = []\n\nconst notify = () => {\n version += 1\n snapshot = [...sources.values()]\n for (const listener of [...listeners]) listener()\n}\n\n/**\n * Registers a source, replacing any registered under its id. Returns the\n * unregister, which removes the source only if it is still the one registered.\n *\n * Call it from a registration function the plugin loader calls BY NAME, never\n * from a module's top level: a bundler deletes a module imported only for its\n * side effect when its package says it has none (AGL-3025).\n */\nexport function registerRepeatSource(source: RepeatSource): () => void {\n if (sources.get(source.id) !== source) {\n sources.set(source.id, source)\n notify()\n }\n return () => {\n if (sources.get(source.id) !== source) return\n sources.delete(source.id)\n notify()\n }\n}\n\n/**\n * Every registered source, in registration order. The SAME array until the\n * registered set changes, so it can be read as a store snapshot.\n */\nexport function listRepeatSources(): readonly RepeatSource[] {\n return snapshot\n}\n\n/** The source registered under `id`. */\nexport function getRepeatSource(id: string): RepeatSource | undefined {\n return sources.get(id)\n}\n\n/** Called after the registered set changes. Returns the unsubscribe. */\nexport function subscribeRepeatSources(listener: () => void): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\n/** Moves on every change — the snapshot `useSyncExternalStore` reads. */\nexport function getRepeatSourcesVersion(): number {\n return version\n}\n\n/**\n * The registered source a node repeats over, and the key it names, trimmed.\n * `undefined` for a node that repeats over nothing a registered source owns.\n */\nexport function repeatSourceOf(\n node: unknown,\n): { source: RepeatSource; key: string } | undefined {\n const props = (node as { props?: Record<string, unknown> } | undefined)?.props\n if (!props) return undefined\n for (const source of sources.values()) {\n const value = props[source.keyProp]\n const key = typeof value === 'string' ? value.trim() : ''\n if (key) return { source, key }\n }\n return undefined\n}\n"],"names":["sources","Map","listeners","Set","version","snapshot","notify","values","listener","registerRepeatSource","source","get","id","set","delete","listRepeatSources","getRepeatSource","subscribeRepeatSources","add","getRepeatSourcesVersion","repeatSourceOf","node","props","undefined","value","keyProp","key","trim"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAsFD,MAAMA,UAAU,IAAIC;AACpB,MAAMC,YAAY,IAAIC;AACtB,IAAIC,UAAU;AACd;;;;CAIC,GACD,IAAIC,WAAoC,EAAE;AAE1C,MAAMC,SAAS;IACbF,WAAW;IACXC,WAAW;WAAIL,QAAQO,MAAM;KAAG;IAChC,KAAK,MAAMC,YAAY;WAAIN;KAAU,CAAEM;AACzC;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,qBAAqBC,MAAoB;IACvD,IAAIV,QAAQW,GAAG,CAACD,OAAOE,EAAE,MAAMF,QAAQ;QACrCV,QAAQa,GAAG,CAACH,OAAOE,EAAE,EAAEF;QACvBJ;IACF;IACA,OAAO;QACL,IAAIN,QAAQW,GAAG,CAACD,OAAOE,EAAE,MAAMF,QAAQ;QACvCV,QAAQc,MAAM,CAACJ,OAAOE,EAAE;QACxBN;IACF;AACF;AAEA;;;CAGC,GACD,OAAO,SAASS;IACd,OAAOV;AACT;AAEA,sCAAsC,GACtC,OAAO,SAASW,gBAAgBJ,EAAU;IACxC,OAAOZ,QAAQW,GAAG,CAACC;AACrB;AAEA,sEAAsE,GACtE,OAAO,SAASK,uBAAuBT,QAAoB;IACzDN,UAAUgB,GAAG,CAACV;IACd,OAAO;QACLN,UAAUY,MAAM,CAACN;IACnB;AACF;AAEA,uEAAuE,GACvE,OAAO,SAASW;IACd,OAAOf;AACT;AAEA;;;CAGC,GACD,OAAO,SAASgB,eACdC,IAAa;IAEb,MAAMC,QAASD,wBAAD,AAACA,KAA0DC,KAAK;IAC9E,IAAI,CAACA,OAAO,OAAOC;IACnB,KAAK,MAAMb,UAAUV,QAAQO,MAAM,GAAI;QACrC,MAAMiB,QAAQF,KAAK,CAACZ,OAAOe,OAAO,CAAC;QACnC,MAAMC,MAAM,OAAOF,UAAU,WAAWA,MAAMG,IAAI,KAAK;QACvD,IAAID,KAAK,OAAO;YAAEhB;YAAQgB;QAAI;IAChC;IACA,OAAOH;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/repeat-sources.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 { AglynAttributeSchema } from '../foundation/definitions/components.types'\nimport type { EntityPickerKind } from './entity-picker-context'\nimport {\n REPEAT_CONNECTION_KEY_PREFIX,\n REPEAT_CONNECTION_PROP,\n repeatKey,\n type RepeatableDataset,\n} from './expand-repeatables'\n\n/**\n * Where a repeat's rows come from, for the editor (AGL-3111).\n *\n * Any element can repeat, and the platform decides what a repeat MEANS — the\n * scope, the copies, the bounds (`expand-repeatables.ts`). What it does not\n * decide is what an element repeats OVER. That belongs to the plugin that owns\n * the rows, which registers a source here from the registration function its\n * loader calls by name. Core names no source.\n *\n * Reached by path, never through a barrel: nothing on a published page asks\n * where rows come from, so nothing here is in a published page's download.\n */\n\n/**\n * What a source answers for one key.\n *\n * - `loading` — no answer yet.\n * - `missing` — the key names nothing this site may use. The published page\n * renders no copies of the element (AGL-3496); the canvas keeps the\n * template and flags it on the badge.\n * - `error` — the read failed. Nothing is known about the rows.\n * - `ready` — the rows, read and bounded exactly as the published page's\n * composition reads them.\n */\nexport type RepeatRowsAnswer =\n | { status: 'loading' }\n | { status: 'missing' }\n | { status: 'error' }\n | {\n status: 'ready'\n /** The name authors know the entry by, for the canvas badge. */\n label: string\n /**\n * The rows under every key the expansion looks them up by: the key as\n * the node stores it, the entry's id, and each entry a one-hop reference\n * in the rows reads (`{{item.ref.field}}`).\n */\n rowsByKey: Readonly<Record<string, RepeatableDataset>>\n }\n\n/** One read a source is asked for. */\nexport interface RepeatRowsRequest {\n /** The site the canvas edits. A source answers only what it may show. */\n hostId: string\n /** The key exactly as the node stores it. */\n key: string\n}\n\n/** One field a repeat's `{{item.<id>}}` token can name, as the menu lists it. */\nexport interface RepeatItemField {\n /** What follows `item.` in the token. */\n id: string\n /** What a person reads in the insert-token menu. */\n label: string\n}\n\n/** One kind of thing an element can repeat over. */\nexport interface RepeatSource {\n /** Stable id, e.g. the plugin's name for the kind. */\n id: string\n /** What the Attributes panel calls the kind. */\n label: string\n /**\n * The node prop the chosen key persists under. Persisted in documents, so a\n * source never renames it.\n */\n keyProp: string\n /**\n * The attribute that picks a key, drawn by the Attributes panel as any\n * component attribute is. The panel names the field after `keyProp`.\n */\n keyAttribute: Omit<AglynAttributeSchema, 'name'>\n /**\n * The entity picker kind a key names, when a key is an entity the picker\n * lists. With it, the insert-token menu inside the repeat names the entity\n * through the picker and offers `{{item.<field>}}` for each field the\n * entity declares (`EntityPickerContextValue.entityFields`). Without it the\n * menu offers no item tokens and authors type them.\n */\n entityKind?: EntityPickerKind\n /**\n * The fields a key's rows hold, for a source whose keys are no entity the\n * picker lists (AGL-4212). With it, the insert-token menu inside the repeat\n * offers `{{item.<id>}}` for each; `undefined` for a key it does not know.\n * Plain, not a hook: a source whose fields depend on the site is\n * registered again when they change, which the registry announces.\n */\n fields?(key: string): readonly RepeatItemField[] | undefined\n /**\n * `false` while the source has nothing this site can pick (AGL-4212): the\n * Attributes panel then draws its key field only on an element that already\n * repeats over one of its keys, so it can be cleared. Absent means offered.\n */\n offered?: boolean\n /**\n * Reads one key's rows for the besigner's canvas preview and badge. A React\n * hook: the editor mounts one reader per key and calls it unconditionally,\n * so its identity must not change after registration.\n */\n useRows(request: RepeatRowsRequest): RepeatRowsAnswer\n}\n\nconst sources = new Map<string, RepeatSource>()\nconst listeners = new Set<() => void>()\nlet version = 0\n/**\n * Replaced only when the registered set changes, never rebuilt per call: it is\n * the snapshot `useSyncExternalStore` compares, and a fresh array every time\n * is a render loop rather than a wasted allocation.\n */\nlet snapshot: readonly RepeatSource[] = []\n\nconst notify = () => {\n version += 1\n snapshot = [...sources.values()]\n for (const listener of [...listeners]) listener()\n}\n\n/**\n * Registers a source, replacing any registered under its id. Returns the\n * unregister, which removes the source only if it is still the one registered.\n *\n * Call it from a registration function the plugin loader calls BY NAME, never\n * from a module's top level: a bundler deletes a module imported only for its\n * side effect when its package says it has none (AGL-3025).\n */\nexport function registerRepeatSource(source: RepeatSource): () => void {\n if (sources.get(source.id) !== source) {\n sources.set(source.id, source)\n notify()\n }\n return () => {\n if (sources.get(source.id) !== source) return\n sources.delete(source.id)\n notify()\n }\n}\n\n/**\n * Every registered source, in registration order. The SAME array until the\n * registered set changes, so it can be read as a store snapshot.\n */\nexport function listRepeatSources(): readonly RepeatSource[] {\n return snapshot\n}\n\n/** The source registered under `id`. */\nexport function getRepeatSource(id: string): RepeatSource | undefined {\n return sources.get(id)\n}\n\n/** Called after the registered set changes. Returns the unsubscribe. */\nexport function subscribeRepeatSources(listener: () => void): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\n/** Moves on every change — the snapshot `useSyncExternalStore` reads. */\nexport function getRepeatSourcesVersion(): number {\n return version\n}\n\n/**\n * The registered source a node repeats over, and the key it names, trimmed.\n * `undefined` for a node that repeats over nothing a registered source owns.\n *\n * A node carrying two sources' keys repeats over the one the published page\n * expands it by (`repeatKey`, AGL-4212), so the canvas never previews rows\n * the page does not render.\n */\nexport function repeatSourceOf(\n node: unknown,\n): { source: RepeatSource; key: string } | undefined {\n const props = (node as { props?: Record<string, unknown> } | undefined)?.props\n if (!props) return undefined\n const expandedBy = repeatKey(node)\n let first: { source: RepeatSource; key: string } | undefined\n for (const source of sources.values()) {\n const value = props[source.keyProp]\n const key = typeof value === 'string' ? value.trim() : ''\n if (!key) continue\n const asExpanded =\n source.keyProp === REPEAT_CONNECTION_PROP\n ? `${REPEAT_CONNECTION_KEY_PREFIX}${key}`\n : key\n if (asExpanded === expandedBy) return { source, key }\n first ??= { source, key }\n }\n return first\n}\n\n/**\n * What a source's own picker calls `key`, read off its key attribute's\n * `options`, or `undefined` when the attribute lists none that matches\n * (AGL-4212). How a sentence or a menu names a repeat whose key is no entity\n * the picker lists, without printing the stored value.\n */\nexport function repeatKeyOptionLabel(\n source: Pick<RepeatSource, 'keyAttribute'>,\n key: string,\n): string | undefined {\n const options = (source.keyAttribute as { options?: unknown }).options\n if (!Array.isArray(options)) return undefined\n const match = options.find(\n (option): option is { value: string; label?: unknown } =>\n Boolean(option) &&\n typeof option === 'object' &&\n (option as { value?: unknown }).value === key,\n )\n return typeof match?.label === 'string' && match.label ? match.label : undefined\n}\n"],"names":["REPEAT_CONNECTION_KEY_PREFIX","REPEAT_CONNECTION_PROP","repeatKey","sources","Map","listeners","Set","version","snapshot","notify","values","listener","registerRepeatSource","source","get","id","set","delete","listRepeatSources","getRepeatSource","subscribeRepeatSources","add","getRepeatSourcesVersion","repeatSourceOf","node","props","undefined","expandedBy","first","value","keyProp","key","trim","asExpanded","repeatKeyOptionLabel","options","keyAttribute","Array","isArray","match","find","option","Boolean","label"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,SACEA,4BAA4B,EAC5BC,sBAAsB,EACtBC,SAAS,QAEJ,0BAAsB;AAwG7B,MAAMC,UAAU,IAAIC;AACpB,MAAMC,YAAY,IAAIC;AACtB,IAAIC,UAAU;AACd;;;;CAIC,GACD,IAAIC,WAAoC,EAAE;AAE1C,MAAMC,SAAS;IACbF,WAAW;IACXC,WAAW;WAAIL,QAAQO,MAAM;KAAG;IAChC,KAAK,MAAMC,YAAY;WAAIN;KAAU,CAAEM;AACzC;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,qBAAqBC,MAAoB;IACvD,IAAIV,QAAQW,GAAG,CAACD,OAAOE,EAAE,MAAMF,QAAQ;QACrCV,QAAQa,GAAG,CAACH,OAAOE,EAAE,EAAEF;QACvBJ;IACF;IACA,OAAO;QACL,IAAIN,QAAQW,GAAG,CAACD,OAAOE,EAAE,MAAMF,QAAQ;QACvCV,QAAQc,MAAM,CAACJ,OAAOE,EAAE;QACxBN;IACF;AACF;AAEA;;;CAGC,GACD,OAAO,SAASS;IACd,OAAOV;AACT;AAEA,sCAAsC,GACtC,OAAO,SAASW,gBAAgBJ,EAAU;IACxC,OAAOZ,QAAQW,GAAG,CAACC;AACrB;AAEA,sEAAsE,GACtE,OAAO,SAASK,uBAAuBT,QAAoB;IACzDN,UAAUgB,GAAG,CAACV;IACd,OAAO;QACLN,UAAUY,MAAM,CAACN;IACnB;AACF;AAEA,uEAAuE,GACvE,OAAO,SAASW;IACd,OAAOf;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASgB,eACdC,IAAa;IAEb,MAAMC,QAASD,wBAAD,AAACA,KAA0DC,KAAK;IAC9E,IAAI,CAACA,OAAO,OAAOC;IACnB,MAAMC,aAAazB,UAAUsB;IAC7B,IAAII;IACJ,KAAK,MAAMf,UAAUV,QAAQO,MAAM,GAAI;QACrC,MAAMmB,QAAQJ,KAAK,CAACZ,OAAOiB,OAAO,CAAC;QACnC,MAAMC,MAAM,OAAOF,UAAU,WAAWA,MAAMG,IAAI,KAAK;QACvD,IAAI,CAACD,KAAK;QACV,MAAME,aACJpB,OAAOiB,OAAO,KAAK7B,yBACf,GAAGD,+BAA+B+B,KAAK,GACvCA;QACN,IAAIE,eAAeN,YAAY,OAAO;YAAEd;YAAQkB;QAAI;QACpDH,gBAAAA,QAAAA,QAAU;YAAEf;YAAQkB;QAAI;IAC1B;IACA,OAAOH;AACT;AAEA;;;;;CAKC,GACD,OAAO,SAASM,qBACdrB,MAA0C,EAC1CkB,GAAW;IAEX,MAAMI,UAAU,AAACtB,OAAOuB,YAAY,CAA2BD,OAAO;IACtE,IAAI,CAACE,MAAMC,OAAO,CAACH,UAAU,OAAOT;IACpC,MAAMa,QAAQJ,QAAQK,IAAI,CACxB,CAACC,SACCC,QAAQD,WACR,OAAOA,WAAW,YAClB,AAACA,OAA+BZ,KAAK,KAAKE;IAE9C,OAAO,QAAOQ,yBAAAA,MAAOI,KAAK,MAAK,YAAYJ,MAAMI,KAAK,GAAGJ,MAAMI,KAAK,GAAGjB;AACzE"}
|
|
@@ -14,7 +14,8 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/ import {
|
|
17
|
+
*/ import { repeatKey } from "./expand-repeatables.js";
|
|
18
|
+
import { buildPageMarkdown, headingLevelOf, isPageChromeNode, pageContentRootId } from "./page-markdown.js";
|
|
18
19
|
/**
|
|
19
20
|
* What a page SAYS, read off its node tree (AGL-2910): the text a search
|
|
20
21
|
* listing summarizes, the headings, and the images — each heading and image
|
|
@@ -91,11 +92,7 @@ const childIdsOf = (node)=>Array.isArray(node == null ? void 0 : node.nodes) ? (
|
|
|
91
92
|
var _pageNodes_id;
|
|
92
93
|
return ((_pageNodes_id = pageNodes[id]) == null ? void 0 : _pageNodes_id.componentId) === REUSABLE_INSTANCE;
|
|
93
94
|
});
|
|
94
|
-
const repeatIds = Object.keys(pageNodes).filter((id)=>
|
|
95
|
-
var _pageNodes_id_props, _pageNodes_id;
|
|
96
|
-
const key = (_pageNodes_id = pageNodes[id]) == null ? void 0 : (_pageNodes_id_props = _pageNodes_id.props) == null ? void 0 : _pageNodes_id_props['repeatDataset'];
|
|
97
|
-
return typeof key === 'string' && key.trim() !== '';
|
|
98
|
-
});
|
|
95
|
+
const repeatIds = Object.keys(pageNodes).filter((id)=>repeatKey(pageNodes[id]) !== '');
|
|
99
96
|
const resolve = (id, depth)=>{
|
|
100
97
|
if (depth > MAX_DEPTH) return null;
|
|
101
98
|
const own = pageNodes[id];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/seo-page-facts.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 {\n buildPageMarkdown,\n headingLevelOf,\n isPageChromeNode,\n pageContentRootId,\n type PageMarkdownNode,\n type PageMarkdownNodes,\n} from './page-markdown'\n\n/**\n * What a page SAYS, read off its node tree (AGL-2910): the text a search\n * listing summarizes, the headings, and the images — each heading and image\n * by node id, so a finding can name the element it is about and a fix can\n * address the element it changes.\n *\n * Pure, and the platform's: the SEO check (`seo-audit.ts`) judges a page by\n * these facts, and anything that proposes a listing or a content fix reads\n * the same ones rather than walking the tree its own way.\n *\n * The text is the page's Markdown representation, the one an agent is\n * served, so what the listing summarizes is what a reader of the page gets.\n *\n * ## The page as it publishes (AGL-3501)\n *\n * Hand it the COMPOSED node map — reusable components grafted, repeats\n * expanded (`seo-site-scan.ts` composes one) — and the page's own map as\n * `pageNodes`. A heading a component renders is the page's heading; reading\n * the raw map instead missed every one of them. The page's own map is what\n * says where a fact can be fixed: an element a component renders points at\n * the component's placement on the page and is not `editable` (a page fix\n * cannot rewrite a component's text), and so is a copy a repeat makes, whose\n * text is a row's.\n *\n * A `{{…}}` token is not copy. A token the composition did not resolve —\n * a repeat whose rows were not read, a site variable the head resolves — is\n * left out of the text and the headings, and a heading or a description\n * made of one is neither judged by what it says nor offered to a fix.\n * The walk starts where that serializer starts — the content region — and\n * skips what it skips, through the same chrome predicate: a heading in the\n * site's navigation is not the page's heading.\n */\n\n/** How much of a page's text the facts carry. A listing summarizes; it does not need the page. */\nexport const SEO_PAGE_TEXT_MAX_CHARS = 2_000\n\n/** How much text around an image describes it. */\nconst IMAGE_CONTEXT_MAX_CHARS = 160\n\n/** The deepest a walk goes, and it stops at a cycle — a node map is data. */\nconst MAX_DEPTH = 64\n\n/** The text components whose heading level `headingLevelOf` reads. */\nconst TEXT_COMPONENTS: ReadonlySet<string> = new Set(['muiTypography', 'muiInlineText', 'muiListItemText'])\n\n/** A reusable-component placement, as the page's own map stores it (`reusable-component-keys.ts`). */\nconst REUSABLE_INSTANCE = 'reusableInstance'\n\n/** The prefix a component's grafted elements carry (`reusable-component-keys.ts`): `cmp__{placementId}__{id}`. */\nconst COMPONENT_GRAFT_PREFIX = 'cmp__'\n\n/** The prefix a repeat's copies carry (`expand-repeatables.ts`): `rep__{repeatId}__{index}__{templateId}`. */\nconst REPEAT_COPY_PREFIX = 'rep__'\n\n/** A `{{…}}` token: a value something else resolves, never copy of its own. */\nconst TOKEN_PATTERN = /\\{\\{[^{}]*\\}\\}/g\n\nexport interface SeoHeading {\n /**\n * The element on the page — for one a component renders, the component's\n * placement — or `null` for a heading inside the page's rich text a fix\n * cannot address.\n */\n nodeId: string | null\n level: number\n /** What it says, without the tokens it resolves at render: `''` for a heading made of one. */\n text: string\n /**\n * Whether a content fix can change it: a text component on the page itself\n * with plain text and no token — not one a component or a repeat renders.\n */\n editable: boolean\n /** Rendered by a reusable component placed on the page; `nodeId` is the placement. */\n inComponent?: boolean\n}\n\nexport interface SeoImage {\n /** The element on the page, or the component placement that renders it. */\n nodeId: string\n src: string\n alt: string\n /** Whether a content fix can set its description: an image on the page itself, not a component's or a repeat's. */\n editable: boolean\n /** Rendered by a reusable component placed on the page; `nodeId` is the placement. */\n inComponent?: boolean\n /**\n * The author marked it decorative (AGL-1305), so its empty description is\n * the accessible answer rather than a gap.\n */\n decorative: boolean\n /** The nearest heading or text before it, which is what the image illustrates. */\n context: string\n}\n\nexport interface SeoPageFacts {\n /** The page's Markdown body, capped. */\n text: string\n wordCount: number\n headings: SeoHeading[]\n h1s: SeoHeading[]\n images: SeoImage[]\n imagesMissingAlt: SeoImage[]\n /** The page's own node the content region starts at; a new heading goes first inside it. */\n contentRootId: string | null\n}\n\nconst collapse = (value: string): string => value.replace(/\\s+/g, ' ').trim()\n\nconst hasToken = (value: string): boolean => value.search(TOKEN_PATTERN) >= 0\n\n/** A value as copy: its unresolved tokens left out. */\nconst withoutTokens = (value: string): string => collapse(value.replace(TOKEN_PATTERN, ' '))\n\n/** Author HTML to its text, for a heading stored as rich text. */\nfunction htmlText(html: string): string {\n return collapse(html.replace(/<[^>]*>/g, ' ').replace(/ /g, ' ').replace(/&/g, '&'))\n}\n\n/** A text component's own text, and whether it is plain (a fix can rewrite it). */\nfunction textOf(props: Record<string, unknown>): { text: string; plain: boolean } {\n const html = props['html']\n if (typeof html === 'string' && html.trim()) return { text: htmlText(html), plain: false }\n const children = props['children']\n return typeof children === 'string' ? { text: collapse(children), plain: true } : { text: '', plain: true }\n}\n\nconst childIdsOf = (node: PageMarkdownNode | undefined): string[] =>\n Array.isArray(node?.nodes) ? (node?.nodes as unknown[]).filter((id): id is string => typeof id === 'string') : []\n\n/** Where a fact found on a composed page can be addressed on the page itself. */\ninterface FactOrigin {\n nodeId: string\n editable: boolean\n inComponent: boolean\n}\n\n/**\n * Maps an element of the composed map to the page's own map: itself when the\n * page holds it, its placement when a component renders it (the placement\n * keeps its id as the component's root; what the component holds is grafted\n * under the placement's prefix), and the template a repeat copied it from —\n * with the copy's text a row's, so not editable.\n */\nfunction originResolver(\n pageNodes: PageMarkdownNodes,\n): (id: string) => FactOrigin | null {\n const placementIds = Object.keys(pageNodes).filter((id) => pageNodes[id]?.componentId === REUSABLE_INSTANCE)\n const repeatIds = Object.keys(pageNodes).filter((id) => {\n const key = (pageNodes[id]?.props as Record<string, unknown> | null | undefined)?.['repeatDataset']\n return typeof key === 'string' && key.trim() !== ''\n })\n const resolve = (id: string, depth: number): FactOrigin | null => {\n if (depth > MAX_DEPTH) return null\n const own = pageNodes[id]\n if (own) {\n return own.componentId === REUSABLE_INSTANCE\n ? { nodeId: id, editable: false, inComponent: true }\n : { nodeId: id, editable: true, inComponent: false }\n }\n if (id.startsWith(COMPONENT_GRAFT_PREFIX)) {\n const placementId = placementIds.find((placement) => id.startsWith(`${COMPONENT_GRAFT_PREFIX}${placement}__`))\n return placementId ? { nodeId: placementId, editable: false, inComponent: true } : null\n }\n if (!id.startsWith(REPEAT_COPY_PREFIX)) return null\n for (const repeatId of repeatIds) {\n const prefix = `${REPEAT_COPY_PREFIX}${repeatId}__`\n if (!id.startsWith(prefix)) continue\n const template = /^\\d+__(.+)$/.exec(id.slice(prefix.length))?.[1]\n const origin = template ? resolve(template, depth + 1) : null\n if (origin) return { ...origin, editable: false }\n }\n return null\n }\n return (id) => resolve(id, 0)\n}\n\n/**\n * Read the facts a listing and the SEO check need from one page's node map.\n *\n * `nodes` is the page as it publishes, composed; `pageNodes` the page's own\n * map it was composed from, which decides what a fact points at and whether\n * a fix may change it. Without `pageNodes` the map is read as the page's own.\n */\nexport function seoPageFacts(\n nodes: PageMarkdownNodes | null | undefined,\n options: { rootId?: string; maxChars?: number; pageNodes?: PageMarkdownNodes | null } = {},\n): SeoPageFacts {\n const empty: SeoPageFacts = {\n text: '',\n wordCount: 0,\n headings: [],\n h1s: [],\n images: [],\n imagesMissingAlt: [],\n contentRootId: null,\n }\n if (!nodes) return empty\n const contentRootId = pageContentRootId(nodes, options.rootId)\n if (!contentRootId) return empty\n\n const markdown = buildPageMarkdown({ nodes, rootId: options.rootId })\n .replace(TOKEN_PATTERN, '')\n .replace(/[ \\t]{2,}/g, ' ')\n const text = markdown.trim().slice(0, options.maxChars ?? SEO_PAGE_TEXT_MAX_CHARS)\n const headings: SeoHeading[] = []\n const images: SeoImage[] = []\n /** Images whose description is a token: described at render, by a value this read cannot see. */\n const boundAlt = new Set<SeoImage>()\n const originOf = originResolver(options.pageNodes ?? nodes)\n let lastText = ''\n\n const seen = new Set<string>()\n const visit = (id: string, depth: number, owner: FactOrigin | null): void => {\n if (depth > MAX_DEPTH || seen.has(id)) return\n const node = nodes[id]\n if (!node) return\n seen.add(id)\n if (isPageChromeNode(node)) return\n // Inside a placement everything is the component's; elsewhere the page's own map says.\n const origin: FactOrigin = owner ?? originOf(id) ?? { nodeId: id, editable: false, inComponent: false }\n const tag = origin.inComponent ? { inComponent: true as const } : {}\n const props = (node.props ?? {}) as Record<string, unknown>\n const componentId = String(node.componentId ?? '')\n if (TEXT_COMPONENTS.has(componentId)) {\n const { text: raw, plain } = textOf(props)\n const own = withoutTokens(raw)\n const bound = hasToken(raw)\n const level = headingLevelOf(props)\n if (own || bound) {\n if (level > 0) {\n headings.push({ nodeId: origin.nodeId, level, text: own, editable: plain && !bound && origin.editable, ...tag })\n }\n if (own) lastText = own\n }\n } else if (componentId === 'markdown' && typeof props['content'] === 'string') {\n for (const line of String(props['content']).split('\\n')) {\n const match = /^(#{1,6})\\s+(.+)$/.exec(line.trim())\n if (match) {\n headings.push({\n nodeId: origin.inComponent ? origin.nodeId : null,\n level: match[1].length,\n text: withoutTokens(match[2]),\n editable: false,\n ...tag,\n })\n }\n }\n lastText = withoutTokens(String(props['content'])).slice(0, IMAGE_CONTEXT_MAX_CHARS)\n } else if (componentId === 'custom-html' && typeof (props['html'] ?? props['children']) === 'string') {\n const html = String(props['html'] ?? props['children'])\n for (const match of html.matchAll(/<h([1-6])[^>]*>([\\s\\S]*?)<\\/h\\1>/gi)) {\n headings.push({\n nodeId: origin.inComponent ? origin.nodeId : null,\n level: Number(match[1]),\n text: withoutTokens(htmlText(match[2])),\n editable: false,\n ...tag,\n })\n }\n } else if (componentId === 'image') {\n const src = String(props['src'] ?? '').trim()\n if (src) {\n const rawAlt = String(props['alt'] ?? '')\n const image: SeoImage = {\n nodeId: origin.nodeId,\n src,\n alt: withoutTokens(rawAlt),\n decorative: props['decorative'] === true,\n editable: origin.editable && !hasToken(rawAlt),\n context: lastText.slice(0, IMAGE_CONTEXT_MAX_CHARS),\n ...tag,\n }\n images.push(image)\n if (hasToken(rawAlt)) boundAlt.add(image)\n }\n }\n const inherited = owner ?? (origin.inComponent ? origin : null)\n for (const childId of childIdsOf(node)) visit(childId, depth + 1, inherited)\n }\n visit(contentRootId, 0, null)\n\n return {\n text,\n wordCount: text ? text.split(/\\s+/).filter(Boolean).length : 0,\n headings,\n h1s: headings.filter((heading) => heading.level === 1),\n images,\n imagesMissingAlt: images.filter((image) => !image.alt && !image.decorative && !boundAlt.has(image)),\n // Where a fix adds a heading is the page's own content region, which a\n // composed map can start inside a component.\n contentRootId: options.pageNodes ? pageContentRootId(options.pageNodes, options.rootId) : contentRootId,\n }\n}\n"],"names":["buildPageMarkdown","headingLevelOf","isPageChromeNode","pageContentRootId","SEO_PAGE_TEXT_MAX_CHARS","IMAGE_CONTEXT_MAX_CHARS","MAX_DEPTH","TEXT_COMPONENTS","Set","REUSABLE_INSTANCE","COMPONENT_GRAFT_PREFIX","REPEAT_COPY_PREFIX","TOKEN_PATTERN","collapse","value","replace","trim","hasToken","search","withoutTokens","htmlText","html","textOf","props","text","plain","children","childIdsOf","node","Array","isArray","nodes","filter","id","originResolver","pageNodes","placementIds","Object","keys","componentId","repeatIds","key","resolve","depth","own","nodeId","editable","inComponent","startsWith","placementId","find","placement","repeatId","prefix","template","exec","slice","length","origin","seoPageFacts","options","empty","wordCount","headings","h1s","images","imagesMissingAlt","contentRootId","rootId","markdown","maxChars","boundAlt","originOf","lastText","seen","visit","owner","has","add","tag","String","raw","bound","level","push","line","split","match","matchAll","Number","src","rawAlt","image","alt","decorative","context","inherited","childId","Boolean","heading"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,EAChBC,iBAAiB,QAGZ,qBAAiB;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GAED,gGAAgG,GAChG,OAAO,MAAMC,0BAA0B,KAAK;AAE5C,gDAAgD,GAChD,MAAMC,0BAA0B;AAEhC,2EAA2E,GAC3E,MAAMC,YAAY;AAElB,oEAAoE,GACpE,MAAMC,kBAAuC,IAAIC,IAAI;IAAC;IAAiB;IAAiB;CAAkB;AAE1G,oGAAoG,GACpG,MAAMC,oBAAoB;AAE1B,gHAAgH,GAChH,MAAMC,yBAAyB;AAE/B,4GAA4G,GAC5G,MAAMC,qBAAqB;AAE3B,6EAA6E,GAC7E,MAAMC,gBAAgB;AAmDtB,MAAMC,WAAW,CAACC,QAA0BA,MAAMC,OAAO,CAAC,QAAQ,KAAKC,IAAI;AAE3E,MAAMC,WAAW,CAACH,QAA2BA,MAAMI,MAAM,CAACN,kBAAkB;AAE5E,qDAAqD,GACrD,MAAMO,gBAAgB,CAACL,QAA0BD,SAASC,MAAMC,OAAO,CAACH,eAAe;AAEvF,gEAAgE,GAChE,SAASQ,SAASC,IAAY;IAC5B,OAAOR,SAASQ,KAAKN,OAAO,CAAC,YAAY,KAAKA,OAAO,CAAC,WAAW,KAAKA,OAAO,CAAC,UAAU;AAC1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B,IAAIP,IAAI;YAC3C,IAAI0E,KAAK;oBACenE;gBAAtB,MAAMoE,SAASX,QAAOzD,aAAAA,KAAK,CAAC,MAAM,YAAZA,aAAgB;gBACtC,MAAMqE,QAAkB;oBACtB/C,QAAQa,OAAOb,MAAM;oBACrB6C;oBACAG,KAAK1E,cAAcwE;oBACnBG,YAAYvE,KAAK,CAAC,aAAa,KAAK;oBACpCuB,UAAUY,OAAOZ,QAAQ,IAAI,CAAC7B,SAAS0E;oBACvCI,SAAStB,SAASjB,KAAK,CAAC,GAAGnD;mBACxB0E;gBAELd,OAAOmB,IAAI,CAACQ;gBACZ,IAAI3E,SAAS0E,SAASpB,SAASO,GAAG,CAACc;YACrC;QACF;QACA,MAAMI,YAAYpB,gBAAAA,QAAUlB,OAAOX,WAAW,GAAGW,SAAS;QAC1D,KAAK,MAAMuC,WAAWtE,WAAWC,MAAO+C,MAAMsB,SAAStD,QAAQ,GAAGqD;IACpE;IACArB,MAAMR,eAAe,GAAG;IAExB,OAAO;QACL3C;QACAsC,WAAWtC,OAAOA,KAAK8D,KAAK,CAAC,OAAOtD,MAAM,CAACkE,SAASzC,MAAM,GAAG;QAC7DM;QACAC,KAAKD,SAAS/B,MAAM,CAAC,CAACmE,UAAYA,QAAQhB,KAAK,KAAK;QACpDlB;QACAC,kBAAkBD,OAAOjC,MAAM,CAAC,CAAC4D,QAAU,CAACA,MAAMC,GAAG,IAAI,CAACD,MAAME,UAAU,IAAI,CAACvB,SAASM,GAAG,CAACe;QAC5F,uEAAuE;QACvE,6CAA6C;QAC7CzB,eAAeP,QAAQzB,SAAS,GAAGhC,kBAAkByD,QAAQzB,SAAS,EAAEyB,QAAQQ,MAAM,IAAID;IAC5F;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/seo-page-facts.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 { repeatKey } from './expand-repeatables'\nimport {\n buildPageMarkdown,\n headingLevelOf,\n isPageChromeNode,\n pageContentRootId,\n type PageMarkdownNode,\n type PageMarkdownNodes,\n} from './page-markdown'\n\n/**\n * What a page SAYS, read off its node tree (AGL-2910): the text a search\n * listing summarizes, the headings, and the images — each heading and image\n * by node id, so a finding can name the element it is about and a fix can\n * address the element it changes.\n *\n * Pure, and the platform's: the SEO check (`seo-audit.ts`) judges a page by\n * these facts, and anything that proposes a listing or a content fix reads\n * the same ones rather than walking the tree its own way.\n *\n * The text is the page's Markdown representation, the one an agent is\n * served, so what the listing summarizes is what a reader of the page gets.\n *\n * ## The page as it publishes (AGL-3501)\n *\n * Hand it the COMPOSED node map — reusable components grafted, repeats\n * expanded (`seo-site-scan.ts` composes one) — and the page's own map as\n * `pageNodes`. A heading a component renders is the page's heading; reading\n * the raw map instead missed every one of them. The page's own map is what\n * says where a fact can be fixed: an element a component renders points at\n * the component's placement on the page and is not `editable` (a page fix\n * cannot rewrite a component's text), and so is a copy a repeat makes, whose\n * text is a row's.\n *\n * A `{{…}}` token is not copy. A token the composition did not resolve —\n * a repeat whose rows were not read, a site variable the head resolves — is\n * left out of the text and the headings, and a heading or a description\n * made of one is neither judged by what it says nor offered to a fix.\n * The walk starts where that serializer starts — the content region — and\n * skips what it skips, through the same chrome predicate: a heading in the\n * site's navigation is not the page's heading.\n */\n\n/** How much of a page's text the facts carry. A listing summarizes; it does not need the page. */\nexport const SEO_PAGE_TEXT_MAX_CHARS = 2_000\n\n/** How much text around an image describes it. */\nconst IMAGE_CONTEXT_MAX_CHARS = 160\n\n/** The deepest a walk goes, and it stops at a cycle — a node map is data. */\nconst MAX_DEPTH = 64\n\n/** The text components whose heading level `headingLevelOf` reads. */\nconst TEXT_COMPONENTS: ReadonlySet<string> = new Set(['muiTypography', 'muiInlineText', 'muiListItemText'])\n\n/** A reusable-component placement, as the page's own map stores it (`reusable-component-keys.ts`). */\nconst REUSABLE_INSTANCE = 'reusableInstance'\n\n/** The prefix a component's grafted elements carry (`reusable-component-keys.ts`): `cmp__{placementId}__{id}`. */\nconst COMPONENT_GRAFT_PREFIX = 'cmp__'\n\n/** The prefix a repeat's copies carry (`expand-repeatables.ts`): `rep__{repeatId}__{index}__{templateId}`. */\nconst REPEAT_COPY_PREFIX = 'rep__'\n\n/** A `{{…}}` token: a value something else resolves, never copy of its own. */\nconst TOKEN_PATTERN = /\\{\\{[^{}]*\\}\\}/g\n\nexport interface SeoHeading {\n /**\n * The element on the page — for one a component renders, the component's\n * placement — or `null` for a heading inside the page's rich text a fix\n * cannot address.\n */\n nodeId: string | null\n level: number\n /** What it says, without the tokens it resolves at render: `''` for a heading made of one. */\n text: string\n /**\n * Whether a content fix can change it: a text component on the page itself\n * with plain text and no token — not one a component or a repeat renders.\n */\n editable: boolean\n /** Rendered by a reusable component placed on the page; `nodeId` is the placement. */\n inComponent?: boolean\n}\n\nexport interface SeoImage {\n /** The element on the page, or the component placement that renders it. */\n nodeId: string\n src: string\n alt: string\n /** Whether a content fix can set its description: an image on the page itself, not a component's or a repeat's. */\n editable: boolean\n /** Rendered by a reusable component placed on the page; `nodeId` is the placement. */\n inComponent?: boolean\n /**\n * The author marked it decorative (AGL-1305), so its empty description is\n * the accessible answer rather than a gap.\n */\n decorative: boolean\n /** The nearest heading or text before it, which is what the image illustrates. */\n context: string\n}\n\nexport interface SeoPageFacts {\n /** The page's Markdown body, capped. */\n text: string\n wordCount: number\n headings: SeoHeading[]\n h1s: SeoHeading[]\n images: SeoImage[]\n imagesMissingAlt: SeoImage[]\n /** The page's own node the content region starts at; a new heading goes first inside it. */\n contentRootId: string | null\n}\n\nconst collapse = (value: string): string => value.replace(/\\s+/g, ' ').trim()\n\nconst hasToken = (value: string): boolean => value.search(TOKEN_PATTERN) >= 0\n\n/** A value as copy: its unresolved tokens left out. */\nconst withoutTokens = (value: string): string => collapse(value.replace(TOKEN_PATTERN, ' '))\n\n/** Author HTML to its text, for a heading stored as rich text. */\nfunction htmlText(html: string): string {\n return collapse(html.replace(/<[^>]*>/g, ' ').replace(/ /g, ' ').replace(/&/g, '&'))\n}\n\n/** A text component's own text, and whether it is plain (a fix can rewrite it). */\nfunction textOf(props: Record<string, unknown>): { text: string; plain: boolean } {\n const html = props['html']\n if (typeof html === 'string' && html.trim()) return { text: htmlText(html), plain: false }\n const children = props['children']\n return typeof children === 'string' ? { text: collapse(children), plain: true } : { text: '', plain: true }\n}\n\nconst childIdsOf = (node: PageMarkdownNode | undefined): string[] =>\n Array.isArray(node?.nodes) ? (node?.nodes as unknown[]).filter((id): id is string => typeof id === 'string') : []\n\n/** Where a fact found on a composed page can be addressed on the page itself. */\ninterface FactOrigin {\n nodeId: string\n editable: boolean\n inComponent: boolean\n}\n\n/**\n * Maps an element of the composed map to the page's own map: itself when the\n * page holds it, its placement when a component renders it (the placement\n * keeps its id as the component's root; what the component holds is grafted\n * under the placement's prefix), and the template a repeat copied it from —\n * with the copy's text a row's, so not editable.\n */\nfunction originResolver(\n pageNodes: PageMarkdownNodes,\n): (id: string) => FactOrigin | null {\n const placementIds = Object.keys(pageNodes).filter((id) => pageNodes[id]?.componentId === REUSABLE_INSTANCE)\n const repeatIds = Object.keys(pageNodes).filter((id) => repeatKey(pageNodes[id]) !== '')\n const resolve = (id: string, depth: number): FactOrigin | null => {\n if (depth > MAX_DEPTH) return null\n const own = pageNodes[id]\n if (own) {\n return own.componentId === REUSABLE_INSTANCE\n ? { nodeId: id, editable: false, inComponent: true }\n : { nodeId: id, editable: true, inComponent: false }\n }\n if (id.startsWith(COMPONENT_GRAFT_PREFIX)) {\n const placementId = placementIds.find((placement) => id.startsWith(`${COMPONENT_GRAFT_PREFIX}${placement}__`))\n return placementId ? { nodeId: placementId, editable: false, inComponent: true } : null\n }\n if (!id.startsWith(REPEAT_COPY_PREFIX)) return null\n for (const repeatId of repeatIds) {\n const prefix = `${REPEAT_COPY_PREFIX}${repeatId}__`\n if (!id.startsWith(prefix)) continue\n const template = /^\\d+__(.+)$/.exec(id.slice(prefix.length))?.[1]\n const origin = template ? resolve(template, depth + 1) : null\n if (origin) return { ...origin, editable: false }\n }\n return null\n }\n return (id) => resolve(id, 0)\n}\n\n/**\n * Read the facts a listing and the SEO check need from one page's node map.\n *\n * `nodes` is the page as it publishes, composed; `pageNodes` the page's own\n * map it was composed from, which decides what a fact points at and whether\n * a fix may change it. Without `pageNodes` the map is read as the page's own.\n */\nexport function seoPageFacts(\n nodes: PageMarkdownNodes | null | undefined,\n options: { rootId?: string; maxChars?: number; pageNodes?: PageMarkdownNodes | null } = {},\n): SeoPageFacts {\n const empty: SeoPageFacts = {\n text: '',\n wordCount: 0,\n headings: [],\n h1s: [],\n images: [],\n imagesMissingAlt: [],\n contentRootId: null,\n }\n if (!nodes) return empty\n const contentRootId = pageContentRootId(nodes, options.rootId)\n if (!contentRootId) return empty\n\n const markdown = buildPageMarkdown({ nodes, rootId: options.rootId })\n .replace(TOKEN_PATTERN, '')\n .replace(/[ \\t]{2,}/g, ' ')\n const text = markdown.trim().slice(0, options.maxChars ?? SEO_PAGE_TEXT_MAX_CHARS)\n const headings: SeoHeading[] = []\n const images: SeoImage[] = []\n /** Images whose description is a token: described at render, by a value this read cannot see. */\n const boundAlt = new Set<SeoImage>()\n const originOf = originResolver(options.pageNodes ?? nodes)\n let lastText = ''\n\n const seen = new Set<string>()\n const visit = (id: string, depth: number, owner: FactOrigin | null): void => {\n if (depth > MAX_DEPTH || seen.has(id)) return\n const node = nodes[id]\n if (!node) return\n seen.add(id)\n if (isPageChromeNode(node)) return\n // Inside a placement everything is the component's; elsewhere the page's own map says.\n const origin: FactOrigin = owner ?? originOf(id) ?? { nodeId: id, editable: false, inComponent: false }\n const tag = origin.inComponent ? { inComponent: true as const } : {}\n const props = (node.props ?? {}) as Record<string, unknown>\n const componentId = String(node.componentId ?? '')\n if (TEXT_COMPONENTS.has(componentId)) {\n const { text: raw, plain } = textOf(props)\n const own = withoutTokens(raw)\n const bound = hasToken(raw)\n const level = headingLevelOf(props)\n if (own || bound) {\n if (level > 0) {\n headings.push({ nodeId: origin.nodeId, level, text: own, editable: plain && !bound && origin.editable, ...tag })\n }\n if (own) lastText = own\n }\n } else if (componentId === 'markdown' && typeof props['content'] === 'string') {\n for (const line of String(props['content']).split('\\n')) {\n const match = /^(#{1,6})\\s+(.+)$/.exec(line.trim())\n if (match) {\n headings.push({\n nodeId: origin.inComponent ? origin.nodeId : null,\n level: match[1].length,\n text: withoutTokens(match[2]),\n editable: false,\n ...tag,\n })\n }\n }\n lastText = withoutTokens(String(props['content'])).slice(0, IMAGE_CONTEXT_MAX_CHARS)\n } else if (componentId === 'custom-html' && typeof (props['html'] ?? props['children']) === 'string') {\n const html = String(props['html'] ?? props['children'])\n for (const match of html.matchAll(/<h([1-6])[^>]*>([\\s\\S]*?)<\\/h\\1>/gi)) {\n headings.push({\n nodeId: origin.inComponent ? origin.nodeId : null,\n level: Number(match[1]),\n text: withoutTokens(htmlText(match[2])),\n editable: false,\n ...tag,\n })\n }\n } else if (componentId === 'image') {\n const src = String(props['src'] ?? '').trim()\n if (src) {\n const rawAlt = String(props['alt'] ?? '')\n const image: SeoImage = {\n nodeId: origin.nodeId,\n src,\n alt: withoutTokens(rawAlt),\n decorative: props['decorative'] === true,\n editable: origin.editable && !hasToken(rawAlt),\n context: lastText.slice(0, IMAGE_CONTEXT_MAX_CHARS),\n ...tag,\n }\n images.push(image)\n if (hasToken(rawAlt)) boundAlt.add(image)\n }\n }\n const inherited = owner ?? (origin.inComponent ? origin : null)\n for (const childId of childIdsOf(node)) visit(childId, depth + 1, inherited)\n }\n visit(contentRootId, 0, null)\n\n return {\n text,\n wordCount: text ? text.split(/\\s+/).filter(Boolean).length : 0,\n headings,\n h1s: headings.filter((heading) => heading.level === 1),\n images,\n imagesMissingAlt: images.filter((image) => !image.alt && !image.decorative && !boundAlt.has(image)),\n // Where a fix adds a heading is the page's own content region, which a\n // composed map can start inside a component.\n contentRootId: options.pageNodes ? pageContentRootId(options.pageNodes, options.rootId) : contentRootId,\n }\n}\n"],"names":["repeatKey","buildPageMarkdown","headingLevelOf","isPageChromeNode","pageContentRootId","SEO_PAGE_TEXT_MAX_CHARS","IMAGE_CONTEXT_MAX_CHARS","MAX_DEPTH","TEXT_COMPONENTS","Set","REUSABLE_INSTANCE","COMPONENT_GRAFT_PREFIX","REPEAT_COPY_PREFIX","TOKEN_PATTERN","collapse","value","replace","trim","hasToken","search","withoutTokens","htmlText","html","textOf","props","text","plain","children","childIdsOf","node","Array","isArray","nodes","filter","id","originResolver","pageNodes","placementIds","Object","keys","componentId","repeatIds","resolve","depth","own","nodeId","editable","inComponent","startsWith","placementId","find","placement","repeatId","prefix","template","exec","slice","length","origin","seoPageFacts","options","empty","wordCount","headings","h1s","images","imagesMissingAlt","contentRootId","rootId","markdown","maxChars","boundAlt","originOf","lastText","seen","visit","owner","has","add","tag","String","raw","bound","level","push","line","split","match","matchAll","Number","src","rawAlt","image","alt","decorative","context","inherited","childId","Boolean","heading"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,SAAS,QAAQ,0BAAsB;AAChD,SACEC,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,EAChBC,iBAAiB,QAGZ,qBAAiB;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GAED,gGAAgG,GAChG,OAAO,MAAMC,0BAA0B,KAAK;AAE5C,gDAAgD,GAChD,MAAMC,0BAA0B;AAEhC,2EAA2E,GAC3E,MAAMC,YAAY;AAElB,oEAAoE,GACpE,MAAMC,kBAAuC,IAAIC,IAAI;IAAC;IAAiB;IAAiB;CAAkB;AAE1G,oGAAoG,GACpG,MAAMC,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ME,UAAU,IAAI,CAACvB,SAASM,GAAG,CAACe;QAC5F,uEAAuE;QACvE,6CAA6C;QAC7CzB,eAAeP,QAAQxB,SAAS,GAAGhC,kBAAkBwD,QAAQxB,SAAS,EAAEwB,QAAQQ,MAAM,IAAID;IAC5F;AACF"}
|
|
@@ -162,6 +162,12 @@ export declare const PLUGIN_DISTRIBUTION: PluginDistribution | null;
|
|
|
162
162
|
* once, as written.
|
|
163
163
|
*/
|
|
164
164
|
export declare const PLUGIN_REPEAT_SOURCE_DECLARED: RepeatSourceDeclaration | null;
|
|
165
|
+
/**
|
|
166
|
+
* The plugin that answers a published page's repeats over a plugin
|
|
167
|
+
* connection's record, declared by that plugin (AGL-4212). `null` when none
|
|
168
|
+
* does, and such a repeat then renders no copies.
|
|
169
|
+
*/
|
|
170
|
+
export declare const PLUGIN_CONNECTION_REPEAT_SOURCE_DECLARED: RepeatSourceDeclaration | null;
|
|
165
171
|
/**
|
|
166
172
|
* The site documents a plugin authors in the besigner, declared by that
|
|
167
173
|
* plugin (AGL-3080). Empty when none does, and the console's plugin-document
|
|
@@ -2632,6 +2632,14 @@ export const PUBLISHED_SITE_IMPACT = {
|
|
|
2632
2632
|
"pluginId": "data",
|
|
2633
2633
|
"id": "dataset"
|
|
2634
2634
|
};
|
|
2635
|
+
/**
|
|
2636
|
+
* The plugin that answers a published page's repeats over a plugin
|
|
2637
|
+
* connection's record, declared by that plugin (AGL-4212). `null` when none
|
|
2638
|
+
* does, and such a repeat then renders no copies.
|
|
2639
|
+
*/ export const PLUGIN_CONNECTION_REPEAT_SOURCE_DECLARED = {
|
|
2640
|
+
"pluginId": "marketplace",
|
|
2641
|
+
"id": "pluginConnection"
|
|
2642
|
+
};
|
|
2635
2643
|
/**
|
|
2636
2644
|
* The site documents a plugin authors in the besigner, declared by that
|
|
2637
2645
|
* plugin (AGL-3080). Empty when none does, and the console's plugin-document
|