@openui5/sap.ui.codeeditor 1.99.1 → 1.102.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.
package/THIRDPARTY.txt CHANGED
@@ -400,7 +400,7 @@ Contained in: src/sap.ui.mdc/test/sap/ui/mdc/sample/field/filterfieldwithoperato
400
400
 
401
401
  Library: sap.ui.webc.common:
402
402
 
403
- Component: UI5 Web Components, version: 1.0.0-rc.12
403
+ Component: UI5 Web Components, version: 1.1.2
404
404
  Copyright: SAP
405
405
  License: Apache-2.0
406
406
  License Text: https://github.com/SAP/openui5/blob/master/LICENSES/Apache-2.0.txt
@@ -411,7 +411,7 @@ Contained in: src/sap.ui.webc.common/src/sap/ui/webc/common/thirdparty/base/*.*
411
411
  src/sap.ui.webc.common/src/sap/ui/webc/common/thirdparty/icons-tnt/*.*
412
412
  src/sap.ui.webc.common/src/sap/ui/webc/common/thirdparty/icons-business-suite/*.*
413
413
 
414
- Component: lit-html, version: 1.4.1
414
+ Component: lit-html, version: 2.0.1
415
415
  Copyright: Google LLC
416
416
  License: BSD-3-Clause
417
417
  License Text: https://github.com/SAP/openui5/blob/master/LICENSES/BSD-3-Clause.txt
@@ -420,7 +420,7 @@ Contained in: src/sap.ui.webc.common/src/sap/ui/webc/common/thirdparty/lit-html/
420
420
 
421
421
  Library: sap.ui.webc.fiori:
422
422
 
423
- Component: UI5 Web Components, version: 1.0.0-rc.12
423
+ Component: UI5 Web Components, version: 1.1.2
424
424
  Copyright: SAP
425
425
  License: Apache-2.0
426
426
  License Text: https://github.com/SAP/openui5/blob/master/LICENSES/Apache-2.0.txt
@@ -429,7 +429,7 @@ Contained in: src/sap.ui.webc.fiori/src/sap/ui/webc/fiori/thirdparty/*.*
429
429
 
430
430
  Library: sap.ui.webc.main:
431
431
 
432
- Component: UI5 Web Components, version: 1.0.0-rc.12
432
+ Component: UI5 Web Components, version: 1.1.2
433
433
  Copyright: SAP
434
434
  License: Apache-2.0
435
435
  License Text: https://github.com/SAP/openui5/blob/master/LICENSES/Apache-2.0.txt
@@ -450,7 +450,7 @@ License: Apache-2.0
450
450
  License Text: https://github.com/SAP/openui5/blob/master/LICENSES/Apache-2.0.txt
451
451
  Contained in: lib/jsdoc/ui5/plugin.js
452
452
 
453
- Component: SAP Theming Base Content, version: 11.1.34
453
+ Component: SAP Theming Base Content, version: 11.1.39
454
454
  Copyright: SAP SE or an SAP affiliate company and Theming Base Content contributors
455
455
  License: Apache-2.0
456
456
  License Text: https://github.com/SAP/openui5/blob/master/LICENSES/Apache-2.0.txt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openui5/sap.ui.codeeditor",
3
- "version": "1.99.1",
3
+ "version": "1.102.0",
4
4
  "description": "OpenUI5 UI Library sap.ui.codeeditor",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -14,6 +14,6 @@
14
14
  "url": "https://github.com/SAP/openui5.git"
15
15
  },
16
16
  "dependencies": {
17
- "@openui5/sap.ui.core": "1.99.1"
17
+ "@openui5/sap.ui.core": "1.102.0"
18
18
  }
19
19
  }
@@ -6,7 +6,7 @@
6
6
  <copyright>OpenUI5
7
7
  * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
8
8
  * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.</copyright>
9
- <version>1.99.1</version>
9
+ <version>1.102.0</version>
10
10
 
11
11
  <documentation>UI5 library: sap.ui.codeeditor</documentation>
12
12
 
@@ -63,7 +63,7 @@ sap.ui.define([
63
63
  * @extends sap.ui.core.Control
64
64
  *
65
65
  * @author SAP SE
66
- * @version 1.99.1
66
+ * @version 1.102.0
67
67
  *
68
68
  * @constructor
69
69
  * @public
@@ -234,18 +234,7 @@ sap.ui.define([
234
234
  "sap-ui-codeeditor-ace"
235
235
  );
236
236
 
237
- var sUiTheme = Core.getConfiguration().getTheme().toLowerCase();
238
- var sEditorTheme = "tomorrow";
239
- if (sUiTheme.indexOf("hcb") > -1) {
240
- sEditorTheme = "chaos";
241
- } else if (sUiTheme.indexOf("hcw") > -1) {
242
- sEditorTheme = "github";
243
- } else if (sUiTheme === "sap_fiori_3") {
244
- sEditorTheme = "crimson_editor";
245
- } else if (sUiTheme === "sap_fiori_3_dark") {
246
- sEditorTheme = "clouds_midnight";
247
- }
248
- this.setColorTheme(sEditorTheme);
237
+ this._applyTheme();
249
238
 
250
239
  this._oEditor.setOptions({
251
240
  enableBasicAutocompletion: true,
@@ -301,11 +290,39 @@ sap.ui.define([
301
290
  CodeEditor.prototype.exit = function() {
302
291
  this._deregisterResizeListener();
303
292
  this._oEditor.destroy(); // clear ace intervals
293
+ this._oEditor.getSession().setUseWorker(false); // explicitly disable worker usage, in case the ace mode is still loading, to avoid worker initialization after destroy
304
294
  jQuery(this._oEditorDomRef).remove(); // remove DOM node together with all event listeners
305
295
  this._oEditorDomRef = null;
306
296
  this._oEditor = null;
307
297
  };
308
298
 
299
+ /**
300
+ * @private
301
+ */
302
+ CodeEditor.prototype.onThemeChanged = function() {
303
+ this._applyTheme();
304
+ };
305
+
306
+ /**
307
+ * @private
308
+ */
309
+ CodeEditor.prototype._applyTheme = function() {
310
+ var sUiTheme = Core.getConfiguration().getTheme().toLowerCase();
311
+ var sEditorTheme = "tomorrow";
312
+ if (sUiTheme.indexOf("hcb") > -1) {
313
+ sEditorTheme = "chaos";
314
+ } else if (sUiTheme.indexOf("hcw") > -1) {
315
+ sEditorTheme = "github";
316
+ } else if (sUiTheme === "sap_fiori_3") {
317
+ sEditorTheme = "crimson_editor";
318
+ } else if (sUiTheme === "sap_fiori_3_dark") {
319
+ sEditorTheme = "clouds_midnight";
320
+ } else if (sUiTheme === "sap_horizon_dark") {
321
+ sEditorTheme = "nord_dark";
322
+ }
323
+ this.setColorTheme(sEditorTheme);
324
+ };
325
+
309
326
  /**
310
327
  * @private
311
328
  */
