@plasmicapp/loader-react 1.0.341 → 1.0.343

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
@@ -1,44 +1,134 @@
1
+ /// <reference types="react" />
2
+
1
3
  import { AssetModule } from '@plasmicapp/loader-core';
2
- import { CodeComponentMeta as CodeComponentMeta_2 } from '@plasmicapp/host';
4
+ import type { CodeComponentMeta as CodeComponentMeta_2 } from '@plasmicapp/host';
3
5
  import { CodeModule } from '@plasmicapp/loader-fetcher';
6
+ import type { ComponentHelpers } from '@plasmicapp/host';
4
7
  import { ComponentMeta } from '@plasmicapp/loader-core';
5
- import { CustomFunctionMeta as CustomFunctionMeta_2 } from '@plasmicapp/host';
8
+ import { ComponentMeta as ComponentMeta_2 } from '@plasmicapp/loader-fetcher';
9
+ import type { CustomFunctionMeta as CustomFunctionMeta_2 } from '@plasmicapp/host';
6
10
  import { DataCtxReader } from '@plasmicapp/host';
7
11
  import { DataProvider } from '@plasmicapp/host';
8
- import { extractPlasmicQueryData } from '@plasmicapp/prepass';
9
12
  import { FontMeta } from '@plasmicapp/loader-core';
10
13
  import { getExternalIds } from '@plasmicapp/loader-splits';
11
14
  import { GlobalActionsContext } from '@plasmicapp/host';
12
15
  import { GlobalActionsProvider } from '@plasmicapp/host';
13
- import { GlobalContextMeta as GlobalContextMeta_2 } from '@plasmicapp/host';
16
+ import type { GlobalContextMeta as GlobalContextMeta_2 } from '@plasmicapp/host';
14
17
  import { GlobalGroupMeta } from '@plasmicapp/loader-core';
15
18
  import { LoaderBundleCache } from '@plasmicapp/loader-core';
16
- import { LoaderBundleOutput } from '@plasmicapp/loader-core';
19
+ import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';
20
+ import { LoaderBundleOutput as LoaderBundleOutput_2 } from '@plasmicapp/loader-core';
17
21
  import { PageMeta } from '@plasmicapp/loader-core';
18
- import { PageMeta as PageMeta_2 } from '@plasmicapp/loader-fetcher';
19
22
  import { PageMetadata } from '@plasmicapp/loader-core';
20
23
  import { PageParamsProvider } from '@plasmicapp/host';
24
+ import { plasmicappDataSourcesContext } from '@plasmicapp/data-sources-context';
25
+ import { plasmicappHost } from '@plasmicapp/host';
26
+ import { plasmicappQuery } from '@plasmicapp/query';
21
27
  import { PlasmicCanvasContext } from '@plasmicapp/host';
22
28
  import { PlasmicCanvasHost } from '@plasmicapp/host';
23
29
  import { PlasmicDataSourceContextValue } from '@plasmicapp/data-sources-context';
24
- import { plasmicPrepass } from '@plasmicapp/prepass';
30
+ import { PlasmicModulesFetcher } from '@plasmicapp/loader-core';
31
+ import { PlasmicTracker } from '@plasmicapp/loader-core';
25
32
  import { PropType } from '@plasmicapp/host';
26
- import { default as React_2 } from 'react';
27
- import * as React_3 from 'react';
33
+ import { react } from 'react';
34
+ import * as React_2 from 'react';
35
+ import { default as React_3 } from 'react';
36
+ import { reactDom } from 'react-dom';
37
+ import { reactJsxDevRuntime } from 'react/jsx-dev-runtime';
38
+ import { reactJsxRuntime } from 'react/jsx-runtime';
28
39
  import { Registry } from '@plasmicapp/loader-core';
29
40
  import { repeatedElement } from '@plasmicapp/host';
30
41
  import { Split } from '@plasmicapp/loader-fetcher';
31
- import { StateHelpers } from '@plasmicapp/host';
32
- import { StateSpec } from '@plasmicapp/host';
42
+ import type { StateHelpers } from '@plasmicapp/host';
43
+ import type { StateSpec } from '@plasmicapp/host';
33
44
  import { TokenRegistration } from '@plasmicapp/host';
