@aglyn/aglyn 1.20.3 → 1.22.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 +17 -17
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +6 -6
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/native-besigner-back.d.ts +60 -0
- package/src/lib/app-utils/native-besigner-back.js +97 -0
- package/src/lib/app-utils/native-besigner-back.js.map +1 -0
- package/src/lib/app-utils/plain-data.d.ts +20 -0
- package/src/lib/app-utils/plain-data.js +122 -0
- package/src/lib/app-utils/plain-data.js.map +1 -0
- package/src/lib/app-utils/site-interactions.js +1 -1
- package/src/lib/app-utils/site-interactions.js.map +1 -1
- package/src/lib/app-utils/variables.js +13 -6
- package/src/lib/app-utils/variables.js.map +1 -1
- package/src/lib/app-utils/visitor-consent.js +1 -1
- package/src/lib/app-utils/visitor-consent.js.map +1 -1
- package/src/lib/canvas-manager/canvas-manager.d.ts +1 -1
- package/src/lib/canvas-manager/canvas-manager.js +7 -8
- package/src/lib/canvas-manager/canvas-manager.js.map +1 -1
- package/src/lib/emit-manager/emit-manager.js.map +1 -1
- package/src/lib/foundation/constants/components.js.map +1 -1
- package/src/lib/foundation/constants/shared.js.map +1 -1
- package/src/lib/foundation/constants/symbol.js.map +1 -1
- package/src/lib/foundation/definitions/components.types.d.ts +11 -0
- package/src/lib/foundation/definitions/components.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/plugin-manager/enabled-plugins.d.ts +12 -4
- package/src/lib/plugin-manager/enabled-plugins.js +16 -12
- package/src/lib/plugin-manager/enabled-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugin-interactions.generated.d.ts +22 -0
- package/src/lib/plugin-manager/first-party-plugin-interactions.generated.js +242 -0
- package/src/lib/plugin-manager/first-party-plugin-interactions.generated.js.map +1 -0
- package/src/lib/plugin-manager/first-party-plugin-switchboard.generated.d.ts +32 -0
- package/src/lib/plugin-manager/first-party-plugin-switchboard.generated.js +307 -0
- package/src/lib/plugin-manager/first-party-plugin-switchboard.generated.js.map +1 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +3 -33
- package/src/lib/plugin-manager/first-party-plugins.generated.js +6 -311
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/interaction-recipes.js +1 -1
- package/src/lib/plugin-manager/interaction-recipes.js.map +1 -1
- package/src/lib/plugin-manager/plugin-manager.js.map +1 -1
- package/src/lib/types/nodes.d.ts +18 -2
- package/src/lib/types/nodes.js.map +1 -1
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ var _globalScope_RECIPES_KEY;
|
|
17
17
|
import { getRegisteringPluginId } from "../app-utils/registering-plugin.js";
|
|
18
|
-
import { PLUGIN_INTERACTION_RECIPES_DECLARED } from "./first-party-
|
|
18
|
+
import { PLUGIN_INTERACTION_RECIPES_DECLARED } from "./first-party-plugin-interactions.generated.js";
|
|
19
19
|
/** Every recipe a first-party plugin declares, in `plugins.config.json` order. */ export function declaredInteractionRecipes() {
|
|
20
20
|
return PLUGIN_INTERACTION_RECIPES_DECLARED;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/interaction-recipes.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 { InteractionStepBase, SiteInteraction } from '../app-utils/site-interactions'\nimport { getRegisteringPluginId } from '../app-utils/registering-plugin'\nimport { PLUGIN_INTERACTION_RECIPES_DECLARED } from './first-party-plugins.generated'\n\n/**\n * A READY-TO-EDIT INTERACTION ANOTHER PLUGIN OFFERS (AGL-3080).\n *\n * A recipe is a stored interaction — a trigger, its conditions and an ordered\n * step list — built from the step vocabulary and handed to an editor as a\n * draft. Nothing is written until a person saves, and every field is theirs to\n * change first: the recipe decides where the editor starts, not what the site\n * runs. The plugin that knows what a recipe is FOR writes it — the CRM's\n * \"Welcome a new lead\" is the CRM's — and the plugin that edits and stores\n * interactions offers it. Neither imports the other: the author registers its\n * recipes here, and the editor reads them.\n *\n * A stored interaction remembers the recipe it began as by the recipe's id\n * (its `recipe` stamp), so a recipe's id never changes once it has shipped.\n *\n * ## Declared, then registered\n *\n * A recipe BUILDS its interaction, which is code, so it is registered — from\n * the author's `declarations` entry, which both apps and the console's loader\n * run at boot. Its ID is also declared, under `interactionRecipes` in\n * `plugins.config.json`, and compiled into core, because a validator must know\n * a stamp names a real recipe in every process, including one where the\n * author's declarations did not run: {@link isKnownInteractionRecipe} answers\n * from either. A marketplace plugin's recipes are registered and never\n * compiled, and are known once registered.\n */\n\n/** The compiled declaration: which plugin offers which recipe. */\nexport interface InteractionRecipeDeclaration {\n pluginId: string\n /** The recipe's id, as a stored interaction's `recipe` stamp names it. */\n id: string\n}\n\n/** What a recipe is handed before it builds. */\nexport interface InteractionRecipeInput {\n /**\n * The record a person picked, for a recipe that {@link InteractionRecipe.picks}\n * one: its id, its name, and the `facts` its owner shares about it through\n * the kind's list source — what a recipe may shape its draft by, such as\n * whether a form files leads.\n */\n picked?: { id: string; name: string; facts?: Readonly<Record<string, unknown>> }\n}\n\n/**\n * The record a person picks before a recipe can be built, and the words the\n * editor asks for it in. The editor lists the records of `kind` through the\n * list source the plugin that keeps them publishes (`plugin-record-lists`).\n */\nexport interface InteractionRecipePick {\n /** The record kind, as `plugin-record-lists` lists it: `'form'`. */\n kind: string\n /** The picker's label: \"Form\". */\n label: string\n /** The kind's plural, for the sentence that says the list was cut short: \"forms\". */\n plural: string\n /** What the person is asked to pick, one sentence: \"Pick the form whose new contacts get the tag.\" */\n prompt: string\n /** What the picker says on a site that has none. */\n none: string\n}\n\n/** The interaction a recipe builds: a fresh one each call, stamped with the recipe's id. */\nexport type InteractionRecipeDraft = SiteInteraction<InteractionStepBase> & {\n recipe: string\n}\n\nexport interface InteractionRecipe {\n /** Never changes once shipped: stored interactions name it. */\n id: string\n /** How the recipe reads in a menu; also the interaction's starting name. */\n title: string\n /** One sentence under the title. */\n description: string\n /**\n * The record a person picks before the recipe can be built. A recipe that\n * needs nothing opens the editor at once. Built WITHOUT its pick, such a\n * recipe yields an interaction a validator refuses — a condition with no\n * value — rather than one that saves and then silently matches nothing.\n */\n picks?: InteractionRecipePick\n /**\n * A fresh interaction each call, because the draft is edited in place. It\n * carries `recipe: id` — the provenance is the builder's to stamp, so a\n * writer that saves what it was handed cannot forget it.\n */\n build(input?: InteractionRecipeInput): InteractionRecipeDraft\n}\n\n/** Every recipe a first-party plugin declares, in `plugins.config.json` order. */\nexport function declaredInteractionRecipes(): readonly InteractionRecipeDeclaration[] {\n return PLUGIN_INTERACTION_RECIPES_DECLARED\n}\n\ninterface RegisteredRecipe {\n pluginId: string\n recipe: InteractionRecipe\n}\n\n/**\n * One table per process, on `globalThis` (AGL-3412): the server apps register\n * from `instrumentation.ts`, which Next compiles apart from the routes that\n * read, and a module-scoped map would be filled in one copy and read empty in\n * the other.\n */\nconst RECIPES_KEY = Symbol.for('@aglyn/aglyn:interaction-recipes')\n\nconst globalScope = globalThis as typeof globalThis & {\n [RECIPES_KEY]?: Map<string, RegisteredRecipe>\n}\n\nconst recipes: Map<string, RegisteredRecipe> =\n globalScope[RECIPES_KEY] ?? (globalScope[RECIPES_KEY] = new Map())\n\n/**\n * Registers a plugin's recipes, in the order its menu lists them.\n *\n * The owner is the plugin whose register fn is running, or the `pluginId`\n * passed for a boot declaration. A registration with neither is refused; so is\n * a recipe id another plugin declares or already registered, because two\n * recipes under one id would each answer for the other's stamps. The same\n * plugin registering again replaces its own. Nothing is registered unless\n * every recipe is accepted.\n */\nexport function registerInteractionRecipes(\n list: readonly InteractionRecipe[],\n options?: { pluginId?: string },\n): void {\n const pluginId = (getRegisteringPluginId() ?? options?.pluginId ?? '').trim()\n if (!pluginId) {\n throw new Error(\n 'interaction recipes were registered with no owner: pass { pluginId } ' +\n 'when registering outside a plugin register fn',\n )\n }\n for (const recipe of list) {\n const id = recipe.id.trim()\n if (!id) throw new Error(`\"${pluginId}\" registered an interaction recipe with no id`)\n const declared = PLUGIN_INTERACTION_RECIPES_DECLARED.find((row) => row.id === id)\n if (declared && declared.pluginId !== pluginId) {\n throw new Error(\n `interaction recipe \"${id}\" is declared by \"${declared.pluginId}\"; refused \"${pluginId}\"`,\n )\n }\n const held = recipes.get(id)\n if (held && held.pluginId !== pluginId) {\n throw new Error(\n `interaction recipe \"${id}\" is already registered by \"${held.pluginId}\"; refused \"${pluginId}\"`,\n )\n }\n }\n for (const [id, entry] of [...recipes]) if (entry.pluginId === pluginId) recipes.delete(id)\n for (const recipe of list) recipes.set(recipe.id.trim(), { pluginId, recipe })\n}\n\n/** Every registered recipe, each plugin's in its own order. */\nexport function interactionRecipes(): InteractionRecipe[] {\n return [...recipes.values()].map((entry) => entry.recipe)\n}\n\n/** The registered recipe with this id, or `null` for one nobody registered. */\nexport function interactionRecipe(id: unknown): InteractionRecipe | null {\n return typeof id === 'string' ? (recipes.get(id)?.recipe ?? null) : null\n}\n\n/**\n * Whether a stamp names a recipe: one a first-party plugin declares, or one a\n * plugin registered in this process.\n */\nexport function isKnownInteractionRecipe(id: unknown): id is string {\n if (typeof id !== 'string' || !id) return false\n return recipes.has(id) || PLUGIN_INTERACTION_RECIPES_DECLARED.some((row) => row.id === id)\n}\n\n/**\n * The recipe a STORED interaction came from, read off its document (AGL-2639).\n *\n * Three answers, and the third is the one that matters. A known id: the\n * interaction was installed from, or begun as, that recipe — one a plugin\n * declares or registered ({@link isKnownInteractionRecipe}). `null`: it was\n * begun blank, or from a recipe this build no longer knows — the editor wrote\n * the field and said \"no recipe\". `undefined`: the document carries no\n * `recipe` field at all, which is every interaction saved before the stamp\n * existed. Such an interaction may well have started from a recipe — the menu\n * opened the editor prefilled long before anything recorded it — so a reader\n * that needs to know whether a site has a recipe treats `undefined` as\n * UNKNOWN, never as absent, and never writes a `null` over it.\n */\nexport function interactionRecipeStamp(\n interaction: { recipe?: unknown } | null | undefined,\n): string | null | undefined {\n const stamp = interaction?.recipe\n if (stamp === undefined) return undefined\n return isKnownInteractionRecipe(stamp) ? stamp : null\n}\n\n/** Only for specs: forgets every registered recipe. */\nexport function resetInteractionRecipesForTests(): void {\n recipes.clear()\n}\n"],"names":["globalScope","getRegisteringPluginId","PLUGIN_INTERACTION_RECIPES_DECLARED","declaredInteractionRecipes","RECIPES_KEY","Symbol","for","globalThis","recipes","Map","registerInteractionRecipes","list","options","pluginId","trim","Error","recipe","id","declared","find","row","held","get","entry","delete","set","interactionRecipes","values","map","interactionRecipe","isKnownInteractionRecipe","has","some","interactionRecipeStamp","interaction","stamp","undefined","resetInteractionRecipesForTests","clear"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,OAuHCA;AApHF,SAASC,sBAAsB,QAAQ,qCAAiC;AACxE,SAASC,mCAAmC,QAAQ,qCAAiC;AA4FrF,gFAAgF,GAChF,OAAO,SAASC;IACd,OAAOD;AACT;AAOA;;;;;CAKC,GACD,MAAME,cAAcC,OAAOC,GAAG,CAAC;AAE/B,MAAMN,cAAcO;AAIpB,MAAMC,WACJR,2BAAAA,WAAW,CAACI,YAAY,YAAxBJ,2BAA6BA,WAAW,CAACI,YAAY,GAAG,IAAIK;AAE9D;;;;;;;;;CASC,GACD,OAAO,SAASC,2BACdC,IAAkC,EAClCC,OAA+B;QAEbX,MAAAA;IAAlB,MAAMY,WAAW,EAACZ,QAAAA,0BAAAA,oCA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wBAAZT,aAAiBQ,MAAM,mBAAI,OAAQ;AACtE;AAEA;;;CAGC,GACD,OAAO,SAASc,yBAAyBb,EAAW;IAClD,IAAI,OAAOA,OAAO,YAAY,CAACA,IAAI,OAAO;IAC1C,OAAOT,QAAQuB,GAAG,CAACd,OAAOf,oCAAoC8B,IAAI,CAAC,CAACZ,MAAQA,IAAIH,EAAE,KAAKA;AACzF;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASgB,uBACdC,WAAoD;IAEpD,MAAMC,QAAQD,+BAAAA,YAAalB,MAAM;IACjC,IAAImB,UAAUC,WAAW,OAAOA;IAChC,OAAON,yBAAyBK,SAASA,QAAQ;AACnD;AAEA,qDAAqD,GACrD,OAAO,SAASE;IACd7B,QAAQ8B,KAAK;AACf"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/interaction-recipes.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 { InteractionStepBase, SiteInteraction } from '../app-utils/site-interactions'\nimport { getRegisteringPluginId } from '../app-utils/registering-plugin'\nimport { PLUGIN_INTERACTION_RECIPES_DECLARED } from './first-party-plugin-interactions.generated'\n\n/**\n * A READY-TO-EDIT INTERACTION ANOTHER PLUGIN OFFERS (AGL-3080).\n *\n * A recipe is a stored interaction — a trigger, its conditions and an ordered\n * step list — built from the step vocabulary and handed to an editor as a\n * draft. Nothing is written until a person saves, and every field is theirs to\n * change first: the recipe decides where the editor starts, not what the site\n * runs. The plugin that knows what a recipe is FOR writes it — the CRM's\n * \"Welcome a new lead\" is the CRM's — and the plugin that edits and stores\n * interactions offers it. Neither imports the other: the author registers its\n * recipes here, and the editor reads them.\n *\n * A stored interaction remembers the recipe it began as by the recipe's id\n * (its `recipe` stamp), so a recipe's id never changes once it has shipped.\n *\n * ## Declared, then registered\n *\n * A recipe BUILDS its interaction, which is code, so it is registered — from\n * the author's `declarations` entry, which both apps and the console's loader\n * run at boot. Its ID is also declared, under `interactionRecipes` in\n * `plugins.config.json`, and compiled into core, because a validator must know\n * a stamp names a real recipe in every process, including one where the\n * author's declarations did not run: {@link isKnownInteractionRecipe} answers\n * from either. A marketplace plugin's recipes are registered and never\n * compiled, and are known once registered.\n */\n\n/** The compiled declaration: which plugin offers which recipe. */\nexport interface InteractionRecipeDeclaration {\n pluginId: string\n /** The recipe's id, as a stored interaction's `recipe` stamp names it. */\n id: string\n}\n\n/** What a recipe is handed before it builds. */\nexport interface InteractionRecipeInput {\n /**\n * The record a person picked, for a recipe that {@link InteractionRecipe.picks}\n * one: its id, its name, and the `facts` its owner shares about it through\n * the kind's list source — what a recipe may shape its draft by, such as\n * whether a form files leads.\n */\n picked?: { id: string; name: string; facts?: Readonly<Record<string, unknown>> }\n}\n\n/**\n * The record a person picks before a recipe can be built, and the words the\n * editor asks for it in. The editor lists the records of `kind` through the\n * list source the plugin that keeps them publishes (`plugin-record-lists`).\n */\nexport interface InteractionRecipePick {\n /** The record kind, as `plugin-record-lists` lists it: `'form'`. */\n kind: string\n /** The picker's label: \"Form\". */\n label: string\n /** The kind's plural, for the sentence that says the list was cut short: \"forms\". */\n plural: string\n /** What the person is asked to pick, one sentence: \"Pick the form whose new contacts get the tag.\" */\n prompt: string\n /** What the picker says on a site that has none. */\n none: string\n}\n\n/** The interaction a recipe builds: a fresh one each call, stamped with the recipe's id. */\nexport type InteractionRecipeDraft = SiteInteraction<InteractionStepBase> & {\n recipe: string\n}\n\nexport interface InteractionRecipe {\n /** Never changes once shipped: stored interactions name it. */\n id: string\n /** How the recipe reads in a menu; also the interaction's starting name. */\n title: string\n /** One sentence under the title. */\n description: string\n /**\n * The record a person picks before the recipe can be built. A recipe that\n * needs nothing opens the editor at once. Built WITHOUT its pick, such a\n * recipe yields an interaction a validator refuses — a condition with no\n * value — rather than one that saves and then silently matches nothing.\n */\n picks?: InteractionRecipePick\n /**\n * A fresh interaction each call, because the draft is edited in place. It\n * carries `recipe: id` — the provenance is the builder's to stamp, so a\n * writer that saves what it was handed cannot forget it.\n */\n build(input?: InteractionRecipeInput): InteractionRecipeDraft\n}\n\n/** Every recipe a first-party plugin declares, in `plugins.config.json` order. */\nexport function declaredInteractionRecipes(): readonly InteractionRecipeDeclaration[] {\n return PLUGIN_INTERACTION_RECIPES_DECLARED\n}\n\ninterface RegisteredRecipe {\n pluginId: string\n recipe: InteractionRecipe\n}\n\n/**\n * One table per process, on `globalThis` (AGL-3412): the server apps register\n * from `instrumentation.ts`, which Next compiles apart from the routes that\n * read, and a module-scoped map would be filled in one copy and read empty in\n * the other.\n */\nconst RECIPES_KEY = Symbol.for('@aglyn/aglyn:interaction-recipes')\n\nconst globalScope = globalThis as typeof globalThis & {\n [RECIPES_KEY]?: Map<string, RegisteredRecipe>\n}\n\nconst recipes: Map<string, RegisteredRecipe> =\n globalScope[RECIPES_KEY] ?? (globalScope[RECIPES_KEY] = new Map())\n\n/**\n * Registers a plugin's recipes, in the order its menu lists them.\n *\n * The owner is the plugin whose register fn is running, or the `pluginId`\n * passed for a boot declaration. A registration with neither is refused; so is\n * a recipe id another plugin declares or already registered, because two\n * recipes under one id would each answer for the other's stamps. The same\n * plugin registering again replaces its own. Nothing is registered unless\n * every recipe is accepted.\n */\nexport function registerInteractionRecipes(\n list: readonly InteractionRecipe[],\n options?: { pluginId?: string },\n): void {\n const pluginId = (getRegisteringPluginId() ?? options?.pluginId ?? '').trim()\n if (!pluginId) {\n throw new Error(\n 'interaction recipes were registered with no owner: pass { pluginId } ' +\n 'when registering outside a plugin register fn',\n )\n }\n for (const recipe of list) {\n const id = recipe.id.trim()\n if (!id) throw new Error(`\"${pluginId}\" registered an interaction recipe with no id`)\n const declared = PLUGIN_INTERACTION_RECIPES_DECLARED.find((row) => row.id === id)\n if (declared && declared.pluginId !== pluginId) {\n throw new Error(\n `interaction recipe \"${id}\" is declared by \"${declared.pluginId}\"; refused \"${pluginId}\"`,\n )\n }\n const held = recipes.get(id)\n if (held && held.pluginId !== pluginId) {\n throw new Error(\n `interaction recipe \"${id}\" is already registered by \"${held.pluginId}\"; refused \"${pluginId}\"`,\n )\n }\n }\n for (const [id, entry] of [...recipes]) if (entry.pluginId === pluginId) recipes.delete(id)\n for (const recipe of list) recipes.set(recipe.id.trim(), { pluginId, recipe })\n}\n\n/** Every registered recipe, each plugin's in its own order. */\nexport function interactionRecipes(): InteractionRecipe[] {\n return [...recipes.values()].map((entry) => entry.recipe)\n}\n\n/** The registered recipe with this id, or `null` for one nobody registered. */\nexport function interactionRecipe(id: unknown): InteractionRecipe | null {\n return typeof id === 'string' ? (recipes.get(id)?.recipe ?? null) : null\n}\n\n/**\n * Whether a stamp names a recipe: one a first-party plugin declares, or one a\n * plugin registered in this process.\n */\nexport function isKnownInteractionRecipe(id: unknown): id is string {\n if (typeof id !== 'string' || !id) return false\n return recipes.has(id) || PLUGIN_INTERACTION_RECIPES_DECLARED.some((row) => row.id === id)\n}\n\n/**\n * The recipe a STORED interaction came from, read off its document (AGL-2639).\n *\n * Three answers, and the third is the one that matters. A known id: the\n * interaction was installed from, or begun as, that recipe — one a plugin\n * declares or registered ({@link isKnownInteractionRecipe}). `null`: it was\n * begun blank, or from a recipe this build no longer knows — the editor wrote\n * the field and said \"no recipe\". `undefined`: the document carries no\n * `recipe` field at all, which is every interaction saved before the stamp\n * existed. Such an interaction may well have started from a recipe — the menu\n * opened the editor prefilled long before anything recorded it — so a reader\n * that needs to know whether a site has a recipe treats `undefined` as\n * UNKNOWN, never as absent, and never writes a `null` over it.\n */\nexport function interactionRecipeStamp(\n interaction: { recipe?: unknown } | null | undefined,\n): string | null | undefined {\n const stamp = interaction?.recipe\n if (stamp === undefined) return undefined\n return isKnownInteractionRecipe(stamp) ? stamp : null\n}\n\n/** Only for specs: forgets every registered recipe. */\nexport function resetInteractionRecipesForTests(): void {\n recipes.clear()\n}\n"],"names":["globalScope","getRegisteringPluginId","PLUGIN_INTERACTION_RECIPES_DECLARED","declaredInteractionRecipes","RECIPES_KEY","Symbol","for","globalThis","recipes","Map","registerInteractionRecipes","list","options","pluginId","trim","Error","recipe","id","declared","find","row","held","get","entry","delete","set","interactionRecipes","values","map","interactionRecipe","isKnownInteractionRecipe","has","some","interactionRecipeStamp","interaction","stamp","undefined","resetInteractionRecipesForTests","clear"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,OAuHCA;AApHF,SAASC,sBAAsB,QAAQ,qCAAiC;AACxE,SAASC,mCAAmC,QAAQ,iDAA6C;AA4FjG,gFAAgF,GAChF,OAAO,SAASC;IACd,OAAOD;AACT;AAOA;;;;;CAKC,GACD,MAAME,cAAcC,OAAOC,GAAG,CAAC;AAE/B,MAAMN,cAAcO;AAIpB,MAAMC,WACJR,2BAAAA,WAAW,CAACI,YAAY,YAAxBJ,2BAA6BA,WAAW,CAACI,YAAY,GAAG,IAAIK;AAE9D;;;;;;;;;CASC,GACD,OAAO,SAASC,2BACdC,IAAkC,EAClCC,OAA+B;QAEbX,MAAAA;IAAlB,MAAMY,WAAW,EAACZ,QAAAA,0BAAAA,oCAAAA,0BAA4BW,2BAAAA,QAASC,QAAQ,YAA7CZ,OAAiD,IAAIa,IAAI;IAC3E,IAAI,CAACD,UAAU;QACb,MAAM,IAAIE,MACR,0EACE;IAEN;IACA,KAAK,MAAMC,UAAUL,KAAM;QACzB,MAAMM,KAAKD,OAAOC,EAAE,CAACH,IAAI;QACzB,IAAI,CAACG,IAAI,MAAM,IAAIF,MAAM,CAAC,CAAC,EAAEF,SAAS,6CAA6C,CAAC;QACpF,MAAMK,WAAWhB,oCAAoCiB,IAAI,CAAC,CAACC,MAAQA,IAAIH,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jC,IAAImB,UAAUC,WAAW,OAAOA;IAChC,OAAON,yBAAyBK,SAASA,QAAQ;AACnD;AAEA,qDAAqD,GACrD,OAAO,SAASE;IACd7B,QAAQ8B,KAAK;AACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-manager.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 { MdiIconProps } from '../types/nodes'\nimport { makeAutoObservable } from 'mobx'\nimport type { Aglyn } from '../aglyn'\nimport { lifecycleEvent } from '../lifecycle'\nimport { AglynEvent } from '../emit-manager'\n\nexport enum PluginStatus {\n WAITING = 'waiting',\n LOADING = 'loading',\n LOADED = 'loaded',\n UNLOADING = 'unloading',\n}\n\nimport type { PluginId } from '../foundation'\nexport type { PluginId }\nexport type PluginStatusById = Record<PluginId, PluginStatus>\nexport type PluginsById = Record<PluginId, Plugin>\nexport type PluginDependencies = Record<PluginId, true>\nexport type Dependents = Record<PluginId, true>\nexport type PluginDependents = Record<PluginId, Dependents>\n\nexport interface Plugin {\n $id?: PluginId\n displayName?: string\n title?: string\n subtitle?: string\n description?: string\n icon?: MdiIconProps\n dependencies?: PluginDependencies\n load?(...args: any[]): void\n destroy?(...args: any[]): void\n}\n\n// export const plugins: Record<PluginId, Plugin> = {}\n//\n// export function getBundle(pluginId: PluginId) {\n// return plugins[pluginId]\n// }\n//\n// export function hasBundle(pluginId: PluginId) {\n// return pluginId && _hasOwnProperty(pluginId, plugins)\n// }\n//\n// export function registerBundle(schema: Plugin) {\n// const { $id: pluginId } = schema\n// lifecycleEvent(\n// () => {\n// addDependency(schema)\n// plugins[pluginId] = schema\n// // for (const preset of schema.presets || []) {\n// // emitter.emit(AglynEvent.PRESET_REGISTER, { preset })\n// // }\n// },\n// {\n// beforeEvent: AglynEvent.PLUGIN_REGISTERING,\n// beforePayload: [{ schema }],\n// afterEvent: AglynEvent.PLUGIN_REGISTERED,\n// afterPayload: [{ schema }],\n// },\n// )\n// }\n//\n// export function unregisterBundle(pluginId: PluginId) {\n// const bundle = plugins[pluginId]\n// lifecycleEvent(\n// () => {\n// if (!bundle) throw new Error(`No bundle exists with $id ${pluginId}`)\n//\n// // for (const componentId of bundle.componentIds || []) {\n// // emitter.emit(AglynEvent.COMPONENT_UNREGISTER, { componentId, pluginId })\n// // }\n// delete plugins[pluginId]\n// },\n// {\n// beforeEvent: AglynEvent.PLUGIN_UNREGISTERING,\n// beforePayload: [{ pluginId }],\n// afterEvent: AglynEvent.PLUGIN_UNREGISTERED,\n// afterPayload: [{ pluginId }],\n// },\n// )\n// }\n\nexport class PluginManager {\n // ____ __________ _______ _______________________\n // / __ \\/ ____/ __ \\/ ____/ | / / ____/ _/ ____/ ___/\n // / / / / __/ / /_/ / __/ / |/ / / / // __/ \\__ \\\n // / /_/ / /___/ ____/ /___/ /| / /____/ // /___ ___/ /\n // /_____/_____/_/ /_____/_/ |_/\\____/___/_____//____/\n //\n\n public dependencies: PluginsById = {}\n public dependencyStatusById: PluginStatusById = {}\n public dependencyDependentsById: PluginDependents = {}\n\n constructor(protected aglyn?: Aglyn) {\n makeAutoObservable(this)\n }\n\n public getDependency(dependencyId: PluginId): Plugin | undefined {\n return this.dependencies[dependencyId]\n }\n\n public getDependencyDependents(\n dependencyId: PluginId,\n ): Dependents | undefined {\n return this.dependencyDependentsById[dependencyId]\n }\n\n public getDependencyStatus(dependencyId: PluginId): PluginStatus | undefined {\n return this.dependencyStatusById[dependencyId]\n }\n\n public hasDependency(dependencyId: PluginId): boolean {\n return Boolean(dependencyId && this.getDependency(dependencyId))\n }\n\n public isDependencyWaiting(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.WAITING\n }\n\n public isDependencyLoading(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.LOADING\n }\n\n public isDependencyLoaded(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.LOADED\n }\n\n public isDependencyUnloading(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.UNLOADING\n }\n\n public areAllDependenciesLoaded(dependentId: PluginId): boolean {\n for (const dependencyId of Object.keys(\n this.getDependency(dependentId)?.dependencies || {},\n )) {\n if (!this.isDependencyLoaded(dependencyId)) {\n return false\n }\n }\n return true\n }\n\n public addDependency(dependency: Plugin) {\n lifecycleEvent(\n () => {\n this.handleAddingDependencyAndDependents(dependency)\n },\n {\n beforeEvent: AglynEvent.PLUGIN_REGISTERING,\n beforePayload: [{ schema: dependency }],\n afterEvent: AglynEvent.PLUGIN_REGISTERED,\n afterPayload: [{ schema: dependency }],\n },\n )\n return\n }\n\n public addDependencies(dependencies?: Array<Plugin>) {\n const _dependencies = Array.isArray(dependencies) ? dependencies : []\n for (const dependency of _dependencies) {\n this.addDependency(dependency)\n }\n }\n\n public destroyDependencies() {\n const dependencyIds = Object.keys(this.dependencies)\n for (const $id of dependencyIds) {\n this.removeDependency($id)\n }\n }\n\n public removeDependency($id: PluginId) {\n lifecycleEvent(\n () => {\n this.handleRemovingDependencyAndDependents($id)\n },\n {\n beforeEvent: AglynEvent.PLUGIN_UNREGISTERING,\n beforePayload: [{ $id }],\n afterEvent: AglynEvent.PLUGIN_UNREGISTERED,\n afterPayload: [{ $id }],\n },\n )\n return\n }\n\n public loadDependency($id: PluginId) {\n return this.handleLoadingDependencyAndDependents($id)\n }\n\n public unloadDependency($id: PluginId) {\n return this.handleUnloadingDependencyAndDependents($id)\n }\n\n public getDependencyCopy(\n dependencyId: PluginId,\n ): Readonly<Plugin> | undefined {\n const dependency = this.getDependency(dependencyId)\n return dependency ? { ...dependency } : undefined\n }\n\n /**\n * Every registered dependency still parked in WAITING, paired with the\n * dependencies it is waiting on that have not loaded (AGL-759).\n *\n * A bundle lands here when a dependency it declared never reached LOADED.\n * With the reverse-dependency edge fixed, a bundle that registers before\n * its dependency is recovered as soon as the dependency finishes — so the\n * only thing left in this list once a batch has settled is a bundle whose\n * dependency was never activated at all (a manifest/enablement gap). That\n * used to present as an empty besigner drawer with no error: the bundle's\n * components simply never registered. Callers report this at a settle\n * point (the plugin loader, after an `ensure`) so the gap says so instead.\n */\n public getStuckDependencies(): Array<{\n id: PluginId\n waitingOn: PluginId[]\n }> {\n const stuck: Array<{ id: PluginId; waitingOn: PluginId[] }> = []\n for (const id of Object.keys(this.dependencyStatusById)) {\n if (!this.isDependencyWaiting(id)) continue\n const waitingOn = Object.keys(\n this.getDependency(id)?.dependencies || {},\n ).filter((dependencyId) => !this.isDependencyLoaded(dependencyId))\n stuck.push({ id, waitingOn })\n }\n return stuck\n }\n\n // ____ __________ _____ ____ _ ________\n // / __ \\/ ____/ __ \\/ ___/ / __ \\ | / /_ __/\n // / / / / __/ / /_/ /\\__ \\ ______ / /_/ / | / / / /\n // / /_/ / /___/ ____/___/ / /_____/ / ____/| |/ / / /\n // /_____/_____/_/ /____/ /_/ |___/ /_/\n // 👇\n\n private handleSettingDependencyProperties(\n dependencyId: PluginId,\n dependency: Plugin,\n ) {\n this.dependencyStatusById[dependencyId] = PluginStatus.WAITING\n this.dependencyDependentsById[dependencyId] ||= {}\n this.dependencies[dependencyId] = dependency\n return\n }\n\n private handleSettingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependency(dependencyId)?.dependencies || {},\n )) {\n // Read the bucket back instead of using the value of `||= {}` (AGL-759).\n // This class is `makeAutoObservable`, so assigning a plain `{}` stores an\n // observable COPY of it — while `x ||= {}` evaluates to the plain object\n // that was assigned, not the copy that was stored. Mutating that captured\n // object wrote into something already detached from the manager.\n //\n // Only the FIRST dependent of any given dependency was lost, because\n // every later one found the key present and short-circuited onto the real\n // observable. In manifest order that made `bookings` — the first bundle\n // depending on mui — permanently WAITING on every besigner, with no\n // error: its components simply never registered and the drawer was short\n // a category. `plugins.dependencyDependentsById` reads empty for that\n // first edge, which is the fingerprint.\n if (!this.dependencyDependentsById[dependentId]) {\n this.dependencyDependentsById[dependentId] = {}\n }\n this.dependencyDependentsById[dependentId][dependencyId] = true\n }\n return\n }\n\n private handleRemovingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependency(dependencyId)?.dependencies || {},\n )) {\n delete this.dependencyDependentsById[dependentId]?.[dependencyId]\n }\n return\n }\n\n private handleRemovingDependencyProperties(dependencyId: PluginId) {\n delete this.dependencyDependentsById[dependencyId]\n delete this.dependencyStatusById[dependencyId]\n delete this.dependencies[dependencyId]\n return\n }\n\n private handleLoadingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependencyDependents(dependencyId) || {},\n )) {\n if (!this.isDependencyLoaded(dependentId)) {\n this.handleLoadingDependencyAndDependents(dependentId)\n }\n }\n return\n }\n\n private handleLoadingDependency(dependencyId: PluginId) {\n if (this.isDependencyWaiting(dependencyId)) {\n this.dependencyStatusById[dependencyId] = PluginStatus.LOADING\n this.getDependency(dependencyId)?.load?.()\n this.dependencyStatusById[dependencyId] = PluginStatus.LOADED\n }\n return\n }\n\n private handleUnloadingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependencyDependents(dependencyId) || {},\n )) {\n this.handleUnloadingDependencyAndDependents(dependentId)\n }\n return\n }\n\n private handleUnloadingDependency(dependencyId: PluginId) {\n if (this.isDependencyLoaded(dependencyId)) {\n this.dependencyStatusById[dependencyId] = PluginStatus.UNLOADING\n this.getDependency(dependencyId)?.destroy?.()\n this.dependencyStatusById[dependencyId] = PluginStatus.WAITING\n }\n return\n }\n\n private handleAddingDependencyAndDependents(dependency: Plugin) {\n if (!dependency) throw new Error('Invalid dependency')\n const dependencyId: PluginId = dependency.$id\n if (!dependencyId) throw new Error('Invalid dependencyId')\n /**\n * Set properties on local dependencies object\n */\n this.handleSettingDependencyProperties(dependencyId, dependency)\n /**\n * Set dependencies' dependent relationships\n */\n this.handleSettingDependencyDependents(dependencyId)\n /**\n * Load applicable dependencies\n */\n this.handleLoadingDependencyAndDependents(dependencyId)\n return\n }\n\n private handleLoadingDependencyAndDependents(dependencyId: PluginId) {\n if (!this.hasDependency(dependencyId)) return\n /**\n * Verify all dependencies are loaded\n */\n if (!this.areAllDependenciesLoaded(dependencyId)) return\n /**\n * Load the self dependency\n */\n this.handleLoadingDependency(dependencyId)\n /**\n * Load waiting dependents\n */\n this.handleLoadingDependencyDependents(dependencyId)\n return\n }\n\n private handleUnloadingDependencyAndDependents(dependencyId: PluginId) {\n if (!this.hasDependency(dependencyId)) return\n /**\n * Unload all dependents of the dependency\n */\n this.handleUnloadingDependencyDependents(dependencyId)\n /**\n * Unload self dependency\n */\n this.handleUnloadingDependency(dependencyId)\n return\n }\n\n private handleRemovingDependencyAndDependents(dependencyId: PluginId) {\n if (!this.hasDependency(dependencyId)) return\n /**\n * Unload dependency and its dependents\n */\n this.handleUnloadingDependencyAndDependents(dependencyId)\n\n /**\n * Remove dependencies dependent relationships\n */\n this.handleRemovingDependencyDependents(dependencyId)\n\n /**\n * Remove self from local dependencies property\n */\n this.handleRemovingDependencyProperties(dependencyId)\n return\n }\n}\n\nexport default PluginManager\n"],"names":["makeAutoObservable","lifecycleEvent","AglynEvent","PluginStatus","PluginManager","getDependency","dependencyId","dependencies","getDependencyDependents","dependencyDependentsById","getDependencyStatus","dependencyStatusById","hasDependency","Boolean","isDependencyWaiting","isDependencyLoading","isDependencyLoaded","isDependencyUnloading","areAllDependenciesLoaded","dependentId","Object","keys","addDependency","dependency","handleAddingDependencyAndDependents","beforeEvent","PLUGIN_REGISTERING","beforePayload","schema","afterEvent","PLUGIN_REGISTERED","afterPayload","addDependencies","_dependencies","Array","isArray","destroyDependencies","dependencyIds","$id","removeDependency","handleRemovingDependencyAndDependents","PLUGIN_UNREGISTERING","PLUGIN_UNREGISTERED","loadDependency","handleLoadingDependencyAndDependents","unloadDependency","handleUnloadingDependencyAndDependents","getDependencyCopy","undefined","getStuckDependencies","stuck","id","waitingOn","filter","push","handleSettingDependencyProperties","handleSettingDependencyDependents","handleRemovingDependencyDependents","handleRemovingDependencyProperties","handleLoadingDependencyDependents","handleLoadingDependency","load","handleUnloadingDependencyDependents","handleUnloadingDependency","destroy","Error","aglyn"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,kBAAkB,QAAQ,OAAM;AAEzC,SAASC,cAAc,QAAQ,kBAAc;AAC7C,SAASC,UAAU,QAAQ,2BAAiB;AAE5C,OAAO,IAAA,AAAKC,sCAAAA;;;;;WAAAA;MAKX;AAsBD,sDAAsD;AACtD,EAAE;AACF,kDAAkD;AAClD,6BAA6B;AAC7B,IAAI;AACJ,EAAE;AACF,kDAAkD;AAClD,0DAA0D;AAC1D,IAAI;AACJ,EAAE;AACF,mDAAmD;AACnD,qCAAqC;AACrC,oBAAoB;AACpB,cAAc;AACd,8BAA8B;AAC9B,mCAAmC;AACnC,wDAAwD;AACxD,kEAAkE;AAClE,aAAa;AACb,SAAS;AACT,QAAQ;AACR,oDAAoD;AACpD,qCAAqC;AACrC,kDAAkD;AAClD,oCAAoC;AACpC,SAAS;AACT,MAAM;AACN,IAAI;AACJ,EAAE;AACF,yDAAyD;AACzD,qCAAqC;AACrC,oBAAoB;AACpB,cAAc;AACd,8EAA8E;AAC9E,EAAE;AACF,kEAAkE;AAClE,sFAAsF;AACtF,aAAa;AACb,iCAAiC;AACjC,SAAS;AACT,QAAQ;AACR,sDAAsD;AACtD,uCAAuC;AACvC,oDAAoD;AACpD,sCAAsC;AACtC,SAAS;AACT,MAAM;AACN,IAAI;AAEJ,OAAO,MAAMC;IAgBJC,cA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V,iCAAiC,CAACjD,cAAciB;QACrD;;KAEC,GACD,IAAI,CAACiC,iCAAiC,CAAClD;QACvC;;KAEC,GACD,IAAI,CAACsC,oCAAoC,CAACtC;QAC1C;IACF;IAEQsC,qCAAqCtC,YAAsB,EAAE;QACnE,IAAI,CAAC,IAAI,CAACM,aAAa,CAACN,eAAe;QACvC;;KAEC,GACD,IAAI,CAAC,IAAI,CAACY,wBAAwB,CAACZ,eAAe;QAClD;;KAEC,GACD,IAAI,CAACsD,uBAAuB,CAACtD;QAC7B;;KAEC,GACD,IAAI,CAACqD,iCAAiC,CAACrD;QACvC;IACF;IAEQwC,uCAAuCxC,YAAsB,EAAE;QACrE,IAAI,CAAC,IAAI,CAACM,aAAa,CAACN,eAAe;QACvC;;KAEC,GACD,IAAI,CAACwD,mCAAmC,CAACxD;QACzC;;KAEC,GACD,IAAI,CAACyD,yBAAyB,CAACzD;QAC/B;IACF;IAEQkC,sCAAsClC,YAAsB,EAAE;QACpE,IAAI,CAAC,IAAI,CAACM,aAAa,CAACN,eAAe;QACvC;;KAEC,GACD,IAAI,CAACwC,sCAAsC,CAACxC;QAE5C;;KAEC,GACD,IAAI,CAACmD,kCAAkC,CAACnD;QAExC;;KAEC,GACD,IAAI,CAACoD,kCAAkC,CAACpD;QACxC;IACF;IA1SA,YAAY,AAAU4D,KAAa,CAAE;aAAfA,QAAAA;QAXtB,0DAA0D;QAC1D,0DAA0D;QAC1D,yDAAyD;QACzD,yDAAyD;QACzD,wDAAwD;QACxD,EAAE;aAEK3D,eAA4B,CAAC;aAC7BI,uBAAyC,CAAC;aAC1CF,2BAA6C,CAAC;QAGnDT,mBAAmB,IAAI;IACzB;AAySF;AAEA,eAAeI,cAAa"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-manager.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 { MdiIconProps } from '../types/nodes'\nimport { makeAutoObservable } from 'mobx'\nimport type { Aglyn } from '../aglyn'\nimport { lifecycleEvent } from '../lifecycle'\nimport { AglynEvent } from '../emit-manager'\n\nexport enum PluginStatus {\n WAITING = 'waiting',\n LOADING = 'loading',\n LOADED = 'loaded',\n UNLOADING = 'unloading',\n}\n\nimport type { PluginId } from '../foundation'\nexport type { PluginId }\nexport type PluginStatusById = Record<PluginId, PluginStatus>\nexport type PluginsById = Record<PluginId, Plugin>\nexport type PluginDependencies = Record<PluginId, true>\nexport type Dependents = Record<PluginId, true>\nexport type PluginDependents = Record<PluginId, Dependents>\n\nexport interface Plugin {\n $id?: PluginId\n displayName?: string\n title?: string\n subtitle?: string\n description?: string\n icon?: MdiIconProps\n dependencies?: PluginDependencies\n load?(...args: any[]): void\n destroy?(...args: any[]): void\n}\n\n// export const plugins: Record<PluginId, Plugin> = {}\n//\n// export function getBundle(pluginId: PluginId) {\n// return plugins[pluginId]\n// }\n//\n// export function hasBundle(pluginId: PluginId) {\n// return pluginId && _hasOwnProperty(pluginId, plugins)\n// }\n//\n// export function registerBundle(schema: Plugin) {\n// const { $id: pluginId } = schema\n// lifecycleEvent(\n// () => {\n// addDependency(schema)\n// plugins[pluginId] = schema\n// // for (const preset of schema.presets || []) {\n// // emitter.emit(AglynEvent.PRESET_REGISTER, { preset })\n// // }\n// },\n// {\n// beforeEvent: AglynEvent.PLUGIN_REGISTERING,\n// beforePayload: [{ schema }],\n// afterEvent: AglynEvent.PLUGIN_REGISTERED,\n// afterPayload: [{ schema }],\n// },\n// )\n// }\n//\n// export function unregisterBundle(pluginId: PluginId) {\n// const bundle = plugins[pluginId]\n// lifecycleEvent(\n// () => {\n// if (!bundle) throw new Error(`No bundle exists with $id ${pluginId}`)\n//\n// // for (const componentId of bundle.componentIds || []) {\n// // emitter.emit(AglynEvent.COMPONENT_UNREGISTER, { componentId, pluginId })\n// // }\n// delete plugins[pluginId]\n// },\n// {\n// beforeEvent: AglynEvent.PLUGIN_UNREGISTERING,\n// beforePayload: [{ pluginId }],\n// afterEvent: AglynEvent.PLUGIN_UNREGISTERED,\n// afterPayload: [{ pluginId }],\n// },\n// )\n// }\n\nexport class PluginManager {\n // ____ __________ _______ _______________________\n // / __ \\/ ____/ __ \\/ ____/ | / / ____/ _/ ____/ ___/\n // / / / / __/ / /_/ / __/ / |/ / / / // __/ \\__ \\\n // / /_/ / /___/ ____/ /___/ /| / /____/ // /___ ___/ /\n // /_____/_____/_/ /_____/_/ |_/\\____/___/_____//____/\n //\n\n public dependencies: PluginsById = {}\n public dependencyStatusById: PluginStatusById = {}\n public dependencyDependentsById: PluginDependents = {}\n\n constructor(protected aglyn?: Aglyn) {\n makeAutoObservable(this)\n }\n\n public getDependency(dependencyId: PluginId): Plugin | undefined {\n return this.dependencies[dependencyId]\n }\n\n public getDependencyDependents(\n dependencyId: PluginId,\n ): Dependents | undefined {\n return this.dependencyDependentsById[dependencyId]\n }\n\n public getDependencyStatus(dependencyId: PluginId): PluginStatus | undefined {\n return this.dependencyStatusById[dependencyId]\n }\n\n public hasDependency(dependencyId: PluginId): boolean {\n return Boolean(dependencyId && this.getDependency(dependencyId))\n }\n\n public isDependencyWaiting(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.WAITING\n }\n\n public isDependencyLoading(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.LOADING\n }\n\n public isDependencyLoaded(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.LOADED\n }\n\n public isDependencyUnloading(dependencyId: PluginId): boolean {\n return this.getDependencyStatus(dependencyId) === PluginStatus.UNLOADING\n }\n\n public areAllDependenciesLoaded(dependentId: PluginId): boolean {\n for (const dependencyId of Object.keys(\n this.getDependency(dependentId)?.dependencies || {},\n )) {\n if (!this.isDependencyLoaded(dependencyId)) {\n return false\n }\n }\n return true\n }\n\n public addDependency(dependency: Plugin) {\n lifecycleEvent(\n () => {\n this.handleAddingDependencyAndDependents(dependency)\n },\n {\n beforeEvent: AglynEvent.PLUGIN_REGISTERING,\n beforePayload: [{ schema: dependency }],\n afterEvent: AglynEvent.PLUGIN_REGISTERED,\n afterPayload: [{ schema: dependency }],\n },\n )\n return\n }\n\n public addDependencies(dependencies?: Array<Plugin>) {\n const _dependencies = Array.isArray(dependencies) ? dependencies : []\n for (const dependency of _dependencies) {\n this.addDependency(dependency)\n }\n }\n\n public destroyDependencies() {\n const dependencyIds = Object.keys(this.dependencies)\n for (const $id of dependencyIds) {\n this.removeDependency($id)\n }\n }\n\n public removeDependency($id: PluginId) {\n lifecycleEvent(\n () => {\n this.handleRemovingDependencyAndDependents($id)\n },\n {\n beforeEvent: AglynEvent.PLUGIN_UNREGISTERING,\n beforePayload: [{ $id }],\n afterEvent: AglynEvent.PLUGIN_UNREGISTERED,\n afterPayload: [{ $id }],\n },\n )\n return\n }\n\n public loadDependency($id: PluginId) {\n return this.handleLoadingDependencyAndDependents($id)\n }\n\n public unloadDependency($id: PluginId) {\n return this.handleUnloadingDependencyAndDependents($id)\n }\n\n public getDependencyCopy(\n dependencyId: PluginId,\n ): Readonly<Plugin> | undefined {\n const dependency = this.getDependency(dependencyId)\n return dependency ? { ...dependency } : undefined\n }\n\n /**\n * Every registered dependency still parked in WAITING, paired with the\n * dependencies it is waiting on that have not loaded (AGL-759).\n *\n * A bundle lands here when a dependency it declared never reached LOADED.\n * With the reverse-dependency edge fixed, a bundle that registers before\n * its dependency is recovered as soon as the dependency finishes — so the\n * only thing left in this list once a batch has settled is a bundle whose\n * dependency was never activated at all (a manifest/enablement gap). That\n * used to present as an empty besigner drawer with no error: the bundle's\n * components simply never registered. Callers report this at a settle\n * point (the plugin loader, after an `ensure`) so the gap says so instead.\n */\n public getStuckDependencies(): Array<{\n id: PluginId\n waitingOn: PluginId[]\n }> {\n const stuck: Array<{ id: PluginId; waitingOn: PluginId[] }> = []\n for (const id of Object.keys(this.dependencyStatusById)) {\n if (!this.isDependencyWaiting(id)) continue\n const waitingOn = Object.keys(\n this.getDependency(id)?.dependencies || {},\n ).filter((dependencyId) => !this.isDependencyLoaded(dependencyId))\n stuck.push({ id, waitingOn })\n }\n return stuck\n }\n\n // ____ __________ _____ ____ _ ________\n // / __ \\/ ____/ __ \\/ ___/ / __ \\ | / /_ __/\n // / / / / __/ / /_/ /\\__ \\ ______ / /_/ / | / / / /\n // / /_/ / /___/ ____/___/ / /_____/ / ____/| |/ / / /\n // /_____/_____/_/ /____/ /_/ |___/ /_/\n // 👇\n\n private handleSettingDependencyProperties(\n dependencyId: PluginId,\n dependency: Plugin,\n ) {\n this.dependencyStatusById[dependencyId] = PluginStatus.WAITING\n this.dependencyDependentsById[dependencyId] ||= {}\n this.dependencies[dependencyId] = dependency\n return\n }\n\n private handleSettingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependency(dependencyId)?.dependencies || {},\n )) {\n // Read the bucket back instead of using the value of `||= {}` (AGL-759).\n // This class is `makeAutoObservable`, so assigning a plain `{}` stores an\n // observable COPY of it — while `x ||= {}` evaluates to the plain object\n // that was assigned, not the copy that was stored. Mutating that captured\n // object wrote into something already detached from the manager.\n //\n // Only the FIRST dependent of any given dependency was lost, because\n // every later one found the key present and short-circuited onto the real\n // observable. In manifest order that made `bookings` — the first bundle\n // depending on mui — permanently WAITING on every besigner, with no\n // error: its components simply never registered and the drawer was short\n // a category. `plugins.dependencyDependentsById` reads empty for that\n // first edge, which is the fingerprint.\n if (!this.dependencyDependentsById[dependentId]) {\n this.dependencyDependentsById[dependentId] = {}\n }\n this.dependencyDependentsById[dependentId][dependencyId] = true\n }\n return\n }\n\n private handleRemovingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependency(dependencyId)?.dependencies || {},\n )) {\n delete this.dependencyDependentsById[dependentId]?.[dependencyId]\n }\n return\n }\n\n private handleRemovingDependencyProperties(dependencyId: PluginId) {\n delete this.dependencyDependentsById[dependencyId]\n delete this.dependencyStatusById[dependencyId]\n delete this.dependencies[dependencyId]\n return\n }\n\n private handleLoadingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependencyDependents(dependencyId) || {},\n )) {\n if (!this.isDependencyLoaded(dependentId)) {\n this.handleLoadingDependencyAndDependents(dependentId)\n }\n }\n return\n }\n\n private handleLoadingDependency(dependencyId: PluginId) {\n if (this.isDependencyWaiting(dependencyId)) {\n this.dependencyStatusById[dependencyId] = PluginStatus.LOADING\n this.getDependency(dependencyId)?.load?.()\n this.dependencyStatusById[dependencyId] = PluginStatus.LOADED\n }\n return\n }\n\n private handleUnloadingDependencyDependents(dependencyId: PluginId) {\n for (const dependentId of Object.keys(\n this.getDependencyDependents(dependencyId) || {},\n )) {\n this.handleUnloadingDependencyAndDependents(dependentId)\n }\n return\n }\n\n private handleUnloadingDependency(dependencyId: PluginId) {\n if (this.isDependencyLoaded(dependencyId)) {\n this.dependencyStatusById[dependencyId] = PluginStatus.UNLOADING\n this.getDependency(dependencyId)?.destroy?.()\n this.dependencyStatusById[dependencyId] = PluginStatus.WAITING\n }\n return\n }\n\n private handleAddingDependencyAndDependents(dependency: Plugin) {\n if (!dependency) throw new Error('Invalid dependency')\n const dependencyId: PluginId = dependency.$id\n if (!dependencyId) throw new Error('Invalid dependencyId')\n /**\n * Set properties on local dependencies object\n */\n this.handleSettingDependencyProperties(dependencyId, dependency)\n /**\n * Set dependencies' dependent relationships\n */\n this.handleSettingDependencyDependents(dependencyId)\n /**\n * Load applicable dependencies\n */\n this.handleLoadingDependencyAndDependents(dependencyId)\n return\n }\n\n private handleLoadingDependencyAndDependents(dependencyId: PluginId) {\n if (!this.hasDependency(dependencyId)) return\n /**\n * Verify all dependencies are loaded\n */\n if (!this.areAllDependenciesLoaded(dependencyId)) return\n /**\n * Load the self dependency\n */\n this.handleLoadingDependency(dependencyId)\n /**\n * Load waiting dependents\n */\n this.handleLoadingDependencyDependents(dependencyId)\n return\n }\n\n private handleUnloadingDependencyAndDependents(dependencyId: PluginId) {\n if (!this.hasDependency(dependencyId)) return\n /**\n * Unload all dependents of the dependency\n */\n this.handleUnloadingDependencyDependents(dependencyId)\n /**\n * Unload self dependency\n */\n this.handleUnloadingDependency(dependencyId)\n return\n }\n\n private handleRemovingDependencyAndDependents(dependencyId: PluginId) {\n if (!this.hasDependency(dependencyId)) return\n /**\n * Unload dependency and its dependents\n */\n this.handleUnloadingDependencyAndDependents(dependencyId)\n\n /**\n * Remove dependencies dependent relationships\n */\n this.handleRemovingDependencyDependents(dependencyId)\n\n /**\n * Remove self from local dependencies property\n */\n this.handleRemovingDependencyProperties(dependencyId)\n return\n }\n}\n\nexport default PluginManager\n"],"names":["makeAutoObservable","lifecycleEvent","AglynEvent","PluginStatus","PluginManager","getDependency","dependencyId","dependencies","getDependencyDependents","dependencyDependentsById","getDependencyStatus","dependencyStatusById","hasDependency","Boolean","isDependencyWaiting","isDependencyLoading","isDependencyLoaded","isDependencyUnloading","areAllDependenciesLoaded","dependentId","Object","keys","addDependency","dependency","handleAddingDependencyAndDependents","beforeEvent","PLUGIN_REGISTERING","beforePayload","schema","afterEvent","PLUGIN_REGISTERED","afterPayload","addDependencies","_dependencies","Array","isArray","destroyDependencies","dependencyIds","$id","removeDependency","handleRemovingDependencyAndDependents","PLUGIN_UNREGISTERING","PLUGIN_UNREGISTERED","loadDependency","handleLoadingDependencyAndDependents","unloadDependency","handleUnloadingDependencyAndDependents","getDependencyCopy","undefined","getStuckDependencies","stuck","id","waitingOn","filter","push","handleSettingDependencyProperties","handleSettingDependencyDependents","handleRemovingDependencyDependents","handleRemovingDependencyProperties","handleLoadingDependencyDependents","handleLoadingDependency","load","handleUnloadingDependencyDependents","handleUnloadingDependency","destroy","Error","aglyn"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,kBAAkB,QAAQ,OAAM;AAEzC,SAASC,cAAc,QAAQ,kBAAc;AAC7C,SAASC,UAAU,QAAQ,2BAAiB;AAE5C,OAAO,IAAA,AAAKC;;;;;;MAKX;AAsBD,sDAAsD;AACtD,EAAE;AACF,kDAAkD;AAClD,6BAA6B;AAC7B,IAAI;AACJ,EAAE;AACF,kDAAkD;AAClD,0DAA0D;AAC1D,IAAI;AACJ,EAAE;AACF,mDAAmD;AACnD,qCAAqC;AACrC,oBAAoB;AACpB,cAAc;AACd,8BAA8B;AAC9B,mCAAmC;AACnC,wDAAwD;AACxD,kEAAkE;AAClE,aAAa;AACb,SAAS;AACT,QAAQ;AACR,oDAAoD;AACpD,qCAAqC;AACrC,kDAAkD;AAClD,oCAAoC;AACpC,SAAS;AACT,MAAM;AACN,IAAI;AACJ,EAAE;AACF,yDAAyD;AACzD,qCAAqC;AACrC,oBAAoB;AACpB,cAAc;AACd,8EAA8E;AAC9E,EAAE;AACF,kEAAkE;AAClE,sFAAsF;AACtF,aAAa;AACb,iCAAiC;AACjC,SAAS;AACT,QAAQ;AACR,sDAAsD;AACtD,uCAAuC;AACvC,oDAAoD;AACpD,sCAAsC;AACtC,SAAS;AACT,MAAM;AACN,IAAI;AAEJ,OAAO,MAAMC;IAgBJC,cAAcC,YAAsB,EAAsB;QAC/D,OAAO,IAAI,CAACC,YAAY,CAACD,aAAa;IACxC;IAEOE,wBACLF,YAAsB,EACE;QACxB,OAAO,IAAI,CAACG,wBAAwB,CAACH,aAAa;IACpD;IAEOI,oBAAoBJ,YAAsB,EAA4B;QAC3E,OAAO,IAAI,CAACK,oBAAoB,CAACL,aAAa;IAChD;IAEOM,cAAcN,YAAsB,EAAW;QACpD,OAAOO,QAAQP,gBAAgB,IAAI,CAACD,aAAa,CAACC;IACpD;IAEOQ,oBAAoBR,YAAsB,E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AAI,CAACqD,iCAAiC,CAACrD;QACvC;IACF;IAEQwC,uCAAuCxC,YAAsB,EAAE;QACrE,IAAI,CAAC,IAAI,CAACM,aAAa,CAACN,eAAe;QACvC;;KAEC,GACD,IAAI,CAACwD,mCAAmC,CAACxD;QACzC;;KAEC,GACD,IAAI,CAACyD,yBAAyB,CAACzD;QAC/B;IACF;IAEQkC,sCAAsClC,YAAsB,EAAE;QACpE,IAAI,CAAC,IAAI,CAACM,aAAa,CAACN,eAAe;QACvC;;KAEC,GACD,IAAI,CAACwC,sCAAsC,CAACxC;QAE5C;;KAEC,GACD,IAAI,CAACmD,kCAAkC,CAACnD;QAExC;;KAEC,GACD,IAAI,CAACoD,kCAAkC,CAACpD;QACxC;IACF;IA1SA,YAAY,AAAU4D,KAAa,CAAE;aAAfA,QAAAA;QAXtB,0DAA0D;QAC1D,0DAA0D;QAC1D,yDAAyD;QACzD,yDAAyD;QACzD,wDAAwD;QACxD,EAAE;aAEK3D,eAA4B,CAAC;aAC7BI,uBAAyC,CAAC;aAC1CF,2BAA6C,CAAC;QAGnDT,mBAAmB,IAAI;IACzB;AAySF;AAEA,eAAeI,cAAa"}
|
package/src/lib/types/nodes.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
22
|
-
|
|
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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/types/nodes.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 { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { SvgIconProps } from '@mui/material/SvgIcon'\n/** Minimal icon-props type used in component/preset schemas. Structurally compatible with @aglyn/shared-ui-jsx MdiIconProps. */\nexport type MdiIconProps<D extends React.ElementType = 'svg', P = object> = SvgIconProps<D, P> & {\n path?: string\n}\nimport type {\n ComponentId,\n ComponentsLinealOrder,\n NodeId,\n PresetId,\n} from '../foundation'\nimport { ComponentCategory } from '../foundation/constants/components'\nimport type { ITimestamp } from '@aglyn/shared-util-timestamp'\nimport type React from 'react'\nimport type { ComponentClass, ComponentProps } from 'react'\nimport type { NODE_ROOT_ID } from '../canvas-manager'\nimport type { NodeInteraction } from '../app-utils/node-interactions'\n\nimport type {\n FEATURE_FLAG,\n FieldComponentType,\n RICH_TEXT_COMMANDS,\n} from '../foundation'\nimport type { PluginId } from '../plugin-manager'\nimport type { ElementContentMap, Node, Props, Taxonomic } from './ast'\nimport type { AglynDocument } from '../foundation'\nimport type { HostUid } from '../foundation'\n\ndeclare module './ast' {\n /**\n * This map registers all node types that may be used as top-level content in\n * the document.\n *\n * These types are accepted inside `root` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * // Allow using raw nodes defined by `rehype-raw`.\n * raw: Raw;\n * }\n * }\n */\n export interface RootContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n\n /**\n * This map registers all node types that may be used as content in an\n * element.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\n export interface ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n}\n\n/**\n * This map registers all node types that may be used as content in an canvas\n * node.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\nexport interface CanvasNodeContentMap extends ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n}\n\nexport type CanvasNodeContent = CanvasNodeContentMap[keyof CanvasNodeContentMap]\n\n/**\n * CanvasNode represents a the schema for building a JSX Element.\n */\nexport interface CanvasNode extends Node {\n /**\n * Represents this variant of a Node.\n */\n type: 'node'\n\n /**\n * List representing the children of a node.\n */\n children?: CanvasNodeContent[] | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n\n /**\n * Represents the element's parent unique identifier\n */\n parentId?: string | undefined\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n}\n\n/**\n * CanvasElement represents a living JSX Element\n */\nexport interface CanvasElement extends CanvasNode {\n /**\n * Represents the element's unique identifier\n */\n $id: string\n}\n\nexport type AbstractId = string\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AbstractNodeSchema<P = JSX.AnyProps> extends CanvasNode {\n /**\n * The unique identifier for a node\n */\n $id: AbstractId\n title?: string\n displayName?: string\n description?: string\n\n children?: any\n nodes?: any\n\n /**\n * The node style properties for emotion\n */\n sx?: JSX.SxProps\n /**\n * The node props/attributes passed to the component\n */\n props?: P\n\n category?: any\n icon?: any\n\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n deletedAt?: ITimestamp\n}\n\n/**\n * CanvasPreset represents an encapsulated 'node' type as the root node for\n * crafting a living JSX Element\n */\nexport interface CanvasPreset extends Node, Taxonomic {\n /**\n * Represents this variant of a Node.\n */\n type: 'preset'\n\n /**\n * Represents the element's unique identifier\n */\n $id: string\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n}\n\nexport type { NodeId }\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype PresetI = AglynDocument &\n Omit<AbstractNodeSchema<any>, 'type' | 'data'> &\n Omit<CanvasPreset, 'type' | 'data'>\n\ninterface PresetII extends PresetI {\n type: NodeType.PRESET | string\n}\n\nexport interface PresetSchema<P = JSX.AnyProps> extends PresetII {\n $id: PresetId\n pluginId?: PluginId\n displayName?: string\n description?: string\n category?: string | ComponentCategory\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n icon?: MdiIconProps\n data: NodeSchemaNested<P>\n /**\n * Interaction templates wired when the preset is inserted (AGL-589):\n * the host app resolves each `presetRef` marker to a freshly minted node\n * and persists the result. Presets that need hover choreography (a\n * primitive dropdown panel) ship working out of the box instead of asking\n * the user to author the interactions by hand.\n *\n * TEMPLATES, and named so. These are not interactions: they are\n * unresolved, they reference nodes that do not exist yet, and they are\n * consumed at insert time and never stored. What they resolve INTO lives\n * on the node as {@link NodeSchema.interactions}, and a `PresetSchema` is\n * assignable to a `NodeSchema` — so while the two shared a name, one of\n * them had to be wrong wherever a preset was passed as a node.\n */\n interactionTemplates?: PresetInteractionSchema[]\n}\n\n/**\n * A visibility step inside a {@link PresetSchema} interaction template.\n * Only the basic client visibility steps are expressible — presets\n * scaffold in-page choreography, never server automations.\n */\nexport interface PresetInteractionStepSchema {\n type: 'showElement' | 'hideElement' | 'toggleElement'\n /** `presetRef` of the preset node this step targets. */\n targetRef: string\n /** Optional grace delay, validated to 0–5000ms like the builder. */\n delayMs?: number\n /** Self-dismissal for steps that can reveal the target. */\n dismissOn?: Array<'escape' | 'outsideClick'>\n}\n\n/** An interaction template a preset wires on insert (AGL-589). */\nexport interface PresetInteractionSchema {\n name: string\n event: 'elementClick' | 'elementHoverEnter' | 'elementHoverLeave'\n /** `presetRef` of the preset node whose selector fires the trigger. */\n triggerRef: string\n steps: PresetInteractionStepSchema[]\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype NodeI<P> = AglynDocument & Omit<AbstractNodeSchema<P>, 'type'>\n\nexport interface NodeSchema<P = JSX.AnyProps> extends NodeI<P> {\n type: NodeType | string\n /**\n * List of the children unique identifiers for the node\n */\n nodes?: NodeId[]\n /**\n * Class name to pass the DOM node, can also be defined in props\n */\n className?: string\n /**\n * Preset-authoring marker (AGL-589): names a node inside a preset's\n * `data` tree so the preset's interaction templates can reference it\n * (`triggerRef` / `targetRef`). Cloned onto the inserted node; inert\n * everywhere else.\n */\n presetRef?: string\n /**\n * Per-instance style overrides on a reusable-component instance node\n * (AGL-1306), keyed by target: `root` (see `STYLE_OVERRIDES_ROOT_KEY`)\n * addresses the component ROOT, and any other key is a DEFINITION-internal\n * node id addressing one leaf inside the component (AGL-1332). Each slice\n * is an sx-shaped record merged over that node's own sx at graft time\n * (`composeReusableComponentNodes` → `mergeNodeSx`), so one page's CTA can\n * switch to a white background AND repaint its headline without widening\n * the component's declared props or detaching.\n *\n * Keyed on the definition's id, never the grafted `cmp__{instance}__{def}`\n * id: the graft id is derived per placement, so it would not survive a\n * duplicate or a re-key, and the same component could not offer two\n * instances the same authoring vocabulary. A key naming a node the\n * definition no longer has is ignored — a component edited later degrades\n * to its own styling instead of taking a page down.\n *\n * A first-class node field, NOT a prop: `AglynNode`'s constructor drops\n * unknown top-level keys, and anything in `props` is spread onto the\n * instance's wrapper DOM element. Lives on the instance node in the\n * document that places it — it survives component republish and never\n * pins the instance to an old component version, because the graft\n * always merges it over the definition's CURRENT nodes.\n */\n styleOverrides?: Record<string, JSX.SxProps>\n /**\n * Per-instance ATTRIBUTE overrides on a reusable-component instance node\n * (AGL-1899) — the same addressing as {@link styleOverrides}, applied to\n * a node's props instead of its sx, so one placement can carry a\n * different button `variant`, `size` or `href` without the component\n * declaring a prop for it and without detaching.\n *\n * Merged **per named prop**: a slice replaces only the props it names and\n * leaves the definition's others alone, so a component that later adds a\n * prop still gives every existing instance the new default. That is\n * deliberately shallower than the sx merge next door — an sx slice\n * cascades because `@scheme dark` and breakpoint objects are themselves\n * selectors, whereas a prop value is one value, and half-merging two\n * objects that merely look alike (say a `slotProps`) would produce a\n * third thing neither side asked for.\n *\n * `sx` is refused here. Styling an instance already has a mechanism one\n * field up, and honouring both would leave two writers racing for one\n * rendered value with no rule to say which wins.\n *\n * Applied BEFORE `{{prop.*}}` substitution, so an override may itself be\n * written in tokens and still resolves, and an override on a prop the\n * definition binds to a declared prop wins — the more specific placement\n * beats the component's own default.\n */\n attrOverrides?: Record<string, Record<string, unknown>>\n /**\n * EDITOR-ONLY: a screen's per-page restyling of its layout's elements\n * (AGL-3286), parked on the screen canvas ROOT while the besigner is open.\n *\n * Stored on the screen VERSION as `layoutStyleOverrides`, never in `nodes`:\n * the editor injects it here on load and lifts it back out on save\n * (`injectLayoutStyleOverrides` / `extractLayoutStyleOverrides`). Carried on\n * the root so an edit is an undo step, marks the screen dirty and rides the\n * working draft like any other change. Composition ignores it — the screen\n * root is dropped when it is grafted into the layout's slot.\n */\n layoutStyleOverrides?: Record<string, Record<string, Record<string, unknown>>>\n /**\n * Interactions this element carries — the click, hover and\n * scroll-into-view choreography authored on it in the besigner.\n *\n * ## Why they live on the NODE\n *\n * They used to be rows in `hosts/{hostId}/actions`, bound to an element by\n * a `[data-aglyn=\"leaf:<id>\"]` selector — the same collection the Workflows\n * page lists. An interaction is not a site-wide automation, and storing it\n * as one had four consequences, every one of them a thing an author would\n * expect to work:\n *\n * - it was not versioned with the document, so it neither published nor\n * rolled back with the screen it belongs to;\n * - it did not travel with a component copied to another site, or packaged\n * into a template or a plugin — the element arrived inert;\n * - deleting the element left the action behind, pointing at a selector\n * nothing resolves;\n * - and a nav's hover choreography sat in the site's automation list\n * beside \"when an order is placed\", which is a different kind of thing.\n *\n * Host actions remain, and remain the right home for a genuine site event.\n * The split is the concept: an ACTION is something the site does, an\n * INTERACTION is something an element does.\n *\n * ## Shape\n *\n * Deliberately the same `SiteInteraction` a site-wide interaction is, so\n * nothing about the runtime changes: the selector is stamped from this\n * node's own id when the page is composed, and the compiled result is the\n * shape the client engine has always consumed. `trigger.selector` is\n * therefore ignored here — the node IS the selector.\n */\n interactions?: NodeInteraction[]\n /**\n * Hidden by the author — the eye on the element's hierarchy row.\n *\n * Renders `display: none` on the canvas AND on the published site. It is\n * the plain \"I do not want this on the page\" switch: no runtime, no\n * interaction, nothing reveals it. Showing it again is the same eye.\n *\n * ## Why a FIELD and not a style\n *\n * Because it has to override the element's own display rather than replace\n * it. An author who toggles the eye on a Stack laid out with\n * `display: flex` must get that flex back when they toggle it off, and\n * writing `display: none` into `node.sx` destroys the value it overwrote —\n * there is nothing left to restore. Composed LAST in `Leaf` instead, so it\n * wins on the cascade and the stored style is never touched.\n *\n * ## Not {@link ELEMENT_HIDDEN_CLASS}\n *\n * `aglyn-hidden` is a different thing wearing a similar name: it means\n * \"starts hidden, and an interaction shows it\" — a mega-menu panel, a\n * drawer. That class is part of a runtime contract (the show/hide steps\n * toggle it, and the canvas reveals it for designing), and it is bespoke to\n * that job. A visibility toggle that wrote it would enrol every hidden\n * element in a choreography it is not part of.\n */\n hidden?: boolean\n /**\n * The computed node parent (only for type completion)\n */\n readonly parent?: NodeSchema<any> | null\n /**\n * The computed node parent (only for type completion)\n */\n readonly children?: NodeSchema<any>[]\n /**\n * The computed index in parent nodes (only for type completion)\n */\n readonly index?: number | null\n /**\n * The computed label (only for type completion)\n */\n readonly labelShort?: string | undefined\n /**\n * The computed breadcrumb path (only for type completion)\n */\n readonly breadcrumbPath?: NodeBreadcrumbPath\n /**\n * The computed component schema (only for type completion)\n */\n readonly componentSchema?: ComponentSchema | undefined\n /**\n * The computed guard for of child nodes (only for type completion)\n */\n readonly hasNodes?: boolean\n /**\n * The computed property for the resolved props from component schema\n */\n readonly resolvedProps?: P\n}\n\nexport enum NodeType {\n NODE = 'node',\n TEXT = 'text',\n NUMBER = 'number',\n SCREEN = 'screen',\n REF = 'ref',\n PRESET = 'preset',\n}\n\nexport type NodeSchemaJSON<P = JSX.AnyProps> = Omit<\n NodeSchema<P>,\n | 'parent'\n | 'index'\n | 'labelShort'\n | 'breadcrumbPath'\n | 'componentSchema'\n | 'hasNodes'\n>\n\nexport type NodeSchemaNested<P = JSX.AnyProps> = Omit<\n NodeSchemaJSON<P>,\n 'nodes'\n> & { nodes?: NodeSchemaNested<any>[] }\n\nexport type NodesMap = Record<NodeId, NodeSchema<any>>\n\nexport type NodeBreadcrumbPath = [\n root: string & typeof NODE_ROOT_ID,\n ...nodes: [...ancestors: NodeId[], node: NodeId],\n]\n\nexport type ProcessableNodes =\n | NodeSchemaNested<any>[]\n | NodeSchemaNested<any>\n | Record<NodeId, NodeSchema>\n\nexport { ComponentCategory }\n\nexport type { ComponentId }\nexport type { PresetId }\n\nexport type ComponentFactory<\n P extends ComponentProps<C> | any = any,\n C extends keyof JSX.IntrinsicElements | JSX.ElementConstructor<any> = any,\n> = ComponentClass<P> | JSX.ElementConstructor<P> | keyof JSX.IntrinsicElements\n// | keyof JSX.IntrinsicElements[keyof JSX.IntrinsicElements]\n\nexport type { ComponentsLinealOrder }\n\n/**\n * What the Attributes panel knows about the element a field edits, handed to\n * an attribute's `resolveProps` as its fourth argument.\n *\n * data-driven-forms gives a field its own value and the form's values, which\n * are the element's props and nothing else. A rule about the element as a\n * whole needs more than that: whether a Link Container holds anything that\n * names its link depends on the elements inside it. So the panel adds the\n * node, and a lookup for the ids listed in its `nodes`.\n *\n * Absent wherever a field is drawn outside that panel, including a unit test\n * calling the function directly, so a `resolveProps` that reads it has to\n * treat a missing context as having nothing to say.\n */\nexport interface AttributeFieldContext {\n /** The element the Attributes panel is editing. */\n node: NodeSchema<any>\n /** An element of the same document by id, such as a child in `nodes`. */\n getNode: (id: NodeId) => NodeSchema<any> | undefined\n}\n\n/**\n * An attribute's `resolveProps`: the three arguments data-driven-forms\n * passes, then the {@link AttributeFieldContext} the Attributes panel adds.\n */\nexport type AttributeResolveProps = (\n ...args: [\n ...Parameters<ResolvePropsFunction>,\n context?: AttributeFieldContext,\n ]\n) => ReturnType<ResolvePropsFunction>\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AttributeSchema 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?: any\n clearedValue?: any\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: AttributeResolveProps\n description?: string\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface ComponentSchema<P = any> {\n $id?: ComponentId\n pluginId?: PluginId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n category?: string | ComponentCategory\n\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n\n /**\n * Icon props for display around besigner\n */\n icon?: MdiIconProps\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<NodeSchema<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AttributeSchema[]\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): the inline editor\n * upgrades to a formatting surface and commits sanitized HTML into the\n * `html` prop (with `children` kept as the plain-text fallback).\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * hands it one React child per node child instead of the single `<Branch>`\n * 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 heading.\n *\n * Opt in only for components with this contract; the wrapper is what keeps\n * the Branch/Stem/Leaf seam swappable for everything else.\n */\n positionalChildren?: FEATURE_FLAG\n /**\n * Nothing this component renders responds to the visitor until it is\n * hydrated, beyond what its server HTML does on its own — copy, images,\n * layout, a plain `<a href>` (AGL-3581).\n *\n * On a published page, a subtree made ONLY of components declaring this\n * may keep its server HTML through hydration and render when the visitor\n * nears it, instead of hydrating with the rest of the page. One component\n * without it keeps its whole ancestry hydrating at once, so leave it off\n * anything with a handler, state or an effect a visitor could reach:\n * menus, toggles, forms, accordions, carousels, players.\n */\n lazyHydration?: FEATURE_FLAG\n /**\n * Renders its node children directly inside its root DOM element, adds\n * nothing of its own around or among them, and passes props it does not\n * know through to that element (AGL-3581).\n *\n * That is what lets a static subtree keep its server HTML: the renderer\n * hands such a component `dangerouslySetInnerHTML` in place of its\n * children while the page hydrates, so its root hydrates and its contents\n * are left exactly as the server sent them. A component that wraps,\n * joins or decorates its children (a divider between them, a ripple\n * after them) must not declare it — React refuses an element that has\n * both.\n */\n childrenInRoot?: FEATURE_FLAG\n }\n}\n\nexport type SchemasByCategory = Record<\n ComponentCategory | string,\n (ComponentSchema<any> | PresetSchema<any>)[]\n>\n\nexport interface ScreenSchema {\n nodes: NodeSchemaNested\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n hostId?: HostUid\n}\n"],"names":["ComponentCategory","NodeType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAuBD,SAASA,iBAAiB,QAAQ,wCAAoC;AAictE,OAAO,IAAA,AAAKC,kCAAAA;;;;;;;WAAAA;MAOX;AA6BD,SAASD,iBAAiB,GAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/types/nodes.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 { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { SvgIconProps } from '@mui/material/SvgIcon'\n/**\n * Minimal icon-props type used in component/preset schemas. Structurally\n * compatible with @aglyn/shared-ui-jsx MdiIconProps, which draws `path` and\n * takes no ReactNode children (only a `(d) => …` render function), so\n * `children` is left out here too.\n */\nexport type MdiIconProps<D extends React.ElementType = 'svg', P = object> = Omit<SvgIconProps<D, P>, 'children'> & {\n path?: string\n}\nimport type {\n ComponentId,\n ComponentsLinealOrder,\n NodeId,\n PresetId,\n} from '../foundation'\nimport { ComponentCategory } from '../foundation/constants/components'\nimport type { ITimestamp } from '@aglyn/shared-util-timestamp'\nimport type React from 'react'\nimport type { ComponentClass, ComponentProps } from 'react'\nimport type { NODE_ROOT_ID } from '../canvas-manager'\nimport type { NodeInteraction } from '../app-utils/node-interactions'\n\nimport type {\n FEATURE_FLAG,\n FieldComponentType,\n RICH_TEXT_COMMANDS,\n} from '../foundation'\nimport type { PluginId } from '../plugin-manager'\nimport type { ElementContentMap, Node, Props, Taxonomic } from './ast'\nimport type { AglynDocument } from '../foundation'\nimport type { HostUid } from '../foundation'\n\ndeclare module './ast' {\n /**\n * This map registers all node types that may be used as top-level content in\n * the document.\n *\n * These types are accepted inside `root` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * // Allow using raw nodes defined by `rehype-raw`.\n * raw: Raw;\n * }\n * }\n */\n export interface RootContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n\n /**\n * This map registers all node types that may be used as content in an\n * element.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\n export interface ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n}\n\n/**\n * This map registers all node types that may be used as content in an canvas\n * node.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\nexport interface CanvasNodeContentMap extends ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n}\n\nexport type CanvasNodeContent = CanvasNodeContentMap[keyof CanvasNodeContentMap]\n\n/**\n * CanvasNode represents a the schema for building a JSX Element.\n */\nexport interface CanvasNode extends Node {\n /**\n * Represents this variant of a Node.\n */\n type: 'node'\n\n /**\n * List representing the children of a node.\n */\n children?: CanvasNodeContent[] | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n\n /**\n * Represents the element's parent unique identifier\n */\n parentId?: string | undefined\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n}\n\n/**\n * CanvasElement represents a living JSX Element\n */\nexport interface CanvasElement extends CanvasNode {\n /**\n * Represents the element's unique identifier\n */\n $id: string\n}\n\nexport type AbstractId = string\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AbstractNodeSchema<P = JSX.AnyProps> extends CanvasNode {\n /**\n * The unique identifier for a node\n */\n $id: AbstractId\n title?: string\n displayName?: string\n description?: string\n\n children?: any\n nodes?: any\n\n /**\n * The node style properties for emotion\n */\n sx?: JSX.SxProps\n /**\n * The node props/attributes passed to the component\n */\n props?: P\n\n category?: any\n icon?: any\n\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n deletedAt?: ITimestamp\n}\n\n/**\n * CanvasPreset represents an encapsulated 'node' type as the root node for\n * crafting a living JSX Element\n */\nexport interface CanvasPreset extends Node, Taxonomic {\n /**\n * Represents this variant of a Node.\n */\n type: 'preset'\n\n /**\n * Represents the element's unique identifier\n */\n $id: string\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n}\n\nexport type { NodeId }\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype PresetI = AglynDocument &\n Omit<AbstractNodeSchema<any>, 'type' | 'data'> &\n Omit<CanvasPreset, 'type' | 'data'>\n\ninterface PresetII extends PresetI {\n type: NodeType.PRESET | string\n}\n\nexport interface PresetSchema<P = JSX.AnyProps> extends PresetII {\n $id: PresetId\n pluginId?: PluginId\n displayName?: string\n description?: string\n category?: string | ComponentCategory\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n icon?: MdiIconProps\n data: NodeSchemaNested<P>\n /**\n * Interaction templates wired when the preset is inserted (AGL-589):\n * the host app resolves each `presetRef` marker to a freshly minted node\n * and persists the result. Presets that need hover choreography (a\n * primitive dropdown panel) ship working out of the box instead of asking\n * the user to author the interactions by hand.\n *\n * TEMPLATES, and named so. These are not interactions: they are\n * unresolved, they reference nodes that do not exist yet, and they are\n * consumed at insert time and never stored. What they resolve INTO lives\n * on the node as {@link NodeSchema.interactions}, and a `PresetSchema` is\n * assignable to a `NodeSchema` — so while the two shared a name, one of\n * them had to be wrong wherever a preset was passed as a node.\n */\n interactionTemplates?: PresetInteractionSchema[]\n}\n\n/**\n * A visibility step inside a {@link PresetSchema} interaction template.\n * Only the basic client visibility steps are expressible — presets\n * scaffold in-page choreography, never server automations.\n */\nexport interface PresetInteractionStepSchema {\n type: 'showElement' | 'hideElement' | 'toggleElement'\n /** `presetRef` of the preset node this step targets. */\n targetRef: string\n /** Optional grace delay, validated to 0–5000ms like the builder. */\n delayMs?: number\n /** Self-dismissal for steps that can reveal the target. */\n dismissOn?: Array<'escape' | 'outsideClick'>\n}\n\n/** An interaction template a preset wires on insert (AGL-589). */\nexport interface PresetInteractionSchema {\n name: string\n event: 'elementClick' | 'elementHoverEnter' | 'elementHoverLeave'\n /** `presetRef` of the preset node whose selector fires the trigger. */\n triggerRef: string\n steps: PresetInteractionStepSchema[]\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype NodeI<P> = AglynDocument & Omit<AbstractNodeSchema<P>, 'type'>\n\nexport interface NodeSchema<P = JSX.AnyProps> extends NodeI<P> {\n type: NodeType | string\n /**\n * List of the children unique identifiers for the node\n */\n nodes?: NodeId[]\n /**\n * Class name to pass the DOM node, can also be defined in props\n */\n className?: string\n /**\n * Preset-authoring marker (AGL-589): names a node inside a preset's\n * `data` tree so the preset's interaction templates can reference it\n * (`triggerRef` / `targetRef`). Cloned onto the inserted node; inert\n * everywhere else.\n */\n presetRef?: string\n /**\n * Per-instance style overrides on a reusable-component instance node\n * (AGL-1306), keyed by target: `root` (see `STYLE_OVERRIDES_ROOT_KEY`)\n * addresses the component ROOT, and any other key is a DEFINITION-internal\n * node id addressing one leaf inside the component (AGL-1332). Each slice\n * is an sx-shaped record merged over that node's own sx at graft time\n * (`composeReusableComponentNodes` → `mergeNodeSx`), so one page's CTA can\n * switch to a white background AND repaint its headline without widening\n * the component's declared props or detaching.\n *\n * Keyed on the definition's id, never the grafted `cmp__{instance}__{def}`\n * id: the graft id is derived per placement, so it would not survive a\n * duplicate or a re-key, and the same component could not offer two\n * instances the same authoring vocabulary. A key naming a node the\n * definition no longer has is ignored — a component edited later degrades\n * to its own styling instead of taking a page down.\n *\n * A first-class node field, NOT a prop: `AglynNode`'s constructor drops\n * unknown top-level keys, and anything in `props` is spread onto the\n * instance's wrapper DOM element. Lives on the instance node in the\n * document that places it — it survives component republish and never\n * pins the instance to an old component version, because the graft\n * always merges it over the definition's CURRENT nodes.\n */\n styleOverrides?: Record<string, JSX.SxProps>\n /**\n * Per-instance ATTRIBUTE overrides on a reusable-component instance node\n * (AGL-1899) — the same addressing as {@link styleOverrides}, applied to\n * a node's props instead of its sx, so one placement can carry a\n * different button `variant`, `size` or `href` without the component\n * declaring a prop for it and without detaching.\n *\n * Merged **per named prop**: a slice replaces only the props it names and\n * leaves the definition's others alone, so a component that later adds a\n * prop still gives every existing instance the new default. That is\n * deliberately shallower than the sx merge next door — an sx slice\n * cascades because `@scheme dark` and breakpoint objects are themselves\n * selectors, whereas a prop value is one value, and half-merging two\n * objects that merely look alike (say a `slotProps`) would produce a\n * third thing neither side asked for.\n *\n * `sx` is refused here. Styling an instance already has a mechanism one\n * field up, and honouring both would leave two writers racing for one\n * rendered value with no rule to say which wins.\n *\n * Applied BEFORE `{{prop.*}}` substitution, so an override may itself be\n * written in tokens and still resolves, and an override on a prop the\n * definition binds to a declared prop wins — the more specific placement\n * beats the component's own default.\n */\n attrOverrides?: Record<string, Record<string, unknown>>\n /**\n * EDITOR-ONLY: a screen's per-page restyling of its layout's elements\n * (AGL-3286), parked on the screen canvas ROOT while the besigner is open.\n *\n * Stored on the screen VERSION as `layoutStyleOverrides`, never in `nodes`:\n * the editor injects it here on load and lifts it back out on save\n * (`injectLayoutStyleOverrides` / `extractLayoutStyleOverrides`). Carried on\n * the root so an edit is an undo step, marks the screen dirty and rides the\n * working draft like any other change. Composition ignores it — the screen\n * root is dropped when it is grafted into the layout's slot.\n */\n layoutStyleOverrides?: Record<string, Record<string, Record<string, unknown>>>\n /**\n * Interactions this element carries — the click, hover and\n * scroll-into-view choreography authored on it in the besigner.\n *\n * ## Why they live on the NODE\n *\n * They used to be rows in `hosts/{hostId}/actions`, bound to an element by\n * a `[data-aglyn=\"leaf:<id>\"]` selector — the same collection the Workflows\n * page lists. An interaction is not a site-wide automation, and storing it\n * as one had four consequences, every one of them a thing an author would\n * expect to work:\n *\n * - it was not versioned with the document, so it neither published nor\n * rolled back with the screen it belongs to;\n * - it did not travel with a component copied to another site, or packaged\n * into a template or a plugin — the element arrived inert;\n * - deleting the element left the action behind, pointing at a selector\n * nothing resolves;\n * - and a nav's hover choreography sat in the site's automation list\n * beside \"when an order is placed\", which is a different kind of thing.\n *\n * Host actions remain, and remain the right home for a genuine site event.\n * The split is the concept: an ACTION is something the site does, an\n * INTERACTION is something an element does.\n *\n * ## Shape\n *\n * Deliberately the same `SiteInteraction` a site-wide interaction is, so\n * nothing about the runtime changes: the selector is stamped from this\n * node's own id when the page is composed, and the compiled result is the\n * shape the client engine has always consumed. `trigger.selector` is\n * therefore ignored here — the node IS the selector.\n */\n interactions?: NodeInteraction[]\n /**\n * Hidden by the author — the eye on the element's hierarchy row.\n *\n * Renders `display: none` on the canvas AND on the published site. It is\n * the plain \"I do not want this on the page\" switch: no runtime, no\n * interaction, nothing reveals it. Showing it again is the same eye.\n *\n * ## Why a FIELD and not a style\n *\n * Because it has to override the element's own display rather than replace\n * it. An author who toggles the eye on a Stack laid out with\n * `display: flex` must get that flex back when they toggle it off, and\n * writing `display: none` into `node.sx` destroys the value it overwrote —\n * there is nothing left to restore. Composed LAST in `Leaf` instead, so it\n * wins on the cascade and the stored style is never touched.\n *\n * ## Not {@link ELEMENT_HIDDEN_CLASS}\n *\n * `aglyn-hidden` is a different thing wearing a similar name: it means\n * \"starts hidden, and an interaction shows it\" — a mega-menu panel, a\n * drawer. That class is part of a runtime contract (the show/hide steps\n * toggle it, and the canvas reveals it for designing), and it is bespoke to\n * that job. A visibility toggle that wrote it would enrol every hidden\n * element in a choreography it is not part of.\n */\n hidden?: boolean\n /**\n * The computed node parent (only for type completion)\n */\n readonly parent?: NodeSchema<any> | null\n /**\n * The computed node parent (only for type completion)\n */\n readonly children?: NodeSchema<any>[]\n /**\n * The computed index in parent nodes (only for type completion)\n */\n readonly index?: number | null\n /**\n * The computed label (only for type completion)\n */\n readonly labelShort?: string | undefined\n /**\n * The computed breadcrumb path (only for type completion)\n */\n readonly breadcrumbPath?: NodeBreadcrumbPath\n /**\n * The computed component schema (only for type completion)\n */\n readonly componentSchema?: ComponentSchema | undefined\n /**\n * The computed guard for of child nodes (only for type completion)\n */\n readonly hasNodes?: boolean\n /**\n * The computed property for the resolved props from component schema\n */\n readonly resolvedProps?: P\n}\n\nexport enum NodeType {\n NODE = 'node',\n TEXT = 'text',\n NUMBER = 'number',\n SCREEN = 'screen',\n REF = 'ref',\n PRESET = 'preset',\n}\n\nexport type NodeSchemaJSON<P = JSX.AnyProps> = Omit<\n NodeSchema<P>,\n | 'parent'\n | 'index'\n | 'labelShort'\n | 'breadcrumbPath'\n | 'componentSchema'\n | 'hasNodes'\n>\n\nexport type NodeSchemaNested<P = JSX.AnyProps> = Omit<\n NodeSchemaJSON<P>,\n 'nodes'\n> & { nodes?: NodeSchemaNested<any>[] }\n\nexport type NodesMap = Record<NodeId, NodeSchema<any>>\n\nexport type NodeBreadcrumbPath = [\n root: string & typeof NODE_ROOT_ID,\n ...nodes: [...ancestors: NodeId[], node: NodeId],\n]\n\nexport type ProcessableNodes =\n | NodeSchemaNested<any>[]\n | NodeSchemaNested<any>\n | Record<NodeId, NodeSchema>\n\nexport { ComponentCategory }\n\nexport type { ComponentId }\nexport type { PresetId }\n\nexport type ComponentFactory<\n P extends ComponentProps<C> | any = any,\n C extends keyof JSX.IntrinsicElements | JSX.ElementConstructor<any> = any,\n> = ComponentClass<P> | JSX.ElementConstructor<P> | keyof JSX.IntrinsicElements\n// | keyof JSX.IntrinsicElements[keyof JSX.IntrinsicElements]\n\nexport type { ComponentsLinealOrder }\n\n/**\n * What the Attributes panel knows about the element a field edits, handed to\n * an attribute's `resolveProps` as its fourth argument.\n *\n * data-driven-forms gives a field its own value and the form's values, which\n * are the element's props and nothing else. A rule about the element as a\n * whole needs more than that: whether a Link Container holds anything that\n * names its link depends on the elements inside it. So the panel adds the\n * node, and a lookup for the ids listed in its `nodes`.\n *\n * Absent wherever a field is drawn outside that panel, including a unit test\n * calling the function directly, so a `resolveProps` that reads it has to\n * treat a missing context as having nothing to say.\n */\nexport interface AttributeFieldContext {\n /** The element the Attributes panel is editing. */\n node: NodeSchema<any>\n /** An element of the same document by id, such as a child in `nodes`. */\n getNode: (id: NodeId) => NodeSchema<any> | undefined\n}\n\n/**\n * An attribute's `resolveProps`: the three arguments data-driven-forms\n * passes, then the {@link AttributeFieldContext} the Attributes panel adds.\n */\nexport type AttributeResolveProps = (\n ...args: [\n ...Parameters<ResolvePropsFunction>,\n context?: AttributeFieldContext,\n ]\n) => ReturnType<ResolvePropsFunction>\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AttributeSchema 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?: any\n clearedValue?: any\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: AttributeResolveProps\n description?: string\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface ComponentSchema<P = any> {\n $id?: ComponentId\n pluginId?: PluginId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n category?: string | ComponentCategory\n\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n\n /**\n * Icon props for display around besigner\n */\n icon?: MdiIconProps\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<NodeSchema<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AttributeSchema[]\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): the inline editor\n * upgrades to a formatting surface and commits sanitized HTML into the\n * `html` prop (with `children` kept as the plain-text fallback).\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * hands it one React child per node child instead of the single `<Branch>`\n * 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 heading.\n *\n * Opt in only for components with this contract; the wrapper is what keeps\n * 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 * Nothing this component renders responds to the visitor until it is\n * hydrated, beyond what its server HTML does on its own — copy, images,\n * layout, a plain `<a href>` (AGL-3581).\n *\n * On a published page, a subtree made ONLY of components declaring this\n * may keep its server HTML through hydration and render when the visitor\n * nears it, instead of hydrating with the rest of the page. One component\n * without it keeps its whole ancestry hydrating at once, so leave it off\n * anything with a handler, state or an effect a visitor could reach:\n * menus, toggles, forms, accordions, carousels, players.\n */\n lazyHydration?: FEATURE_FLAG\n /**\n * Renders its node children directly inside its root DOM element, adds\n * nothing of its own around or among them, and passes props it does not\n * know through to that element (AGL-3581).\n *\n * That is what lets a static subtree keep its server HTML: the renderer\n * hands such a component `dangerouslySetInnerHTML` in place of its\n * children while the page hydrates, so its root hydrates and its contents\n * are left exactly as the server sent them. A component that wraps,\n * joins or decorates its children (a divider between them, a ripple\n * after them) must not declare it — React refuses an element that has\n * both.\n */\n childrenInRoot?: FEATURE_FLAG\n }\n}\n\nexport type SchemasByCategory = Record<\n ComponentCategory | string,\n (ComponentSchema<any> | PresetSchema<any>)[]\n>\n\nexport interface ScreenSchema {\n nodes: NodeSchemaNested\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n hostId?: HostUid\n}\n"],"names":["ComponentCategory","NodeType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GA4BD,SAASA,iBAAiB,QAAQ,wCAAoC;AAictE,OAAO,IAAA,AAAKC;;;;;;;;MAOX;AA6BD,SAASD,iBAAiB,GAAE"}
|