@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
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isRecord as e } from "../helpers/isRecord.mjs";
|
|
2
|
+
import { canonicalCondition as t } from "./styleConditions.mjs";
|
|
3
|
+
import { isStylePseudo as n } from "./stylePseudos.mjs";
|
|
4
|
+
import { isParentAncestor as r } from "./styleStates.mjs";
|
|
4
5
|
//#region src/style/styleTarget.ts
|
|
5
|
-
var
|
|
6
|
+
var i = (e) => {
|
|
6
7
|
let t = [];
|
|
7
8
|
return e.styleAncestor ? t.push("ancestors", e.styleAncestor) : e.styleCondition && t.push("conditions", e.styleCondition), e.styleVariant && t.push("variants", e.styleVariant), e.stylePseudo && t.push("pseudos", e.stylePseudo), t.push(...e.styleState ? ["states", e.styleState] : ["default"]), t;
|
|
8
|
-
},
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
14
|
-
if (
|
|
15
|
-
},
|
|
16
|
-
let
|
|
17
|
-
for (let
|
|
18
|
-
if (!
|
|
19
|
-
|
|
9
|
+
}, a = (e) => {
|
|
10
|
+
if (e.styleAncestor && e.styleCondition) return "an ancestor condition cannot also be under a condition";
|
|
11
|
+
if (e.styleAncestor && e.stylePseudo) return "a pseudo-element has no ancestor conditions of its own";
|
|
12
|
+
if (e.styleCondition && e.styleVariant) return "a condition holds the class’s own rules, not its variants’";
|
|
13
|
+
if (e.styleCondition && t(e.styleCondition) !== e.styleCondition) return `"${e.styleCondition}" is not a condition`;
|
|
14
|
+
if (e.stylePseudo && !n(e.stylePseudo)) return `"${String(e.stylePseudo)}" is not a pseudo-element`;
|
|
15
|
+
if (e.styleAncestor && r(e.styleAncestor) && e.styleVariant) return "the element around it is named by its state, never by a variant";
|
|
16
|
+
}, o = (t, n) => {
|
|
17
|
+
let r = t;
|
|
18
|
+
for (let t of n) {
|
|
19
|
+
if (!e(r) || !Object.hasOwn(r, t)) return;
|
|
20
|
+
r = r[t];
|
|
20
21
|
}
|
|
21
|
-
return
|
|
22
|
-
}, s = (
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
let
|
|
26
|
-
|
|
22
|
+
return r;
|
|
23
|
+
}, s = (t, n, r) => {
|
|
24
|
+
let i = t;
|
|
25
|
+
n.slice(0, -1).forEach((t) => {
|
|
26
|
+
let n = i[t], r = e(n) ? n : {};
|
|
27
|
+
i[t] = r, i = r;
|
|
27
28
|
});
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
}, c = (
|
|
31
|
-
let n = o(e,
|
|
29
|
+
let a = n.at(-1);
|
|
30
|
+
a !== void 0 && (i[a] = r);
|
|
31
|
+
}, c = (t) => e(t) && Object.values(t).every((e) => typeof e == "string" || typeof e == "number"), l = (e, t) => {
|
|
32
|
+
let n = o(e, i(t));
|
|
32
33
|
return c(n) ? n : void 0;
|
|
33
34
|
};
|
|
34
35
|
//#endregion
|
|
35
|
-
export { c as isStyleRules, s as setAtKeys,
|
|
36
|
+
export { c as isStyleRules, s as setAtKeys, i as styleTargetKeys, a as styleTargetProblem, l as styleTargetRules, o as valueAtKeys };
|
|
@@ -20,13 +20,18 @@ export type DataSourceUtilityParams<TParams = string | boolean | number> = Recor
|
|
|
20
20
|
}>;
|
|
21
21
|
export type DataSourceUtilityParamsValue<T = string | boolean | number> = Record<keyof DataSourceUtility<T>['params'], T>;
|
|
22
22
|
export type DataSourceUtilityParamType = 'text' | 'select' | 'textarea' | 'checkbox' | 'codemirror-text';
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* A step a binding's value goes through on its way to an attribute. It receives whatever the binding resolved to — or
|
|
25
|
+
* the step before it answered — and a value it has no use for goes on untouched, so both ends are `unknown` unless one
|
|
26
|
+
* says more.
|
|
27
|
+
*/
|
|
28
|
+
export type DataSourceUtility<TSource = unknown, TSourceReturn = unknown, TParams = string | boolean | number> = {
|
|
24
29
|
action: string;
|
|
25
30
|
title: string;
|
|
26
31
|
type: 'utility' | 'unknown';
|
|
27
32
|
params: DataSourceUtilityParams<TParams>;
|
|
28
33
|
preview: Record<string, string>;
|
|
29
|
-
callback: (source: TSource, params: DataSourceUtilityParamsValue<TParams>, element: Partial<Element>, dataSources?: Record<string,
|
|
34
|
+
callback: (source: TSource, params: DataSourceUtilityParamsValue<TParams>, element: Partial<Element>, dataSources?: Record<string, unknown>) => TSourceReturn;
|
|
30
35
|
};
|
|
31
36
|
export type SourceField = {
|
|
32
37
|
path: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** What sdk-event-bridge's context holds: its bridge, whose class is that package's own. */
|
|
2
|
+
export type EventBridgeContextValue<T> = {
|
|
2
3
|
eventBridge: T;
|
|
3
4
|
};
|
|
4
5
|
export type EventBridgeModule = 'main' | 'builder' | 'snippet' | 'interaction' | 'element';
|
|
@@ -30,17 +30,28 @@ export type InteractionCallbackParam<T extends Record<string, unknown> = Record<
|
|
|
30
30
|
* space's credentials of that kind to pick from, rather than a text box somebody has to type an identifier into.
|
|
31
31
|
*/
|
|
32
32
|
credentialProvider?: SpaceCredentialProvider;
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* A space's task refuses to run without it — empty, or only spaces — saying so with the param's `label`, before its
|
|
35
|
+
* code runs: what a task otherwise checked by hand in its first lines.
|
|
36
|
+
*/
|
|
37
|
+
required?: boolean;
|
|
38
|
+
} &
|
|
39
|
+
/** Handed to a task as text, whatever was written or bound — a number as its digits — at most `maxLength` long. */
|
|
40
|
+
({
|
|
34
41
|
type: 'text';
|
|
35
42
|
defaultValue?: string | number;
|
|
43
|
+
maxLength?: number;
|
|
36
44
|
}
|
|
37
|
-
/** Written as text — a number or a template — and handed to the callback as a number
|
|
45
|
+
/** Written as text — a number or a template — and handed to the callback as a number, within `min` and `max`. */
|
|
38
46
|
| {
|
|
39
47
|
type: 'number';
|
|
40
48
|
defaultValue?: number;
|
|
49
|
+
min?: number;
|
|
50
|
+
max?: number;
|
|
41
51
|
} | {
|
|
42
52
|
type: 'textarea';
|
|
43
53
|
defaultValue?: string | number;
|
|
54
|
+
maxLength?: number;
|
|
44
55
|
} | {
|
|
45
56
|
type: 'codemirror-text';
|
|
46
57
|
defaultValue?: string;
|
|
@@ -133,8 +144,35 @@ export type Subscriptor<T extends Record<string, unknown> = Record<string, unkno
|
|
|
133
144
|
id: string;
|
|
134
145
|
triggers: Record<string, Trigger<T>>;
|
|
135
146
|
};
|
|
136
|
-
|
|
137
|
-
|
|
147
|
+
/**
|
|
148
|
+
* The interactions manager as everything outside sdk-interactions reaches it — through its context. Declared here, where
|
|
149
|
+
* every package can name it, and implemented by sdk-interactions' `InteractionsManager`, which the compiler holds to it.
|
|
150
|
+
*
|
|
151
|
+
* Methods, not function-valued fields: a manager's children are managers of its own class, which only this way can
|
|
152
|
+
* stand for the interface.
|
|
153
|
+
*/
|
|
154
|
+
export interface InteractionsManagerApi {
|
|
155
|
+
/** The page's id and its route and query params: what a flow reads as `navigation`. */
|
|
156
|
+
interactionsData: Record<string, string | number | boolean>;
|
|
157
|
+
/**
|
|
158
|
+
* Fires `eventName` on the element `subscriptorId`: the flows it starts, with `params` for them to read — what each
|
|
159
|
+
* answered, or nothing when there is no element to fire on.
|
|
160
|
+
*/
|
|
161
|
+
interactionTrigger(subscriptorId: string | undefined, eventName: string, params?: Record<string, unknown>): Promise<unknown[]> | undefined;
|
|
162
|
+
subscribe<TParams extends Record<string, unknown> = Record<string, unknown>>(id: string, interactions?: Record<string, ElementInteraction>, triggers?: Record<string, InteractionCallback<TParams>>, callbacks?: Record<string, InteractionCallback<TParams>>, getAdditionalParams?: Subscriptor<TParams>['getAdditionalParams']): boolean;
|
|
163
|
+
update<TParams extends Record<string, unknown> = Record<string, unknown>>(id: string, interactions?: Record<string, ElementInteraction>, triggers?: Record<string, InteractionCallback<TParams>>, callbacks?: Record<string, InteractionCallback<TParams>>, getAdditionalParams?: Subscriptor<TParams>['getAdditionalParams']): boolean;
|
|
164
|
+
unsubscribe(id: string): boolean;
|
|
165
|
+
getSubscriptor(subscriptorId: string): Subscriptor | undefined;
|
|
166
|
+
/** Every callback an element answers, by element and action — the step picker's list. */
|
|
167
|
+
getCallbacksAvailables(): Record<string, Record<string, InteractionCallback>>;
|
|
168
|
+
/** A manager for a replica — a list's row — whose route and query params are its own. */
|
|
169
|
+
createChildManager(routeParams?: Record<string, string>, queryParams?: Record<string, string>): InteractionsManagerApi;
|
|
170
|
+
removeChildManager(childManager: InteractionsManagerApi): void;
|
|
171
|
+
/** Called with the time of each change to what is subscribed; answers how to stop. */
|
|
172
|
+
onUpdate(listener: (timestamp: number) => void): () => void;
|
|
173
|
+
}
|
|
174
|
+
export type InteractionsContextValue = {
|
|
175
|
+
interactionsManager: InteractionsManagerApi;
|
|
138
176
|
useInteractions: <T extends Record<string, unknown> = Record<string, unknown>>(props: {
|
|
139
177
|
id?: string;
|
|
140
178
|
interactions?: Record<string, ElementInteraction>;
|
|
@@ -112,7 +112,12 @@ export type RTMessageManagedServer = {
|
|
|
112
112
|
type: RTEvent.COLLABORATOR_DISCONNECTED;
|
|
113
113
|
payload: SubscriptionCollaborator;
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
/** What a message of one event carries, as the server sends it. */
|
|
116
|
+
export type RTPayload<E extends RTEvent> = Extract<RTMessageManagedServer, {
|
|
117
|
+
type: E;
|
|
118
|
+
}>['payload'];
|
|
119
|
+
/** A listener for one realtime event, handed what that event carries. */
|
|
120
|
+
export type RTCallback<E extends RTEvent = RTEvent> = (payload: RTPayload<E>) => void;
|
|
116
121
|
export type RTMessage<T = unknown> = {
|
|
117
122
|
type: RTEvent;
|
|
118
123
|
payload: T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-shared",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.13",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -571,9 +571,9 @@
|
|
|
571
571
|
"types": "./dist/hooks/useNetwork.d.ts",
|
|
572
572
|
"import": "./dist/hooks/useNetwork.mjs"
|
|
573
573
|
},
|
|
574
|
-
"./hooks/
|
|
575
|
-
"types": "./dist/hooks/
|
|
576
|
-
"import": "./dist/hooks/
|
|
574
|
+
"./hooks/usePlitzi": {
|
|
575
|
+
"types": "./dist/hooks/usePlitzi.d.ts",
|
|
576
|
+
"import": "./dist/hooks/usePlitzi.mjs"
|
|
577
577
|
},
|
|
578
578
|
"./hooks/useStableValue": {
|
|
579
579
|
"types": "./dist/hooks/useStableValue.d.ts",
|
|
@@ -1099,6 +1099,10 @@
|
|
|
1099
1099
|
"types": "./dist/network/spaceEvents.d.ts",
|
|
1100
1100
|
"import": "./dist/network/spaceEvents.mjs"
|
|
1101
1101
|
},
|
|
1102
|
+
"./plugins/PluginsContext": {
|
|
1103
|
+
"types": "./dist/plugins/PluginsContext.d.ts",
|
|
1104
|
+
"import": "./dist/plugins/PluginsContext.mjs"
|
|
1105
|
+
},
|
|
1102
1106
|
"./plugins/bundle": {
|
|
1103
1107
|
"types": "./dist/plugins/bundle.d.ts",
|
|
1104
1108
|
"import": "./dist/plugins/bundle.mjs"
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BuilderContextValue } from '../builder';
|
|
2
|
-
import { NetworkContextValue } from '../network';
|
|
3
|
-
import { ComponentContextValue, EventBridgeContextValue, InteractionsContextValue, PluginsContextValue, ColorScheme } from '../types';
|
|
4
|
-
import { Context, ReactNode, RefObject } from 'react';
|
|
5
|
-
export type PlitziServiceContextValue<TEventBridge = any, TInteractions = any> = {
|
|
6
|
-
settings: {
|
|
7
|
-
isHydrating?: boolean;
|
|
8
|
-
previewMode?: boolean;
|
|
9
|
-
environment?: string;
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
/** Already resolved: an element paints in one of two schemes and has no use for the word `system`. */
|
|
12
|
-
theme: ColorScheme;
|
|
13
|
-
};
|
|
14
|
-
root: {
|
|
15
|
-
baseElementId: string;
|
|
16
|
-
};
|
|
17
|
-
utils: {
|
|
18
|
-
getWindow: () => Window | null;
|
|
19
|
-
rootRef: RefObject<HTMLElement | null>;
|
|
20
|
-
};
|
|
21
|
-
customContexts: Record<string, Context<any>>;
|
|
22
|
-
contexts: {
|
|
23
|
-
ComponentContext: Context<ComponentContextValue>;
|
|
24
|
-
EventBridgeContext: Context<EventBridgeContextValue<TEventBridge>>;
|
|
25
|
-
PluginsContext: Context<PluginsContextValue>;
|
|
26
|
-
InteractionsContext: Context<InteractionsContextValue<TInteractions>>;
|
|
27
|
-
NetworkContext: Context<NetworkContextValue>;
|
|
28
|
-
BuilderContext?: Context<BuilderContextValue>;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
declare const PlitziServiceContext: Context<PlitziServiceContextValue<any, any>>;
|
|
32
|
-
declare const usePlitziServiceContext: <TEventBridge = any, TInteractions = any>() => PlitziServiceContextValue<TEventBridge, TInteractions>;
|
|
33
|
-
declare const PlitziServiceProvider: (props: {
|
|
34
|
-
children?: ReactNode;
|
|
35
|
-
value: PlitziServiceContextValue;
|
|
36
|
-
}) => import('react').JSX.Element;
|
|
37
|
-
export { PlitziServiceProvider, PlitziServiceContext };
|
|
38
|
-
export default usePlitziServiceContext;
|