@plitzi/plitzi-builder 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 +139 -0
- package/dist/App.d.ts +5 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.html +1 -0
- package/dist/modules/App/AppContext.d.ts +2 -0
- package/dist/modules/App/AppMain.d.ts +2 -1
- package/dist/modules/Builder/helpers/canvasIcons.d.ts +10 -0
- package/dist/modules/Builder/helpers/canvasIcons.test.d.ts +1 -0
- package/dist/modules/Network/contexts/BuilderSubscriptionsContext.d.ts +1 -1
- package/dist/modules/Queue/QueueContext.d.ts +11 -2
- package/dist/modules/Queue/hooks/useQueueManager.d.ts +2 -2
- package/dist/modules/Undoable/UndoableContext.d.ts +12 -3
- package/dist/modules/Undoable/UndoableReducer.d.ts +10 -9
- package/dist/package.json.d.ts +1 -1
- package/dist/plitzi-builder.css +1 -1
- package/dist/plitzi-builder.css.gz +0 -0
- package/dist/plitzi-builder.js +2521 -2558
- package/dist/plitzi-builder.js.gz +0 -0
- package/dist/plitzi-functions-worker.js +1 -1
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,144 @@
|
|
|
1
1
|
# @plitzi/plitzi-builder
|
|
2
2
|
|
|
3
|
+
## 0.38.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.38.13
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @plitzi/plitzi-sdk@0.38.13
|
|
10
|
+
- @plitzi/sdk-auth@0.38.13
|
|
11
|
+
- @plitzi/sdk-authoring@0.38.13
|
|
12
|
+
- @plitzi/sdk-dev-tools@0.38.13
|
|
13
|
+
- @plitzi/sdk-elements@0.38.13
|
|
14
|
+
- @plitzi/sdk-event-bridge@0.38.13
|
|
15
|
+
- @plitzi/sdk-interactions@0.38.13
|
|
16
|
+
- @plitzi/sdk-navigation@0.38.13
|
|
17
|
+
- @plitzi/sdk-plugins@0.38.13
|
|
18
|
+
- @plitzi/sdk-schema@0.38.13
|
|
19
|
+
- @plitzi/sdk-shared@0.38.13
|
|
20
|
+
- @plitzi/sdk-style@0.38.13
|
|
21
|
+
- @plitzi/sdk-variables@0.38.13
|
|
22
|
+
|
|
23
|
+
## 0.38.12
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 1301338: ## Builder
|
|
28
|
+
|
|
29
|
+
- **Icons in the canvas again** (`@plitzi/plitzi-builder`): the canvas inlined the SDK's Font Awesome sheet into its
|
|
30
|
+
`<style>`, where the sheet's `url(webfonts/…)` resolved against the editor's URL — a `srcdoc` frame takes it as its
|
|
31
|
+
base — so every icon was a 404 under `/spaces/<space>/webfonts/` and drew as an empty box. Only the Vite dev server,
|
|
32
|
+
which rewrites the URL, hid it. The canvas and the element preview now link the sheet from where the host serves it:
|
|
33
|
+
a new prop, `sdkIconsStylePath`, the one the host already gives the pages it renders
|
|
34
|
+
(`/sdk-assets/plitzi-sdk-icons.css` for sdk-server). Absent, the canvas links no icon sheet.
|
|
35
|
+
|
|
36
|
+
## Plugins
|
|
37
|
+
- **A plugin's other elements, hosted by `custom`** (`@plitzi/sdk-elements`): `custom({ renderType: 'jamDisc' })` on a
|
|
38
|
+
space with a plugin installed whose main element is another (`plitzi plugin pack` of several folders: the first is the
|
|
39
|
+
plugin, the rest go in it) rendered "Custom Component jamDisc Not Found" — the page registers only the plugin's main
|
|
40
|
+
element, and a `custom` host looked nowhere else. It now loads the type from the installed plugin that packs it, as
|
|
41
|
+
an element of the type itself always did, so the two ways the docs give to place a plugin's element are the same
|
|
42
|
+
everywhere: in a project `plitzi create` wrote, and once the project is on Plitzi.
|
|
43
|
+
- **One way to place a plugin's element** (`@plitzi/sdk-authoring`, `@plitzi/cli`, docs): from its declaration,
|
|
44
|
+
`const seatPicker = defineElement(declaration)` then `seatPicker({ id, … })` — typed by what it
|
|
45
|
+
declares, and the element the builder adds when somebody drops it. The welcome space `plitzi create` writes, the
|
|
46
|
+
plugin package's preview, `plitzi plugin add` and `plitzi explain` all write it so (the template's
|
|
47
|
+
`PluginHostOptions` now takes the plugin's `type` and `declaration: { from, attributes? }`; `custom`/`element` hosting
|
|
48
|
+
is gone). `pluginFolders(folder)` (`@plitzi/sdk-authoring/node`) reads each plugin with the folder it is in;
|
|
49
|
+
`pluginDeclarations` is built on it. A `custom({ renderType })` naming a plugin the space was handed the declaration
|
|
50
|
+
of is offered the declaration instead — suggestion `plugin-custom-host`. `custom` stays for a component registered
|
|
51
|
+
by name with no declaration. The skills, the CLI README, the MCP guide, `docs/en` and the website say the same.
|
|
52
|
+
- **`definePlugin`** (`@plitzi/sdk-authoring/plugin`, a new entry of 3 KB with nothing else in it): a plugin's
|
|
53
|
+
declaration written from what only it can say —
|
|
54
|
+
`definePlugin<SeatPickerAttributes>()({ type, label, attributes, triggers, callbacks })` — and every other field
|
|
55
|
+
at the default all plugins share (the builder's gestures, the catalogue entry, each attribute bindable, an empty
|
|
56
|
+
style). It answers the whole declaration, branded with its attributes, so `defineElement(declaration)` is typed
|
|
57
|
+
without a generic. `plitzi plugin add` and `create --plugin` write declarations with it (about a third of the lines).
|
|
58
|
+
- **`usePluginTrigger(declaration)`** (`@plitzi/plitzi-sdk`): fires a plugin's declared event on its element — the
|
|
59
|
+
event name and what each hands a flow typed off the declaration's `preview` — on a live page only. The hook every
|
|
60
|
+
plugin wrote for itself (and `plugin add` generated as `use<Name>Events`) is gone from the scaffold.
|
|
61
|
+
- **Attributes as the types their defaults are** (`@plitzi/sdk-elements`): a plugin's attribute bound from text — a
|
|
62
|
+
state, a row, a channel message — reaches its component as the number or the flag its declared default is (`'112'`
|
|
63
|
+
as 112, `'true'` as true). A plugin no longer types its props `number | string` and parses them.
|
|
64
|
+
|
|
65
|
+
## Server actions and functions
|
|
66
|
+
- **Task params with rules** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a task declares `required`, a text's
|
|
67
|
+
`maxLength` and a number's `min`/`max`, and the runner refuses a call that breaks any of them — every rule broken at
|
|
68
|
+
once, in the words the page shows (`Title is required; Seconds is at most 300`) — before the code runs. A `text` param
|
|
69
|
+
bound to a number arrives as its digits. The manifest keeps the rules, so the platform's sandbox checks the same.
|
|
70
|
+
- **`taskAction(task, { trigger })`** (`@plitzi/sdk-authoring`): the action that runs one of the space's tasks and
|
|
71
|
+
answers its result, derived from the task — its id (`<namespace>-<action>`), name, description and input (the task's
|
|
72
|
+
params, once). An action of more than one step is still `defineAction`.
|
|
73
|
+
- **`ctx.rateLimit(bucket, { …, refuse })`**: past the limit the call is refused with those words instead of answering
|
|
74
|
+
`allowed: false` for the code to check — natively and in the sandbox.
|
|
75
|
+
|
|
76
|
+
## Authoring
|
|
77
|
+
- **`runServerActionOrNotify(id, params, fallback)`**: a server action run and the notice the visitor reads when it
|
|
78
|
+
fails — the action's own refusal, or the fallback — as two steps to spread into a flow.
|
|
79
|
+
- **`repeated-shape` reads what copies bind**: copies whose bindings read their data in different forms (a count, a
|
|
80
|
+
total of a quota) and copies holding a provider resolved on the server (found by its own id) are no longer offered
|
|
81
|
+
as one component.
|
|
82
|
+
- **`element-color-inherited`** (suggestion): `elements` giving a heading, a text, a link… `color: inherit` or the
|
|
83
|
+
page's own colour. **A link inherits the page's colour** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-elements`) rather than
|
|
84
|
+
holding the SDK's grey — the same by default, and the space's palette inside a card that is a link. The template
|
|
85
|
+
every space starts from writes its colours once, on the page.
|
|
86
|
+
|
|
87
|
+
## Fixes
|
|
88
|
+
- **A dialog opened with an id** (`@plitzi/sdk-elements`): `openDialog('dialog', '{{ row.id }}')` reads the id as its
|
|
89
|
+
`content`, as `openModal` already did — a numeric id parsed as the number and the dialog's bindings read nothing.
|
|
90
|
+
- **A select's chevron** (`@plitzi/plitzi-sdk`): a drawn chevron in the field's own colour, sized by its type, in place
|
|
91
|
+
of the `▼` glyph — and laid out in the box, so it ends where the box's padding begins whatever that padding is, and
|
|
92
|
+
the chosen option stops short of it instead of running under it. A disabled select's is faded.
|
|
93
|
+
- **Every element has its settings** (`@plitzi/plitzi-builder`, `@plitzi/sdk-elements`): the builder found none for
|
|
94
|
+
`tabContainerHeader` (registered under a misspelt type), `themeToggle`, `dropdownPopup`, `loading` and `notFound`.
|
|
95
|
+
The theme toggle's panel sets its mode, its labels and whether it offers "System"; the registry is typed by element
|
|
96
|
+
type and must hold one for each.
|
|
97
|
+
- **A plugin's panel** (`@plitzi/cli`): `plitzi doctor` warns of a plugin with no `Settings.tsx`, or one its entry never
|
|
98
|
+
passes as `pluginSettings` (`plugin-settings-missing`); the example `create` writes has its panel, as every element
|
|
99
|
+
`plugin add` writes does, and the panels it generates are laid out as the project's Prettier lays them out.
|
|
100
|
+
- **A refused or failed run reaches `onFlowError` in every mode** (`@plitzi/sdk-interactions`): an awaited server
|
|
101
|
+
action the server refused fired no `onFlowError` on the element that started it, as `detached` and `stream` ones do
|
|
102
|
+
— a board rolling its edits back on a refusal never did; and a run answered `status: 'failed'` fired `onFlowEnd`
|
|
103
|
+
(detached) or nothing (awaited) rather than `onFlowError`.
|
|
104
|
+
- **A source renamed** (`@plitzi/sdk-shared`): the binding picker lists a provider, a form or a modal by the name its
|
|
105
|
+
element has now, not the one it had when it mounted.
|
|
106
|
+
- **A text's words in the builder** (`@plitzi/sdk-elements`): a `paragraph`, `text` or `heading` whose `content` is
|
|
107
|
+
`0` shows `0` while editing too, not its placeholder; one bound to nothing shows nothing rather than `null`.
|
|
108
|
+
- **Built-in declarations** (`@plitzi/sdk-shared`): `elementDeclaration` fills in what every element shares — the
|
|
109
|
+
builder's gestures, Plitzi's catalogue entry, a visible element with no bindings, its style named by its label —
|
|
110
|
+
from the defaults `definePlugin` uses; each element's declaration says only what is its own (a third of the lines).
|
|
111
|
+
|
|
112
|
+
## Typed for plugins and hosts
|
|
113
|
+
- **`usePlitzi()` and `PlitziProvider`** (`@plitzi/sdk-shared/hooks/usePlitzi`, `@plitzi/plitzi-sdk`): what were
|
|
114
|
+
`usePlitziServiceContext()` and `PlitziServiceProvider` (and `PlitziServiceContextValue`, now `PlitziContextValue`),
|
|
115
|
+
holding only what the host rendering a space knows — `settings`, `root`, `utils`. Its `contexts` and
|
|
116
|
+
`customContexts` are gone: every context it carried is a shared one already, imported from its own module
|
|
117
|
+
(`@plitzi/sdk-interactions/InteractionsContext`, `@plitzi/sdk-shared/network/NetworkContext`…), and
|
|
118
|
+
`PluginsContext` moves to `@plitzi/sdk-shared/plugins/PluginsContext` beside the others.
|
|
119
|
+
- **`InteractionsManagerApi`** (`@plitzi/sdk-shared`): the interactions manager as everything outside
|
|
120
|
+
`@plitzi/sdk-interactions` reaches it, declared where every package can name it and implemented by
|
|
121
|
+
`InteractionsManager`, so `use(InteractionsContext)` is typed — `interactionTrigger`, `createChildManager`… — where it
|
|
122
|
+
was `any`.
|
|
123
|
+
- **`getPathsFromObject`** (`@plitzi/sdk-shared/helpers/utils`), spelt right; `getPathsFromObeject` is gone.
|
|
124
|
+
- **`ElementWords` places itself** (`@plitzi/sdk-elements`): `contentPlacement` and the element's children, so a button
|
|
125
|
+
and a link write their words once.
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [1301338]
|
|
128
|
+
- @plitzi/plitzi-sdk@0.38.12
|
|
129
|
+
- @plitzi/sdk-auth@0.38.12
|
|
130
|
+
- @plitzi/sdk-authoring@0.38.12
|
|
131
|
+
- @plitzi/sdk-dev-tools@0.38.12
|
|
132
|
+
- @plitzi/sdk-elements@0.38.12
|
|
133
|
+
- @plitzi/sdk-event-bridge@0.38.12
|
|
134
|
+
- @plitzi/sdk-interactions@0.38.12
|
|
135
|
+
- @plitzi/sdk-navigation@0.38.12
|
|
136
|
+
- @plitzi/sdk-plugins@0.38.12
|
|
137
|
+
- @plitzi/sdk-schema@0.38.12
|
|
138
|
+
- @plitzi/sdk-shared@0.38.12
|
|
139
|
+
- @plitzi/sdk-style@0.38.12
|
|
140
|
+
- @plitzi/sdk-variables@0.38.12
|
|
141
|
+
|
|
3
142
|
## 0.38.11
|
|
4
143
|
|
|
5
144
|
### Patch Changes
|
package/dist/App.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export type AppProps = {
|
|
|
13
13
|
* of this package, from wherever the host serves the builder's files. Absent, the panel edits and saves without it.
|
|
14
14
|
*/
|
|
15
15
|
functionsWorkerUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Where the SDK's Font Awesome sheet (`plitzi-sdk-icons.css`) is served, with its `webfonts/` beside it — the one
|
|
18
|
+
* the host already gives the pages it renders. The canvas links it; absent, its icons draw as empty boxes.
|
|
19
|
+
*/
|
|
20
|
+
sdkIconsStylePath?: string;
|
|
16
21
|
};
|
|
17
22
|
declare const App: (props: AppProps) => import('react').JSX.Element;
|
|
18
23
|
export default App;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { default as PluginRemote } from '@plitzi/sdk-elements/Element/PluginRemo
|
|
|
8
8
|
import { default as ReplicaProvider } from '@plitzi/sdk-elements/Element/ReplicaProvider';
|
|
9
9
|
import { default as RootElement } from '@plitzi/sdk-elements/Element/RootElement';
|
|
10
10
|
import { default as ComponentContext } from '@plitzi/sdk-shared/elements/ComponentContext';
|
|
11
|
-
import { default as
|
|
11
|
+
import { default as usePlitzi, PlitziProvider } from '@plitzi/sdk-shared/hooks/usePlitzi';
|
|
12
12
|
import { useBuilderStore } from '@plitzi/sdk-shared/store';
|
|
13
13
|
import { AppProps } from './App';
|
|
14
14
|
import { ComponentPlugin, RenderMode, Server } from '@plitzi/sdk-shared';
|
|
@@ -29,11 +29,12 @@ export type PlitziBuilderProps = {
|
|
|
29
29
|
state?: object;
|
|
30
30
|
debugMode?: boolean;
|
|
31
31
|
functionsWorkerUrl?: AppProps['functionsWorkerUrl'];
|
|
32
|
+
sdkIconsStylePath?: AppProps['sdkIconsStylePath'];
|
|
32
33
|
};
|
|
33
34
|
declare const PlitziBuilder: {
|
|
34
35
|
(props: PlitziBuilderProps): import('react').JSX.Element;
|
|
35
36
|
Plugin: (_props: import('./modules/Builder/BuilderPlugin').BuilderPluginProps) => undefined;
|
|
36
37
|
};
|
|
37
38
|
export declare const version: string;
|
|
38
|
-
export { useBuilderStore, ComponentProvider, ComponentContext,
|
|
39
|
+
export { useBuilderStore, ComponentProvider, ComponentContext, usePlitzi, PlitziProvider, RootElement, withElement, JsxManager, PluginManager, PluginRemote, ReplicaProvider, useElement, useRscData };
|
|
39
40
|
export default PlitziBuilder;
|
package/dist/index.html
CHANGED
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
userKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaXNzIjoiaHR0cHM6Ly9zZXJ2ZXIucGxpdHppLmxvY2FsIiwiYXVkIjpbImh0dHBzOi8vcGxpdHppLmxvY2FsIiwiaHR0cHM6Ly9hcHAucGxpdHppLmxvY2FsIiwiaHR0cHM6Ly9hcHAucGxpdHppLmxvY2FsOjMwMDAiLCJodHRwczovL2FwcC5wbGl0emkubG9jYWw6MzAwMSIsImh0dHBzOi8vYXBpLnBsaXR6aS5sb2NhbCIsImh0dHBzOi8vc3NyLnBsaXR6aS5sb2NhbCIsImh0dHBzOi8vc2VydmVyLnBsaXR6aS5sb2NhbCIsImh0dHBzOi8vbWNwLnBsaXR6aS5sb2NhbCIsImh0dHBzOi8vYXV0aC5wbGl0emkubG9jYWwiLCJodHRwOi8vMTI3LjAuMC4xOjUzMDAiLCJodHRwOi8vbG9jYWxob3N0OjUxODAiXSwic2NvcGUiOiJ1c2VyIiwiZXhwIjoxNzkxNTQ1ODcxLCJpYXQiOjE3OTE0NTk0NzEsImp0aSI6IjMwNjQ3NmFlN2YzOTgwMmMiLCJuYmYiOjE3OTE0NTk0NzF9.1yw4JxzN9qkssRYSHAqg4hjFRvatT82PkYVGwF3SP_I',
|
|
57
57
|
environment: 'main',
|
|
58
58
|
functionsWorkerUrl: '/plitzi-functions-worker.js',
|
|
59
|
+
sdkIconsStylePath: '',
|
|
59
60
|
server: {
|
|
60
61
|
basePath: '',
|
|
61
62
|
// Dashboard
|
|
@@ -27,6 +27,8 @@ export type AppContextValue = {
|
|
|
27
27
|
setMobilePreview: Dispatch<SetStateAction<boolean>>;
|
|
28
28
|
/** Where the Functions panel's TypeScript worker is served; empty when the host serves none. */
|
|
29
29
|
functionsWorkerUrl: string;
|
|
30
|
+
/** Where the SDK's icon sheet is served, for the canvases to link; empty when the host serves none. */
|
|
31
|
+
sdkIconsStylePath: string;
|
|
30
32
|
};
|
|
31
33
|
declare const AppContext: import('react').Context<AppContextValue>;
|
|
32
34
|
export default AppContext;
|
|
@@ -14,6 +14,7 @@ export type AppMainProps = {
|
|
|
14
14
|
children?: ReactNode;
|
|
15
15
|
debugMode?: boolean;
|
|
16
16
|
functionsWorkerUrl?: string;
|
|
17
|
+
sdkIconsStylePath?: string;
|
|
17
18
|
};
|
|
18
|
-
declare const AppMain: ({ webKey, webId, userKey, instanceId, server, environment, includeSubscriptions, includeRealTime, externalStyle, debugMode, functionsWorkerUrl }: AppMainProps) => import('react').JSX.Element;
|
|
19
|
+
declare const AppMain: ({ webKey, webId, userKey, instanceId, server, environment, includeSubscriptions, includeRealTime, externalStyle, debugMode, functionsWorkerUrl, sdkIconsStylePath }: AppMainProps) => import('react').JSX.Element;
|
|
19
20
|
export default AppMain;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Asset } from '@plitzi/sdk-shared';
|
|
2
|
+
/**
|
|
3
|
+
* The SDK's Font Awesome sheet in a canvas: linked, never inlined.
|
|
4
|
+
*
|
|
5
|
+
* The sheet names its fonts relative to itself (`webfonts/…`), so they are found wherever the sheet is served from.
|
|
6
|
+
* Inlined into the canvas's `<style>` they resolved against the document instead — a `srcdoc` frame takes the editor's
|
|
7
|
+
* URL as its base — and every icon was a 404 under `/spaces/<space>/webfonts/`. Only the Vite dev server, which
|
|
8
|
+
* rewrites the URL, hid it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const canvasIconsAssets: (href: string) => Record<string, Asset>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,7 @@ export type BuilderSubscriptionsContextValue = {
|
|
|
3
3
|
includeSubscriptions: boolean;
|
|
4
4
|
supportRealTime: boolean;
|
|
5
5
|
subscriptionsPush: (data: RTMessageManagedClient) => void;
|
|
6
|
-
subscriptionsRegisterCallback: (type:
|
|
6
|
+
subscriptionsRegisterCallback: <E extends RTEvent>(type: E, callback: RTCallback<E>, subscriberId?: string) => void;
|
|
7
7
|
subscriptionsUnregisterCallback: (type: RTEvent, subscriberId?: string) => void;
|
|
8
8
|
};
|
|
9
9
|
declare const BuilderSubscriptionsContext: import('react').Context<BuilderSubscriptionsContextValue>;
|
|
@@ -3,14 +3,23 @@ import { SchemaReducerActions } from '@plitzi/sdk-schema/SchemaReducer';
|
|
|
3
3
|
import { Schema, Style } from '@plitzi/sdk-shared';
|
|
4
4
|
import { StyleReducerActions } from '@plitzi/sdk-style/StyleReducer';
|
|
5
5
|
import { ActionDispatch } from 'react';
|
|
6
|
-
export type QueueItem<TState
|
|
6
|
+
export type QueueItem<TState, TDispatchAction> = {
|
|
7
7
|
action: TDispatchAction;
|
|
8
8
|
prevState: TState;
|
|
9
9
|
state: TState;
|
|
10
10
|
dispatch: ActionDispatch<[action: TDispatchAction]>;
|
|
11
11
|
};
|
|
12
|
+
/** A change the queue sends: to the schema or to the style, each with its own reducer's state and action. */
|
|
13
|
+
export type QueuedChange = ({
|
|
14
|
+
kind: 'schema';
|
|
15
|
+
} & QueueItem<Schema, SchemaReducerActions>) | ({
|
|
16
|
+
kind: 'style';
|
|
17
|
+
} & QueueItem<Style, StyleReducerActions>);
|
|
12
18
|
export type QueueContextValue = {
|
|
13
|
-
|
|
19
|
+
/** What queues the schema reducer's changes, as its middleware. */
|
|
20
|
+
enqueueSchema: ReducerMiddlewareCallback<Schema, [action: SchemaReducerActions]>;
|
|
21
|
+
/** What queues the style reducer's changes, as its middleware. */
|
|
22
|
+
enqueueStyle: ReducerMiddlewareCallback<Style, [action: StyleReducerActions]>;
|
|
14
23
|
};
|
|
15
24
|
declare const QueueContext: import('react').Context<QueueContextValue>;
|
|
16
25
|
export default QueueContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueuedChange } from '../QueueContext';
|
|
2
2
|
import { BuilderMutationsMap, BuilderQueriesMap } from '@plitzi/sdk-shared';
|
|
3
3
|
import { NetworkContextValue } from '@plitzi/sdk-shared/network/NetworkContext';
|
|
4
4
|
export type UseQueueManagerProps = {
|
|
@@ -9,7 +9,7 @@ export type UseQueueManagerProps = {
|
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
};
|
|
11
11
|
declare const useQueueManager: ({ delay, mutate, maxRetries, retryTimeout, disabled }: UseQueueManagerProps) => {
|
|
12
|
-
enqueue: (item:
|
|
12
|
+
enqueue: (item: QueuedChange) => void;
|
|
13
13
|
processing: boolean;
|
|
14
14
|
};
|
|
15
15
|
export default useQueueManager;
|
|
@@ -4,21 +4,30 @@ import { SchemaReducerActions } from '@plitzi/sdk-schema/SchemaReducer';
|
|
|
4
4
|
import { Schema, Style } from '@plitzi/sdk-shared';
|
|
5
5
|
import { StyleReducerActions } from '@plitzi/sdk-style/StyleReducer';
|
|
6
6
|
import { ActionDispatch } from 'react';
|
|
7
|
-
export type UndoableItem<TState
|
|
7
|
+
export type UndoableItem<TState, TDispatchAction> = {
|
|
8
8
|
action: TDispatchAction;
|
|
9
9
|
dispatch: ActionDispatch<[action: TDispatchAction]>;
|
|
10
10
|
nextState: TState;
|
|
11
11
|
prevState: TState;
|
|
12
12
|
};
|
|
13
|
+
/** A change the history keeps: to the schema or to the style, each with its own reducer's state and action. */
|
|
14
|
+
export type UndoableChange = ({
|
|
15
|
+
kind: 'schema';
|
|
16
|
+
} & UndoableItem<Schema, SchemaReducerActions>) | ({
|
|
17
|
+
kind: 'style';
|
|
18
|
+
} & UndoableItem<Style, StyleReducerActions>);
|
|
13
19
|
export type UndoableContextValue = {
|
|
14
20
|
canUndo: boolean;
|
|
15
21
|
canRedo: boolean;
|
|
16
22
|
dispatchUndoable: ActionDispatch<[action: UndoableReducerActions]>;
|
|
17
|
-
undoableAddUndo: (
|
|
23
|
+
undoableAddUndo: (change: UndoableChange) => void;
|
|
18
24
|
undoableUndo: () => void;
|
|
19
25
|
undoableRedo: () => void;
|
|
20
26
|
undoableClearHistory: () => void;
|
|
21
|
-
|
|
27
|
+
/** What remembers the schema reducer's changes, as its middleware. */
|
|
28
|
+
undoableSchema: ReducerMiddlewareCallback<Schema, [action: SchemaReducerActions]>;
|
|
29
|
+
/** What remembers the style reducer's changes, as its middleware. */
|
|
30
|
+
undoableStyle: ReducerMiddlewareCallback<Style, [action: StyleReducerActions]>;
|
|
22
31
|
};
|
|
23
32
|
declare const UndoableContext: import('react').Context<UndoableContextValue>;
|
|
24
33
|
export default UndoableContext;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type UndoableReducerActions =
|
|
1
|
+
import { UndoableChange } from './UndoableContext';
|
|
2
|
+
export type UndoableReducerActions = {
|
|
3
3
|
type: 'undoableAddUndo';
|
|
4
|
-
|
|
4
|
+
change: UndoableChange;
|
|
5
|
+
} | {
|
|
5
6
|
type: 'undoableUndo';
|
|
6
|
-
past:
|
|
7
|
-
future:
|
|
7
|
+
past: UndoableChange[];
|
|
8
|
+
future: UndoableChange[];
|
|
8
9
|
} | {
|
|
9
10
|
type: 'undoableRedo';
|
|
10
|
-
past:
|
|
11
|
-
future:
|
|
11
|
+
past: UndoableChange[];
|
|
12
|
+
future: UndoableChange[];
|
|
12
13
|
} | {
|
|
13
14
|
type: 'undoableClearHistory';
|
|
14
15
|
};
|
|
15
16
|
export type UndoableState = {
|
|
16
|
-
past:
|
|
17
|
-
future:
|
|
17
|
+
past: UndoableChange[];
|
|
18
|
+
future: UndoableChange[];
|
|
18
19
|
canUndo: boolean;
|
|
19
20
|
canRedo: boolean;
|
|
20
21
|
};
|