@plasmicapp/loader-react 1.0.340 → 1.0.342
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 +242 -70
- package/dist/index.esm.js +265 -268
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +259 -263
- package/dist/index.js.map +4 -4
- package/dist/react-server.d.ts +377 -32
- package/dist/react-server.esm.js +1035 -28
- package/dist/react-server.esm.js.map +4 -4
- package/dist/react-server.js +1030 -27
- package/dist/react-server.js.map +4 -4
- package/package.json +4 -4
package/dist/react-server.d.ts
CHANGED
|
@@ -1,14 +1,199 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
import { AssetModule } from '@plasmicapp/loader-core';
|
|
4
|
+
import type { CodeComponentMeta as CodeComponentMeta_2 } from '@plasmicapp/host';
|
|
1
5
|
import { CodeModule } from '@plasmicapp/loader-fetcher';
|
|
6
|
+
import type { ComponentHelpers } from '@plasmicapp/host';
|
|
2
7
|
import { ComponentMeta } from '@plasmicapp/loader-core';
|
|
3
8
|
import { ComponentMeta as ComponentMeta_2 } from '@plasmicapp/loader-fetcher';
|
|
9
|
+
import type { CustomFunctionMeta as CustomFunctionMeta_2 } from '@plasmicapp/host';
|
|
10
|
+
import { FontMeta } from '@plasmicapp/loader-core';
|
|
11
|
+
import { getExternalIds } from '@plasmicapp/loader-splits';
|
|
12
|
+
import type { GlobalContextMeta as GlobalContextMeta_2 } from '@plasmicapp/host';
|
|
13
|
+
import { GlobalGroupMeta } from '@plasmicapp/loader-core';
|
|
4
14
|
import { LoaderBundleCache } from '@plasmicapp/loader-core';
|
|
5
|
-
import { LoaderBundleOutput } from '@plasmicapp/loader-
|
|
6
|
-
import { LoaderBundleOutput as LoaderBundleOutput_2 } from '@plasmicapp/loader-
|
|
15
|
+
import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';
|
|
16
|
+
import { LoaderBundleOutput as LoaderBundleOutput_2 } from '@plasmicapp/loader-core';
|
|
7
17
|
import { PageMeta } from '@plasmicapp/loader-core';
|
|
8
18
|
import { PageMetadata } from '@plasmicapp/loader-core';
|
|
19
|
+
import { plasmicappDataSourcesContext } from '@plasmicapp/data-sources-context';
|
|
20
|
+
import { plasmicappHost } from '@plasmicapp/host';
|
|
21
|
+
import { plasmicappQuery } from '@plasmicapp/query';
|
|
9
22
|
import { PlasmicModulesFetcher } from '@plasmicapp/loader-core';
|
|
10
23
|
import { PlasmicTracker } from '@plasmicapp/loader-core';
|
|
24
|
+
import { react } from 'react';
|
|
25
|
+
import * as React_2 from 'react';
|
|
26
|
+
import { default as React_3 } from 'react';
|
|
27
|
+
import { reactDom } from 'react-dom';
|
|
28
|
+
import { reactJsxDevRuntime } from 'react/jsx-dev-runtime';
|
|
29
|
+
import { reactJsxRuntime } from 'react/jsx-runtime';
|
|
30
|
+
import { Registry } from '@plasmicapp/loader-core';
|
|
11
31
|
import { Split } from '@plasmicapp/loader-fetcher';
|
|
32
|
+
import type { StateHelpers } from '@plasmicapp/host';
|
|
33
|
+
import type { StateSpec } from '@plasmicapp/host';
|
|
34
|
+
import type { TokenRegistration } from '@plasmicapp/host';
|
|
35
|
+
import { TrackRenderOptions } from '@plasmicapp/loader-core';
|
|
36
|
+
import type { TraitMeta } from '@plasmicapp/host';
|
|
37
|
+
import type { useDataEnv } from '@plasmicapp/host';
|
|
38
|
+
import type { useMutablePlasmicQueryData } from '@plasmicapp/query';
|
|
39
|
+
import type { useSelector } from '@plasmicapp/host';
|
|
40
|
+
import type { useSelectors } from '@plasmicapp/host';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Performs a prepass over Plasmic content, kicking off the necessary
|
|
44
|
+
* data fetches, and populating the fetched data into a cache. This
|
|
45
|
+
* cache can be passed as prefetchedQueryData into PlasmicRootProvider.
|
|
46
|
+
*
|
|
47
|
+
* To limit rendering errors that can occur when you do this, we recommend
|
|
48
|
+
* that you pass in _only_ the PlasmicComponents that you are planning to use
|
|
49
|
+
* as the argument. For example:
|
|
50
|
+
*
|
|
51
|
+
* const cache = await extractPlasmicQueryData(
|
|
52
|
+
* <ClientPlasmicRootProvider prefetchedData={plasmicData}>
|
|
53
|
+
* <PlasmicComponent component="Home" componentProps={{
|
|
54
|
+
* // Specify the component prop overrides you are planning to use
|
|
55
|
+
* // to render the page, as they may change what data is fetched.
|
|
56
|
+
* ...
|
|
57
|
+
* }} />
|
|
58
|
+
* <PlasmicComponent component="NavBar" componentProps={{
|
|
59
|
+
* ...
|
|
60
|
+
* }} />
|
|
61
|
+
* ...
|
|
62
|
+
* </ClientPlasmicRootProvider>,
|
|
63
|
+
* PLASMIC
|
|
64
|
+
* );
|
|
65
|
+
*
|
|
66
|
+
* If your PlasmicComponent will be wrapping components that require special
|
|
67
|
+
* context set up, you should also wrap the element above with those context
|
|
68
|
+
* providers. Avoid, however, wrapping the root provider, because we inspect
|
|
69
|
+
* the props passed to the root element.
|
|
70
|
+
*
|
|
71
|
+
* You should avoid passing in elements that are not related to Plasmic, as any
|
|
72
|
+
* rendering errors from those elements during the prepass may result in data
|
|
73
|
+
* not being populated in the cache.
|
|
74
|
+
*
|
|
75
|
+
* @param element a React element containing instances of PlasmicComponent.
|
|
76
|
+
* Will attempt to satisfy all data needs from usePlasmicDataQuery()
|
|
77
|
+
* in this element tree.
|
|
78
|
+
* @returns an object mapping query key to fetched data
|
|
79
|
+
*/
|
|
80
|
+
export declare function __EXPERMIENTAL__extractPlasmicQueryData(element: React.ReactElement, loader: PlasmicComponentLoader): Promise<Record<string, any>>;
|
|
81
|
+
|
|
82
|
+
/** Subset of loader functionality that works on Client and React Server Components. */
|
|
83
|
+
declare abstract class BaseInternalPlasmicComponentLoader {
|
|
84
|
+
readonly opts: InitOptions;
|
|
85
|
+
private readonly registry;
|
|
86
|
+
private readonly tracker;
|
|
87
|
+
private readonly fetcher;
|
|
88
|
+
private readonly onBundleMerged?;
|
|
89
|
+
private readonly onBundleFetched?;
|
|
90
|
+
private globalVariants;
|
|
91
|
+
private subs;
|
|
92
|
+
private bundle;
|
|
93
|
+
constructor(args: {
|
|
94
|
+
opts: InitOptions;
|
|
95
|
+
fetcher: PlasmicModulesFetcher;
|
|
96
|
+
tracker: PlasmicTracker;
|
|
97
|
+
/** Called after `mergeBundle` (including `fetch` calls). */
|
|
98
|
+
onBundleMerged?: () => void;
|
|
99
|
+
/** Called after any `fetch` calls. */
|
|
100
|
+
onBundleFetched?: () => void;
|
|
101
|
+
builtinModules: BuiltinRegisteredModules;
|
|
102
|
+
});
|
|
103
|
+
private maybeGetCompMetas;
|
|
104
|
+
maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
|
|
105
|
+
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
106
|
+
fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
|
|
107
|
+
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
108
|
+
fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
|
|
109
|
+
fetchComponents(): Promise<ComponentMeta_2[]>;
|
|
110
|
+
getActiveSplits(): Split[];
|
|
111
|
+
getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]): string;
|
|
112
|
+
private fetchMissingData;
|
|
113
|
+
private maybeReportClientSideFetch;
|
|
114
|
+
private fetchAllData;
|
|
115
|
+
mergeBundle(bundle: LoaderBundleOutput): void;
|
|
116
|
+
getBundle(): LoaderBundleOutput;
|
|
117
|
+
clearCache(): void;
|
|
118
|
+
registerModules(modules: Record<string, any>): void;
|
|
119
|
+
substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
|
|
120
|
+
protected internalSubstituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec, codeComponentHelpers: ComponentHelpers<React.ComponentProps<React.ComponentType<P>>> | undefined): void;
|
|
121
|
+
abstract registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
|
|
122
|
+
abstract registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
123
|
+
abstract registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
|
|
124
|
+
abstract registerTrait(trait: string, meta: TraitMeta): void;
|
|
125
|
+
abstract registerToken(token: TokenRegistration): void;
|
|
126
|
+
protected refreshRegistry(): void;
|
|
127
|
+
isRegistryEmpty(): boolean;
|
|
128
|
+
clearRegistry(): void;
|
|
129
|
+
setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
|
|
130
|
+
getGlobalVariants(): GlobalVariantSpec[];
|
|
131
|
+
registerPrefetchedBundle(bundle: LoaderBundleOutput): void;
|
|
132
|
+
getLookup(): ComponentLookup;
|
|
133
|
+
trackConversion(value?: number): void;
|
|
134
|
+
getActiveVariation(opts: {
|
|
135
|
+
traits: Record<string, string | number | boolean>;
|
|
136
|
+
getKnownValue: (key: string) => string | undefined;
|
|
137
|
+
updateKnownValue: (key: string, value: string) => void;
|
|
138
|
+
}): Promise<Record<string, string>>;
|
|
139
|
+
getTeamIds(): string[];
|
|
140
|
+
getProjectIds(): string[];
|
|
141
|
+
trackRender(opts?: TrackRenderOptions): void;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare interface BuiltinRegisteredModules {
|
|
145
|
+
react: react;
|
|
146
|
+
"react-dom": reactDom;
|
|
147
|
+
"react/jsx-runtime": reactJsxRuntime;
|
|
148
|
+
"react/jsx-dev-runtime": reactJsxDevRuntime;
|
|
149
|
+
"@plasmicapp/query": plasmicappQuery;
|
|
150
|
+
"@plasmicapp/data-sources-context": plasmicappDataSourcesContext;
|
|
151
|
+
"@plasmicapp/host": plasmicappHost;
|
|
152
|
+
"@plasmicapp/loader-runtime-registry": {
|
|
153
|
+
components: Record<string, React.ComponentType<any>>;
|
|
154
|
+
globalVariantHooks: Record<string, () => any>;
|
|
155
|
+
codeComponentHelpers: Record<string, ComponentHelpers<any>>;
|
|
156
|
+
functions: Record<string, (...args: any[]) => any>;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare type CodeComponentMeta<P> = Omit<CodeComponentMeta_2<P>, "importPath" | "componentHelpers" | "states"> & {
|
|
161
|
+
/**
|
|
162
|
+
* The path to be used when importing the component in the generated code.
|
|
163
|
+
* It can be the name of the package that contains the component, or the path
|
|
164
|
+
* to the file in the project (relative to the root directory).
|
|
165
|
+
* Optional: not used by Plasmic headless API, only by codegen.
|
|
166
|
+
*/
|
|
167
|
+
importPath?: string;
|
|
168
|
+
/**
|
|
169
|
+
* The states helpers are registered together with the states for the Plasmic headless API
|
|
170
|
+
*/
|
|
171
|
+
states?: Record<string, StateSpec<P> & StateHelpers<P, any>>;
|
|
172
|
+
/**
|
|
173
|
+
* Helper function to enable data extraction when running Plasmic from
|
|
174
|
+
* Next.js App Router.
|
|
175
|
+
*/
|
|
176
|
+
getServerInfo?: (props: P, ops: ReactServerOps) => ServerInfo;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
declare class ComponentLookup {
|
|
180
|
+
private bundle;
|
|
181
|
+
private registry;
|
|
182
|
+
constructor(bundle: LoaderBundleOutput_2, registry: Registry);
|
|
183
|
+
getComponentMeta(spec: ComponentLookupSpec): ComponentMeta | undefined;
|
|
184
|
+
getComponent<P extends React_2.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
|
|
185
|
+
forceOriginal?: boolean;
|
|
186
|
+
}): any;
|
|
187
|
+
hasComponent(spec: ComponentLookupSpec): boolean;
|
|
188
|
+
getGlobalContexts(): {
|
|
189
|
+
meta: GlobalGroupMeta;
|
|
190
|
+
context: any;
|
|
191
|
+
}[];
|
|
192
|
+
getGlobalContextsProvider(spec: ComponentLookupSpec): any;
|
|
193
|
+
getRootProvider(): any;
|
|
194
|
+
getCss(): AssetModule[];
|
|
195
|
+
getRemoteFonts(): FontMeta[];
|
|
196
|
+
}
|
|
12
197
|
|
|
13
198
|
declare type ComponentLookupSpec = string | {
|
|
14
199
|
name: string;
|
|
@@ -19,14 +204,24 @@ declare type ComponentLookupSpec = string | {
|
|
|
19
204
|
export { ComponentMeta }
|
|
20
205
|
|
|
21
206
|
export declare interface ComponentRenderData {
|
|
22
|
-
entryCompMetas: (
|
|
207
|
+
entryCompMetas: (ComponentMeta_2 & {
|
|
23
208
|
params?: Record<string, string>;
|
|
24
209
|
})[];
|
|
25
210
|
bundle: LoaderBundleOutput;
|
|
26
211
|
remoteFontUrls: string[];
|
|
27
212
|
}
|
|
28
213
|
|
|
29
|
-
export declare const convertBundlesToComponentRenderData: (bundles:
|
|
214
|
+
export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput_2[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
|
|
215
|
+
|
|
216
|
+
declare type CustomFunctionMeta<F extends (...args: any[]) => any> = Omit<CustomFunctionMeta_2<F>, "importPath"> & {
|
|
217
|
+
/**
|
|
218
|
+
* The path to be used when importing the function in the generated code.
|
|
219
|
+
* It can be the name of the package that contains the function, or the path
|
|
220
|
+
* to the file in the project (relative to the root directory).
|
|
221
|
+
* Optional: not used by Plasmic headless API, only by codegen.
|
|
222
|
+
*/
|
|
223
|
+
importPath?: string;
|
|
224
|
+
};
|
|
30
225
|
|
|
31
226
|
declare interface FetchComponentDataOpts {
|
|
32
227
|
/**
|
|
@@ -55,6 +250,22 @@ declare type FetchPagesOpts = {
|
|
|
55
250
|
includeDynamicPages?: boolean;
|
|
56
251
|
};
|
|
57
252
|
|
|
253
|
+
declare type GlobalContextMeta<P> = Omit<GlobalContextMeta_2<P>, "importPath"> & {
|
|
254
|
+
/**
|
|
255
|
+
* The path to be used when importing the component in the generated code.
|
|
256
|
+
* It can be the name of the package that contains the component, or the path
|
|
257
|
+
* to the file in the project (relative to the root directory).
|
|
258
|
+
* Optional: not used by Plasmic headless API, only by codegen.
|
|
259
|
+
*/
|
|
260
|
+
importPath?: string;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
declare interface GlobalVariantSpec {
|
|
264
|
+
name: string;
|
|
265
|
+
projectId?: string;
|
|
266
|
+
value: any;
|
|
267
|
+
}
|
|
268
|
+
|
|
58
269
|
export declare interface InitOptions {
|
|
59
270
|
projects: {
|
|
60
271
|
id: string;
|
|
@@ -100,7 +311,17 @@ export declare interface InitOptions {
|
|
|
100
311
|
manualRedirect?: boolean;
|
|
101
312
|
}
|
|
102
313
|
|
|
103
|
-
export declare function initPlasmicLoader(opts: InitOptions):
|
|
314
|
+
export declare function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader;
|
|
315
|
+
|
|
316
|
+
export declare class InternalPlasmicComponentLoader extends BaseInternalPlasmicComponentLoader {
|
|
317
|
+
constructor(opts: InitOptions);
|
|
318
|
+
registerComponent<T extends React_3.ComponentType<any>>(component: T, meta: CodeComponentMeta<React_3.ComponentProps<T>>): void;
|
|
319
|
+
registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
320
|
+
registerGlobalContext<T extends React_3.ComponentType<any>>(context: T, meta: GlobalContextMeta<React_3.ComponentProps<T>>): void;
|
|
321
|
+
registerTrait: (trait: string, meta: TraitMeta) => void;
|
|
322
|
+
registerToken: (token: TokenRegistration) => void;
|
|
323
|
+
refreshRegistry(): void;
|
|
324
|
+
}
|
|
104
325
|
|
|
105
326
|
/**
|
|
106
327
|
* Check if `lookup` resolves to `pagePath`. If it's a match, return an object
|
|
@@ -122,38 +343,162 @@ export { PageMeta }
|
|
|
122
343
|
|
|
123
344
|
export { PageMetadata }
|
|
124
345
|
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
private
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
346
|
+
/**
|
|
347
|
+
* Library for fetching component data, and registering
|
|
348
|
+
* custom components.
|
|
349
|
+
*/
|
|
350
|
+
export declare class PlasmicComponentLoader {
|
|
351
|
+
private __internal;
|
|
352
|
+
constructor(internal: BaseInternalPlasmicComponentLoader);
|
|
353
|
+
/**
|
|
354
|
+
* Sets global variants to be used for all components. Note that
|
|
355
|
+
* this is not reactive, and will not re-render all components
|
|
356
|
+
* already mounted; instead, it should be used to activate global
|
|
357
|
+
* variants that should always be activated for the lifetime of this
|
|
358
|
+
* app. If you'd like to reactively change the global variants,
|
|
359
|
+
* you should specify them via <PlasmicRootProvider />
|
|
360
|
+
*/
|
|
361
|
+
setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
|
|
362
|
+
registerModules(modules: Record<string, any>): void;
|
|
363
|
+
/**
|
|
364
|
+
* Register custom components that should be swapped in for
|
|
365
|
+
* components defined in your project. You can use this to
|
|
366
|
+
* swap in / substitute a Plasmic component with a "real" component.
|
|
367
|
+
*/
|
|
368
|
+
substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
|
|
369
|
+
/**
|
|
370
|
+
* Register code components to be used on Plasmic Editor.
|
|
371
|
+
*/
|
|
372
|
+
registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
|
|
373
|
+
/**
|
|
374
|
+
* [[deprecated]] Please use `substituteComponent` instead for component
|
|
375
|
+
* substitution, or the other `registerComponent` overload to register
|
|
376
|
+
* code components to be used on Plasmic Editor.
|
|
377
|
+
*
|
|
378
|
+
* @see `substituteComponent`
|
|
379
|
+
*/
|
|
380
|
+
registerComponent<T extends React.ComponentType<any>>(component: T, name: ComponentLookupSpec): void;
|
|
381
|
+
private warnedRegisterComponent;
|
|
382
|
+
registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
383
|
+
registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
|
|
384
|
+
registerTrait(trait: string, meta: TraitMeta): void;
|
|
385
|
+
registerToken(token: TokenRegistration): void;
|
|
386
|
+
/**
|
|
387
|
+
* Pre-fetches component data needed to for PlasmicLoader to render
|
|
388
|
+
* these components. Should be passed into PlasmicRootProvider as
|
|
389
|
+
* the prefetchedData prop.
|
|
390
|
+
*
|
|
391
|
+
* You can look up a component either by:
|
|
392
|
+
* - the name of the component
|
|
393
|
+
* - the path for a page component
|
|
394
|
+
* - an array of strings that make up parts of the path
|
|
395
|
+
* - object { name: "name_or_path", projectId: ...}, to specify which project
|
|
396
|
+
* to use, if multiple projects have the same component name
|
|
397
|
+
*
|
|
398
|
+
* Throws an Error if a specified component to fetch does not exist in
|
|
399
|
+
* the Plasmic project.
|
|
400
|
+
*/
|
|
146
401
|
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
402
|
+
fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
|
|
403
|
+
/**
|
|
404
|
+
* Like fetchComponentData(), but returns null instead of throwing an Error
|
|
405
|
+
* when a component is not found. Useful when you are implementing a catch-all
|
|
406
|
+
* page and want to check if a specific path had been defined for Plasmic.
|
|
407
|
+
*/
|
|
408
|
+
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
409
|
+
maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
|
|
410
|
+
/**
|
|
411
|
+
* Returns all the page component metadata for these projects.
|
|
412
|
+
*/
|
|
147
413
|
fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
|
|
414
|
+
/**
|
|
415
|
+
* Returns all components metadata for these projects.
|
|
416
|
+
*/
|
|
148
417
|
fetchComponents(): Promise<ComponentMeta_2[]>;
|
|
418
|
+
protected _getActiveVariation(opts: {
|
|
419
|
+
traits: Record<string, string | number | boolean>;
|
|
420
|
+
getKnownValue: (key: string) => string | undefined;
|
|
421
|
+
updateKnownValue: (key: string, value: string) => void;
|
|
422
|
+
}): Promise<Record<string, string>>;
|
|
423
|
+
getActiveVariation(opts: {
|
|
424
|
+
known?: Record<string, string>;
|
|
425
|
+
traits: Record<string, string | number | boolean>;
|
|
426
|
+
}): Promise<Record<string, string>>;
|
|
427
|
+
getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]): string;
|
|
428
|
+
getExternalVariation(variation: Record<string, string>, filters?: Parameters<typeof getExternalIds>[2]): Record<string, string>;
|
|
149
429
|
getActiveSplits(): Split[];
|
|
150
|
-
|
|
151
|
-
private fetchMissingData;
|
|
152
|
-
private maybeReportClientSideFetch;
|
|
153
|
-
private fetchAllData;
|
|
154
|
-
mergeBundle(bundle: LoaderBundleOutput_2): void;
|
|
155
|
-
getBundle(): LoaderBundleOutput_2;
|
|
430
|
+
trackConversion(value?: number): void;
|
|
156
431
|
clearCache(): void;
|
|
157
432
|
}
|
|
158
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Helper functions to describe code component behaviors, in order to allow
|
|
436
|
+
* data extraction in RSC / Next.js App routing.
|
|
437
|
+
*/
|
|
438
|
+
declare interface ReactServerOps {
|
|
439
|
+
readDataEnv: typeof useDataEnv;
|
|
440
|
+
readDataSelector: typeof useSelector;
|
|
441
|
+
readDataSelectors: typeof useSelectors;
|
|
442
|
+
/**
|
|
443
|
+
* The contexts are passed using a key instead of the context provider
|
|
444
|
+
* Notice it cannot access the default context value if none has been provided,
|
|
445
|
+
* since React server components cannot create contexts.
|
|
446
|
+
*/
|
|
447
|
+
readContext: (contextKey: string) => any;
|
|
448
|
+
/**
|
|
449
|
+
* Allows data fetching from the code component and caching the result,
|
|
450
|
+
* which will be stored in the `queryCache` returned by
|
|
451
|
+
* `extractPlasmicQueryData`.
|
|
452
|
+
*/
|
|
453
|
+
fetchData: typeof useMutablePlasmicQueryData;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Each child of a code component might receive separate `DataProvider` and
|
|
458
|
+
* Context values.
|
|
459
|
+
*/
|
|
460
|
+
declare interface ServerChildData {
|
|
461
|
+
providedData?: ServerProvidedData | ServerProvidedData[];
|
|
462
|
+
providedContexts?: ServerProvidedContext | ServerProvidedContext[];
|
|
463
|
+
node: React.ReactNode;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
declare interface ServerInfo {
|
|
467
|
+
/**
|
|
468
|
+
* Optional: Indicates the React Nodes created by the component and the
|
|
469
|
+
* respective contexts provided to them. If not specified, it will render the
|
|
470
|
+
* children passed to the component as props.
|
|
471
|
+
*/
|
|
472
|
+
children?: ServerChildData | ServerChildData[];
|
|
473
|
+
providedData?: ServerProvidedData | ServerProvidedData[];
|
|
474
|
+
providedContexts?: ServerProvidedContext | ServerProvidedContext[];
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Provides a new value for a given context key, similar to Context.Provider.
|
|
479
|
+
* The context itself is not available (RSC doesn't allow calling
|
|
480
|
+
* `createContext`) so each context will need to be represented as a unique
|
|
481
|
+
* "context key". Also it means the default context value is not available
|
|
482
|
+
* in case no value is passed (and reading that context will return `undefined`)
|
|
483
|
+
*/
|
|
484
|
+
declare interface ServerProvidedContext {
|
|
485
|
+
/**
|
|
486
|
+
* Identifier to the context, required to read it later via
|
|
487
|
+
* `ReactServerOps.readContext()`.
|
|
488
|
+
*/
|
|
489
|
+
contextKey: string;
|
|
490
|
+
/**
|
|
491
|
+
* Context value being provided (similar to `Context.Provider`).
|
|
492
|
+
*/
|
|
493
|
+
value: any;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Represents data provided by a code component via `DataProvider`
|
|
498
|
+
*/
|
|
499
|
+
declare interface ServerProvidedData {
|
|
500
|
+
name: string;
|
|
501
|
+
data: any;
|
|
502
|
+
}
|
|
503
|
+
|
|
159
504
|
export { }
|