sunrize 1.11.3 → 1.11.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sunrize",
3
3
  "productName": "Sunrize X3D Editor",
4
- "version": "1.11.3",
4
+ "version": "1.11.4",
5
5
  "description": "A Multi-Platform X3D Editor",
6
6
  "main": "src/main.js",
7
7
  "bin": {
@@ -91,7 +91,7 @@
91
91
  "@vscode/codicons": "^0.0.41",
92
92
  "capitalize": "^2.0.4",
93
93
  "console": "^0.7.2",
94
- "electron": "^38.4.0",
94
+ "electron": "^39.0.0",
95
95
  "electron-prompt": "^1.7.0",
96
96
  "electron-squirrel-startup": "^1.0.1",
97
97
  "electron-tabs": "^1.0.4",
@@ -110,7 +110,7 @@
110
110
  "string-similarity": "^4.0.4",
111
111
  "tweakpane": "^3.1.10",
112
112
  "update-electron-app": "^3.1.1",
113
- "x_ite": "^12.1.3",
113
+ "x_ite": "^12.1.4",
114
114
  "x3d-traverse": "^1.0.22"
115
115
  }
116
116
  }
@@ -124,7 +124,7 @@ module .exports = class Console extends Interface
124
124
  // Input
125
125
 
126
126
  this .textarea = $("<textarea></textarea>")
127
- .attr ("placeholder", _("Evaluate X3D Script code here, e.g. type `Browser.name`."))
127
+ .attr ("placeholder", _("Evaluate Script node code here, e.g. type `Browser.name`."))
128
128
  .attr ("tabindex", 0)
129
129
  .on ("keydown", event => this .onkeydown (event))
130
130
  .on ("keyup", event => this .onkeyup (event))
@@ -368,6 +368,7 @@ module .exports = class OutlineView extends Interface
368
368
  expandSceneSubtreeComplete (specialElements, elements)
