@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +183 -183
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +636 -491
  5. package/bin/cli.js +372 -367
  6. package/files/eslintrc.js +57 -0
  7. package/files/prettierrc.js +3 -0
  8. package/lib/babel/cmjs-plugins-presets.js +16 -9
  9. package/lib/babel/es-plugins-presets.js +26 -14
  10. package/lib/common/getEntries.js +31 -22
  11. package/lib/common/getPublicPathConfig.js +27 -13
  12. package/lib/common/index.js +21 -25
  13. package/lib/common/splitChunks.js +62 -53
  14. package/lib/common/templateParameters.js +10 -8
  15. package/lib/configs/jest.config.js +15 -25
  16. package/lib/configs/webpack.component.umd.config.js +31 -37
  17. package/lib/configs/webpack.css.umd.config.js +44 -47
  18. package/lib/configs/webpack.dev.config.js +70 -52
  19. package/lib/configs/webpack.docs.config.js +106 -106
  20. package/lib/configs/webpack.prod.config.js +95 -75
  21. package/lib/hooks/docsProptypeHook.js +32 -38
  22. package/lib/jest/commitedFilesResult.js +103 -74
  23. package/lib/jest/coverageCollector.js +41 -21
  24. package/lib/jest/jsonMaker.js +15 -16
  25. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  26. package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
  27. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  28. package/lib/jest/result.js +90 -45
  29. package/lib/jest/run.js +43 -43
  30. package/lib/jest/setup.js +102 -95
  31. package/lib/loaderUtils/getCSSLoaders.js +21 -22
  32. package/lib/loaderUtils/getDevJsLoaders.js +25 -23
  33. package/lib/loaderUtils/index.js +11 -13
  34. package/lib/loaders/docsLoader.js +15 -15
  35. package/lib/loaders/docsPropsLoader.js +14 -17
  36. package/lib/loaders/fileLoader.js +33 -35
  37. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  38. package/lib/loaders/workerLoader.js +136 -0
  39. package/lib/middlewares/HMRMiddleware.js +54 -45
  40. package/lib/middlewares/SSTMiddleware.js +8 -5
  41. package/lib/pluginUtils/getDevPlugins.js +114 -52
  42. package/lib/pluginUtils/getDocsPlugins.js +25 -29
  43. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  44. package/lib/pluginUtils/getProdPlugins.js +163 -74
  45. package/lib/pluginUtils/getServerPlugins.js +8 -11
  46. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  47. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  48. package/lib/pluginUtils/index.js +36 -43
  49. package/lib/plugins/CdnChangePlugin.js +63 -0
  50. package/lib/plugins/CleanupStatsPlugin.js +18 -32
  51. package/lib/plugins/CustomAttributePlugin.js +79 -0
  52. package/lib/plugins/CustomAttributePlugin.md +35 -0
  53. package/lib/plugins/EFCPlugin.js +185 -0
  54. package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
  55. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  56. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  57. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  58. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  59. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  60. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  61. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  62. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  63. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  64. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  65. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  66. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  67. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  68. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  69. package/lib/plugins/ManifestPlugin.js +52 -63
  70. package/lib/plugins/ModuleStatsPlugin.js +83 -173
  71. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  72. package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
  73. package/lib/plugins/PublicPathChangePlugin.js +175 -284
  74. package/lib/plugins/ReportGeneratePlugin.js +150 -151
  75. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  76. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  77. package/lib/plugins/ServiceWorkerPlugin.js +81 -57
  78. package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
  79. package/lib/plugins/SourceMapHookPlugin.js +21 -33
  80. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  81. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  82. package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
  83. package/lib/plugins/index.js +100 -91
  84. package/lib/plugins/webpackwatchrunplugin.js +18 -30
  85. package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
  86. package/lib/schemas/index.js +336 -81
  87. package/lib/servers/clusterHubServer.js +22 -26
  88. package/lib/servers/docsServer.js +3 -5
  89. package/lib/servers/docsServerCore.js +84 -91
  90. package/lib/servers/helpServer.js +19 -21
  91. package/lib/servers/impactServer.js +99 -92
  92. package/lib/servers/mockserver.js +24 -24
  93. package/lib/servers/scrServer.js +78 -98
  94. package/lib/servers/server.js +101 -122
  95. package/lib/servers/ssServer.js +63 -61
  96. package/lib/sh/pre-commit.sh +34 -34
  97. package/lib/sh/reportPublish.sh +45 -46
  98. package/lib/templates/CoverageScriptTemplate.js +45 -18
  99. package/lib/templates/WMSTemplate.js +17 -18
  100. package/lib/templates/linterConstant.js +6 -4
  101. package/lib/utils/babelPresets.js +12 -5
  102. package/lib/utils/buildstats.html +148 -148
  103. package/lib/utils/clean.js +12 -11
  104. package/lib/utils/copy.js +12 -34
  105. package/lib/utils/copyTimezones.js +9 -16
  106. package/lib/utils/createEventStream.js +24 -19
  107. package/lib/utils/cssClassNameGenerate.js +44 -73
  108. package/lib/utils/cssURLReplacer.js +60 -54
  109. package/lib/utils/dependencyPostPublish.js +20 -19
  110. package/lib/utils/fileUtils.js +66 -54
  111. package/lib/utils/folderIterator.js +20 -21
  112. package/lib/utils/getComponents.js +70 -27
  113. package/lib/utils/getCurrentBranch.js +11 -17
  114. package/lib/utils/getDependenciesImpactList.js +114 -187
  115. package/lib/utils/getHash.js +9 -13
  116. package/lib/utils/getIp.js +9 -9
  117. package/lib/utils/getOptions.js +26 -29
  118. package/lib/utils/getServerURL.js +19 -10
  119. package/lib/utils/index.js +147 -126
  120. package/lib/utils/init.js +2 -2
  121. package/lib/utils/initPreCommitHook.js +40 -32
  122. package/lib/utils/jsonHelper.js +37 -21
  123. package/lib/utils/lint/addScripts.js +27 -0
  124. package/lib/utils/lint/checkExistingConfig.js +67 -0
  125. package/lib/utils/lint/copyConfigs.js +24 -0
  126. package/lib/utils/lint/index.js +54 -0
  127. package/lib/utils/lint/lintScripts.js +11 -0
  128. package/lib/utils/lint/lintSetup.js +31 -0
  129. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  130. package/lib/utils/lint/question.js +30 -0
  131. package/lib/utils/lintReporter.js +70 -56
  132. package/lib/utils/mailSender.js +12 -27
  133. package/lib/utils/pullOrigin.js +21 -18
  134. package/lib/utils/reinstallDependencies.js +76 -85
  135. package/lib/utils/removeAttributes.js +25 -23
  136. package/lib/utils/repoClone.js +47 -45
  137. package/lib/utils/request.js +64 -77
  138. package/lib/utils/resultSchema.json +73 -73
  139. package/lib/utils/rtl.js +22 -29
  140. package/lib/utils/setEnvVariables.js +5 -6
  141. package/lib/utils/ssTestHack.js +21 -19
  142. package/lib/utils/switchBranch.js +21 -20
  143. package/lib/utils/urlConcat.js +22 -0
  144. package/package.json +141 -136
  145. package/templates/app/.eslintrc.js +140 -140
  146. package/templates/app/README.md +12 -12
  147. package/templates/app/app/index.html +24 -24
  148. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  149. package/templates/app/app/properties/i18nkeys.json +3 -3
  150. package/templates/app/docs/all.html +69 -69
  151. package/templates/app/mockapi/index.js +18 -18
  152. package/templates/app/package.json +37 -37
  153. package/templates/app/src/actions/SampleActions/index.js +37 -37
  154. package/templates/app/src/actions/index.js +65 -65
  155. package/templates/app/src/appUrls.js +19 -19
  156. package/templates/app/src/components/Alert/Alert.js +134 -134
  157. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  158. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  159. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  160. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  161. package/templates/app/src/components/Sample/SampleList.js +61 -61
  162. package/templates/app/src/components/Slider/Slider.css +41 -41
  163. package/templates/app/src/components/Slider/Slider.js +55 -55
  164. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  165. package/templates/app/src/containers/AppContainer/index.js +96 -96
  166. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  167. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  168. package/templates/app/src/containers/DevTools/index.js +10 -10
  169. package/templates/app/src/containers/Header/index.js +67 -67
  170. package/templates/app/src/containers/Header/index.module.css +43 -43
  171. package/templates/app/src/containers/Redirect/index.js +63 -63
  172. package/templates/app/src/containers/Redirector/index.js +47 -47
  173. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  174. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  175. package/templates/app/src/historyChange.js +5 -5
  176. package/templates/app/src/index.html +10 -10
  177. package/templates/app/src/index.js +24 -24
  178. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  179. package/templates/app/src/reducers/alertData.js +11 -11
  180. package/templates/app/src/reducers/index.js +6 -6
  181. package/templates/app/src/reducers/samples.js +19 -19
  182. package/templates/app/src/store/configureStore.dev.js +51 -51
  183. package/templates/app/src/store/configureStore.js +5 -5
  184. package/templates/app/src/store/configureStore.prod.js +26 -26
  185. package/templates/app/src/util/Common.js +5 -5
  186. package/templates/app/src/util/RequestAPI.js +132 -132
  187. package/templates/docs/all.html +249 -249
  188. package/templates/docs/component.html +178 -178
  189. package/templates/docs/components.html +221 -221
  190. package/templates/docs/css/b.min.css +6 -6
  191. package/templates/docs/css/component.css +42 -42
  192. package/templates/docs/css/componentTest.css +6 -6
  193. package/templates/docs/css/hopscotch.css +585 -585
  194. package/templates/docs/css/style.css +1022 -1022
  195. package/templates/docs/index.html +1493 -1493
  196. package/templates/docs/js/active-line.js +72 -72
  197. package/templates/docs/js/b.min.js +7 -7
  198. package/templates/docs/js/codemirror.js +9680 -9680
  199. package/templates/docs/js/designTokens.js +334 -334
  200. package/templates/docs/js/j.min.js +4 -4
  201. package/templates/docs/js/javascript.js +874 -874
  202. package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,145 +1,145 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- (function(mod) {
5
- if (typeof exports == "object" && typeof module == "object") // CommonJS
6
- mod(require("../../lib/codemirror"));
7
- else if (typeof define == "function" && define.amd) // AMD
8
- define(["../../lib/codemirror"], mod);
9
- else // Plain browser env
10
- mod(CodeMirror);
11
- })(function(CodeMirror) {
12
- var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
13
- (document.documentMode == null || document.documentMode < 8);
14
-
15
- var Pos = CodeMirror.Pos;
16
-
17
- var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
18
-
19
- function findMatchingBracket(cm, where, config) {
20
- var line = cm.getLineHandle(where.line), pos = where.ch - 1;
21
- var afterCursor = config && config.afterCursor
22
- if (afterCursor == null)
23
- afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
24
-
25
- // A cursor is defined as between two characters, but in in vim command mode
26
- // (i.e. not insert mode), the cursor is visually represented as a
27
- // highlighted box on top of the 2nd character. Otherwise, we allow matches
28
- // from before or after the cursor.
29
- var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
30
- matching[line.text.charAt(++pos)];
31
- if (!match) return null;
32
- var dir = match.charAt(1) == ">" ? 1 : -1;
33
- if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
34
- var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
35
-
36
- var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
37
- if (found == null) return null;
38
- return {from: Pos(where.line, pos), to: found && found.pos,
39
- match: found && found.ch == match.charAt(0), forward: dir > 0};
40
- }
41
-
42
- // bracketRegex is used to specify which type of bracket to scan
43
- // should be a regexp, e.g. /[[\]]/
44
- //
45
- // Note: If "where" is on an open bracket, then this bracket is ignored.
46
- //
47
- // Returns false when no bracket was found, null when it reached
48
- // maxScanLines and gave up
49
- function scanForBracket(cm, where, dir, style, config) {
50
- var maxScanLen = (config && config.maxScanLineLength) || 10000;
51
- var maxScanLines = (config && config.maxScanLines) || 1000;
52
-
53
- var stack = [];
54
- var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
55
- var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
56
- : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
57
- for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
58
- var line = cm.getLine(lineNo);
59
- if (!line) continue;
60
- var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
61
- if (line.length > maxScanLen) continue;
62
- if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
63
- for (; pos != end; pos += dir) {
64
- var ch = line.charAt(pos);
65
- if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
66
- var match = matching[ch];
67
- if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
68
- else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
69
- else stack.pop();
70
- }
71
- }
72
- }
73
- return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
74
- }
75
-
76
- function matchBrackets(cm, autoclear, config) {
77
- // Disable brace matching in long lines, since it'll cause hugely slow updates
78
- var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
79
- var marks = [], ranges = cm.listSelections();
80
- for (var i = 0; i < ranges.length; i++) {
81
- var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
82
- if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
83
- var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
84
- marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
85
- if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
86
- marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
87
- }
88
- }
89
-
90
- if (marks.length) {
91
- // Kludge to work around the IE bug from issue #1193, where text
92
- // input stops going to the textare whever this fires.
93
- if (ie_lt8 && cm.state.focused) cm.focus();
94
-
95
- var clear = function() {
96
- cm.operation(function() {
97
- for (var i = 0; i < marks.length; i++) marks[i].clear();
98
- });
99
- };
100
- if (autoclear) setTimeout(clear, 800);
101
- else return clear;
102
- }
103
- }
104
-
105
- function doMatchBrackets(cm) {
106
- cm.operation(function() {
107
- if (cm.state.matchBrackets.currentlyHighlighted) {
108
- cm.state.matchBrackets.currentlyHighlighted();
109
- cm.state.matchBrackets.currentlyHighlighted = null;
110
- }
111
- cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
112
- });
113
- }
114
-
115
- CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
116
- if (old && old != CodeMirror.Init) {
117
- cm.off("cursorActivity", doMatchBrackets);
118
- if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
119
- cm.state.matchBrackets.currentlyHighlighted();
120
- cm.state.matchBrackets.currentlyHighlighted = null;
121
- }
122
- }
123
- if (val) {
124
- cm.state.matchBrackets = typeof val == "object" ? val : {};
125
- cm.on("cursorActivity", doMatchBrackets);
126
- }
127
- });
128
-
129
- CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
130
- CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
131
- // Backwards-compatibility kludge
132
- if (oldConfig || typeof config == "boolean") {
133
- if (!oldConfig) {
134
- config = config ? {strict: true} : null
135
- } else {
136
- oldConfig.strict = config
137
- config = oldConfig
138
- }
139
- }
140
- return findMatchingBracket(this, pos, config)
141
- });
142
- CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
143
- return scanForBracket(this, pos, dir, style, config);
144
- });
145
- });
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
13
+ (document.documentMode == null || document.documentMode < 8);
14
+
15
+ var Pos = CodeMirror.Pos;
16
+
17
+ var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
18
+
19
+ function findMatchingBracket(cm, where, config) {
20
+ var line = cm.getLineHandle(where.line), pos = where.ch - 1;
21
+ var afterCursor = config && config.afterCursor
22
+ if (afterCursor == null)
23
+ afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
24
+
25
+ // A cursor is defined as between two characters, but in in vim command mode
26
+ // (i.e. not insert mode), the cursor is visually represented as a
27
+ // highlighted box on top of the 2nd character. Otherwise, we allow matches
28
+ // from before or after the cursor.
29
+ var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
30
+ matching[line.text.charAt(++pos)];
31
+ if (!match) return null;
32
+ var dir = match.charAt(1) == ">" ? 1 : -1;
33
+ if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
34
+ var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
35
+
36
+ var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
37
+ if (found == null) return null;
38
+ return {from: Pos(where.line, pos), to: found && found.pos,
39
+ match: found && found.ch == match.charAt(0), forward: dir > 0};
40
+ }
41
+
42
+ // bracketRegex is used to specify which type of bracket to scan
43
+ // should be a regexp, e.g. /[[\]]/
44
+ //
45
+ // Note: If "where" is on an open bracket, then this bracket is ignored.
46
+ //
47
+ // Returns false when no bracket was found, null when it reached
48
+ // maxScanLines and gave up
49
+ function scanForBracket(cm, where, dir, style, config) {
50
+ var maxScanLen = (config && config.maxScanLineLength) || 10000;
51
+ var maxScanLines = (config && config.maxScanLines) || 1000;
52
+
53
+ var stack = [];
54
+ var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
55
+ var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
56
+ : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
57
+ for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
58
+ var line = cm.getLine(lineNo);
59
+ if (!line) continue;
60
+ var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
61
+ if (line.length > maxScanLen) continue;
62
+ if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
63
+ for (; pos != end; pos += dir) {
64
+ var ch = line.charAt(pos);
65
+ if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
66
+ var match = matching[ch];
67
+ if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
68
+ else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
69
+ else stack.pop();
70
+ }
71
+ }
72
+ }
73
+ return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
74
+ }
75
+
76
+ function matchBrackets(cm, autoclear, config) {
77
+ // Disable brace matching in long lines, since it'll cause hugely slow updates
78
+ var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
79
+ var marks = [], ranges = cm.listSelections();
80
+ for (var i = 0; i < ranges.length; i++) {
81
+ var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
82
+ if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
83
+ var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
84
+ marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
85
+ if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
86
+ marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
87
+ }
88
+ }
89
+
90
+ if (marks.length) {
91
+ // Kludge to work around the IE bug from issue #1193, where text
92
+ // input stops going to the textare whever this fires.
93
+ if (ie_lt8 && cm.state.focused) cm.focus();
94
+
95
+ var clear = function() {
96
+ cm.operation(function() {
97
+ for (var i = 0; i < marks.length; i++) marks[i].clear();
98
+ });
99
+ };
100
+ if (autoclear) setTimeout(clear, 800);
101
+ else return clear;
102
+ }
103
+ }
104
+
105
+ function doMatchBrackets(cm) {
106
+ cm.operation(function() {
107
+ if (cm.state.matchBrackets.currentlyHighlighted) {
108
+ cm.state.matchBrackets.currentlyHighlighted();
109
+ cm.state.matchBrackets.currentlyHighlighted = null;
110
+ }
111
+ cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
112
+ });
113
+ }
114
+
115
+ CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
116
+ if (old && old != CodeMirror.Init) {
117
+ cm.off("cursorActivity", doMatchBrackets);
118
+ if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
119
+ cm.state.matchBrackets.currentlyHighlighted();
120
+ cm.state.matchBrackets.currentlyHighlighted = null;
121
+ }
122
+ }
123
+ if (val) {
124
+ cm.state.matchBrackets = typeof val == "object" ? val : {};
125
+ cm.on("cursorActivity", doMatchBrackets);
126
+ }
127
+ });
128
+
129
+ CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
130
+ CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
131
+ // Backwards-compatibility kludge
132
+ if (oldConfig || typeof config == "boolean") {
133
+ if (!oldConfig) {
134
+ config = config ? {strict: true} : null
135
+ } else {
136
+ oldConfig.strict = config
137
+ config = oldConfig
138
+ }
139
+ }
140
+ return findMatchingBracket(this, pos, config)
141
+ });
142
+ CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
143
+ return scanForBracket(this, pos, dir, style, config);
144
+ });
145
+ });