@lvce-editor/renderer-process 21.7.0 → 21.8.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.
@@ -289,8 +289,10 @@ const Option$1 = 64;
289
289
  const Code$1 = 65;
290
290
  const Label$1 = 66;
291
291
  const Dt$1 = 67;
292
+ const Reference$1 = 100;
292
293
  const VirtualDomElements$1 = {
293
294
  __proto__: null,
295
+ Reference: Reference$1,
294
296
  Text: Text$1};
295
297
  const getElementTag$1 = type => {
296
298
  switch (type) {
@@ -413,6 +415,13 @@ const ElementTagMap = {
413
415
  const {
414
416
  getElementTag
415
417
  } = ElementTagMap;
418
+ const instances = Object.create(null);
419
+ const get$1$1 = viewletId => {
420
+ return instances[viewletId];
421
+ };
422
+ const set$1$1 = (viewletId, instance) => {
423
+ instances[viewletId] = instance;
424
+ };
416
425
  const getEventListenerOptions$1 = (eventName, value) => {
417
426
  if (value.passive) {
418
427
  return {
@@ -468,10 +477,10 @@ const cache$1 = new Map();
468
477
  const has$1 = listener => {
469
478
  return cache$1.has(listener);
470
479
  };
471
- const set$1$1 = (listener, value) => {
480
+ const set$8 = (listener, value) => {
472
481
  cache$1.set(listener, value);
473
482
  };
474
- const get$1$1 = listener => {
483
+ const get$9 = listener => {
475
484
  return cache$1.get(listener);
476
485
  };
477
486
  const nameAnonymousFunction$1 = (fn, name) => {
@@ -495,9 +504,9 @@ const getWrappedListener$1 = (listener, returnValue) => {
495
504
  ipc.send('Viewlet.executeViewletCommand', uid, ...result);
496
505
  };
497
506
  nameAnonymousFunction$1(wrapped, listener.name);
498
- set$1$1(listener, wrapped);
507
+ set$8(listener, wrapped);
499
508
  }
500
- return get$1$1(listener);
509
+ return get$9(listener);
501
510
  };
502
511
  const getOptions = fn => {
503
512
  if (fn.passive) {
@@ -634,7 +643,8 @@ const setProps = ($Element, props, eventMap, newEventMap) => {
634
643
  }
635
644
  };
636
645
  const {
637
- Text: Text$2} = VirtualDomElements$1;
646
+ Text: Text$2,
647
+ Reference} = VirtualDomElements$1;
638
648
  const renderDomTextNode = element => {
639
649
  return document.createTextNode(element.text);
640
650
  };
@@ -644,8 +654,15 @@ const renderDomElement = (element, eventMap, newEventMap) => {
644
654
  setProps($Element, element, eventMap, newEventMap);
645
655
  return $Element;
646
656
  };
657
+ const renderReferenceNode = element => {
658
+ const instance = get$1$1(element.uid);
659
+ const $Node = instance.state.$Viewlet;
660
+ return $Node;
661
+ };
647
662
  const render$1 = (element, eventMap, newEventMap) => {
648
663
  switch (element.type) {
664
+ case Reference:
665
+ return renderReferenceNode(element);
649
666
  case Text$2:
650
667
  return renderDomTextNode(element);
651
668
  default:
@@ -1187,13 +1204,6 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1187
1204
  stopIgnore();
1188
1205
  return $Viewlet;
1189
1206
  };
1190
- const instances = Object.create(null);
1191
- const get$9 = viewletId => {
1192
- return instances[viewletId];
1193
- };
1194
- const set$8 = (viewletId, instance) => {
1195
- instances[viewletId] = instance;
1196
- };
1197
1207
 
1198
1208
  const get$8 = ids => {
1199
1209
  return getFileHandles$1(ids);
@@ -1934,7 +1944,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
1934
1944
  return promise;
1935
1945
  };
1936
1946
  const Message$1 = 3;
1937
- const create$5$1 = async ({
1947
+ const create$5$2 = async ({
1938
1948
  isMessagePortOpen,
1939
1949
  messagePort
1940
1950
  }) => {
@@ -1985,7 +1995,7 @@ const wrap$5 = messagePort => {
1985
1995
  };
1986
1996
  const IpcParentWithMessagePort$1 = {
1987
1997
  __proto__: null,
1988
- create: create$5$1,
1998
+ create: create$5$2,
1989
1999
  signal: signal$1,
1990
2000
  wrap: wrap$5
1991
2001
  };
@@ -2430,14 +2440,14 @@ const execute = (command, ...args) => {
2430
2440
  };
2431
2441
 
2432
2442
  const Two = '2.0';
2433
- const create$s$1 = (method, params) => {
2443
+ const create$t$1 = (method, params) => {
2434
2444
  return {
2435
2445
  jsonrpc: Two,
2436
2446
  method,
2437
2447
  params
2438
2448
  };
2439
2449
  };
2440
- const create$r$1 = (id, method, params) => {
2450
+ const create$s$1 = (id, method, params) => {
2441
2451
  const message = {
2442
2452
  id,
2443
2453
  jsonrpc: Two,
@@ -2447,14 +2457,14 @@ const create$r$1 = (id, method, params) => {
2447
2457
  return message;
2448
2458
  };
2449
2459
  let id = 0;
2450
- const create$q$1 = () => {
2460
+ const create$r$1 = () => {
2451
2461
  return ++id;
2452
2462
  };
2453
2463
 
2454
2464
  /* eslint-disable n/no-unsupported-features/es-syntax */
2455
2465
 
2456
2466
  const registerPromise = map => {
2457
- const id = create$q$1();
2467
+ const id = create$r$1();
2458
2468
  const {
2459
2469
  promise,
2460
2470
  resolve
@@ -2472,7 +2482,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
2472
2482
  id,
2473
2483
  promise
2474
2484
  } = registerPromise(callbacks);
2475
- const message = create$r$1(id, method, params);
2485
+ const message = create$s$1(id, method, params);
2476
2486
  if (useSendAndTransfer && ipc.sendAndTransfer) {
2477
2487
  ipc.sendAndTransfer(message);
2478
2488
  } else {
@@ -2508,7 +2518,7 @@ const createRpc = ipc => {
2508
2518
  * @deprecated
2509
2519
  */
2510
2520
  send(method, ...params) {
2511
- const message = create$s$1(method, params);
2521
+ const message = create$t$1(method, params);
2512
2522
  ipc.send(message);
2513
2523
  }
2514
2524
  };
@@ -2544,7 +2554,7 @@ const unhandleIpc = ipc => {
2544
2554
  ipc.onmessage = null;
2545
2555
  }
2546
2556
  };
2547
- const create$l$1 = async ({
2557
+ const create$m$1 = async ({
2548
2558
  commandMap,
2549
2559
  window
2550
2560
  }) => {
@@ -2557,12 +2567,12 @@ const create$l$1 = async ({
2557
2567
  };
2558
2568
  const ElectronWindowRpcClient = {
2559
2569
  __proto__: null,
2560
- create: create$l$1
2570
+ create: create$m$1
2561
2571
  };
2562
2572
  const isWorker = value => {
2563
2573
  return value instanceof Worker;
2564
2574
  };
2565
- const create$b$1 = async ({
2575
+ const create$c$1 = async ({
2566
2576
  commandMap,
2567
2577
  name,
2568
2578
  url
@@ -2583,9 +2593,9 @@ const create$b$1 = async ({
2583
2593
  };
2584
2594
  const ModuleWorkerRpcParent = {
2585
2595
  __proto__: null,
2586
- create: create$b$1
2596
+ create: create$c$1
2587
2597
  };
2588
- const create$a$1 = async ({
2598
+ const create$b$1 = async ({
2589
2599
  commandMap,
2590
2600
  name,
2591
2601
  port,
@@ -2609,9 +2619,9 @@ const create$a$1 = async ({
2609
2619
  };
2610
2620
  const ModuleWorkerWithMessagePortRpcParent = {
2611
2621
  __proto__: null,
2612
- create: create$a$1
2622
+ create: create$b$1
2613
2623
  };
2614
- const create$4$1 = async ({
2624
+ const create$5$1 = async ({
2615
2625
  commandMap,
2616
2626
  isMessagePortOpen = true,
2617
2627
  messagePort
@@ -2628,18 +2638,18 @@ const create$4$1 = async ({
2628
2638
  messagePort.start();
2629
2639
  return rpc;
2630
2640
  };
2631
- const create$3$1 = async ({
2641
+ const create$4$1 = async ({
2632
2642
  commandMap,
2633
2643
  messagePort
2634
2644
  }) => {
2635
- return create$4$1({
2645
+ return create$5$1({
2636
2646
  commandMap,
2637
2647
  messagePort
2638
2648
  });
2639
2649
  };
2640
2650
  const PlainMessagePortRpcParent = {
2641
2651
  __proto__: null,
2642
- create: create$3$1
2652
+ create: create$4$1
2643
2653
  };
2644
2654
 
2645
2655
  // TODO add test
@@ -7658,13 +7668,6 @@ const ViewletOutput = {
7658
7668
  setText
7659
7669
  };
7660
7670
 
7661
- const state$1 = {
7662
- currentPanelView: undefined,
7663
- currentSideBarView: undefined,
7664
- instances: Object.create(null),
7665
- modules: Object.create(null)
7666
- };
7667
-
7668
7671
  const handleClickClose = event => {
7669
7672
  const uid = fromEvent(event);
7670
7673
  hidePanel(uid);
@@ -7811,8 +7814,7 @@ const setActionsDom$1 = (state, actions, childUid) => {
7811
7814
  const {
7812
7815
  $PanelActions
7813
7816
  } = state;
7814
- const instances = state$1.instances;
7815
- const instance = instances[childUid];
7817
+ const instance = get$1$1(childUid);
7816
7818
  if (!instance) {
7817
7819
  throw new Error(`child instance not found`);
7818
7820
  }
@@ -8926,12 +8928,18 @@ const load$1 = moduleId => {
8926
8928
  }
8927
8929
  };
8928
8930
 
8931
+ const state$1 = {
8932
+ currentPanelView: undefined,
8933
+ currentSideBarView: undefined,
8934
+ modules: Object.create(null)
8935
+ };
8936
+
8929
8937
  const create$3 = (id, uid = id) => {
8930
8938
  const module = state$1.modules[id];
8931
8939
  if (!module) {
8932
8940
  throw new Error(`module not found: ${id}`);
8933
8941
  }
8934
- const existing = get$9(id);
8942
+ const existing = get$1$1(id);
8935
8943
  if (existing?.state.$Viewlet.isConnected) {
8936
8944
  existing.state.$Viewlet.remove();
8937
8945
  }
@@ -8940,7 +8948,7 @@ const create$3 = (id, uid = id) => {
8940
8948
  if (module.attachEvents) {
8941
8949
  module.attachEvents(instanceState);
8942
8950
  }
8943
- set$8(uid, {
8951
+ set$1$1(uid, {
8944
8952
  factory: module,
8945
8953
  state: instanceState
8946
8954
  });
@@ -8953,14 +8961,14 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8953
8961
  if (!module) {
8954
8962
  throw new Error(`module not found: ${id}`);
8955
8963
  }
8956
- const existing = get$9(id);
8964
+ const existing = get$1$1(id);
8957
8965
  if (existing?.state.$Viewlet.isConnected) {
8958
8966
  existing.state.$Viewlet.remove();
8959
8967
  }
8960
8968
  const instanceState = {
8961
8969
  $Viewlet: document.createElement('div')
8962
8970
  };
8963
- set$8(uid, {
8971
+ set$1$1(uid, {
8964
8972
  factory: module,
8965
8973
  state: instanceState
8966
8974
  });
@@ -8983,7 +8991,7 @@ const loadModule = async id => {
8983
8991
  };
8984
8992
  const invoke = (viewletId, method, ...args) => {
8985
8993
  string(method);
8986
- const instance = get$9(viewletId);
8994
+ const instance = get$1$1(viewletId);
8987
8995
  if (!instance?.factory) {
8988
8996
  if (viewletId && method !== 'setActionsDom') {
8989
8997
  warn$1(`cannot execute ${method} viewlet instance ${viewletId} not found`);
@@ -9001,7 +9009,7 @@ const focus$1 = viewletId => {
9001
9009
  // eslint-disable-next-line no-console
9002
9010
  console.trace(`focus ${viewletId}`);
9003
9011
  }
9004
- const instance = get$9(viewletId);
9012
+ const instance = get$1$1(viewletId);
9005
9013
  if (instance.factory?.setFocused) {
9006
9014
  instance.factory.setFocused(instance.state, true);
9007
9015
  } else if (instance?.factory?.focus) {
@@ -9017,7 +9025,7 @@ const focusElementByName = (viewletId, name) => {
9017
9025
  // eslint-disable-next-line no-console
9018
9026
  console.trace(`focusByName ${viewletId} ${name}`);
9019
9027
  }
9020
- const instance = get$9(viewletId);
9028
+ const instance = get$1$1(viewletId);
9021
9029
  if (!instance) {
9022
9030
  return;
9023
9031
  }
@@ -9032,7 +9040,7 @@ const focusElementByName = (viewletId, name) => {
9032
9040
  };
9033
9041
  const setElementProperty = (viewletId, name, key, value) => {
9034
9042
  const selector = `[name="${name}"]`;
9035
- const instance = get$9(viewletId);
9043
+ const instance = get$1$1(viewletId);
9036
9044
  if (!instance) {
9037
9045
  return;
9038
9046
  }
@@ -9061,7 +9069,7 @@ const setCheckBoxValue = (viewletId, name, value) => {
9061
9069
  };
9062
9070
  const setSelectionByName = (viewletId, name, start, end) => {
9063
9071
  const selector = `[name="${name}"]`;
9064
- const instance = get$9(viewletId);
9072
+ const instance = get$1$1(viewletId);
9065
9073
  if (!instance) {
9066
9074
  return;
9067
9075
  }
@@ -9076,7 +9084,7 @@ const setSelectionByName = (viewletId, name, start, end) => {
9076
9084
  $Element.selectionEnd = end;
9077
9085
  };
9078
9086
  const setUid = (viewletId, uid) => {
9079
- const instance = get$9(viewletId);
9087
+ const instance = get$1$1(viewletId);
9080
9088
  if (!instance) {
9081
9089
  return;
9082
9090
  }
@@ -9086,7 +9094,7 @@ const setUid = (viewletId, uid) => {
9086
9094
  set$3($Viewlet, uid);
9087
9095
  };
9088
9096
  const focusSelector = (viewletId, selector) => {
9089
- const instance = get$9(viewletId);
9097
+ const instance = get$1$1(viewletId);
9090
9098
  if (!instance) {
9091
9099
  return;
9092
9100
  }
@@ -9104,7 +9112,7 @@ const focusSelector = (viewletId, selector) => {
9104
9112
  * @deprecated
9105
9113
  */
9106
9114
  const refresh$1 = (viewletId, viewletContext) => {
9107
- const instance = get$9(viewletId);
9115
+ const instance = get$1$1(viewletId);
9108
9116
  if (instance) {
9109
9117
  instance.factory.refresh(instance.state, viewletContext);
9110
9118
  } else {
@@ -9123,10 +9131,10 @@ const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
9123
9131
  if (isSpecial(viewletId)) {
9124
9132
  $PlaceHolder.id = viewletId;
9125
9133
  }
9126
- const parentInstance = get$9(parentId);
9134
+ const parentInstance = get$1$1(parentId);
9127
9135
  const $Parent = parentInstance.state.$Viewlet;
9128
9136
  $Parent.append($PlaceHolder);
9129
- set$8(viewletId, {
9137
+ set$1$1(viewletId, {
9130
9138
  state: {
9131
9139
  $Viewlet: $PlaceHolder
9132
9140
  }
@@ -9136,7 +9144,7 @@ const setDragData = (viewletId, dragData) => {
9136
9144
  set$2(viewletId, dragData);
9137
9145
  };
9138
9146
  const setDom = (viewletId, dom) => {
9139
- const instance = get$9(viewletId);
9147
+ const instance = get$1$1(viewletId);
9140
9148
  if (!instance) {
9141
9149
  return;
9142
9150
  }
@@ -9149,7 +9157,7 @@ const setDom = (viewletId, dom) => {
9149
9157
  renderInto($Viewlet, dom, Events);
9150
9158
  };
9151
9159
  const setDom2 = (viewletId, dom) => {
9152
- const instance = get$9(viewletId);
9160
+ const instance = get$1$1(viewletId);
9153
9161
  if (!instance) {
9154
9162
  return;
9155
9163
  }
@@ -9171,7 +9179,7 @@ const setDom2 = (viewletId, dom) => {
9171
9179
  // @ts-ignore
9172
9180
  set$3($NewViewlet, uid);
9173
9181
  }
9174
- set$8(viewletId, {
9182
+ set$1$1(viewletId, {
9175
9183
  ...instance,
9176
9184
  state: {
9177
9185
  ...instance.state,
@@ -9180,7 +9188,7 @@ const setDom2 = (viewletId, dom) => {
9180
9188
  });
9181
9189
  };
9182
9190
  const setPatches = (uid, patches) => {
9183
- const instance = get$9(uid);
9191
+ const instance = get$1$1(uid);
9184
9192
  if (!instance) {
9185
9193
  return;
9186
9194
  }
@@ -9351,7 +9359,7 @@ const sendMultiple = commands => {
9351
9359
  const dispose$3 = id => {
9352
9360
  try {
9353
9361
  number(id);
9354
- const instance = get$9(id);
9362
+ const instance = get$1$1(id);
9355
9363
  if (!instance) {
9356
9364
  warn$1(`viewlet instance ${id} not found and cannot be disposed`);
9357
9365
  return;
@@ -9362,14 +9370,14 @@ const dispose$3 = id => {
9362
9370
  if (instance.state.$Viewlet?.isConnected) {
9363
9371
  instance.state.$Viewlet.remove();
9364
9372
  }
9365
- set$8(id, undefined);
9373
+ set$1$1(id, undefined);
9366
9374
  } catch {
9367
9375
  throw new Error(`Failed to dispose ${id}`);
9368
9376
  }
9369
9377
  };
9370
9378
  const handleError$1 = (id, parentId, message) => {
9371
9379
  info(`[viewlet-error] ${id}: ${message}`);
9372
- const instance = get$9(id);
9380
+ const instance = get$1$1(id);
9373
9381
  if (instance?.state.$Viewlet.isConnected) {
9374
9382
  instance.state.$Viewlet.remove();
9375
9383
  }
@@ -9381,7 +9389,7 @@ const handleError$1 = (id, parentId, message) => {
9381
9389
  instance.state.$Viewlet.textContent = `${message}`;
9382
9390
  }
9383
9391
  // TODO error should bubble up to until highest possible component
9384
- const parentInstance = get$9(parentId);
9392
+ const parentInstance = get$1$1(parentId);
9385
9393
  if (parentInstance?.factory?.handleError) {
9386
9394
  parentInstance.factory.handleError(instance.state, message);
9387
9395
  }
@@ -9395,9 +9403,9 @@ const appendViewlet = (parentId, childId, focus) => {
9395
9403
  // TODO
9396
9404
  return;
9397
9405
  }
9398
- const parentInstanceState = get$9(parentId); // TODO must ensure that parent is already created
9406
+ const parentInstanceState = get$1$1(parentId); // TODO must ensure that parent is already created
9399
9407
  const parentModule = parentInstanceState.factory;
9400
- const childInstance = get$9(childId);
9408
+ const childInstance = get$1$1(childId);
9401
9409
  if (!childInstance) {
9402
9410
  throw new Error(`child instance ${childId} must be defined to be appended to parent ${parentId}`);
9403
9411
  }
@@ -9416,12 +9424,12 @@ const ariaAnnounce = async message => {
9416
9424
  const append = (parentId, childId, referenceNodes) => {
9417
9425
  number(parentId);
9418
9426
  number(childId);
9419
- const parentInstance = get$9(parentId);
9427
+ const parentInstance = get$1$1(parentId);
9420
9428
  if (!parentInstance) {
9421
9429
  throw new Error(`cannot append child: instance ${parentId} not found`);
9422
9430
  }
9423
9431
  const $Parent = parentInstance.state.$Viewlet;
9424
- const childInstance = get$9(childId);
9432
+ const childInstance = get$1$1(childId);
9425
9433
  if (!childInstance) {
9426
9434
  throw new Error(`cannot append child: child instance not found ${childId}`);
9427
9435
  }
@@ -9437,7 +9445,7 @@ const append = (parentId, childId, referenceNodes) => {
9437
9445
  if (id === childId) {
9438
9446
  for (let j = i - 1; j >= 0; j--) {
9439
9447
  const beforeId = referenceNodes[j];
9440
- const beforeInstance = get$9(beforeId);
9448
+ const beforeInstance = get$1$1(beforeId);
9441
9449
  if (beforeInstance) {
9442
9450
  const $ReferenceNode = beforeInstance.state.$Viewlet;
9443
9451
  $ReferenceNode.after($Child);
@@ -9446,7 +9454,7 @@ const append = (parentId, childId, referenceNodes) => {
9446
9454
  }
9447
9455
  for (let j = i + 1; j < referenceNodes.length; j++) {
9448
9456
  const afterId = referenceNodes[j];
9449
- const afterInstance = get$9(afterId);
9457
+ const afterInstance = get$1$1(afterId);
9450
9458
  if (afterInstance) {
9451
9459
  const $ReferenceNode = afterInstance.state.$Viewlet;
9452
9460
  $ReferenceNode.before($Child);
@@ -9464,11 +9472,11 @@ const append = (parentId, childId, referenceNodes) => {
9464
9472
  }
9465
9473
  };
9466
9474
  const replaceChildren = (parentId, childIds) => {
9467
- const parentInstance = get$9(parentId);
9475
+ const parentInstance = get$1$1(parentId);
9468
9476
  const $Parent = parentInstance.state.$Viewlet;
9469
9477
  const $Fragment = document.createDocumentFragment();
9470
9478
  for (const childId of childIds) {
9471
- const childInstance = get$9(childId);
9479
+ const childInstance = get$1$1(childId);
9472
9480
  const $Child = childInstance.state.$Viewlet;
9473
9481
  $Fragment.append($Child);
9474
9482
  }
@@ -9476,7 +9484,7 @@ const replaceChildren = (parentId, childIds) => {
9476
9484
  };
9477
9485
  const appendToBody = childId => {
9478
9486
  const $Parent = document.body;
9479
- const childInstance = get$9(childId);
9487
+ const childInstance = get$1$1(childId);
9480
9488
  const $Child = childInstance.state.$Viewlet;
9481
9489
  $Parent.append($Child);
9482
9490
  };
@@ -9548,7 +9556,7 @@ const executeCommands = commands => {
9548
9556
  }
9549
9557
  };
9550
9558
  const show = id => {
9551
- const instance = get$9(id);
9559
+ const instance = get$1$1(id);
9552
9560
  const $Viewlet = instance.state.$Viewlet;
9553
9561
  const $Workbench = document.getElementById('Workbench');
9554
9562
  // @ts-expect-error
@@ -9558,7 +9566,7 @@ const show = id => {
9558
9566
  }
9559
9567
  };
9560
9568
  const setBounds$1 = (id, left, top, width, height) => {
9561
- const instance = get$9(id);
9569
+ const instance = get$1$1(id);
9562
9570
  if (!instance) {
9563
9571
  return;
9564
9572
  }
@@ -9566,7 +9574,7 @@ const setBounds$1 = (id, left, top, width, height) => {
9566
9574
  setBounds$a($Viewlet, left, top, width, height);
9567
9575
  };
9568
9576
  const setProperty = (id, selector, property, value) => {
9569
- const instance = get$9(id);
9577
+ const instance = get$1$1(id);
9570
9578
  if (!instance) {
9571
9579
  return;
9572
9580
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "21.7.0",
3
+ "version": "21.8.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"