@plasmicapp/loader-react 1.0.77 → 1.0.82
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 +1 -1
- package/dist/loader-react.cjs.development.js +40 -30
- package/dist/loader-react.cjs.development.js.map +1 -1
- package/dist/loader-react.cjs.production.min.js +1 -1
- package/dist/loader-react.cjs.production.min.js.map +1 -1
- package/dist/loader-react.esm.js +35 -31
- package/dist/loader-react.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PlasmicCanvasContext, PlasmicCanvasHost, PrimitiveType, PropType, repeatedElement, } from '@plasmicapp/host';
|
|
1
|
+
export { PlasmicCanvasContext, PlasmicCanvasHost, PrimitiveType, PropType, repeatedElement, usePlasmicCanvasContext, } from '@plasmicapp/host';
|
|
2
2
|
export { ComponentMeta, PageMeta, PageMetadata } from '@plasmicapp/loader-core';
|
|
3
3
|
export { usePlasmicQueryData } from '@plasmicapp/query';
|
|
4
4
|
export { convertBundlesToComponentRenderData } from './bundles';
|
|
@@ -2140,44 +2140,48 @@ function PlasmicComponent(props) {
|
|
|
2140
2140
|
throw new Error("You must use <PlasmicRootProvider/> at the root of your app");
|
|
2141
2141
|
}
|
|
2142
2142
|
|
|
2143
|
-
var
|
|
2143
|
+
var loader = rootContext.loader,
|
|
2144
|
+
globalContextsProps = rootContext.globalContextsProps;
|
|
2144
2145
|
var Component = usePlasmicComponent({
|
|
2145
2146
|
name: component,
|
|
2146
2147
|
projectId: projectId
|
|
2147
2148
|
}, {
|
|
2148
2149
|
forceOriginal: forceOriginal
|
|
2149
2150
|
});
|
|
2151
|
+
var element = React.useMemo(function () {
|
|
2152
|
+
if (!Component) {
|
|
2153
|
+
return null;
|
|
2154
|
+
}
|
|
2150
2155
|
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
value: true
|
|
2178
|
-
}, element)));
|
|
2179
|
-
}
|
|
2156
|
+
var element = React.createElement(Component, Object.assign({}, componentProps));
|
|
2157
|
+
|
|
2158
|
+
if (isRootLoader) {
|
|
2159
|
+
// If this is the root PlasmicComponent, then wrap the content with the
|
|
2160
|
+
// react-web's PlasmicRootProvider. We are doing this here, instead of
|
|
2161
|
+
// say PlasmicRootProvider, because we don't have access to this context
|
|
2162
|
+
// provider until data has been loaded. If we insert this provider into
|
|
2163
|
+
// the tree at the root after data is loaded, then we'll invalidate the
|
|
2164
|
+
// React tree and tree state, which is bad. Instead, we do it at the
|
|
2165
|
+
// "root-most PlasmicComponent"; we won't risk invalidating the sub-tree
|
|
2166
|
+
// here because there were no children before the data came in.
|
|
2167
|
+
var lookup = loader.getLookup();
|
|
2168
|
+
var ReactWebRootProvider = lookup.getRootProvider();
|
|
2169
|
+
var GlobalContextsProvider = lookup.getGlobalContextsProvider({
|
|
2170
|
+
name: component,
|
|
2171
|
+
projectId: projectId
|
|
2172
|
+
});
|
|
2173
|
+
element = React.createElement(ReactWebRootProvider, null, React.createElement(MaybeWrap, {
|
|
2174
|
+
cond: !!GlobalContextsProvider,
|
|
2175
|
+
wrapper: function wrapper(children) {
|
|
2176
|
+
return React.createElement(GlobalContextsProvider, Object.assign({}, globalContextsProps), children);
|
|
2177
|
+
}
|
|
2178
|
+
}, React.createElement(PlasmicComponentContext.Provider, {
|
|
2179
|
+
value: true
|
|
2180
|
+
}, element)));
|
|
2181
|
+
}
|
|
2180
2182
|
|
|
2183
|
+
return element;
|
|
2184
|
+
}, [Component, componentProps, loader, isRootLoader, component, projectId, globalContextsProps]);
|
|
2181
2185
|
return element;
|
|
2182
2186
|
}
|
|
2183
2187
|
|
|
@@ -2481,6 +2485,12 @@ Object.defineProperty(exports, 'repeatedElement', {
|
|
|
2481
2485
|
return host.repeatedElement;
|
|
2482
2486
|
}
|
|
2483
2487
|
});
|
|
2488
|
+
Object.defineProperty(exports, 'usePlasmicCanvasContext', {
|
|
2489
|
+
enumerable: true,
|
|
2490
|
+
get: function () {
|
|
2491
|
+
return host.usePlasmicCanvasContext;
|
|
2492
|
+
}
|
|
2493
|
+
});
|
|
2484
2494
|
Object.defineProperty(exports, 'usePlasmicQueryData', {
|
|
2485
2495
|
enumerable: true,
|
|
2486
2496
|
get: function () {
|