@plurid/plurid-react 0.0.0-27 → 0.0.0-28

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.
@@ -308,6 +308,8 @@ const getSpace = state => state.space;
308
308
 
309
309
  const getLoading = state => state.space.loading;
310
310
 
311
+ const getResolvedLayout = state => state.space.resolvedLayout;
312
+
311
313
  const getTransformMatrix = state => state.space.transform;
312
314
 
313
315
  const getAnimatedTransform = state => state.space.animatedTransform;
@@ -355,6 +357,7 @@ var selectors$3 = Object.freeze({
355
357
  __proto__: null,
356
358
  getSpace: getSpace,
357
359
  getLoading: getLoading,
360
+ getResolvedLayout: getResolvedLayout,
358
361
  getTransformMatrix: getTransformMatrix,
359
362
  getAnimatedTransform: getAnimatedTransform,
360
363
  getTransformTime: getTransformTime,
@@ -379,6 +382,7 @@ const {toRadians: toRadians} = pluridFunctions.mathematics.geometry;
379
382
 
380
383
  const initialState$2 = {
381
384
  loading: true,
385
+ resolvedLayout: false,
382
386
  transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
383
387
  animatedTransform: false,
384
388
  transformTime: 450,
@@ -753,20 +757,6 @@ const store = store$1;
753
757
 
754
758
  const StateContext = React__default["default"].createContext({});
755
759
 
756
- const loadStateFromContext = (context, space) => {
757
- if (!context) {
758
- return;
759
- }
760
- if (!space) {
761
- if (typeof window === "undefined") {
762
- return;
763
- }
764
- const defaultContext = context.states[window.location.pathname];
765
- return defaultContext;
766
- }
767
- return context.states[space];
768
- };
769
-
770
760
  function __awaiter(thisArg, _arguments, P, generator) {
771
761
  function adopt(value) {
772
762
  return value instanceof P ? value : new P((function(resolve) {
@@ -816,17 +806,8 @@ const {getTransformRotate: getTransformRotate, getTransformTranslate: getTransfo
816
806
 
817
807
  const {rotateMatrix: rotateMatrix$1, translateMatrix: translateMatrixArray, scaleMatrix: scaleMatrix$1, multiplyArrayOfMatrices: multiplyArrayOfMatrices$1} = matrix;
818
808
 
819
- const computeApplication = (planes, configuration, view) => {
809
+ const computeApplication = (planes, configuration, view, origin = "origin") => {
820
810
  const appConfiguration = pluridEngine.general.configuration.merge(configuration);
821
- if (planes) {
822
- for (const plane of planes) {
823
- const planeData = resolvePluridPlaneData(plane);
824
- const linkPath = pluridEngine.routing.resolveRoute(planeData.route);
825
- if (!linkPath) {
826
- continue;
827
- }
828
- }
829
- }
830
811
  const currentView = view || [];
831
812
  const absoluteView = [];
832
813
  for (const viewItem of currentView) {
@@ -838,7 +819,6 @@ const computeApplication = (planes, configuration, view) => {
838
819
  absoluteView.push(viewPath.route);
839
820
  }
840
821
  }
841
- const origin = "localhost:63000";
842
822
  const registrar = new PluridPlanesRegistrar(planes, origin);
843
823
  const registrarPlanes = registrar.getAll();
844
824
  const spaceTree = new pluridEngine.space.tree.Tree({
@@ -1092,8 +1072,6 @@ const closeActivePlane = (state, pubsub) => {
1092
1072
  });
1093
1073
  };
1094
1074
 
1095
- const {direction: directionLogic} = pluridEngine.interaction;
1096
-
1097
1075
  const handleGlobalShortcuts = (dispatch, state, pubsub, event, firstPerson, locks) => {
1098
1076
  if (event.defaultPrevented) {
1099
1077
  return;
@@ -1287,7 +1265,7 @@ const handleGlobalWheel = (dispatch, event, modes, locks) => {
1287
1265
  deltaY: event.deltaY
1288
1266
  };
1289
1267
  const absoluteThreshold = 100;
1290
- const direction = directionLogic.getWheelDirection(deltas, absoluteThreshold);
1268
+ const direction = pluridEngine.interaction.direction.getWheelDirection(deltas, absoluteThreshold);
1291
1269
  if (modes.rotation) {
1292
1270
  if (direction === pluridData.directions.left && locks.rotationY) {
1293
1271
  return dispatch(actions.space.rotateLeft());
@@ -2151,24 +2129,13 @@ const ConnectedPluridRoots = reactRedux.connect(mapStateToProperties$g, mapDispa
2151
2129
  context: StateContext
2152
2130
  })(PluridRoots);
2153
2131
 
2154
- const fadeIn = styled.keyframes`
2155
- from {
2156
- opacity: 0%;
2157
- }
2158
-
2159
- to {
2160
- opacity: 100%;
2161
- }
2162
- `;
2163
-
2164
- const fadeInAnimation = fadeInTime => styled.css`${fadeIn} ${fadeInTime}ms linear 100ms forwards`;
2165
-
2166
2132
  const StyledPluridSpace = styled__default["default"].div`
2167
2133
  position: relative;
2168
2134
  height: 100%;
2169
2135
  overflow: hidden;
2170
2136
  perspective: 2000px;
2171
2137
  outline: none;
2138
+ transition: opacity ${({fadeInTime: fadeInTime}) => fadeInTime}ms linear;
2172
2139
 
2173
2140
  background: ${({opaque: opaque, theme: theme}) => {
2174
2141
  if (opaque) {
@@ -2178,24 +2145,10 @@ const StyledPluridSpace = styled__default["default"].div`
2178
2145
  }
2179
2146
  return "transparent";
2180
2147
  }};
2181
-
2182
- /* TOFIX */
2183
- /* opacity: ${({fadeInTime: fadeInTime}) => {
2184
- if (fadeInTime) {
2185
- return "0";
2186
- }
2187
- return "1";
2188
- }};
2189
- animation: ${({isMounted: isMounted, fadeInTime: fadeInTime}) => {
2190
- if (isMounted && fadeInTime) {
2191
- return fadeInAnimation(fadeInTime);
2192
- }
2193
- return "";
2194
- }}; */
2195
2148
  `;
2196
2149
 
2197
2150
  const PluridSpace = properties => {
2198
- const {stateConfiguration: stateConfiguration, stateGeneralTheme: stateGeneralTheme} = properties;
2151
+ const {stateConfiguration: stateConfiguration, stateGeneralTheme: stateGeneralTheme, stateResolvedLayout: stateResolvedLayout} = properties;
2199
2152
  const {space: space} = stateConfiguration;
2200
2153
  const {opaque: opaque, fadeInTime: fadeInTime} = space;
2201
2154
  const [isMounted, setIsMounted] = React.useState(false);
@@ -2207,13 +2160,17 @@ const PluridSpace = properties => {
2207
2160
  opaque: opaque,
2208
2161
  isMounted: isMounted,
2209
2162
  fadeInTime: fadeInTime,
2210
- "data-plurid-entity": pluridData.PLURID_ENTITY_SPACE
2163
+ "data-plurid-entity": pluridData.PLURID_ENTITY_SPACE,
2164
+ style: {
2165
+ opacity: stateResolvedLayout ? 1 : 0
2166
+ }
2211
2167
  }, React__default["default"].createElement(ConnectedPluridRoots, null));
2212
2168
  };
2213
2169
 
2214
2170
  const mapStateToProperties$f = state => ({
2215
2171
  stateConfiguration: selectors.configuration.getConfiguration(state),
2216
- stateGeneralTheme: selectors.themes.getGeneralTheme(state)
2172
+ stateGeneralTheme: selectors.themes.getGeneralTheme(state),
2173
+ stateResolvedLayout: selectors.space.getResolvedLayout(state)
2217
2174
  });
2218
2175
 
2219
2176
  const mapDispatchToProperties$f = dispatch => ({});
@@ -2281,6 +2238,18 @@ const ConnectedOrigin = reactRedux.connect(mapStateToProperties$e, mapDispatchTo
2281
2238
  context: StateContext
2282
2239
  })(Origin);
2283
2240
 
2241
+ const fadeIn = styled.keyframes`
2242
+ from {
2243
+ opacity: 0%;
2244
+ }
2245
+
2246
+ to {
2247
+ opacity: 100%;
2248
+ }
2249
+ `;
2250
+
2251
+ const fadeInAnimation = fadeInTime => styled.css`${fadeIn} ${fadeInTime}ms linear 100ms forwards`;
2252
+
2284
2253
  var MENUS;
2285
2254
 
2286
2255
  (function(MENUS) {
@@ -4357,7 +4326,7 @@ const ConnectedPluridViewcube = reactRedux.connect(mapStateToProperties$8, mapDi
4357
4326
  const PluridViewContainer = _properties => React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(ConnectedPluridSpace, null), React__default["default"].createElement(ConnectedOrigin, null), React__default["default"].createElement(ConnectedPluridToolbar, null), React__default["default"].createElement(ConnectedPluridViewcube, null));
4358
4327
 
4359
4328
  const PluridView = properties => {
4360
- const {planesRegistrar: planesRegistrar, customPlane: customPlane, planeContext: planeContext, planeContextValue: planeContextValue, pubsub: pubsub, planeNotFound: planeNotFound, planeRenderError: planeRenderError, matchedRoute: matchedRoute, hostname: hostname, state: state, stateConfiguration: stateConfiguration, stateTransform: stateTransform, stateSpaceView: stateSpaceView, stateTree: stateTree, stateGeneralTheme: stateGeneralTheme, dispatch: dispatch, dispatchSetConfiguration: dispatchSetConfiguration, dispatchSetGeneralTheme: dispatchSetGeneralTheme, dispatchSetInteractionTheme: dispatchSetInteractionTheme, dispatchSetSpaceField: dispatchSetSpaceField, dispatchSetSpaceLocation: dispatchSetSpaceLocation, dispatchSetAnimatedTransform: dispatchSetAnimatedTransform, dispatchSetTransformTime: dispatchSetTransformTime, dispatchSetTree: dispatchSetTree, dispatchRotateXWith: dispatchRotateXWith, dispatchRotateX: dispatchRotateX, dispatchRotateYWith: dispatchRotateYWith, dispatchRotateY: dispatchRotateY, dispatchTranslateXWith: dispatchTranslateXWith, dispatchTranslateYWith: dispatchTranslateYWith, dispatchTranslateZWith: dispatchTranslateZWith, dispatchScaleUpWith: dispatchScaleUpWith, dispatchScaleDownWith: dispatchScaleDownWith, dispatchSpaceSetViewSize: dispatchSpaceSetViewSize, dispatchSpaceSetView: dispatchSpaceSetView} = properties;
4329
+ const {planesRegistrar: planesRegistrar, customPlane: customPlane, planeContext: planeContext, planeContextValue: planeContextValue, pubsub: pubsub, planeNotFound: planeNotFound, planeRenderError: planeRenderError, matchedRoute: matchedRoute, hostname: hostname, state: state, stateConfiguration: stateConfiguration, stateResolvedLayout: stateResolvedLayout, stateTransform: stateTransform, stateSpaceView: stateSpaceView, stateTree: stateTree, stateGeneralTheme: stateGeneralTheme, dispatch: dispatch, dispatchSetConfiguration: dispatchSetConfiguration, dispatchSetGeneralTheme: dispatchSetGeneralTheme, dispatchSetInteractionTheme: dispatchSetInteractionTheme, dispatchSetSpaceField: dispatchSetSpaceField, dispatchSetSpaceLocation: dispatchSetSpaceLocation, dispatchSetAnimatedTransform: dispatchSetAnimatedTransform, dispatchSetTransformTime: dispatchSetTransformTime, dispatchSetTree: dispatchSetTree, dispatchRotateXWith: dispatchRotateXWith, dispatchRotateX: dispatchRotateX, dispatchRotateYWith: dispatchRotateYWith, dispatchRotateY: dispatchRotateY, dispatchTranslateXWith: dispatchTranslateXWith, dispatchTranslateYWith: dispatchTranslateYWith, dispatchTranslateZWith: dispatchTranslateZWith, dispatchScaleUpWith: dispatchScaleUpWith, dispatchScaleDownWith: dispatchScaleDownWith, dispatchSpaceSetViewSize: dispatchSpaceSetViewSize, dispatchSpaceSetView: dispatchSpaceSetView} = properties;
4361
4330
  const viewElement = React.useRef(null);
4362
4331
  const scrollTimeout = React.useRef();
4363
4332
  const [pluridPubSub, setPluridPubSub] = React.useState(pubsub ? [ pubsub ] : [ new PluridPubSub__default["default"] ]);
@@ -4371,6 +4340,10 @@ const PluridView = properties => {
4371
4340
  setPreventOverscroll(false);
4372
4341
  }), pluridData.PLURID_DEFAULT_PREVENT_OVERSCROLL_TIMEOUT);
4373
4342
  };
4343
+ const resolveLayout = () => {
4344
+ const layout = true;
4345
+ treeUpdate(stateSpaceView, stateConfiguration, layout);
4346
+ };
4374
4347
  const shortcutsCallback = React.useCallback((event => {
4375
4348
  const {transformLocks: transformLocks} = stateConfiguration.space;
4376
4349
  handleGlobalShortcuts(dispatch, state, pluridPubSub[0], event, stateConfiguration.space.firstPerson, transformLocks);
@@ -4385,12 +4358,13 @@ const PluridView = properties => {
4385
4358
  };
4386
4359
  handleGlobalWheel(dispatch, event, transformModes, transformLocks);
4387
4360
  }), [ dispatch, stateConfiguration.space.transformMode, stateConfiguration.space.transformLocks ]);
4388
- const treeUpdate = (view, configuration = stateConfiguration) => {
4361
+ const treeUpdate = (view, configuration = stateConfiguration, layout) => {
4389
4362
  const planes = getRegisteredPlanes(planesRegistrar);
4390
4363
  const spaceTree = new pluridEngine.space.tree.Tree({
4391
4364
  planes: planes,
4392
4365
  configuration: configuration,
4393
- view: view
4366
+ view: view,
4367
+ layout: layout
4394
4368
  }, hostname);
4395
4369
  const computedTree = spaceTree.compute();
4396
4370
  for (const statePlane of stateTree) {
@@ -4406,7 +4380,7 @@ const PluridView = properties => {
4406
4380
  dispatchSetTree(computedTree);
4407
4381
  };
4408
4382
  const treeUpdateCallback = React.useCallback((() => {
4409
- treeUpdate(stateSpaceView);
4383
+ treeUpdate(stateSpaceView, stateConfiguration);
4410
4384
  }), [ hostname, stateSpaceView, stateConfiguration, JSON.stringify(stateTree) ]);
4411
4385
  const handlePubSubSubscribe = pubsub => {
4412
4386
  const subscriptions = [ {
@@ -4907,6 +4881,15 @@ const PluridView = properties => {
4907
4881
  React.useEffect((() => {
4908
4882
  treeUpdateCallback();
4909
4883
  }), []);
4884
+ React.useEffect((() => {
4885
+ if (!stateResolvedLayout) {
4886
+ resolveLayout();
4887
+ dispatchSetSpaceField({
4888
+ field: "resolvedLayout",
4889
+ value: true
4890
+ });
4891
+ }
4892
+ }), [ stateResolvedLayout ]);
4910
4893
  const pluridContext = {
4911
4894
  planesRegistrar: planesRegistrar,
4912
4895
  planeContext: planeContext,
@@ -4936,6 +4919,7 @@ const mapStateToProperties$7 = state => ({
4936
4919
  state: state,
4937
4920
  stateConfiguration: selectors.configuration.getConfiguration(state),
4938
4921
  stateTransform: selectors.space.getTransform(state),
4922
+ stateResolvedLayout: selectors.space.getResolvedLayout(state),
4939
4923
  stateTree: selectors.space.getTree(state),
4940
4924
  stateSpaceLoading: selectors.space.getLoading(state),
4941
4925
  stateSpaceView: selectors.space.getView(state),
@@ -4976,8 +4960,8 @@ class PluridApplication extends React.Component {
4976
4960
  super(properties);
4977
4961
  this.storeID = properties.id || "default";
4978
4962
  this.context = context;
4979
- const defaultStore = this.computeStore();
4980
- this.store = store(defaultStore);
4963
+ this.prepare();
4964
+ this.store = store(this.computeStore());
4981
4965
  this.subscribeStore();
4982
4966
  }
4983
4967
  componentDidUpdate() {
@@ -4996,15 +4980,20 @@ class PluridApplication extends React.Component {
4996
4980
  return React__default["default"].createElement(reactRedux.Provider, {
4997
4981
  store: this.store,
4998
4982
  context: StateContext
4999
- }, React__default["default"].createElement(ConnectedPluridView, Object.assign({}, this.props)));
4983
+ }, React__default["default"].createElement(ConnectedPluridView, Object.assign({}, this.props, {
4984
+ planesRegistrar: this.planesRegistrar
4985
+ })));
4986
+ }
4987
+ prepare() {
4988
+ this.planesRegistrar = typeof window === "undefined" && !this.props.planesRegistrar ? new PluridPlanesRegistrar(this.props.planes, this.props.hostname) : this.props.planesRegistrar;
5000
4989
  }
5001
4990
  computeStore() {
5002
- const {view: view, planes: planes, configuration: configuration, precomputedState: precomputedState, planesRegistrar: planesRegistrar, useLocalStorage: useLocalStorage, hostname: hostname, space: space} = this.props;
5003
- registerPlanes(planes, planesRegistrar, hostname);
4991
+ const {view: view, planes: planes, configuration: configuration, precomputedState: precomputedState, useLocalStorage: useLocalStorage, hostname: hostname, space: space} = this.props;
4992
+ registerPlanes(planes, this.planesRegistrar, hostname);
5004
4993
  const currentState = this.store ? this.store.getState() : undefined;
5005
4994
  const localState = pluridEngine.state.local.load(this.storeID, useLocalStorage);
5006
- const contextState = loadStateFromContext(this.context, space);
5007
- const store = pluridEngine.state.compute(view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname);
4995
+ const contextState = undefined;
4996
+ const store = pluridEngine.state.compute(view, configuration, this.planesRegistrar, currentState, localState, precomputedState, contextState, hostname);
5008
4997
  return store;
5009
4998
  }
5010
4999
  subscribeStore() {
@@ -6393,14 +6382,13 @@ const ConnectedPluridSpaceDebugger = reactRedux.connect(mapStateToProperties, ma
6393
6382
  context: StateContext
6394
6383
  })(PluridSpaceDebugger);
6395
6384
 
6396
- const serverComputeMetastate = (isoMatch, paths, globals) => __awaiter(void 0, void 0, void 0, (function*() {
6385
+ const serverComputeMetastate = (isoMatch, paths, globals, hostname = "origin") => __awaiter(void 0, void 0, void 0, (function*() {
6397
6386
  const protocol = "http";
6398
- const host = "localhost:63000";
6399
- const pluridApplications = yield collectApplicationsFromPath(isoMatch, protocol, host, globals);
6387
+ const pluridApplications = yield collectApplicationsFromPath(isoMatch, protocol, hostname, globals);
6400
6388
  const states = {};
6401
6389
  for (const application of pluridApplications) {
6402
6390
  const {planes: planes, view: view, configuration: configuration} = application;
6403
- const {computedTree: computedTree, appConfiguration: appConfiguration} = computeApplication(planes, isoMatch.data.defaultConfiguration, view);
6391
+ const {computedTree: computedTree, appConfiguration: appConfiguration} = computeApplication(planes, isoMatch.data.defaultConfiguration, view, hostname);
6404
6392
  const state = {
6405
6393
  configuration: Object.assign({}, appConfiguration),
6406
6394
  shortcuts: {
@@ -6415,6 +6403,7 @@ const serverComputeMetastate = (isoMatch, paths, globals) => __awaiter(void 0, v
6415
6403
  },
6416
6404
  space: {
6417
6405
  loading: false,
6406
+ resolvedLayout: false,
6418
6407
  animatedTransform: false,
6419
6408
  transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
6420
6409
  scale: 1,