@plasmicapp/loader-react 1.0.317 → 1.0.319
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 +522 -14
- package/dist/index.esm.js +6 -6
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +4 -4
- package/dist/index.js.map +2 -2
- package/dist/react-server.d.ts +150 -4
- package/package.json +9 -12
- package/dist/PlasmicComponent.d.ts +0 -19
- package/dist/PlasmicRootProvider.d.ts +0 -112
- package/dist/bundles.d.ts +0 -7
- package/dist/component-lookup.d.ts +0 -21
- package/dist/global-variants.d.ts +0 -13
- package/dist/loader-react-server.d.ts +0 -92
- package/dist/loader.d.ts +0 -185
- package/dist/render.d.ts +0 -29
- package/dist/shared-exports.d.ts +0 -6
- package/dist/usePlasmicComponent.d.ts +0 -15
- package/dist/utils.d.ts +0 -31
- package/dist/variation.d.ts +0 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,523 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { AssetModule } from '@plasmicapp/loader-core';
|
|
2
|
+
import { CodeComponentMeta as CodeComponentMeta_2 } from '@plasmicapp/host';
|
|
3
|
+
import { ComponentMeta } from '@plasmicapp/loader-core';
|
|
4
|
+
import { CustomFunctionMeta as CustomFunctionMeta_2 } from '@plasmicapp/host';
|
|
5
|
+
import { DataCtxReader } from '@plasmicapp/host';
|
|
6
|
+
import { DataProvider } from '@plasmicapp/host';
|
|
7
|
+
import { extractPlasmicQueryData } from '@plasmicapp/prepass';
|
|
8
|
+
import { FontMeta } from '@plasmicapp/loader-core';
|
|
9
|
+
import { getExternalIds } from '@plasmicapp/loader-splits';
|
|
10
|
+
import { GlobalContextMeta as GlobalContextMeta_2 } from '@plasmicapp/host';
|
|
11
|
+
import { GlobalGroupMeta } from '@plasmicapp/loader-core';
|
|
12
|
+
import { LoaderBundleCache } from '@plasmicapp/loader-core';
|
|
13
|
+
import { LoaderBundleOutput } from '@plasmicapp/loader-core';
|
|
14
|
+
import { PageMeta } from '@plasmicapp/loader-core';
|
|
15
|
+
import { PageMeta as PageMeta_2 } from '@plasmicapp/loader-fetcher';
|
|
16
|
+
import { PageMetadata } from '@plasmicapp/loader-core';
|
|
17
|
+
import { PageParamsProvider } from '@plasmicapp/host';
|
|
18
|
+
import { PlasmicCanvasContext } from '@plasmicapp/host';
|
|
19
|
+
import { PlasmicCanvasHost } from '@plasmicapp/host';
|
|
20
|
+
import { PlasmicDataSourceContextValue } from '@plasmicapp/data-sources-context';
|
|
21
|
+
import { plasmicPrepass } from '@plasmicapp/prepass';
|
|
22
|
+
import { PropType } from '@plasmicapp/host';
|
|
23
|
+
import { default as React_2 } from 'react';
|
|
24
|
+
import * as React_3 from 'react';
|
|
25
|
+
import { Registry } from '@plasmicapp/loader-core';
|
|
26
|
+
import { repeatedElement } from '@plasmicapp/host';
|
|
27
|
+
import { Split } from '@plasmicapp/loader-fetcher';
|
|
28
|
+
import { StateHelpers } from '@plasmicapp/host';
|
|
29
|
+
import { StateSpec } from '@plasmicapp/host';
|
|
30
|
+
import { TokenRegistration } from '@plasmicapp/host';
|
|
31
|
+
import { TrackRenderOptions } from '@plasmicapp/loader-core';
|
|
32
|
+
import { TraitMeta } from '@plasmicapp/host';
|
|
33
|
+
import { useDataEnv } from '@plasmicapp/host';
|
|
34
|
+
import { usePlasmicCanvasContext } from '@plasmicapp/host';
|
|
35
|
+
import { usePlasmicQueryData } from '@plasmicapp/query';
|
|
36
|
+
import { useSelector } from '@plasmicapp/host';
|
|
37
|
+
import { useSelectors } from '@plasmicapp/host';
|
|
38
|
+
|
|
39
|
+
export declare type CodeComponentMeta<P> = Omit<CodeComponentMeta_2<P>, "importPath" | "componentHelpers" | "states"> & {
|
|
40
|
+
/**
|
|
41
|
+
* The path to be used when importing the component in the generated code.
|
|
42
|
+
* It can be the name of the package that contains the component, or the path
|
|
43
|
+
* to the file in the project (relative to the root directory).
|
|
44
|
+
* Optional: not used by Plasmic headless API, only by codegen.
|
|
45
|
+
*/
|
|
46
|
+
importPath?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The states helpers are registered together with the states for the Plasmic headless API
|
|
49
|
+
*/
|
|
50
|
+
states?: Record<string, StateSpec<P> & StateHelpers<P, any>>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
declare class ComponentLookup {
|
|
54
|
+
private bundle;
|
|
55
|
+
private registry;
|
|
56
|
+
constructor(bundle: LoaderBundleOutput, registry: Registry);
|
|
57
|
+
getComponentMeta(spec: ComponentLookupSpec): ComponentMeta | undefined;
|
|
58
|
+
getComponent<P extends React_3.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
|
|
59
|
+
forceOriginal?: boolean;
|
|
60
|
+
}): any;
|
|
61
|
+
hasComponent(spec: ComponentLookupSpec): boolean;
|
|
62
|
+
getGlobalContexts(): {
|
|
63
|
+
meta: GlobalGroupMeta;
|
|
64
|
+
context: any;
|
|
65
|
+
}[];
|
|
66
|
+
getGlobalContextsProvider(spec: ComponentLookupSpec): any;
|
|
67
|
+
getRootProvider(): any;
|
|
68
|
+
getCss(): AssetModule[];
|
|
69
|
+
getRemoteFonts(): FontMeta[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare type ComponentLookupSpec = string | {
|
|
73
|
+
name: string;
|
|
74
|
+
projectId?: string;
|
|
75
|
+
isCode?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export { ComponentMeta }
|
|
79
|
+
|
|
80
|
+
export declare interface ComponentRenderData {
|
|
81
|
+
entryCompMetas: (ComponentMeta & {
|
|
82
|
+
params?: Record<string, string>;
|
|
83
|
+
})[];
|
|
84
|
+
bundle: LoaderBundleOutput;
|
|
85
|
+
remoteFontUrls: string[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
|
|
89
|
+
|
|
90
|
+
declare type CustomFunctionMeta<F extends (...args: any[]) => any> = Omit<CustomFunctionMeta_2<F>, "importPath"> & {
|
|
91
|
+
/**
|
|
92
|
+
* The path to be used when importing the function in the generated code.
|
|
93
|
+
* It can be the name of the package that contains the function, or the path
|
|
94
|
+
* to the file in the project (relative to the root directory).
|
|
95
|
+
* Optional: not used by Plasmic headless API, only by codegen.
|
|
96
|
+
*/
|
|
97
|
+
importPath?: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { DataCtxReader }
|
|
101
|
+
|
|
102
|
+
export { DataProvider }
|
|
103
|
+
|
|
104
|
+
export { extractPlasmicQueryData }
|
|
105
|
+
|
|
106
|
+
export declare function extractPlasmicQueryDataFromElement(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
|
|
107
|
+
prefetchedData?: ComponentRenderData;
|
|
108
|
+
componentProps?: any;
|
|
109
|
+
globalVariants?: GlobalVariantSpec[];
|
|
110
|
+
prefetchedQueryData?: Record<string, any>;
|
|
111
|
+
}): Promise<Record<string, any>>;
|
|
112
|
+
|
|
113
|
+
declare interface FetchComponentDataOpts {
|
|
114
|
+
/**
|
|
115
|
+
* Will fetch either code targeting SSR or browser hydration in the
|
|
116
|
+
* returned bundle.
|
|
117
|
+
*
|
|
118
|
+
* By default, the target is browser. That's okay, because even when
|
|
119
|
+
* doing SSR, as long as you are using the same instance of PlasmicLoader
|
|
120
|
+
* that was used to fetch component data, it will still know how to get at
|
|
121
|
+
* the server code.
|
|
122
|
+
*
|
|
123
|
+
* But, if you are building your own SSR solution, where fetching and rendering
|
|
124
|
+
* are using different instances of PlasmicLoader, then you'll want to make
|
|
125
|
+
* sure that when you fetch, you are fetching the right one to be used in the
|
|
126
|
+
* right environment for either SSR or browser hydration.
|
|
127
|
+
*/
|
|
128
|
+
target?: "server" | "browser";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare type FetchPagesOpts = {
|
|
132
|
+
/**
|
|
133
|
+
* Whether to include dynamic pages in fetchPages() output. A page is
|
|
134
|
+
* considered dynamic if its path contains some param between brackets,
|
|
135
|
+
* e.g. "[slug]".
|
|
136
|
+
*/
|
|
137
|
+
includeDynamicPages?: boolean;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
declare type GlobalContextMeta<P> = Omit<GlobalContextMeta_2<P>, "importPath"> & {
|
|
141
|
+
/**
|
|
142
|
+
* The path to be used when importing the component in the generated code.
|
|
143
|
+
* It can be the name of the package that contains the component, or the path
|
|
144
|
+
* to the file in the project (relative to the root directory).
|
|
145
|
+
* Optional: not used by Plasmic headless API, only by codegen.
|
|
146
|
+
*/
|
|
147
|
+
importPath?: string;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export declare interface GlobalVariantSpec {
|
|
151
|
+
name: string;
|
|
152
|
+
projectId?: string;
|
|
153
|
+
value: any;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare function hydrateFromElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
|
|
157
|
+
prefetchedData?: ComponentRenderData;
|
|
158
|
+
componentProps?: any;
|
|
159
|
+
globalVariants?: GlobalVariantSpec[];
|
|
160
|
+
prefetchedQueryData?: Record<string, any>;
|
|
161
|
+
}): Promise<void>;
|
|
162
|
+
|
|
163
|
+
export declare interface InitOptions {
|
|
164
|
+
projects: {
|
|
165
|
+
id: string;
|
|
166
|
+
token: string;
|
|
167
|
+
version?: string;
|
|
168
|
+
}[];
|
|
169
|
+
cache?: LoaderBundleCache;
|
|
170
|
+
platform?: "react" | "nextjs" | "gatsby";
|
|
171
|
+
platformOptions?: {
|
|
172
|
+
nextjs?: {
|
|
173
|
+
appDir: boolean;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
preview?: boolean;
|
|
177
|
+
host?: string;
|
|
178
|
+
onClientSideFetch?: "warn" | "error";
|
|
179
|
+
i18n?: {
|
|
180
|
+
keyScheme: "content" | "hash" | "path";
|
|
181
|
+
tagPrefix?: string;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated use i18n.keyScheme instead
|
|
185
|
+
*/
|
|
186
|
+
i18nKeyScheme?: "content" | "hash";
|
|
187
|
+
/**
|
|
188
|
+
* By default, fetchComponentData() and fetchPages() calls cached in memory
|
|
189
|
+
* with the PlasmicComponentLoader instance. If alwaysFresh is true, then
|
|
190
|
+
* data is always freshly fetched over the network.
|
|
191
|
+
*/
|
|
192
|
+
alwaysFresh?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* If true, generated code from the server won't include page metadata tags
|
|
195
|
+
*/
|
|
196
|
+
skipHead?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* If true, uses browser / node's native fetch
|
|
199
|
+
*/
|
|
200
|
+
nativeFetch?: boolean;
|
|
201
|
+
}
|
|
202
|
+
|
|
15
203
|
export declare function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader;
|
|
204
|
+
|
|
205
|
+
export declare class InternalPlasmicComponentLoader {
|
|
206
|
+
opts: InitOptions;
|
|
207
|
+
private readonly reactServerLoader;
|
|
208
|
+
private readonly registry;
|
|
209
|
+
private subs;
|
|
210
|
+
private roots;
|
|
211
|
+
private globalVariants;
|
|
212
|
+
private tracker;
|
|
213
|
+
constructor(opts: InitOptions);
|
|
214
|
+
getBundle(): LoaderBundleOutput;
|
|
215
|
+
setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
|
|
216
|
+
getGlobalVariants(): GlobalVariantSpec[];
|
|
217
|
+
registerModules(modules: Record<string, any>): void;
|
|
218
|
+
substituteComponent<P>(component: React_2.ComponentType<P>, name: ComponentLookupSpec): void;
|
|
219
|
+
private internalSubstituteComponent;
|
|
220
|
+
registerComponent<T extends React_2.ComponentType<any>>(component: T, meta: CodeComponentMeta<React_2.ComponentProps<T>>): void;
|
|
221
|
+
registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
222
|
+
registerGlobalContext<T extends React_2.ComponentType<any>>(context: T, meta: GlobalContextMeta<React_2.ComponentProps<T>>): void;
|
|
223
|
+
registerTrait(trait: string, meta: TraitMeta): void;
|
|
224
|
+
registerToken(token: TokenRegistration): void;
|
|
225
|
+
registerPrefetchedBundle(bundle: LoaderBundleOutput): void;
|
|
226
|
+
subscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
|
|
227
|
+
unsubscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
|
|
228
|
+
clearCache(): void;
|
|
229
|
+
getLookup(): ComponentLookup;
|
|
230
|
+
maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
|
|
231
|
+
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
232
|
+
fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
|
|
233
|
+
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
234
|
+
fetchPages(opts?: FetchPagesOpts): Promise<PageMeta_2[]>;
|
|
235
|
+
fetchComponents(): Promise<ComponentMeta[]>;
|
|
236
|
+
getActiveSplits(): Split[];
|
|
237
|
+
trackConversion(value?: number): void;
|
|
238
|
+
getActiveVariation(opts: {
|
|
239
|
+
traits: Record<string, string | number | boolean>;
|
|
240
|
+
getKnownValue: (key: string) => string | undefined;
|
|
241
|
+
updateKnownValue: (key: string, value: string) => void;
|
|
242
|
+
}): Promise<Record<string, string>>;
|
|
243
|
+
getTeamIds(): string[];
|
|
244
|
+
getProjectIds(): string[];
|
|
245
|
+
trackRender(opts?: TrackRenderOptions): void;
|
|
246
|
+
private refreshRegistry;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Check if `lookup` resolves to `pagePath`. If it's a match, return an object
|
|
251
|
+
* containing path params; otherwise, return false.
|
|
252
|
+
*
|
|
253
|
+
* For example,
|
|
254
|
+
* - `matchesPagePath("/hello/[name]", "/hello/world")` -> `{params: {name:
|
|
255
|
+
* "world"}}`
|
|
256
|
+
* - `matchesPagePath("/hello/[name]", "/")` -> `false`
|
|
257
|
+
* - `matchesPagePath("/hello/[...catchall]", "/hello/a/b/c")` -> `{params: {catchall: ["a", "b", "c"]}}`
|
|
258
|
+
* - `matchesPagePath("/", "")` -> `{params: {}}`
|
|
259
|
+
*/
|
|
260
|
+
export declare function matchesPagePath(pagePath: string, lookup: string): {
|
|
261
|
+
params: Record<string, string | string[]>;
|
|
262
|
+
} | false;
|
|
263
|
+
|
|
264
|
+
export { PageMeta }
|
|
265
|
+
|
|
266
|
+
export { PageMetadata }
|
|
267
|
+
|
|
268
|
+
export { PageParamsProvider }
|
|
269
|
+
|
|
270
|
+
export { PlasmicCanvasContext }
|
|
271
|
+
|
|
272
|
+
export { PlasmicCanvasHost }
|
|
273
|
+
|
|
274
|
+
export declare function PlasmicComponent(props: {
|
|
275
|
+
/**
|
|
276
|
+
* Name of the component to render, or the path of the page component
|
|
277
|
+
*/
|
|
278
|
+
component: string;
|
|
279
|
+
/**
|
|
280
|
+
* Optionally specify a projectId if there are multiple components
|
|
281
|
+
* of the same name from different projects
|
|
282
|
+
*/
|
|
283
|
+
projectId?: string;
|
|
284
|
+
/**
|
|
285
|
+
* If you used registerComponent(), then if the name matches a registered
|
|
286
|
+
* component, that component is used. If you want the Plasmic-generated
|
|
287
|
+
* component instead, specify forceOriginal.
|
|
288
|
+
*/
|
|
289
|
+
forceOriginal?: boolean;
|
|
290
|
+
componentProps?: any;
|
|
291
|
+
}): React_3.ReactElement | null;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Library for fetching component data, and registering
|
|
295
|
+
* custom components.
|
|
296
|
+
*/
|
|
297
|
+
export declare class PlasmicComponentLoader {
|
|
298
|
+
private __internal;
|
|
299
|
+
constructor(internal: InternalPlasmicComponentLoader);
|
|
300
|
+
/**
|
|
301
|
+
* Sets global variants to be used for all components. Note that
|
|
302
|
+
* this is not reactive, and will not re-render all components
|
|
303
|
+
* already mounted; instead, it should be used to activate global
|
|
304
|
+
* variants that should always be activated for the lifetime of this
|
|
305
|
+
* app. If you'd like to reactively change the global variants,
|
|
306
|
+
* you should specify them via <PlasmicRootProvider />
|
|
307
|
+
*/
|
|
308
|
+
setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
|
|
309
|
+
registerModules(modules: Record<string, any>): void;
|
|
310
|
+
/**
|
|
311
|
+
* Register custom components that should be swapped in for
|
|
312
|
+
* components defined in your project. You can use this to
|
|
313
|
+
* swap in / substitute a Plasmic component with a "real" component.
|
|
314
|
+
*/
|
|
315
|
+
substituteComponent<P>(component: React_2.ComponentType<P>, name: ComponentLookupSpec): void;
|
|
316
|
+
/**
|
|
317
|
+
* Register code components to be used on Plasmic Editor.
|
|
318
|
+
*/
|
|
319
|
+
registerComponent<T extends React_2.ComponentType<any>>(component: T, meta: CodeComponentMeta<React_2.ComponentProps<T>>): void;
|
|
320
|
+
/**
|
|
321
|
+
* [[deprecated]] Please use `substituteComponent` instead for component
|
|
322
|
+
* substitution, or the other `registerComponent` overload to register
|
|
323
|
+
* code components to be used on Plasmic Editor.
|
|
324
|
+
*
|
|
325
|
+
* @see `substituteComponent`
|
|
326
|
+
*/
|
|
327
|
+
registerComponent<T extends React_2.ComponentType<any>>(component: T, name: ComponentLookupSpec): void;
|
|
328
|
+
private warnedRegisterComponent;
|
|
329
|
+
registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
330
|
+
registerGlobalContext<T extends React_2.ComponentType<any>>(context: T, meta: GlobalContextMeta<React_2.ComponentProps<T>>): void;
|
|
331
|
+
registerTrait(trait: string, meta: TraitMeta): void;
|
|
332
|
+
registerToken(token: TokenRegistration): void;
|
|
333
|
+
/**
|
|
334
|
+
* Pre-fetches component data needed to for PlasmicLoader to render
|
|
335
|
+
* these components. Should be passed into PlasmicRootProvider as
|
|
336
|
+
* the prefetchedData prop.
|
|
337
|
+
*
|
|
338
|
+
* You can look up a component either by:
|
|
339
|
+
* - the name of the component
|
|
340
|
+
* - the path for a page component
|
|
341
|
+
* - an array of strings that make up parts of the path
|
|
342
|
+
* - object { name: "name_or_path", projectId: ...}, to specify which project
|
|
343
|
+
* to use, if multiple projects have the same component name
|
|
344
|
+
*
|
|
345
|
+
* Throws an Error if a specified component to fetch does not exist in
|
|
346
|
+
* the Plasmic project.
|
|
347
|
+
*/
|
|
348
|
+
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
349
|
+
/**
|
|
350
|
+
* Like fetchComponentData(), but returns null instead of throwing an Error
|
|
351
|
+
* when a component is not found. Useful when you are implementing a catch-all
|
|
352
|
+
* page and want to check if a specific path had been defined for Plasmic.
|
|
353
|
+
*/
|
|
354
|
+
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
355
|
+
/**
|
|
356
|
+
* Returns all the page component metadata for these projects.
|
|
357
|
+
*/
|
|
358
|
+
fetchPages(opts?: FetchPagesOpts): Promise<PageMeta_2[]>;
|
|
359
|
+
/**
|
|
360
|
+
* Returns all components metadata for these projects.
|
|
361
|
+
*/
|
|
362
|
+
fetchComponents(): Promise<ComponentMeta[]>;
|
|
363
|
+
protected _getActiveVariation(opts: {
|
|
364
|
+
traits: Record<string, string | number | boolean>;
|
|
365
|
+
getKnownValue: (key: string) => string | undefined;
|
|
366
|
+
updateKnownValue: (key: string, value: string) => void;
|
|
367
|
+
}): Promise<Record<string, string>>;
|
|
368
|
+
getActiveVariation(opts: {
|
|
369
|
+
known?: Record<string, string>;
|
|
370
|
+
traits: Record<string, string | number | boolean>;
|
|
371
|
+
}): Promise<Record<string, string>>;
|
|
372
|
+
getExternalVariation(variation: Record<string, string>, filters?: Parameters<typeof getExternalIds>[2]): Record<string, string>;
|
|
373
|
+
getActiveSplits(): Split[];
|
|
374
|
+
trackConversion(value?: number): void;
|
|
375
|
+
clearCache(): void;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export { plasmicPrepass }
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* PlasmicRootProvider should be used at the root of your page
|
|
382
|
+
* or application.
|
|
383
|
+
*/
|
|
384
|
+
export declare function PlasmicRootProvider(props: {
|
|
385
|
+
/**
|
|
386
|
+
* The global PlasmicComponentLoader instance you created via
|
|
387
|
+
* initPlasmicLoader().
|
|
388
|
+
*/
|
|
389
|
+
loader: PlasmicComponentLoader;
|
|
390
|
+
/**
|
|
391
|
+
* Global variants to activate for Plasmic components
|
|
392
|
+
*/
|
|
393
|
+
globalVariants?: GlobalVariantSpec[];
|
|
394
|
+
children?: React_3.ReactNode;
|
|
395
|
+
/**
|
|
396
|
+
* If true, will skip rendering css
|
|
397
|
+
*/
|
|
398
|
+
skipCss?: boolean;
|
|
399
|
+
/**
|
|
400
|
+
* If true, will skip installing fonts
|
|
401
|
+
*/
|
|
402
|
+
skipFonts?: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* If you have pre-fetched component data via PlasmicComponentLoader,
|
|
405
|
+
* you can pass them in here; PlasmicComponent will avoid fetching
|
|
406
|
+
* component data that have already been pre-fetched.
|
|
407
|
+
*/
|
|
408
|
+
prefetchedData?: ComponentRenderData;
|
|
409
|
+
/**
|
|
410
|
+
* If you have pre-fetched data that are needed by usePlasmicQueryData(),
|
|
411
|
+
* then pass in the pre-fetched cache here, mapping query key to fetched data.
|
|
412
|
+
*/
|
|
413
|
+
prefetchedQueryData?: Record<string, any>;
|
|
414
|
+
/**
|
|
415
|
+
* Specifies whether usePlasmicQueryData() should be operating in suspense mode
|
|
416
|
+
* (throwing promises).
|
|
417
|
+
*/
|
|
418
|
+
suspenseForQueryData?: boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Override your Global Contexts Provider props. This is a map from
|
|
421
|
+
* globalContextComponentNameProps to object of props to use for that
|
|
422
|
+
* component.
|
|
423
|
+
*/
|
|
424
|
+
globalContextsProps?: Record<string, any>;
|
|
425
|
+
/**
|
|
426
|
+
* Specifies a mapping of split id to slice id that should be activated
|
|
427
|
+
*/
|
|
428
|
+
variation?: Record<string, string>;
|
|
429
|
+
/**
|
|
430
|
+
* Translator function to be used for text blocks
|
|
431
|
+
*/
|
|
432
|
+
translator?: PlasmicTranslator;
|
|
433
|
+
/**
|
|
434
|
+
* Head component to use in PlasmicHead component (e.g. Head from next/head
|
|
435
|
+
* or Helmet from react-helmet).
|
|
436
|
+
*/
|
|
437
|
+
Head?: React_3.ComponentType<any>;
|
|
438
|
+
/**
|
|
439
|
+
* Link component to use. Can be any component that takes in props passed
|
|
440
|
+
* to an <a/> tag.
|
|
441
|
+
*/
|
|
442
|
+
Link?: React_3.ComponentType<any>;
|
|
443
|
+
/**
|
|
444
|
+
* Page route without params substitution (e.g. /products/[slug]).
|
|
445
|
+
*/
|
|
446
|
+
pageRoute?: string;
|
|
447
|
+
/**
|
|
448
|
+
* Page path parameters (e.g. {slug: "foo"} if page path is
|
|
449
|
+
* /products/[slug] and URI is /products/foo).
|
|
450
|
+
*/
|
|
451
|
+
pageParams?: Record<string, string | string[] | undefined>;
|
|
452
|
+
/**
|
|
453
|
+
* Page query parameters (e.g. {q: "foo"} if page path is
|
|
454
|
+
* /some/path?q=foo).
|
|
455
|
+
*/
|
|
456
|
+
pageQuery?: Record<string, string | string[] | undefined>;
|
|
457
|
+
/**
|
|
458
|
+
* Whether the React.Suspense boundaries should be removed
|
|
459
|
+
*/
|
|
460
|
+
disableLoadingBoundary?: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* Fallback value for the root-level React.Suspense
|
|
463
|
+
*/
|
|
464
|
+
suspenseFallback?: React_3.ReactNode;
|
|
465
|
+
} & PlasmicDataSourceContextValue): React_3.JSX.Element;
|
|
466
|
+
|
|
467
|
+
declare interface PlasmicRootWatcher {
|
|
468
|
+
onDataFetched?: () => void;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export declare type PlasmicTranslator = (str: string, opts?: {
|
|
472
|
+
components?: {
|
|
473
|
+
[key: string]: React_3.ReactElement | React_3.ReactFragment;
|
|
474
|
+
};
|
|
475
|
+
}) => React_3.ReactNode;
|
|
476
|
+
|
|
477
|
+
export { PropType }
|
|
478
|
+
|
|
479
|
+
export declare function renderToElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
|
|
480
|
+
prefetchedData?: ComponentRenderData;
|
|
481
|
+
componentProps?: any;
|
|
482
|
+
globalVariants?: GlobalVariantSpec[];
|
|
483
|
+
prefetchedQueryData?: Record<string, any>;
|
|
484
|
+
pageParams?: Record<string, any>;
|
|
485
|
+
pageQuery?: Record<string, any>;
|
|
486
|
+
}): Promise<void>;
|
|
487
|
+
|
|
488
|
+
export declare function renderToString(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
|
|
489
|
+
prefetchedData?: ComponentRenderData;
|
|
490
|
+
componentProps?: any;
|
|
491
|
+
globalVariants?: GlobalVariantSpec[];
|
|
492
|
+
prefetchedQueryData?: Record<string, any>;
|
|
493
|
+
}): string;
|
|
494
|
+
|
|
495
|
+
export { repeatedElement }
|
|
496
|
+
|
|
497
|
+
export { TokenRegistration }
|
|
498
|
+
|
|
499
|
+
export { useDataEnv }
|
|
500
|
+
|
|
501
|
+
export { usePlasmicCanvasContext }
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Hook that fetches and returns a React component for rendering the argument
|
|
505
|
+
* Plasmic component. Returns undefined if the component data is still
|
|
506
|
+
* being fetched.
|
|
507
|
+
*
|
|
508
|
+
* @param opts.forceOriginal if you used PlasmicComponentLoader.registerComponent,
|
|
509
|
+
* then normally usePlasmicComponent will return the registered component.
|
|
510
|
+
* You can set forceOriginal to true if you want to return the Plasmic-generated
|
|
511
|
+
* component instead.
|
|
512
|
+
*/
|
|
513
|
+
export declare function usePlasmicComponent<P extends React_3.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
|
|
514
|
+
forceOriginal?: boolean;
|
|
515
|
+
}): P;
|
|
516
|
+
|
|
517
|
+
export { usePlasmicQueryData }
|
|
518
|
+
|
|
519
|
+
export { useSelector }
|
|
520
|
+
|
|
521
|
+
export { useSelectors }
|
|
522
|
+
|
|
523
|
+
export { }
|
package/dist/index.esm.js
CHANGED
|
@@ -56,11 +56,11 @@ import * as PlasmicDataSourcesContext from "@plasmicapp/data-sources-context";
|
|
|
56
56
|
import * as PlasmicHost from "@plasmicapp/host";
|
|
57
57
|
import {
|
|
58
58
|
registerComponent,
|
|
59
|
+
registerFunction,
|
|
59
60
|
registerGlobalContext,
|
|
60
61
|
registerToken,
|
|
61
62
|
registerTrait,
|
|
62
|
-
stateHelpersKeys
|
|
63
|
-
unstable_registerFunction
|
|
63
|
+
stateHelpersKeys
|
|
64
64
|
} from "@plasmicapp/host";
|
|
65
65
|
import {
|
|
66
66
|
PlasmicModulesFetcher,
|
|
@@ -933,9 +933,9 @@ var InternalPlasmicComponentLoader = class {
|
|
|
933
933
|
}
|
|
934
934
|
} : {}));
|
|
935
935
|
}
|
|
936
|
-
|
|
936
|
+
registerFunction(fn, meta) {
|
|
937
937
|
var _a;
|
|
938
|
-
|
|
938
|
+
registerFunction(fn, __spreadProps(__spreadValues({}, meta), {
|
|
939
939
|
importPath: (_a = meta.importPath) != null ? _a : ""
|
|
940
940
|
}));
|
|
941
941
|
REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
|
|
@@ -1079,8 +1079,8 @@ var PlasmicComponentLoader = class {
|
|
|
1079
1079
|
this.substituteComponent(component, metaOrName);
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
|
-
|
|
1083
|
-
this.__internal.
|
|
1082
|
+
registerFunction(fn, meta) {
|
|
1083
|
+
this.__internal.registerFunction(fn, meta);
|
|
1084
1084
|
}
|
|
1085
1085
|
registerGlobalContext(context, meta) {
|
|
1086
1086
|
this.__internal.registerGlobalContext(context, meta);
|