@plasmicapp/loader-react 2.0.0-alpha.0 → 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 +34 -3
- package/dist/index.esm.js +13 -11
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +13 -11
- package/dist/index.js.map +3 -3
- package/dist/react-server.d.ts +0 -2
- package/dist/react-server.esm.js +1 -2
- package/dist/react-server.esm.js.map +2 -2
- package/dist/react-server.js +1 -2
- package/dist/react-server.js.map +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -36,9 +36,9 @@ 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
|
-
import { registerFunction } from '@plasmicapp/host';
|
|
42
42
|
import { Registry } from '@plasmicapp/loader-core';
|
|
43
43
|
import { repeatedElement } from '@plasmicapp/host';
|
|
44
44
|
import { Split } from '@plasmicapp/loader-fetcher';
|
|
@@ -122,7 +122,6 @@ declare interface BuiltinRegisteredModules {
|
|
|
122
122
|
"@plasmicapp/query": plasmicappQuery;
|
|
123
123
|
"@plasmicapp/data-sources-context": plasmicappDataSourcesContext;
|
|
124
124
|
"@plasmicapp/host": plasmicappHost;
|
|
125
|
-
"@plasmicapp/host/registerFunction": registerFunction;
|
|
126
125
|
"@plasmicapp/loader-runtime-registry": {
|
|
127
126
|
components: Record<string, React.ComponentType<any>>;
|
|
128
127
|
globalVariantHooks: Record<string, () => any>;
|
|
@@ -239,6 +238,11 @@ export { DataProvider }
|
|
|
239
238
|
*/
|
|
240
239
|
export declare function extractPlasmicQueryData(element: React.ReactElement): Promise<Record<string, any>>;
|
|
241
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
|
+
*/
|
|
242
246
|
export declare function extractPlasmicQueryDataFromElement(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
|
|
243
247
|
prefetchedData?: ComponentRenderData;
|
|
244
248
|
componentProps?: any;
|
|
@@ -293,12 +297,18 @@ export declare interface GlobalVariantSpec {
|
|
|
293
297
|
value: any;
|
|
294
298
|
}
|
|
295
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
|
+
*/
|
|
296
306
|
export declare function hydrateFromElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
|
|
297
307
|
prefetchedData?: ComponentRenderData;
|
|
298
308
|
componentProps?: any;
|
|
299
309
|
globalVariants?: GlobalVariantSpec[];
|
|
300
310
|
prefetchedQueryData?: Record<string, any>;
|
|
301
|
-
}):
|
|
311
|
+
}): ReactDOMClient.Root;
|
|
302
312
|
|
|
303
313
|
export declare interface InitOptions {
|
|
304
314
|
projects: {
|
|
@@ -622,6 +632,27 @@ declare interface ReactServerOps {
|
|
|
622
632
|
fetchData: typeof useMutablePlasmicQueryData;
|
|
623
633
|
}
|
|
624
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
|
+
*/
|
|
641
|
+
export declare function renderToElement(loader: PlasmicComponentLoader, target: HTMLElement, lookup: ComponentLookupSpec, opts?: {
|
|
642
|
+
prefetchedData?: ComponentRenderData;
|
|
643
|
+
componentProps?: any;
|
|
644
|
+
globalVariants?: GlobalVariantSpec[];
|
|
645
|
+
prefetchedQueryData?: Record<string, any>;
|
|
646
|
+
pageParams?: Record<string, any>;
|
|
647
|
+
pageQuery?: Record<string, any>;
|
|
648
|
+
}): ReactDOMClient.Root;
|
|
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
|
+
*/
|
|
625
656
|
export declare function renderToString(loader: PlasmicComponentLoader, lookup: ComponentLookupSpec, opts?: {
|
|
626
657
|
prefetchedData?: ComponentRenderData;
|
|
627
658
|
componentProps?: any;
|
package/dist/index.esm.js
CHANGED
|
@@ -1176,7 +1176,6 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
|
|
|
1176
1176
|
"@plasmicapp/query": PlasmicQuery,
|
|
1177
1177
|
"@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
|
|
1178
1178
|
"@plasmicapp/host": PlasmicHost,
|
|
1179
|
-
"@plasmicapp/host/registerFunction": internalSetRegisteredFunction,
|
|
1180
1179
|
"@plasmicapp/loader-runtime-registry": {
|
|
1181
1180
|
components: SUBSTITUTED_COMPONENTS,
|
|
1182
1181
|
globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
|
|
@@ -1420,11 +1419,11 @@ function plasmicPrepass(element) {
|
|
|
1420
1419
|
// src/render.tsx
|
|
1421
1420
|
import { extractPlasmicQueryData as extractPlasmicQueryData2 } from "@plasmicapp/prepass";
|
|
1422
1421
|
import React6 from "react";
|
|
1423
|
-
import
|
|
1424
|
-
import
|
|
1422
|
+
import ReactDOMClient from "react-dom/client";
|
|
1423
|
+
import ReactDOMServer from "react-dom/server";
|
|
1425
1424
|
function renderToString(loader, lookup, opts = {}) {
|
|
1426
1425
|
const element = makeElement(loader, lookup, opts);
|
|
1427
|
-
return
|
|
1426
|
+
return ReactDOMServer.renderToString(element);
|
|
1428
1427
|
}
|
|
1429
1428
|
function extractPlasmicQueryDataFromElement(_0, _1) {
|
|
1430
1429
|
return __async(this, arguments, function* (loader, lookup, opts = {}) {
|
|
@@ -1432,13 +1431,15 @@ function extractPlasmicQueryDataFromElement(_0, _1) {
|
|
|
1432
1431
|
return extractPlasmicQueryData2(element);
|
|
1433
1432
|
});
|
|
1434
1433
|
}
|
|
1435
|
-
function
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
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);
|
|
1442
1443
|
}
|
|
1443
1444
|
function makeElement(loader, lookup, opts = {}) {
|
|
1444
1445
|
return /* @__PURE__ */ React6.createElement(
|
|
@@ -1487,6 +1488,7 @@ export {
|
|
|
1487
1488
|
initPlasmicLoader,
|
|
1488
1489
|
matchesPagePath,
|
|
1489
1490
|
plasmicPrepass,
|
|
1491
|
+
renderToElement,
|
|
1490
1492
|
renderToString,
|
|
1491
1493
|
repeatedElement,
|
|
1492
1494
|
useDataEnv,
|