@nextlyhq/plugin-sdk 0.0.2-alpha.50 → 0.0.2-alpha.51

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/dist/admin.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { BulkAction, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardProps, CardTitle, CellContext, CellRenderer, CellRendererDefinition, ColumnProvider, ColumnTransform, ComponentPath, DataTable, DataTableContext, DataTableProps, DataTableSelection, DataTableTarget, DataTableView, DataTableViewProps, FieldDefaultOption, FieldDefaultValueInput, FieldDefaultValueInputProps, FieldOption, FieldOptionsEditor, FieldOptionsEditorProps, FieldTypePicker, FieldTypePickerProps, Grid, GridProps, NextlyColumn, NextlyFieldSchema, NextlyFieldType, RowAction, Stack, StackProps, Stat, StatProps, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, transformColumns, usePluginFieldTypeEntries, withOptionIds } from '@nextlyhq/admin';
1
+ export { BulkAction, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardProps, CardTitle, CellContext, CellRenderer, CellRendererDefinition, ColumnProvider, ColumnTransform, ComponentPath, ConditionOperatorName, ConditionRange, ConditionRow, ConditionRowProps, ConditionSource, ConditionSourceOption, ConditionValue, DataTable, DataTableContext, DataTableProps, DataTableSelection, DataTableTarget, DataTableView, DataTableViewProps, FieldDefaultOption, FieldDefaultValueInput, FieldDefaultValueInputProps, FieldOption, FieldOptionsEditor, FieldOptionsEditorProps, FieldTypePicker, FieldTypePickerProps, Grid, GridProps, NextlyColumn, NextlyFieldSchema, NextlyFieldType, RowAction, Stack, StackProps, Stat, StatProps, operatorTakesValue, operatorsForType, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, transformColumns, usePluginFieldTypeEntries, withOptionIds } from '@nextlyhq/admin';
2
2
  export { PluginAdminContributions, PluginAdminPage, PluginCollectionView, PluginMenuItem } from 'nextly';
3
- import '@nextlyhq/blocks-engine';
4
3
  import 'nextly/testing';
package/dist/admin.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, DataTable, DataTableView, FieldDefaultValueInput, FieldOptionsEditor, FieldTypePicker, Grid, Stack, Stat, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, transformColumns, usePluginFieldTypeEntries, withOptionIds } from '@nextlyhq/admin';
1
+ export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ConditionRow, DataTable, DataTableView, FieldDefaultValueInput, FieldOptionsEditor, FieldTypePicker, Grid, Stack, Stat, operatorTakesValue, operatorsForType, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, transformColumns, usePluginFieldTypeEntries, withOptionIds } from '@nextlyhq/admin';
2
2
  //# sourceMappingURL=admin.mjs.map
3
3
  //# sourceMappingURL=admin.mjs.map
