@plitzi/sdk-authoring 0.38.11 → 0.38.12
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/CHANGELOG.md +104 -0
- package/dist/index-declare.js +102 -0
- package/dist/index-src.js +781 -1467
- package/dist/index.d.ts +3361 -4026
- package/dist/index.js +3 -2
- package/dist/node.d.ts +26 -7
- package/dist/node.js +16 -11
- package/package.json +11 -6
- package/skills/plitzi-authoring/CHEATSHEET.md +1 -1
- package/skills/plitzi-authoring/recipes/plugin.ts +9 -7
- package/skills/plitzi-authoring/reference/authoring-errors.md +3 -1
- package/skills/plitzi-authoring/reference/elements-and-styles.md +1 -1
- package/skills/plitzi-authoring/reference/flows.md +5 -4
- package/skills/plitzi-authoring/reference/plugins.md +40 -35
- package/skills/plitzi-authoring/reference/rules.md +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { $ as GLOBAL_CALLBACK_BUILDERS, $i as
|
|
2
|
-
|
|
1
|
+
import { $ as GLOBAL_CALLBACK_BUILDERS, $i as source, $n as twigTemplate, $r as button, $t as css, A as unrollPage, Ai as themeToggle, An as getUtility, Ar as onKey, At as d, B as blankSpace, Bi as activeOn, Bn as cycleState, Br as resetForm, Bt as grid, C as pageTexts, Ca as o, Ci as richText, Cn as flagGateOf, Cr as declaredTrigger, Ct as unusedDeclarations, D as pageRegions, Da as r$2, Di as tabContainerHeader, Dn as taskAction, Dr as onFlowError, Dt as pageFamily, E as diffPictures, Ea as n$1, Ei as tabContainerBody, En as defineAction, Er as onFlowEnd, Et as familyOf, F as readDevTools, Fi as defineElement, Fn as authLogout, Fr as onSubmit, Ft as t$1, G as space$1, Gi as hasVisibilityBinding, Gn as navigate, Gr as toggleElement, Gt as isClassModifier, H as catalogTemplateFiles, Hi as authorBinding, Hn as hostAction, Hr as scrollIntoView, Ht as className, I as readDevToolsInPage, Ii as element, In as authRefreshDetails, Ir as openDialog, It as tokens, J as importSlug, Ji as toBindingSpecs, Jn as runServerActionOrNotify, Jr as withPluginCatalogs, Jt as modifierClassName, K as space, Ki as hiddenWhen, Kn as removeState, Kr as updateElement, Kt as isClassRef, L as dataIssues, Li as inferredLinkMode, Ln as cancelServerAction, Lr as openModal, Lt as createTw, M as inspectPage, Mi as component, Mn as addNotification, Mr as onPageLoad, Mt as FIXABLE_CODES, N as onScreen, Ni as defaultAttributes, Nn as appendState, Nr as onPointerDown, Nt as n, O as profilePictures, Oa as s$1, Oi as tabContainerItem, On as BUILTIN_UTILITIES, Or as onFlowProgress, Ot as notificationsCss, P as failedFlowText, Pi as defaultLabel, Pn as authLogin, Pr as onScroll, Pt as r, Q as EXPLAIN_KINDS, Qi as actionSource, Qn as toggleState, Qr as blockJsx, Qt as STYLE_STATES, R as answerAction, Ri as COMPONENT_SOURCES, Rn as clearState, Rr as publishOn, Rt as tw, S as compareTexts, Sa as i$1, Si as reference, Sn as selectorFor, Sr as declaredCallback, St as suggestClassOverrides, T as comparePictures, Ta as c, Ti as tabContainer, Tn as authoringCodesTable, Tr as onClick, Tt as refusalOf, U as emptyTemplateFiles, Ui as bindTemplate, Un as invalidateQueries, Ur as scrollTo, Ut as classNames, V as blankTemplateFiles, Vi as activeWhen, Vn as delay, Vr as scrollBy, Vt as row, W as toPortableSource, Wi as groupBindings, Wn as moveState, Wr as setFieldValue, Wt as classRefs, X as importProbe, Xi as visibleWhen, Xn as stepState, Xr as apiContainer, Xt as styles, Y as importedFiles, Yi as variantFrom, Yn as setState, Yt as splitClassList, Z as BUILDER_NAMES, Zi as withVisibility, Zn as toggleInState, Zr as blockHtml, Zt as BREAKPOINTS, _ as shortcutKey, _a as elementTypeNames, _i as markdown, _n as slugify, _r as carouselPause, _t as assertSnippetValid, a as locateClasses, aa as authoringCodeEntry, ai as dialogContainer, an as expandShorthand, ar as when, at as SPACE_FIELDS, b as summariseRenders, ba as elementAttributeNames, bi as pagination, bn as locate, br as closeDialog, bt as suggestSpace, c as validateSnippet, ca as elementAttributeValues, ci as embed, cn as shorthandLonghands, cr as whileRunning, ct as specFromSpace, d as i$2, da as elementDefaultAttributes, di as formControl, dn as cssPropertyName, dr as getGlobalCallback, dt as actionToSource, ea as twig, ei as carousel, en as isRuleSetSpec, er as webHook, et as explain, f as o$1, fa as elementLeafTypes, fi as heading, fn as isCssProperty, fr as e, ft as withNamedIds, g as pressShortcut, ga as elementTriggers, gi as listItem, gn as digest, gr as carouselNext, gt as transformerCatalog, h as withElement, ha as elementSourceTypes, hi as list, hr as carouselGoTo, ht as suggestTransformer, i as lintSpace, ia as AuthoringError, ii as custom, in as cssShorthands, ir as named, it as ELEMENT_FIELDS, j as inspectDocument, ji as video, jn as SET_STATE_TYPES, jr as onLoad, jt as i, k as loadImages, ka as t, ki as text, kn as applyUtility, kr as onInterval, kt as withNotificationsCss, l as validateSpace, la as elementCallbacks, li as fontAwesome, ln as cssNumberValue, lr as BUILTIN_GLOBAL_CALLBACKS, lt as compareSpaces, m as singlePageSpace, ma as elementSlots, mi as link, mn as suggestCssProperty, mr as cancelApi, mt as getTransformer, n as authorSpace, na as scope, ni as channel, nn as toBlocks, nr as authorFlows, nt as explainList, o as locateElements, oa as isSuggestionCode, oi as dropdown, on as expandShorthandPatch, or as whenFailed, ot as specToSource, p as compactSvg, pa as elementPartTypes, pi as image, pn as isCustomProperty, pr as announceOn, pt as BUILTIN_TRANSFORMERS, q as darkScheme, qi as resolveSource, qn as runServerAction, qr as elementsFromManifest, qt as isStyleDeclaration, r as fixSpace, ra as AUTHORING_CODES, ri as container, rn as toResponsive, rr as flowStepIds, rt as explanationText, s as planFixes, sa as elementAncestorTypes, si as dropdownPopup, sn as expandShorthandTraced, sr as whenSucceeded, st as SCHEMA_SETTINGS, t as authorSnippet, ta as closest, ti as carouselTrack, tn as sameBlocks, tr as authorFlow, tt as explainKindOf, u as a$2, ua as elementCatalog, ui as form, un as cssProperties, ur as applyBuiltinCallback, ut as actionSpecFromEntry, v as openPage, va as typeCallbackDefinitions, vi as modalContainer, vn as buildHandles, vr as carouselPlay, vt as PAGE_SPEC_FIELDS, w as alignPictures, wa as s, wi as svg, wn as flagSpecOf, wr as on, wt as SpaceRefusedError, x as PAGE_TEXT_LIMIT, xa as a, xi as paragraph, xn as pathForSlug, xr as closeModal, xt as withoutQuieted, y as inspectRenders, ya as typeTriggerDefinitions, yi as nodeHtml, yn as instanceSelectorFor, yr as carouselPrevious, yt as assertSpaceValid, z as CATALOG_TEMPLATE_IDENTITY, zi as GLOBAL_SOURCES, zn as copyToClipboard, zr as reloadApi, zt as column } from "./index-src.js";
|
|
2
|
+
import { n as e$1, r as r$1, t as a$1 } from "./index-declare.js";
|
|
3
|
+
export { AUTHORING_CODES, AuthoringError, BREAKPOINTS, BUILDER_NAMES, a as BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, t as BUILTIN_PARAM_TYPES, BUILTIN_TRANSFORMERS, BUILTIN_UTILITIES, CATALOG_TEMPLATE_IDENTITY, COMPONENT_SOURCES, ELEMENT_FIELDS, EXPLAIN_KINDS, FIXABLE_CODES, GLOBAL_CALLBACK_BUILDERS, GLOBAL_SOURCES, t$1 as MOTION_ENTERS, r as MOTION_LOOPS, n as MOTION_TRIGGERS, i as NOTIFICATIONS_FIELDS, PAGE_SPEC_FIELDS, PAGE_TEXT_LIMIT, SCHEMA_SETTINGS, i$1 as SCROLL_CALLBACKS, SET_STATE_TYPES, SPACE_FIELDS, STYLE_STATES, SpaceRefusedError, actionSource, actionSpecFromEntry, actionToSource, activeOn, activeWhen, addNotification, alignPictures, announceOn, answerAction, apiContainer, appendState, applyBuiltinCallback, s as applyElementCallback, applyUtility, assertSnippetValid, assertSpaceValid, authLogin, authLogout, authRefreshDetails, authorBinding, authorFlow, authorFlows, authorSnippet, authorSpace, authoringCodeEntry, authoringCodesTable, bindTemplate, blankSpace, space as blankSpaceSpec, blankTemplateFiles, blockHtml, blockJsx, buildHandles, button, cancelApi, cancelServerAction, carousel, carouselGoTo, carouselNext, carouselPause, carouselPlay, carouselPrevious, carouselTrack, catalogTemplateFiles, channel, className, classNames, classRefs, clearState, closeDialog, closeModal, closest, column, compactSvg, comparePictures, compareSpaces, compareTexts, component, container, copyToClipboard, createTw, css, cssNumberValue, cssProperties, cssPropertyName, cssShorthands, custom, cycleState, darkScheme, dataIssues, declaredCallback, declaredTrigger, defaultAttributes, defaultLabel, defineAction, defineElement, a$1 as definePlugin, delay, dialogContainer, diffPictures, digest, dropdown, dropdownPopup, element, elementAncestorTypes, elementAttributeNames, elementAttributeValues, elementCallbacks, elementCatalog, r$1 as elementDeclaration, elementDefaultAttributes, elementLeafTypes, elementPartTypes, elementSlots, elementSourceTypes, elementTriggers, elementTypeNames, elementsFromManifest, embed, space$1 as emptySpaceSpec, emptyTemplateFiles, expandShorthand, expandShorthandPatch, expandShorthandTraced, explain, explainKindOf, explainList, explanationText, failedFlowText, familyOf, fixSpace, flagGateOf, flagSpecOf, flowStepIds, fontAwesome, form, formControl, o as getElementCallback, getGlobalCallback, getTransformer, getUtility, grid, groupBindings, hasVisibilityBinding, heading, n$1 as hiddenParams, hiddenWhen, hostAction, image, importProbe, importSlug, importedFiles, inferredLinkMode, inspectDocument, inspectPage, inspectRenders, instanceSelectorFor, s$1 as invalidParams, invalidateQueries, isClassModifier, isClassRef, isCssProperty, isCustomProperty, isRuleSetSpec, isStyleDeclaration, isSuggestionCode, link, lintSpace, list, listItem, loadImages, locate, locateClasses, locateElements, markdown, r$2 as missingRequiredParams, modalContainer, modifierClassName, moveState, named, navigate, nodeHtml, notificationsCss, on, onClick, onFlowEnd, onFlowError, onFlowProgress, onInterval, onKey, onLoad, onPageLoad, onPointerDown, onScreen, onScroll, onSubmit, openDialog, openModal, openPage, pageFamily, pageRegions, pageTexts, pagination, paragraph, pathForSlug, planFixes, pressShortcut, profilePictures, publishOn, readDevTools, readDevToolsInPage, c as reconcileParams, reference, refusalOf, reloadApi, removeState, resetForm, resolveSource, richText, row, runServerAction, runServerActionOrNotify, sameBlocks, scope, scrollBy, scrollIntoView, scrollTo, selectorFor, setFieldValue, setState, shortcutKey, shorthandLonghands, singlePageSpace, slugify, source, e as spaceCallbacks, specFromSpace, specToSource, splitClassList, d as splitNotificationsCss, stepState, styles, suggestClassOverrides, suggestCssProperty, suggestSpace, suggestTransformer, summariseRenders, svg, tabContainer, tabContainerBody, tabContainerHeader, tabContainerItem, taskAction, text, themeToggle, toBindingSpecs, toBlocks, i$2 as toBuilderParams, a$2 as toInteractionCallback, o$1 as toInteractionCallbacks, toPortableSource, toResponsive, toggleElement, toggleInState, toggleState, tokens, transformerCatalog, tw, twig, twigTemplate, typeCallbackDefinitions, typeTriggerDefinitions, unrollPage, unusedDeclarations, updateElement, validateSnippet, validateSpace, e$1 as valuesOf, variantFrom, video, visibleWhen, webHook, when, whenFailed, whenSucceeded, whileRunning, withElement, withNamedIds, withNotificationsCss, withPluginCatalogs, withVisibility, withoutQuieted };
|
package/dist/node.d.ts
CHANGED
|
@@ -1017,9 +1017,19 @@ declare const AUTHORING_CODES: {
|
|
|
1017
1017
|
};
|
|
1018
1018
|
readonly 'repeated-shape': {
|
|
1019
1019
|
readonly kind: "suggested";
|
|
1020
|
-
readonly means: "the same structure written again and again with different words — cards, rows, tiles";
|
|
1020
|
+
readonly means: "the same structure written again and again with different words — cards, rows, tiles; copies that bind different data, read their own template or render on the server are controls, not repeats";
|
|
1021
1021
|
readonly fix: "a component with props (`components`, `component(id, { props })`), or one `list` when they are rows of data side by side — a few cards a person rewords on the canvas can stay cards";
|
|
1022
1022
|
};
|
|
1023
|
+
readonly 'element-color-inherited': {
|
|
1024
|
+
readonly kind: "suggested";
|
|
1025
|
+
readonly means: "`elements` giving a type — a heading, a text, a link — `color: inherit` or the page's own colour, which it takes by itself";
|
|
1026
|
+
readonly fix: "remove it, and name the colour once on `elements.page`: every element reads in the page’s colour, a link’s words included";
|
|
1027
|
+
};
|
|
1028
|
+
readonly 'plugin-custom-host': {
|
|
1029
|
+
readonly kind: "suggested";
|
|
1030
|
+
readonly means: "a `custom` element naming, by `renderType`, a plugin whose declaration the space was handed";
|
|
1031
|
+
readonly fix: "place it from its declaration — `const seatPicker = defineElement(declaration)`, then `seatPicker({ id, … })`: typed by what it declares (a `definePlugin` declaration carries its attributes), the element the builder adds too";
|
|
1032
|
+
};
|
|
1023
1033
|
readonly 'content-attribute': {
|
|
1024
1034
|
readonly kind: "suggested";
|
|
1025
1035
|
readonly means: "a button or a link whose children are only its words and an icon — a `text`, a `fontAwesome` — elements more than it needs";
|
|
@@ -1979,14 +1989,23 @@ declare interface PluginDeclarationData {
|
|
|
1979
1989
|
};
|
|
1980
1990
|
}
|
|
1981
1991
|
|
|
1992
|
+
/** The declaration of every plugin under `folder`, for `authorSpace`'s `plugins`: what each fires, answers and reads. */
|
|
1993
|
+
export declare const pluginDeclarations: (folder: string | URL) => Promise<PluginDeclarationData[]>;
|
|
1994
|
+
|
|
1995
|
+
/** A plugin of the project's own: the folder it is in — the name a space imports its declaration by — and what it declares. */
|
|
1996
|
+
export declare interface PluginFolder {
|
|
1997
|
+
/** The folder's name under the plugins folder: `StatCard`. */
|
|
1998
|
+
name: string;
|
|
1999
|
+
declaration: PluginDeclarationData;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
1982
2002
|
/**
|
|
1983
|
-
*
|
|
1984
|
-
*
|
|
1985
|
-
*
|
|
1986
|
-
*
|
|
1987
|
-
* order, so the same folders always author the same space.
|
|
2003
|
+
* Every plugin under `folder` — `src/plugins/<Name>/declaration.ts`, its default export — with the folder it is in.
|
|
2004
|
+
* Found by folder, as the server finds the plugins themselves, so a plugin is declared by being there and no list can
|
|
2005
|
+
* forget one. A folder without the file is a component and nothing else; one whose default export is not a declaration
|
|
2006
|
+
* is refused, naming the file. In folder order, so the same folders always author the same space.
|
|
1988
2007
|
*/
|
|
1989
|
-
export declare const
|
|
2008
|
+
export declare const pluginFolders: (folder: string | URL) => Promise<PluginFolder[]>;
|
|
1990
2009
|
|
|
1991
2010
|
/** What a project `@plitzi/cli` writes checks its space against: the part of `authorSpace`'s options its files say. */
|
|
1992
2011
|
export declare type ProjectAuthoring = {
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hn as e$1, n as authorSpace, p as compactSvg
|
|
1
|
+
import { Yr as e, hn as e$1, n as authorSpace, p as compactSvg } from "./index-src.js";
|
|
2
2
|
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
3
3
|
import m from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -541,22 +541,27 @@ var publicData = (folder) => fileReader(folder, "/");
|
|
|
541
541
|
*/
|
|
542
542
|
var projectData = (folder) => fileReader(folder, e$1);
|
|
543
543
|
/**
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
* order, so the same folders always author the same space.
|
|
544
|
+
* Every plugin under `folder` — `src/plugins/<Name>/declaration.ts`, its default export — with the folder it is in.
|
|
545
|
+
* Found by folder, as the server finds the plugins themselves, so a plugin is declared by being there and no list can
|
|
546
|
+
* forget one. A folder without the file is a component and nothing else; one whose default export is not a declaration
|
|
547
|
+
* is refused, naming the file. In folder order, so the same folders always author the same space.
|
|
549
548
|
*/
|
|
550
|
-
var
|
|
549
|
+
var pluginFolders = async (folder) => {
|
|
551
550
|
const root = pathOf(folder);
|
|
552
|
-
const
|
|
553
|
-
return Promise.all(
|
|
551
|
+
const names = existsSync(root) ? readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && existsSync(m.join(root, entry.name, "declaration.ts"))).map((entry) => entry.name).sort() : [];
|
|
552
|
+
return Promise.all(names.map(async (name) => {
|
|
553
|
+
const file = m.join(root, name, c$1);
|
|
554
554
|
const loaded = await importProjectModule(file, root);
|
|
555
555
|
const declaration = typeof loaded === "object" && loaded !== null && "default" in loaded ? loaded.default : void 0;
|
|
556
556
|
if (typeof declaration !== "object" || declaration === null || !("type" in declaration) || typeof declaration.type !== "string") throw new Error(`${file} exports no declaration by default: \`export default { type: '…', … }\`.`);
|
|
557
|
-
return
|
|
557
|
+
return {
|
|
558
|
+
name,
|
|
559
|
+
declaration
|
|
560
|
+
};
|
|
558
561
|
}));
|
|
559
562
|
};
|
|
563
|
+
/** The declaration of every plugin under `folder`, for `authorSpace`'s `plugins`: what each fires, answers and reads. */
|
|
564
|
+
var pluginDeclarations = async (folder) => (await pluginFolders(folder)).map(({ declaration }) => declaration);
|
|
560
565
|
/** The manifest of a plugin run as it was built, read; nothing when it cannot be — the layout check says why first. */
|
|
561
566
|
var manifestOf = (file) => {
|
|
562
567
|
try {
|
|
@@ -694,4 +699,4 @@ var authorProjectSpace = async () => {
|
|
|
694
699
|
return authorSpace(space, authoring);
|
|
695
700
|
};
|
|
696
701
|
//#endregion
|
|
697
|
-
export { ProjectModuleError, ProjectSpaceError, authorProjectSpace, compactSvg, moduleProblem, pluginDeclarations, projectAuthoring, projectAuthoringAt, projectData, projectSpace, projectSpaceAt, publicData, svgFile, svgFiles };
|
|
702
|
+
export { ProjectModuleError, ProjectSpaceError, authorProjectSpace, compactSvg, moduleProblem, pluginDeclarations, pluginFolders, projectAuthoring, projectAuthoringAt, projectData, projectSpace, projectSpaceAt, publicData, svgFile, svgFiles };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-authoring",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.12",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/index.js",
|
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"import": "./dist/node.js",
|
|
25
25
|
"default": "./dist/node.js"
|
|
26
26
|
},
|
|
27
|
+
"./plugin": {
|
|
28
|
+
"types": "./dist/plugin.d.ts",
|
|
29
|
+
"import": "./dist/plugin.js",
|
|
30
|
+
"default": "./dist/plugin.js"
|
|
31
|
+
},
|
|
27
32
|
"./skills/*": "./skills/*",
|
|
28
33
|
"./package.json": "./package.json"
|
|
29
34
|
},
|
|
@@ -54,11 +59,11 @@
|
|
|
54
59
|
"devDependencies": {
|
|
55
60
|
"@microsoft/api-extractor": "^7.59.3",
|
|
56
61
|
"@plitzi/plitzi-ui": "^1.6.33",
|
|
57
|
-
"@plitzi/sdk-elements": "0.38.
|
|
58
|
-
"@plitzi/sdk-interactions": "0.38.
|
|
59
|
-
"@plitzi/sdk-schema": "0.38.
|
|
60
|
-
"@plitzi/sdk-shared": "0.38.
|
|
61
|
-
"@plitzi/sdk-style": "0.38.
|
|
62
|
+
"@plitzi/sdk-elements": "0.38.12",
|
|
63
|
+
"@plitzi/sdk-interactions": "0.38.12",
|
|
64
|
+
"@plitzi/sdk-schema": "0.38.12",
|
|
65
|
+
"@plitzi/sdk-shared": "0.38.12",
|
|
66
|
+
"@plitzi/sdk-style": "0.38.12",
|
|
62
67
|
"@types/react": "^19.3.0",
|
|
63
68
|
"eslint": "^9.39.5",
|
|
64
69
|
"prettier": "^3.9.9",
|
|
@@ -55,7 +55,7 @@ form({ id, managedByInteractions: true, flows, children })
|
|
|
55
55
|
formControl({ name: 'email', label: 'Email', subType: 'email', required: true }) // optional without required; select: options: [{ label, value }]
|
|
56
56
|
modalContainer({ id, visible: false, title, children })
|
|
57
57
|
component('card', { props: { title }, children: { body: [ … ] } })
|
|
58
|
-
|
|
58
|
+
const seats = defineElement(seatsDeclaration); seats({ id }) // a plugin
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
## Styles
|
|
@@ -11,18 +11,20 @@ import {
|
|
|
11
11
|
onClick,
|
|
12
12
|
setState
|
|
13
13
|
} from '@plitzi/sdk-authoring';
|
|
14
|
+
import { definePlugin } from '@plitzi/sdk-authoring/plugin';
|
|
14
15
|
|
|
15
16
|
import type { PluginDeclarationData, SpaceSpec } from '@plitzi/sdk-authoring';
|
|
16
17
|
|
|
17
|
-
// In a project
|
|
18
|
-
const declaration = {
|
|
18
|
+
// In a project, `src/plugins/SeatPicker/declaration.ts` — `export default definePlugin<SeatPickerAttributes>()({ … })`.
|
|
19
|
+
const declaration = definePlugin<{ rows?: number }>()({
|
|
19
20
|
type: 'seatPicker',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
21
|
+
label: 'Seat Picker',
|
|
22
|
+
attributes: { rows: 10 },
|
|
23
|
+
triggers: { onPick: { preview: { seat: '' } } },
|
|
24
|
+
callbacks: { reset: {} }
|
|
25
|
+
});
|
|
24
26
|
|
|
25
|
-
const seatPicker = defineElement
|
|
27
|
+
const seatPicker = defineElement(declaration);
|
|
26
28
|
|
|
27
29
|
// `authorSpace(recipe, { plugins })` — in a project, every `src/plugins/<Name>/declaration.ts`, found by folder.
|
|
28
30
|
export const plugins: PluginDeclarationData[] = [declaration];
|
|
@@ -234,11 +234,13 @@ Nothing is wrong: the page renders as written. Each is a shorter way to the same
|
|
|
234
234
|
| `custom-css-notifications` | the toasts or their icon, close button or progress bar dressed with `.Toastify__*` rules in `customCss` | `notifications: { font, fontSize, fontWeight, minHeight, iconSize, closeColor, progressHeight, … }` |
|
|
235
235
|
| `custom-css-sdk-default` | `customCss` repeating what the SDK already does for every space — less motion when asked, the theme toggle showing one icon | nothing: remove it |
|
|
236
236
|
| `custom-css-slot` | a part of a built-in element dressed in `customCss` by the SDK's markup — a form control's `<input>`, a pager's buttons, a heading inside a markdown | a class on the slot of that part — `slots: { field: input }`, `elements.<type>.slots` — with its states |
|
|
237
|
+
| `element-color-inherited` | `elements` giving a type — a heading, a text, a link — `color: inherit` or the page's own colour, which it takes by itself | remove it, and name the colour once on `elements.page`: every element reads in the page’s colour, a link’s words included |
|
|
237
238
|
| `heavy-animation` | keyframes animating what the browser repaints or lays out again on every frame — a size, a position, a blur, a shadow, or a colour in a loop — which stutters whenever the page is busy, most of all while it loads | `opacity` and `transform`: a size or a position is `translate`/`scale`, a blur or a shadow is the `opacity` of a layer carrying it; a loop that must animate anything else starts `paused` and runs under `[data-hydrated]` |
|
|
238
239
|
| `literal-colour` | a colour written out in a class where the space has a token of that value — it stays put in the dark scheme | `var(--token)` when it should follow the scheme; a token of one value of its own when it must stay the same in both |
|
|
239
240
|
| `not-found-page` | a space with no page of its own for an address no other page answers — a plain one was added, in the home page’s layout, sent with status 404 | a page whose slug is `'*'`: `{ id: 'not-found', name: 'Not found', slug: '*', layout: …, body: [...] }` |
|
|
241
|
+
| `plugin-custom-host` | a `custom` element naming, by `renderType`, a plugin whose declaration the space was handed | place it from its declaration — `const seatPicker = defineElement(declaration)`, then `seatPicker({ id, … })`: typed by what it declares (a `definePlugin` declaration carries its attributes), the element the builder adds too |
|
|
240
242
|
| `repeated-on-pages` | the same block — a header, a footer, a side panel — written into several pages | a layout holding it once (`layouts`, and `layout: { id, slot }` on each page) — a component when only some pages of a layout carry it; a link marks its own page with the `current` state |
|
|
241
|
-
| `repeated-shape` | the same structure written again and again with different words — cards, rows, tiles | a component with props (`components`, `component(id, { props })`), or one `list` when they are rows of data side by side — a few cards a person rewords on the canvas can stay cards |
|
|
243
|
+
| `repeated-shape` | the same structure written again and again with different words — cards, rows, tiles; copies that bind different data, read their own template or render on the server are controls, not repeats | a component with props (`components`, `component(id, { props })`), or one `list` when they are rows of data side by side — a few cards a person rewords on the canvas can stay cards |
|
|
242
244
|
| `unused-class` | a class declared in `classes` that no element, binding, flow or other class names | remove it from `classes` — or wear it where it was meant to go |
|
|
243
245
|
| `unused-component` | a component no page, layout or other component places | remove it from `components`, or place it where it was meant to go |
|
|
244
246
|
| `unused-token` | a token of `variables` no `var(--…)` reads — not a class, an element, `customCss` nor another token | remove it, or write it where its colour is written out |
|
|
@@ -73,7 +73,7 @@ indented with space below it: `{ margin: '0px', padding: '0px' }` on its class t
|
|
|
73
73
|
children sit in the parent's layout and a `class` on it styles nothing (`STYLE_WITHOUT_TAG`). Put the layout on the
|
|
74
74
|
parent, or give it `attributes: { subType: 'div' }`.
|
|
75
75
|
|
|
76
|
-
A plugin's type is authored the same way: `defineElement
|
|
76
|
+
A plugin's type is authored the same way: `defineElement(declaration)` — see [plugins](plugins.md).
|
|
77
77
|
|
|
78
78
|
**What a type takes:** `npx @plitzi/cli explain formControl`, or the exported catalogues ([validation.md](validation.md)).
|
|
79
79
|
|
|
@@ -69,8 +69,7 @@ A step's params are templates, evaluated in full (conditions, loops, filters). A
|
|
|
69
69
|
a row's button posts `{ jobId: '{{ list_jobRows.item.id }}' }` — the row that was clicked; the short name is refused.
|
|
70
70
|
|
|
71
71
|
**Pass objects, not JSON text.** `input: { title: '{{ form.values.title }}' }` rather than `input: '{"title": …}'`:
|
|
72
|
-
each value keeps its own type, and nothing depends on the quoting.
|
|
73
|
-
is escaped for it — but an object needs no punctuation.)
|
|
72
|
+
each value keeps its own type, and nothing depends on the quoting.
|
|
74
73
|
|
|
75
74
|
**A field left empty is not in `values`.** A form sends what was typed, and a field nobody typed in sends nothing —
|
|
76
75
|
so `when({ field: 'sent.values.code', operator: '=', value: '' }, …)` never holds for it. Ask
|
|
@@ -106,7 +105,7 @@ ticks while the element is mounted and the tab is in view, never in the builder
|
|
|
106
105
|
|
|
107
106
|
**A number that goes round, or stops:** `cycleState({ key: 'slide', length: 4 })` is "next" — after the last the first
|
|
108
107
|
— and `by: -1` "previous"; `stepState({ key: 'shown', by: 40, max: 'apiContainer_site.data.total' })` adds and stops
|
|
109
|
-
at the bound.
|
|
108
|
+
at the bound.
|
|
110
109
|
|
|
111
110
|
**Scrolling** is a step on the element whose box scrolls (`overflow-x: auto` on a row of cards): `scrollBy('cards',
|
|
112
111
|
{ x: '80%' })` moves it by most of what it shows (`'-80%'` back, `'240'` pixels), `scrollTo('cards', { x: 'end' })`
|
|
@@ -165,6 +164,8 @@ Pages that see each other — cursors, presence, a shared board — talk over a
|
|
|
165
164
|
asks it. `appendState({ key, value, withId: true })` stores `{ id, value }` — bind `.value`, address by `.id`.
|
|
166
165
|
`whenFailed` matches every outcome that is not `completed` (also `skipped`, `aborted`). A failed run gives `reason`,
|
|
167
166
|
and `error` only when the server or a step wrote one for the caller (a task throwing `ActionRefusal`, `flow.fail` with
|
|
168
|
-
`tellCaller`) — so show `{{ saved.error ? saved.error : "…" }}`, never the bare `error`.
|
|
167
|
+
`tellCaller`) — so show `{{ saved.error ? saved.error : "…" }}`, never the bare `error`. That pair is one call:
|
|
168
|
+
`...runServerActionOrNotify('saved', { actionId, input }, 'Could not save')` — the named run, then that toast
|
|
169
|
+
(`{ appearance, placement }` fourth).
|
|
169
170
|
|
|
170
171
|
`when(rule, step)` around a step that already has a `when` adds to it: both must hold.
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
# Plugins
|
|
2
2
|
|
|
3
|
-
A plugin is a React component of the project's own — a chart, a map, a game —
|
|
4
|
-
|
|
3
|
+
A plugin is a React component of the project's own — a chart, a map, a game — and an element type of its own. The
|
|
4
|
+
space places it from its `declaration.ts`, typed by what it declares:
|
|
5
5
|
|
|
6
6
|
```ts
|
|
7
|
-
|
|
7
|
+
const nebulaRun = defineElement(nebulaRunDeclaration);
|
|
8
|
+
nebulaRun({ id: 'arcade', shipColor: 'amber', bind: { best: 'state.arcadeBest' } })
|
|
8
9
|
```
|
|
9
10
|
|
|
11
|
+
(`custom({ renderType })` is for a component registered by name, with no declaration.)
|
|
12
|
+
|
|
10
13
|
## Creating one
|
|
11
14
|
|
|
12
15
|
The CLI writes it, in the shape Plitzi's own elements are written in: `npx @plitzi/cli plugin add seat-picker` (a
|
|
13
16
|
package of its own and packing it: the CLI skill).
|
|
14
17
|
|
|
15
|
-
One folder, four files: `SeatPicker.tsx` (the component), `declaration.ts` (its
|
|
16
|
-
`
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`
|
|
18
|
+
One folder, four files: `SeatPicker.tsx` (the component), `declaration.ts`, `Settings.tsx` (its panel in the builder),
|
|
19
|
+
and `index.ts` (`Object.assign(Component, declaration, { pluginSettings: Settings })`). The declaration is data only,
|
|
20
|
+
`definePlugin<SeatPickerAttributes>()({ type, label, attributes, triggers, callbacks })` from
|
|
21
|
+
`@plitzi/sdk-authoring/plugin`: the rest of what the builder needs is derived. An event or an action is declared there
|
|
22
|
+
and registered by the component from there, never only in the component.
|
|
23
|
+
|
|
24
|
+
A plugin fires its events with `const fire = usePluginTrigger(declaration)` (`@plitzi/plitzi-sdk`), typed by the
|
|
25
|
+
declaration: `fire('onPick', { seat })` — an undeclared event, or a payload missing a field its `preview` names, does
|
|
26
|
+
not compile. Nothing fires while the page is edited. Fire whenever there is news — from the first effect too: a flow
|
|
27
|
+
starts once the page has finished mounting, so the `setState` it calls is there. No `queueMicrotask` or delay of your
|
|
28
|
+
own. An event that REPORTS a state, and may fire again before its flow ends (as a
|
|
23
29
|
component reads its real value right after mounting), wants `whileRunning('queue', …)` on the flow: by default a firing
|
|
24
30
|
while the flow runs is dropped, and the stale first report would stick.
|
|
25
31
|
|
|
26
32
|
## Props
|
|
27
33
|
|
|
28
|
-
**The
|
|
34
|
+
**The element's attributes ARE the component's props.** Whatever the space writes on it arrives
|
|
29
35
|
by the same name, and so does whatever a binding writes — which is what makes a plugin live: bind an attribute to
|
|
30
36
|
`state`, a provider or a row, and the component re-renders with the answer. Prefer this to anything else.
|
|
31
37
|
|
|
@@ -34,6 +40,8 @@ panel edits for a plugin it has no controls for; from code, write attributes. A
|
|
|
34
40
|
"Settings Malformed" in the page.
|
|
35
41
|
|
|
36
42
|
Every prop is optional with a default: an attribute not authored yet, or a binding not answered yet, is `undefined`.
|
|
43
|
+
One whose declared default is a number or a boolean arrives as one, written or bound: type it `number`, never
|
|
44
|
+
`number | string`.
|
|
37
45
|
|
|
38
46
|
## The component
|
|
39
47
|
|
|
@@ -73,7 +81,7 @@ on ([kept state](kept-state.md)), what a plugin writes there — its layout, a c
|
|
|
73
81
|
## Laying out the space's elements
|
|
74
82
|
|
|
75
83
|
A plugin that arranges elements — a dock, tabs, a masonry — HOLDS them: they are its children in the space
|
|
76
|
-
(`
|
|
84
|
+
(`dock({ id: 'dock', children: [feed, tools] })`, or dropped into it in the builder), and the component
|
|
77
85
|
places each in a box of its own, by the id it was authored under:
|
|
78
86
|
|
|
79
87
|
```tsx
|
|
@@ -138,16 +146,15 @@ with thousands of shapes fast — see [drawing](drawing.md).
|
|
|
138
146
|
## Registering
|
|
139
147
|
|
|
140
148
|
A project `plitzi create` wrote registers every folder of `src/plugins` by itself, under the folder's name in
|
|
141
|
-
camelCase (`StatCard` → `statCard`). Anywhere else, the entry registers the component under its
|
|
142
|
-
third argument to `render()`, `<PlitziSdk.Plugin>` in a React application, `plugins` on a page server of your own. A
|
|
143
|
-
renders "Custom Component … Not Found", and a page server logs
|
|
144
|
-
|
|
149
|
+
camelCase (`StatCard` → `statCard`): its type. Anywhere else, the entry registers the component under its type: the
|
|
150
|
+
third argument to `render()`, `<PlitziSdk.Plugin>` in a React application, `plugins` on a page server of your own. A
|
|
151
|
+
type nothing registered renders "Custom Component … Not Found", and a page server logs it at `error` once per space:
|
|
152
|
+
on a server, register it in `plugins` AND name it in the deployment's `pluginNames`.
|
|
145
153
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
`defineElement
|
|
149
|
-
|
|
150
|
-
`element('seatPicker', { id: 'seats', start: 3 })`.
|
|
154
|
+
On Plitzi, every element loads from the plugin the space installed (`plitzi plugin pack` and `upload`: several folders
|
|
155
|
+
are one plugin). A plugin PACKAGE is placed the same way:
|
|
156
|
+
`defineElement` from its `declaration.ts`, or `elementsFromManifest<{ seatPicker: SeatPickerAttributes }>(manifest)`
|
|
157
|
+
from what it published.
|
|
151
158
|
|
|
152
159
|
## Checked like a built-in element
|
|
153
160
|
|
|
@@ -160,11 +167,10 @@ import declaration from './plugins/SeatPicker/declaration';
|
|
|
160
167
|
authorSpace(space, { plugins: [declaration] });
|
|
161
168
|
```
|
|
162
169
|
|
|
163
|
-
It is then held to what it declares
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
judged on its events at all — nothing here knows them.
|
|
170
|
+
It is then held to what it declares: a flow on an event it never fires, a step sent to an action it does not answer,
|
|
171
|
+
an attribute it does not read — each is refused with the name it should have been. (`pluginTypes: ['seatPicker']`
|
|
172
|
+
only tells the linter the type exists; nothing about how the space uses it is checked.) A plugin whose declaration is
|
|
173
|
+
NOT handed over is not judged on its events at all — nothing here knows them.
|
|
168
174
|
|
|
169
175
|
Its events and actions have builders typed from the same declaration, so a name it does not declare is a compile error:
|
|
170
176
|
|
|
@@ -175,9 +181,9 @@ button({ content: 'Clear', flows: [[onClick(), declaredCallback(declaration, 're
|
|
|
175
181
|
|
|
176
182
|
A plugin says what HAPPENED through its events (`onPick`, with the seat in the payload) and lets the space's flows
|
|
177
183
|
decide what that means — write `state`, open a modal, call a server action. Prefer that to writing `state` from inside
|
|
178
|
-
the component: the flow is visible in the space,
|
|
184
|
+
the component: the flow is visible in the space, and a button can do the same.
|
|
179
185
|
|
|
180
|
-
-
|
|
186
|
+
- An action's param declared `number` or `boolean` arrives as one, written or bound; any other arrives as written.
|
|
181
187
|
- To act when another element appears, `useElementVisible('tools')` (`@plitzi/plitzi-sdk`) — never watch classes.
|
|
182
188
|
- A name for screen readers is a prop of its own: declare `label`, write it as the root's `aria-label`.
|
|
183
189
|
|
|
@@ -186,14 +192,14 @@ the component: the flow is visible in the space, the builder shows it, and the s
|
|
|
186
192
|
The builder draws the element on its canvas while somebody edits the page: a click selects it, a drag moves it, a key
|
|
187
193
|
belongs to the editor.
|
|
188
194
|
|
|
189
|
-
- **Outside preview, do nothing on your own.** `
|
|
190
|
-
page is edited
|
|
191
|
-
|
|
195
|
+
- **Outside preview, do nothing on your own.** `usePlitzi().settings.previewMode` is `false` while the
|
|
196
|
+
page is edited: gate your own click handlers, timers, listeners, permission prompts and map gestures on it, and
|
|
197
|
+
still render something to select.
|
|
192
198
|
- **A drag lives in state, not in refs read while rendering** (the project's lint refuses that): keep the gesture
|
|
193
199
|
in `useState`, mirror the latest props into a ref inside an effect, and attach `pointermove` on `pointerdown`.
|
|
194
200
|
- **Never the global `window` or `document`.** The canvas is a frame of its own and the code runs in the builder's
|
|
195
201
|
window: listen, measure and go full screen through the node's own page (`ref.current.ownerDocument`, its
|
|
196
|
-
`defaultView`) or `
|
|
202
|
+
`defaultView`) or `usePlitzi().utils.getWindow()`. An `instanceof` check takes its class from there too.
|
|
197
203
|
|
|
198
204
|
## The plugin's stylesheet and the space's CSS
|
|
199
205
|
|
|
@@ -209,5 +215,4 @@ fonts a stylesheet names are carried the same way.
|
|
|
209
215
|
A map, a chart library, anything that positions its own markers or popups: its roots are the library's to place. Never
|
|
210
216
|
give them a class that sets `position` — the element falls into the page's flow, offset by every marker before it. Put
|
|
211
217
|
the look in the plugin's own stylesheet (imported CSS ships beside the bundle) and take colours from custom properties
|
|
212
|
-
the space sets (`--seat-accent: var(--accent)` in `customCss`)
|
|
213
|
-
element with `getComputedStyle(probe).color`, again whenever `theme.resolved` changes (bind it as a prop).
|
|
218
|
+
the space sets (`--seat-accent: var(--accent)` in `customCss`).
|
|
@@ -50,7 +50,7 @@ refuses or warns of, with the fix.
|
|
|
50
50
|
every switch through `computed` (`plates: '{{ state.platesOff ? false : true }}'`) so its default shows before
|
|
51
51
|
anybody touches it.
|
|
52
52
|
12. **Hand plugins over as their declarations**: `authorSpace(space, { plugins: [declaration] })` holds a plugin —
|
|
53
|
-
|
|
53
|
+
placed with `defineElement(declaration)` — to the events, actions and attributes it declares. See
|
|
54
54
|
[plugins](plugins.md).
|
|
55
55
|
13. **Usable without sight.** Screen readers and browser agents (Claude in Chrome) find a page's controls in its
|
|
56
56
|
accessibility tree: every button and link has words (an icon-only button a `title`), every field a `label`
|