Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: baidu/san-ssr
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.2.4
Choose a base ref
...
head repository: baidu/san-ssr
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 38,227 additions and 40,835 deletions.
  1. +1 −1 .babelrc.js
  2. +4 −4 .eslintignore
  3. +7 −3 .eslintrc.json
  4. +65 −0 .github/ISSUE_TEMPLATE/bug_report.md
  5. +34 −0 .github/workflows/check.yml
  6. +25 −0 .github/workflows/release.yml
  7. +9 −2 .gitignore
  8. +0 −29 .travis.yml
  9. +480 −5 CHANGELOG.md
  10. +2 −3 README.en.md
  11. +16 −12 README.md
  12. +0 −221 arkit.svg
  13. +69 −30 bin/debug
  14. +44 −0 bin/debug-local.js
  15. +20 −5 bin/render-by-source.js
  16. +20 −4 bin/render-onthefly.js
  17. +6 −6 demo/README.md
  18. +1 −6 demo/{app.js → component.js}
  19. +16 −0 demo/component.san.html
  20. +13 −0 demo/component.ts
  21. +2 −0 demo/dist/.gitignore
  22. +57 −0 demo/index.js
  23. +4 −5 demo/package.json
  24. +0 −7 demo/server.js
  25. +17 −0 demo/tsconfig.json
  26. +0 −2,333 docs/assets/css/main.css
  27. BIN docs/assets/images/icons.png
  28. BIN docs/assets/images/icons@2x.png
  29. BIN docs/assets/images/widgets.png
  30. BIN docs/assets/images/widgets@2x.png
  31. +0 −1 docs/assets/js/main.js
  32. +0 −3 docs/assets/js/search.js
  33. +0 −452 docs/classes/_models_component_info_.componentinfoimpl.html
  34. +0 −462 docs/classes/_models_component_info_.dynamiccomponentinfo.html
  35. +0 −484 docs/classes/_models_component_info_.typedcomponentinfo.html
  36. +0 −592 docs/classes/_models_san_project_.sanproject.html
  37. +0 −331 docs/classes/_models_san_source_file_.dynamicsansourcefile.html
  38. +0 −343 docs/classes/_models_san_source_file_.sansourcefileimpl.html
  39. +0 −366 docs/classes/_models_san_source_file_.typedsansourcefile.html
  40. +0 −414 docs/classes/_parsers_component_class_parser_.componentclassparser.html
  41. +0 −257 docs/classes/_parsers_typescript_san_parser_.typescriptsanparser.html
  42. +0 −398 docs/classes/_runtime_san_data_.sandata.html
  43. +0 −708 docs/classes/_target_js_compilers_anode_compiler_.anodecompiler.html
  44. +0 −374 docs/classes/_target_js_compilers_component_compiler_.componentclasscompiler.html
  45. +0 −458 docs/classes/_target_js_compilers_element_compiler_.elementcompiler.html
  46. +0 −445 docs/classes/_target_js_compilers_renderer_compiler_.renderercompiler.html
  47. +0 −456 docs/classes/_target_js_index_.tojscompiler.html
  48. +0 −1,208 docs/classes/_target_js_js_emitter_.jsemitter.html
  49. +0 −658 docs/classes/_utils_emitter_.emitter.html
  50. +0 −317 docs/globals.html
  51. +0 −380 docs/index.html
  52. +0 −256 docs/interfaces/_models_compiler_.compiler.html
  53. +0 −212 docs/interfaces/_models_component_.computed.html
  54. +0 −210 docs/interfaces/_models_component_.filters.html
  55. +0 −264 docs/interfaces/_models_component_reference_.componentreference.html
  56. +0 −293 docs/interfaces/_models_component_reference_.dynamiccomponentreference.html
  57. +0 −246 docs/interfaces/_models_options_.typescriptfiledescriptor.html
  58. +0 −203 docs/interfaces/_models_renderer_.renderer.html
  59. +0 −324 docs/interfaces/_runtime_index_.sanssrruntime.html
  60. +0 −348 docs/interfaces/_runtime_resolver_.resolver.html
  61. +0 −206 docs/interfaces/_runtime_san_data_.computed.html
  62. +0 −183 docs/interfaces/_runtime_san_data_.dataobject.html
  63. +0 −255 docs/interfaces/_runtime_underscore_.context.html
  64. +0 −290 docs/modules/_bin_ssr_.html
  65. +0 −501 docs/modules/_fixtures_case_.html
  66. +0 −249 docs/modules/_index_.html
  67. +0 −171 docs/modules/_models_compiler_.html
  68. +0 −254 docs/modules/_models_component_.html
  69. +0 −155 docs/modules/_models_component_id_.html
  70. +0 −250 docs/modules/_models_component_info_.html
  71. +0 −292 docs/modules/_models_component_reference_.html
  72. +0 −310 docs/modules/_models_options_.html
  73. +0 −171 docs/modules/_models_renderer_.html
  74. +0 −225 docs/modules/_models_san_project_.html
  75. +0 −258 docs/modules/_models_san_source_file_.html
  76. +0 −171 docs/modules/_parsers_component_class_parser_.html
  77. +0 −197 docs/modules/_parsers_normalize_component_.html
  78. +0 −372 docs/modules/_parsers_parse_template_.html
  79. +0 −200 docs/modules/_parsers_tsconfig_.html
  80. +0 −193 docs/modules/_parsers_typescript_san_parser_.html
  81. +0 −264 docs/modules/_runtime_index_.html
  82. +0 −311 docs/modules/_runtime_resolver_.html
  83. +0 −184 docs/modules/_runtime_san_data_.html
  84. +0 −921 docs/modules/_runtime_underscore_.html
  85. +0 −171 docs/modules/_target_js_compilers_anode_compiler_.html
  86. +0 −171 docs/modules/_target_js_compilers_component_compiler_.html
  87. +0 −171 docs/modules/_target_js_compilers_element_compiler_.html
  88. +0 −674 docs/modules/_target_js_compilers_expr_compiler_.html
  89. +0 −193 docs/modules/_target_js_compilers_renderer_compiler_.html
  90. +0 −299 docs/modules/_target_js_compilers_stringifier_.html
  91. +0 −223 docs/modules/_target_js_index_.html
  92. +0 −171 docs/modules/_target_js_js_emitter_.html
  93. +0 −252 docs/modules/_transpilers_ts2js_.html
  94. +0 −294 docs/modules/_utils_anode_util_.html
  95. +0 −531 docs/modules/_utils_ast_util_.html
  96. +0 −197 docs/modules/_utils_buffer_.html
  97. +0 −377 docs/modules/_utils_case_.html
  98. +0 −198 docs/modules/_utils_dom_util_.html
  99. +0 −171 docs/modules/_utils_emitter_.html
  100. +0 −197 docs/modules/_utils_fs_.html
  101. +0 −290 docs/modules/_utils_lang_.html
  102. +0 −683 docs/modules/_utils_type_guards_.html
  103. +3 −2 jest.config.js
  104. +27,621 −12,112 package-lock.json
  105. +63 −51 package.json
  106. +486 −0 src/ast/js-ast-util.ts
  107. +435 −0 src/ast/renderer-ast-dfn.ts
  108. +142 −0 src/ast/renderer-ast-util.ts
  109. +107 −0 src/ast/renderer-ast-walker.ts
  110. +105 −0 src/ast/san-ast-type-guards.ts
  111. +54 −0 src/ast/san-ast-util.ts
  112. +98 −30 src/{utils/ast-util.ts → ast/ts-ast-util.ts}
  113. +24 −10 src/bin/ssr.ts
  114. +548 −0 src/compilers/anode-compiler.ts
  115. +215 −0 src/compilers/element-compiler.ts
  116. +395 −0 src/compilers/renderer-compiler.ts
  117. +55 −0 src/compilers/renderer-options.ts
  118. +4 −0 src/compilers/reserved-names.ts
  119. +194 −0 src/compilers/san-expr-compiler.ts
  120. +2 −1 src/{transpilers → compilers}/ts2js.ts
  121. +115 −29 src/fixtures/case.ts
  122. 0 docs/.nojekyll → src/helpers/createComponentInstanceTree.ts
  123. +45 −0 src/helpers/markExternalComponent.ts
  124. +23 −8 src/index.ts
  125. 0 src/models/component-id.ts
  126. +160 −36 src/models/component-info.ts
  127. +45 −53 src/models/component-reference.ts
  128. +49 −10 src/models/component.ts
  129. +8 −0 src/models/global-context.ts
  130. +39 −9 src/models/options.ts
  131. +30 −2 src/models/renderer.ts
  132. +125 −44 src/models/san-project.ts
  133. +37 −4 src/models/san-source-file.ts
  134. +8 −1 src/models/{compiler.ts → target-code-generator.ts}
  135. +20 −0 src/optimizers/README.md
  136. +21 −0 src/optimizers/bracket-to-dot.ts
  137. +44 −0 src/optimizers/merge-literal-add.ts
  138. +105 −47 src/parsers/component-class-parser.ts
  139. +349 −0 src/parsers/javascript-san-parser.ts
  140. +1 −1 src/parsers/normalize-component.ts
  141. +74 −20 src/parsers/parse-template.ts
  142. +23 −0 src/parsers/remove-modules.ts
  143. +132 −0 src/parsers/san-file-parser.ts
  144. +95 −13 src/parsers/typescript-san-parser.ts
  145. +64 −0 src/runtime/create-helpers.ts
  146. +3 −0 src/runtime/helpers.ts
  147. +0 −57 src/runtime/index.ts
  148. +99 −14 src/runtime/resolver.ts
  149. +0 −53 src/runtime/san-data.ts
  150. +187 −0 src/runtime/san-ssr-data.ts
  151. +161 −49 src/runtime/underscore.ts
  152. +0 −248 src/target-js/compilers/anode-compiler.ts
  153. +6 −0 src/target-js/compilers/compile-options.ts
  154. +39 −3 src/target-js/compilers/component-compiler.ts
  155. +0 −168 src/target-js/compilers/element-compiler.ts
  156. +0 −162 src/target-js/compilers/expr-compiler.ts
  157. +0 −102 src/target-js/compilers/renderer-compiler.ts
  158. +0 −71 src/target-js/compilers/stringifier.ts
  159. +115 −49 src/target-js/index.ts
  160. +329 −87 src/target-js/js-emitter.ts
  161. +0 −42 src/utils/anode-util.ts
  162. +2 −1 src/utils/case.ts
  163. +24 −10 src/utils/emitter.ts
  164. +21 −0 src/utils/id-generator.ts
  165. +9 −5 src/utils/lang.ts
  166. +0 −93 src/utils/type-guards.ts
  167. +2 −1 test/.eslintrc.json
  168. +13 −0 test/cases/custom-require-with-provide-class/childA.san.js
  169. +13 −0 test/cases/custom-require-with-provide-class/childB.san.js
  170. +12 −0 test/cases/custom-require-with-provide-class/component.js
  171. +2 −0 test/cases/custom-require-with-provide-class/data.json
  172. +1 −0 test/cases/custom-require-with-provide-class/expected.html
  173. +76 −0 test/cases/custom-require-with-provide-class/ssr-spec.ts
  174. +8 −0 test/cases/custom-require/childB.san.js
  175. +11 −0 test/cases/custom-require/component.js
  176. +2 −0 test/cases/custom-require/data.json
  177. +1 −0 test/cases/custom-require/expected.html
  178. +61 −0 test/cases/custom-require/ssr-spec.ts
  179. +8 −0 test/cases/external-placeholder/childA.san.js
  180. +19 −0 test/cases/external-placeholder/component.js
  181. +2 −0 test/cases/external-placeholder/data.json
  182. +1 −0 test/cases/external-placeholder/expected.html
  183. +50 −0 test/cases/external-placeholder/ssr-spec.ts
  184. +44 −0 test/cases/provide-class-auto-with-name/component.js
  185. +2 −0 test/cases/provide-class-auto-with-name/data.json
  186. +1 −0 test/cases/provide-class-auto-with-name/expected.html
  187. +15 −0 test/cases/provide-class-auto-with-name/ssr-spec.ts
  188. +44 −0 test/cases/provide-class-auto/component.js
  189. +2 −0 test/cases/provide-class-auto/data.json
  190. +1 −0 test/cases/provide-class-auto/expected.html
  191. +14 −0 test/cases/provide-class-auto/ssr-spec.ts
  192. +54 −0 test/cases/provide-class-template-component/component.js
  193. +2 −0 test/cases/provide-class-template-component/data.json
  194. +1 −0 test/cases/provide-class-template-component/expected.html
  195. +12 −0 test/cases/provide-class-template-component/ssr-spec.ts
  196. +54 −0 test/cases/provide-class/component.js
  197. +2 −0 test/cases/provide-class/data.json
  198. +1 −0 test/cases/provide-class/expected.html
  199. +12 −0 test/cases/provide-class/ssr-spec.ts
  200. +5 −0 test/cases/readme.md
  201. +144 −32 test/e2e.spec.ts
  202. +165 −0 test/error.spec.ts
  203. +0 −93 test/lib/triggerEvent.js
  204. +129 −0 test/perf/_cli.js
  205. +76 −59 test/perf/{ → cases}/list-multi-mode.js
  206. +122 −107 test/perf/{ → cases}/list.js
  207. +116 −0 test/perf/cases/simple-list.js
  208. +57 −0 test/perf/cases/template-component.js
  209. +34 −34 test/perf/{ → cases}/vue/index.js
  210. 0 test/perf/{ → cases}/vue/package.json
  211. +0 −3 test/perf/index.js
  212. +83 −0 test/perf/run.js
  213. +0 −85 test/perf/simple-list.js
  214. +3 −1 test/perf/{ → tti}/tti-component.js
  215. 0 test/perf/{ → tti}/tti-gen.js
  216. 0 test/perf/{ → tti}/tti.tpl.html
  217. +373 −0 test/perf/utils/common.js
  218. +1 −1 test/stub/bar.js
  219. +1 −1 test/stub/filters.comp.ts
  220. +12 −0 test/stub/remove-modules.comp.ts
  221. +2 −0 test/stub/remove-modules.d.ts
  222. +2 −2 test/stub/ssr.js
  223. +16 −0 test/stub/util.ts
  224. +7 −0 test/unit/ast/renderer-ast-walker.spec.ts
  225. +155 −0 test/unit/compilers/element-compiler.spec.ts
  226. +106 −0 test/unit/compilers/renderer-compiler.spec.ts
  227. +192 −0 test/unit/compilers/san-expr-compiler.spec.ts
  228. +2 −2 test/unit/{transpilers → compilers}/ts2js.spec.ts
  229. +16 −12 test/unit/emitter.spec.ts
  230. +34 −0 test/unit/helpers/markExternalComponent.spec.ts
  231. +10 −4 test/unit/index.spec.ts
  232. +54 −21 test/unit/models/component-info.spec.ts
  233. +68 −12 test/unit/models/san-project.spec.ts
  234. +15 −3 test/unit/models/san-source-file.spec.ts
  235. +24 −0 test/unit/optimizers/merge-literal-add.spec.ts
  236. +14 −5 test/unit/parsers/component-class-parser.spec.ts
  237. +298 −0 test/unit/parsers/javascript-san-parser.spec.ts
  238. +1 −1 test/unit/parsers/normalize-component.spec.ts
  239. +55 −0 test/unit/parsers/parse-template.spec.ts
  240. +28 −0 test/unit/parsers/remove-modules.spec.ts
  241. +95 −0 test/unit/parsers/san-file-parser.spec.ts
  242. +40 −2 test/unit/parsers/typescript-san-parser.spec.ts
  243. +116 −2 test/unit/runtime/resolver.spec.ts
  244. +71 −16 test/unit/runtime/san-data.spec.ts
  245. +98 −14 test/unit/runtime/underscore.spec.ts
  246. +20 −2 test/unit/target-js/compilers/component-compiler.spec.ts
  247. +0 −70 test/unit/target-js/compilers/element-compiler.spec.ts
  248. +0 −33 test/unit/target-js/compilers/expr-compiler.spec.ts
  249. +0 −44 test/unit/target-js/compilers/renderer-compiler.spec.ts
  250. +0 −19 test/unit/target-js/compilers/stringifier.spec.ts
  251. +7 −1 test/unit/target-js/index.spec.ts
  252. +44 −127 test/unit/target-js/js-emitter.spec.ts
  253. +4 −0 test/unit/utils/case.spec.ts
  254. +154 −0 test/unit/utils/js-ast-util.spec.ts
  255. +19 −0 test/unit/utils/lang.spec.ts
  256. +53 −40 test/unit/utils/{ast-util.spec.ts → ts-ast-util.spec.ts}
  257. +1 −0 tsconfig.json
  258. +472 −304 types/san.d.ts