package/dist/blocks.d.ts CHANGED
@@ -1 +1,288 @@
1
- export { AnyBlockDefinition, BlockDefinition, BlockRenderArgs, BlockRenderResult, BlockSupports, InferBlockProps, PropSchema, SupportDefinition, defineBlock } from '@nextlyhq/blocks-engine';
1
+ import { BlockDefinition as BlockDefinition$1, BlockRenderArgs as BlockRenderArgs$1 } from '@nextlyhq/blocks-engine';
2
+ export { AnyBlockDefinition, BlockEditorMeta, BlockExample, BlockVariation, ComponentPath, InferBlockProps, NodeStyles, PropSchema, SlotLock, SlotSpec, SupportDefinition } from '@nextlyhq/blocks-engine';
3
+ import { ReactNode } from 'react';
4
+
5
+ /**
6
+ * Block authoring — the contracts a plugin contributing blocks to the page
7
+ * builder needs.
8
+ *
9
+ * A subpath rather than the SDK's main entry, so a plugin that has nothing to
10
+ * do with blocks never pulls the block engine into its type graph. The SDK
11
+ * remains the single stable import surface a plugin author is offered; this
12
+ * simply keeps a page-builder-specific vocabulary out of everyone else's way.
13
+ *
14
+ * The engine is a real dependency of this package rather than an optional peer,
15
+ * because the types below are built on top of its own: they have to resolve for
16
+ * an author who installed only the SDK, and under a strict `node_modules`
17
+ * layout the page builder's copy is not reachable from their package. The
18
+ * engine's registry is pinned to `globalThis`, so even a duplicated install
19
+ * still reads and writes the one registry the page builder consumes.
20
+ *
21
+ * What an author writes is declared here rather than re-exported. `defineBlock`
22
+ * and `BlockSupports` are this module's own so that `BlockSupportKeys` can be
23
+ * augmented from a plugin's source, which only works for a module that plugin
24
+ * can name.
25
+ *
26
+ * The registration side is not here. Contributing a block means calling the
27
+ * page builder's own service — it is that plugin's registry, not core's — so
28
+ * `blockRegistry` comes from `@nextlyhq/plugin-page-builder/blocks`, which is
29
+ * also where a contributor already declares its `dependsOn`.
30
+ *
31
+ * @packageDocumentation
32
+ */
33
+
34
+ /**
35
+ * The support keys a block may declare.
36
+ *
37
+ * Declared HERE rather than in the engine, and that placement is the whole
38
+ * point. A module augmentation has to name a module that resolves from the file
39
+ * doing the augmenting, and a plugin author installs this package: under a
40
+ * strict `node_modules` layout the engine is a nested transitive dependency
41
+ * their own source cannot name, so an augmentation pointed at it fails to
42
+ * compile and the custom support silently never arrives.
43
+ *
44
+ * A plugin that calls `registerSupport()` adds its key to the vocabulary the
45
+ * compiler checks against:
46
+ *
47
+ * ```ts
48
+ * declare module "@nextlyhq/plugin-sdk/blocks" {
49
+ * interface BlockSupportKeys {
50
+ * animation: "enter" | "exit";
51
+ * parallax: true;
52
+ * }
53
+ * }
54
+ * ```
55
+ *
56
+ * Declaration merging rather than an index signature: an index signature accepts
57
+ * every key, which is what leaves a misspelled `spaceing` to be found at boot,
58
+ * in someone else's app, instead of while it is being written.
59
+ *
60
+ * One rule reads the value: a union of strings names the sub-flags the support
61
+ * recognises, and anything else means the support is all-or-nothing. So a nested
62
+ * typo is caught in the same breath as a top-level one — `{ spacing: { paddding:
63
+ * true } }` enables nothing at all, and finding that out at boot is exactly what
64
+ * this exists to prevent — while a support with no finer granularity can be
65
+ * written the way it reads, as `never` or as `true`.
66
+ *
67
+ * The built-in keys are the style catalog's groups plus the capabilities that
68
+ * have no catalog group of their own. A test holds both the keys and their
69
+ * flags to what the registry actually accepts, so the two cannot drift.
70
+ *
71
+ * @experimental Carried by the same freeze as `defineBlock`.
72
+ */
73
+ interface BlockSupportKeys {
74
+ /** Padding and margin. */
75
+ spacing: "margin" | "padding";
76
+ /** Flow, alignment and gap. */
77
+ layout: never;
78
+ /** Width, height and their limits. */
79
+ dimensions: never;
80
+ /** Font, size, weight, line height and letter spacing. */
81
+ typography: never;
82
+ /** Text and link colours. */
83
+ color: "text" | "link";
84
+ /** Background colour, image and gradient. */
85
+ background: "color" | "image" | "gradient";
86
+ /** Border lines and corner rounding. */
87
+ border: "line" | "radius";
88
+ /** Box and text shadows. */
89
+ shadow: never;
90
+ /** Opacity, filters and transforms. */
91
+ effects: never;
92
+ /** Positioning and stacking. */
93
+ position: never;
94
+ /** Container-query behaviour. */
95
+ container: never;
96
+ /** Author-written CSS on this block. Gates a capability, not a style group. */
97
+ customCss: never;
98
+ }
99
+ /**
100
+ * What one support key accepts, given the sub-flags it declares.
101
+ *
102
+ * The two cases are kept apart rather than both handed to `Record`, because
103
+ * `Record` demands a property key and a support that declares no flags has none
104
+ * to give. Feeding it either sentinel is unsound in opposite directions: `true`
105
+ * is not a property key at all, so the mapped type stops instantiating and an
106
+ * augmenting plugin's build fails on the declaration rather than on anything it
107
+ * wrote; `never` produces `Partial<Record<never, boolean>>`, which is `{}`, and
108
+ * `{}` accepts every object — so `{ layout: { typo: true } }` type-checks and is
109
+ * refused only later, by the registry, at boot.
110
+ *
111
+ * `[F] extends [never]` is asked first and in tuple form. Bare `F extends never`
112
+ * distributes and answers for the empty union rather than about it, and
113
+ * `[never] extends [string]` is true, so a `never` reaching the string case
114
+ * would rebuild the same `{}`.
115
+ */
116
+ type SupportSetting<F> = [F] extends [never] ? boolean : [F] extends [string] ? boolean | Partial<Record<F & string, boolean>> : boolean;
117
+ /**
118
+ * Style capabilities a block opts into: `true` for a whole group, or an object
119
+ * naming the sub-flags it wants.
120
+ *
121
+ * @experimental Carried by the same freeze as `defineBlock`.
122
+ */
123
+ type BlockSupports = {
124
+ [K in keyof BlockSupportKeys]?: SupportSetting<BlockSupportKeys[K]>;
125
+ };
126
+ /**
127
+ * Supports as written at a definition, with unknown keys refused.
128
+ *
129
+ * TypeScript checks for excess properties only on a literal written in place,
130
+ * so lifting settings into a shared object skips it: `const shared = { spacing:
131
+ * true, spaceing: true }` assigns to `BlockSupports` without complaint, and the
132
+ * typo survives to be caught at boot in someone else's app — which is the whole
133
+ * failure this vocabulary exists to move earlier.
134
+ *
135
+ * Naming the offending key as `never` refuses it wherever it was written.
136
+ */
137
+ type ExactSupports<S> = S & {
138
+ [K in Exclude<keyof S, keyof BlockSupportKeys>]: never;
139
+ };
140
+ /**
141
+ * Everything a renderer makes available to every block it draws.
142
+ *
143
+ * ONE description per app, rather than each block inventing its own. A block
144
+ * author writes `defineBlock<MyProps>` and `ctx` is already typed as whatever
145
+ * this app's renderer provides, with no type written by hand; a block that
146
+ * needs something unusual has to add it here, which is an app-wide statement
147
+ * anyone can see rather than a quiet assumption inside one file.
148
+ *
149
+ * A renderer declares what it supplies by augmenting this from its own package:
150
+ *
151
+ * ```ts
152
+ * declare module "@nextlyhq/plugin-sdk/blocks" {
153
+ * interface BlockRenderContext {
154
+ * data?: DataProvider;
155
+ * }
156
+ * }
157
+ * ```
158
+ *
159
+ * `locale` is here because every renderer of localized content has one, and a
160
+ * block that varies its own output by language should not have to reach past
161
+ * this interface to find out which.
162
+ *
163
+ * @experimental Carried by the same freeze as `defineBlock`.
164
+ */
165
+ interface BlockRenderContext {
166
+ /** The locale being rendered, when the renderer is rendering one. */
167
+ locale?: string;
168
+ }
169
+ /**
170
+ * What a block's `render` receives.
171
+ *
172
+ * The engine's own version leaves both the context and the output unnamed,
173
+ * because the engine serves any renderer and cannot know either. This one names
174
+ * both: the context is what THIS app's renderer provides, which is what lets a
175
+ * block read `ctx.data` with no type written by hand, and the output is React,
176
+ * which is what lets a block place a slot straight into its JSX instead of
177
+ * asserting a type over it.
178
+ *
179
+ * @experimental Carried by the same freeze as `defineBlock`.
180
+ */
181
+ interface BlockRenderArgs<P> extends Omit<BlockRenderArgs$1<P, BlockRenderContext>, "renderSlot"> {
182
+ /**
183
+ * Render one of this block's slots, optionally under a different context.
184
+ *
185
+ * `ReactNode` rather than the `ReactNode | Promise<ReactNode>` that `render`
186
+ * returns, and the asymmetry is deliberate: this value is one a block places
187
+ * into its own JSX, and that union is not a legal child under EITHER supported
188
+ * peer. React 18 admits no promise at all; React 19 admits only
189
+ * `Promise<AwaitedReactNode>`, a promise of a settled node, so a promise that
190
+ * may itself yield a promise is refused there too. Widening here would move
191
+ * the error onto every block that draws a slot.
192
+ *
193
+ * It still says what each peer can express, because React 19 counts
194
+ * `Promise<AwaitedReactNode>` as a `ReactNode`: a renderer on 19 may hand back
195
+ * a pending slot and the block places it unchanged. On 18 it may not, which
196
+ * costs nothing, since an async block cannot be drawn under React 18's types
197
+ * regardless — `<AsyncBlock />` is refused outright there.
198
+ */
199
+ renderSlot(this: void, name: string, ctx?: BlockRenderContext): ReactNode;
200
+ }
201
+ /**
202
+ * One block type, as an author writes it.
203
+ *
204
+ * The engine's own definition leaves `supports` open, because its registry holds
205
+ * blocks from every source and checks their keys at boot against whatever is
206
+ * registered. Authoring is the moment a typo is cheap to catch, so this narrows
207
+ * that one member and changes nothing else.
208
+ *
209
+ * @experimental Carried by the same freeze as `defineBlock`.
210
+ */
211
+ interface BlockDefinition<P extends object = Record<string, unknown>> extends Omit<BlockDefinition$1<P, BlockRenderContext>, "supports" | "render"> {
212
+ supports?: BlockSupports;
213
+ /**
214
+ * Renders the block.
215
+ *
216
+ * The promise is spelled out rather than left to `ReactNode`. React 19 added
217
+ * promises to that type and React 18 did not, and this package supports both,
218
+ * so an async block would compile against one peer and be rejected by the
219
+ * other. Naming it here makes the async contract mean the same thing across
220
+ * the range this package declares.
221
+ */
222
+ render(args: BlockRenderArgs<P>): BlockRenderResult;
223
+ }
224
+ /**
225
+ * Declare a block.
226
+ *
227
+ * Returns its argument. It exists to infer the prop type from what is written
228
+ * and to check the rest against the definition shape, which is what makes a
229
+ * mistyped prop name or an unknown support key a compile error rather than a
230
+ * boot one.
231
+ *
232
+ * There is deliberately no per-block context parameter. What a renderer
233
+ * provides is one description per app, and a block that needs something unusual
234
+ * declares it on `BlockRenderContext` where the whole app can see it. A block
235
+ * naming its own context would be asserting privately that it will be handed
236
+ * something, which nothing checks and no registry can honour.
237
+ *
238
+ * @experimental The block API is frozen at the end of the engine phase, not
239
+ * now. Until then a contributed block may need changes when the definition
240
+ * shape settles.
241
+ */
242
+ declare function defineBlock<P extends object>(definition: BlockDefinition<P>): BlockDefinition<P>;
243
+ /**
244
+ * Supports settings meant to be shared between blocks.
245
+ *
246
+ * Written straight into a definition, a typo is caught: TypeScript checks a
247
+ * literal for keys the target does not declare. Lifted into a variable first,
248
+ * it is not, because that check applies only where the literal is written. This
249
+ * puts the check back at the declaration, which is where the settings are.
250
+ *
251
+ * ```ts
252
+ * const layoutSupports = blockSupports({ spacing: true, layout: true });
253
+ * defineBlock<MyProps>({ …, supports: layoutSupports });
254
+ * ```
255
+ *
256
+ * `satisfies BlockSupports` does the same thing and needs nothing from this
257
+ * package; the helper exists because it reads as the obvious move and cannot be
258
+ * forgotten halfway through.
259
+ *
260
+ * It cannot live on `defineBlock` itself: catching this needs the supplied
261
+ * object's own keys inferred, and TypeScript infers nothing once any type
262
+ * argument is written by hand, so `defineBlock<MyProps>` — the form nearly
263
+ * every block uses — would stop checking anything at all.
264
+ *
265
+ * @experimental Carried by the same freeze as `defineBlock`.
266
+ */
267
+ declare function blockSupports<S extends BlockSupports>(supports: ExactSupports<S>): BlockSupports;
268
+
269
+ /**
270
+ * What a block's `render` returns.
271
+ *
272
+ * Declared here rather than re-exported. The engine's own is `unknown`, because
273
+ * the engine serves any renderer and cannot name an output type; naming it there
274
+ * would tie a runtime-free package to React. That leaves the re-exported name
275
+ * useless for the thing an author would reach for it to do — a helper typed
276
+ * `(args: BlockRenderArgs<P>) => BlockRenderResult` returns `unknown`, which does
277
+ * not satisfy `BlockDefinition["render"]`, so handing that helper to
278
+ * `defineBlock` failed to compile.
279
+ *
280
+ * The promise is spelled out for the same reason `render` spells it out: React
281
+ * 19 added promises to `ReactNode` and React 18 did not, and this package
282
+ * supports both.
283
+ *
284
+ * @experimental Carried by the same freeze as `defineBlock`.
285
+ */
286
+ type BlockRenderResult = ReactNode | Promise<ReactNode>;
287
+
288
+ export { type BlockDefinition, type BlockRenderArgs, type BlockRenderContext, type BlockRenderResult, type BlockSupportKeys, type BlockSupports, blockSupports, defineBlock };
package/dist/blocks.mjs CHANGED
@@ -1,3 +1,11 @@
1
- export { defineBlock } from '@nextlyhq/blocks-engine';
1
+ // src/blocks.ts
2
+ function defineBlock(definition) {
3
+ return definition;
4
+ }
5
+ function blockSupports(supports) {
6
+ return supports;
7
+ }
8
+
9
+ export { blockSupports, defineBlock };
2
10
  //# sourceMappingURL=blocks.mjs.map
