motoko 3.0.0-beta5 → 3.0.0-beta6

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/contrib/hljs.js CHANGED
@@ -1,5 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ const { keywords, typeKeywords } = require('../lib/keywords');
4
+
5
+ const literalKeywords = ['true', 'false', 'null'];
6
+
3
7
  /// Highlight.js configuration
4
8
  exports.configure = (hljs) => {
5
9
  var string = {
@@ -25,25 +29,19 @@ exports.configure = (hljs) => {
25
29
  ],
26
30
  relevance: 0,
27
31
  };
28
- hljs.registerLanguage('motoko', function (hljs) {
32
+ hljs.registerLanguage('motoko', (hljs) => {
29
33
  return {
30
34
  name: 'Motoko',
31
35
  aliases: ['mo'],
32
36
  keywords: {
33
37
  $pattern: '[a-zA-Z_]\\w*',
34
- keyword:
35
- 'actor and await break case catch class' +
36
- ' continue debug do else for func if in import' +
37
- ' module not object or label let loop private' +
38
- ' public return shared try throw query switch' +
39
- ' type var while stable flexible system debug_show' +
40
- ' assert ignore from_candid to_candid with',
41
- literal: 'true false null',
42
- built_in:
43
- 'Any None Null Bool Int Int8 Int16 Int32 Int64' +
44
- ' Nat Nat8 Nat16 Nat32 Nat64 Word8 Word16 Word32 Word64' +
45
- ' Float Char Text Blob Error Principal' +
46
- ' async',
38
+ keyword: keywords
39
+ .filter(
40
+ (k) => !literalKeywords.includes(k) && k !== 'async',
41
+ )
42
+ .join(' '),
43
+ literal: literalKeywords.join(' '),
44
+ built_in: `async ${typeKeywords.join(' ')}`,
47
45
  },
48
46
  illegal: '</',
49
47
  contains: [
@@ -92,7 +90,7 @@ exports.configure = (hljs) => {
92
90
  ],
93
91
  };
94
92
  });
95
- hljs.registerLanguage('candid', function (hljs) {
93
+ hljs.registerLanguage('candid', (hljs) => {
96
94
  return {
97
95
  name: 'Candid',
98
96
  aliases: ['did'],
package/contrib/monaco.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { keywords, typeKeywords } = require('../lib/keywords');
4
+
3
5
  /// Monaco editor configuration
4
6
  exports.configure = (monaco) => {
5
7
  monaco.languages.register({ id: 'motoko' });
@@ -25,12 +27,7 @@ exports.configure = (monaco) => {
25
27
  defaultToken: '',
26
28
  tokenPostfix: '.mo',
27
29
  // prettier-ignore
28
- keywords: [
29
- 'actor', 'and', 'async', 'assert', 'await', 'break', 'case', 'catch', 'class',
30
- 'continue', 'debug', 'debug_show', 'do', 'else', 'false', 'flexible', 'for', 'from_candid', 'func', 'if', 'ignore', 'in',
31
- 'import', 'label', 'let', 'loop', 'module', 'not', 'null', 'object', 'or', 'private', 'public', 'query', 'return', 'shared',
32
- 'stable', 'switch', 'system', 'throw', 'to_candid', 'true', 'try', 'type', 'var', 'while', 'with',
33
- ],
30
+ keywords,
34
31
  accessmodifiers: [
35
32
  'public',
36
33
  'private',
@@ -41,10 +38,7 @@ exports.configure = (monaco) => {
41
38
  'system',
42
39
  ],
43
40
  // prettier-ignore
44
- typeKeywords: [
45
- 'Any', 'None', 'Null', 'Bool', 'Int', 'Int8', 'Int16', 'Int32', 'Int64', 'Nat',
46
- 'Nat8', 'Nat16', 'Nat32', 'Nat64', 'Float', 'Char', 'Text', 'Blob', 'Error', 'Principal',
47
- ],
41
+ typeKeywords,
48
42
  // prettier-ignore
49
43
  operators: [
50
44
  '=', '<', '>', ':', '<:', '?', '+', '-', '*', '/', '%', '**', '+%', '-%', '*%', '**%', '&', '|', '^', '<<', '>>', '<<>', '<>>',
@@ -0,0 +1,3 @@
1
+ export declare const keywords: string[];
2
+ export declare const typeKeywords: string[];
3
+ //# sourceMappingURL=keywords.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keywords.d.ts","sourceRoot":"","sources":["../src/keywords.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,UAgDpB,CAAC;AAEF,eAAO,MAAM,YAAY,UAqBxB,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typeKeywords = exports.keywords = void 0;
4
+ exports.keywords = [
5
+ 'actor',
6
+ 'and',
7
+ 'async',
8
+ 'assert',
9
+ 'await',
10
+ 'break',
11
+ 'case',
12
+ 'catch',
13
+ 'class',
14
+ 'continue',
15
+ 'debug',
16
+ 'debug_show',
17
+ 'do',
18
+ 'else',
19
+ 'false',
20
+ 'flexible',
21
+ 'for',
22
+ 'from_candid',
23
+ 'func',
24
+ 'if',
25
+ 'ignore',
26
+ 'in',
27
+ 'import',
28
+ 'label',
29
+ 'let',
30
+ 'loop',
31
+ 'module',
32
+ 'not',
33
+ 'null',
34
+ 'object',
35
+ 'or',
36
+ 'private',
37
+ 'public',
38
+ 'query',
39
+ 'return',
40
+ 'shared',
41
+ 'stable',
42
+ 'switch',
43
+ 'system',
44
+ 'throw',
45
+ 'to_candid',
46
+ 'true',
47
+ 'try',
48
+ 'type',
49
+ 'var',
50
+ 'while',
51
+ 'with',
52
+ ];
53
+ exports.typeKeywords = [
54
+ 'Any',
55
+ 'None',
56
+ 'Null',
57
+ 'Bool',
58
+ 'Int',
59
+ 'Int8',
60
+ 'Int16',
61
+ 'Int32',
62
+ 'Int64',
63
+ 'Nat',
64
+ 'Nat8',
65
+ 'Nat16',
66
+ 'Nat32',
67
+ 'Nat64',
68
+ 'Float',
69
+ 'Char',
70
+ 'Text',
71
+ 'Blob',
72
+ 'Error',
73
+ 'Principal',
74
+ ];
75
+ //# sourceMappingURL=keywords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keywords.js","sourceRoot":"","sources":["../src/keywords.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACpB,OAAO;IACP,KAAK;IACL,OAAO;IACP,QAAQ;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,UAAU;IACV,OAAO;IACP,YAAY;IACZ,IAAI;IACJ,MAAM;IACN,OAAO;IACP,UAAU;IACV,KAAK;IACL,aAAa;IACb,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,KAAK;IACL,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,WAAW;IACX,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;CACT,CAAC;AAEW,QAAA,YAAY,GAAG;IACxB,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,WAAW;CACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motoko",
3
- "version": "3.0.0-beta5",
3
+ "version": "3.0.0-beta6",
4
4
  "description": "Compile and run Motoko smart contracts in Node.js or the browser.",
5
5
  "author": "Ryan Vandersmith (https://github.com/rvanasa)",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,72 @@
1
+ export const keywords = [
2
+ 'actor',
3
+ 'and',
4
+ 'async',
5
+ 'assert',
6
+ 'await',
7
+ 'break',
8
+ 'case',
9
+ 'catch',
10
+ 'class',
11
+ 'continue',
12
+ 'debug',
13
+ 'debug_show',
14
+ 'do',
15
+ 'else',
16
+ 'false',
17
+ 'flexible',
18
+ 'for',
19
+ 'from_candid',
20
+ 'func',
21
+ 'if',
22
+ 'ignore',
23
+ 'in',
24
+ 'import',
25
+ 'label',
26
+ 'let',
27
+ 'loop',
28
+ 'module',
29
+ 'not',
30
+ 'null',
31
+ 'object',
32
+ 'or',
33
+ 'private',
34
+ 'public',
35
+ 'query',
36
+ 'return',
37
+ 'shared',
38
+ 'stable',
39
+ 'switch',
40
+ 'system',
41
+ 'throw',
42
+ 'to_candid',
43
+ 'true',
44
+ 'try',
45
+ 'type',
46
+ 'var',
47
+ 'while',
48
+ 'with',
49
+ ];
50
+
51
+ export const typeKeywords = [
52
+ 'Any',
53
+ 'None',
54
+ 'Null',
55
+ 'Bool',
56
+ 'Int',
57
+ 'Int8',
58
+ 'Int16',
59
+ 'Int32',
60
+ 'Int64',
61
+ 'Nat',
62
+ 'Nat8',
63
+ 'Nat16',
64
+ 'Nat32',
65
+ 'Nat64',
66
+ 'Float',
67
+ 'Char',
68
+ 'Text',
69
+ 'Blob',
70
+ 'Error',
71
+ 'Principal',
72
+ ];