@plitzi/sdk-shared 0.31.2 → 0.32.0

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.32.0
4
+
5
+ ### Minor Changes
6
+
7
+ - v0.32.0
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @plitzi/nexus@0.32.0
13
+
3
14
  ## 0.31.2
4
15
 
5
16
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import { BuilderContextValue } from '../builder';
2
2
  import { NetworkContextValue } from '../network';
3
- import { CollectionContextValue, ComponentContextValue, EventBridgeContextValue, InteractionsContextValue, NavigationContextValue, PluginsContextValue, SegmentsContextValue, StateManagerContextValue, Theme } from '../types';
3
+ import { CollectionContextValue, ComponentContextValue, EventBridgeContextValue, InteractionsContextValue, NavigationContextValue, PluginsContextValue, SegmentsContextValue, Theme } from '../types';
4
4
  import { Context, ReactNode, RefObject } from 'react';
5
5
  export type PlitziServiceContextValue<TEventBridge = any, TInteractions = any> = {
6
6
  settings: {
@@ -23,7 +23,6 @@ export type PlitziServiceContextValue<TEventBridge = any, TInteractions = any> =
23
23
  NavigationContext: Context<NavigationContextValue>;
24
24
  CollectionContext: Context<CollectionContextValue>;
25
25
  ComponentContext: Context<ComponentContextValue>;
26
- StateManagerContext: Context<StateManagerContextValue>;
27
26
  EventBridgeContext: Context<EventBridgeContextValue<TEventBridge>>;
28
27
  PluginsContext: Context<PluginsContextValue>;
29
28
  InteractionsContext: Context<InteractionsContextValue<TInteractions>>;
package/dist/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export * from './websockets';
14
14
  export * from './devTools';
15
15
  export * from './theme';
16
16
  export * from './server';
17
+ export * from './state';
package/dist/index.mjs CHANGED
@@ -34,4 +34,5 @@ import fe, { ThemeContext as pe } from "./theme/ThemeProvider.mjs";
34
34
  import me from "./server/rsc/RscContext.mjs";
35
35
  import he from "./server/hooks/useRscData.mjs";
36
36
  import ge from "./server/rsc/RscProvider.mjs";
37
- export { e as BuilderContext, ee as BuilderMutations, te as BuilderQueries, ne as BuilderSubscriptions, n as CollectionContext, I as ComponentContext, M as DevToolsContext, X as EMPTY_SCHEMA, G as EMPTY_STYLE_SCHEMA, L as ElementContext, Q as NetworkContext, $ as NetworkInternalContext, _ as ParamsFromURL, N as PlitziConsole, V as PlitziServiceContext, H as PlitziServiceProvider, oe as RTCodec, se as RTEvent, ce as RTEventCloseCode, me as RscContext, ge as RscProvider, Y as SchemaContext, re as SdkMutations, ie as SdkQueries, ae as SegmentsContext, K as StyleBindingsAllowed, U as StyleVariableCategory, pe as ThemeContext, fe as ThemeProvider, Z as VARIABLE_REGEX, q as baseDefaultValue, t as contexts, P as createStoreDevToolsLogger, k as createStripTypenameLink, v as delay, O as disableReactDevTools, y as emptyObject, r as fetchManifest, o as formatDate, s as formatDateUTC, c as formatFromNow, l as formatUTCToLocal, i as generateFacade, b as generateID, x as getDisplayName, u as getDurationMs, le as getInstance, S as getKeyDecoded, C as getPathsFromObeject, h as hasValidToken, w as hexToRGB, J as inheritableAttributesBase, d as isDate, T as isInViewport, ue as isRTEvent, E as isTestMode, f as isValidFormat, D as makeId, F as pConsole, p as parseDate, g as processTwig, de as setInstance, A as stripTypenameDeep, W as styleConstants, a as syntaxHighlight, m as toUnixSeconds, R as useElement, z as useNetwork, B as usePlitziServiceContext, j as useRegisterSource, he as useRscData };
37
+ import { runtimeStatePersist as _e } from "./state/runtimeStatePersist.mjs";
38
+ export { e as BuilderContext, ee as BuilderMutations, te as BuilderQueries, ne as BuilderSubscriptions, n as CollectionContext, I as ComponentContext, M as DevToolsContext, X as EMPTY_SCHEMA, G as EMPTY_STYLE_SCHEMA, L as ElementContext, Q as NetworkContext, $ as NetworkInternalContext, _ as ParamsFromURL, N as PlitziConsole, V as PlitziServiceContext, H as PlitziServiceProvider, oe as RTCodec, se as RTEvent, ce as RTEventCloseCode, me as RscContext, ge as RscProvider, Y as SchemaContext, re as SdkMutations, ie as SdkQueries, ae as SegmentsContext, K as StyleBindingsAllowed, U as StyleVariableCategory, pe as ThemeContext, fe as ThemeProvider, Z as VARIABLE_REGEX, q as baseDefaultValue, t as contexts, P as createStoreDevToolsLogger, k as createStripTypenameLink, v as delay, O as disableReactDevTools, y as emptyObject, r as fetchManifest, o as formatDate, s as formatDateUTC, c as formatFromNow, l as formatUTCToLocal, i as generateFacade, b as generateID, x as getDisplayName, u as getDurationMs, le as getInstance, S as getKeyDecoded, C as getPathsFromObeject, h as hasValidToken, w as hexToRGB, J as inheritableAttributesBase, d as isDate, T as isInViewport, ue as isRTEvent, E as isTestMode, f as isValidFormat, D as makeId, F as pConsole, p as parseDate, g as processTwig, _e as runtimeStatePersist, de as setInstance, A as stripTypenameDeep, W as styleConstants, a as syntaxHighlight, m as toUnixSeconds, R as useElement, z as useNetwork, B as usePlitziServiceContext, j as useRegisterSource, he as useRscData };
@@ -0,0 +1 @@
1
+ export * from './runtimeStatePersist';
@@ -0,0 +1,2 @@
1
+ import { runtimeStatePersist as e } from "./runtimeStatePersist.mjs";
2
+ export { e as runtimeStatePersist };
@@ -0,0 +1,3 @@
1
+ import { CommonState } from '../types';
2
+ import { StoreMiddleware } from '@plitzi/nexus';
3
+ export declare const runtimeStatePersist: <TState extends CommonState>(webId: number) => StoreMiddleware<TState>;
@@ -0,0 +1,12 @@
1
+ import { persistMiddleware as e } from "@plitzi/nexus";
2
+ //#region src/state/runtimeStatePersist.ts
3
+ var t = (t) => e({
4
+ key: `plitzi_${t}_state`,
5
+ paths: ["runtime.state"],
6
+ storage: ({ schema: e }) => {
7
+ let t = e?.settings;
8
+ return t?.keepState ? t.stateStorage === "sessionStorage" ? "session" : "local" : !1;
9
+ }
10
+ });
11
+ //#endregion
12
+ export { t as runtimeStatePersist };
@@ -1,7 +1,7 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
- export type StateManagerContextValue = {
3
- state: Record<string, unknown>;
4
- setState: Dispatch<SetStateAction<Record<string, unknown>>>;
5
- setStateByKey: (key: string, value: unknown, storeMode?: 'localStorage' | 'sessionStorage') => void;
6
- clearCache: (storeMode?: 'localStorage' | 'sessionStorage') => void;
1
+ export type RuntimeState = Record<string, unknown>;
2
+ export type RuntimeStateInstance = {
3
+ state: RuntimeState;
4
+ setState: (value: RuntimeState | ((prev: RuntimeState) => RuntimeState)) => void;
5
+ setStateByKey: (key: string, value: unknown) => void;
6
+ clearState: () => void;
7
7
  };
@@ -9,6 +9,9 @@ export type RuntimeSourceValues = {
9
9
  queryParams: Record<string, unknown>;
10
10
  };
11
11
  auth?: Record<string, unknown>;
12
+ state?: Record<string, unknown>;
13
+ /** @deprecated Use the `state` source (mirrors `runtime.state`). Kept as an alias so existing `page.*` bindings keep
14
+ * working; it still carries the runtime state plus `currentPageId`. */
12
15
  page?: Record<string, unknown>;
13
16
  };
14
17
  export type CommonState = {
@@ -18,7 +21,8 @@ export type CommonState = {
18
21
  style: Style;
19
22
  segments: Record<string, Segment>;
20
23
  runtime?: {
21
- sources?: RuntimeSourceValues & Record<string, unknown>;
24
+ sources: RuntimeSourceValues & Record<string, unknown>;
25
+ state?: Record<string, unknown>;
22
26
  };
23
27
  sources?: Record<string, Source>;
24
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-shared",
3
- "version": "0.31.2",
3
+ "version": "0.32.0",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -869,6 +869,18 @@
869
869
  "types": "./dist/server/rsc/RscProvider.d.ts",
870
870
  "import": "./dist/server/rsc/RscProvider.mjs"
871
871
  },
872
+ "./state": {
873
+ "types": "./dist/state/index.d.ts",
874
+ "import": "./dist/state/index.mjs"
875
+ },
876
+ "./state/index": {
877
+ "types": "./dist/state/index.d.ts",
878
+ "import": "./dist/state/index.mjs"
879
+ },
880
+ "./state/runtimeStatePersist": {
881
+ "types": "./dist/state/runtimeStatePersist.d.ts",
882
+ "import": "./dist/state/runtimeStatePersist.mjs"
883
+ },
872
884
  "./style": {
873
885
  "types": "./dist/style/index.d.ts",
874
886
  "import": "./dist/style/index.mjs"
@@ -999,7 +1011,7 @@
999
1011
  },
1000
1012
  "dependencies": {
1001
1013
  "@modelcontextprotocol/sdk": "^1.29.0",
1002
- "@plitzi/nexus": "0.31.2",
1014
+ "@plitzi/nexus": "0.32.0",
1003
1015
  "@plitzi/plitzi-ui": "^1.6.9",
1004
1016
  "date-fns": "^4.3.0",
1005
1017
  "date-fns-tz": "^3.2.0",