├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── appveyor.yml ├── index.js ├── mocha.opts ├── package-lock.json ├── package.json ├── rollup.config.js ├── scripts └── move-type-declarations.js ├── src ├── handlers │ ├── AwaitBlock.ts │ ├── Comment.ts │ ├── Component.ts │ ├── DebugTag.ts │ ├── EachBlock.ts │ ├── Element.ts │ ├── Head.ts │ ├── HtmlTag.ts │ ├── IfBlock.ts │ ├── Slot.ts │ ├── Tag.ts │ ├── Text.ts │ ├── Title.ts │ └── fragment.ts ├── index.ts └── utils │ ├── deindent.ts │ ├── fullCharCodeAt.ts │ ├── getObject.ts │ ├── getTailSnippet.ts │ ├── globalWhitelist.ts │ ├── isValidIdentifier.ts │ ├── isVoidElementName.ts │ ├── quoteIfNecessary.ts │ └── stringify.ts ├── test └── test.ts ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | *.d.ts 4 | dist -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | 5 | env: 6 | global: 7 | - BUILD_TIMEOUT=10000 -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # TODO changelog 2 | 3 | ## 1.0.0 4 | 5 | * First release -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Rich Harris 2 | 3 | Permission is hereby granted by the authors of this software, to any person, to use the software for any purpose, free of charge, including the rights to run, read, copy, change, distribute and sell it, and including usage rights to any patents the authors may hold on it, subject to the following conditions: 4 | 5 | This license, or a link to its text, must be included with all copies of the software and any derivative works. 6 | 7 | Any modification to the software submitted to the authors may be incorporated into the software under the terms of this license. 8 | 9 | The software is provided "as is", without warranty of any kind, including but not limited to the warranties of title, fitness, merchantability and non-infringement. The authors have no obligation to provide support or updates for the software, and may not be held liable for any damages, claims or other liability arising from its use. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @sveltejs/generate-ssr 2 | 3 | WIP -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # http://www.appveyor.com/docs/appveyor-yml 2 | 3 | version: "{build}" 4 | 5 | clone_depth: 10 6 | 7 | init: 8 | - git config --global core.autocrlf false 9 | 10 | environment: 11 | matrix: 12 | # node.js 13 | - nodejs_version: 8 14 | 15 | install: 16 | - ps: Install-Product node $env:nodejs_version 17 | - npm install 18 | 19 | build: off 20 | 21 | test_script: 22 | - node --version && npm --version 23 | - npm test 24 | 25 | matrix: 26 | fast_finish: false 27 | 28 | # cache: 29 | # - C:\Users\appveyor\AppData\Roaming\npm-cache -> package.json # npm cache 30 | # - node_modules -> package.json # local npm modules 31 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /*! ***************************************************************************** 2 | Copyright (c) Microsoft Corporation. All rights reserved. 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10 | MERCHANTABLITY OR NON-INFRINGEMENT. 11 | 12 | See the Apache Version 2.0 License for specific language governing permissions 13 | and limitations under the License. 14 | ***************************************************************************** */ 15 | 16 | function __makeTemplateObject(cooked, raw) { 17 | if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 18 | return cooked; 19 | } 20 | 21 | var start = /\n(\t+)/; 22 | function deindent(strings) { 23 | var values = []; 24 | for (var _i = 1; _i < arguments.length; _i++) { 25 | values[_i - 1] = arguments[_i]; 26 | } 27 | var indentation = start.exec(strings[0])[1]; 28 | var pattern = new RegExp("^" + indentation, 'gm'); 29 | var result = strings[0].replace(start, '').replace(pattern, ''); 30 | var trailingIndentation = getTrailingIndentation(result); 31 | for (var i = 1; i < strings.length; i += 1) { 32 | var expression = values[i - 1]; 33 | var string = strings[i].replace(pattern, ''); 34 | if (Array.isArray(expression)) { 35 | expression = expression.length ? expression.join('\n') : null; 36 | } 37 | if (expression || expression === '') { 38 | var value = String(expression).replace(/\n/g, "\n" + trailingIndentation); 39 | result += value + string; 40 | } 41 | else { 42 | var c = result.length; 43 | while (/\s/.test(result[c - 1])) 44 | c -= 1; 45 | result = result.slice(0, c) + string; 46 | } 47 | trailingIndentation = getTrailingIndentation(result); 48 | } 49 | return result.trim().replace(/\t+$/gm, ''); 50 | } 51 | function getTrailingIndentation(str) { 52 | var i = str.length; 53 | while (str[i - 1] === ' ' || str[i - 1] === '\t') 54 | i -= 1; 55 | return str.slice(i, str.length); 56 | } 57 | 58 | function stringify(data, options) { 59 | if (options === void 0) { options = {}; } 60 | return JSON.stringify(escape(data, options)); 61 | } 62 | function escape(data, _a) { 63 | var _b = (_a === void 0 ? {} : _a).onlyEscapeAtSymbol, onlyEscapeAtSymbol = _b === void 0 ? false : _b; 64 | return data.replace(onlyEscapeAtSymbol ? /(%+|@+)/g : /(%+|@+|#+)/g, function (match) { 65 | return match + match[0]; 66 | }); 67 | } 68 | var escaped = { 69 | '&': '&', 70 | '<': '<', 71 | '>': '>' 72 | }; 73 | function escapeHTML(html) { 74 | return String(html).replace(/[&<>]/g, function (match) { return escaped[match]; }); 75 | } 76 | function escapeTemplate(str) { 77 | return str.replace(/(\${|`|\\)/g, '\\$1'); 78 | } 79 | 80 | var globalWhitelist = new Set([ 81 | 'Array', 82 | 'Boolean', 83 | 'console', 84 | 'Date', 85 | 'decodeURI', 86 | 'decodeURIComponent', 87 | 'encodeURI', 88 | 'encodeURIComponent', 89 | 'Infinity', 90 | 'Intl', 91 | 'isFinite', 92 | 'isNaN', 93 | 'JSON', 94 | 'Map', 95 | 'Math', 96 | 'NaN', 97 | 'Number', 98 | 'Object', 99 | 'parseFloat', 100 | 'parseInt', 101 | 'Promise', 102 | 'RegExp', 103 | 'Set', 104 | 'String', 105 | 'undefined', 106 | ]); 107 | 108 | function Comment (node, target, options) { 109 | if (options.preserveComments) { 110 | target.append(""); 111 | } 112 | } 113 | 114 | // Reserved word lists for various dialects of the language 115 | 116 | // ## Character categories 117 | 118 | // Big ugly regular expressions that match characters in the 119 | // whitespace, identifier, and identifier-start categories. These 120 | // are only applied when a character is found to actually have a 121 | // code point above 128. 122 | // Generated by `bin/generate-identifier-regex.js`. 123 | 124 | var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7b9\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; 125 | var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; 126 | 127 | var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); 128 | var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); 129 | 130 | nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; 131 | 132 | // These are a run-length and offset encoded representation of the 133 | // >0xffff code points that are a valid part of identifiers. The 134 | // offset starts at 0x10000, and each pair of numbers represents an 135 | // offset to the next range, and then a size of the range. They were 136 | // generated by bin/generate-identifier-regex.js 137 | 138 | // eslint-disable-next-line comma-spacing 139 | var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]; 140 | 141 | // eslint-disable-next-line comma-spacing 142 | var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]; 143 | 144 | // This has a complexity linear to the value of the code. The 145 | // assumption is that looking up astral identifier characters is 146 | // rare. 147 | function isInAstralSet(code, set) { 148 | var pos = 0x10000; 149 | for (var i = 0; i < set.length; i += 2) { 150 | pos += set[i]; 151 | if (pos > code) { return false } 152 | pos += set[i + 1]; 153 | if (pos >= code) { return true } 154 | } 155 | } 156 | 157 | // Test whether a given character code starts an identifier. 158 | 159 | function isIdentifierStart(code, astral) { 160 | if (code < 65) { return code === 36 } 161 | if (code < 91) { return true } 162 | if (code < 97) { return code === 95 } 163 | if (code < 123) { return true } 164 | if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) } 165 | if (astral === false) { return false } 166 | return isInAstralSet(code, astralIdentifierStartCodes) 167 | } 168 | 169 | // Test whether a given character is part of an identifier. 170 | 171 | function isIdentifierChar(code, astral) { 172 | if (code < 48) { return code === 36 } 173 | if (code < 58) { return true } 174 | if (code < 65) { return false } 175 | if (code < 91) { return true } 176 | if (code < 97) { return code === 95 } 177 | if (code < 123) { return true } 178 | if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) } 179 | if (astral === false) { return false } 180 | return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes) 181 | } 182 | 183 | // ## Token types 184 | 185 | // The assignment of fine-grained, information-carrying type objects 186 | // allows the tokenizer to store the information it has about a 187 | // token in a way that is very cheap for the parser to look up. 188 | 189 | // All token type variables start with an underscore, to make them 190 | // easy to recognize. 191 | 192 | // The `beforeExpr` property is used to disambiguate between regular 193 | // expressions and divisions. It is set on all token types that can 194 | // be followed by an expression (thus, a slash after them would be a 195 | // regular expression). 196 | // 197 | // The `startsExpr` property is used to check if the token ends a 198 | // `yield` expression. It is set on all token types that either can 199 | // directly start an expression (like a quotation mark) or can 200 | // continue an expression (like the body of a string). 201 | // 202 | // `isLoop` marks a keyword as starting a loop, which is important 203 | // to know when parsing a label, in order to allow or disallow 204 | // continue jumps to that label. 205 | 206 | var TokenType = function TokenType(label, conf) { 207 | if ( conf === void 0 ) conf = {}; 208 | 209 | this.label = label; 210 | this.keyword = conf.keyword; 211 | this.beforeExpr = !!conf.beforeExpr; 212 | this.startsExpr = !!conf.startsExpr; 213 | this.isLoop = !!conf.isLoop; 214 | this.isAssign = !!conf.isAssign; 215 | this.prefix = !!conf.prefix; 216 | this.postfix = !!conf.postfix; 217 | this.binop = conf.binop || null; 218 | this.updateContext = null; 219 | }; 220 | 221 | function binop(name, prec) { 222 | return new TokenType(name, {beforeExpr: true, binop: prec}) 223 | } 224 | var beforeExpr = {beforeExpr: true}; 225 | var startsExpr = {startsExpr: true}; 226 | 227 | // Map keyword names to token types. 228 | 229 | var keywords$1 = {}; 230 | 231 | // Succinct definitions of keyword token types 232 | function kw(name, options) { 233 | if ( options === void 0 ) options = {}; 234 | 235 | options.keyword = name; 236 | return keywords$1[name] = new TokenType(name, options) 237 | } 238 | 239 | var types = { 240 | num: new TokenType("num", startsExpr), 241 | regexp: new TokenType("regexp", startsExpr), 242 | string: new TokenType("string", startsExpr), 243 | name: new TokenType("name", startsExpr), 244 | eof: new TokenType("eof"), 245 | 246 | // Punctuation token types. 247 | bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}), 248 | bracketR: new TokenType("]"), 249 | braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}), 250 | braceR: new TokenType("}"), 251 | parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}), 252 | parenR: new TokenType(")"), 253 | comma: new TokenType(",", beforeExpr), 254 | semi: new TokenType(";", beforeExpr), 255 | colon: new TokenType(":", beforeExpr), 256 | dot: new TokenType("."), 257 | question: new TokenType("?", beforeExpr), 258 | arrow: new TokenType("=>", beforeExpr), 259 | template: new TokenType("template"), 260 | invalidTemplate: new TokenType("invalidTemplate"), 261 | ellipsis: new TokenType("...", beforeExpr), 262 | backQuote: new TokenType("`", startsExpr), 263 | dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}), 264 | 265 | // Operators. These carry several kinds of properties to help the 266 | // parser use them properly (the presence of these properties is 267 | // what categorizes them as operators). 268 | // 269 | // `binop`, when present, specifies that this operator is a binary 270 | // operator, and will refer to its precedence. 271 | // 272 | // `prefix` and `postfix` mark the operator as a prefix or postfix 273 | // unary operator. 274 | // 275 | // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as 276 | // binary operators with a very low precedence, that should result 277 | // in AssignmentExpression nodes. 278 | 279 | eq: new TokenType("=", {beforeExpr: true, isAssign: true}), 280 | assign: new TokenType("_=", {beforeExpr: true, isAssign: true}), 281 | incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}), 282 | prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}), 283 | logicalOR: binop("||", 1), 284 | logicalAND: binop("&&", 2), 285 | bitwiseOR: binop("|", 3), 286 | bitwiseXOR: binop("^", 4), 287 | bitwiseAND: binop("&", 5), 288 | equality: binop("==/!=/===/!==", 6), 289 | relational: binop("/<=/>=", 7), 290 | bitShift: binop("<>/>>>", 8), 291 | plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}), 292 | modulo: binop("%", 10), 293 | star: binop("*", 10), 294 | slash: binop("/", 10), 295 | starstar: new TokenType("**", {beforeExpr: true}), 296 | 297 | // Keyword token types. 298 | _break: kw("break"), 299 | _case: kw("case", beforeExpr), 300 | _catch: kw("catch"), 301 | _continue: kw("continue"), 302 | _debugger: kw("debugger"), 303 | _default: kw("default", beforeExpr), 304 | _do: kw("do", {isLoop: true, beforeExpr: true}), 305 | _else: kw("else", beforeExpr), 306 | _finally: kw("finally"), 307 | _for: kw("for", {isLoop: true}), 308 | _function: kw("function", startsExpr), 309 | _if: kw("if"), 310 | _return: kw("return", beforeExpr), 311 | _switch: kw("switch"), 312 | _throw: kw("throw", beforeExpr), 313 | _try: kw("try"), 314 | _var: kw("var"), 315 | _const: kw("const"), 316 | _while: kw("while", {isLoop: true}), 317 | _with: kw("with"), 318 | _new: kw("new", {beforeExpr: true, startsExpr: true}), 319 | _this: kw("this", startsExpr), 320 | _super: kw("super", startsExpr), 321 | _class: kw("class", startsExpr), 322 | _extends: kw("extends", beforeExpr), 323 | _export: kw("export"), 324 | _import: kw("import"), 325 | _null: kw("null", startsExpr), 326 | _true: kw("true", startsExpr), 327 | _false: kw("false", startsExpr), 328 | _in: kw("in", {beforeExpr: true, binop: 7}), 329 | _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}), 330 | _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}), 331 | _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}), 332 | _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true}) 333 | }; 334 | 335 | // The algorithm used to determine whether a regexp can appear at a 336 | // given point in the program is loosely based on sweet.js' approach. 337 | // See https://github.com/mozilla/sweet.js/wiki/design 338 | 339 | var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) { 340 | this.token = token; 341 | this.isExpr = !!isExpr; 342 | this.preserveSpace = !!preserveSpace; 343 | this.override = override; 344 | this.generator = !!generator; 345 | }; 346 | 347 | var types$1 = { 348 | b_stat: new TokContext("{", false), 349 | b_expr: new TokContext("{", true), 350 | b_tmpl: new TokContext("${", false), 351 | p_stat: new TokContext("(", false), 352 | p_expr: new TokContext("(", true), 353 | q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }), 354 | f_stat: new TokContext("function", false), 355 | f_expr: new TokContext("function", true), 356 | f_expr_gen: new TokContext("function", true, false, null, true), 357 | f_gen: new TokContext("function", false, false, null, true) 358 | }; 359 | 360 | // Token-specific context update code 361 | 362 | types.parenR.updateContext = types.braceR.updateContext = function() { 363 | if (this.context.length === 1) { 364 | this.exprAllowed = true; 365 | return 366 | } 367 | var out = this.context.pop(); 368 | if (out === types$1.b_stat && this.curContext().token === "function") { 369 | out = this.context.pop(); 370 | } 371 | this.exprAllowed = !out.isExpr; 372 | }; 373 | 374 | types.braceL.updateContext = function(prevType) { 375 | this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr); 376 | this.exprAllowed = true; 377 | }; 378 | 379 | types.dollarBraceL.updateContext = function() { 380 | this.context.push(types$1.b_tmpl); 381 | this.exprAllowed = true; 382 | }; 383 | 384 | types.parenL.updateContext = function(prevType) { 385 | var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while; 386 | this.context.push(statementParens ? types$1.p_stat : types$1.p_expr); 387 | this.exprAllowed = true; 388 | }; 389 | 390 | types.incDec.updateContext = function() { 391 | // tokExprAllowed stays unchanged 392 | }; 393 | 394 | types._function.updateContext = types._class.updateContext = function(prevType) { 395 | if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && 396 | !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) 397 | { this.context.push(types$1.f_expr); } 398 | else 399 | { this.context.push(types$1.f_stat); } 400 | this.exprAllowed = false; 401 | }; 402 | 403 | types.backQuote.updateContext = function() { 404 | if (this.curContext() === types$1.q_tmpl) 405 | { this.context.pop(); } 406 | else 407 | { this.context.push(types$1.q_tmpl); } 408 | this.exprAllowed = false; 409 | }; 410 | 411 | types.star.updateContext = function(prevType) { 412 | if (prevType === types._function) { 413 | var index = this.context.length - 1; 414 | if (this.context[index] === types$1.f_expr) 415 | { this.context[index] = types$1.f_expr_gen; } 416 | else 417 | { this.context[index] = types$1.f_gen; } 418 | } 419 | this.exprAllowed = true; 420 | }; 421 | 422 | types.name.updateContext = function(prevType) { 423 | var allowed = false; 424 | if (this.options.ecmaVersion >= 6) { 425 | if (this.value === "of" && !this.exprAllowed || 426 | this.value === "yield" && this.inGeneratorContext()) 427 | { allowed = true; } 428 | } 429 | this.exprAllowed = allowed; 430 | }; 431 | 432 | var data = { 433 | "$LONE": [ 434 | "ASCII", 435 | "ASCII_Hex_Digit", 436 | "AHex", 437 | "Alphabetic", 438 | "Alpha", 439 | "Any", 440 | "Assigned", 441 | "Bidi_Control", 442 | "Bidi_C", 443 | "Bidi_Mirrored", 444 | "Bidi_M", 445 | "Case_Ignorable", 446 | "CI", 447 | "Cased", 448 | "Changes_When_Casefolded", 449 | "CWCF", 450 | "Changes_When_Casemapped", 451 | "CWCM", 452 | "Changes_When_Lowercased", 453 | "CWL", 454 | "Changes_When_NFKC_Casefolded", 455 | "CWKCF", 456 | "Changes_When_Titlecased", 457 | "CWT", 458 | "Changes_When_Uppercased", 459 | "CWU", 460 | "Dash", 461 | "Default_Ignorable_Code_Point", 462 | "DI", 463 | "Deprecated", 464 | "Dep", 465 | "Diacritic", 466 | "Dia", 467 | "Emoji", 468 | "Emoji_Component", 469 | "Emoji_Modifier", 470 | "Emoji_Modifier_Base", 471 | "Emoji_Presentation", 472 | "Extender", 473 | "Ext", 474 | "Grapheme_Base", 475 | "Gr_Base", 476 | "Grapheme_Extend", 477 | "Gr_Ext", 478 | "Hex_Digit", 479 | "Hex", 480 | "IDS_Binary_Operator", 481 | "IDSB", 482 | "IDS_Trinary_Operator", 483 | "IDST", 484 | "ID_Continue", 485 | "IDC", 486 | "ID_Start", 487 | "IDS", 488 | "Ideographic", 489 | "Ideo", 490 | "Join_Control", 491 | "Join_C", 492 | "Logical_Order_Exception", 493 | "LOE", 494 | "Lowercase", 495 | "Lower", 496 | "Math", 497 | "Noncharacter_Code_Point", 498 | "NChar", 499 | "Pattern_Syntax", 500 | "Pat_Syn", 501 | "Pattern_White_Space", 502 | "Pat_WS", 503 | "Quotation_Mark", 504 | "QMark", 505 | "Radical", 506 | "Regional_Indicator", 507 | "RI", 508 | "Sentence_Terminal", 509 | "STerm", 510 | "Soft_Dotted", 511 | "SD", 512 | "Terminal_Punctuation", 513 | "Term", 514 | "Unified_Ideograph", 515 | "UIdeo", 516 | "Uppercase", 517 | "Upper", 518 | "Variation_Selector", 519 | "VS", 520 | "White_Space", 521 | "space", 522 | "XID_Continue", 523 | "XIDC", 524 | "XID_Start", 525 | "XIDS" 526 | ], 527 | "General_Category": [ 528 | "Cased_Letter", 529 | "LC", 530 | "Close_Punctuation", 531 | "Pe", 532 | "Connector_Punctuation", 533 | "Pc", 534 | "Control", 535 | "Cc", 536 | "cntrl", 537 | "Currency_Symbol", 538 | "Sc", 539 | "Dash_Punctuation", 540 | "Pd", 541 | "Decimal_Number", 542 | "Nd", 543 | "digit", 544 | "Enclosing_Mark", 545 | "Me", 546 | "Final_Punctuation", 547 | "Pf", 548 | "Format", 549 | "Cf", 550 | "Initial_Punctuation", 551 | "Pi", 552 | "Letter", 553 | "L", 554 | "Letter_Number", 555 | "Nl", 556 | "Line_Separator", 557 | "Zl", 558 | "Lowercase_Letter", 559 | "Ll", 560 | "Mark", 561 | "M", 562 | "Combining_Mark", 563 | "Math_Symbol", 564 | "Sm", 565 | "Modifier_Letter", 566 | "Lm", 567 | "Modifier_Symbol", 568 | "Sk", 569 | "Nonspacing_Mark", 570 | "Mn", 571 | "Number", 572 | "N", 573 | "Open_Punctuation", 574 | "Ps", 575 | "Other", 576 | "C", 577 | "Other_Letter", 578 | "Lo", 579 | "Other_Number", 580 | "No", 581 | "Other_Punctuation", 582 | "Po", 583 | "Other_Symbol", 584 | "So", 585 | "Paragraph_Separator", 586 | "Zp", 587 | "Private_Use", 588 | "Co", 589 | "Punctuation", 590 | "P", 591 | "punct", 592 | "Separator", 593 | "Z", 594 | "Space_Separator", 595 | "Zs", 596 | "Spacing_Mark", 597 | "Mc", 598 | "Surrogate", 599 | "Cs", 600 | "Symbol", 601 | "S", 602 | "Titlecase_Letter", 603 | "Lt", 604 | "Unassigned", 605 | "Cn", 606 | "Uppercase_Letter", 607 | "Lu" 608 | ], 609 | "Script": [ 610 | "Adlam", 611 | "Adlm", 612 | "Ahom", 613 | "Anatolian_Hieroglyphs", 614 | "Hluw", 615 | "Arabic", 616 | "Arab", 617 | "Armenian", 618 | "Armn", 619 | "Avestan", 620 | "Avst", 621 | "Balinese", 622 | "Bali", 623 | "Bamum", 624 | "Bamu", 625 | "Bassa_Vah", 626 | "Bass", 627 | "Batak", 628 | "Batk", 629 | "Bengali", 630 | "Beng", 631 | "Bhaiksuki", 632 | "Bhks", 633 | "Bopomofo", 634 | "Bopo", 635 | "Brahmi", 636 | "Brah", 637 | "Braille", 638 | "Brai", 639 | "Buginese", 640 | "Bugi", 641 | "Buhid", 642 | "Buhd", 643 | "Canadian_Aboriginal", 644 | "Cans", 645 | "Carian", 646 | "Cari", 647 | "Caucasian_Albanian", 648 | "Aghb", 649 | "Chakma", 650 | "Cakm", 651 | "Cham", 652 | "Cherokee", 653 | "Cher", 654 | "Common", 655 | "Zyyy", 656 | "Coptic", 657 | "Copt", 658 | "Qaac", 659 | "Cuneiform", 660 | "Xsux", 661 | "Cypriot", 662 | "Cprt", 663 | "Cyrillic", 664 | "Cyrl", 665 | "Deseret", 666 | "Dsrt", 667 | "Devanagari", 668 | "Deva", 669 | "Duployan", 670 | "Dupl", 671 | "Egyptian_Hieroglyphs", 672 | "Egyp", 673 | "Elbasan", 674 | "Elba", 675 | "Ethiopic", 676 | "Ethi", 677 | "Georgian", 678 | "Geor", 679 | "Glagolitic", 680 | "Glag", 681 | "Gothic", 682 | "Goth", 683 | "Grantha", 684 | "Gran", 685 | "Greek", 686 | "Grek", 687 | "Gujarati", 688 | "Gujr", 689 | "Gurmukhi", 690 | "Guru", 691 | "Han", 692 | "Hani", 693 | "Hangul", 694 | "Hang", 695 | "Hanunoo", 696 | "Hano", 697 | "Hatran", 698 | "Hatr", 699 | "Hebrew", 700 | "Hebr", 701 | "Hiragana", 702 | "Hira", 703 | "Imperial_Aramaic", 704 | "Armi", 705 | "Inherited", 706 | "Zinh", 707 | "Qaai", 708 | "Inscriptional_Pahlavi", 709 | "Phli", 710 | "Inscriptional_Parthian", 711 | "Prti", 712 | "Javanese", 713 | "Java", 714 | "Kaithi", 715 | "Kthi", 716 | "Kannada", 717 | "Knda", 718 | "Katakana", 719 | "Kana", 720 | "Kayah_Li", 721 | "Kali", 722 | "Kharoshthi", 723 | "Khar", 724 | "Khmer", 725 | "Khmr", 726 | "Khojki", 727 | "Khoj", 728 | "Khudawadi", 729 | "Sind", 730 | "Lao", 731 | "Laoo", 732 | "Latin", 733 | "Latn", 734 | "Lepcha", 735 | "Lepc", 736 | "Limbu", 737 | "Limb", 738 | "Linear_A", 739 | "Lina", 740 | "Linear_B", 741 | "Linb", 742 | "Lisu", 743 | "Lycian", 744 | "Lyci", 745 | "Lydian", 746 | "Lydi", 747 | "Mahajani", 748 | "Mahj", 749 | "Malayalam", 750 | "Mlym", 751 | "Mandaic", 752 | "Mand", 753 | "Manichaean", 754 | "Mani", 755 | "Marchen", 756 | "Marc", 757 | "Masaram_Gondi", 758 | "Gonm", 759 | "Meetei_Mayek", 760 | "Mtei", 761 | "Mende_Kikakui", 762 | "Mend", 763 | "Meroitic_Cursive", 764 | "Merc", 765 | "Meroitic_Hieroglyphs", 766 | "Mero", 767 | "Miao", 768 | "Plrd", 769 | "Modi", 770 | "Mongolian", 771 | "Mong", 772 | "Mro", 773 | "Mroo", 774 | "Multani", 775 | "Mult", 776 | "Myanmar", 777 | "Mymr", 778 | "Nabataean", 779 | "Nbat", 780 | "New_Tai_Lue", 781 | "Talu", 782 | "Newa", 783 | "Nko", 784 | "Nkoo", 785 | "Nushu", 786 | "Nshu", 787 | "Ogham", 788 | "Ogam", 789 | "Ol_Chiki", 790 | "Olck", 791 | "Old_Hungarian", 792 | "Hung", 793 | "Old_Italic", 794 | "Ital", 795 | "Old_North_Arabian", 796 | "Narb", 797 | "Old_Permic", 798 | "Perm", 799 | "Old_Persian", 800 | "Xpeo", 801 | "Old_South_Arabian", 802 | "Sarb", 803 | "Old_Turkic", 804 | "Orkh", 805 | "Oriya", 806 | "Orya", 807 | "Osage", 808 | "Osge", 809 | "Osmanya", 810 | "Osma", 811 | "Pahawh_Hmong", 812 | "Hmng", 813 | "Palmyrene", 814 | "Palm", 815 | "Pau_Cin_Hau", 816 | "Pauc", 817 | "Phags_Pa", 818 | "Phag", 819 | "Phoenician", 820 | "Phnx", 821 | "Psalter_Pahlavi", 822 | "Phlp", 823 | "Rejang", 824 | "Rjng", 825 | "Runic", 826 | "Runr", 827 | "Samaritan", 828 | "Samr", 829 | "Saurashtra", 830 | "Saur", 831 | "Sharada", 832 | "Shrd", 833 | "Shavian", 834 | "Shaw", 835 | "Siddham", 836 | "Sidd", 837 | "SignWriting", 838 | "Sgnw", 839 | "Sinhala", 840 | "Sinh", 841 | "Sora_Sompeng", 842 | "Sora", 843 | "Soyombo", 844 | "Soyo", 845 | "Sundanese", 846 | "Sund", 847 | "Syloti_Nagri", 848 | "Sylo", 849 | "Syriac", 850 | "Syrc", 851 | "Tagalog", 852 | "Tglg", 853 | "Tagbanwa", 854 | "Tagb", 855 | "Tai_Le", 856 | "Tale", 857 | "Tai_Tham", 858 | "Lana", 859 | "Tai_Viet", 860 | "Tavt", 861 | "Takri", 862 | "Takr", 863 | "Tamil", 864 | "Taml", 865 | "Tangut", 866 | "Tang", 867 | "Telugu", 868 | "Telu", 869 | "Thaana", 870 | "Thaa", 871 | "Thai", 872 | "Tibetan", 873 | "Tibt", 874 | "Tifinagh", 875 | "Tfng", 876 | "Tirhuta", 877 | "Tirh", 878 | "Ugaritic", 879 | "Ugar", 880 | "Vai", 881 | "Vaii", 882 | "Warang_Citi", 883 | "Wara", 884 | "Yi", 885 | "Yiii", 886 | "Zanabazar_Square", 887 | "Zanb" 888 | ] 889 | }; 890 | Array.prototype.push.apply(data.$LONE, data.General_Category); 891 | data.gc = data.General_Category; 892 | data.sc = data.Script_Extensions = data.scx = data.Script; 893 | 894 | // Adapted from https://github.com/acornjs/acorn/blob/6584815dca7440e00de841d1dad152302fdd7ca5/src/tokenize.js 895 | // Reproduced under MIT License https://github.com/acornjs/acorn/blob/master/LICENSE 896 | function fullCharCodeAt(str, i) { 897 | var code = str.charCodeAt(i); 898 | if (code <= 0xd7ff || code >= 0xe000) 899 | return code; 900 | var next = str.charCodeAt(i + 1); 901 | return (code << 10) + next - 0x35fdc00; 902 | } 903 | 904 | function isValidIdentifier(str) { 905 | var i = 0; 906 | while (i < str.length) { 907 | var code = fullCharCodeAt(str, i); 908 | if (!(i === 0 ? isIdentifierStart : isIdentifierChar)(code, true)) 909 | return false; 910 | i += code <= 0xffff ? 1 : 2; 911 | } 912 | return true; 913 | } 914 | 915 | function quoteNameIfNecessary(name) { 916 | if (!isValidIdentifier(name)) 917 | return "\"" + name + "\""; 918 | return name; 919 | } 920 | function quotePropIfNecessary(name) { 921 | if (!isValidIdentifier(name)) 922 | return "[\"" + name + "\"]"; 923 | return "." + name; 924 | } 925 | 926 | function getObject(node) { 927 | while (node.type === 'MemberExpression') 928 | node = node.object; 929 | return node; 930 | } 931 | 932 | function getTailSnippet(node) { 933 | var end = node.end; 934 | while (node.type === 'MemberExpression') 935 | node = node.object; 936 | var start = node.end; 937 | return "[\u2702" + start + "-" + end + "\u2702]"; 938 | } 939 | 940 | function Component (node, target, options) { 941 | function stringifyAttribute(chunk) { 942 | if (chunk.type === 'Text') { 943 | return escapeTemplate(escape(chunk.data)); 944 | } 945 | return '${@escape( ' + chunk.snippet + ')}'; 946 | } 947 | var bindingProps = node.bindings.map(function (binding) { 948 | var name = getObject(binding.value.node).name; 949 | var tail = binding.value.node.type === 'MemberExpression' 950 | ? getTailSnippet(binding.value.node) 951 | : ''; 952 | return quoteNameIfNecessary(binding.name) + ": ctx" + quotePropIfNecessary(name) + tail; 953 | }); 954 | function getAttributeValue(attribute) { 955 | if (attribute.isTrue) 956 | return "true"; 957 | if (attribute.chunks.length === 0) 958 | return "''"; 959 | if (attribute.chunks.length === 1) { 960 | var chunk = attribute.chunks[0]; 961 | if (chunk.type === 'Text') { 962 | return stringify(chunk.data); 963 | } 964 | return chunk.snippet; 965 | } 966 | return '`' + attribute.chunks.map(stringifyAttribute).join('') + '`'; 967 | } 968 | var usesSpread = node.attributes.find(function (attr) { return attr.isSpread; }); 969 | var props = usesSpread 970 | ? "Object.assign(" + node.attributes 971 | .map(function (attribute) { 972 | if (attribute.isSpread) { 973 | return attribute.expression.snippet; 974 | } 975 | else { 976 | return "{ " + quoteNameIfNecessary(attribute.name) + ": " + getAttributeValue(attribute) + " }"; 977 | } 978 | }) 979 | .concat(bindingProps.map(function (p) { return "{ " + p + " }"; })) 980 | .join(', ') + ")" 981 | : "{ " + node.attributes 982 | .map(function (attribute) { return quoteNameIfNecessary(attribute.name) + ": " + getAttributeValue(attribute); }) 983 | .concat(bindingProps) 984 | .join(', ') + " }"; 985 | var expression = (node.name === 'svelte:self' 986 | ? node.compiler.name 987 | : node.name === 'svelte:component' 988 | ? "((" + node.expression.snippet + ") || @missingComponent)" 989 | : "%components-" + node.name); 990 | node.bindings.forEach(function (binding) { 991 | var conditions = []; 992 | var parent = node; 993 | while (parent = parent.parent) { 994 | if (parent.type === 'IfBlock') { 995 | // TODO handle contextual bindings... 996 | conditions.push("(" + parent.expression.snippet + ")"); 997 | } 998 | } 999 | conditions.push("!('" + binding.name + "' in ctx)", expression + ".data"); 1000 | var name = getObject(binding.value.node).name; 1001 | target.bindings.push(deindent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t\t\tif (", ") {\n\t\t\t\ttmp = ", ".data();\n\t\t\t\tif ('", "' in tmp) {\n\t\t\t\t\tctx", " = tmp.", ";\n\t\t\t\t\tsettled = false;\n\t\t\t\t}\n\t\t\t}\n\t\t"], ["\n\t\t\tif (", ") {\n\t\t\t\ttmp = ", ".data();\n\t\t\t\tif ('", "' in tmp) {\n\t\t\t\t\tctx", " = tmp.", ";\n\t\t\t\t\tsettled = false;\n\t\t\t\t}\n\t\t\t}\n\t\t"])), conditions.reverse().join('&&'), expression, name, quotePropIfNecessary(binding.name), name)); 1002 | }); 1003 | var open = "${@validateSsrComponent(" + expression + ", '" + node.name + "')._render(__result, " + props; 1004 | var options = []; 1005 | options.push("store: options.store"); 1006 | if (node.children.length) { 1007 | var appendTarget_1 = { 1008 | slots: { "default": '' }, 1009 | slotStack: ['default'] 1010 | }; 1011 | target.appendTargets.push(appendTarget_1); 1012 | fragment$1(node.children, target, options); 1013 | var slotted = Object.keys(appendTarget_1.slots) 1014 | .map(function (name) { return quoteNameIfNecessary(name) + ": () => `" + appendTarget_1.slots[name] + "`"; }) 1015 | .join(', '); 1016 | options.push("slotted: { " + slotted + " }"); 1017 | target.appendTargets.pop(); 1018 | } 1019 | if (options.length) { 1020 | open += ", { " + options.join(', ') + " }"; 1021 | } 1022 | target.append(open); 1023 | target.append(')}'); 1024 | } 1025 | var templateObject_1; 1026 | 1027 | function DebugTag (node, target, options) { 1028 | if (!options.dev) 1029 | return; 1030 | var filename = options.file || null; 1031 | var _a = options.locate(node.start + 1), line = _a.line, column = _a.column; 1032 | var obj = node.expressions.length === 0 1033 | ? "ctx" 1034 | : "{ " + node.expressions 1035 | .map(function (e) { return e.node.name; }) 1036 | .map(function (name) { return name + ": ctx." + name; }) 1037 | .join(', ') + " }"; 1038 | var str = '${@debug(' + ((filename && stringify(filename)) + ", " + line + ", " + column + ", " + obj + ")}"); 1039 | target.append(str); 1040 | } 1041 | 1042 | function EachBlock (node, target, options) { 1043 | var snippet = node.expression.snippet; 1044 | var props = node.contexts.map(function (prop) { return prop.key.name + ": item" + prop.tail; }); 1045 | var getContext = node.index 1046 | ? "(item, i) => Object.assign({}, ctx, { " + props.join(', ') + ", " + node.index + ": i })" 1047 | : "item => Object.assign({}, ctx, { " + props.join(', ') + " })"; 1048 | var open = "${ " + (node["else"] ? snippet + ".length ? " : '') + "@each(" + snippet + ", " + getContext + ", ctx => `"; 1049 | target.append(open); 1050 | fragment$1(node.children, target, options); 1051 | var close = "`)"; 1052 | target.append(close); 1053 | if (node["else"]) { 1054 | target.append(" : `"); 1055 | fragment$1(node["else"].children, target, options); 1056 | target.append("`"); 1057 | } 1058 | target.append('}'); 1059 | } 1060 | 1061 | var voidElementNames = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/; 1062 | function isVoidElementName(name) { 1063 | return voidElementNames.test(name) || name.toLowerCase() === '!doctype'; 1064 | } 1065 | 1066 | // source: https://gist.github.com/ArjanSchouten/0b8574a6ad7f5065a5e7 1067 | var booleanAttributes = new Set([ 1068 | 'async', 1069 | 'autocomplete', 1070 | 'autofocus', 1071 | 'autoplay', 1072 | 'border', 1073 | 'challenge', 1074 | 'checked', 1075 | 'compact', 1076 | 'contenteditable', 1077 | 'controls', 1078 | 'default', 1079 | 'defer', 1080 | 'disabled', 1081 | 'formnovalidate', 1082 | 'frameborder', 1083 | 'hidden', 1084 | 'indeterminate', 1085 | 'ismap', 1086 | 'loop', 1087 | 'multiple', 1088 | 'muted', 1089 | 'nohref', 1090 | 'noresize', 1091 | 'noshade', 1092 | 'novalidate', 1093 | 'nowrap', 1094 | 'open', 1095 | 'readonly', 1096 | 'required', 1097 | 'reversed', 1098 | 'scoped', 1099 | 'scrolling', 1100 | 'seamless', 1101 | 'selected', 1102 | 'sortable', 1103 | 'spellcheck', 1104 | 'translate' 1105 | ]); 1106 | function Element (node, target, options) { 1107 | var openingTag = "<" + node.name; 1108 | var textareaContents; // awkward special case 1109 | var slot = node.getStaticAttributeValue('slot'); 1110 | if (slot && node.hasAncestor('Component')) { 1111 | var slot_1 = node.attributes.find(function (attribute) { return attribute.name === 'slot'; }); 1112 | var slotName = slot_1.chunks[0].data; 1113 | var appendTarget = target.appendTargets[target.appendTargets.length - 1]; 1114 | appendTarget.slotStack.push(slotName); 1115 | appendTarget.slots[slotName] = ''; 1116 | } 1117 | var classExpr = node.classes.map(function (classDir) { 1118 | var expression = classDir.expression, name = classDir.name; 1119 | var snippet = expression ? expression.snippet : "ctx" + quotePropIfNecessary(name); 1120 | return snippet + " ? \"" + name + "\" : \"\""; 1121 | }).join(', '); 1122 | var addClassAttribute = classExpr ? true : false; 1123 | if (node.attributes.find(function (attr) { return attr.isSpread; })) { 1124 | // TODO dry this out 1125 | var args_1 = []; 1126 | node.attributes.forEach(function (attribute) { 1127 | if (attribute.isSpread) { 1128 | args_1.push(attribute.expression.snippet); 1129 | } 1130 | else { 1131 | if (attribute.name === 'value' && node.name === 'textarea') { 1132 | textareaContents = attribute.stringifyForSsr(); 1133 | } 1134 | else if (attribute.isTrue) { 1135 | args_1.push("{ " + quoteNameIfNecessary(attribute.name) + ": true }"); 1136 | } 1137 | else if (booleanAttributes.has(attribute.name) && 1138 | attribute.chunks.length === 1 && 1139 | attribute.chunks[0].type !== 'Text') { 1140 | // a boolean attribute with one non-Text chunk 1141 | args_1.push("{ " + quoteNameIfNecessary(attribute.name) + ": " + attribute.chunks[0].snippet + " }"); 1142 | } 1143 | else { 1144 | args_1.push("{ " + quoteNameIfNecessary(attribute.name) + ": `" + attribute.stringifyForSsr() + "` }"); 1145 | } 1146 | } 1147 | }); 1148 | openingTag += "${@spread([" + args_1.join(', ') + "])}"; 1149 | } 1150 | else { 1151 | node.attributes.forEach(function (attribute) { 1152 | if (attribute.type !== 'Attribute') 1153 | return; 1154 | if (attribute.name === 'value' && node.name === 'textarea') { 1155 | textareaContents = attribute.stringifyForSsr(); 1156 | } 1157 | else if (attribute.isTrue) { 1158 | openingTag += " " + attribute.name; 1159 | } 1160 | else if (booleanAttributes.has(attribute.name) && 1161 | attribute.chunks.length === 1 && 1162 | attribute.chunks[0].type !== 'Text') { 1163 | // a boolean attribute with one non-Text chunk 1164 | openingTag += '${' + attribute.chunks[0].snippet + ' ? " ' + attribute.name + '" : "" }'; 1165 | } 1166 | else if (attribute.name === 'class' && classExpr) { 1167 | addClassAttribute = false; 1168 | openingTag += " class=\"${ [`" + attribute.stringifyForSsr() + "`, " + classExpr + " ].join(' ').trim() }\""; 1169 | } 1170 | else { 1171 | openingTag += " " + attribute.name + "=\"" + attribute.stringifyForSsr() + "\""; 1172 | } 1173 | }); 1174 | } 1175 | if (addClassAttribute) { 1176 | openingTag += " class=\"${ [" + classExpr + "].join(' ').trim() }\""; 1177 | } 1178 | openingTag += '>'; 1179 | target.append(openingTag); 1180 | if (node.name === 'textarea' && textareaContents !== undefined) { 1181 | target.append(textareaContents); 1182 | } 1183 | else { 1184 | fragment$1(node.children, target, options); 1185 | } 1186 | if (!isVoidElementName(node.name)) { 1187 | target.append(""); 1188 | } 1189 | } 1190 | 1191 | function Head (node, target, options) { 1192 | target.append('${(__result.head += `'); 1193 | fragment$1(node.children, target, options); 1194 | target.append('`, "")}'); 1195 | } 1196 | 1197 | function HtmlTag (node, target, options) { 1198 | target.append('${' + node.expression.snippet + '}'); 1199 | } 1200 | 1201 | function IfBlock (node, target, options) { 1202 | var snippet = node.expression.snippet; 1203 | target.append('${ ' + snippet + ' ? `'); 1204 | fragment$1(node.children, target, options); 1205 | target.append('` : `'); 1206 | if (node["else"]) { 1207 | fragment$1(node["else"].children, target, options); 1208 | } 1209 | target.append('` }'); 1210 | } 1211 | 1212 | function Slot (node, target, options) { 1213 | var name = node.attributes.find(function (attribute) { return attribute.name === 'name'; }); 1214 | var slotName = name && name.chunks[0].data || 'default'; 1215 | var prop = quotePropIfNecessary(slotName); 1216 | target.append("${options && options.slotted && options.slotted" + prop + " ? options.slotted" + prop + "() : `"); 1217 | fragment$1(node.children, target, options); 1218 | target.append("`}"); 1219 | } 1220 | 1221 | function Tag (node, target, options) { 1222 | target.append(node.parent && 1223 | node.parent.type === 'Element' && 1224 | node.parent.name === 'style' 1225 | ? '${' + node.expression.snippet + '}' 1226 | : '${@escape(' + node.expression.snippet + ')}'); 1227 | } 1228 | 1229 | function Text (node, target, options) { 1230 | var text = node.data; 1231 | if (!node.parent || 1232 | node.parent.type !== 'Element' || 1233 | (node.parent.name !== 'script' && node.parent.name !== 'style')) { 1234 | // unless this Text node is inside a