@arpproject/recrate 0.1.19 → 0.1.21

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.
@@ -1,8 +1,12 @@
1
+ import { default as React, ReactNode } from 'react';
1
2
  import { EditorState } from './editor-state';
2
3
  interface Store {
3
4
  configuration: Record<string, any>;
4
5
  editorState: EditorState;
5
6
  setConfiguration: (config: Record<string, any>) => void;
6
7
  }
7
- export declare const useStateStore: import('zustand').UseBoundStore<import('zustand').StoreApi<Store>>;
8
+ export declare const StateStoreProvider: ({ children }: {
9
+ children: ReactNode;
10
+ }) => React.FunctionComponentElement<React.ProviderProps<import('zustand').StoreApi<Store> | null>>;
11
+ export declare const useStateStore: () => Store;
8
12
  export {};
@@ -58701,7 +58701,7 @@ function requireLodash() {
58701
58701
  copyObject(source, keys2(source), object4, customizer);
58702
58702
  });
58703
58703
  var at = flatRest(baseAt);
58704
- function create2(prototype, properties) {
58704
+ function create(prototype, properties) {
58705
58705
  var result2 = baseCreate(prototype);
58706
58706
  return properties == null ? result2 : baseAssign(result2, properties);
58707
58707
  }
@@ -59448,7 +59448,7 @@ function requireLodash() {
59448
59448
  lodash2.conforms = conforms;
59449
59449
  lodash2.constant = constant;
59450
59450
  lodash2.countBy = countBy;
59451
- lodash2.create = create2;
59451
+ lodash2.create = create;
59452
59452
  lodash2.curry = curry;
59453
59453
  lodash2.curryRight = curryRight;
59454
59454
  lodash2.debounce = debounce2;
@@ -67349,13 +67349,6 @@ function useStore(api2, selector = identity) {
67349
67349
  React__default.useDebugValue(slice2);
67350
67350
  return slice2;
67351
67351
  }
67352
- const createImpl = (createState) => {
67353
- const api2 = createStore(createState);
67354
- const useBoundStore = (selector) => useStore(api2, selector);
67355
- Object.assign(useBoundStore, api2);
67356
- return useBoundStore;
67357
- };
67358
- const create = ((createState) => createState ? createImpl(createState) : createImpl);
67359
67352
  let EditorState$1 = class EditorState {
67360
67353
  constructor() {
67361
67354
  this.history = [];
@@ -67451,11 +67444,28 @@ let EditorState$1 = class EditorState {
67451
67444
  });
67452
67445
  }
67453
67446
  };
67454
- const useStateStore = create((set2) => ({
67447
+ const createStateStore = () => createStore((set2) => ({
67455
67448
  configuration: {},
67456
67449
  editorState: new EditorState$1(),
67457
67450
  setConfiguration: (config2) => set2({ configuration: config2 })
67458
67451
  }));
67452
+ const defaultStore = createStateStore();
67453
+ const StateStoreContext = createContext(null);
67454
+ const StateStoreProvider = ({ children }) => {
67455
+ const storeRef = useRef(null);
67456
+ if (!storeRef.current) {
67457
+ storeRef.current = createStateStore();
67458
+ }
67459
+ return React__default.createElement(
67460
+ StateStoreContext.Provider,
67461
+ { value: storeRef.current },
67462
+ children
67463
+ );
67464
+ };
67465
+ const useStateStore = () => {
67466
+ const scopedStore = useContext(StateStoreContext);
67467
+ return useStore(scopedStore ?? defaultStore);
67468
+ };
67459
67469
  const EntityId = ({ entity, onUpdate }) => {
67460
67470
  var _a2;
67461
67471
  const state = useStateStore();
@@ -77010,12 +77020,12 @@ function requireLeafletSrc() {
77010
77020
  toBack(layer2._container);
77011
77021
  }
77012
77022
  };
77013
- var create2 = Browser.vml ? vmlCreate : svgCreate;
77023
+ var create = Browser.vml ? vmlCreate : svgCreate;
77014
77024
  var SVG = Renderer.extend({
77015
77025
  _initContainer: function() {
77016
- this._container = create2("svg");
77026
+ this._container = create("svg");
77017
77027
  this._container.setAttribute("pointer-events", "none");
77018
- this._rootGroup = create2("g");
77028
+ this._rootGroup = create("g");
77019
77029
  this._container.appendChild(this._rootGroup);
77020
77030
  },
77021
77031
  _destroyContainer: function() {
@@ -77042,7 +77052,7 @@ function requireLeafletSrc() {
77042
77052
  },
77043
77053
  // methods below are called by vector layers implementations
77044
77054
  _initPath: function(layer2) {
77045
- var path2 = layer2._path = create2("path");
77055
+ var path2 = layer2._path = create("path");
77046
77056
  if (layer2.options.className) {
77047
77057
  addClass(path2, layer2.options.className);
77048
77058
  }
@@ -77177,7 +77187,7 @@ function requireLeafletSrc() {
77177
77187
  function rectangle(latLngBounds, options) {
77178
77188
  return new Rectangle(latLngBounds, options);
77179
77189
  }
77180
- SVG.create = create2;
77190
+ SVG.create = create;
77181
77191
  SVG.pointsToPath = pointsToPath;
77182
77192
  GeoJSON.geometryToLayer = geometryToLayer;
77183
77193
  GeoJSON.coordsToLatLng = coordsToLatLng;
@@ -83349,8 +83359,8 @@ class StateField {
83349
83359
  way it is initialized. Can be useful when you need to provide a
83350
83360
  non-default starting value for the field.
83351
83361
  */
83352
- init(create2) {
83353
- return [this, initField.of({ field: this, create: create2 })];
83362
+ init(create) {
83363
+ return [this, initField.of({ field: this, create })];
83354
83364
  }
83355
83365
  /**
83356
83366
  State field instances can be used as
@@ -87550,9 +87560,9 @@ const viewPlugin = /* @__PURE__ */ Facet.define({
87550
87560
  }
87551
87561
  });
87552
87562
  class ViewPlugin {
87553
- constructor(id2, create2, domEventHandlers, domEventObservers, buildExtensions) {
87563
+ constructor(id2, create, domEventHandlers, domEventObservers, buildExtensions) {
87554
87564
  this.id = id2;
87555
- this.create = create2;
87565
+ this.create = create;
87556
87566
  this.domEventHandlers = domEventHandlers;
87557
87567
  this.domEventObservers = domEventObservers;
87558
87568
  this.baseExtensions = buildExtensions(this);
@@ -87568,9 +87578,9 @@ class ViewPlugin {
87568
87578
  Define a plugin from a constructor function that creates the
87569
87579
  plugin's value, given an editor view.
87570
87580
  */
87571
- static define(create2, spec) {
87581
+ static define(create, spec) {
87572
87582
  const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
87573
- return new ViewPlugin(nextPluginID++, create2, eventHandlers, eventObservers, (plugin) => {
87583
+ return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, (plugin) => {
87574
87584
  let ext = [];
87575
87585
  if (deco)
87576
87586
  ext.push(decorations.of((view) => {
@@ -115850,7 +115860,7 @@ var Logger = (function() {
115850
115860
  }
115851
115861
  }, {
115852
115862
  key: "create",
115853
- value: function create2(moduleName) {
115863
+ value: function create(moduleName) {
115854
115864
  return new Logger2(this.logger, _objectSpread$6(_objectSpread$6({}, {
115855
115865
  prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
115856
115866
  }), this.options));
@@ -119535,7 +119545,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
119535
119545
  }) : null
119536
119546
  );
119537
119547
  var CacheProvider = EmotionCacheContext.Provider;
119538
- const version = "0.1.19";
119548
+ const version = "0.1.20";
119539
119549
  const pkg = {
119540
119550
  version
119541
119551
  };
@@ -119544,6 +119554,9 @@ const ProfileManagerContext = React__default.createContext(null);
119544
119554
  const CrateManagerContext = React__default.createContext(null);
119545
119555
  const LookupsContext = React__default.createContext(null);
119546
119556
  function DescriboCrateBuilder(props) {
119557
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(StateStoreProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DescriboCrateBuilderInner, { ...props }) });
119558
+ }
119559
+ function DescriboCrateBuilderInner(props) {
119547
119560
  const {
119548
119561
  crate,
119549
119562
  profile,
@@ -119663,7 +119676,7 @@ function DescriboCrateBuilder(props) {
119663
119676
  setCm(newCm);
119664
119677
  setPm(newPm);
119665
119678
  setError(false);
119666
- state.configuration = configuration;
119679
+ state.setConfiguration(configuration);
119667
119680
  try {
119668
119681
  const graph = Array.isArray(crate == null ? void 0 : crate["@graph"]) ? crate["@graph"] : [];
119669
119682
  const validIds = new Set(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "type": "module",
5
5
  "main": "./dist/recrate.es.js",
6
6
  "module": "./dist/recrate.es.js",