369
369
  {
370
370
  this .requestUpdateRouteGraph ();
371
+ this .updateQtips ();
371
372
 
372
373
  // Reopen externprotos, protos, imported, exported nodes.
373
374
 
@@ -846,7 +847,8 @@ module .exports = class OutlineView extends Interface
846
847
 
847
848
  expandNodeComplete (protos, scenes, elements)
848
849
  {
849
- this .requestUpdateRouteGraph ()
850
+ this .requestUpdateRouteGraph ();
851
+ this .updateQtips ();
850
852
 
851
853
  // Auto expand SFNodes
852
854
 
@@ -854,12 +856,12 @@ module .exports = class OutlineView extends Interface
854
856
  {
855
857
  const
856
858
  element = $(e),
857
- field = this .getField (element)
859
+ field = this .getField (element);
858
860
 
859
861
  if (field .getValue ())
860
862
  {
861
- element .data ("auto-expand", true)
862
- element .jstree ("open_node", element)
863
+ element .data ("auto-expand", true);
864
+ element .jstree ("open_node", element);
863
865
  }
864
866
  }
865
867
 
@@ -869,12 +871,12 @@ module .exports = class OutlineView extends Interface
869
871
  {
870
872
  const
871
873
  element = $(e),
872
- field = this .getField (element)
874
+ field = this .getField (element);
873
875
 
874
876
  if (field .length && field .length <= this .autoExpandMaxChildren)
875
877
  {
876
- element .data ("auto-expand", true)
877
- element .jstree ("open_node", element)
878
+ element .data ("auto-expand", true);
879
+ element .jstree ("open_node", element);
878
880
  }
879
881
  }
880
882
 
@@ -884,11 +886,11 @@ module .exports = class OutlineView extends Interface
884
886
  {
885
887
  const
886
888
  element = $(e),
887
- node = this .getNode (element)
889
+ node = this .getNode (element);
888
890
 
889
891
  if (node .getUserData (_expanded) && element .jstree ("is_closed", element))
890
892
  {
891
- element .jstree ("open_node", element)
893
+ element .jstree ("open_node", element);
892
894
  }
893
895
  }
894
896
 
@@ -898,12 +900,12 @@ module .exports = class OutlineView extends Interface
898
900
  {
899
901
  const
900
902
  element = $(e),
901
- scene = this .getNode (element)
903
+ scene = this .getNode (element);
902
904
 
903
905
  if (scene .getUserData (_expanded) && element .jstree ("is_closed", element))
904
906
  {
905
- element .data ("auto-expand", true)
906
- element .jstree ("open_node", element)
907
+ element .data ("auto-expand", true);
908
+ element .jstree ("open_node", element);
907
909
  }
908
910
  }
909
911
 
@@ -913,12 +915,12 @@ module .exports = class OutlineView extends Interface
913
915
  {
914
916
  const
915
917
  element = $(e),
916
- field = this .getField (element)
918
+ field = this .getField (element);
917
919
 
918
920
  if (field .getUserData (_expanded) && element .jstree ("is_closed", element))
919
921
  {
920
- element .data ("auto-expand", true)
921
- element .jstree ("open_node", element)
922
+ element .data ("auto-expand", true);
923
+ element .jstree ("open_node", element);
922
924
  }
923
925
  }
924
926
  }
@@ -1862,7 +1864,7 @@ module .exports = class OutlineView extends Interface
1862
1864
  {
1863
1865
  const
1864
1866
  name = $(event .currentTarget),
1865
- element = $(event .currentTarget) .closest (".externproto, .proto, .node, .special", this .sceneGraph),
1867
+ element = name .closest (".externproto, .proto, .node, .imported-node, .exported-node", this .sceneGraph),
1866
1868
  node = this .objects .get (parseInt (element .attr ("node-id")));
1867
1869
 
1868
1870
  // Handle NULL node element.
@@ -1878,7 +1880,7 @@ module .exports = class OutlineView extends Interface
1878
1880
  {
1879
1881
  const
1880
1882
  name = $(event .currentTarget),
1881
- element = $(event .currentTarget) .closest (".field, .special", this .sceneGraph),
1883
+ element = name .closest (".field, .special", this .sceneGraph),
1882
1884
  node = this .objects .get (parseInt (element .attr ("node-id"))),
1883
1885
  field = this .objects .get (parseInt (element .attr ("field-id"))),
1884
1886
  fieldElement = X3DUOM .find (`ConcreteNode[name="${node .getTypeName ()}"] field[name="${field .getName ()}"]`);
@@ -2218,6 +2220,7 @@ module .exports = class OutlineView extends Interface
2218
2220
  }
2219
2221
 
2220
2222
  this .requestUpdateRouteGraph ();
2223
+ this .updateQtips ();
2221
2224
  }
2222
2225
 
2223
2226
  expandSFNode (parent, node, field, type, full)
@@ -2299,6 +2302,7 @@ module .exports = class OutlineView extends Interface
2299
2302
  }
2300
2303
 
2301
2304
  this .requestUpdateRouteGraph ();
2305
+ this .updateQtips ();
2302
2306
  }
2303
2307
 
2304
2308
  nodeIcons = new Map ([
@@ -2390,7 +2394,9 @@ module .exports = class OutlineView extends Interface
2390
2394
  // Expand children.
2391
2395
 
2392
2396
  child .show ();
2397
+
2393
2398
  this .requestUpdateRouteGraph ();
2399
+ this .updateQtips ();
2394
2400
  }
2395
2401
 
2396
2402
  onkeydownField (input, event)
@@ -2495,8 +2501,10 @@ module .exports = class OutlineView extends Interface
2495
2501
 
2496
2502
  // Expand children.
2497
2503
 
2498
- child .show ()
2499
- this .requestUpdateRouteGraph ()
2504
+ child .show ();
2505
+
2506
+ this .requestUpdateRouteGraph ();
2507
+ this .updateQtips ();
2500
2508
  }
2501
2509
 
2502
2510
  onkeydownArrayField (textarea, event)
@@ -2905,6 +2913,7 @@ module .exports = class OutlineView extends Interface
2905
2913
  element .jstree ("open_node", element);
2906
2914
 
2907
2915
  this .requestUpdateRouteGraph ();