34
45
  import { TrackRenderOptions } from '@plasmicapp/loader-core';
35
46
  import { TraitMeta } from '@plasmicapp/host';
36
47
  import { useDataEnv } from '@plasmicapp/host';
48
+ import type { useMutablePlasmicQueryData } from '@plasmicapp/query';
37
49
  import { usePlasmicCanvasContext } from '@plasmicapp/host';
38
50
  import { usePlasmicQueryData } from '@plasmicapp/query';
39
51
  import { useSelector } from '@plasmicapp/host';
40
52
  import { useSelectors } from '@plasmicapp/host';
41
53
 
54
+ /** Subset of loader functionality that works on Client and React Server Components. */
55
+ declare abstract class BaseInternalPlasmicComponentLoader {
56
+ readonly opts: InitOptions;
57
+ private readonly registry;
58
+ private readonly tracker;
59
+ private readonly fetcher;
60
+ private readonly onBundleMerged?;
61
+ private readonly onBundleFetched?;
62
+ private globalVariants;
63
+ private subs;
64
+ private bundle;
65
+ constructor(args: {
66
+ opts: InitOptions;
67
+ fetcher: PlasmicModulesFetcher;
68
+ tracker: PlasmicTracker;
69
+ /** Called after `mergeBundle` (including `fetch` calls). */
70
+ onBundleMerged?: () => void;
71
+ /** Called after any `fetch` calls. */
72
+ onBundleFetched?: () => void;
73
+ builtinModules: BuiltinRegisteredModules;
74
+ });
75
+ private maybeGetCompMetas;
76
+ maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
77
+ maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
78
+ fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
79
+ fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
80
+ fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
81
+ fetchComponents(): Promise<ComponentMeta_2[]>;
82
+ getActiveSplits(): Split[];
83
+ getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]): string;
84
+ private fetchMissingData;
85
+ private maybeReportClientSideFetch;
86
+ private fetchAllData;
87
+ mergeBundle(newBundle: LoaderBundleOutput): void;
88
+ getBundle(): LoaderBundleOutput;
89
+ clearCache(): void;
90
+ registerModules(modules: Record<string, any>): void;
91
+ substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
92
+ protected internalSubstituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec, codeComponentHelpers: ComponentHelpers<React.ComponentProps<React.ComponentType<P>>> | undefined): void;
93
+ abstract registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
94
+ abstract registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
95
+ abstract registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
96
+ abstract registerTrait(trait: string, meta: TraitMeta): void;
97
+ abstract registerToken(token: TokenRegistration): void;
98
+ protected refreshRegistry(): void;
99
+ isRegistryEmpty(): boolean;
100
+ clearRegistry(): void;
101
+ setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
102
+ getGlobalVariants(): GlobalVariantSpec[];
103
+ registerPrefetchedBundle(bundle: LoaderBundleOutput): void;
104
+ getLookup(): ComponentLookup;
105
+ trackConversion(value?: number): void;
106
+ getActiveVariation(opts: {
107
+ traits: Record<string, string | number | boolean>;
108
+ getKnownValue: (key: string) => string | undefined;
109
+ updateKnownValue: (key: string, value: string) => void;
110
+ }): Promise<Record<string, string>>;
111
+ getTeamIds(): string[];
112
+ getProjectIds(): string[];
113
+ trackRender(opts?: TrackRenderOptions): void;
114
+ }
115
+
116
+ declare interface BuiltinRegisteredModules {
117
+ react: react;
118
+ "react-dom": reactDom;
119
+ "react/jsx-runtime": reactJsxRuntime;
120
+ "react/jsx-dev-runtime": reactJsxDevRuntime;
121
+ "@plasmicapp/query": plasmicappQuery;
122
+ "@plasmicapp/data-sources-context": plasmicappDataSourcesContext;
123
+ "@plasmicapp/host": plasmicappHost;
124
+ "@plasmicapp/loader-runtime-registry": {
125
+ components: Record<string, React.ComponentType<any>>;
126
+ globalVariantHooks: Record<string, () => any>;
127
+ codeComponentHelpers: Record<string, ComponentHelpers<any>>;
128
+ functions: Record<string, (...args: any[]) => any>;
129
+ };
130
+ }
131
+
42
132
  export declare type CodeComponentMeta<P> = Omit<CodeComponentMeta_2<P>, "importPath" | "componentHelpers" | "states"> & {
43
133
  /**
44
134
  * The path to be used when importing the component in the generated code.
@@ -51,14 +141,19 @@ export declare type CodeComponentMeta<P> = Omit<CodeComponentMeta_2<P>, "importP
51
141
  * The states helpers are registered together with the states for the Plasmic headless API
52
142
  */
53
143
  states?: Record<string, StateSpec<P> & StateHelpers<P, any>>;
144
+ /**
145
+ * Helper function to enable data extraction when running Plasmic from
146
+ * Next.js App Router.
147
+ */
148
+ getServerInfo?: (props: P, ops: ReactServerOps) => ServerInfo;
54
149
  };
