@plasmicapp/loader-react 1.0.37 → 1.0.39-6.beta

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,8 +1,719 @@
1
- export { PlasmicCanvasContext, PlasmicCanvasHost, PrimitiveType, PropType, repeatedElement, } from '@plasmicapp/host';
2
- export { ComponentMeta, PageMeta, PageMetadata } from '@plasmicapp/loader-core';
3
- export { convertBundlesToComponentRenderData } from './bundles';
4
- export { ComponentRenderData, InitOptions, initPlasmicLoader, PlasmicComponentLoader, } from './loader';
5
- export { PlasmicComponent } from './PlasmicComponent';
6
- export { GlobalVariantSpec, PlasmicRootProvider } from './PlasmicRootProvider';
7
- export { hydrateFromElement, renderToElement, renderToString } from './render';
8
- export { usePlasmicComponent } from './usePlasmicComponent';
1
+ /// <reference types="react" />
2
+
3
+ import { AssetModule } from '@plasmicapp/loader-core';
4
+ import type { CodeComponentMeta as CodeComponentMeta_2 } from '@plasmicapp/host';
5
+ import { CodeModule } from '@plasmicapp/loader-fetcher';
6
+ import type { ComponentHelpers } from '@plasmicapp/host';
7
+ import { ComponentMeta } from '@plasmicapp/loader-core';
8
+ import { ComponentMeta as ComponentMeta_2 } from '@plasmicapp/loader-fetcher';
9
+ import type { CustomFunctionMeta as CustomFunctionMeta_2 } from '@plasmicapp/host';
10
+ import { DataCtxReader } from '@plasmicapp/host';
11
+ import { DataProvider } from '@plasmicapp/host';
12
+ import { FontMeta } from '@plasmicapp/loader-core';
13
+ import { getActiveVariation } from '@plasmicapp/loader-splits';
14
+ import { getExternalIds } from '@plasmicapp/loader-splits';
15
+ import { GlobalActionsContext } from '@plasmicapp/host';
16
+ import { GlobalActionsProvider } from '@plasmicapp/host';
17
+ import type { GlobalContextMeta as GlobalContextMeta_2 } from '@plasmicapp/host';
18
+ import { GlobalGroupMeta } from '@plasmicapp/loader-core';
19
+ import { LoaderBundleCache } from '@plasmicapp/loader-core';
20
+ import { LoaderBundleOutput } from '@plasmicapp/loader-fetcher';
21
+ import { LoaderBundleOutput as LoaderBundleOutput_2 } from '@plasmicapp/loader-core';
22
+ import { PageMeta } from '@plasmicapp/loader-core';
23
+ import { PageMetadata } from '@plasmicapp/loader-core';
24
+ import { PageParamsProvider } from '@plasmicapp/host';
25
+ import { plasmicappDataSourcesContext } from '@plasmicapp/data-sources-context';
26
+ import { plasmicappHost } from '@plasmicapp/host';
27
+ import { plasmicappQuery } from '@plasmicapp/query';
28
+ import { PlasmicCanvasContext } from '@plasmicapp/host';
29
+ import { PlasmicCanvasHost } from '@plasmicapp/host';
30
+ import { PlasmicDataSourceContextValue } from '@plasmicapp/data-sources-context';
31
+ import { PlasmicModulesFetcher } from '@plasmicapp/loader-core';
32
+ import { PlasmicTracker } from '@plasmicapp/loader-core';
33
+ import { PlasmicTranslatorContext } from '@plasmicapp/host';
34
+ import { PropType } from '@plasmicapp/host';
35
+ import { react } from 'react';
36
+ import * as React_2 from 'react';
37
+ import { default as React_3 } from 'react';
38
+ import { reactDom } from 'react-dom';
39
+ import { reactJsxDevRuntime } from 'react/jsx-dev-runtime';
40
+ import { reactJsxRuntime } from 'react/jsx-runtime';
41
+ import { Registry } from '@plasmicapp/loader-core';
42
+ import { repeatedElement } from '@plasmicapp/host';
43
+ import { Split } from '@plasmicapp/loader-fetcher';
44
+ import type { StateHelpers } from '@plasmicapp/host';
45
+ import type { StateSpec } from '@plasmicapp/host';
46
+ import { TokenRegistration } from '@plasmicapp/host';
47
+ import { TrackRenderOptions } from '@plasmicapp/loader-core';
48
+ import { TraitMeta } from '@plasmicapp/host';
49
+ import { useDataEnv } from '@plasmicapp/host';
50
+ import type { useMutablePlasmicQueryData } from '@plasmicapp/query';
51
+ import { usePlasmicCanvasComponentInfo } from '@plasmicapp/host';
52
+ import { usePlasmicCanvasContext } from '@plasmicapp/host';
53
+ import { usePlasmicQueryData } from '@plasmicapp/query';
54
+ import { useSelector } from '@plasmicapp/host';
55
+ import { useSelectors } from '@plasmicapp/host';
56
+
57
+ /** Subset of loader functionality that works on Client and React Server Components. */
58
+ declare abstract class BaseInternalPlasmicComponentLoader {
59
+ readonly opts: InitOptions;
60
+ private readonly registry;
61
+ private readonly tracker;
62
+ private readonly fetcher;
63
+ private readonly onBundleMerged?;
64
+ private readonly onBundleFetched?;
65
+ private globalVariants;
66
+ private subs;
67
+ private bundle;
68
+ constructor(args: {
69
+ opts: InitOptions;
70
+ fetcher: PlasmicModulesFetcher;
71
+ tracker: PlasmicTracker;
72
+ /** Called after `mergeBundle` (including `fetch` calls). */
73
+ onBundleMerged?: () => void;
74
+ /** Called after any `fetch` calls. */
75
+ onBundleFetched?: () => void;
76
+ builtinModules: BuiltinRegisteredModules;
77
+ });
78
+ private maybeGetCompMetas;
79
+ maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
80
+ maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
81
+ fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
82
+ fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
83
+ fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
84
+ fetchComponents(): Promise<ComponentMeta_2[]>;
85
+ getActiveSplits(): Split[];
86
+ getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]): string;
87
+ private fetchMissingData;
88
+ private maybeReportClientSideFetch;
89
+ private fetchAllData;
90
+ mergeBundle(newBundle: LoaderBundleOutput): void;
91
+ getBundle(): LoaderBundleOutput;
92
+ clearCache(): void;
93
+ registerModules(modules: Record<string, any>): void;
94
+ substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
95
+ protected internalSubstituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec, codeComponentHelpers: ComponentHelpers<React.ComponentProps<React.ComponentType<P>>> | undefined): void;
96
+ abstract registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
97
+ abstract registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
98
+ abstract registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
99
+ abstract registerTrait(trait: string, meta: TraitMeta): void;
100
+ abstract registerToken(token: TokenRegistration): void;
101
+ protected refreshRegistry(): void;
102
+ isRegistryEmpty(): boolean;
103
+ clearRegistry(): void;
104
+ setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
105
+ getGlobalVariants(): GlobalVariantSpec[];
106
+ registerPrefetchedBundle(bundle: LoaderBundleOutput): void;
107
+ getLookup(): ComponentLookup;
108
+ trackConversion(value?: number): void;
109
+ getActiveVariation(opts: Omit<Parameters<typeof getActiveVariation>[0], "splits">): Promise<Record<string, string>>;
110
+ getTeamIds(): string[];
111
+ getProjectIds(): string[];
112
+ trackRender(opts?: TrackRenderOptions): void;
113
+ loadServerQueriesModule(fileName: string): any;
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
+
132
+ export declare type CodeComponentMeta<P> = Omit<CodeComponentMeta_2<P>, "importPath" | "componentHelpers" | "states"> & {
133
+ /**
134
+ * The path to be used when importing the component in the generated code.
135
+ * It can be the name of the package that contains the component, or the path
136
+ * to the file in the project (relative to the root directory).
137
+ * Optional: not used by Plasmic headless API, only by codegen.
138
+ */
139
+ importPath?: string;
140
+ /**
141
+ * The states helpers are registered together with the states for the Plasmic headless API
142
+ */
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;
149
+ };
150
+
151
+ declare class ComponentLookup {
152
+ private bundle;
153
+ private registry;
154
+ constructor(bundle: LoaderBundleOutput_2, registry: Registry);
155
+ getComponentMeta(spec: ComponentLookupSpec): ComponentMeta | undefined;
156
+ getComponent<P extends React_2.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
157
+ forceOriginal?: boolean;
158
+ }): any;
159
+ hasComponent(spec: ComponentLookupSpec): boolean;
160
+ getGlobalContexts(): {
161
+ meta: GlobalGroupMeta;
162
+ context: any;
163
+ }[];
164
+ /** Returns StyleTokensProvider if the project has style token overrides. */
165
+ maybeGetStyleTokensProvider(spec: ComponentLookupSpec): any;
166
+ getGlobalContextsProvider(spec: ComponentLookupSpec): any;
167
+ getRootProvider(): any;
168
+ getCss(): AssetModule[];
169
+ getRemoteFonts(): FontMeta[];
170
+ }
171
+
172
+ export declare type ComponentLookupSpec = string | {
173
+ name: string;
174
+ projectId?: string;
175
+ isCode?: boolean;
176
+ };
177
+
178
+ export { ComponentMeta }
179
+
180
+ export declare interface ComponentRenderData {
181
+ entryCompMetas: (ComponentMeta_2 & {
182
+ params?: Record<string, string>;
183
+ })[];
184
+ bundle: LoaderBundleOutput;
185
+ remoteFontUrls: string[];
186
+ }
187
+
188
+ export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput_2[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
189
+
190
+ export declare type CustomFunctionMeta<F extends (...args: any[]) => any> = Omit<CustomFunctionMeta_2<F>, "importPath"> & {
191
+ /**
192
+ * The path to be used when importing the function in the generated code.
193
+ * It can be the name of the package that contains the function, or the path
194
+ * to the file in the project (relative to the root directory).
195
+ * Optional: not used by Plasmic headless API, only by codegen.
196
+ */
197
+ importPath?: string;
198
+ };
199
+
200
+ export { DataCtxReader }
201
+
202
+ export { DataProvider }
203
+
204
+ /**
205
+ * Performs a prepass over Plasmic content, kicking off the necessary
206
+ * data fetches, and populating the fetched data into a cache. This
207
+ * cache can be passed as prefetchedQueryData into PlasmicRootProvider.
208
+ *
209
+ * To limit rendering errors that can occur when you do this, we recommend
210
+ * that you pass in _only_ the PlasmicComponents that you are planning to use
211
+ * as the argument. For example:
212
+ *
213
+ * const cache = await extractPlasmicQueryData(
214
+ * <PlasmicRootProvider loader={PLASMIC} prefetchedData={plasmicData}>
215
+ * <PlasmicComponent component="Home" componentProps={{
216
+ * // Specify the component prop overrides you are planning to use
217
+ * // to render the page, as they may change what data is fetched.
218
+ * ...
219
+ * }} />
220
+ * <PlasmicComponent component="NavBar" componentProps={{
221
+ * ...
222
+ * }} />
223
+ * ...
224
+ * </PlasmicRootProvider>
225
+ * );
226
+ *
227
+ * If your PlasmicComponent will be wrapping components that require special
228
+ * context set up, you should also wrap the element above with those context
229
+ * providers.
230
+ *
231
+ * You should avoid passing in elements that are not related to Plasmic, as any
232
+ * rendering errors from those elements during the prepass may result in data
233
+ * not being populated in the cache.
234
+ *
235
+ * @param element a React element containing instances of PlasmicComponent.
236
+ * Will attempt to satisfy all data needs from usePlasmicDataQuery()
237
+ * in this element tree.
238
+ * @returns an object mapping query key to fetched data
239
+ */
240
+ export declare function extractPlasmicQueryData(element: React.ReactElement): Promise<Record<string, any>>;
241
+
242
+ export declare function extractPlasmicQueryDataFromElement(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
243
+ prefetchedData?: ComponentRenderData;
244
+ componentProps?: any;
245
+ globalVariants?: GlobalVariantSpec[];
246
+ prefetchedQueryData?: Record<string, any>;
247
+ }): Promise<Record<string, any>>;
248
+
249
+ export declare interface FetchComponentDataOpts {
250
+ /**
251
+ * Will fetch either code targeting SSR or browser hydration in the
252
+ * returned bundle.
253
+ *
254
+ * By default, the target is browser. That's okay, because even when
255
+ * doing SSR, as long as you are using the same instance of PlasmicLoader
256
+ * that was used to fetch component data, it will still know how to get at
257
+ * the server code.
258
+ *
259
+ * But, if you are building your own SSR solution, where fetching and rendering
260
+ * are using different instances of PlasmicLoader, then you'll want to make
261
+ * sure that when you fetch, you are fetching the right one to be used in the
262
+ * right environment for either SSR or browser hydration.
263
+ */
264
+ target?: "server" | "browser";
265
+ }
266
+
267
+ declare type FetchPagesOpts = {
268
+ /**
269
+ * Whether to include dynamic pages in fetchPages() output. A page is
270
+ * considered dynamic if its path contains some param between brackets,
271
+ * e.g. "[slug]".
272
+ */
273
+ includeDynamicPages?: boolean;
274
+ };
275
+
276
+ export { GlobalActionsContext }
277
+
278
+ export { GlobalActionsProvider }
279
+
280
+ export declare type GlobalContextMeta<P> = Omit<GlobalContextMeta_2<P>, "importPath"> & {
281
+ /**
282
+ * The path to be used when importing the component in the generated code.
283
+ * It can be the name of the package that contains the component, or the path
284
+ * to the file in the project (relative to the root directory).
285
+ * Optional: not used by Plasmic headless API, only by codegen.
286
+ */
287
+ importPath?: string;
288
+ };
289
+
290
+ export declare interface GlobalVariantSpec {
291
+ name: string;
292
+ projectId?: string;
293
+ value: any;
294
+ }
295
+
296
+ export declare function hydrateFromElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
297
+ prefetchedData?: ComponentRenderData;
298
+ componentProps?: any;
299
+ globalVariants?: GlobalVariantSpec[];
300
+ prefetchedQueryData?: Record<string, any>;
301
+ }): Promise<void>;
302
+
303
+ export declare interface InitOptions {
304
+ projects: {
305
+ id: string;
306
+ token: string;
307
+ version?: string;
308
+ }[];
309
+ cache?: LoaderBundleCache;
310
+ platform?: "react" | "nextjs" | "gatsby";
311
+ platformOptions?: {
312
+ nextjs?: {
313
+ appDir: boolean;
314
+ };
315
+ };
316
+ preview?: boolean;
317
+ host?: string;
318
+ onClientSideFetch?: "warn" | "error";
319
+ i18n?: {
320
+ keyScheme: "content" | "hash" | "path";
321
+ tagPrefix?: string;
322
+ };
323
+ /**
324
+ * @deprecated use i18n.keyScheme instead
325
+ */
326
+ i18nKeyScheme?: "content" | "hash";
327
+ /**
328
+ * By default, fetchComponentData() and fetchPages() calls cached in memory
329
+ * with the PlasmicComponentLoader instance. If alwaysFresh is true, then
330
+ * data is always freshly fetched over the network.
331
+ */
332
+ alwaysFresh?: boolean;
333
+ /**
334
+ * If true, generated code from the server won't include page metadata tags
335
+ */
336
+ skipHead?: boolean;
337
+ /**
338
+ * If true, uses browser / node's native fetch
339
+ */
340
+ nativeFetch?: boolean;
341
+ /**
342
+ * If true, will not redirect to the codegen server automatically, and will
343
+ * try to reuse the existing bundle in the cache.
344
+ */
345
+ manualRedirect?: boolean;
346
+ }
347
+
348
+ export declare function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader;
349
+
350
+ export declare class InternalPlasmicComponentLoader extends BaseInternalPlasmicComponentLoader {
351
+ private readonly roots;
352
+ constructor(opts: InitOptions);
353
+ registerComponent<T extends React_3.ComponentType<any>>(component: T, meta: CodeComponentMeta<React_3.ComponentProps<T>>): void;
354
+ registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
355
+ registerGlobalContext<T extends React_3.ComponentType<any>>(context: T, meta: GlobalContextMeta<React_3.ComponentProps<T>>): void;
356
+ registerTrait(trait: string, meta: TraitMeta): void;
357
+ registerToken(token: TokenRegistration): void;
358
+ subscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
359
+ unsubscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
360
+ refreshRegistry(): void;
361
+ }
362
+
363
+ /**
364
+ * Check if `lookup` resolves to `pagePath`. If it's a match, return an object
365
+ * containing path params; otherwise, return false.
366
+ *
367
+ * For example,
368
+ * - `matchesPagePath("/hello/[name]", "/hello/world")` -> `{params: {name:
369
+ * "world"}}`
370
+ * - `matchesPagePath("/hello/[name]", "/")` -> `false`
371
+ * - `matchesPagePath("/hello/[...catchall]", "/hello/a/b/c")` -> `{params: {catchall: ["a", "b", "c"]}}`
372
+ * - `matchesPagePath("/hello/[[...catchall]]", "/hello/")` -> `{params: {catchall: []}}`
373
+ * - `matchesPagePath("/", "")` -> `{params: {}}`
374
+ */
375
+ export declare function matchesPagePath(pattern: string, path: string): false | {
376
+ params: Record<string, string | string[]>;
377
+ };
378
+
379
+ export { PageMeta }
380
+
381
+ export { PageMetadata }
382
+
383
+ export { PageParamsProvider }
384
+
385
+ export { PlasmicCanvasContext }
386
+
387
+ export { PlasmicCanvasHost }
388
+
389
+ export declare function PlasmicComponent(props: {
390
+ /**
391
+ * Name of the component to render, or the path of the page component
392
+ */
393
+ component: string;
394
+ /**
395
+ * Optionally specify a projectId if there are multiple components
396
+ * of the same name from different projects
397
+ */
398
+ projectId?: string;
399
+ /**
400
+ * If you used registerComponent(), then if the name matches a registered
401
+ * component, that component is used. If you want the Plasmic-generated
402
+ * component instead, specify forceOriginal.
403
+ */
404
+ forceOriginal?: boolean;
405
+ componentProps?: any;
406
+ }): React_2.ReactElement | null;
407
+
408
+ /**
409
+ * Library for fetching component data, and registering
410
+ * custom components.
411
+ */
412
+ export declare class PlasmicComponentLoader {
413
+ private __internal;
414
+ constructor(internal: BaseInternalPlasmicComponentLoader);
415
+ /**
416
+ * Sets global variants to be used for all components. Note that
417
+ * this is not reactive, and will not re-render all components
418
+ * already mounted; instead, it should be used to activate global
419
+ * variants that should always be activated for the lifetime of this
420
+ * app. If you'd like to reactively change the global variants,
421
+ * you should specify them via <PlasmicRootProvider />
422
+ */
423
+ setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
424
+ registerModules(modules: Record<string, any>): void;
425
+ /**
426
+ * Register custom components that should be swapped in for
427
+ * components defined in your project. You can use this to
428
+ * swap in / substitute a Plasmic component with a "real" component.
429
+ */
430
+ substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
431
+ /**
432
+ * Register code components to be used on Plasmic Editor.
433
+ */
434
+ registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
435
+ /**
436
+ * [[deprecated]] Please use `substituteComponent` instead for component
437
+ * substitution, or the other `registerComponent` overload to register
438
+ * code components to be used on Plasmic Editor.
439
+ *
440
+ * @see `substituteComponent`
441
+ */
442
+ registerComponent<T extends React.ComponentType<any>>(component: T, name: ComponentLookupSpec): void;
443
+ private warnedRegisterComponent;
444
+ registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
445
+ registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
446
+ registerTrait(trait: string, meta: TraitMeta): void;
447
+ registerToken(token: TokenRegistration): void;
448
+ /**
449
+ * Pre-fetches component data needed to for PlasmicLoader to render
450
+ * these components. Should be passed into PlasmicRootProvider as
451
+ * the prefetchedData prop.
452
+ *
453
+ * You can look up a component either by:
454
+ * - the name of the component
455
+ * - the path for a page component
456
+ * - an array of strings that make up parts of the path
457
+ * - object { name: "name_or_path", projectId: ...}, to specify which project
458
+ * to use, if multiple projects have the same component name
459
+ *
460
+ * Throws an Error if a specified component to fetch does not exist in
461
+ * the Plasmic project.
462
+ */
463
+ fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
464
+ fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
465
+ /**
466
+ * Like fetchComponentData(), but returns null instead of throwing an Error
467
+ * when a component is not found. Useful when you are implementing a catch-all
468
+ * page and want to check if a specific path had been defined for Plasmic.
469
+ */
470
+ maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
471
+ maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
472
+ /**
473
+ * Returns all the page component metadata for these projects.
474
+ */
475
+ fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
476
+ /**
477
+ * Returns all components metadata for these projects.
478
+ */
479
+ fetchComponents(): Promise<ComponentMeta_2[]>;
480
+ protected _getActiveVariation(opts: Parameters<typeof PlasmicComponentLoader.__internal.getActiveVariation>[0]): Promise<Record<string, string>>;
481
+ getActiveVariation(opts: {
482
+ known?: Record<string, string>;
483
+ traits: Record<string, string | number | boolean>;
484
+ }): Promise<Record<string, string>>;
485
+ getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]): string;
486
+ getExternalVariation(variation: Record<string, string>, filters?: Parameters<typeof getExternalIds>[2]): Record<string, string>;
487
+ getActiveSplits(): Split[];
488
+ trackConversion(value?: number): void;
489
+ clearCache(): void;
490
+ unstable__getServerQueriesData(renderData: ComponentRenderData, $ctx: Record<string, any>): Promise<any>;
491
+ }
492
+
493
+ /**
494
+ * @deprecated Maintained for backwards compatibility
495
+ */
496
+ export declare function plasmicPrepass(element: React.ReactElement): Promise<void>;
497
+
498
+ /**
499
+ * PlasmicRootProvider should be used at the root of your page
500
+ * or application.
501
+ */
502
+ export declare function PlasmicRootProvider(props: {
503
+ /**
504
+ * The global PlasmicComponentLoader instance you created via
505
+ * initPlasmicLoader().
506
+ */
507
+ loader: PlasmicComponentLoader;
508
+ /**
509
+ * Global variants to activate for Plasmic components
510
+ */
511
+ globalVariants?: GlobalVariantSpec[];
512
+ children?: React_2.ReactNode;
513
+ /**
514
+ * If true, will skip rendering css
515
+ */
516
+ skipCss?: boolean;
517
+ /**
518
+ * If true, will skip installing fonts
519
+ */
520
+ skipFonts?: boolean;
521
+ /**
522
+ * If you have pre-fetched component data via PlasmicComponentLoader,
523
+ * you can pass them in here; PlasmicComponent will avoid fetching
524
+ * component data that have already been pre-fetched.
525
+ */
526
+ prefetchedData?: ComponentRenderData;
527
+ /**
528
+ * If you have pre-fetched data that are needed by usePlasmicQueryData(),
529
+ * then pass in the pre-fetched cache here, mapping query key to fetched data.
530
+ */
531
+ prefetchedQueryData?: Record<string, any>;
532
+ /**
533
+ * Specifies whether usePlasmicQueryData() should be operating in suspense mode
534
+ * (throwing promises).
535
+ */
536
+ suspenseForQueryData?: boolean;
537
+ /**
538
+ * Override your Global Contexts Provider props. This is a map from
539
+ * globalContextComponentNameProps to object of props to use for that
540
+ * component.
541
+ */
542
+ globalContextsProps?: Record<string, any>;
543
+ /**
544
+ * Specifies a mapping of split id to slice id that should be activated
545
+ */
546
+ variation?: Record<string, string>;
547
+ /**
548
+ * Translator function to be used for text blocks
549
+ */
550
+ translator?: PlasmicTranslator;
551
+ /**
552
+ * Head component to use in PlasmicHead component (e.g. Head from next/head
553
+ * or Helmet from react-helmet).
554
+ */
555
+ Head?: React_2.ComponentType<any>;
556
+ /**
557
+ * Link component to use. Can be any component that takes in props passed
558
+ * to an <a/> tag.
559
+ */
560
+ Link?: React_2.ComponentType<any>;
561
+ /**
562
+ * Page route without params substitution (e.g. /products/[slug]).
563
+ */
564
+ pageRoute?: string;
565
+ /**
566
+ * Page path parameters (e.g. {slug: "foo"} if page path is
567
+ * /products/[slug] and URI is /products/foo).
568
+ */
569
+ pageParams?: Record<string, string | string[] | undefined>;
570
+ /**
571
+ * Page query parameters (e.g. {q: "foo"} if page path is
572
+ * /some/path?q=foo).
573
+ */
574
+ pageQuery?: Record<string, string | string[] | undefined>;
575
+ /**
576
+ * Whether the internal Plasmic React.Suspense boundaries should be removed
577
+ */
578
+ disableLoadingBoundary?: boolean;
579
+ /**
580
+ * Whether the root React.Suspense boundary should be removed
581
+ */
582
+ disableRootLoadingBoundary?: boolean;
583
+ /**
584
+ * Fallback value for React.Suspense boundary
585
+ */
586
+ suspenseFallback?: React_2.ReactNode;
587
+ } & PlasmicDataSourceContextValue): React_2.JSX.Element;
588
+
589
+ declare interface PlasmicRootWatcher {
590
+ onDataFetched?: () => void;
591
+ }
592
+
593
+ export declare type PlasmicTranslator = (str: string, opts?: {
594
+ components?: {
595
+ [key: string]: React_2.ReactElement | React_2.ReactFragment;
596
+ };
597
+ }) => React_2.ReactNode;
598
+
599
+ export { PlasmicTranslatorContext }
600
+
601
+ export { PropType }
602
+
603
+ /**
604
+ * Helper functions to describe code component behaviors, in order to allow
605
+ * data extraction in RSC / Next.js App routing.
606
+ */
607
+ declare interface ReactServerOps {
608
+ readDataEnv: typeof useDataEnv;
609
+ readDataSelector: typeof useSelector;
610
+ readDataSelectors: typeof useSelectors;
611
+ /**
612
+ * The contexts are passed using a key instead of the context provider
613
+ * Notice it cannot access the default context value if none has been provided,
614
+ * since React server components cannot create contexts.
615
+ */
616
+ readContext: (contextKey: string) => any;
617
+ /**
618
+ * Allows data fetching from the code component and caching the result,
619
+ * which will be stored in the `queryCache` returned by
620
+ * `extractPlasmicQueryData`.
621
+ */
622
+ fetchData: typeof useMutablePlasmicQueryData;
623
+ }
624
+
625
+ export declare function renderToElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
626
+ prefetchedData?: ComponentRenderData;
627
+ componentProps?: any;
628
+ globalVariants?: GlobalVariantSpec[];
629
+ prefetchedQueryData?: Record<string, any>;
630
+ pageParams?: Record<string, any>;
631
+ pageQuery?: Record<string, any>;
632
+ }): Promise<void>;
633
+
634
+ export declare function renderToString(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
635
+ prefetchedData?: ComponentRenderData;
636
+ componentProps?: any;
637
+ globalVariants?: GlobalVariantSpec[];
638
+ prefetchedQueryData?: Record<string, any>;
639
+ }): string;
640
+
641
+ export { repeatedElement }
642
+
643
+ /**
644
+ * Each child of a code component might receive separate `DataProvider` and
645
+ * Context values.
646
+ */
647
+ declare interface ServerChildData {
648
+ providedData?: ServerProvidedData | ServerProvidedData[];
649
+ providedContexts?: ServerProvidedContext | ServerProvidedContext[];
650
+ node: React.ReactNode;
651
+ }
652
+
653
+ declare interface ServerInfo {
654
+ /**
655
+ * Optional: Indicates the React Nodes created by the component and the
656
+ * respective contexts provided to them. If not specified, it will render the
657
+ * children passed to the component as props.
658
+ */
659
+ children?: ServerChildData | ServerChildData[];
660
+ providedData?: ServerProvidedData | ServerProvidedData[];
661
+ providedContexts?: ServerProvidedContext | ServerProvidedContext[];
662
+ }
663
+
664
+ /**
665
+ * Provides a new value for a given context key, similar to Context.Provider.
666
+ * The context itself is not available (RSC doesn't allow calling
667
+ * `createContext`) so each context will need to be represented as a unique
668
+ * "context key". Also it means the default context value is not available
669
+ * in case no value is passed (and reading that context will return `undefined`)
670
+ */
671
+ declare interface ServerProvidedContext {
672
+ /**
673
+ * Identifier to the context, required to read it later via
674
+ * `ReactServerOps.readContext()`.
675
+ */
676
+ contextKey: string;
677
+ /**
678
+ * Context value being provided (similar to `Context.Provider`).
679
+ */
680
+ value: any;
681
+ }
682
+
683
+ /**
684
+ * Represents data provided by a code component via `DataProvider`
685
+ */
686
+ declare interface ServerProvidedData {
687
+ name: string;
688
+ data: any;
689
+ }
690
+
691
+ export { TokenRegistration }
692
+
693
+ export { useDataEnv }
694
+
695
+ export { usePlasmicCanvasComponentInfo }
696
+
697
+ export { usePlasmicCanvasContext }
698
+
699
+ /**
700
+ * Hook that fetches and returns a React component for rendering the argument
701
+ * Plasmic component. Returns undefined if the component data is still
702
+ * being fetched.
703
+ *
704
+ * @param opts.forceOriginal if you used PlasmicComponentLoader.registerComponent,
705
+ * then normally usePlasmicComponent will return the registered component.
706
+ * You can set forceOriginal to true if you want to return the Plasmic-generated
707
+ * component instead.
708
+ */
709
+ export declare function usePlasmicComponent<P extends React_2.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
710
+ forceOriginal?: boolean;
711
+ }): P;
712
+
713
+ export { usePlasmicQueryData }
714
+
715
+ export { useSelector }
716
+
717
+ export { useSelectors }
718
+
719
+ export { }