@plitzi/plitzi-sdk 0.38.3 → 0.38.5

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/index.d.ts CHANGED
@@ -2,8 +2,10 @@ import { default as sdkComponents } from './modules/Element';
2
2
  import { createShaderProgram, ShaderError, useAnimationFrame, useCanvas2d, useReducedMotion, useWebGL, useWebGL2, CanvasHandle, CanvasOptions, CanvasSize, Frame } from '@plitzi/sdk-elements/canvas';
3
3
  import { default as ComponentProvider } from '@plitzi/sdk-elements/Component/ComponentProvider';
4
4
  import { default as useFlag } from '@plitzi/sdk-elements/dataSource/useFlag';
5
+ import { default as elementChildren, ElementChild } from '@plitzi/sdk-elements/Element/helpers/elementChildren';
5
6
  import { default as withElement } from '@plitzi/sdk-elements/Element/hocs/withElement';
6
7
  import { default as useElement } from '@plitzi/sdk-elements/Element/hooks/useElement';
8
+ import { default as useElementVisible } from '@plitzi/sdk-elements/Element/hooks/useElementVisible';
7
9
  import { default as useRscData } from '@plitzi/sdk-elements/Element/hooks/useRscData';
8
10
  import { default as JsxManager } from '@plitzi/sdk-elements/Element/JsxManager';
9
11
  import { default as PluginManager } from '@plitzi/sdk-elements/Element/PluginManager';
@@ -14,8 +16,11 @@ import { default as useChannel, ChannelHandle } from '@plitzi/sdk-elements/realt
14
16
  import { default as ComponentContext } from '@plitzi/sdk-shared/elements/ComponentContext';
15
17
  import { PlitziServiceProvider } from '@plitzi/sdk-shared/hooks/usePlitziServiceContext';
16
18
  import { default as useRscRefresh } from '@plitzi/sdk-shared/server/rsc/useRscRefresh';
19
+ import { default as usePluginRoute } from '@plitzi/sdk-shared/server/usePluginRoute';
17
20
  import { useSdkStore } from '@plitzi/sdk-shared/store';
21
+ import { default as useDisplayMode } from '@plitzi/sdk-shared/style/useDisplayMode';
18
22
  import { track } from './modules/Analytics';
23
+ import { DeferredPlugin, PluginComponent } from './modules/Sdk/deferredPlugins';
19
24
  import { ElementContextValue } from '@plitzi/sdk-elements/Element/ElementContext';
20
25
  import { default as EventBridge } from '@plitzi/sdk-event-bridge';
21
26
  import { default as InteractionsManager } from '@plitzi/sdk-interactions/InteractionsManager';
@@ -31,19 +36,35 @@ import { ReactNode } from 'react';
31
36
  * caller for it made the parameter impossible to satisfy without a cast: everybody registering a component of
32
37
  * their own has a React component and nothing else, which is also exactly what `<Sdk.Plugin component>` declares.
33
38
  */