2916
+ this .updateQtips ();
2908
2917
  }
2909
2918
 
2910
2919
  removeSubtree (element)
@@ -3716,6 +3725,7 @@ module .exports = class OutlineView extends Interface
3716
3725
  onresize ()
3717
3726
  {
3718
3727
  this .requestUpdateRouteGraph ();
3728
+ this .updateQtips ();
3719
3729
  }
3720
3730
 
3721
3731
  addFieldButtons (parent, child, node)
@@ -3819,6 +3829,11 @@ module .exports = class OutlineView extends Interface
3819
3829
  // Update route graph.
3820
3830
  }
3821
3831
 
3832
+ updateQtips ()
3833
+ {
3834
+ this .sceneGraph .find ("[data-hasqtip]") .qtip ?.("reposition");
3835
+ }
3836
+
3822
3837
  onDragStartExternProto () { }
3823
3838
 
3824
3839
  onDragStartProto () { }
@@ -139,6 +139,7 @@ module .exports = class ScriptEditor extends Interface
139
139
 
140
140
  // Setup.
141
141
 
142
+ this .addLanguages ();
142
143
  this .setup ();
143
144
  }
144
145
 
@@ -157,6 +158,178 @@ module .exports = class ScriptEditor extends Interface
157
158
  monaco .editor .setTheme (shouldUseDarkColors ? "vs-dark" : "vs-light");
158
159
  }
159
160
 