55
150
 
56
151
  declare class ComponentLookup {
57
152
  private bundle;
58
153
  private registry;
59
- constructor(bundle: LoaderBundleOutput, registry: Registry);
154
+ constructor(bundle: LoaderBundleOutput_2, registry: Registry);
60
155
  getComponentMeta(spec: ComponentLookupSpec): ComponentMeta | undefined;
61
- getComponent<P extends React_3.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
156
+ getComponent<P extends React_2.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
62
157
  forceOriginal?: boolean;
63
158
  }): any;
64
159
  hasComponent(spec: ComponentLookupSpec): boolean;
@@ -81,14 +176,14 @@ export declare type ComponentLookupSpec = string | {
81
176
  export { ComponentMeta }
82
177
 
83
178
  export declare interface ComponentRenderData {
84
- entryCompMetas: (ComponentMeta & {
179
+ entryCompMetas: (ComponentMeta_2 & {
85
180
  params?: Record<string, string>;
86
181
  })[];
87
182
  bundle: LoaderBundleOutput;
88
183
  remoteFontUrls: string[];
89
184
  }
90
185
 
91
- export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
186
+ export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput_2[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
92
187
 
93
188
  declare type CustomFunctionMeta<F extends (...args: any[]) => any> = Omit<CustomFunctionMeta_2<F>, "importPath"> & {
94
189
  /**
@@ -104,7 +199,43 @@ export { DataCtxReader }
104
199
 
105
200
  export { DataProvider }
106
201
 
107
- export { extractPlasmicQueryData }
202
+ /**
203
+ * Performs a prepass over Plasmic content, kicking off the necessary
204
+ * data fetches, and populating the fetched data into a cache. This
205
+ * cache can be passed as prefetchedQueryData into PlasmicRootProvider.
206
+ *
207
+ * To limit rendering errors that can occur when you do this, we recommend
208
+ * that you pass in _only_ the PlasmicComponents that you are planning to use
209
+ * as the argument. For example:
210
+ *
211
+ * const cache = await extractPlasmicQueryData(
212
+ * <PlasmicRootProvider loader={PLASMIC} prefetchedData={plasmicData}>
213
+ * <PlasmicComponent component="Home" componentProps={{
214
+ * // Specify the component prop overrides you are planning to use
215
+ * // to render the page, as they may change what data is fetched.
216
+ * ...
217
+ * }} />
218
+ * <PlasmicComponent component="NavBar" componentProps={{
219
+ * ...
220
+ * }} />
221
+ * ...
222
+ * </PlasmicRootProvider>
223
+ * );
224
+ *
225
+ * If your PlasmicComponent will be wrapping components that require special
226
+ * context set up, you should also wrap the element above with those context
227
+ * providers.
228
+ *
229
+ * You should avoid passing in elements that are not related to Plasmic, as any
230
+ * rendering errors from those elements during the prepass may result in data
231
+ * not being populated in the cache.
232
+ *
233
+ * @param element a React element containing instances of PlasmicComponent.
234
+ * Will attempt to satisfy all data needs from usePlasmicDataQuery()
235
+ * in this element tree.
236
+ * @returns an object mapping query key to fetched data
237
+ */
238
+ export declare function extractPlasmicQueryData(element: React.ReactElement): Promise<Record<string, any>>;
108
239
 
109
240
  export declare function extractPlasmicQueryDataFromElement(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
110
241
  prefetchedData?: ComponentRenderData;
@@ -214,49 +345,17 @@ export declare interface InitOptions {
214
345
 
215
346
  export declare function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader;
216
347
 
217
- export declare class InternalPlasmicComponentLoader {
218
- opts: InitOptions;
219
- private readonly reactServerLoader;
220
- private readonly registry;
221
- private subs;
222
- private roots;
223
- private globalVariants;
224
- private tracker;
348
+ export declare class InternalPlasmicComponentLoader extends BaseInternalPlasmicComponentLoader {
349
+ private readonly roots;
225
350
  constructor(opts: InitOptions);
226
- getBundle(): LoaderBundleOutput;
227
- setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
228
- getGlobalVariants(): GlobalVariantSpec[];
229
- registerModules(modules: Record<string, any>): void;
230
- substituteComponent<P>(component: React_2.ComponentType<P>, name: ComponentLookupSpec): void;
231
- private internalSubstituteComponent;
232
- registerComponent<T extends React_2.ComponentType<any>>(component: T, meta: CodeComponentMeta<React_2.ComponentProps<T>>): void;
351
+ registerComponent<T extends React_3.ComponentType<any>>(component: T, meta: CodeComponentMeta<React_3.ComponentProps<T>>): void;
233
352
  registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
234
- registerGlobalContext<T extends React_2.ComponentType<any>>(context: T, meta: GlobalContextMeta<React_2.ComponentProps<T>>): void;
353
+ registerGlobalContext<T extends React_3.ComponentType<any>>(context: T, meta: GlobalContextMeta<React_3.ComponentProps<T>>): void;
235
354
  registerTrait(trait: string, meta: TraitMeta): void;
236
355
  registerToken(token: TokenRegistration): void;
237
- registerPrefetchedBundle(bundle: LoaderBundleOutput): void;
238
356
  subscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
239
357
  unsubscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
240
- clearCache(): void;
241
- getLookup(): ComponentLookup;
242
- maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
243
- maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
244
- fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
245
- fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
246
- fetchPages(opts?: FetchPagesOpts): Promise<PageMeta_2[]>;
247
- fetchComponents(): Promise<ComponentMeta[]>;
248
- getActiveSplits(): Split[];
249
- getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]): string;
250
- trackConversion(value?: number): void;
251
- getActiveVariation(opts: {
252
- traits: Record<string, string | number | boolean>;
253
- getKnownValue: (key: string) => string | undefined;
254
- updateKnownValue: (key: string, value: string) => void;
255
- }): Promise<Record<string, string>>;
256
- getTeamIds(): string[];
257
- getProjectIds(): string[];
258
- trackRender(opts?: TrackRenderOptions): void;
259
- private refreshRegistry;
358
+ refreshRegistry(): void;
260
359
  }
261
360
 
262
361
  /**
@@ -302,7 +401,7 @@ export declare function PlasmicComponent(props: {
302
401
  */
303
402
  forceOriginal?: boolean;
304
403
  componentProps?: any;
305
- }): React_3.ReactElement | null;
404
+ }): React_2.ReactElement | null;
306
405
 
307
406
  /**
308
407
  * Library for fetching component data, and registering
@@ -310,7 +409,7 @@ export declare function PlasmicComponent(props: {
310
409
  */
311
410
  export declare class PlasmicComponentLoader {
312
411
  private __internal;
313
- constructor(internal: InternalPlasmicComponentLoader);
412
+ constructor(internal: BaseInternalPlasmicComponentLoader);
314
413
  /**
315
414
  * Sets global variants to be used for all components. Note that
316
415
  * this is not reactive, and will not re-render all components
@@ -326,11 +425,11 @@ export declare class PlasmicComponentLoader {
326
425
  * components defined in your project. You can use this to
327
426
  * swap in / substitute a Plasmic component with a "real" component.
328
427
  */
329
- substituteComponent<P>(component: React_2.ComponentType<P>, name: ComponentLookupSpec): void;
428
+ substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
330
429
  /**
331
430
  * Register code components to be used on Plasmic Editor.
332
431
  */
333
- registerComponent<T extends React_2.ComponentType<any>>(component: T, meta: CodeComponentMeta<React_2.ComponentProps<T>>): void;
432
+ registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
334
433
  /**
335
434
  * [[deprecated]] Please use `substituteComponent` instead for component
336
435
  * substitution, or the other `registerComponent` overload to register
@@ -338,10 +437,10 @@ export declare class PlasmicComponentLoader {
338
437
  *
339
438
  * @see `substituteComponent`
340
439
  */
341
- registerComponent<T extends React_2.ComponentType<any>>(component: T, name: ComponentLookupSpec): void;
440
+ registerComponent<T extends React.ComponentType<any>>(component: T, name: ComponentLookupSpec): void;
342
441
  private warnedRegisterComponent;
343
442
  registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
344
- registerGlobalContext<T extends React_2.ComponentType<any>>(context: T, meta: GlobalContextMeta<React_2.ComponentProps<T>>): void;
443
+ registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
345
444
  registerTrait(trait: string, meta: TraitMeta): void;
346
445
  registerToken(token: TokenRegistration): void;
347
446
  /**
@@ -371,11 +470,11 @@ export declare class PlasmicComponentLoader {
371
470
  /**
372
471
  * Returns all the page component metadata for these projects.
373
472
  */
374
- fetchPages(opts?: FetchPagesOpts): Promise<PageMeta_2[]>;
473
+ fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
375
474
  /**
376
475
  * Returns all components metadata for these projects.
377
476
  */
378
- fetchComponents(): Promise<ComponentMeta[]>;
477
+ fetchComponents(): Promise<ComponentMeta_2[]>;
379
478
  protected _getActiveVariation(opts: {
380
479
  traits: Record<string, string | number | boolean>;
381
480
  getKnownValue: (key: string) => string | undefined;
@@ -392,7 +491,10 @@ export declare class PlasmicComponentLoader {
392
491
  clearCache(): void;
393
492
  }
394
493
 
395
- export { plasmicPrepass }
494
+ /**
495
+ * @deprecated Maintained for backwards compatibility
496
+ */
497
+ export declare function plasmicPrepass(element: React.ReactElement): Promise<void>;
396
498
 
397
499
  /**
398
500
  * PlasmicRootProvider should be used at the root of your page
@@ -408,7 +510,7 @@ export declare function PlasmicRootProvider(props: {
408
510
  * Global variants to activate for Plasmic components
409
511
  */
410
512
  globalVariants?: GlobalVariantSpec[];
411
- children?: React_3.ReactNode;
513
+ children?: React_2.ReactNode;
412
514
  /**
413
515
  * If true, will skip rendering css
414
516
  */
@@ -451,12 +553,12 @@ export declare function PlasmicRootProvider(props: {
451
553
  * Head component to use in PlasmicHead component (e.g. Head from next/head
452
554
  * or Helmet from react-helmet).
453
555
  */
454
- Head?: React_3.ComponentType<any>;
556
+ Head?: React_2.ComponentType<any>;
455
557
  /**
456
558
  * Link component to use. Can be any component that takes in props passed
457
559
  * to an <a/> tag.
458
560
  */
459
- Link?: React_3.ComponentType<any>;
561
+ Link?: React_2.ComponentType<any>;
460
562
  /**
461
563
  * Page route without params substitution (e.g. /products/[slug]).
462
564
  */
@@ -478,8 +580,8 @@ export declare function PlasmicRootProvider(props: {
478
580
  /**
479
581
  * Fallback value for the root-level React.Suspense
480
582
  */
481
- suspenseFallback?: React_3.ReactNode;
482
- } & PlasmicDataSourceContextValue): React_3.JSX.Element;
583
+ suspenseFallback?: React_2.ReactNode;
584
+ } & PlasmicDataSourceContextValue): React_2.JSX.Element;
483
585
 
484
586
  declare interface PlasmicRootWatcher {
485
587
  onDataFetched?: () => void;
@@ -487,12 +589,34 @@ declare interface PlasmicRootWatcher {
487
589
 
488
590
  export declare type PlasmicTranslator = (str: string, opts?: {
489
591
  components?: {
490
- [key: string]: React_3.ReactElement | React_3.ReactFragment;
592
+ [key: string]: React_2.ReactElement | React_2.ReactFragment;
491
593
  };
492
- }) => React_3.ReactNode;
594
+ }) => React_2.ReactNode;
493
595
 
494
596
  export { PropType }
495
597
 
598
+ /**
599
+ * Helper functions to describe code component behaviors, in order to allow
600
+ * data extraction in RSC / Next.js App routing.
601
+ */
602
+ declare interface ReactServerOps {
603
+ readDataEnv: typeof useDataEnv;
604
+ readDataSelector: typeof useSelector;
605
+ readDataSelectors: typeof useSelectors;
606
+ /**
607
+ * The contexts are passed using a key instead of the context provider
608
+ * Notice it cannot access the default context value if none has been provided,
609
+ * since React server components cannot create contexts.
610
+ */
611
+ readContext: (contextKey: string) => any;
612
+ /**
613
+ * Allows data fetching from the code component and caching the result,
614
+ * which will be stored in the `queryCache` returned by
615
+ * `extractPlasmicQueryData`.
616
+ */
617
+ fetchData: typeof useMutablePlasmicQueryData;
618
+ }
619
+
496
620
  export declare function renderToElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
497
621
  prefetchedData?: ComponentRenderData;
498
622
  componentProps?: any;
@@ -511,6 +635,54 @@ export declare function renderToString(loader: PlasmicComponentLoader, lookup: C
511
635
 
512
636
  export { repeatedElement }
513
637
 
638
+ /**
639
+ * Each child of a code component might receive separate `DataProvider` and
640
+ * Context values.
641
+ */
642
+ declare interface ServerChildData {
643
+ providedData?: ServerProvidedData | ServerProvidedData[];
644
+ providedContexts?: ServerProvidedContext | ServerProvidedContext[];
645
+ node: React.ReactNode;
646
+ }
647
+
648
+ declare interface ServerInfo {
649
+ /**
650
+ * Optional: Indicates the React Nodes created by the component and the
651
+ * respective contexts provided to them. If not specified, it will render the
652
+ * children passed to the component as props.
653
+ */
654
+ children?: ServerChildData | ServerChildData[];
655
+ providedData?: ServerProvidedData | ServerProvidedData[];
656
+ providedContexts?: ServerProvidedContext | ServerProvidedContext[];
657
+ }
658
+
659
+ /**
660
+ * Provides a new value for a given context key, similar to Context.Provider.
661
+ * The context itself is not available (RSC doesn't allow calling
662
+ * `createContext`) so each context will need to be represented as a unique
663
+ * "context key". Also it means the default context value is not available
664
+ * in case no value is passed (and reading that context will return `undefined`)
665
+ */
666
+ declare interface ServerProvidedContext {
667
+ /**
668
+ * Identifier to the context, required to read it later via
669
+ * `ReactServerOps.readContext()`.
670
+ */
671
+ contextKey: string;
672
+ /**
673
+ * Context value being provided (similar to `Context.Provider`).
674
+ */
675
+ value: any;
676
+ }
677
+
678
+ /**
679
+ * Represents data provided by a code component via `DataProvider`
680
+ */
681
+ declare interface ServerProvidedData {
682
+ name: string;
683
+ data: any;
684
+ }
685
+
514
686
  export { TokenRegistration }
515
687
 
516
688
  export { useDataEnv }
@@ -527,7 +699,7 @@ export { usePlasmicCanvasContext }
527
699
  * You can set forceOriginal to true if you want to return the Plasmic-generated
528
700
  * component instead.
529
701
  */
530
- export declare function usePlasmicComponent<P extends React_3.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
702
+ export declare function usePlasmicComponent<P extends React_2.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
531
703
  forceOriginal?: boolean;
532
704
  }): P;
533
705