2 changes: 1 addition & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,6 @@ module.exports = {
'@babel/preset-typescript'
],
"plugins": [
"transform-class-properties"
"@babel/plugin-proposal-class-properties"
]
};
8 changes: 4 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
dist
coverage
test/e2e.spec.js
ssr.php
ssr.js
types
docs
types
bin/component.js
bin/output.js
10 changes: 7 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -12,13 +12,11 @@
"promise"
],
"rules": {
"dot-notation": "off",
"no-var": 2,
"prefer-const": 2,
"no-labels": "off",
"indent": ["error", 4],
"no-var": 2,
"prefer-const": 2,
"no-labels": "off",
"no-useless-constructor": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/explicit-function-return-type": "off",
@@ -28,6 +26,12 @@
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "debug" }],
"max-len": ["warn", {
"code": 120,
"ignoreRegExpLiterals": true,
"ignoreTemplateLiterals": true,
"ignoreUrls": true
}],
"no-unused-vars": "off",
"no-dupe-class-members": "off",
"import/export": "off"
65 changes: 65 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

> 请先尝试升级 San、San-SSR 到最新的版本。
**To Reproduce**

请提供一个可以复现的最小 case,例如:

反解错误时:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bug Report</title>
</head>

<body>
<script src="./node_modules/san/dist/san.js"></script>
<div id="root">
<!-- San-SSR 的输出结果 -->
</div>
<script>
// 组件定义
let MyApp = san.defineComponent({
template: ``,
})
let myApp = new MyApp({el: document.getElementById('root').firstElementChild});
myApp.attach(document.getElementById('root'));
</script>
</body>
</html>
```

编译错误时:
```javascript
const san = require('san')

const MyComponent = san.defineComponent({
template: '',
initData () {
return {
}
}
})

module.exports = MyComponent
```

**Versions (please complete the following information):**
- San: [e.g. x.x.x]
- San-SSR: [e.g. x.x.x]

**Additional context**
Add any other context about the problem here.
34 changes: 34 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
check:
name: Check
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['12', '14', '16']
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Unit Test
run: |
npm run build
npm run coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release
on: workflow_dispatch
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Unit Test
run: |
npm ci
npm run build
npm test
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,13 @@ npm-debug.log
/test/karma-context.html
coverage
vendor/
dist/
/dist/
test/cases/*/ssr.js
test/cases/*/ssr.php
test/cases/*/ssr.php
test/cases/*/output
.vscode
/example
bin/sample
bin/output.js
bin/component*.js
bin/dist
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

Loading