@plasmicapp/loader-react 1.0.395 → 2.0.0-alpha.1
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 +27 -3
- package/dist/index.esm.js +12 -18
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +12 -18
- package/dist/index.js.map +3 -3
- package/package.json +23 -16
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { react } from 'react';
|
|
|
36
36
|
import * as React_2 from 'react';
|
|
37
37
|
import { default as React_3 } from 'react';
|
|
38
38
|
import { reactDom } from 'react-dom';
|
|
39
|
+
import ReactDOMClient from 'react-dom/client';
|
|
39
40
|
import { reactJsxDevRuntime } from 'react/jsx-dev-runtime';
|
|
40
41
|
import { reactJsxRuntime } from 'react/jsx-runtime';
|
|
41
42
|
import { Registry } from '@plasmicapp/loader-core';
|
|
@@ -237,6 +238,11 @@ export { DataProvider }
|
|
|
237
238
|
*/
|
|
238
239
|
export declare function extractPlasmicQueryData(element: React.ReactElement): Promise<Record<string, any>>;
|
|
239
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Pre-renders a Plasmic tree to extract query data.
|
|
243
|
+
*
|
|
244
|
+
* This is intended to be used for server-rendered apps.
|
|
245
|
+
*/
|
|
240
246
|
export declare function extractPlasmicQueryDataFromElement(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
|
|
241
247
|
prefetchedData?: ComponentRenderData;
|
|
242
248
|
componentProps?: any;
|
|
@@ -275,7 +281,7 @@ export { GlobalActionsContext }
|
|
|
275
281
|
|
|
276
282
|
export { GlobalActionsProvider }
|
|
277
283
|
|
|
278
|
-
|
|
284
|
+
declare type GlobalContextMeta<P> = Omit<GlobalContextMeta_2<P>, "importPath"> & {
|
|
279
285
|
/**
|
|
280
286
|
* The path to be used when importing the component in the generated code.
|
|
281
287
|
* It can be the name of the package that contains the component, or the path
|
|
@@ -291,12 +297,18 @@ export declare interface GlobalVariantSpec {
|
|
|
291
297
|
value: any;
|
|
292
298
|
}
|
|
293
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Hydrates a Plasmic tree in the target element.
|
|
302
|
+
*
|
|
303
|
+
* Uses React DOM client API `hydrateRoot`, which is intended to be used from
|
|
304
|
+
* server-rendered apps.
|
|
305
|
+
*/
|
|
294
306
|
export declare function hydrateFromElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
|
|
295
307
|
prefetchedData?: ComponentRenderData;
|
|
296
308
|
componentProps?: any;
|
|
297
309
|
globalVariants?: GlobalVariantSpec[];
|
|
298
310
|
prefetchedQueryData?: Record<string, any>;
|
|
299
|
-
}):
|
|
311
|
+
}): ReactDOMClient.Root;
|
|
300
312
|
|
|
301
313
|
export declare interface InitOptions {
|
|
302
314
|
projects: {
|
|
@@ -620,6 +632,12 @@ declare interface ReactServerOps {
|
|
|
620
632
|
fetchData: typeof useMutablePlasmicQueryData;
|
|
621
633
|
}
|
|
622
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Renders a Plasmic tree in the target element.
|
|
637
|
+
*
|
|
638
|
+
* Uses React DOM client API `createRoot`, which is intended to be used from
|
|
639
|
+
* client-rendered apps.
|
|
640
|
+
*/
|
|
623
641
|
export declare function renderToElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
|
|
624
642
|
prefetchedData?: ComponentRenderData;
|
|
625
643
|
componentProps?: any;
|
|
@@ -627,8 +645,14 @@ export declare function renderToElement(loader: PlasmicComponentLoader, target:
|
|
|
627
645
|
prefetchedQueryData?: Record<string, any>;
|
|
628
646
|
pageParams?: Record<string, any>;
|
|
629
647
|
pageQuery?: Record<string, any>;
|
|
630
|
-
}):
|
|
648
|
+
}): ReactDOMClient.Root;
|
|
631
649
|
|
|
650
|
+
/**
|
|
651
|
+
* Renders a Plasmic tree to a string.
|
|
652
|
+
*
|
|
653
|
+
* Uses React DOM server API `renderToString`, which is intended to be used for
|
|
654
|
+
* server-rendered apps.
|
|
655
|
+
*/
|
|
632
656
|
export declare function renderToString(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
|
|
633
657
|
prefetchedData?: ComponentRenderData;
|
|
634
658
|
componentProps?: any;
|
package/dist/index.esm.js
CHANGED
|
@@ -1419,19 +1419,11 @@ function plasmicPrepass(element) {
|
|
|
1419
1419
|
// src/render.tsx
|
|
1420
1420
|
import { extractPlasmicQueryData as extractPlasmicQueryData2 } from "@plasmicapp/prepass";
|
|
1421
1421
|
import React6 from "react";
|
|
1422
|
-
import
|
|
1423
|
-
import
|
|
1424
|
-
function renderToElement(_0, _1, _2) {
|
|
1425
|
-
return __async(this, arguments, function* (loader, target, lookup, opts = {}) {
|
|
1426
|
-
return new Promise((resolve) => {
|
|
1427
|
-
const element = makeElement(loader, lookup, opts);
|
|
1428
|
-
ReactDOM2.render(element, target, () => resolve());
|
|
1429
|
-
});
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1422
|
+
import ReactDOMClient from "react-dom/client";
|
|
1423
|
+
import ReactDOMServer from "react-dom/server";
|
|
1432
1424
|
function renderToString(loader, lookup, opts = {}) {
|
|
1433
1425
|
const element = makeElement(loader, lookup, opts);
|
|
1434
|
-
return
|
|
1426
|
+
return ReactDOMServer.renderToString(element);
|
|
1435
1427
|
}
|
|
1436
1428
|
function extractPlasmicQueryDataFromElement(_0, _1) {
|
|
1437
1429
|
return __async(this, arguments, function* (loader, lookup, opts = {}) {
|
|
@@ -1439,13 +1431,15 @@ function extractPlasmicQueryDataFromElement(_0, _1) {
|
|
|
1439
1431
|
return extractPlasmicQueryData2(element);
|
|
1440
1432
|
});
|
|
1441
1433
|
}
|
|
1442
|
-
function
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1434
|
+
function renderToElement(loader, target, lookup, opts = {}) {
|
|
1435
|
+
const element = makeElement(loader, lookup, opts);
|
|
1436
|
+
const root = ReactDOMClient.createRoot(target);
|
|
1437
|
+
root.render(element);
|
|
1438
|
+
return root;
|
|
1439
|
+
}
|
|
1440
|
+
function hydrateFromElement(loader, target, lookup, opts = {}) {
|
|
1441
|
+
const element = makeElement(loader, lookup, opts);
|
|
1442
|
+
return ReactDOMClient.hydrateRoot(target, element);
|
|
1449
1443
|
}
|
|
1450
1444
|
function makeElement(loader, lookup, opts = {}) {
|
|
1451
1445
|
return /* @__PURE__ */ React6.createElement(
|