3
11
  //# sourceMappingURL=blocks.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"blocks.mjs","sourcesContent":[]}
1
+ {"version":3,"sources":["../src/blocks.ts"],"names":[],"mappings":";AAmQO,SAAS,YACd,UAAA,EACoB;AACpB,EAAA,OAAO,UAAA;AACT;AA0BO,SAAS,cACd,QAAA,EACe;AACf,EAAA,OAAO,QAAA;AACT","file":"blocks.mjs","sourcesContent":["/**\n * Block authoring — the contracts a plugin contributing blocks to the page\n * builder needs.\n *\n * A subpath rather than the SDK's main entry, so a plugin that has nothing to\n * do with blocks never pulls the block engine into its type graph. The SDK\n * remains the single stable import surface a plugin author is offered; this\n * simply keeps a page-builder-specific vocabulary out of everyone else's way.\n *\n * The engine is a real dependency of this package rather than an optional peer,\n * because the types below are built on top of its own: they have to resolve for\n * an author who installed only the SDK, and under a strict `node_modules`\n * layout the page builder's copy is not reachable from their package. The\n * engine's registry is pinned to `globalThis`, so even a duplicated install\n * still reads and writes the one registry the page builder consumes.\n *\n * What an author writes is declared here rather than re-exported. `defineBlock`\n * and `BlockSupports` are this module's own so that `BlockSupportKeys` can be\n * augmented from a plugin's source, which only works for a module that plugin\n * can name.\n *\n * The registration side is not here. Contributing a block means calling the\n * page builder's own service — it is that plugin's registry, not core's — so\n * `blockRegistry` comes from `@nextlyhq/plugin-page-builder/blocks`, which is\n * also where a contributor already declares its `dependsOn`.\n *\n * @packageDocumentation\n */\n\nimport type {\n BlockDefinition as EngineBlockDefinition,\n BlockRenderArgs as EngineBlockRenderArgs,\n} from \"@nextlyhq/blocks-engine\";\nimport type { ReactNode } from \"react\";\n\n/**\n * The support keys a block may declare.\n *\n * Declared HERE rather than in the engine, and that placement is the whole\n * point. A module augmentation has to name a module that resolves from the file\n * doing the augmenting, and a plugin author installs this package: under a\n * strict `node_modules` layout the engine is a nested transitive dependency\n * their own source cannot name, so an augmentation pointed at it fails to\n * compile and the custom support silently never arrives.\n *\n * A plugin that calls `registerSupport()` adds its key to the vocabulary the\n * compiler checks against:\n *\n * ```ts\n * declare module \"@nextlyhq/plugin-sdk/blocks\" {\n * interface BlockSupportKeys {\n * animation: \"enter\" | \"exit\";\n * parallax: true;\n * }\n * }\n * ```\n *\n * Declaration merging rather than an index signature: an index signature accepts\n * every key, which is what leaves a misspelled `spaceing` to be found at boot,\n * in someone else's app, instead of while it is being written.\n *\n * One rule reads the value: a union of strings names the sub-flags the support\n * recognises, and anything else means the support is all-or-nothing. So a nested\n * typo is caught in the same breath as a top-level one — `{ spacing: { paddding:\n * true } }` enables nothing at all, and finding that out at boot is exactly what\n * this exists to prevent — while a support with no finer granularity can be\n * written the way it reads, as `never` or as `true`.\n *\n * The built-in keys are the style catalog's groups plus the capabilities that\n * have no catalog group of their own. A test holds both the keys and their\n * flags to what the registry actually accepts, so the two cannot drift.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockSupportKeys {\n /** Padding and margin. */\n spacing: \"margin\" | \"padding\";\n /** Flow, alignment and gap. */\n layout: never;\n /** Width, height and their limits. */\n dimensions: never;\n /** Font, size, weight, line height and letter spacing. */\n typography: never;\n /** Text and link colours. */\n color: \"text\" | \"link\";\n /** Background colour, image and gradient. */\n background: \"color\" | \"image\" | \"gradient\";\n /** Border lines and corner rounding. */\n border: \"line\" | \"radius\";\n /** Box and text shadows. */\n shadow: never;\n /** Opacity, filters and transforms. */\n effects: never;\n /** Positioning and stacking. */\n position: never;\n /** Container-query behaviour. */\n container: never;\n /** Author-written CSS on this block. Gates a capability, not a style group. */\n customCss: never;\n}\n\n/**\n * What one support key accepts, given the sub-flags it declares.\n *\n * The two cases are kept apart rather than both handed to `Record`, because\n * `Record` demands a property key and a support that declares no flags has none\n * to give. Feeding it either sentinel is unsound in opposite directions: `true`\n * is not a property key at all, so the mapped type stops instantiating and an\n * augmenting plugin's build fails on the declaration rather than on anything it\n * wrote; `never` produces `Partial<Record<never, boolean>>`, which is `{}`, and\n * `{}` accepts every object — so `{ layout: { typo: true } }` type-checks and is\n * refused only later, by the registry, at boot.\n *\n * `[F] extends [never]` is asked first and in tuple form. Bare `F extends never`\n * distributes and answers for the empty union rather than about it, and\n * `[never] extends [string]` is true, so a `never` reaching the string case\n * would rebuild the same `{}`.\n */\ntype SupportSetting<F> = [F] extends [never]\n ? boolean\n : [F] extends [string]\n ? boolean | Partial<Record<F & string, boolean>>\n : boolean;\n\n/**\n * Style capabilities a block opts into: `true` for a whole group, or an object\n * naming the sub-flags it wants.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type BlockSupports = {\n [K in keyof BlockSupportKeys]?: SupportSetting<BlockSupportKeys[K]>;\n};\n\n/**\n * Supports as written at a definition, with unknown keys refused.\n *\n * TypeScript checks for excess properties only on a literal written in place,\n * so lifting settings into a shared object skips it: `const shared = { spacing:\n * true, spaceing: true }` assigns to `BlockSupports` without complaint, and the\n * typo survives to be caught at boot in someone else's app — which is the whole\n * failure this vocabulary exists to move earlier.\n *\n * Naming the offending key as `never` refuses it wherever it was written.\n */\ntype ExactSupports<S> = S & {\n [K in Exclude<keyof S, keyof BlockSupportKeys>]: never;\n};\n\n/**\n * Everything a renderer makes available to every block it draws.\n *\n * ONE description per app, rather than each block inventing its own. A block\n * author writes `defineBlock<MyProps>` and `ctx` is already typed as whatever\n * this app's renderer provides, with no type written by hand; a block that\n * needs something unusual has to add it here, which is an app-wide statement\n * anyone can see rather than a quiet assumption inside one file.\n *\n * A renderer declares what it supplies by augmenting this from its own package:\n *\n * ```ts\n * declare module \"@nextlyhq/plugin-sdk/blocks\" {\n * interface BlockRenderContext {\n * data?: DataProvider;\n * }\n * }\n * ```\n *\n * `locale` is here because every renderer of localized content has one, and a\n * block that varies its own output by language should not have to reach past\n * this interface to find out which.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockRenderContext {\n /** The locale being rendered, when the renderer is rendering one. */\n locale?: string;\n}\n\n/**\n * What a block's `render` receives.\n *\n * The engine's own version leaves both the context and the output unnamed,\n * because the engine serves any renderer and cannot know either. This one names\n * both: the context is what THIS app's renderer provides, which is what lets a\n * block read `ctx.data` with no type written by hand, and the output is React,\n * which is what lets a block place a slot straight into its JSX instead of\n * asserting a type over it.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockRenderArgs<P>\n extends Omit<EngineBlockRenderArgs<P, BlockRenderContext>, \"renderSlot\"> {\n /**\n * Render one of this block's slots, optionally under a different context.\n *\n * `ReactNode` rather than the `ReactNode | Promise<ReactNode>` that `render`\n * returns, and the asymmetry is deliberate: this value is one a block places\n * into its own JSX, and that union is not a legal child under EITHER supported\n * peer. React 18 admits no promise at all; React 19 admits only\n * `Promise<AwaitedReactNode>`, a promise of a settled node, so a promise that\n * may itself yield a promise is refused there too. Widening here would move\n * the error onto every block that draws a slot.\n *\n * It still says what each peer can express, because React 19 counts\n * `Promise<AwaitedReactNode>` as a `ReactNode`: a renderer on 19 may hand back\n * a pending slot and the block places it unchanged. On 18 it may not, which\n * costs nothing, since an async block cannot be drawn under React 18's types\n * regardless — `<AsyncBlock />` is refused outright there.\n */\n renderSlot(this: void, name: string, ctx?: BlockRenderContext): ReactNode;\n}\n\n/**\n * One block type, as an author writes it.\n *\n * The engine's own definition leaves `supports` open, because its registry holds\n * blocks from every source and checks their keys at boot against whatever is\n * registered. Authoring is the moment a typo is cheap to catch, so this narrows\n * that one member and changes nothing else.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockDefinition<P extends object = Record<string, unknown>>\n extends Omit<\n EngineBlockDefinition<P, BlockRenderContext>,\n \"supports\" | \"render\"\n > {\n supports?: BlockSupports;\n /**\n * Renders the block.\n *\n * The promise is spelled out rather than left to `ReactNode`. React 19 added\n * promises to that type and React 18 did not, and this package supports both,\n * so an async block would compile against one peer and be rejected by the\n * other. Naming it here makes the async contract mean the same thing across\n * the range this package declares.\n */\n render(args: BlockRenderArgs<P>): BlockRenderResult;\n}\n\n/**\n * Declare a block.\n *\n * Returns its argument. It exists to infer the prop type from what is written\n * and to check the rest against the definition shape, which is what makes a\n * mistyped prop name or an unknown support key a compile error rather than a\n * boot one.\n *\n * There is deliberately no per-block context parameter. What a renderer\n * provides is one description per app, and a block that needs something unusual\n * declares it on `BlockRenderContext` where the whole app can see it. A block\n * naming its own context would be asserting privately that it will be handed\n * something, which nothing checks and no registry can honour.\n *\n * @experimental The block API is frozen at the end of the engine phase, not\n * now. Until then a contributed block may need changes when the definition\n * shape settles.\n */\nexport function defineBlock<P extends object>(\n definition: BlockDefinition<P>\n): BlockDefinition<P> {\n return definition;\n}\n\n/**\n * Supports settings meant to be shared between blocks.\n *\n * Written straight into a definition, a typo is caught: TypeScript checks a\n * literal for keys the target does not declare. Lifted into a variable first,\n * it is not, because that check applies only where the literal is written. This\n * puts the check back at the declaration, which is where the settings are.\n *\n * ```ts\n * const layoutSupports = blockSupports({ spacing: true, layout: true });\n * defineBlock<MyProps>({ …, supports: layoutSupports });\n * ```\n *\n * `satisfies BlockSupports` does the same thing and needs nothing from this\n * package; the helper exists because it reads as the obvious move and cannot be\n * forgotten halfway through.\n *\n * It cannot live on `defineBlock` itself: catching this needs the supplied\n * object's own keys inferred, and TypeScript infers nothing once any type\n * argument is written by hand, so `defineBlock<MyProps>` — the form nearly\n * every block uses — would stop checking anything at all.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport function blockSupports<S extends BlockSupports>(\n supports: ExactSupports<S>\n): BlockSupports {\n return supports;\n}\n\n/**\n * @experimental Carried by the same freeze as `defineBlock`: these describe the\n * definition shape, so they change with it.\n */\nexport type {\n AnyBlockDefinition,\n InferBlockProps,\n PropSchema,\n SupportDefinition,\n} from \"@nextlyhq/blocks-engine\";\n\n/**\n * What a block's `render` returns.\n *\n * Declared here rather than re-exported. The engine's own is `unknown`, because\n * the engine serves any renderer and cannot name an output type; naming it there\n * would tie a runtime-free package to React. That leaves the re-exported name\n * useless for the thing an author would reach for it to do — a helper typed\n * `(args: BlockRenderArgs<P>) => BlockRenderResult` returns `unknown`, which does\n * not satisfy `BlockDefinition[\"render\"]`, so handing that helper to\n * `defineBlock` failed to compile.\n *\n * The promise is spelled out for the same reason `render` spells it out: React\n * 19 added promises to `ReactNode` and React 18 did not, and this package\n * supports both.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type BlockRenderResult = ReactNode | Promise<ReactNode>;\n\n/**\n * The rest of the definition's own vocabulary. Every one of these names a field\n * a block author fills in, so leaving them off this surface meant writing a slot\n * template, an example, or an editor entry against a type that could only be\n * reached by importing the engine directly — which is the one thing this subpath\n * exists to make unnecessary.\n *\n * `BlockSupportValue` is deliberately NOT among them. The engine's is\n * `boolean | Record<string, boolean>`, which is what its registry stores from\n * every source; offered here as authoring vocabulary it would undo the check\n * this module exists for, since `const spacing: BlockSupportValue = { paddding:\n * true }` accepts the typo the per-key flag unions refuse. A shared setting for\n * one key is written as `BlockSupports[\"spacing\"]`, which is checked, and a\n * whole object goes through `blockSupports()`.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type {\n BlockEditorMeta,\n BlockExample,\n BlockVariation,\n ComponentPath,\n NodeStyles,\n SlotLock,\n SlotSpec,\n} from \"@nextlyhq/blocks-engine\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextlyhq/plugin-sdk",
3
- "version": "0.0.2-alpha.50",
3
+ "version": "0.0.2-alpha.51",
4
4
  "description": "Nextly Plugin SDK — the author-facing surface for building Nextly plugins; the plugin API stability boundary (see STABILITY.md).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -50,13 +50,13 @@
50
50
  "node": ">=20.0.0"
51
51
  },
52
52
  "dependencies": {
53
- "@nextlyhq/blocks-engine": "0.0.2-alpha.50"
53
+ "@nextlyhq/blocks-engine": "0.0.2-alpha.51"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": "^18.0.0 || ^19.0.0",
57
57
  "react-dom": "^18.0.0 || ^19.0.0",
58
- "@nextlyhq/admin": "0.0.2-alpha.50",
59
- "nextly": "0.0.2-alpha.50"
58
+ "@nextlyhq/admin": "0.0.2-alpha.51",
59
+ "nextly": "0.0.2-alpha.51"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@nextlyhq/admin": {
@@ -76,10 +76,10 @@
76
76
  "tsup": "^8.5.0",
77
77
  "typescript": "^5.9.3",
78
78
  "vitest": "^4.1.0",
79
- "@nextlyhq/admin": "0.0.2-alpha.50",
80
- "@nextlyhq/eslint-config": "0.0.2-alpha.50",
81
- "@nextlyhq/tsconfig": "0.0.2-alpha.50",
82
- "nextly": "0.0.2-alpha.50"
79
+ "@nextlyhq/admin": "0.0.2-alpha.51",
80
+ "@nextlyhq/eslint-config": "0.0.2-alpha.51",
81
+ "@nextlyhq/tsconfig": "0.0.2-alpha.51",
82
+ "nextly": "0.0.2-alpha.51"
83
83
  },
84
84
  "publishConfig": {
85
85
  "access": "public",