@lvce-editor/renderer-process 30.50.0 → 30.52.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.
@@ -3,6 +3,15 @@ const play = async src => {
3
3
  await audio.play();
4
4
  };
5
5
 
6
+ const fileSaved = (applicationId, uri) => {
7
+ window.dispatchEvent(new CustomEvent('lvce-file-saved', {
8
+ detail: {
9
+ applicationId,
10
+ uri
11
+ }
12
+ }));
13
+ };
14
+
6
15
  class AssertionError extends Error {
7
16
  constructor(message) {
8
17
  super(message);
@@ -7915,6 +7924,9 @@ const handleSashDoubleClick = event => {
7915
7924
  handleSashDoubleClick$1(id);
7916
7925
  };
7917
7926
  const handleResize = () => {
7927
+ if (new URL(location.href).searchParams.has('applicationHost')) {
7928
+ return;
7929
+ }
7918
7930
  const {
7919
7931
  innerHeight,
7920
7932
  innerWidth
@@ -9643,7 +9655,101 @@ const setDragData = (viewletId, dragData) => {
9643
9655
  const getDragData = () => {
9644
9656
  return getCurrent();
9645
9657
  };
9658
+
9659
+ // Keep the actual patch baseline intact while a component DOM preview is displayed.
9660
+ const restoreComponentDom = viewletId => {
9661
+ const instance = get$a(viewletId);
9662
+ const $Original = instance?.componentDomOriginal;
9663
+ if (!$Original) {
9664
+ return;
9665
+ }
9666
+ const references = instance.componentDomReferences || [];
9667
+ for (const {
9668
+ placeholder,
9669
+ uid
9670
+ } of references) {
9671
+ const $Child = get$a(uid)?.state.$Viewlet;
9672
+ if ($Child) {
9673
+ placeholder.replaceWith($Child);
9674
+ } else {
9675
+ placeholder.remove();
9676
+ }
9677
+ }
9678
+ instance.state.$Viewlet.replaceWith($Original);
9679
+ set$a(viewletId, {
9680
+ ...instance,
9681
+ componentDom: undefined,
9682
+ componentDomOriginal: undefined,
9683
+ componentDomReferences: undefined,
9684
+ state: {
9685
+ ...instance.state,
9686
+ $Viewlet: $Original
9687
+ }
9688
+ });
9689
+ };
9690
+ const setComponentDom = (viewletId, dom) => {
9691
+ const instance = get$a(viewletId);
9692
+ if (!instance) {
9693
+ return;
9694
+ }
9695
+ const {
9696
+ $Viewlet
9697
+ } = instance.state;
9698
+ const $Original = instance.componentDomOriginal || $Viewlet;
9699
+ const references = [...(instance.componentDomReferences || [])];
9700
+ const newReferences = [];
9701
+ for (const node of dom) {
9702
+ if (node.type !== Reference || references.some(reference => reference.uid === node.uid)) {
9703
+ continue;
9704
+ }
9705
+ const $Child = get$a(node.uid)?.state.$Viewlet;
9706
+ if (!$Child || $Child === $Original || !$Original.contains($Child)) {
9707
+ throw new Error('Component DOM references must belong to the edited component');
9708
+ }
9709
+ newReferences.push({
9710
+ child: $Child,
9711
+ uid: node.uid
9712
+ });
9713
+ }
9714
+ for (const {
9715
+ child,
9716
+ uid
9717
+ } of newReferences) {
9718
+ const placeholder = document.createComment('component-dom-reference');
9719
+ child.before(placeholder);
9720
+ references.push({
9721
+ placeholder,
9722
+ uid
9723
+ });
9724
+ }
9725
+ set$a(viewletId, {
9726
+ ...instance,
9727
+ componentDomOriginal: $Original,
9728
+ componentDomReferences: references
9729
+ });
9730
+ // Render against a detached copy so focus preservation cannot move nodes out of the baseline.
9731
+ let $Preview;
9732
+ try {
9733
+ $Preview = rememberFocus($Viewlet.cloneNode(true), dom, instance.factory.Events, viewletId);
9734
+ } catch (error) {
9735
+ restoreComponentDom(viewletId);
9736
+ throw error;
9737
+ }
9738
+ $Viewlet.replaceWith($Preview);
9739
+ set$a(viewletId, {
9740
+ ...instance,
9741
+ componentDom: dom,
9742
+ componentDomOriginal: $Original,
9743
+ componentDomReferences: references,
9744
+ state: {
9745
+ ...instance.state,
9746
+ $Viewlet: $Preview
9747
+ }
9748
+ });
9749
+ };
9750
+ const getComponentDom = viewletId => get$a(viewletId)?.componentDom;
9646
9751
  const setDom = (viewletId, dom) => {
9752
+ restoreComponentDom(viewletId);
9647
9753
  const instance = get$a(viewletId);
9648
9754
  if (!instance) {
9649
9755
  return;
@@ -9657,6 +9763,7 @@ const setDom = (viewletId, dom) => {
9657
9763
  renderInto($Viewlet, dom, Events);
9658
9764
  };
9659
9765
  const setDom2 = (viewletId, dom) => {
9766
+ restoreComponentDom(viewletId);
9660
9767
  const instance = get$a(viewletId);
9661
9768
  if (!instance) {
9662
9769
  return;
@@ -9688,6 +9795,10 @@ const setDom2 = (viewletId, dom) => {
9688
9795
  });
9689
9796
  };
9690
9797
  const setPatches = (uid, patches) => {
9798
+ if (patches.length === 0) {
9799
+ return;
9800
+ }
9801
+ restoreComponentDom(uid);
9691
9802
  const instance = get$a(uid);
9692
9803
  if (!instance) {
9693
9804
  return;
@@ -9759,6 +9870,7 @@ const commitPending = (uid, transactionId) => {
9759
9870
  const dispose$3 = id => {
9760
9871
  try {
9761
9872
  number(id);
9873
+ restoreComponentDom(id);
9762
9874
  unregisterView(id);
9763
9875
  const instance = get$a(id);
9764
9876
  if (!instance) {
@@ -10041,6 +10153,7 @@ const commandHandlers = {
10041
10153
  'Viewlet.focusElementByName': focusElementByName,
10042
10154
  'Viewlet.focusSelector': focusSelector,
10043
10155
  'Viewlet.focusSelectorAfterRender': focusSelectorAfterRender,
10156
+ 'Viewlet.getComponentDom': getComponentDom,
10044
10157
  'Viewlet.handleError': handleError$1,
10045
10158
  'Viewlet.move': move,
10046
10159
  'Viewlet.patchCss': patchCssStyleSheet,
@@ -10053,6 +10166,7 @@ const commandHandlers = {
10053
10166
  'Viewlet.send': invoke,
10054
10167
  'Viewlet.setBounds': setBounds$1,
10055
10168
  'Viewlet.setCheckBoxValue': setCheckboxValue,
10169
+ 'Viewlet.setComponentDom': setComponentDom,
10056
10170
  'Viewlet.setCss': addCssStyleSheet,
10057
10171
  'Viewlet.setDom': setDom,
10058
10172
  'Viewlet.setDom2': setDom2,
@@ -10500,6 +10614,7 @@ const readMicLevels = options => {
10500
10614
  };
10501
10615
 
10502
10616
  const commandMap = {
10617
+ 'ApplicationHost.fileSaved': fileSaved,
10503
10618
  'Audio.play': play,
10504
10619
  'ClipBoard.execCopy': execCopy,
10505
10620
  'ClipBoard.read': read,
@@ -10580,6 +10695,7 @@ const commandMap = {
10580
10695
  'Viewlet.focusElementByName': focusElementByName,
10581
10696
  'Viewlet.focusSelector': focusSelector,
10582
10697
  'Viewlet.focusSelectorAfterRender': focusSelectorAfterRender,
10698
+ 'Viewlet.getComponentDom': getComponentDom,
10583
10699
  'Viewlet.getDragData': getDragData,
10584
10700
  'Viewlet.handleError': handleError$1,
10585
10701
  'Viewlet.invoke': invoke,
@@ -10593,6 +10709,7 @@ const commandMap = {
10593
10709
  'Viewlet.send': invoke,
10594
10710
  'Viewlet.sendMultiple': sendMultiple,
10595
10711
  'Viewlet.setBounds': setBounds$1,
10712
+ 'Viewlet.setComponentDom': setComponentDom,
10596
10713
  'Viewlet.show': show,
10597
10714
  'WebRtc.readMicLevels': readMicLevels,
10598
10715
  'WebRtc.setRemoteDescription': setRemoteDescription,
@@ -11089,7 +11206,7 @@ const main = async () => {
11089
11206
  setIpc(ViewletEventRouter);
11090
11207
  };
11091
11208
 
11092
- main();
11209
+ const ready = main();
11093
11210
 
11094
11211
  const defaultColumns = 80;
11095
11212
  const defaultRows = 24;
@@ -11339,3 +11456,5 @@ const AriaAlert = {
11339
11456
  __proto__: null,
11340
11457
  alert: alert$1
11341
11458
  };
11459
+
11460
+ export { invoke$1 as executeCommand, ready };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.50.0",
3
+ "version": "30.52.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"
@@ -1,191 +0,0 @@
1
- :root {
2
- --EditorCursorBackground: #aeafad;
3
- --EditorFontFamily: monospace;
4
- --EditorFontFeatureSettings: normal;
5
- --EditorFontSize: 15px;
6
- --EditorFontWeight: 400;
7
- --EditorLetterSpacing: 0;
8
- --EditorLineHeight: 20px;
9
- --EditorSelectionBackground: #264f78;
10
- --EditorTabSize: 2;
11
- --MainBackground: #1e1e1e;
12
- }
13
-
14
- html,
15
- body {
16
- width: 100%;
17
- height: 100%;
18
- margin: 0;
19
- overflow: hidden;
20
- background: var(--MainBackground);
21
- }
22
-
23
- .Viewlet {
24
- contain: strict;
25
- }
26
-
27
- .Editor {
28
- width: 100%;
29
- height: 100%;
30
- background: var(--MainBackground);
31
- color: #d4d4d4;
32
- outline: none;
33
- border: none;
34
- font-family: var(--EditorFontFamily);
35
- white-space: pre;
36
- font-size: var(--EditorFontSize);
37
- letter-spacing: var(--EditorLetterSpacing);
38
- font-feature-settings: var(--EditorFontFeatureSettings);
39
- tab-size: var(--EditorTabSize);
40
- cursor: text;
41
- font-weight: var(--EditorFontWeight);
42
- display: flex;
43
- }
44
-
45
- .EditorContent,
46
- .EditorLayers,
47
- .EditorRows {
48
- contain: strict;
49
- width: 100%;
50
- height: 100%;
51
- }
52
-
53
- .EditorRows {
54
- white-space: pre;
55
- }
56
-
57
- .EditorRow {
58
- display: block;
59
- height: var(--EditorLineHeight);
60
- line-height: var(--EditorLineHeight);
61
- contain: strict;
62
- }
63
-
64
- .Editors {
65
- flex: 1;
66
- }
67
-
68
- .EditorCursor {
69
- width: 2px;
70
- height: var(--EditorLineHeight);
71
- position: absolute;
72
- top: 0;
73
- left: 0;
74
- background: var(--EditorCursorBackground);
75
- pointer-events: none;
76
- contain: strict;
77
- }
78
-
79
- .EditorInput {
80
- position: absolute;
81
- width: 0;
82
- height: 0;
83
- opacity: 0;
84
- padding: 0;
85
- border: 0;
86
- font-size: 1px;
87
- top: -9999px;
88
- left: -9999px;
89
- }
90
-
91
- .EditorSelection {
92
- position: absolute;
93
- top: 0;
94
- left: 0;
95
- pointer-events: none;
96
- background: var(--EditorSelectionBackground);
97
- }
98
-
99
- .Token {
100
- contain: content;
101
- }
102
-
103
- .TokenComment {
104
- color: #6a9955;
105
- }
106
-
107
- .TokenString,
108
- .TokenStringValue {
109
- color: #ce9178;
110
- }
111
-
112
- .TokenNumeric,
113
- .TokenNumber {
114
- color: #b5cea8;
115
- }
116
-
117
- .TokenKeyword,
118
- .TokenTag,
119
- .TokenTagName {
120
- color: #569cd6;
121
- }
122
-
123
- .TokenAttribute,
124
- .TokenAttributeName,
125
- .TokenProperty,
126
- .TokenPropertyName {
127
- color: #9cdcfe;
128
- }
129
-
130
- .TokenPunctuation,
131
- .TokenPunctuationTag {
132
- color: #808080;
133
- }
134
-
135
- .LayerCursor,
136
- .LayerDiagnostics {
137
- position: absolute;
138
- inset: 0;
139
- pointer-events: none;
140
- }
141
-
142
- .Gutter {
143
- contain: strict;
144
- width: 30px;
145
- height: 100%;
146
- display: flex;
147
- flex-direction: column;
148
- }
149
-
150
- .Gutter:empty {
151
- display: none;
152
- }
153
-
154
- .LineNumber {
155
- color: rgba(155, 162, 160, 0.6);
156
- contain: strict;
157
- margin-right: 1px;
158
- height: var(--EditorLineHeight);
159
- text-align: right;
160
- }
161
-
162
- .ScrollBar {
163
- position: absolute;
164
- right: 0;
165
- top: 0;
166
- width: 14px;
167
- bottom: 0;
168
- contain: strict;
169
- cursor: default;
170
- }
171
-
172
- .ScrollBarHorizontal {
173
- left: 0;
174
- top: auto;
175
- height: 14px;
176
- width: auto;
177
- }
178
-
179
- .ScrollBarThumb {
180
- width: 100%;
181
- position: absolute;
182
- contain: strict;
183
- background: rgba(57, 71, 71, 0.6);
184
- height: var(--ScrollBarThumbHeight);
185
- top: var(--ScrollBarThumbTop);
186
- }
187
-
188
- .ScrollBarThumbHorizontal {
189
- height: 100%;
190
- width: auto;
191
- }