@lvce-editor/main-area-worker 9.58.0 → 9.59.0

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.
@@ -1839,8 +1839,39 @@ const wrapSerialCommand = fn => {
1839
1839
  return registry.wrapSerialCommand(withActiveEditorChange(fn));
1840
1840
  };
1841
1841
 
1842
+ const state$1 = {
1843
+ configured: false,
1844
+ lastId: -1,
1845
+ nextId: 0
1846
+ };
1847
+ const configure = (start, end) => {
1848
+ const {
1849
+ configured
1850
+ } = state$1;
1851
+ if (configured) {
1852
+ throw new Error('Component id range is already configured');
1853
+ }
1854
+ if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
1855
+ throw new Error('Invalid component id range');
1856
+ }
1857
+ state$1.nextId = start;
1858
+ state$1.lastId = end;
1859
+ state$1.configured = true;
1860
+ };
1842
1861
  const create$2 = () => {
1843
- return Math.random();
1862
+ const {
1863
+ configured,
1864
+ lastId,
1865
+ nextId
1866
+ } = state$1;
1867
+ if (!configured) {
1868
+ // Compatibility with renderer versions that do not assign worker id ranges.
1869
+ return Math.random();
1870
+ }
1871
+ if (nextId > lastId) {
1872
+ throw new Error('Component id range exhausted');
1873
+ }
1874
+ return state$1.nextId++;
1844
1875
  };
1845
1876
 
1846
1877
  const updateTab = (state, tabId, updates) => {
@@ -8827,6 +8858,7 @@ const resize = async (uid, dimensions) => {
8827
8858
  const handleDirectMessagePort = (port, setAsRendererProcessFallback = true) => handleMessagePort(port, commandMap, setAsRendererProcessFallback);
8828
8859
  const handleTestWorkerMessagePort = port => handleMessagePort(port, commandMap, false);
8829
8860
  const commandMap = {
8861
+ 'Id.configure': configure,
8830
8862
  'Main.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
8831
8863
  'Main.closeAll': wrapSerialCommand(closeAll$1),
8832
8864
  'Main.closeAllEditors': wrapSerialCommand(closeAll$1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.58.0",
3
+ "version": "9.59.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",