161
+ async addLanguages ()
162
+ {
163
+ const monaco = await this .getMonaco ();
164
+
165
+ const conf = {
166
+ comments: {
167
+ lineComment: '//',
168
+ blockComment: ['/*', '*/']
169
+ },
170
+ brackets: [
171
+ ['{', '}'],
172
+ ['[', ']'],
173
+ ['(', ')']
174
+ ],
175
+ autoClosingPairs: [
176
+ { open: '[', close: ']' },
177
+ { open: '{', close: '}' },
178
+ { open: '(', close: ')' },
179
+ { open: "'", close: "'", notIn: ['string', 'comment'] },
180
+ { open: '"', close: '"', notIn: ['string'] }
181
+ ],
182
+ surroundingPairs: [
183
+ { open: '{', close: '}' },
184
+ { open: '[', close: ']' },
185
+ { open: '(', close: ')' },
186
+ { open: '"', close: '"' },
187
+ { open: "'", close: "'" }
188
+ ]
189
+ };
190
+
191
+ const keywords = [
192
+ 'const', 'uniform', 'break', 'continue',
193
+ 'do', 'for', 'while', 'if', 'else', 'switch', 'case', 'in', 'out', 'inout', 'true', 'false',
194
+ 'invariant', 'discard', 'return', 'sampler2D', 'samplerCube', 'sampler3D', 'struct',
195
+ 'radians', 'degrees', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'pow', 'sinh', 'cosh', 'tanh', 'asinh', 'acosh', 'atanh',
196
+ 'exp', 'log', 'exp2', 'log2', 'sqrt', 'inversesqrt', 'abs', 'sign', 'floor', 'ceil', 'round', 'roundEven', 'trunc', 'fract', 'mod', 'modf',
197
+ 'min', 'max', 'clamp', 'mix', 'step', 'smoothstep', 'length', 'distance', 'dot', 'cross ',
198
+ 'determinant', 'inverse', 'normalize', 'faceforward', 'reflect', 'refract', 'matrixCompMult', 'outerProduct', 'transpose', 'lessThan ',
199
+ 'lessThanEqual', 'greaterThan', 'greaterThanEqual', 'equal', 'notEqual', 'any', 'all', 'not', 'packUnorm2x16', 'unpackUnorm2x16', 'packSnorm2x16', 'unpackSnorm2x16', 'packHalf2x16', 'unpackHalf2x16',
200
+ 'dFdx', 'dFdy', 'fwidth', 'textureSize', 'texture', 'textureProj', 'textureLod', 'textureGrad', 'texelFetch', 'texelFetchOffset',
201
+ 'textureProjLod', 'textureLodOffset', 'textureGradOffset', 'textureProjLodOffset', 'textureProjGrad', 'intBitsToFloat', 'uintBitsToFloat', 'floatBitsToInt', 'floatBitsToUint', 'isnan', 'isinf',
202
+ 'vec2', 'vec3', 'vec4', 'ivec2', 'ivec3', 'ivec4', 'uvec2', 'uvec3', 'uvec4', 'bvec2', 'bvec3', 'bvec4',
203
+ 'mat2', 'mat3', 'mat2x2', 'mat2x3', 'mat2x4', 'mat3x2', 'mat3x3', 'mat3x4', 'mat4x2', 'mat4x3', 'mat4x4', 'mat4',
204
+ 'float', 'int', 'uint', 'void', 'bool',
205
+ ];
206
+
207
+ const language = {
208
+ tokenPostfix: '.glsl',
209
+ // Set defaultToken to invalid to see what you do not tokenize yet
210
+ defaultToken: 'invalid',
211
+ keywords,
212
+ operators: [
213
+ '=',
214
+ '>',
215
+ '<',
216
+ '!',
217
+ '~',
218
+ '?',
219
+ ':',
220
+ '==',
221
+ '<=',
222
+ '>=',
223
+ '!=',
224
+ '&&',
225
+ '||',
226
+ '++',
227
+ '--',
228
+ '+',
229
+ '-',
230
+ '*',
231
+ '/',
232
+ '&',
233
+ '|',
234
+ '^',
235
+ '%',
236
+ '<<',
237
+ '>>',
238
+ '>>>',
239
+ '+=',
240
+ '-=',
241
+ '*=',
242
+ '/=',
243
+ '&=',
244
+ '|=',
245
+ '^=',
246
+ '%=',
247
+ '<<=',
248
+ '>>=',
249
+ '>>>='
250
+ ],
251
+ symbols: /[=><!~?:&|+\-*\/\^%]+/,
252
+ escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
253
+ integersuffix: /([uU](ll|LL|l|L)|(ll|LL|l|L)?[uU]?)/,
254
+ floatsuffix: /[fFlL]?/,
255
+ encoding: /u|u8|U|L/,
256
+
257
+ tokenizer: {
258
+ root: [
259
+ // identifiers and keywords
260
+ [
261
+ /[a-zA-Z_]\w*/,
262
+ {
263
+ cases: {
264
+ '@keywords': { token: 'keyword.$0' },
265
+ '@default': 'identifier'
266
+ }
267
+ }
268
+ ],
269
+
270
+ // Preprocessor directive (#define)
271
+ [/^\s*#\s*\w+/, 'keyword.directive'],
272
+
273
+ // Version
274
+ [/#version\s+\d+\s+es/, 'keyword.directive'],
275
+
276
+ // whitespace
277
+ { include: '@whitespace' },
278
+
279
+ // delimiters and operators
280
+ [/[{}()\[\]]/, '@brackets'],
281
+ [/@symbols/, {
282
+ cases: {
283
+ '@operators': 'operator',
284
+ '@default': ''
285
+ }
286
+ }],
287
+
288
+ // numbers
289
+ [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
290
+ [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, 'number.float'],
291
+ [/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/, 'number.hex'],
292
+ [/0[0-7']*[0-7](@integersuffix)/, 'number.octal'],
293
+ [/0[bB][0-1']*[0-1](@integersuffix)/, 'number.binary'],
294
+ [/\d[\d']*\d(@integersuffix)/, 'number'],
295
+ [/\d(@integersuffix)/, 'number'],
296
+
297
+ // delimiter: after number because of .\d floats
298
+ [/[;,.]/, 'delimiter']
299
+ ],
300
+
301
+ comment: [
302
+ [/[^\/*]+/, 'comment'],
303
+ [/\/\*/, 'comment', '@push'],
304
+ ['\\*/', 'comment', '@pop'],
305
+ [/[\/*]/, 'comment']
306
+ ],
307
+
308
+ // Does it have strings?
309
+ string: [
310
+ [/[^\\"]+/, 'string'],
311
+ [/@escapes/, 'string.escape'],
312
+ [/\\./, 'string.escape.invalid'],
313
+ [/"/, {
314
+ token: 'string.quote',
315
+ bracket: '@close',
316
+ next: '@pop'
317
+ }]
318
+ ],
319
+
320
+ whitespace: [
321
+ [/[ \t\r\n]+/, 'white'],
322
+ [/\/\*/, 'comment', '@comment'],
323
+ [/\/\/.*$/, 'comment']
324
+ ]
325
+ }
326
+ };
327
+
328
+ monaco .languages .register ({ id: "glsl" });
329
+ monaco .languages .setMonarchTokensProvider ("glsl", language);
330
+ monaco .languages .setLanguageConfiguration ("glsl", conf);
331
+ }
332
+
160
333
  async setNode (node)
161
334
  {
162
335
  this .directOutputButton .hide ();
@@ -169,7 +342,7 @@ module .exports = class ScriptEditor extends Interface
169
342
  this .node ._loadState .removeFieldCallback (this);
170
343
 
171
344
  for (const field of this .node .getUserDefinedFields ())
172
- field .removeInterest ("setDeclarations", this);
345
+ field .removeInterest ("updateDeclarations", this);
173
346
 
174
347
  switch (this .node .getTypeName ())
175
348
  {
@@ -258,7 +431,7 @@ module .exports = class ScriptEditor extends Interface
258
431
 
259
432
  #declarations;
260
433
 
261
- setDeclarations (monaco)
434
+ updateDeclarations (monaco)
262
435
  {
263
436
  if (!this .node .getType () .includes (X3D .X3DConstants .Script))
264
437
  return;
@@ -362,6 +535,7 @@ module .exports = class ScriptEditor extends Interface
362
535
  declare const X3DField: typeof X3D. X3DField;
363
536
  declare const X3DArrayField: typeof X3D. X3DArrayField;
364
537
  ${Array .from (this .browser .fieldTypes)
538
+ .filter (type => !this .#internalTypes .has (type .type))
365
539
  .map (type => `declare const ${type .typeName}: typeof X3D .${type .typeName};`)
366
540
  .join ("\n")}
367
541
  declare const TRUE: true;
@@ -369,15 +543,15 @@ module .exports = class ScriptEditor extends Interface
369
543
  declare const NULL: null;
370
544
  declare function print (... args: any []): void;
371
545
  ${fields .join ("\n")};
372
- `},
373
- ]);
546
+ `,
547
+ }]);
374
548
  }
375
549
 
376
550
  editors = new Map ();
377
551
 
378
552
  languages = {
379
553
  "Script": "javascript",
380
- "ShaderPart": "c",
554
+ "ShaderPart": "glsl",
381
555
  };
382
556
 
383
557
  async getEditor (node)
@@ -407,11 +581,11 @@ module .exports = class ScriptEditor extends Interface
407
581
 
408
582
  editor .viewState = editor .saveViewState ();
409
583
 
410
- editor .onDidFocusEditorWidget (() => this .setDeclarations (monaco));
584
+ editor .onDidFocusEditorWidget (() => this .updateDeclarations (monaco));
411
585
  editor .onDidBlurEditorWidget (() => this .apply ());
412
586
  editor .onKeyDown (event => this .onKeyDown (event));
413
587
 
414
- element .on ("mouseenter", () => this .setDeclarations (monaco));
588
+ element .on ("mouseenter", () => this .updateDeclarations (monaco));
415
589
  element .on ("contextmenu", () => this .showContextMenu ());
416
590
 
417
591
  // this .debugFindActions (editor)
@@ -795,13 +969,13 @@ main ()
795
969
  case X3D .X3DConstants .SFNode:
796
970
  case X3D .X3DConstants .MFNode:
797
971
  {
798
- field .addInterest ("setDeclarations", this, monaco);
972
+ field .addInterest ("updateDeclarations", this, monaco);
799
973
  break;
800
974
  }
801
975
  }
802
976
  }
803
977
 
804
- this .setDeclarations (monaco);
978
+ this .updateDeclarations (monaco);
805
979
  }
806
980
 
807
981
  toggleDirectOutput ()