sunrize 1.9.1 → 1.10.2

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,22 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  const
4
- $ = require ("jquery"),
5
- electron = require ("electron"),
6
- path = require ("path"),
7
- url = require ("url"),
8
- fs = require ("fs"),
9
- X3D = require ("../X3D"),
10
- Interface = require ("../Application/Interface"),
11
- Splitter = require ("../Controls/Splitter"),
12
- NodeList = require ("./NodeList"),
13
- Console = require ("./Console"),
14
- Editor = require ("../Undo/Editor"),
15
- UndoManager = require ("../Undo/UndoManager"),
16
- monaco = require ("monaco-editor/min/vs/loader.js"),
17
- _ = require ("../Application/GetText");
18
-
19
- monaco .require .config ({
4
+ $ = require ("jquery"),
5
+ electron = require ("electron"),
6
+ path = require ("path"),
7
+ url = require ("url"),
8
+ fs = require ("fs"),
9
+ X3D = require ("../X3D"),
10
+ Interface = require ("../Application/Interface"),
11
+ Splitter = require ("../Controls/Splitter"),
12
+ NodeList = require ("./NodeList"),
13
+ Console = require ("./Console"),
14
+ Editor = require ("../Undo/Editor"),
15
+ UndoManager = require ("../Undo/UndoManager"),
16
+ monacoLoader = require ("monaco-editor/min/vs/loader.js"),
17
+ _ = require ("../Application/GetText");
18
+
19
+ monacoLoader .require .config ({
20
20
  baseUrl: url .pathToFileURL (path .resolve (path .dirname (require .resolve ("monaco-editor/package.json")), "min")) + "/",
21
21
  });
22
22
 
@@ -137,14 +137,21 @@ module .exports = class ScriptEditor extends Interface
137
137
  this .setup ();
138
138
  }
139
139
 
140
- colorScheme (shouldUseDarkColors)
140
+ getMonaco ()
141
141
  {
142
- monaco .require (["vs/editor/editor.main"], monaco =>
142
+ return new Promise (resolve =>
143
143
  {
144
- monaco .editor .setTheme (shouldUseDarkColors ? "vs-dark" : "vs-light");
144
+ monacoLoader .require (["vs/editor/editor.main"], ({ m: monaco }) => resolve (monaco));
145
145
  });
146
146
  }
147
147
 
148
+ async colorScheme (shouldUseDarkColors)
149
+ {
150
+ const monaco = await this .getMonaco ();
151
+
152
+ monaco .editor .setTheme (shouldUseDarkColors ? "vs-dark" : "vs-light");
153
+ }
154
+
148
155
  async setNode (node)
149
156
  {
150
157
  this .directOutputButton .hide ();
@@ -368,74 +375,92 @@ module .exports = class ScriptEditor extends Interface
368
375
  "ShaderPart": "c",
369
376
  };
370
377
 
371
- getEditor (node)
378
+ async getEditor (node)
379
+ {
380
+ if (!this .editors .has (node))
381
+ this .editors .set (node, await this .createEditor (node));
382
+
383
+ return this .editors .get (node);
384
+ }
385
+
386
+ async createEditor (node)
387
+ {
388
+ const
389
+ monaco = await this .getMonaco (),
390
+ element = $("<div></div>") .addClass ("script-editor-monaco");
391
+
392
+ const editor = monaco .editor .create (element .get (0),
393
+ {
394
+ language: this .languages [node .getTypeName ()],
395
+ contextmenu: false,
396
+ automaticLayout: true,
397
+ wordWrap: "on",
398
+ wrappingIndent: "indent",
399
+ minimap: { enabled: false },
400
+ bracketPairColorization: { enabled: true },
401
+ });
402
+
403
+ editor .viewState = editor .saveViewState ();
404
+
405
+ editor .onDidFocusEditorWidget (() => this .setDeclarations (monaco));
406
+ editor .onDidBlurEditorWidget (() => this .apply ());
407
+ editor .onKeyDown (event => this .onKeyDown (event));
408
+
409
+ element .on ("mouseenter", () => this .setDeclarations (monaco));
410
+ element .on ("contextmenu", () => this .showContextMenu ());
411
+
412
+ // this .debugFindActions (editor)
413
+ return { element, editor, monaco };
414
+ }
415
+
416
+ onKeyDown (event)
372
417
  {
373
- return new Promise ((resolve, reject) =>
418
+ const { keyCode, ctrlKey, metaKey } = event;
419
+
420
+ switch (keyCode)
374
421
  {
375
- if (this .editors .has (node))
422
+ case 33: // c
376
423
  {
377
- resolve (this .editors .get (node));
424
+ if (!(metaKey || ctrlKey))
425
+ break;
426
+
427
+ event .preventDefault ();
428
+ event .stopPropagation ();
429
+ this .cutOrCopy ("copy");
430
+ break;
378
431
  }
379
- else
432
+ case 52: // v
380
433
  {
381
- monaco .require (["vs/editor/editor.main"], monaco =>
382
- {
383
- const element = $("<div></div>")
384
- .addClass ("script-editor-monaco")
385
- .appendTo (this .verticalSplitterRight);
386
-
387
- self .MonacoEnvironment =
388
- {
389
- getWorkerUrl (moduleId, label)
390
- {
391
- return url .pathToFileURL (require .resolve ("monaco-editor/min/vs/base/worker/workerMain.js"));
392
- },
393
- };
394
-
395
- const editor = monaco .editor .create (element .get (0),
396
- {
397
- language: this .languages [node .getTypeName ()],
398
- contextmenu: false,
399
- automaticLayout: true,
400
- wordWrap: "on",
401
- wrappingIndent: "indent",
402
- minimap: { enabled: false },
403
- bracketPairColorization: { enabled: true },
404
- });
405
-
406
- editor .onDidFocusEditorWidget (() => this .setDeclarations (monaco));
407
- editor .onDidBlurEditorWidget (() => this .apply ());
408
-
409
- editor .onKeyDown ((event) =>
410
- {
411
- const { keyCode, ctrlKey, metaKey } = event;
412
-
413
- if (keyCode === 52 && (metaKey || ctrlKey))
414
- {
415
- event .preventDefault ();
416
- this .paste ();
417
- }
418
- });
419
-
420
- editor .viewState = editor .saveViewState ();
421
-
422
- element .on ("mouseenter", () => this .setDeclarations (monaco))
423
- element .on ("contextmenu", () => this .showContextMenu ());
424
- element .detach ();
425
-
426
- // this .debugFindActions (editor)
427
- this .editors .set (node, { element, editor, monaco });
428
-
429
- // Return editor.
430
-
431
- resolve (this .editors .get (node));
432
- });
434
+ if (!(metaKey || ctrlKey))
435
+ break;
436
+
437
+ event .preventDefault ();
438
+ event .stopPropagation ();
439
+ this .paste ();
440
+ break;
433
441
  }
434
- });
442
+ case 54: // x
443
+ {
444
+ if (!(metaKey || ctrlKey))
445
+ break;
446
+
447
+ event .preventDefault ();
448
+ event .stopPropagation ();
449
+ this .cutOrCopy ("cut");
450
+ break;
451
+ }
452
+ }
435
453
  }
436
454
 
437
- showContextMenu ()
455
+ async showContextMenu ()
438
456
  {
457
+ await $.sleep ();
458
+
459
+ const app = require ("../Application/Window");
460
+
461
+ if (!app .activeElementIsMonacoEditor ())
462
+ return;
463
+
439
464
  const menu = [
440
465
  // {
441
466
  // label: _("Go to Definition"),
@@ -478,14 +503,17 @@ module .exports = class ScriptEditor extends Interface
478
503
  { type: "separator" },
479
504
  {
480
505
  label: _("Cut"),
481
- args: ["cutOrCopy", true],
506
+ accelerator: "CmdOrCtrl+X",
507
+ args: ["cutOrCopy", "cut"],
482
508
  },
483
509
  {
484
510
  label: _("Copy"),
485
- args: ["cutOrCopy", false],
511
+ accelerator: "CmdOrCtrl+C",
512
+ args: ["cutOrCopy", "copy"],
486
513
  },
487
514
  {
488
515
  label: _("Paste"),
516
+ accelerator: "CmdOrCtrl+V",
489
517
  args: ["paste"],
490
518
  },
491
519
  { type: "separator" },
@@ -503,6 +531,16 @@ module .exports = class ScriptEditor extends Interface
503
531
  this .editor .getAction (id) .run ();
504
532
  }
505
533
 
534
+ triggerEvent (... args)
535
+ {
536
+ this .editor .trigger (... args);
537
+ }
538
+
539
+ // execCommand (command)
540
+ // {
541
+ // document .execCommand (command);
542
+ // }
543
+
506
544
  debugFindActions (editor = this .editor)
507
545
  {
508
546
  for (const action of editor .getSupportedActions ())
@@ -552,12 +590,7 @@ module .exports = class ScriptEditor extends Interface
552
590
  }
553
591
  }
554
592
 
555
- // execCommand (command)
556
- // {
557
- // document .execCommand (command);
558
- // }
559
-
560
- cutOrCopy (cut)
593
+ cutOrCopy (type)
561
594
  {
562
595
  this .editor .focus ();
563
596
 
@@ -576,7 +609,7 @@ module .exports = class ScriptEditor extends Interface
576
609
  // Set the clipboard contents.
577
610
  navigator .clipboard .writeText (data || "");
578
611
 
579
- if (!cut)
612
+ if (type === "copy")
580
613
  return;
581
614
 
582
615
  // This is a cut operation, so replace the selection with an empty string.
@@ -476,8 +476,8 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
476
476
  </html>`
477
477
  }
478
478
 
479
- static absoluteURL = new RegExp ("^(?:[a-z]+:|//)", "i")
480
- static fontFamilies = new Set (["SERIF", "SANS", "TYPEWRITER"])
479
+ static absoluteURL = new RegExp ("^(?:[a-z]+:|//)", "i");
480
+ static fontFamilies = new Set (["SERIF", "SANS", "TYPEWRITER"]);
481
481
 
482
482
  /**
483
483
  *
@@ -3448,7 +3448,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3448
3448
 
3449
3449
  const nodesToRemove = this .#nodesToRemove .get (executionContext);
3450
3450
 
3451
- for (const node of nodes)
3451
+ for (const node of nodes .filter (node => node))
3452
3452
  nodesToRemove .push (node .valueOf ());
3453
3453
 
3454
3454
  if (undoManager .defer ("removeNodesFromExecutionContextIfNecessary"))
@@ -0,0 +1,81 @@
1
+ Windows Registry Editor Version 5.00
2
+
3
+ [HKEY_CURRENT_USER\Software\Classes\.x3d\OpenWithProgids]
4
+ "Sunrize.x3d"=""
5
+
6
+ [HKEY_CURRENT_USER\Software\Classes\.x3dz\OpenWithProgids]
7
+ "Sunrize.x3dz"=""
8
+
9
+ [HKEY_CURRENT_USER\Software\Classes\.x3dv\OpenWithProgids]
10
+ "Sunrize.x3dv"=""
11
+
12
+ [HKEY_CURRENT_USER\Software\Classes\.x3dvz\OpenWithProgids]
13
+ "Sunrize.x3dvz"=""
14
+
15
+ [HKEY_CURRENT_USER\Software\Classes\.x3dj\OpenWithProgids]
16
+ "Sunrize.x3dj"=""
17
+
18
+ [HKEY_CURRENT_USER\Software\Classes\.x3djz\OpenWithProgids]
19
+ "Sunrize.x3djz"=""
20
+
21
+ [HKEY_CURRENT_USER\Software\Classes\.wrl\OpenWithProgids]
22
+ "Sunrize.wrl"=""
23
+
24
+ [HKEY_CURRENT_USER\Software\Classes\.wrz\OpenWithProgids]
25
+ "Sunrize.wrz"=""
26
+
27
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3d]
28
+ @="Sunrize X3D XML File"
29
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3d\DefaultIcon]
30
+ @="\"SUNRIZE_EXE\",0"
31
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3d\shell\open\command]
32
+ @="\"SUNRIZE_EXE\" \"%1\""
33
+
34
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dz]
35
+ @="Sunrize X3D XML File"
36
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dz\DefaultIcon]
37
+ @="\"SUNRIZE_EXE\",0"
38
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dz\shell\open\command]
39
+ @="\"SUNRIZE_EXE\" \"%1\""
40
+
41
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dv]
42
+ @="Sunrize X3D Classic VRML File"
43
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dv\DefaultIcon]
44
+ @="\"SUNRIZE_EXE\",0"
45
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dv\shell\open\command]
46
+ @="\"SUNRIZE_EXE\" \"%1\""
47
+
48
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dvz]
49
+ @="Sunrize X3D Classic VRML File"
50
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dvz\DefaultIcon]
51
+ @="\"SUNRIZE_EXE\",0"
52
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dvz\shell\open\command]
53
+ @="\"SUNRIZE_EXE\" \"%1\""
54
+
55
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dj]
56
+ @="Sunrize X3D JSON File"
57
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dj\DefaultIcon]
58
+ @="\"SUNRIZE_EXE\",0"
59
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3dj\shell\open\command]
60
+ @="\"SUNRIZE_EXE\" \"%1\""
61
+
62
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3djz]
63
+ @="Sunrize X3D JSON File"
64
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3djz\DefaultIcon]
65
+ @="\"SUNRIZE_EXE\",0"
66
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.x3djz\shell\open\command]
67
+ @="\"SUNRIZE_EXE\" \"%1\""
68
+
69
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.wrl]
70
+ @="Sunrize VRML File"
71
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.wrl\DefaultIcon]
72
+ @="\"SUNRIZE_EXE\",0"
73
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.wrl\shell\open\command]
74
+ @="\"SUNRIZE_EXE\" \"%1\""
75
+
76
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.wrz]
77
+ @="Sunrize VRML File"
78
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.wrz\DefaultIcon]
79
+ @="\"SUNRIZE_EXE\",0"
80
+ [HKEY_CURRENT_USER\Software\Classes\Sunrize.wrz\shell\open\command]
81
+ @="\"SUNRIZE_EXE\" \"%1\""
@@ -7,12 +7,29 @@
7
7
  <body>
8
8
  <tab-group sortable="true">
9
9
  <style>
10
+ ::-webkit-scrollbar {
11
+ width: 8px;
12
+ height: 8px;
13
+ }
14
+
15
+ ::-webkit-scrollbar-track, /* Track */
16
+ ::-webkit-scrollbar-thumb:window-inactive, /* Handle */
17
+ ::-webkit-scrollbar-corner { /* Corner */
18
+ background-color: transparent;
19
+ }
20
+
21
+ /* Handle */
22
+ ::-webkit-scrollbar-thumb {
23
+ background-color: var(--scrollbar-thumb-color);
24
+ }
25
+
10
26
  .etabs .nav {
11
27
  height: var(--window-tabs-height);
12
28
  background: var(--background-color);
13
29
  box-shadow: none;
14
30
  border: none;
15
- overflow: auto;
31
+ overflow-x: auto;
32
+ overflow-y: hidden;
16
33
  white-space: nowrap;
17
34
  }
18
35
 
@@ -4,7 +4,6 @@
4
4
  <link rel="stylesheet" type="text/css" href="../node_modules/jquery-ui-dist/jquery-ui.min.css"/>
5
5
  <link rel="stylesheet" type="text/css" href="../node_modules/qtip2/dist/jquery.qtip.min.css"/>
6
6
  <link rel="stylesheet" type="text/css" href="../themes/default.css"/>
7
- <link rel="stylesheet" data-name="vs/editor/editor.main" href="../node_modules/monaco-editor/min/vs/editor/editor.main.css">
8
7
  </head>
9
8
  <body>
10
9
  <div id="vertical-splitter" class="vertical-splitter">
Binary file