34
- export type RenderPlugins = Record<string, {
39
+ type RenderPluginBase = {
40
+ props?: Record<string, unknown>;
41
+ clientOnly?: boolean;
42
+ };
43
+ export type RenderPlugins = Record<string, (RenderPluginBase & {
35
44
  /**
36
45
  * A plugin's props ARE the hosting element's attributes, which this package cannot know — so the parameter is
37
46
  * left open. Narrowed to `ComponentPluginFC` with its default `unknown`, it refuses every component anybody
38
47
  * actually writes: a component declaring `{ label?: string }` has nothing in common with the runtime-supplied
39
48
  * props alone, and TypeScript reads that as a mistake rather than as the intended widening.
40
49
  */
41
- component: ComponentPluginFC<any>;
42
- props?: Record<string, unknown>;
43
- clientOnly?: boolean;
44
- }>;
45
- export declare function render(widgetContainer: string, params?: PlitziSdkProps, plugins?: RenderPlugins, debugMode?: boolean, ssrMode?: boolean): {
50
+ component: PluginComponent;
51
+ })
52
+ /** One the page draws none of — see `deferredPlugin`. */
53
+ | (RenderPluginBase & DeferredPlugin)>;
54
+ export type RenderOptions = {
55
+ /**
56
+ * Development: the page's plugins can be swapped while it runs (`replacePlugin` on what `render` returns) — what a
57
+ * server rebuilding a plugin hands an open page, so an edit shows without loading the page again.
58
+ */
59
+ hotPlugins?: boolean;
60
+ };
61
+ export declare function render(widgetContainer: string, params?: PlitziSdkProps, renderPlugins?: RenderPlugins, debugMode?: boolean, ssrMode?: boolean, { hotPlugins }?: RenderOptions): {
46
62
  unmount: () => void;
63
+ /**
64
+ * Swaps a plugin where it is drawn, with `hotPlugins` on: `false` when it cannot be swapped in place — not
65
+ * registered by this page, or its declaration changed — and the page should load again.
66
+ */
67
+ replacePlugin: (key: string, component: PluginComponent) => boolean;
47
68
  } | undefined;
48
69
  declare global {
49
70
  interface Window {
@@ -134,8 +155,8 @@ declare const PlitziSdk: {
134
155
  };
135
156
  type PlitziServiceContextValue = BasePlitziServiceContextValue<InstanceType<typeof EventBridge>, InstanceType<typeof InteractionsManager>>;
136
157
  declare const usePlitziServiceContext: () => PlitziServiceContextValue;
137
- export { track, useSdkStore as useStore, ComponentProvider, ComponentContext, usePlitziServiceContext, PlitziServiceProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData, useRscRefresh, useChannel, useFlag, useAnimationFrame, useReducedMotion, useCanvas2d, useWebGL, useWebGL2, createShaderProgram, ShaderError };
138
- export type { AnalyticsConfig, ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziServiceContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues, PluginDeclaration, ChannelHandle, RealtimeMember, RealtimeMessage, CanvasHandle, CanvasOptions, CanvasSize, Frame };
158
+ export { track, useSdkStore as useStore, ComponentProvider, ComponentContext, usePlitziServiceContext, PlitziServiceProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData, useElementVisible, elementChildren, useDisplayMode, useRscRefresh, usePluginRoute, useChannel, useFlag, useAnimationFrame, useReducedMotion, useCanvas2d, useWebGL, useWebGL2, createShaderProgram, ShaderError };
159
+ export type { AnalyticsConfig, ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziServiceContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues, PluginDeclaration, ChannelHandle, ElementChild, RealtimeMember, RealtimeMessage, CanvasHandle, CanvasOptions, CanvasSize, Frame };
139
160
  export declare const version: string;
140
161
  export declare const getStateManager: () => RuntimeStateInstance;
141
162
  export declare const getEventBridge: () => EventBridgeContextValue;
package/dist/index.html CHANGED
@@ -30,21 +30,9 @@
30
30
  }
31
31
  </script>
32
32
 
33
- <link
34
- rel="preload"
35
- href="https://fonts.googleapis.com/icon?family=Material+Icons"
36
- as="style"
37
- onload="
38
- this.onload = null;
39
- this.rel = 'stylesheet';
40
- "
41
- />
42
- <noscript>
43
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
44
- </noscript>
45
-
46
33
  <link href="/plitzi-sdk.css" rel="preload" as="style" />
47
34
  <link href="/plitzi-sdk.css" rel="stylesheet" />
35
+ <link href="/plitzi-sdk-icons.css" rel="stylesheet" />
48
36
  </head>
49
37
 
50
38
  <body>
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Plays the space's arrivals that wait to be seen (`motion: { on: 'view' }`) as each first comes into view — every one
3
+ * under the SDK's root, the pages navigated to included. Renders nothing.
4
+ */
5
+ declare const MotionReveal: () => null;
6
+ export default MotionReveal;
@@ -18,7 +18,8 @@ export type ThemedRootProps = {
18
18
  *
19
19
  * It also says when the page is interactive: `data-hydrated` appears once React has taken over the server's markup
20
20
  * (at once for a page rendered in the browser). A space's CSS keys decorative motion that repaints every frame off it
21
- * — `[data-hydrated] .glow { animation-play-state: running; }` — so the load has the main thread to itself.
21
+ * — `[data-hydrated] .glow { animation-play-state: running; }` — so the load has the main thread to itself. And it
22
+ * plays the arrivals that wait to be seen (`MotionReveal`).
22
23
  */
23
24
  declare const ThemedRoot: ({ className, scoped, children }: ThemedRootProps) => import('react').JSX.Element;
24
25
  export default ThemedRoot;
@@ -3,6 +3,7 @@ export type PluginsContextProviderProps = {
3
3
  children: React.ReactNode;
4
4
  plugins?: Record<string, ComponentDefinition>;
5
5
  sdkStylePath?: string;
6
+ sdkIconsPath?: string;
6
7
  };
7
- declare const PluginsContextProvider: ({ children, plugins: pluginsProp, sdkStylePath }: PluginsContextProviderProps) => import('react').JSX.Element;
8
+ declare const PluginsContextProvider: ({ children, plugins: pluginsProp, sdkStylePath, sdkIconsPath }: PluginsContextProviderProps) => import('react').JSX.Element;
8
9
  export default PluginsContextProvider;
@@ -0,0 +1,21 @@
1
+ import { ComponentPluginFC, PluginDeclaration } from '@plitzi/sdk-shared';
2
+ export type PluginComponent = ComponentPluginFC<any> & {
3
+ plugins?: Record<string, PluginComponent>;
4
+ };
5
+ /** A plugin this page draws none of: what it declares now, its code and stylesheet when a page draws it. */
6
+ export type DeferredPlugin = {
7
+ load: () => Promise<{
8
+ default: PluginComponent;
9
+ }>;
10
+ css?: string | null;
11
+ declaration: PluginDeclaration;
12
+ };
13
+ /**
14
+ * The plugin registered as `key`, standing in for itself until it is drawn.
15
+ *
16
+ * It carries the declaration — the definition, the sub-plugins, each a stand-in of its own — so the space knows its
17
+ * types from the start. The first one drawn loads the code and the stylesheet, once, before anything of it mounts: the
18
+ * stylesheet first, or the plugin would paint unstyled for a frame. Its own `Suspense`, so only the element waits and
19
+ * not the page around it.
20
+ */
21
+ export declare const deferredPlugin: (key: string, { load, css, declaration }: DeferredPlugin) => PluginComponent;
@@ -0,0 +1,17 @@
1
+ import { ComponentPluginFC } from '@plitzi/sdk-shared';
2
+ type PluginComponent = ComponentPluginFC<any>;
3
+ /**
4
+ * Plugins a development page can swap while it runs: each one is registered as a proxy that never changes and
5
+ * renders whichever component is current, so swapping one re-mounts the elements of that type alone — the rest of the
6
+ * page, its state and its scroll, stays as it was. A plugin's own state starts again: it is a new component.
7
+ *
8
+ * The proxy carries the plugin's statics (its declaration, its settings panel) as the original did, so nothing that
9
+ * reads them can tell the difference.
10
+ */
11
+ export declare const createHotPlugins: <T extends {
12
+ component: PluginComponent;
13
+ }>(plugins: Record<string, T>) => {
14
+ plugins: Record<string, T>;
15
+ replace: (key: string, next: PluginComponent) => boolean;
16
+ };
17
+ export {};