@@ -486,11 +503,6 @@ sap.ui.define([
486
503
  ace.require("ace/ext/beautify").beautify(this._oEditor.session);
487
504
  };
488
505
 
489
- CodeEditor.prototype.destroy = function (bSuppressInvalidate) {
490
- this._oEditor.destroy(bSuppressInvalidate);
491
- Control.prototype.destroy.call(this, bSuppressInvalidate);
492
- };
493
-
494
506
  CodeEditor.prototype.onfocusout = function () {
495
507
  this._oEditor.getSession().setUseWorker(false);
496
508
  };
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Wrapper for Ace Worker</title>
7
+ <script src="aceWorkerProxy.js"></script>
8
+ </head>
9
+ <body>
10
+ </body>
11
+ </html>
@@ -0,0 +1,57 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ window.addEventListener("load", function () {
8
+ "use strict";
9
+
10
+ var ACE_BASE_PATH = new URL("./js/ace/", document.baseURI).href;
11
+ var workers = new Map();
12
+
13
+ // listen for messages from ace
14
+ window.addEventListener("message", function (event) {
15
+ var message = event.data.message;
16
+ var workerId = event.data.workerId;
17
+ var senderOrigin = event.origin;
18
+
19
+ if (message.createWorker) {
20
+ var workerEntry = createWorkerEntry(message.workerUrl, senderOrigin, workerId);
21
+
22
+ if (workerEntry) {
23
+ workers.set(workerId, workerEntry);
24
+ }
25
+ } else if (message.terminateWorker) {
26
+ workers.get(workerId).worker.terminate();
27
+ workers.delete(workerId);
28
+ } else if (senderOrigin === workers.get(workerId).creatorOrigin) { // send message to the worker only from the origin that created it
29
+ workers.get(workerId).worker.postMessage(message);
30
+ }
31
+ });
32
+
33
+ function createWorkerEntry(url, origin, workerId) {
34
+ if (!url || typeof url !== "string") {
35
+ return null;
36
+ }
37
+
38
+ var absoluteWorkerUrl = new URL(url, document.baseURI).href;
39
+
40
+ // create worker only if it's located on the same origin and is in the "./js/ace/" folder
41
+ if (!absoluteWorkerUrl.startsWith(ACE_BASE_PATH)) {
42
+ return null;
43
+ }
44
+
45
+ var worker = new Worker(absoluteWorkerUrl);
46
+ // forward messages from worker to ace
47
+ worker.addEventListener("message", function(event) {
48
+ event.data.workerId = workerId;
49
+ window.parent.postMessage(event.data, origin);
50
+ });
51
+
52
+ return {
53
+ creatorOrigin: origin,
54
+ worker: worker
55
+ };
56
+ }
57
+ });
@@ -12518,6 +12518,9 @@ var TokenIterator = require("./token_iterator").TokenIterator;
12518
12518
 
12519
12519
  var clipboard = require("./clipboard");
12520
12520
  var Editor = function(renderer, session, options) {
12521
+ // #### BEGIN MODIFIED BY SAP
12522
+ Editor._instancesCnt ++;
12523
+ // #### END MODIFIED BY SAP
12521
12524
  this.$toDestroy = [];
12522
12525
  var container = renderer.getContainerElement();
12523
12526
  this.container = container;
@@ -12559,6 +12562,9 @@ var Editor = function(renderer, session, options) {
12559
12562
  this.setOptions(options);
12560
12563
  config._signal("editor", this);
12561
12564
  };
12565
+ // ##### BEGIN MODIFIED BY SAP
12566
+ Editor._instancesCnt = 0;
12567
+ // ##### END MODIFIED BY SAP
12562
12568
 
12563
12569
  Editor.$uid = 0;
12564
12570
 
@@ -14419,6 +14425,14 @@ Editor.$uid = 0;
14419
14425
  if (this._$emitInputEvent)
14420
14426
  this._$emitInputEvent.cancel();
14421
14427
  this.removeAllListeners();
14428
+
14429
+ // ##### BEGIN MODIFIED BY SAP
14430
+ Editor._instancesCnt--;
14431
+ var iframe = document.getElementById("sap-ui-codeeditor-ace-worker-proxy");
14432
+ if (Editor._instancesCnt === 0 && iframe) {
14433
+ iframe.remove();
14434
+ }
14435
+ // ##### END MODIFIED BY SAP
14422
14436
  };
14423
14437
  this.setAutoScrollEditorIntoView = function(enable) {
14424
14438
  if (!enable)
@@ -19090,16 +19104,85 @@ function $workerBlob(workerUrl) {
19090
19104
  }
19091
19105
  }
19092
19106
 
19107
+ // ##### BEGIN MODIFIED BY SAP
19108
+ var workersCnt = 0;
19109
+
19093
19110
  function createWorker(workerUrl) {
19094
19111
  if (typeof Worker == "undefined")
19095
19112
  return { postMessage: function() {}, terminate: function() {} };
19096
- if (config.get("loadWorkerFromBlob")) {
19097
- var blob = $workerBlob(workerUrl);
19098
- var URL = window.URL || window.webkitURL;
19099
- var blobURL = URL.createObjectURL(blob);
19100
- return new Worker(blobURL);
19113
+
19114
+ var iframe = document.getElementById("sap-ui-codeeditor-ace-worker-proxy");
19115
+ var iframeLoaded = true;
19116
+ if (!iframe) {
19117
+ iframeLoaded = false;
19118
+ iframe = document.createElement("iframe");
19119
+ iframe.id = "sap-ui-codeeditor-ace-worker-proxy";
19120
+ iframe.src = sap.ui.require.toUrl("sap/ui/codeeditor/aceWorkerProxy.html");
19121
+ iframe.hidden = true;
19122
+ iframe.sandbox = "allow-scripts allow-same-origin";
19123
+ document.body.appendChild(iframe);
19124
+
19125
+ // await for the iframe to load and then send to it the pending messages
19126
+ iframe.onload = function () {
19127
+ iframeLoaded = true;
19128
+ messageQueue.forEach(function (entry) {
19129
+ entry.workerProxy.postMessage(entry.message)
19130
+ });
19131
+ }
19132
+ }
19133
+
19134
+ var iframeOrigin = new URL(iframe.src).origin;
19135
+ var messageQueue = [];
19136
+ var workerProxy = {
19137
+ postMessage: function (message) {
19138
+ if (!iframeLoaded) {
19139
+ // enqueue the messages until the iframe is loaded
19140
+ messageQueue.push({
19141
+ workerProxy: this,
19142
+ message: message
19143
+ });
19144
+ return;
19145
+ }
19146
+
19147
+ var wrappedMessage = {
19148
+ workerId: this._id,
19149
+ message: message
19150
+ }
19151
+ // send message to worker
19152
+ iframe.contentWindow.postMessage.call(iframe.contentWindow, wrappedMessage, iframeOrigin);
19153
+ },
19154
+ terminate: function () {
19155
+ this.postMessage({
19156
+ terminateWorker: true
19157
+ });
19158
+
19159
+ window.removeEventListener("message", this._messageFromFrameListener);
19160
+ },
19161
+ set onmessage(cb) {
19162
+ this._messageCb = cb;
19163
+ },
19164
+ _id: workersCnt++,
19165
+ _listenForMessageFromFrame: function () {
19166
+ this._messageFromFrameListener = function (event) {
19167
+ if (!iframe || event.origin !== iframeOrigin || event.source !== iframe.contentWindow || event.data.workerId !== this._id) {
19168
+ return;
19169
+ }
19170
+
19171
+ this._messageCb.call(this._messageCb, event);
19172
+ }.bind(this)
19173
+ window.addEventListener("message", this._messageFromFrameListener);
19174
+ }
19101
19175
  }
19102
- return new Worker(workerUrl);
19176
+
19177
+ workerProxy.postMessage({
19178
+ createWorker: true,
19179
+ workerUrl: workerUrl
19180
+ });
19181
+
19182
+ workerProxy._listenForMessageFromFrame();
19183
+
19184
+ return workerProxy;
19185
+ // ##### END MODIFIED BY SAP
19103
19186
  }
19104
19187
 
19105
19188
  var WorkerClient = function(worker) {
@@ -17,17 +17,13 @@ sap.ui.define([
17
17
  * UI5 library: sap.ui.codeeditor.
18
18
  *
19
19
  * @namespace
20
- * @name sap.ui.codeeditor
20
+ * @alias sap.ui.codeeditor
21
21
  * @author SAP SE
22
- * @version 1.99.1
22
+ * @version 1.102.0
23
23
  * @since 1.48
24
24
  * @public
25
25
  */
26
-
27
- // library dependencies
28
-
29
- // delegate further initialization of this library to the Core
30
- sap.ui.getCore().initLibrary({
26
+ var thisLib = sap.ui.getCore().initLibrary({
31
27
  name : "sap.ui.codeeditor",
32
28
  dependencies : ["sap.ui.core"],
33
29
  types: [],
@@ -37,8 +33,8 @@ sap.ui.define([
37
33
  ],
38
34
  elements: [],
39
35
  noLibraryCSS: false,
40
- version: "1.99.1"
36
+ version: "1.102.0"
41
37
  });
42
38
 
43
- return sap.ui.codeeditor;
39
+ return thisLib;
44
40
  });