@plitzi/sdk-shared 0.38.11 → 0.38.13
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 +110 -0
- package/dist/authoring/declare.d.ts +152 -2
- package/dist/authoring/declare.mjs +95 -2
- package/dist/authoring/index.mjs +5 -5
- package/dist/dataSource/hooks/useRegisterSource.mjs +31 -18
- package/dist/helpers/generateFacade.mjs +16 -12
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/utils.d.ts +1 -1
- package/dist/helpers/utils.mjs +1 -1
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.mjs +2 -2
- package/dist/hooks/usePlitzi.d.ts +32 -0
- package/dist/hooks/{usePlitziServiceContext.mjs → usePlitzi.mjs} +3 -3
- package/dist/index.mjs +3 -3
- package/dist/plugins/PluginsContext.d.ts +3 -0
- package/dist/plugins/PluginsContext.mjs +4 -0
- package/dist/project/paths.d.ts +1 -1
- package/dist/store/index.d.ts +33 -33
- package/dist/style/styleTarget.mjs +28 -27
- package/dist/types/DataSourceTypes.d.ts +7 -2
- package/dist/types/EventBridgeTypes.d.ts +2 -1
- package/dist/types/InteractionTypes.d.ts +42 -4
- package/dist/websockets/RTCodec.d.ts +6 -1
- package/package.json +8 -4
- package/dist/hooks/usePlitziServiceContext.d.ts +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
# @plitzi/sdk-shared
|
|
2
2
|
|
|
3
|
+
## 0.38.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.38.13
|
|
8
|
+
|
|
9
|
+
## 0.38.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 1301338: ## Builder
|
|
14
|
+
|
|
15
|
+
- **Icons in the canvas again** (`@plitzi/plitzi-builder`): the canvas inlined the SDK's Font Awesome sheet into its
|
|
16
|
+
`<style>`, where the sheet's `url(webfonts/…)` resolved against the editor's URL — a `srcdoc` frame takes it as its
|
|
17
|
+
base — so every icon was a 404 under `/spaces/<space>/webfonts/` and drew as an empty box. Only the Vite dev server,
|
|
18
|
+
which rewrites the URL, hid it. The canvas and the element preview now link the sheet from where the host serves it:
|
|
19
|
+
a new prop, `sdkIconsStylePath`, the one the host already gives the pages it renders
|
|
20
|
+
(`/sdk-assets/plitzi-sdk-icons.css` for sdk-server). Absent, the canvas links no icon sheet.
|
|
21
|
+
|
|
22
|
+
## Plugins
|
|
23
|
+
- **A plugin's other elements, hosted by `custom`** (`@plitzi/sdk-elements`): `custom({ renderType: 'jamDisc' })` on a
|
|
24
|
+
space with a plugin installed whose main element is another (`plitzi plugin pack` of several folders: the first is the
|
|
25
|
+
plugin, the rest go in it) rendered "Custom Component jamDisc Not Found" — the page registers only the plugin's main
|
|
26
|
+
element, and a `custom` host looked nowhere else. It now loads the type from the installed plugin that packs it, as
|
|
27
|
+
an element of the type itself always did, so the two ways the docs give to place a plugin's element are the same
|
|
28
|
+
everywhere: in a project `plitzi create` wrote, and once the project is on Plitzi.
|
|
29
|
+
- **One way to place a plugin's element** (`@plitzi/sdk-authoring`, `@plitzi/cli`, docs): from its declaration,
|
|
30
|
+
`const seatPicker = defineElement(declaration)` then `seatPicker({ id, … })` — typed by what it
|
|
31
|
+
declares, and the element the builder adds when somebody drops it. The welcome space `plitzi create` writes, the
|
|
32
|
+
plugin package's preview, `plitzi plugin add` and `plitzi explain` all write it so (the template's
|
|
33
|
+
`PluginHostOptions` now takes the plugin's `type` and `declaration: { from, attributes? }`; `custom`/`element` hosting
|
|
34
|
+
is gone). `pluginFolders(folder)` (`@plitzi/sdk-authoring/node`) reads each plugin with the folder it is in;
|
|
35
|
+
`pluginDeclarations` is built on it. A `custom({ renderType })` naming a plugin the space was handed the declaration
|
|
36
|
+
of is offered the declaration instead — suggestion `plugin-custom-host`. `custom` stays for a component registered
|
|
37
|
+
by name with no declaration. The skills, the CLI README, the MCP guide, `docs/en` and the website say the same.
|
|
38
|
+
- **`definePlugin`** (`@plitzi/sdk-authoring/plugin`, a new entry of 3 KB with nothing else in it): a plugin's
|
|
39
|
+
declaration written from what only it can say —
|
|
40
|
+
`definePlugin<SeatPickerAttributes>()({ type, label, attributes, triggers, callbacks })` — and every other field
|
|
41
|
+
at the default all plugins share (the builder's gestures, the catalogue entry, each attribute bindable, an empty
|
|
42
|
+
style). It answers the whole declaration, branded with its attributes, so `defineElement(declaration)` is typed
|
|
43
|
+
without a generic. `plitzi plugin add` and `create --plugin` write declarations with it (about a third of the lines).
|
|
44
|
+
- **`usePluginTrigger(declaration)`** (`@plitzi/plitzi-sdk`): fires a plugin's declared event on its element — the
|
|
45
|
+
event name and what each hands a flow typed off the declaration's `preview` — on a live page only. The hook every
|
|
46
|
+
plugin wrote for itself (and `plugin add` generated as `use<Name>Events`) is gone from the scaffold.
|
|
47
|
+
- **Attributes as the types their defaults are** (`@plitzi/sdk-elements`): a plugin's attribute bound from text — a
|
|
48
|
+
state, a row, a channel message — reaches its component as the number or the flag its declared default is (`'112'`
|
|
49
|
+
as 112, `'true'` as true). A plugin no longer types its props `number | string` and parses them.
|
|
50
|
+
|
|
51
|
+
## Server actions and functions
|
|
52
|
+
- **Task params with rules** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a task declares `required`, a text's
|
|
53
|
+
`maxLength` and a number's `min`/`max`, and the runner refuses a call that breaks any of them — every rule broken at
|
|
54
|
+
once, in the words the page shows (`Title is required; Seconds is at most 300`) — before the code runs. A `text` param
|
|
55
|
+
bound to a number arrives as its digits. The manifest keeps the rules, so the platform's sandbox checks the same.
|
|
56
|
+
- **`taskAction(task, { trigger })`** (`@plitzi/sdk-authoring`): the action that runs one of the space's tasks and
|
|
57
|
+
answers its result, derived from the task — its id (`<namespace>-<action>`), name, description and input (the task's
|
|
58
|
+
params, once). An action of more than one step is still `defineAction`.
|
|
59
|
+
- **`ctx.rateLimit(bucket, { …, refuse })`**: past the limit the call is refused with those words instead of answering
|
|
60
|
+
`allowed: false` for the code to check — natively and in the sandbox.
|
|
61
|
+
|
|
62
|
+
## Authoring
|
|
63
|
+
- **`runServerActionOrNotify(id, params, fallback)`**: a server action run and the notice the visitor reads when it
|
|
64
|
+
fails — the action's own refusal, or the fallback — as two steps to spread into a flow.
|
|
65
|
+
- **`repeated-shape` reads what copies bind**: copies whose bindings read their data in different forms (a count, a
|
|
66
|
+
total of a quota) and copies holding a provider resolved on the server (found by its own id) are no longer offered
|
|
67
|
+
as one component.
|
|
68
|
+
- **`element-color-inherited`** (suggestion): `elements` giving a heading, a text, a link… `color: inherit` or the
|
|
69
|
+
page's own colour. **A link inherits the page's colour** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-elements`) rather than
|
|
70
|
+
holding the SDK's grey — the same by default, and the space's palette inside a card that is a link. The template
|
|
71
|
+
every space starts from writes its colours once, on the page.
|
|
72
|
+
|
|
73
|
+
## Fixes
|
|
74
|
+
- **A dialog opened with an id** (`@plitzi/sdk-elements`): `openDialog('dialog', '{{ row.id }}')` reads the id as its
|
|
75
|
+
`content`, as `openModal` already did — a numeric id parsed as the number and the dialog's bindings read nothing.
|
|
76
|
+
- **A select's chevron** (`@plitzi/plitzi-sdk`): a drawn chevron in the field's own colour, sized by its type, in place
|
|
77
|
+
of the `▼` glyph — and laid out in the box, so it ends where the box's padding begins whatever that padding is, and
|
|
78
|
+
the chosen option stops short of it instead of running under it. A disabled select's is faded.
|
|
79
|
+
- **Every element has its settings** (`@plitzi/plitzi-builder`, `@plitzi/sdk-elements`): the builder found none for
|
|
80
|
+
`tabContainerHeader` (registered under a misspelt type), `themeToggle`, `dropdownPopup`, `loading` and `notFound`.
|
|
81
|
+
The theme toggle's panel sets its mode, its labels and whether it offers "System"; the registry is typed by element
|
|
82
|
+
type and must hold one for each.
|
|
83
|
+
- **A plugin's panel** (`@plitzi/cli`): `plitzi doctor` warns of a plugin with no `Settings.tsx`, or one its entry never
|
|
84
|
+
passes as `pluginSettings` (`plugin-settings-missing`); the example `create` writes has its panel, as every element
|
|
85
|
+
`plugin add` writes does, and the panels it generates are laid out as the project's Prettier lays them out.
|
|
86
|
+
- **A refused or failed run reaches `onFlowError` in every mode** (`@plitzi/sdk-interactions`): an awaited server
|
|
87
|
+
action the server refused fired no `onFlowError` on the element that started it, as `detached` and `stream` ones do
|
|
88
|
+
— a board rolling its edits back on a refusal never did; and a run answered `status: 'failed'` fired `onFlowEnd`
|
|
89
|
+
(detached) or nothing (awaited) rather than `onFlowError`.
|
|
90
|
+
- **A source renamed** (`@plitzi/sdk-shared`): the binding picker lists a provider, a form or a modal by the name its
|
|
91
|
+
element has now, not the one it had when it mounted.
|
|
92
|
+
- **A text's words in the builder** (`@plitzi/sdk-elements`): a `paragraph`, `text` or `heading` whose `content` is
|
|
93
|
+
`0` shows `0` while editing too, not its placeholder; one bound to nothing shows nothing rather than `null`.
|
|
94
|
+
- **Built-in declarations** (`@plitzi/sdk-shared`): `elementDeclaration` fills in what every element shares — the
|
|
95
|
+
builder's gestures, Plitzi's catalogue entry, a visible element with no bindings, its style named by its label —
|
|
96
|
+
from the defaults `definePlugin` uses; each element's declaration says only what is its own (a third of the lines).
|
|
97
|
+
|
|
98
|
+
## Typed for plugins and hosts
|
|
99
|
+
- **`usePlitzi()` and `PlitziProvider`** (`@plitzi/sdk-shared/hooks/usePlitzi`, `@plitzi/plitzi-sdk`): what were
|
|
100
|
+
`usePlitziServiceContext()` and `PlitziServiceProvider` (and `PlitziServiceContextValue`, now `PlitziContextValue`),
|
|
101
|
+
holding only what the host rendering a space knows — `settings`, `root`, `utils`. Its `contexts` and
|
|
102
|
+
`customContexts` are gone: every context it carried is a shared one already, imported from its own module
|
|
103
|
+
(`@plitzi/sdk-interactions/InteractionsContext`, `@plitzi/sdk-shared/network/NetworkContext`…), and
|
|
104
|
+
`PluginsContext` moves to `@plitzi/sdk-shared/plugins/PluginsContext` beside the others.
|
|
105
|
+
- **`InteractionsManagerApi`** (`@plitzi/sdk-shared`): the interactions manager as everything outside
|
|
106
|
+
`@plitzi/sdk-interactions` reaches it, declared where every package can name it and implemented by
|
|
107
|
+
`InteractionsManager`, so `use(InteractionsContext)` is typed — `interactionTrigger`, `createChildManager`… — where it
|
|
108
|
+
was `any`.
|
|
109
|
+
- **`getPathsFromObject`** (`@plitzi/sdk-shared/helpers/utils`), spelt right; `getPathsFromObeject` is gone.
|
|
110
|
+
- **`ElementWords` places itself** (`@plitzi/sdk-elements`): `contentPlacement` and the element's children, so a button
|
|
111
|
+
and a link write their words once.
|
|
112
|
+
|
|
3
113
|
## 0.38.11
|
|
4
114
|
|
|
5
115
|
### Patch Changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { InteractionCallback } from '../types/InteractionTypes';
|
|
1
|
+
import { InteractionCallback, InteractionCallbackPreviews } from '../types/InteractionTypes';
|
|
2
2
|
import { PluginBuilder, PluginSchema } from '../types/PluginTypes';
|
|
3
3
|
import { ElementDefinition } from '../types/SchemaTypes';
|
|
4
|
+
import { DisplayMode, StyleAttributes } from '../types/StyleTypes';
|
|
4
5
|
/**
|
|
5
6
|
* How an element says what it can be authored with.
|
|
6
7
|
*
|
|
@@ -148,5 +149,154 @@ export type AuthorableAttributes<Props, Injected extends keyof Props = never> =
|
|
|
148
149
|
export declare const valuesOf: <T extends string>() => <const V extends readonly T[]>(values: V & ([Exclude<T, V[number]>] extends [never] ? unknown : {
|
|
149
150
|
readonly missing: Exclude<T, V[number]>;
|
|
150
151
|
})) => readonly string[];
|
|
151
|
-
|
|
152
|
+
/** What a built-in element writes in its declaration's `content`: what is its own — the rest is filled in. */
|
|
153
|
+
export interface ElementContentSpec {
|
|
154
|
+
attributes: Record<string, unknown>;
|
|
155
|
+
/** Left out: `type` (the declaration's), no bindings, visible, and the `base` style selector beside its own. */
|
|
156
|
+
definition: Omit<Partial<ElementDefinition>, 'type' | 'rootId' | 'parentId' | 'interactions' | 'runtime' | 'styleSelectors'> & {
|
|
157
|
+
label: string;
|
|
158
|
+
/** What the element is for, in a sentence: the builder shows it, and an agent reads it to choose the element. */
|
|
159
|
+
description?: string;
|
|
160
|
+
styleSelectors?: Record<string, string>;
|
|
161
|
+
};
|
|
162
|
+
/** Left out, every gesture, and children of any type. */
|
|
163
|
+
builder?: PluginBuilder;
|
|
164
|
+
/** Its place in the catalogue; the rest is Plitzi's own entry. */
|
|
165
|
+
market: {
|
|
166
|
+
category: string;
|
|
167
|
+
icon: string;
|
|
168
|
+
};
|
|
169
|
+
/** Left out: named by its label, for desktop. */
|
|
170
|
+
defaultStyle: {
|
|
171
|
+
name?: string;
|
|
172
|
+
displayMode?: DisplayMode;
|
|
173
|
+
style: StyleAttributes;
|
|
174
|
+
/** A style of its own for each `subType` — a heading's `h1`… — written whole. */
|
|
175
|
+
subTypes?: Record<string, {
|
|
176
|
+
name: string;
|
|
177
|
+
displayMode: DisplayMode;
|
|
178
|
+
style: StyleAttributes;
|
|
179
|
+
}>;
|
|
180
|
+
};
|
|
181
|
+
settings?: Record<string, string | number | boolean>;
|
|
182
|
+
}
|
|
183
|
+
/** What {@link elementDeclaration} takes: the declaration as written, `content` holding only what is the element's. */
|
|
184
|
+
export interface ElementDeclarationSpec extends Omit<ElementDeclarationData, 'content'> {
|
|
185
|
+
content: ElementContentSpec;
|
|
186
|
+
}
|
|
187
|
+
/** What {@link elementDeclaration} fills in, typed as the declaration then carries it. */
|
|
188
|
+
export interface ElementContentDefaults {
|
|
189
|
+
definition: {
|
|
190
|
+
type: string;
|
|
191
|
+
bindings: NonNullable<ElementDefinition['bindings']>;
|
|
192
|
+
initialState: Record<string, unknown>;
|
|
193
|
+
styleSelectors: Record<string, string> & {
|
|
194
|
+
base: string;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
builder: Required<PluginBuilder>;
|
|
198
|
+
market: {
|
|
199
|
+
owner: string;
|
|
200
|
+
verified: boolean;
|
|
201
|
+
license: string;
|
|
202
|
+
website: string;
|
|
203
|
+
backgroundColor: string;
|
|
204
|
+
};
|
|
205
|
+
defaultStyle: {
|
|
206
|
+
name: string;
|
|
207
|
+
displayMode: DisplayMode;
|
|
208
|
+
};
|
|
209
|
+
settings: Record<string, string | number | boolean>;
|
|
210
|
+
}
|
|
211
|
+
/** A built-in element's whole declaration: what it wrote, what was filled in, and the attributes it accepts. */
|
|
212
|
+
export type DeclaredElement<D extends ElementDeclarationSpec, A> = D & {
|
|
213
|
+
content: ElementContentDefaults;
|
|
214
|
+
} & ElementAttributesBrand<A>;
|
|
215
|
+
/**
|
|
216
|
+
* A built-in element's declaration, written from what is its own — its type, words, attributes, style, place in the
|
|
217
|
+
* catalogue — with the rest at the defaults every element shares: the builder's gestures, Plitzi's catalogue entry,
|
|
218
|
+
* a visible element with no bindings, its style named by its label.
|
|
219
|
+
*
|
|
220
|
+
* Called twice, as {@link definePlugin} is: the first call takes the attributes the element accepts, the second the
|
|
221
|
+
* declaration.
|
|
222
|
+
*/
|
|
223
|
+
export declare const elementDeclaration: <A>() => <const D extends ElementDeclarationSpec>(declaration: D) => DeclaredElement<D, A>;
|
|
224
|
+
/** An event a plugin fires, as {@link definePlugin} takes it: what a flow it starts reads (`preview`) — the rest derived. */
|
|
225
|
+
export type PluginTriggerSpec = {
|
|
226
|
+
/** Left out, the event's name in words: `onEdit` is "On Edit". */
|
|
227
|
+
title?: string;
|
|
228
|
+
/** What a flow started by it reads, `{ ops: '' }` — and so what the plugin hands it (`usePluginTrigger`). */
|
|
229
|
+
preview?: InteractionCallbackPreviews;
|
|
230
|
+
params?: InteractionCallback['params'];
|
|
231
|
+
};
|
|
232
|
+
/** An action a plugin answers, as {@link definePlugin} takes it: its params — the rest derived. */
|
|
233
|
+
export type PluginCallbackSpec = {
|
|
234
|
+
title?: string;
|
|
235
|
+
params?: InteractionCallback['params'];
|
|
236
|
+
};
|
|
237
|
+
type PluginContent<A extends object> = PluginDeclaration<A>['content'];
|
|
238
|
+
/** What a plugin is, said once: {@link definePlugin} writes the rest of its declaration from it. */
|
|
239
|
+
export interface PluginSpec<A extends object, T extends Record<string, PluginTriggerSpec>, C extends Record<string, PluginCallbackSpec>> extends Omit<ElementDeclarationData, 'type' | 'triggers' | 'callbacks' | 'content'> {
|
|
240
|
+
/** What a space names it by — the element type. Renaming it orphans every one. */
|
|
241
|
+
type: string;
|
|
242
|
+
/** What the builder's catalogue calls it. */
|
|
243
|
+
label: string;
|
|
244
|
+
/** What it is for, in a sentence: the builder shows it, and an agent reads it to choose the element. */
|
|
245
|
+
description?: string;
|
|
246
|
+
/** Its starting attributes: the component's defaults. */
|
|
247
|
+
attributes: A;
|
|
248
|
+
triggers?: T;
|
|
249
|
+
callbacks?: C;
|
|
250
|
+
/** What the builder lets a person do with it. Left out, every gesture, and no children. */
|
|
251
|
+
builder?: PluginBuilder;
|
|
252
|
+
/** How the catalogue shows it. Left out, under its label, by nobody, MIT. */
|
|
253
|
+
market?: Partial<PluginContent<A>['market']>;
|
|
254
|
+
/** The attributes a data source may be pointed at. Left out, every one. */
|
|
255
|
+
bindable?: readonly (keyof A & string)[];
|
|
256
|
+
/** Its style before anybody styles it. */
|
|
257
|
+
style?: PluginSchema['defaultStyle']['style'];
|
|
258
|
+
/** More of the element's definition — children it starts with (`items`), its style selectors. */
|
|
259
|
+
definition?: Partial<PluginContent<A>['definition']>;
|
|
260
|
+
settings?: PluginContent<A>['settings'];
|
|
261
|
+
}
|
|
262
|
+
/** A plugin's events and actions as its declaration carries them: each named by its key, its preview kept as written. */
|
|
263
|
+
export type DeclaredTriggers<T extends Record<string, PluginTriggerSpec>> = {
|
|
264
|
+
[K in keyof T & string]: Omit<InteractionCallback, 'action' | 'preview'> & {
|
|
265
|
+
action: K;
|
|
266
|
+
preview: T[K]['preview'] extends object ? T[K]['preview'] : Record<string, never>;
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
export type DeclaredCallbacks<C extends Record<string, PluginCallbackSpec>> = {
|
|
270
|
+
[K in keyof C & string]: Omit<InteractionCallback, 'action'> & {
|
|
271
|
+
action: K;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
/** What {@link definePlugin} answers: the declaration, its events and actions named, and its attributes in its type. */
|
|
275
|
+
export type DefinedPlugin<A extends object, T extends Record<string, PluginTriggerSpec>, C extends Record<string, PluginCallbackSpec>> = Omit<PluginDeclaration<A>, 'triggers' | 'callbacks'> & {
|
|
276
|
+
triggers: DeclaredTriggers<T>;
|
|
277
|
+
callbacks: DeclaredCallbacks<C>;
|
|
278
|
+
} & ElementAttributesBrand<A>;
|
|
279
|
+
/**
|
|
280
|
+
* A plugin's declaration, written from what only it can say — its type, its words, its attributes, what it fires and
|
|
281
|
+
* answers — with everything else at the default every plugin shares: the builder's gestures, the catalogue entry, a
|
|
282
|
+
* bindable attribute for each one, an empty style.
|
|
283
|
+
*
|
|
284
|
+
* ```ts
|
|
285
|
+
* export default definePlugin<SeatPickerAttributes>()({
|
|
286
|
+
* type: 'seatPicker',
|
|
287
|
+
* label: 'Seat Picker',
|
|
288
|
+
* description: 'Picks a seat from a plan.',
|
|
289
|
+
* attributes: { start: 0, label: 'Seats' },
|
|
290
|
+
* triggers: { onPick: { preview: { seat: '' } } },
|
|
291
|
+
* callbacks: { reset: {} }
|
|
292
|
+
* });
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* Called twice, as `elementDeclaration` is: the first call takes the attributes the element accepts (its component's
|
|
296
|
+
* props, minus what the runtime supplies), which TypeScript cannot read off defaults that leave some out; the second the
|
|
297
|
+
* rest, whose events it reads as written. The whole declaration comes back — what the build writes into the manifest
|
|
298
|
+
* and the builder reads — branded with the attributes, so `defineElement(declaration)` authors the element typed
|
|
299
|
+
* without being told.
|
|
300
|
+
*/
|
|
301
|
+
export declare const definePlugin: <A extends object>() => <const T extends Record<string, PluginTriggerSpec> = never, const C extends Record<string, PluginCallbackSpec> = never>({ type, label, description, attributes, triggers, callbacks, builder, market, bindable, style, definition, settings, ...rest }: PluginSpec<A, T, C>) => DefinedPlugin<A, T, C>;
|
|
152
302
|
export {};
|
|
@@ -1,4 +1,97 @@
|
|
|
1
1
|
//#region src/authoring/declare.ts
|
|
2
|
-
var e = () => (e) => e, t = () => (
|
|
2
|
+
var e = () => (e) => e, t = () => ({
|
|
3
|
+
canDelete: !0,
|
|
4
|
+
canSelect: !0,
|
|
5
|
+
canDragDrop: !0,
|
|
6
|
+
canMove: !0,
|
|
7
|
+
canSnippet: !0,
|
|
8
|
+
itemsAllowed: [],
|
|
9
|
+
itemsNotAllowed: []
|
|
10
|
+
}), n = (e, t) => ({
|
|
11
|
+
type: e,
|
|
12
|
+
bindings: {},
|
|
13
|
+
initialState: { visibility: !0 },
|
|
14
|
+
...t,
|
|
15
|
+
styleSelectors: {
|
|
16
|
+
base: "",
|
|
17
|
+
...t.styleSelectors
|
|
18
|
+
}
|
|
19
|
+
}), r = () => (e) => {
|
|
20
|
+
let { definition: r, builder: i, market: a, defaultStyle: o, settings: s } = e.content;
|
|
21
|
+
return {
|
|
22
|
+
...e,
|
|
23
|
+
content: {
|
|
24
|
+
...e.content,
|
|
25
|
+
definition: n(e.type, r),
|
|
26
|
+
builder: {
|
|
27
|
+
...t(),
|
|
28
|
+
...i
|
|
29
|
+
},
|
|
30
|
+
market: {
|
|
31
|
+
owner: "Plitzi",
|
|
32
|
+
verified: !0,
|
|
33
|
+
license: "MIT",
|
|
34
|
+
website: "https://plitzi.com",
|
|
35
|
+
backgroundColor: "#4422ee",
|
|
36
|
+
...a
|
|
37
|
+
},
|
|
38
|
+
defaultStyle: {
|
|
39
|
+
name: r.label,
|
|
40
|
+
displayMode: "desktop",
|
|
41
|
+
...o
|
|
42
|
+
},
|
|
43
|
+
settings: s ?? {}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, i = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/^./, (e) => e.toUpperCase()), a = () => ({ type: e, label: r, description: a, attributes: o, triggers: s, callbacks: c, builder: l, market: u, bindable: d, style: f, definition: p, settings: m, ...h }) => {
|
|
47
|
+
let g = (e, t, n) => ({
|
|
48
|
+
action: t,
|
|
49
|
+
title: n.title ?? i(t),
|
|
50
|
+
type: e,
|
|
51
|
+
params: n.params ?? {},
|
|
52
|
+
...e === "trigger" ? { preview: n.preview ?? {} } : {}
|
|
53
|
+
}), _ = d ?? Object.keys(o);
|
|
54
|
+
return {
|
|
55
|
+
...h,
|
|
56
|
+
type: e,
|
|
57
|
+
triggers: Object.fromEntries(Object.entries(s ?? {}).map(([e, t]) => [e, g("trigger", e, t)])),
|
|
58
|
+
callbacks: Object.fromEntries(Object.entries(c ?? {}).map(([e, t]) => [e, g("callback", e, t)])),
|
|
59
|
+
content: {
|
|
60
|
+
attributes: o,
|
|
61
|
+
definition: n(e, {
|
|
62
|
+
label: r,
|
|
63
|
+
...a ? { description: a } : {},
|
|
64
|
+
items: [],
|
|
65
|
+
...p
|
|
66
|
+
}),
|
|
67
|
+
builder: {
|
|
68
|
+
...t(),
|
|
69
|
+
...l
|
|
70
|
+
},
|
|
71
|
+
market: {
|
|
72
|
+
category: r,
|
|
73
|
+
owner: "",
|
|
74
|
+
license: "MIT",
|
|
75
|
+
website: "",
|
|
76
|
+
backgroundColor: "#4422ee",
|
|
77
|
+
icon: "",
|
|
78
|
+
...u
|
|
79
|
+
},
|
|
80
|
+
defaultStyle: {
|
|
81
|
+
name: r,
|
|
82
|
+
displayMode: "desktop",
|
|
83
|
+
style: f ?? { base: { default: {} } },
|
|
84
|
+
bindingsAllowed: {
|
|
85
|
+
attributes: _.map((e) => ({
|
|
86
|
+
path: e,
|
|
87
|
+
label: i(e)
|
|
88
|
+
})),
|
|
89
|
+
initialState: []
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
settings: m ?? {}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
3
96
|
//#endregion
|
|
4
|
-
export {
|
|
97
|
+
export { a as definePlugin, r as elementDeclaration, e as valuesOf };
|
package/dist/authoring/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toBuilderParams as e, toInteractionCallback as t, toInteractionCallbacks as n } from "./builder.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { BUILTIN_PARAM_TYPES as
|
|
4
|
-
import { BUILTIN_ELEMENT_CALLBACKS as
|
|
5
|
-
import { spaceCallbacks as
|
|
6
|
-
export {
|
|
2
|
+
import { definePlugin as r, elementDeclaration as i, valuesOf as a } from "./declare.mjs";
|
|
3
|
+
import { BUILTIN_PARAM_TYPES as o, hiddenParams as s, invalidParams as c, missingRequiredParams as l, reconcileParams as u } from "./paramSpec.mjs";
|
|
4
|
+
import { BUILTIN_ELEMENT_CALLBACKS as d, SCROLL_CALLBACKS as f, applyElementCallback as p, getElementCallback as m } from "./elementCallbacks.mjs";
|
|
5
|
+
import { spaceCallbacks as h } from "./spaceCallbacks.mjs";
|
|
6
|
+
export { d as BUILTIN_ELEMENT_CALLBACKS, o as BUILTIN_PARAM_TYPES, f as SCROLL_CALLBACKS, p as applyElementCallback, r as definePlugin, i as elementDeclaration, m as getElementCallback, s as hiddenParams, c as invalidParams, l as missingRequiredParams, u as reconcileParams, h as spaceCallbacks, e as toBuilderParams, t as toInteractionCallback, n as toInteractionCallbacks, a as valuesOf };
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
import { makeId as e } from "../../helpers/utils.mjs";
|
|
2
|
-
import { useEffect as t,
|
|
3
|
-
import { createStoreHook as
|
|
2
|
+
import { useEffect as t, useEffectEvent as n, useMemo as r } from "react";
|
|
3
|
+
import { createStoreHook as i } from "@plitzi/nexus/react";
|
|
4
4
|
//#region src/dataSource/hooks/useRegisterSource.ts
|
|
5
|
-
var
|
|
6
|
-
let { useStoreSetter:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
id: u,
|
|
5
|
+
var a = ({ id: a = "", source: o, name: s, fields: c = [] }) => {
|
|
6
|
+
let { useStoreSetter: l } = i(), u = l(), d = r(() => `${a}_${e(8)}`, [a]), f = n(() => {
|
|
7
|
+
u(`sources.${d}`, {
|
|
8
|
+
id: d,
|
|
10
9
|
meta: {
|
|
11
|
-
id:
|
|
12
|
-
source:
|
|
13
|
-
name:
|
|
14
|
-
fields:
|
|
10
|
+
id: a,
|
|
11
|
+
source: o,
|
|
12
|
+
name: s,
|
|
13
|
+
fields: c
|
|
15
14
|
}
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
t(() => {
|
|
18
|
+
if (o) return f(), () => u(`sources.${d}`, void 0, { unmount: !0 });
|
|
19
|
+
}, [
|
|
20
|
+
d,
|
|
21
|
+
o,
|
|
22
|
+
u
|
|
23
|
+
]), t(() => {
|
|
24
|
+
o && u(`sources.${d}.meta.name`, s);
|
|
19
25
|
}, [
|
|
20
26
|
s,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
o,
|
|
28
|
+
d,
|
|
29
|
+
u
|
|
30
|
+
]), t(() => {
|
|
31
|
+
o && u(`sources.${d}.meta.fields`, c, { raw: !0 });
|
|
32
|
+
}, [
|
|
33
|
+
c,
|
|
34
|
+
o,
|
|
35
|
+
d,
|
|
36
|
+
u
|
|
24
37
|
]);
|
|
25
38
|
};
|
|
26
39
|
//#endregion
|
|
27
|
-
export {
|
|
40
|
+
export { a as default };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isRecord as e } from "./isRecord.mjs";
|
|
2
|
+
import { omit as t } from "@plitzi/plitzi-ui/helpers";
|
|
2
3
|
//#region src/helpers/generateFacade.tsx
|
|
3
|
-
var
|
|
4
|
-
let
|
|
4
|
+
var n = (e) => e.replace(/^@/, "").replace(/[-/]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()).replace(/\s+/g, ""), r = (t, n) => {
|
|
5
|
+
let r = Reflect.get(window, t), i = e(r) ? r[n] : void 0;
|
|
6
|
+
return e(i) ? i : {};
|
|
7
|
+
}, i = (e, t = "PlitziFacade") => {
|
|
8
|
+
let n = typeof window < "u" ? Object.keys(r(t, e)) : [];
|
|
5
9
|
return n.length === 0 ? "" : `export default window.${t}.${e};${n.filter((e) => e !== "default").map((n) => `export const ${n} = window.${t}.${e}.${n};`).join("")}`;
|
|
6
|
-
},
|
|
10
|
+
}, a = (e) => URL.createObjectURL(new Blob([e], { type: "application/javascript" })), o = () => {
|
|
7
11
|
let e = {};
|
|
8
12
|
return typeof document > "u" || document.querySelectorAll("script[type=\"importmap\"]").forEach((t) => {
|
|
9
13
|
if (t.textContent) try {
|
|
@@ -15,21 +19,21 @@ var t = (e) => e.replace(/^@/, "").replace(/[-/]/g, " ").replace(/\b\w/g, (e) =>
|
|
|
15
19
|
console.error("Invalid importmap JSON", e);
|
|
16
20
|
}
|
|
17
21
|
}), e;
|
|
18
|
-
},
|
|
22
|
+
}, s = (e, t = "PlitziFacade") => JSON.stringify({ imports: Object.keys(e).map((e) => ({
|
|
19
23
|
key: e,
|
|
20
|
-
bob:
|
|
24
|
+
bob: a(i(n(e), t))
|
|
21
25
|
})).reduce((e, t) => ({
|
|
22
26
|
...e,
|
|
23
27
|
[t.key]: t.bob
|
|
24
|
-
}), {}) }),
|
|
28
|
+
}), {}) }), c = (e, r = "PlitziFacade") => {
|
|
25
29
|
if (typeof document > "u" || typeof window > "u") return;
|
|
26
|
-
let
|
|
27
|
-
if (Object.keys(
|
|
28
|
-
window
|
|
29
|
-
let c = a
|
|
30
|
+
let i = o(), a = t(e, Object.keys(i));
|
|
31
|
+
if (Object.keys(a).length === 0) return;
|
|
32
|
+
Reflect.set(window, r, Object.fromEntries(Object.entries(a).map(([e, t]) => [n(e), t])));
|
|
33
|
+
let c = s(a, r);
|
|
30
34
|
if (!c) return;
|
|
31
35
|
let l = document.createElement("script");
|
|
32
36
|
l.type = "importmap", l.textContent = c, document.head.appendChild(l);
|
|
33
37
|
};
|
|
34
38
|
//#endregion
|
|
35
|
-
export {
|
|
39
|
+
export { c as default };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -16,6 +16,6 @@ import { INTERVAL_TRIGGER as k, MIN_INTERVAL_MS as A, intervalOf as j } from "./
|
|
|
16
16
|
import { isDate as M } from "./isDate.mjs";
|
|
17
17
|
import { isUserEdit as N } from "./reducerOrigin.mjs";
|
|
18
18
|
import { evaluateRuleGroup as P } from "./ruleEvaluator.mjs";
|
|
19
|
-
import { ParamsFromURL as F, delay as I, emptyObject as L, getDisplayName as R, getKeyDecoded as z,
|
|
19
|
+
import { ParamsFromURL as F, delay as I, emptyObject as L, getDisplayName as R, getKeyDecoded as z, getPathsFromObject as B, hexToRGB as V, isInViewport as H, makeId as U } from "./utils.mjs";
|
|
20
20
|
import { disableReactDevTools as W } from "./security.mjs";
|
|
21
|
-
export { k as INTERVAL_TRIGGER, s as MAX_PARAM_PASSES, A as MIN_INTERVAL_MS, F as ParamsFromURL, h as cookieFromHeader, I as delay, W as disableReactDevTools, g as documentCookies, _ as elementOf, L as emptyObject, P as evaluateRuleGroup, f as fetchManifest, t as filters, x as formatDate, S as formatDateUTC, C as formatFromNow, w as formatUTCToLocal, p as generateFacade, R as getDisplayName, T as getDurationMs, z as getKeyDecoded, B as
|
|
21
|
+
export { k as INTERVAL_TRIGGER, s as MAX_PARAM_PASSES, A as MIN_INTERVAL_MS, F as ParamsFromURL, h as cookieFromHeader, I as delay, W as disableReactDevTools, g as documentCookies, _ as elementOf, L as emptyObject, P as evaluateRuleGroup, f as fetchManifest, t as filters, x as formatDate, S as formatDateUTC, C as formatFromNow, w as formatUTCToLocal, p as generateFacade, R as getDisplayName, T as getDurationMs, z as getKeyDecoded, B as getPathsFromObject, a as hasTemplateSyntax, o as hasValidToken, V as hexToRGB, l as inspectTemplate, j as intervalOf, M as isDate, v as isElementTarget, H as isInViewport, y as isNodeTarget, e as isRecord, N as isUserEdit, E as isValidFormat, U as makeId, b as nodeOf, D as parseDate, n as processTwig, r as processTwigParam, i as processTwigValue, c as resolveStepParam, m as syntaxHighlight, u as templatePaths, d as templateRootNames, O as toUnixSeconds };
|
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FC } from 'react';
|
|
|
2
2
|
export declare function getDisplayName<T = unknown>(WrappedComponent?: FC<T>): string;
|
|
3
3
|
declare const emptyObject: {};
|
|
4
4
|
export { emptyObject };
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const getPathsFromObject: (object?: {
|
|
6
6
|
[key: string]: unknown;
|
|
7
7
|
}, basePath?: string, glue?: string, skipArray?: boolean) => string[];
|
|
8
8
|
export declare const makeId: (length: number, includeMayus?: boolean, includeNumbers?: boolean) => string;
|
package/dist/helpers/utils.mjs
CHANGED
|
@@ -58,4 +58,4 @@ var s = (e) => new Promise((t) => {
|
|
|
58
58
|
return t ? `rgba(${n},${r},${i},${t})` : `rgb(${n},${r},${i})`;
|
|
59
59
|
};
|
|
60
60
|
//#endregion
|
|
61
|
-
export { o as ParamsFromURL, s as delay, n as emptyObject, t as getDisplayName, a as getKeyDecoded, r as
|
|
61
|
+
export { o as ParamsFromURL, s as delay, n as emptyObject, t as getDisplayName, a as getKeyDecoded, r as getPathsFromObject, l as hexToRGB, c as isInViewport, i as makeId };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as useFontHead } from './useFontHead';
|
|
2
2
|
import { default as useNetwork } from './useNetwork';
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as usePlitzi } from './usePlitzi';
|
|
4
4
|
import { default as useStableValue } from './useStableValue';
|
|
5
5
|
export * from './useNetwork';
|
|
6
|
-
export * from './
|
|
7
|
-
export { useFontHead, useNetwork,
|
|
6
|
+
export * from './usePlitzi';
|
|
7
|
+
export { useFontHead, useNetwork, usePlitzi, useStableValue };
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "./useStableValue.mjs";
|
|
2
2
|
import t from "./useFontHead.mjs";
|
|
3
3
|
import n from "./useNetwork.mjs";
|
|
4
|
-
import r, {
|
|
5
|
-
export { i as
|
|
4
|
+
import r, { PlitziContext as i, PlitziProvider as a } from "./usePlitzi.mjs";
|
|
5
|
+
export { i as PlitziContext, a as PlitziProvider, t as useFontHead, n as useNetwork, r as usePlitzi, e as useStableValue };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ColorScheme } from '../types';
|
|
2
|
+
import { ReactNode, RefObject } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* What the host rendering a space — the builder, the SDK, a shadow-rooted widget — tells every element: whether it is
|
|
5
|
+
* being edited or looked at, its scheme, whether it is still hydrating, the window it paints in and the root it hangs
|
|
6
|
+
* from. Only what the host alone knows: a context of another package is imported from that package, never carried here.
|
|
7
|
+
*/
|
|
8
|
+
export type PlitziContextValue = {
|
|
9
|
+
settings: {
|
|
10
|
+
isHydrating?: boolean;
|
|
11
|
+
previewMode?: boolean;
|
|
12
|
+
environment?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
/** Already resolved: an element paints in one of two schemes and has no use for the word `system`. */
|
|
15
|
+
theme: ColorScheme;
|
|
16
|
+
};
|
|
17
|
+
root: {
|
|
18
|
+
baseElementId: string;
|
|
19
|
+
};
|
|
20
|
+
utils: {
|
|
21
|
+
getWindow: () => Window | null;
|
|
22
|
+
rootRef: RefObject<HTMLElement | null>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
declare const PlitziContext: import('react').Context<PlitziContextValue>;
|
|
26
|
+
declare const usePlitzi: () => PlitziContextValue;
|
|
27
|
+
declare const PlitziProvider: (props: {
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
value: PlitziContextValue;
|
|
30
|
+
}) => import('react').JSX.Element;
|
|
31
|
+
export { PlitziProvider, PlitziContext };
|
|
32
|
+
export default usePlitzi;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { sharedContext as e } from "../helpers/sharedContext.mjs";
|
|
2
2
|
import { use as t } from "react";
|
|
3
3
|
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
-
var r = e("
|
|
4
|
+
var r = e("PlitziContext", {}), i = () => {
|
|
5
5
|
let e = t(r);
|
|
6
|
-
if (e === void 0) throw Error("
|
|
6
|
+
if (e === void 0) throw Error("The Plitzi context is undefined. Render the element inside a PlitziProvider.");
|
|
7
7
|
return e;
|
|
8
8
|
}, a = (e) => {
|
|
9
9
|
let { children: t, value: i } = e;
|
|
@@ -13,4 +13,4 @@ var r = e("PlitziServiceContext", {}), i = () => {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
//#endregion
|
|
16
|
-
export { r as
|
|
16
|
+
export { r as PlitziContext, a as PlitziProvider, i as default };
|