@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/react-server.d.ts
CHANGED
|
@@ -1,5 +1,151 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ComponentMeta } from '@plasmicapp/loader-core';
|
|
2
|
+
import { ComponentMeta as ComponentMeta_2 } from '@plasmicapp/loader-fetcher';
|
|
3
|
+
import { LoaderBundleCache } from '@plasmicapp/loader-core';
|
|
4
|
+
import { LoaderBundleOutput } from '@plasmicapp/loader-core';
|
|
5
|
+
import { LoaderBundleOutput as LoaderBundleOutput_2 } from '@plasmicapp/loader-fetcher';
|
|
6
|
+
import { PageMeta } from '@plasmicapp/loader-core';
|
|
7
|
+
import { PageMetadata } from '@plasmicapp/loader-core';
|
|
8
|
+
import { PlasmicModulesFetcher } from '@plasmicapp/loader-core';
|
|
9
|
+
import { PlasmicTracker } from '@plasmicapp/loader-core';
|
|
10
|
+
import { Split } from '@plasmicapp/loader-fetcher';
|
|
11
|
+
|
|
12
|
+
declare type ComponentLookupSpec = string | {
|
|
13
|
+
name: string;
|
|
14
|
+
projectId?: string;
|
|
15
|
+
isCode?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { ComponentMeta }
|
|
19
|
+
|
|
20
|
+
export declare interface ComponentRenderData {
|
|
21
|
+
entryCompMetas: (ComponentMeta & {
|
|
22
|
+
params?: Record<string, string>;
|
|
23
|
+
})[];
|
|
24
|
+
bundle: LoaderBundleOutput;
|
|
25
|
+
remoteFontUrls: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
|
|
29
|
+
|
|
30
|
+
declare interface FetchComponentDataOpts {
|
|
31
|
+
/**
|
|
32
|
+
* Will fetch either code targeting SSR or browser hydration in the
|
|
33
|
+
* returned bundle.
|
|
34
|
+
*
|
|
35
|
+
* By default, the target is browser. That's okay, because even when
|
|
36
|
+
* doing SSR, as long as you are using the same instance of PlasmicLoader
|
|
37
|
+
* that was used to fetch component data, it will still know how to get at
|
|
38
|
+
* the server code.
|
|
39
|
+
*
|
|
40
|
+
* But, if you are building your own SSR solution, where fetching and rendering
|
|
41
|
+
* are using different instances of PlasmicLoader, then you'll want to make
|
|
42
|
+
* sure that when you fetch, you are fetching the right one to be used in the
|
|
43
|
+
* right environment for either SSR or browser hydration.
|
|
44
|
+
*/
|
|
45
|
+
target?: "server" | "browser";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare type FetchPagesOpts = {
|
|
49
|
+
/**
|
|
50
|
+
* Whether to include dynamic pages in fetchPages() output. A page is
|
|
51
|
+
* considered dynamic if its path contains some param between brackets,
|
|
52
|
+
* e.g. "[slug]".
|
|
53
|
+
*/
|
|
54
|
+
includeDynamicPages?: boolean;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export declare interface InitOptions {
|
|
58
|
+
projects: {
|
|
59
|
+
id: string;
|
|
60
|
+
token: string;
|
|
61
|
+
version?: string;
|
|
62
|
+
}[];
|
|
63
|
+
cache?: LoaderBundleCache;
|
|
64
|
+
platform?: "react" | "nextjs" | "gatsby";
|
|
65
|
+
platformOptions?: {
|
|
66
|
+
nextjs?: {
|
|
67
|
+
appDir: boolean;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
preview?: boolean;
|
|
71
|
+
host?: string;
|
|
72
|
+
onClientSideFetch?: "warn" | "error";
|
|
73
|
+
i18n?: {
|
|
74
|
+
keyScheme: "content" | "hash" | "path";
|
|
75
|
+
tagPrefix?: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated use i18n.keyScheme instead
|
|
79
|
+
*/
|
|
80
|
+
i18nKeyScheme?: "content" | "hash";
|
|
81
|
+
/**
|
|
82
|
+
* By default, fetchComponentData() and fetchPages() calls cached in memory
|
|
83
|
+
* with the PlasmicComponentLoader instance. If alwaysFresh is true, then
|
|
84
|
+
* data is always freshly fetched over the network.
|
|
85
|
+
*/
|
|
86
|
+
alwaysFresh?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* If true, generated code from the server won't include page metadata tags
|
|
89
|
+
*/
|
|
90
|
+
skipHead?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* If true, uses browser / node's native fetch
|
|
93
|
+
*/
|
|
94
|
+
nativeFetch?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
5
97
|
export declare function initPlasmicLoader(opts: InitOptions): ReactServerPlasmicComponentLoader;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Check if `lookup` resolves to `pagePath`. If it's a match, return an object
|
|
101
|
+
* containing path params; otherwise, return false.
|
|
102
|
+
*
|
|
103
|
+
* For example,
|
|
104
|
+
* - `matchesPagePath("/hello/[name]", "/hello/world")` -> `{params: {name:
|
|
105
|
+
* "world"}}`
|
|
106
|
+
* - `matchesPagePath("/hello/[name]", "/")` -> `false`
|
|
107
|
+
* - `matchesPagePath("/hello/[...catchall]", "/hello/a/b/c")` -> `{params: {catchall: ["a", "b", "c"]}}`
|
|
108
|
+
* - `matchesPagePath("/", "")` -> `{params: {}}`
|
|
109
|
+
*/
|
|
110
|
+
export declare function matchesPagePath(pagePath: string, lookup: string): {
|
|
111
|
+
params: Record<string, string | string[]>;
|
|
112
|
+
} | false;
|
|
113
|
+
|
|
114
|
+
export { PageMeta }
|
|
115
|
+
|
|
116
|
+
export { PageMetadata }
|
|
117
|
+
|
|
118
|
+
/** Subset of loader functionality that works on React Server Components. */
|
|
119
|
+
export declare class ReactServerPlasmicComponentLoader {
|
|
120
|
+
private readonly opts;
|
|
121
|
+
private readonly fetcher;
|
|
122
|
+
private readonly tracker;
|
|
123
|
+
private readonly onBundleMerged?;
|
|
124
|
+
private readonly onBundleFetched?;
|
|
125
|
+
private bundle;
|
|
126
|
+
constructor(args: {
|
|
127
|
+
opts: InitOptions;
|
|
128
|
+
fetcher: PlasmicModulesFetcher;
|
|
129
|
+
tracker: PlasmicTracker;
|
|
130
|
+
/** Called after `mergeBundle` (including `fetch` calls). */
|
|
131
|
+
onBundleMerged?: () => void;
|
|
132
|
+
/** Called after any `fetch` calls. */
|
|
133
|
+
onBundleFetched?: () => void;
|
|
134
|
+
});
|
|
135
|
+
private maybeGetCompMetas;
|
|
136
|
+
maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
|
|
137
|
+
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
138
|
+
fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
|
|
139
|
+
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
140
|
+
fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
|
|
141
|
+
fetchComponents(): Promise<ComponentMeta_2[]>;
|
|
142
|
+
getActiveSplits(): Split[];
|
|
143
|
+
private fetchMissingData;
|
|
144
|
+
private maybeReportClientSideFetch;
|
|
145
|
+
private fetchAllData;
|
|
146
|
+
mergeBundle(bundle: LoaderBundleOutput_2): void;
|
|
147
|
+
getBundle(): LoaderBundleOutput_2;
|
|
148
|
+
clearCache(): void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/loader-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.319",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -42,9 +42,6 @@
|
|
|
42
42
|
"build:types": "yarn tsc",
|
|
43
43
|
"build:index": "node ../../build.mjs ./src/index.ts --use-client",
|
|
44
44
|
"build:react-server": "node ../../build.mjs ./src/react-server.ts",
|
|
45
|
-
"postbuild": "yarn postbuild:index && yarn postbuild:react-server",
|
|
46
|
-
"postbuild:index": "node ../../print-module-api.js ./packages/loader-react/dist/index.js > index-api.txt",
|
|
47
|
-
"postbuild:react-server": "node ../../print-module-api.js ./packages/loader-react/dist/react-server.js > index-react-server-api.txt",
|
|
48
45
|
"yalcp": "yalc publish --push",
|
|
49
46
|
"test": "yarn --cwd=../.. test",
|
|
50
47
|
"coverage": "yarn --cwd=../.. test --coverage --passWithNoTests",
|
|
@@ -54,13 +51,13 @@
|
|
|
54
51
|
"analyze": "size-limit --why"
|
|
55
52
|
},
|
|
56
53
|
"dependencies": {
|
|
57
|
-
"@plasmicapp/data-sources-context": "0.1.
|
|
58
|
-
"@plasmicapp/host": "1.0.
|
|
59
|
-
"@plasmicapp/loader-core": "1.0.
|
|
60
|
-
"@plasmicapp/loader-fetcher": "1.0.
|
|
61
|
-
"@plasmicapp/loader-splits": "1.0.
|
|
62
|
-
"@plasmicapp/prepass": "1.0.
|
|
63
|
-
"@plasmicapp/query": "0.1.
|
|
54
|
+
"@plasmicapp/data-sources-context": "0.1.19",
|
|
55
|
+
"@plasmicapp/host": "1.0.180",
|
|
56
|
+
"@plasmicapp/loader-core": "1.0.120",
|
|
57
|
+
"@plasmicapp/loader-fetcher": "1.0.42",
|
|
58
|
+
"@plasmicapp/loader-splits": "1.0.48",
|
|
59
|
+
"@plasmicapp/prepass": "1.0.12",
|
|
60
|
+
"@plasmicapp/query": "0.1.76",
|
|
64
61
|
"pascalcase": "^1.0.0",
|
|
65
62
|
"server-only": "0.0.1"
|
|
66
63
|
},
|
|
@@ -86,5 +83,5 @@
|
|
|
86
83
|
"@types/react-is": "^17.0.3"
|
|
87
84
|
},
|
|
88
85
|
"license": "MIT",
|
|
89
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "e509f855bddb2f2a527bbf0b4fc5fed35e607e5c"
|
|
90
87
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export declare function PlasmicComponent(props: {
|
|
3
|
-
/**
|
|
4
|
-
* Name of the component to render, or the path of the page component
|
|
5
|
-
*/
|
|
6
|
-
component: string;
|
|
7
|
-
/**
|
|
8
|
-
* Optionally specify a projectId if there are multiple components
|
|
9
|
-
* of the same name from different projects
|
|
10
|
-
*/
|
|
11
|
-
projectId?: string;
|
|
12
|
-
/**
|
|
13
|
-
* If you used registerComponent(), then if the name matches a registered
|
|
14
|
-
* component, that component is used. If you want the Plasmic-generated
|
|
15
|
-
* component instead, specify forceOriginal.
|
|
16
|
-
*/
|
|
17
|
-
forceOriginal?: boolean;
|
|
18
|
-
componentProps?: any;
|
|
19
|
-
}): React.ReactElement | null;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { PlasmicDataSourceContextValue } from "@plasmicapp/data-sources-context";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { ComponentRenderData, InternalPlasmicComponentLoader, PlasmicComponentLoader } from "./loader";
|
|
4
|
-
interface PlasmicRootContextValue extends PlasmicDataSourceContextValue {
|
|
5
|
-
globalVariants?: GlobalVariantSpec[];
|
|
6
|
-
globalContextsProps?: Record<string, any>;
|
|
7
|
-
loader: InternalPlasmicComponentLoader;
|
|
8
|
-
variation?: Record<string, string>;
|
|
9
|
-
translator?: PlasmicTranslator;
|
|
10
|
-
Head?: React.ComponentType<any>;
|
|
11
|
-
Link?: React.ComponentType<any>;
|
|
12
|
-
disableLoadingBoundary?: boolean;
|
|
13
|
-
suspenseFallback?: React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
export interface GlobalVariantSpec {
|
|
16
|
-
name: string;
|
|
17
|
-
projectId?: string;
|
|
18
|
-
value: any;
|
|
19
|
-
}
|
|
20
|
-
export type PlasmicTranslator = (str: string, opts?: {
|
|
21
|
-
components?: {
|
|
22
|
-
[key: string]: React.ReactElement | React.ReactFragment;
|
|
23
|
-
};
|
|
24
|
-
}) => React.ReactNode;
|
|
25
|
-
/**
|
|
26
|
-
* PlasmicRootProvider should be used at the root of your page
|
|
27
|
-
* or application.
|
|
28
|
-
*/
|
|
29
|
-
export declare function PlasmicRootProvider(props: {
|
|
30
|
-
/**
|
|
31
|
-
* The global PlasmicComponentLoader instance you created via
|
|
32
|
-
* initPlasmicLoader().
|
|
33
|
-
*/
|
|
34
|
-
loader: PlasmicComponentLoader;
|
|
35
|
-
/**
|
|
36
|
-
* Global variants to activate for Plasmic components
|
|
37
|
-
*/
|
|
38
|
-
globalVariants?: GlobalVariantSpec[];
|
|
39
|
-
children?: React.ReactNode;
|
|
40
|
-
/**
|
|
41
|
-
* If true, will skip rendering css
|
|
42
|
-
*/
|
|
43
|
-
skipCss?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* If true, will skip installing fonts
|
|
46
|
-
*/
|
|
47
|
-
skipFonts?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* If you have pre-fetched component data via PlasmicComponentLoader,
|
|
50
|
-
* you can pass them in here; PlasmicComponent will avoid fetching
|
|
51
|
-
* component data that have already been pre-fetched.
|
|
52
|
-
*/
|
|
53
|
-
prefetchedData?: ComponentRenderData;
|
|
54
|
-
/**
|
|
55
|
-
* If you have pre-fetched data that are needed by usePlasmicQueryData(),
|
|
56
|
-
* then pass in the pre-fetched cache here, mapping query key to fetched data.
|
|
57
|
-
*/
|
|
58
|
-
prefetchedQueryData?: Record<string, any>;
|
|
59
|
-
/**
|
|
60
|
-
* Specifies whether usePlasmicQueryData() should be operating in suspense mode
|
|
61
|
-
* (throwing promises).
|
|
62
|
-
*/
|
|
63
|
-
suspenseForQueryData?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Override your Global Contexts Provider props. This is a map from
|
|
66
|
-
* globalContextComponentNameProps to object of props to use for that
|
|
67
|
-
* component.
|
|
68
|
-
*/
|
|
69
|
-
globalContextsProps?: Record<string, any>;
|
|
70
|
-
/**
|
|
71
|
-
* Specifies a mapping of split id to slice id that should be activated
|
|
72
|
-
*/
|
|
73
|
-
variation?: Record<string, string>;
|
|
74
|
-
/**
|
|
75
|
-
* Translator function to be used for text blocks
|
|
76
|
-
*/
|
|
77
|
-
translator?: PlasmicTranslator;
|
|
78
|
-
/**
|
|
79
|
-
* Head component to use in PlasmicHead component (e.g. Head from next/head
|
|
80
|
-
* or Helmet from react-helmet).
|
|
81
|
-
*/
|
|
82
|
-
Head?: React.ComponentType<any>;
|
|
83
|
-
/**
|
|
84
|
-
* Link component to use. Can be any component that takes in props passed
|
|
85
|
-
* to an <a/> tag.
|
|
86
|
-
*/
|
|
87
|
-
Link?: React.ComponentType<any>;
|
|
88
|
-
/**
|
|
89
|
-
* Page route without params substitution (e.g. /products/[slug]).
|
|
90
|
-
*/
|
|
91
|
-
pageRoute?: string;
|
|
92
|
-
/**
|
|
93
|
-
* Page path parameters (e.g. {slug: "foo"} if page path is
|
|
94
|
-
* /products/[slug] and URI is /products/foo).
|
|
95
|
-
*/
|
|
96
|
-
pageParams?: Record<string, string | string[] | undefined>;
|
|
97
|
-
/**
|
|
98
|
-
* Page query parameters (e.g. {q: "foo"} if page path is
|
|
99
|
-
* /some/path?q=foo).
|
|
100
|
-
*/
|
|
101
|
-
pageQuery?: Record<string, string | string[] | undefined>;
|
|
102
|
-
/**
|
|
103
|
-
* Whether the React.Suspense boundaries should be removed
|
|
104
|
-
*/
|
|
105
|
-
disableLoadingBoundary?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Fallback value for the root-level React.Suspense
|
|
108
|
-
*/
|
|
109
|
-
suspenseFallback?: React.ReactNode;
|
|
110
|
-
} & PlasmicDataSourceContextValue): React.JSX.Element;
|
|
111
|
-
export declare function usePlasmicRootContext(): PlasmicRootContextValue | undefined;
|
|
112
|
-
export {};
|
package/dist/bundles.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta, LoaderBundleOutput } from '@plasmicapp/loader-core';
|
|
2
|
-
import type { ComponentRenderData } from './loader';
|
|
3
|
-
export declare function prepComponentData(bundle: LoaderBundleOutput, compMetas: ComponentMeta[], opts?: {
|
|
4
|
-
target?: 'browser' | 'server';
|
|
5
|
-
}): ComponentRenderData;
|
|
6
|
-
export declare function mergeBundles(target: LoaderBundleOutput, from: LoaderBundleOutput): LoaderBundleOutput;
|
|
7
|
-
export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AssetModule, ComponentMeta, FontMeta, GlobalGroupMeta, LoaderBundleOutput, Registry } from '@plasmicapp/loader-core';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ComponentLookupSpec } from './utils';
|
|
4
|
-
export declare class ComponentLookup {
|
|
5
|
-
private bundle;
|
|
6
|
-
private registry;
|
|
7
|
-
constructor(bundle: LoaderBundleOutput, registry: Registry);
|
|
8
|
-
getComponentMeta(spec: ComponentLookupSpec): ComponentMeta | undefined;
|
|
9
|
-
getComponent<P extends React.ComponentType = any>(spec: ComponentLookupSpec, opts?: {
|
|
10
|
-
forceOriginal?: boolean;
|
|
11
|
-
}): any;
|
|
12
|
-
hasComponent(spec: ComponentLookupSpec): boolean;
|
|
13
|
-
getGlobalContexts(): {
|
|
14
|
-
meta: GlobalGroupMeta;
|
|
15
|
-
context: any;
|
|
16
|
-
}[];
|
|
17
|
-
getGlobalContextsProvider(spec: ComponentLookupSpec): any;
|
|
18
|
-
getRootProvider(): any;
|
|
19
|
-
getCss(): AssetModule[];
|
|
20
|
-
getRemoteFonts(): FontMeta[];
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* We don't actually make use of the global variant React contexts generated
|
|
3
|
-
* in the bundle. That's because we would have to wait until the data is
|
|
4
|
-
* loaded before we can set up the context providers, but setting up context
|
|
5
|
-
* providers will mutate the React tree and invalidate all the children. That means
|
|
6
|
-
* once data comes in, we'll re-render the React tree from the providers down
|
|
7
|
-
* in a way that will lose all existing React state. Therefore, instead,
|
|
8
|
-
* we always have a single context provided -- the PlasmicRootContext -- and we
|
|
9
|
-
* create these fake useGlobalVariant() hooks that just read from that
|
|
10
|
-
* PlasmicRootContext. This allows us to have a stable React tree before and
|
|
11
|
-
* after the data load.
|
|
12
|
-
*/
|
|
13
|
-
export declare function createUseGlobalVariant(name: string, projectId: string): () => any;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { LoaderBundleCache, PageMeta, PlasmicModulesFetcher, PlasmicTracker } from "@plasmicapp/loader-core";
|
|
2
|
-
import { ComponentMeta, LoaderBundleOutput } from "@plasmicapp/loader-fetcher";
|
|
3
|
-
import { ComponentRenderData, FetchPagesOpts } from "./loader";
|
|
4
|
-
import { ComponentLookupSpec } from "./utils";
|
|
5
|
-
export interface InitOptions {
|
|
6
|
-
projects: {
|
|
7
|
-
id: string;
|
|
8
|
-
token: string;
|
|
9
|
-
version?: string;
|
|
10
|
-
}[];
|
|
11
|
-
cache?: LoaderBundleCache;
|
|
12
|
-
platform?: "react" | "nextjs" | "gatsby";
|
|
13
|
-
platformOptions?: {
|
|
14
|
-
nextjs?: {
|
|
15
|
-
appDir: boolean;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
preview?: boolean;
|
|
19
|
-
host?: string;
|
|
20
|
-
onClientSideFetch?: "warn" | "error";
|
|
21
|
-
i18n?: {
|
|
22
|
-
keyScheme: "content" | "hash" | "path";
|
|
23
|
-
tagPrefix?: string;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated use i18n.keyScheme instead
|
|
27
|
-
*/
|
|
28
|
-
i18nKeyScheme?: "content" | "hash";
|
|
29
|
-
/**
|
|
30
|
-
* By default, fetchComponentData() and fetchPages() calls cached in memory
|
|
31
|
-
* with the PlasmicComponentLoader instance. If alwaysFresh is true, then
|
|
32
|
-
* data is always freshly fetched over the network.
|
|
33
|
-
*/
|
|
34
|
-
alwaysFresh?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* If true, generated code from the server won't include page metadata tags
|
|
37
|
-
*/
|
|
38
|
-
skipHead?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* If true, uses browser / node's native fetch
|
|
41
|
-
*/
|
|
42
|
-
nativeFetch?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/** Subset of loader functionality that works on React Server Components. */
|
|
45
|
-
export declare class ReactServerPlasmicComponentLoader {
|
|
46
|
-
private readonly opts;
|
|
47
|
-
private readonly fetcher;
|
|
48
|
-
private readonly tracker;
|
|
49
|
-
private readonly onBundleMerged?;
|
|
50
|
-
private readonly onBundleFetched?;
|
|
51
|
-
private bundle;
|
|
52
|
-
constructor(args: {
|
|
53
|
-
opts: InitOptions;
|
|
54
|
-
fetcher: PlasmicModulesFetcher;
|
|
55
|
-
tracker: PlasmicTracker;
|
|
56
|
-
/** Called after `mergeBundle` (including `fetch` calls). */
|
|
57
|
-
onBundleMerged?: () => void;
|
|
58
|
-
/** Called after any `fetch` calls. */
|
|
59
|
-
onBundleFetched?: () => void;
|
|
60
|
-
});
|
|
61
|
-
private maybeGetCompMetas;
|
|
62
|
-
maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
|
|
63
|
-
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
64
|
-
fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
|
|
65
|
-
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
66
|
-
fetchPages(opts?: FetchPagesOpts): Promise<PageMeta[]>;
|
|
67
|
-
fetchComponents(): Promise<ComponentMeta[]>;
|
|
68
|
-
getActiveSplits(): import("@plasmicapp/loader-core").Split[];
|
|
69
|
-
private fetchMissingData;
|
|
70
|
-
private maybeReportClientSideFetch;
|
|
71
|
-
private fetchAllData;
|
|
72
|
-
mergeBundle(bundle: LoaderBundleOutput): void;
|
|
73
|
-
getBundle(): LoaderBundleOutput;
|
|
74
|
-
clearCache(): void;
|
|
75
|
-
}
|
|
76
|
-
export interface FetchComponentDataOpts {
|
|
77
|
-
/**
|
|
78
|
-
* Will fetch either code targeting SSR or browser hydration in the
|
|
79
|
-
* returned bundle.
|
|
80
|
-
*
|
|
81
|
-
* By default, the target is browser. That's okay, because even when
|
|
82
|
-
* doing SSR, as long as you are using the same instance of PlasmicLoader
|
|
83
|
-
* that was used to fetch component data, it will still know how to get at
|
|
84
|
-
* the server code.
|
|
85
|
-
*
|
|
86
|
-
* But, if you are building your own SSR solution, where fetching and rendering
|
|
87
|
-
* are using different instances of PlasmicLoader, then you'll want to make
|
|
88
|
-
* sure that when you fetch, you are fetching the right one to be used in the
|
|
89
|
-
* right environment for either SSR or browser hydration.
|
|
90
|
-
*/
|
|
91
|
-
target?: "server" | "browser";
|
|
92
|
-
}
|
package/dist/loader.d.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { CodeComponentMeta as InternalCodeComponentMeta, CustomFunctionMeta as InternalCustomFunctionMeta, GlobalContextMeta as InternalGlobalContextMeta, StateHelpers, StateSpec, TokenRegistration, TraitMeta } from "@plasmicapp/host";
|
|
2
|
-
import { ComponentMeta, LoaderBundleOutput, TrackRenderOptions } from "@plasmicapp/loader-core";
|
|
3
|
-
import { getExternalIds } from "@plasmicapp/loader-splits";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { ComponentLookup } from "./component-lookup";
|
|
6
|
-
import { FetchComponentDataOpts, InitOptions } from "./loader-react-server";
|
|
7
|
-
import type { GlobalVariantSpec } from "./PlasmicRootProvider";
|
|
8
|
-
import { ComponentLookupSpec } from "./utils";
|
|
9
|
-
export interface ComponentRenderData {
|
|
10
|
-
entryCompMetas: (ComponentMeta & {
|
|
11
|
-
params?: Record<string, string>;
|
|
12
|
-
})[];
|
|
13
|
-
bundle: LoaderBundleOutput;
|
|
14
|
-
remoteFontUrls: string[];
|
|
15
|
-
}
|
|
16
|
-
interface PlasmicRootWatcher {
|
|
17
|
-
onDataFetched?: () => void;
|
|
18
|
-
}
|
|
19
|
-
export type CodeComponentMeta<P> = Omit<InternalCodeComponentMeta<P>, "importPath" | "componentHelpers" | "states"> & {
|
|
20
|
-
/**
|
|
21
|
-
* The path to be used when importing the component in the generated code.
|
|
22
|
-
* It can be the name of the package that contains the component, or the path
|
|
23
|
-
* to the file in the project (relative to the root directory).
|
|
24
|
-
* Optional: not used by Plasmic headless API, only by codegen.
|
|
25
|
-
*/
|
|
26
|
-
importPath?: string;
|
|
27
|
-
/**
|
|
28
|
-
* The states helpers are registered together with the states for the Plasmic headless API
|
|
29
|
-
*/
|
|
30
|
-
states?: Record<string, StateSpec<P> & StateHelpers<P, any>>;
|
|
31
|
-
};
|
|
32
|
-
export type GlobalContextMeta<P> = Omit<InternalGlobalContextMeta<P>, "importPath"> & {
|
|
33
|
-
/**
|
|
34
|
-
* The path to be used when importing the component in the generated code.
|
|
35
|
-
* It can be the name of the package that contains the component, or the path
|
|
36
|
-
* to the file in the project (relative to the root directory).
|
|
37
|
-
* Optional: not used by Plasmic headless API, only by codegen.
|
|
38
|
-
*/
|
|
39
|
-
importPath?: string;
|
|
40
|
-
};
|
|
41
|
-
export type CustomFunctionMeta<F extends (...args: any[]) => any> = Omit<InternalCustomFunctionMeta<F>, "importPath"> & {
|
|
42
|
-
/**
|
|
43
|
-
* The path to be used when importing the function in the generated code.
|
|
44
|
-
* It can be the name of the package that contains the function, or the path
|
|
45
|
-
* to the file in the project (relative to the root directory).
|
|
46
|
-
* Optional: not used by Plasmic headless API, only by codegen.
|
|
47
|
-
*/
|
|
48
|
-
importPath?: string;
|
|
49
|
-
};
|
|
50
|
-
export type FetchPagesOpts = {
|
|
51
|
-
/**
|
|
52
|
-
* Whether to include dynamic pages in fetchPages() output. A page is
|
|
53
|
-
* considered dynamic if its path contains some param between brackets,
|
|
54
|
-
* e.g. "[slug]".
|
|
55
|
-
*/
|
|
56
|
-
includeDynamicPages?: boolean;
|
|
57
|
-
};
|
|
58
|
-
export declare class InternalPlasmicComponentLoader {
|
|
59
|
-
opts: InitOptions;
|
|
60
|
-
private readonly reactServerLoader;
|
|
61
|
-
private readonly registry;
|
|
62
|
-
private subs;
|
|
63
|
-
private roots;
|
|
64
|
-
private globalVariants;
|
|
65
|
-
private tracker;
|
|
66
|
-
constructor(opts: InitOptions);
|
|
67
|
-
getBundle(): LoaderBundleOutput;
|
|
68
|
-
setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
|
|
69
|
-
getGlobalVariants(): GlobalVariantSpec[];
|
|
70
|
-
registerModules(modules: Record<string, any>): void;
|
|
71
|
-
substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
|
|
72
|
-
private internalSubstituteComponent;
|
|
73
|
-
registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
|
|
74
|
-
unstable_registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
75
|
-
registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
|
|
76
|
-
registerTrait(trait: string, meta: TraitMeta): void;
|
|
77
|
-
registerToken(token: TokenRegistration): void;
|
|
78
|
-
registerPrefetchedBundle(bundle: LoaderBundleOutput): void;
|
|
79
|
-
subscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
|
|
80
|
-
unsubscribePlasmicRoot(watcher: PlasmicRootWatcher): void;
|
|
81
|
-
clearCache(): void;
|
|
82
|
-
getLookup(): ComponentLookup;
|
|
83
|
-
maybeFetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData | null>;
|
|
84
|
-
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
85
|
-
fetchComponentData(specs: ComponentLookupSpec[], opts?: FetchComponentDataOpts): Promise<ComponentRenderData>;
|
|
86
|
-
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
87
|
-
fetchPages(opts?: FetchPagesOpts): Promise<import("@plasmicapp/loader-core").PageMeta[]>;
|
|
88
|
-
fetchComponents(): Promise<ComponentMeta[]>;
|
|
89
|
-
getActiveSplits(): import("@plasmicapp/loader-core").Split[];
|
|
90
|
-
trackConversion(value?: number): void;
|
|
91
|
-
getActiveVariation(opts: {
|
|
92
|
-
traits: Record<string, string | number | boolean>;
|
|
93
|
-
getKnownValue: (key: string) => string | undefined;
|
|
94
|
-
updateKnownValue: (key: string, value: string) => void;
|
|
95
|
-
}): Promise<Record<string, string>>;
|
|
96
|
-
getTeamIds(): string[];
|
|
97
|
-
getProjectIds(): string[];
|
|
98
|
-
trackRender(opts?: TrackRenderOptions): void;
|
|
99
|
-
private refreshRegistry;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Library for fetching component data, and registering
|
|
103
|
-
* custom components.
|
|
104
|
-
*/
|
|
105
|
-
export declare class PlasmicComponentLoader {
|
|
106
|
-
private __internal;
|
|
107
|
-
constructor(internal: InternalPlasmicComponentLoader);
|
|
108
|
-
/**
|
|
109
|
-
* Sets global variants to be used for all components. Note that
|
|
110
|
-
* this is not reactive, and will not re-render all components
|
|
111
|
-
* already mounted; instead, it should be used to activate global
|
|
112
|
-
* variants that should always be activated for the lifetime of this
|
|
113
|
-
* app. If you'd like to reactively change the global variants,
|
|
114
|
-
* you should specify them via <PlasmicRootProvider />
|
|
115
|
-
*/
|
|
116
|
-
setGlobalVariants(globalVariants: GlobalVariantSpec[]): void;
|
|
117
|
-
registerModules(modules: Record<string, any>): void;
|
|
118
|
-
/**
|
|
119
|
-
* Register custom components that should be swapped in for
|
|
120
|
-
* components defined in your project. You can use this to
|
|
121
|
-
* swap in / substitute a Plasmic component with a "real" component.
|
|
122
|
-
*/
|
|
123
|
-
substituteComponent<P>(component: React.ComponentType<P>, name: ComponentLookupSpec): void;
|
|
124
|
-
/**
|
|
125
|
-
* Register code components to be used on Plasmic Editor.
|
|
126
|
-
*/
|
|
127
|
-
registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
|
|
128
|
-
/**
|
|
129
|
-
* [[deprecated]] Please use `substituteComponent` instead for component
|
|
130
|
-
* substitution, or the other `registerComponent` overload to register
|
|
131
|
-
* code components to be used on Plasmic Editor.
|
|
132
|
-
*
|
|
133
|
-
* @see `substituteComponent`
|
|
134
|
-
*/
|
|
135
|
-
registerComponent<T extends React.ComponentType<any>>(component: T, name: ComponentLookupSpec): void;
|
|
136
|
-
private warnedRegisterComponent;
|
|
137
|
-
unstable_registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
138
|
-
registerGlobalContext<T extends React.ComponentType<any>>(context: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
|
|
139
|
-
registerTrait(trait: string, meta: TraitMeta): void;
|
|
140
|
-
registerToken(token: TokenRegistration): void;
|
|
141
|
-
/**
|
|
142
|
-
* Pre-fetches component data needed to for PlasmicLoader to render
|
|
143
|
-
* these components. Should be passed into PlasmicRootProvider as
|
|
144
|
-
* the prefetchedData prop.
|
|
145
|
-
*
|
|
146
|
-
* You can look up a component either by:
|
|
147
|
-
* - the name of the component
|
|
148
|
-
* - the path for a page component
|
|
149
|
-
* - an array of strings that make up parts of the path
|
|
150
|
-
* - object { name: "name_or_path", projectId: ...}, to specify which project
|
|
151
|
-
* to use, if multiple projects have the same component name
|
|
152
|
-
*
|
|
153
|
-
* Throws an Error if a specified component to fetch does not exist in
|
|
154
|
-
* the Plasmic project.
|
|
155
|
-
*/
|
|
156
|
-
fetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData>;
|
|
157
|
-
/**
|
|
158
|
-
* Like fetchComponentData(), but returns null instead of throwing an Error
|
|
159
|
-
* when a component is not found. Useful when you are implementing a catch-all
|
|
160
|
-
* page and want to check if a specific path had been defined for Plasmic.
|
|
161
|
-
*/
|
|
162
|
-
maybeFetchComponentData(...specs: ComponentLookupSpec[]): Promise<ComponentRenderData | null>;
|
|
163
|
-
/**
|
|
164
|
-
* Returns all the page component metadata for these projects.
|
|
165
|
-
*/
|
|
166
|
-
fetchPages(opts?: FetchPagesOpts): Promise<import("@plasmicapp/loader-core").PageMeta[]>;
|
|
167
|
-
/**
|
|
168
|
-
* Returns all components metadata for these projects.
|
|
169
|
-
*/
|
|
170
|
-
fetchComponents(): Promise<ComponentMeta[]>;
|
|
171
|
-
protected _getActiveVariation(opts: {
|
|
172
|
-
traits: Record<string, string | number | boolean>;
|
|
173
|
-
getKnownValue: (key: string) => string | undefined;
|
|
174
|
-
updateKnownValue: (key: string, value: string) => void;
|
|
175
|
-
}): Promise<Record<string, string>>;
|
|
176
|
-
getActiveVariation(opts: {
|
|
177
|
-
known?: Record<string, string>;
|
|
178
|
-
traits: Record<string, string | number | boolean>;
|
|
179
|
-
}): Promise<Record<string, string>>;
|
|
180
|
-
getExternalVariation(variation: Record<string, string>, filters?: Parameters<typeof getExternalIds>[2]): Record<string, string>;
|
|
181
|
-
getActiveSplits(): import("@plasmicapp/loader-core").Split[];
|
|
182
|
-
trackConversion(value?: number): void;
|
|
183
|
-
clearCache(): void;
|
|
184
|
-
}
|
|
185
|
-
export {};
|