Commit 96e4b460bf6e0cfb68ca48b1201720372dafa6fe

Authored by 张 峰林
Committed by xp.Huang
1 parent ba503b7b

perf: 升级支持javascript和tbel,并优化脚本使用

Too many changes to show.

To preserve performance only 7 of 39 files are displayed.

... ... @@ -27,6 +27,7 @@
27 27 "SCADA",
28 28 "SMTPS",
29 29 "SNMP",
  30 + "Tbel",
30 31 "TSLV",
31 32 "UNACK",
32 33 "UNINT",
... ...
... ... @@ -2,18 +2,27 @@ import { DeviceTypeEnum } from './deviceModel';
2 2
3 3 export interface ImportDeviceParams {
4 4 file: string;
5   - tkDeviceProfileId: string;
6   - tbDeviceProfileId: string;
7   - organizationId: string;
8   - deviceTypeEnum: DeviceTypeEnum;
  5 + tkDeviceProfileId?: string;
  6 + tbDeviceProfileId?: string;
  7 + organizationId?: string;
  8 + deviceTypeEnum?: DeviceTypeEnum;
  9 + gateWayTbDeviceId?: string;
  10 + isTcpDeviceProfile?: boolean;
9 11 mapping: {
10 12 columns: Record<'type', string>[];
11 13 delimiter: string;
12 14 header: boolean;
13 15 update: boolean;
14 16 };
15   - gateWayTbDeviceId: string;
16   - isTcpDeviceProfile: boolean;
  17 +
  18 + tkDeviceMapping: {
  19 + tkDeviceProfileId: string;
  20 + tbDeviceProfileId: string;
  21 + organizationId: string;
  22 + deviceTypeEnum: DeviceTypeEnum;
  23 + gateWayTbDeviceId?: string;
  24 + isTcpDeviceProfile: boolean;
  25 + };
17 26 }
18 27
19 28 export interface ImportDeviceResponse {
... ...
1 1 import { DeviceInfoItemType, DeviceTypeItem, PageParams, ScriptTestParams } from './model';
2 2 import { TBPaginationResult } from '/#/axios';
  3 +import { ScriptLanguageEnum } from '/@/enums/scriptEnum';
3 4 import { defHttp } from '/@/utils/http/axios';
4 5
5 6 enum Api {
... ... @@ -144,10 +145,13 @@ export const getEntityEdge = (params: PageParams) => {
144 145 );
145 146 };
146 147
147   -export const testScript = (data: ScriptTestParams) => {
  148 +export const testScript = (
  149 + data: ScriptTestParams,
  150 + scriptLang: ScriptLanguageEnum = ScriptLanguageEnum.JavaScript
  151 +) => {
148 152 return defHttp.post<Record<'error' | 'output', string>>(
149 153 {
150   - url: Api.TEST_SCRIPT,
  154 + url: `${Api.TEST_SCRIPT}?scriptLang=${scriptLang}`,
151 155 data,
152 156 },
153 157 { joinPrefix: false }
... ...
... ... @@ -60,4 +60,5 @@ export interface ScriptTestParams {
60 60 msgType?: string;
61 61 script?: string;
62 62 scriptType?: string;
  63 + needMetadataAndMsgType?: boolean;
63 64 }
... ...
1 1 import { BasicPageParams } from '/@/api/model/baseModel';
  2 +import { ScriptLanguageEnum } from '/@/enums/scriptEnum';
2 3 export type ScriptQueryParam = BasicPageParams & ScriptParam;
3 4
4 5 export type ScriptParam = {
... ... @@ -32,3 +33,29 @@ export interface ScriptRecord {
32 33 dataType: string;
33 34 saveOriginalData: boolean;
34 35 }
  36 +
  37 +export interface TransportScriptParamsType {
  38 + id?: string;
  39 + convertJs?: string;
  40 + convertTbel?: string;
  41 + description?: string;
  42 + name: string;
  43 + scriptLanguage: ScriptLanguageEnum;
  44 + status: number;
  45 + serviceType?: string;
  46 +}
  47 +
  48 +export interface TransportScriptRecordType {
  49 + id: string;
  50 + creator: string;
  51 + createTime: string;
  52 + name: string;
  53 + tenantId: string;
  54 + description: string;
  55 + convertTbel?: string;
  56 + scriptLanguage: string;
  57 + status: number;
  58 + convertJs?: string;
  59 + serviceType?: string;
  60 + saveOriginalData: boolean;
  61 +}
... ...
1   -import { defHttp } from '/@/utils/http/axios';
2   -import { ScriptParam, ScriptQueryParam, ScriptRecord } from './model/scriptModel';
3   -import { PaginationResult } from '/#/axios';
4   -
5   -enum ScriptManagerApi {
6   - SCRIPT_POST_URL = '/js',
7   - SCRIPT_GET_URL = '/js',
8   - SCRIPT_DELETE_URL = '/js',
9   - SCRIPT_MELIST_URL = '/js/me/list',
10   - SCRIPT_TEST_URL = '/js/test',
11   - SCRIPT_STATUS = '/js',
12   -}
13   -
14   -export const ScriptPage = (params: ScriptQueryParam) => {
15   - return defHttp.get<PaginationResult<ScriptRecord>>({
16   - url: ScriptManagerApi.SCRIPT_GET_URL,
17   - params,
18   - });
19   -};
20   -
21   -/**
22   - * 改变转换函数状态
23   - * @param params id status
24   - */
25   -export const scriptPagePutApi = (id, status) =>
26   - defHttp.post({
27   - url: ScriptManagerApi.SCRIPT_STATUS + '/' + id + '/' + status,
28   - });
29   -
30   -//删除脚本
31   -export const deleteScriptManage = (ids: string[]) => {
32   - return defHttp.delete({
33   - url: ScriptManagerApi.SCRIPT_DELETE_URL,
34   - data: {
35   - ids: ids,
36   - },
37   - });
38   -};
39   -
40   -// 创建或编辑脚本
41   -export const createOrEditScriptManage = (data) => {
42   - return defHttp.post<ScriptParam>({
43   - url: ScriptManagerApi.SCRIPT_POST_URL,
44   - data,
45   - });
46   -};
47   -
48   -// 查询脚本详情
49   -export const getScriptManageDetail = (id: string) => {
50   - return defHttp.get({
51   - url: ScriptManagerApi.SCRIPT_GET_URL + `/${id}`,
52   - });
53   -};
54   -
55   -// 获取脚本选项列表
56   -export const getScriptManageMeList = (params) => {
57   - return defHttp.get<ScriptRecord[]>({
58   - url: ScriptManagerApi.SCRIPT_MELIST_URL,
59   - params,
60   - });
61   -};
62   -
63   -// 测试脚本执行结果
64   -export const testScriptManage = (data) => {
65   - return defHttp.post<ScriptParam>({
66   - url: ScriptManagerApi.SCRIPT_TEST_URL,
67   - data,
68   - });
69   -};
  1 +import { defHttp } from '/@/utils/http/axios';
  2 +import {
  3 + ScriptParam,
  4 + ScriptQueryParam,
  5 + ScriptRecord,
  6 + TransportScriptParamsType,
  7 +} from './model/scriptModel';
  8 +import { PaginationResult } from '/#/axios';
  9 +
  10 +enum ScriptManagerApi {
  11 + SCRIPT_POST_URL = '/js',
  12 + SCRIPT_GET_URL = '/js',
  13 + SCRIPT_DELETE_URL = '/js',
  14 + SCRIPT_MELIST_URL = '/js/me/list',
  15 + SCRIPT_TEST_URL = '/js/test',
  16 + SCRIPT_STATUS = '/js',
  17 +}
  18 +
  19 +export const ScriptPage = (params: ScriptQueryParam) => {
  20 + return defHttp.get<PaginationResult<ScriptRecord>>({
  21 + url: ScriptManagerApi.SCRIPT_GET_URL,
  22 + params,
  23 + });
  24 +};
  25 +
  26 +/**
  27 + * 改变转换函数状态
  28 + * @param params id status
  29 + */
  30 +export const scriptPagePutApi = (id, status) =>
  31 + defHttp.post({
  32 + url: ScriptManagerApi.SCRIPT_STATUS + '/' + id + '/' + status,
  33 + });
  34 +
  35 +//删除脚本
  36 +export const deleteScriptManage = (ids: string[]) => {
  37 + return defHttp.delete({
  38 + url: ScriptManagerApi.SCRIPT_DELETE_URL,
  39 + data: {
  40 + ids: ids,
  41 + },
  42 + });
  43 +};
  44 +
  45 +// 创建或编辑脚本
  46 +export const createOrEditScriptManage = (data: TransportScriptParamsType) => {
  47 + return defHttp.post<ScriptParam>({
  48 + url: ScriptManagerApi.SCRIPT_POST_URL,
  49 + data,
  50 + });
  51 +};
  52 +
  53 +// 查询脚本详情
  54 +export const getScriptManageDetail = (id: string) => {
  55 + return defHttp.get({
  56 + url: ScriptManagerApi.SCRIPT_GET_URL + `/${id}`,
  57 + });
  58 +};
  59 +
  60 +// 获取脚本选项列表
  61 +export const getScriptManageMeList = (params) => {
  62 + return defHttp.get<ScriptRecord[]>({
  63 + url: ScriptManagerApi.SCRIPT_MELIST_URL,
  64 + params,
  65 + });
  66 +};
  67 +
  68 +// 测试脚本执行结果
  69 +export const testScriptManage = (data) => {
  70 + return defHttp.post<ScriptParam>({
  71 + url: ScriptManagerApi.SCRIPT_TEST_URL,
  72 + data,
  73 + });
  74 +};
... ...
  1 +/*
  2 + * Copyright © 2016-2023 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  17 +"use strict";
  18 +
  19 +var oop = require("../lib/oop");
  20 +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  21 +
  22 +var DocCommentHighlightRules = function() {
  23 + this.$rules = {
  24 + "start" : [ {
  25 + token : "comment.doc.tag",
  26 + regex : "@[\\w\\d_]+" // TODO: fix email addresses
  27 + },
  28 + DocCommentHighlightRules.getTagRule(),
  29 + {
  30 + defaultToken : "comment.doc",
  31 + caseInsensitive: true
  32 + }]
  33 + };
  34 +};
  35 +
  36 +oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  37 +
  38 +DocCommentHighlightRules.getTagRule = function(start) {
  39 + return {
  40 + token : "comment.doc.tag.storage.type",
  41 + regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  42 + };
  43 +};
  44 +
  45 +DocCommentHighlightRules.getStartRule = function(start) {
  46 + return {
  47 + token : "comment.doc", // doc comment
  48 + regex : "\\/\\*(?=\\*)",
  49 + next : start
  50 + };
  51 +};
  52 +
  53 +DocCommentHighlightRules.getEndRule = function (start) {
  54 + return {
  55 + token : "comment.doc", // closing comment
  56 + regex : "\\*\\/",
  57 + next : start
  58 + };
  59 +};
  60 +
  61 +
  62 +exports.DocCommentHighlightRules = DocCommentHighlightRules;
  63 +
  64 +});
  65 +
  66 +ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
  67 +"use strict";
  68 +
  69 +var oop = require("../lib/oop");
  70 +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  71 +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  72 +var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
  73 +
  74 +var JavaScriptHighlightRules = function(options) {
  75 + var keywordMapper = this.createKeywordMapper({
  76 + "variable.language":
  77 + "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  78 + "Namespace|QName|XML|XMLList|" + // E4X
  79 + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  80 + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  81 + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  82 + "SyntaxError|TypeError|URIError|" +
  83 + "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  84 + "isNaN|parseFloat|parseInt|" +
  85 + "JSON|Math|" + // Other
  86 + "this|arguments|prototype|window|document" , // Pseudo
  87 + "keyword":
  88 + "const|yield|import|get|set|async|await|" +
  89 + "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  90 + "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  91 + "__parent__|__count__|escape|unescape|with|__proto__|" +
  92 + "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  93 + "storage.type":
  94 + "const|let|var|function",
  95 + "constant.language":
  96 + "null|Infinity|NaN|undefined",
  97 + "support.function":
  98 + "alert",
  99 + "constant.language.boolean": "true|false"
  100 + }, "identifier");
  101 + var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  102 +
  103 + var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  104 + "u[0-9a-fA-F]{4}|" + // unicode
  105 + "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  106 + "[0-2][0-7]{0,2}|" + // oct
  107 + "3[0-7][0-7]?|" + // oct
  108 + "[4-7][0-7]?|" + //oct
  109 + ".)";
  110 +
  111 + this.$rules = {
  112 + "no_regex" : [
  113 + DocCommentHighlightRules.getStartRule("doc-start"),
  114 + comments("no_regex"),
  115 + {
  116 + token : "string",
  117 + regex : "'(?=.)",
  118 + next : "qstring"
  119 + }, {
  120 + token : "string",
  121 + regex : '"(?=.)',
  122 + next : "qqstring"
  123 + }, {
  124 + token : "constant.numeric", // hexadecimal, octal and binary
  125 + regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  126 + }, {
  127 + token : "constant.numeric", // decimal integers and floats
  128 + regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
  129 + }, {
  130 + token : [
  131 + "storage.type", "punctuation.operator", "support.function",
  132 + "punctuation.operator", "entity.name.function", "text","keyword.operator"
  133 + ],
  134 + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
  135 + next: "function_arguments"
  136 + }, {
  137 + token : [
  138 + "storage.type", "punctuation.operator", "entity.name.function", "text",
  139 + "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  140 + ],
  141 + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  142 + next: "function_arguments"
  143 + }, {
  144 + token : [
  145 + "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  146 + "text", "paren.lparen"
  147 + ],
  148 + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  149 + next: "function_arguments"
  150 + }, {
  151 + token : [
  152 + "storage.type", "punctuation.operator", "entity.name.function", "text",
  153 + "keyword.operator", "text",
  154 + "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  155 + ],
  156 + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  157 + next: "function_arguments"
  158 + }, {
  159 + token : [
  160 + "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  161 + ],
  162 + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  163 + next: "function_arguments"
  164 + }, {
  165 + token : [
  166 + "entity.name.function", "text", "punctuation.operator",
  167 + "text", "storage.type", "text", "paren.lparen"
  168 + ],
  169 + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  170 + next: "function_arguments"
  171 + }, {
  172 + token : [
  173 + "text", "text", "storage.type", "text", "paren.lparen"
  174 + ],
  175 + regex : "(:)(\\s*)(function)(\\s*)(\\()",
  176 + next: "function_arguments"
  177 + }, {
  178 + token : "keyword",
  179 + regex : "from(?=\\s*('|\"))"
  180 + }, {
  181 + token : "keyword",
  182 + regex : "(?:" + kwBeforeRe + ")\\b",
  183 + next : "start"
  184 + }, {
  185 + token : ["support.constant"],
  186 + regex : /that\b/
  187 + }, {
  188 + token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  189 + regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  190 + }, {
  191 + token : keywordMapper,
  192 + regex : identifierRe
  193 + }, {
  194 + token : "punctuation.operator",
  195 + regex : /[.](?![.])/,
  196 + next : "property"
  197 + }, {
  198 + token : "storage.type",
  199 + regex : /=>/,
  200 + next : "start"
  201 + }, {
  202 + token : "keyword.operator",
  203 + regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  204 + next : "start"
  205 + }, {
  206 + token : "punctuation.operator",
  207 + regex : /[?:,;.]/,
  208 + next : "start"
  209 + }, {
  210 + token : "paren.lparen",
  211 + regex : /[\[({]/,
  212 + next : "start"
  213 + }, {
  214 + token : "paren.rparen",
  215 + regex : /[\])}]/
  216 + }, {
  217 + token: "comment",
  218 + regex: /^#!.*$/
  219 + }
  220 + ],
  221 + property: [{
  222 + token : "text",
  223 + regex : "\\s+"
  224 + }, {
  225 + token : [
  226 + "storage.type", "punctuation.operator", "entity.name.function", "text",
  227 + "keyword.operator", "text",
  228 + "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  229 + ],
  230 + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
  231 + next: "function_arguments"
  232 + }, {
  233 + token : "punctuation.operator",
  234 + regex : /[.](?![.])/
  235 + }, {
  236 + token : "support.function",
  237 + regex : /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
  238 + }, {
  239 + token : "support.function.dom",
  240 + regex : /(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
  241 + }, {
  242 + token : "support.constant",
  243 + regex : /(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
  244 + }, {
  245 + token : "identifier",
  246 + regex : identifierRe
  247 + }, {
  248 + regex: "",
  249 + token: "empty",
  250 + next: "no_regex"
  251 + }
  252 + ],
  253 + "start": [
  254 + DocCommentHighlightRules.getStartRule("doc-start"),
  255 + comments("start"),
  256 + {
  257 + token: "string.regexp",
  258 + regex: "\\/",
  259 + next: "regex"
  260 + }, {
  261 + token : "text",
  262 + regex : "\\s+|^$",
  263 + next : "start"
  264 + }, {
  265 + token: "empty",
  266 + regex: "",
  267 + next: "no_regex"
  268 + }
  269 + ],
  270 + "regex": [
  271 + {
  272 + token: "regexp.keyword.operator",
  273 + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  274 + }, {
  275 + token: "string.regexp",
  276 + regex: "/[sxngimy]*",
  277 + next: "no_regex"
  278 + }, {
  279 + token : "invalid",
  280 + regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  281 + }, {
  282 + token : "constant.language.escape",
  283 + regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  284 + }, {
  285 + token : "constant.language.delimiter",
  286 + regex: /\|/
  287 + }, {
  288 + token: "constant.language.escape",
  289 + regex: /\[\^?/,
  290 + next: "regex_character_class"
  291 + }, {
  292 + token: "empty",
  293 + regex: "$",
  294 + next: "no_regex"
  295 + }, {
  296 + defaultToken: "string.regexp"
  297 + }
  298 + ],
  299 + "regex_character_class": [
  300 + {
  301 + token: "regexp.charclass.keyword.operator",
  302 + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  303 + }, {
  304 + token: "constant.language.escape",
  305 + regex: "]",
  306 + next: "regex"
  307 + }, {
  308 + token: "constant.language.escape",
  309 + regex: "-"
  310 + }, {
  311 + token: "empty",
  312 + regex: "$",
  313 + next: "no_regex"
  314 + }, {
  315 + defaultToken: "string.regexp.charachterclass"
  316 + }
  317 + ],
  318 + "function_arguments": [
  319 + {
  320 + token: "variable.parameter",
  321 + regex: identifierRe
  322 + }, {
  323 + token: "punctuation.operator",
  324 + regex: "[, ]+"
  325 + }, {
  326 + token: "punctuation.operator",
  327 + regex: "$"
  328 + }, {
  329 + token: "empty",
  330 + regex: "",
  331 + next: "no_regex"
  332 + }
  333 + ],
  334 + "qqstring" : [
  335 + {
  336 + token : "constant.language.escape",
  337 + regex : escapedRe
  338 + }, {
  339 + token : "string",
  340 + regex : "\\\\$",
  341 + consumeLineEnd : true
  342 + }, {
  343 + token : "string",
  344 + regex : '"|$',
  345 + next : "no_regex"
  346 + }, {
  347 + defaultToken: "string"
  348 + }
  349 + ],
  350 + "qstring" : [
  351 + {
  352 + token : "constant.language.escape",
  353 + regex : escapedRe
  354 + }, {
  355 + token : "string",
  356 + regex : "\\\\$",
  357 + consumeLineEnd : true
  358 + }, {
  359 + token : "string",
  360 + regex : "'|$",
  361 + next : "no_regex"
  362 + }, {
  363 + defaultToken: "string"
  364 + }
  365 + ]
  366 + };
  367 +
  368 +
  369 + if (!options || !options.noES6) {
  370 + this.$rules.no_regex.unshift({
  371 + regex: "[{}]", onMatch: function(val, state, stack) {
  372 + this.next = val == "{" ? this.nextState : "";
  373 + if (val == "{" && stack.length) {
  374 + stack.unshift("start", state);
  375 + }
  376 + else if (val == "}" && stack.length) {
  377 + stack.shift();
  378 + this.next = stack.shift();
  379 + if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  380 + return "paren.quasi.end";
  381 + }
  382 + return val == "{" ? "paren.lparen" : "paren.rparen";
  383 + },
  384 + nextState: "start"
  385 + }, {
  386 + token : "string.quasi.start",
  387 + regex : /`/,
  388 + push : [{
  389 + token : "constant.language.escape",
  390 + regex : escapedRe
  391 + }, {
  392 + token : "paren.quasi.start",
  393 + regex : /\${/,
  394 + push : "start"
  395 + }, {
  396 + token : "string.quasi.end",
  397 + regex : /`/,
  398 + next : "pop"
  399 + }, {
  400 + defaultToken: "string.quasi"
  401 + }]
  402 + });
  403 +
  404 + if (!options || options.jsx != false)
  405 + JSX.call(this);
  406 + }
  407 +
  408 + this.embedRules(DocCommentHighlightRules, "doc-",
  409 + [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  410 +
  411 + this.normalizeRules();
  412 +};
  413 +
  414 +oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  415 +
  416 +function JSX() {
  417 + var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  418 + var jsxTag = {
  419 + onMatch : function(val, state, stack) {
  420 + var offset = val.charAt(1) == "/" ? 2 : 1;
  421 + if (offset == 1) {
  422 + if (state != this.nextState)
  423 + stack.unshift(this.next, this.nextState, 0);
  424 + else
  425 + stack.unshift(this.next);
  426 + stack[2]++;
  427 + } else if (offset == 2) {
  428 + if (state == this.nextState) {
  429 + stack[1]--;
  430 + if (!stack[1] || stack[1] < 0) {
  431 + stack.shift();
  432 + stack.shift();
  433 + }
  434 + }
  435 + }
  436 + return [{
  437 + type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  438 + value: val.slice(0, offset)
  439 + }, {
  440 + type: "meta.tag.tag-name.xml",
  441 + value: val.substr(offset)
  442 + }];
  443 + },
  444 + regex : "</?" + tagRegex + "",
  445 + next: "jsxAttributes",
  446 + nextState: "jsx"
  447 + };
  448 + this.$rules.start.unshift(jsxTag);
  449 + var jsxJsRule = {
  450 + regex: "{",
  451 + token: "paren.quasi.start",
  452 + push: "start"
  453 + };
  454 + this.$rules.jsx = [
  455 + jsxJsRule,
  456 + jsxTag,
  457 + {include : "reference"},
  458 + {defaultToken: "string"}
  459 + ];
  460 + this.$rules.jsxAttributes = [{
  461 + token : "meta.tag.punctuation.tag-close.xml",
  462 + regex : "/?>",
  463 + onMatch : function(value, currentState, stack) {
  464 + if (currentState == stack[0])
  465 + stack.shift();
  466 + if (value.length == 2) {
  467 + if (stack[0] == this.nextState)
  468 + stack[1]--;
  469 + if (!stack[1] || stack[1] < 0) {
  470 + stack.splice(0, 2);
  471 + }
  472 + }
  473 + this.next = stack[0] || "start";
  474 + return [{type: this.token, value: value}];
  475 + },
  476 + nextState: "jsx"
  477 + },
  478 + jsxJsRule,
  479 + comments("jsxAttributes"),
  480 + {
  481 + token : "entity.other.attribute-name.xml",
  482 + regex : tagRegex
  483 + }, {
  484 + token : "keyword.operator.attribute-equals.xml",
  485 + regex : "="
  486 + }, {
  487 + token : "text.tag-whitespace.xml",
  488 + regex : "\\s+"
  489 + }, {
  490 + token : "string.attribute-value.xml",
  491 + regex : "'",
  492 + stateName : "jsx_attr_q",
  493 + push : [
  494 + {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  495 + {include : "reference"},
  496 + {defaultToken : "string.attribute-value.xml"}
  497 + ]
  498 + }, {
  499 + token : "string.attribute-value.xml",
  500 + regex : '"',
  501 + stateName : "jsx_attr_qq",
  502 + push : [
  503 + {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  504 + {include : "reference"},
  505 + {defaultToken : "string.attribute-value.xml"}
  506 + ]
  507 + },
  508 + jsxTag
  509 + ];
  510 + this.$rules.reference = [{
  511 + token : "constant.language.escape.reference.xml",
  512 + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  513 + }];
  514 +}
  515 +
  516 +function comments(next) {
  517 + return [
  518 + {
  519 + token : "comment", // multi line comment
  520 + regex : /\/\*/,
  521 + next: [
  522 + DocCommentHighlightRules.getTagRule(),
  523 + {token : "comment", regex : "\\*\\/", next : next || "pop"},
  524 + {defaultToken : "comment", caseInsensitive: true}
  525 + ]
  526 + }, {
  527 + token : "comment",
  528 + regex : "\\/\\/",
  529 + next: [
  530 + DocCommentHighlightRules.getTagRule(),
  531 + {token : "comment", regex : "$|^", next : next || "pop"},
  532 + {defaultToken : "comment", caseInsensitive: true}
  533 + ]
  534 + }
  535 + ];
  536 +}
  537 +exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  538 +});
  539 +
  540 +ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  541 +"use strict";
  542 +
  543 +var Range = require("../range").Range;
  544 +
  545 +var MatchingBraceOutdent = function() {};
  546 +
  547 +(function() {
  548 +
  549 + this.checkOutdent = function(line, input) {
  550 + if (! /^\s+$/.test(line))
  551 + return false;
  552 +
  553 + return /^\s*\}/.test(input);
  554 + };
  555 +
  556 + this.autoOutdent = function(doc, row) {
  557 + var line = doc.getLine(row);
  558 + var match = line.match(/^(\s*\})/);
  559 +
  560 + if (!match) return 0;
  561 +
  562 + var column = match[1].length;
  563 + var openBracePos = doc.findMatchingBracket({row: row, column: column});
  564 +
  565 + if (!openBracePos || openBracePos.row == row) return 0;
  566 +
  567 + var indent = this.$getIndent(doc.getLine(openBracePos.row));
  568 + doc.replace(new Range(row, 0, row, column-1), indent);
  569 + };
  570 +
  571 + this.$getIndent = function(line) {
  572 + return line.match(/^\s*/)[0];
  573 + };
  574 +
  575 +}).call(MatchingBraceOutdent.prototype);
  576 +
  577 +exports.MatchingBraceOutdent = MatchingBraceOutdent;
  578 +});
  579 +
  580 +ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  581 +"use strict";
  582 +
  583 +var oop = require("../../lib/oop");
  584 +var Range = require("../../range").Range;
  585 +var BaseFoldMode = require("./fold_mode").FoldMode;
  586 +
  587 +var FoldMode = exports.FoldMode = function(commentRegex) {
  588 + if (commentRegex) {
  589 + this.foldingStartMarker = new RegExp(
  590 + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  591 + );
  592 + this.foldingStopMarker = new RegExp(
  593 + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  594 + );
  595 + }
  596 +};
  597 +oop.inherits(FoldMode, BaseFoldMode);
  598 +
  599 +(function() {
  600 +
  601 + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  602 + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  603 + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  604 + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  605 + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  606 + this._getFoldWidgetBase = this.getFoldWidget;
  607 + this.getFoldWidget = function(session, foldStyle, row) {
  608 + var line = session.getLine(row);
  609 +
  610 + if (this.singleLineBlockCommentRe.test(line)) {
  611 + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  612 + return "";
  613 + }
  614 +
  615 + var fw = this._getFoldWidgetBase(session, foldStyle, row);
  616 +
  617 + if (!fw && this.startRegionRe.test(line))
  618 + return "start"; // lineCommentRegionStart
  619 +
  620 + return fw;
  621 + };
  622 +
  623 + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  624 + var line = session.getLine(row);
  625 +
  626 + if (this.startRegionRe.test(line))
  627 + return this.getCommentRegionBlock(session, line, row);
  628 +
  629 + var match = line.match(this.foldingStartMarker);
  630 + if (match) {
  631 + var i = match.index;
  632 +
  633 + if (match[1])
  634 + return this.openingBracketBlock(session, match[1], row, i);
  635 +
  636 + var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  637 +
  638 + if (range && !range.isMultiLine()) {
  639 + if (forceMultiline) {
  640 + range = this.getSectionRange(session, row);
  641 + } else if (foldStyle != "all")
  642 + range = null;
  643 + }
  644 +
  645 + return range;
  646 + }
  647 +
  648 + if (foldStyle === "markbegin")
  649 + return;
  650 +
  651 + var match = line.match(this.foldingStopMarker);
  652 + if (match) {
  653 + var i = match.index + match[0].length;
  654 +
  655 + if (match[1])
  656 + return this.closingBracketBlock(session, match[1], row, i);
  657 +
  658 + return session.getCommentFoldRange(row, i, -1);
  659 + }
  660 + };
  661 +
  662 + this.getSectionRange = function(session, row) {
  663 + var line = session.getLine(row);
  664 + var startIndent = line.search(/\S/);
  665 + var startRow = row;
  666 + var startColumn = line.length;
  667 + row = row + 1;
  668 + var endRow = row;
  669 + var maxRow = session.getLength();
  670 + while (++row < maxRow) {
  671 + line = session.getLine(row);
  672 + var indent = line.search(/\S/);
  673 + if (indent === -1)
  674 + continue;
  675 + if (startIndent > indent)
  676 + break;
  677 + var subRange = this.getFoldWidgetRange(session, "all", row);
  678 +
  679 + if (subRange) {
  680 + if (subRange.start.row <= startRow) {
  681 + break;
  682 + } else if (subRange.isMultiLine()) {
  683 + row = subRange.end.row;
  684 + } else if (startIndent == indent) {
  685 + break;
  686 + }
  687 + }
  688 + endRow = row;
  689 + }
  690 +
  691 + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  692 + };
  693 + this.getCommentRegionBlock = function(session, line, row) {
  694 + var startColumn = line.search(/\s*$/);
  695 + var maxRow = session.getLength();
  696 + var startRow = row;
  697 +
  698 + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  699 + var depth = 1;
  700 + while (++row < maxRow) {
  701 + line = session.getLine(row);
  702 + var m = re.exec(line);
  703 + if (!m) continue;
  704 + if (m[1]) depth--;
  705 + else depth++;
  706 +
  707 + if (!depth) break;
  708 + }
  709 +
  710 + var endRow = row;
  711 + if (endRow > startRow) {
  712 + return new Range(startRow, startColumn, endRow, line.length);
  713 + }
  714 + };
  715 +
  716 +}).call(FoldMode.prototype);
  717 +
  718 +});
  719 +
  720 +ace.define("ace/mode/tbel",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
  721 +"use strict";
  722 +
  723 +var oop = require("../lib/oop");
  724 +var TextMode = require("./text").Mode;
  725 +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  726 +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  727 +var WorkerClient = require("../worker/worker_client").WorkerClient;
  728 +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  729 +var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  730 +
  731 +var Mode = function() {
  732 + this.HighlightRules = JavaScriptHighlightRules;
  733 +
  734 + this.$outdent = new MatchingBraceOutdent();
  735 + this.$behaviour = new CstyleBehaviour();
  736 + this.foldingRules = new CStyleFoldMode();
  737 +};
  738 +oop.inherits(Mode, TextMode);
  739 +
  740 +(function() {
  741 +
  742 + this.lineCommentStart = "//";
  743 + this.blockComment = {start: "/*", end: "*/"};
  744 + this.$quotes = {'"': '"', "'": "'", "`": "`"};
  745 +
  746 + this.getNextLineIndent = function(state, line, tab) {
  747 + var indent = this.$getIndent(line);
  748 +
  749 + var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  750 + var tokens = tokenizedLine.tokens;
  751 + var endState = tokenizedLine.state;
  752 +
  753 + if (tokens.length && tokens[tokens.length-1].type == "comment") {
  754 + return indent;
  755 + }
  756 +
  757 + if (state == "start" || state == "no_regex") {
  758 + var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  759 + if (match) {
  760 + indent += tab;
  761 + }
  762 + } else if (state == "doc-start") {
  763 + if (endState == "start" || endState == "no_regex") {
  764 + return "";
  765 + }
  766 + var match = line.match(/^\s*(\/?)\*/);
  767 + if (match) {
  768 + if (match[1]) {
  769 + indent += " ";
  770 + }
  771 + indent += "* ";
  772 + }
  773 + }
  774 +
  775 + return indent;
  776 + };
  777 +
  778 + this.checkOutdent = function(state, line, input) {
  779 + return this.$outdent.checkOutdent(line, input);
  780 + };
  781 +
  782 + this.autoOutdent = function(state, doc, row) {
  783 + this.$outdent.autoOutdent(doc, row);
  784 + };
  785 +
  786 + this.createWorker = function(session) {
  787 + var worker = new WorkerClient(["ace"], "ace/mode/tbel_worker", "TbelWorker");
  788 + worker.attachToDocument(session.getDocument());
  789 +
  790 + worker.on("annotate", function(results) {
  791 + session.setAnnotations(results.data);
  792 + });
  793 +
  794 + worker.on("terminate", function() {
  795 + session.clearAnnotations();
  796 + });
  797 +
  798 + return worker;
  799 + };
  800 +
  801 + this.$id = "ace/mode/tbel";
  802 + this.snippetFileId = "ace/snippets/javascript";
  803 +}).call(Mode.prototype);
  804 +
  805 +exports.Mode = Mode;
  806 +}); (function() {
  807 + ace.require(["ace/mode/tbel"], function(m) {
  808 + if (typeof module == "object" && typeof exports == "object" && module) {
  809 + module.exports = m;
  810 + }
  811 + });
  812 + })();
... ...