chrome-devtools-frontend 1.0.943709 → 1.0.945329

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/config/gni/devtools_grd_files.gni +3 -0
  2. package/front_end/core/common/ParsedURL.ts +1 -1
  3. package/front_end/core/host/UserMetrics.ts +2 -1
  4. package/front_end/core/i18n/i18nImpl.ts +7 -4
  5. package/front_end/core/i18n/locales/en-US.json +3 -72
  6. package/front_end/core/i18n/locales/en-XL.json +15 -84
  7. package/front_end/core/protocol_client/NodeURL.ts +1 -0
  8. package/front_end/core/sdk/CSSStyleDeclaration.ts +4 -0
  9. package/front_end/core/sdk/CSSStyleSheetHeader.ts +2 -3
  10. package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +2 -3
  11. package/front_end/core/sdk/Cookie.ts +17 -0
  12. package/front_end/core/sdk/CookieModel.ts +1 -0
  13. package/front_end/core/sdk/DebuggerModel.ts +5 -4
  14. package/front_end/core/sdk/NetworkManager.ts +4 -1
  15. package/front_end/core/sdk/NetworkRequest.ts +2 -2
  16. package/front_end/core/sdk/OverlayModel.ts +0 -9
  17. package/front_end/core/sdk/Resource.ts +2 -2
  18. package/front_end/core/sdk/Script.ts +2 -7
  19. package/front_end/core/sdk/sdk-meta.ts +0 -26
  20. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +0 -13
  21. package/front_end/entrypoints/main/MainImpl.ts +4 -0
  22. package/front_end/models/bindings/BreakpointManager.ts +3 -4
  23. package/front_end/models/bindings/DefaultScriptMapping.ts +1 -9
  24. package/front_end/models/bindings/ResourceMapping.ts +1 -2
  25. package/front_end/models/bindings/ResourceScriptMapping.ts +3 -11
  26. package/front_end/models/bindings/StylesSourceMapping.ts +1 -2
  27. package/front_end/models/formatter/SourceFormatter.ts +0 -15
  28. package/front_end/models/persistence/IsolatedFileSystem.ts +7 -6
  29. package/front_end/models/persistence/PersistenceActions.ts +4 -1
  30. package/front_end/models/persistence/PlatformFileSystem.ts +3 -4
  31. package/front_end/models/text_utils/ContentProvider.ts +1 -2
  32. package/front_end/models/text_utils/StaticContentProvider.ts +2 -3
  33. package/front_end/models/workspace/UISourceCode.ts +2 -2
  34. package/front_end/models/workspace_diff/WorkspaceDiff.ts +20 -6
  35. package/front_end/panels/animation/animationTimeline.css +2 -0
  36. package/front_end/panels/application/BackForwardCacheStrings.ts +15 -75
  37. package/front_end/panels/application/ReportingApiView.ts +15 -1
  38. package/front_end/panels/application/components/EndpointsGrid.ts +63 -4
  39. package/front_end/panels/application/components/FrameDetailsView.ts +21 -34
  40. package/front_end/panels/changes/ChangesView.ts +8 -7
  41. package/front_end/panels/console/ConsolePinPane.ts +1 -0
  42. package/front_end/panels/console/ConsolePrompt.ts +121 -171
  43. package/front_end/panels/console/ConsoleView.ts +1 -1
  44. package/front_end/panels/console/consoleView.css +1 -1
  45. package/front_end/panels/css_overview/cssOverviewCompletedView.css +2 -2
  46. package/front_end/panels/elements/AccessibilityTreeUtils.ts +98 -67
  47. package/front_end/panels/elements/AccessibilityTreeView.ts +76 -126
  48. package/front_end/panels/elements/ElementsPanel.ts +6 -7
  49. package/front_end/panels/elements/ElementsTreeElement.ts +1 -0
  50. package/front_end/panels/elements/StylePropertyHighlighter.ts +29 -19
  51. package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
  52. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +27 -3
  53. package/front_end/panels/emulation/DeviceModeView.ts +3 -0
  54. package/front_end/panels/help/ReleaseNoteText.ts +3 -1
  55. package/front_end/panels/network/NetworkDataGridNode.ts +5 -1
  56. package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +1 -1
  57. package/front_end/panels/sources/BreakpointEditDialog.ts +1 -0
  58. package/front_end/panels/sources/DebuggerPlugin.ts +1 -1
  59. package/front_end/panels/sources/NavigatorView.ts +1 -1
  60. package/front_end/panels/sources/UISourceCodeFrame.ts +0 -1
  61. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +3 -34
  62. package/front_end/panels/timeline/TimelineUIUtils.ts +51 -3
  63. package/front_end/services/window_bounds/WindowBoundsService.ts +27 -0
  64. package/front_end/services/window_bounds/window_bounds.ts +9 -0
  65. package/front_end/third_party/acorn/README.chromium +2 -2
  66. package/front_end/third_party/acorn/acorn.ts +1 -1
  67. package/front_end/third_party/acorn/package/CHANGELOG.md +31 -1
  68. package/front_end/third_party/acorn/package/README.md +1 -1
  69. package/front_end/third_party/acorn/package/dist/acorn.d.ts +3 -0
  70. package/front_end/third_party/acorn/package/dist/acorn.js +772 -708
  71. package/front_end/third_party/acorn/package/dist/acorn.mjs +767 -703
  72. package/front_end/third_party/acorn/package/dist/bin.js +47 -21
  73. package/front_end/third_party/acorn/package/package.json +1 -1
  74. package/front_end/third_party/acorn-loose/README.chromium +2 -2
  75. package/front_end/third_party/acorn-loose/package/CHANGELOG.md +12 -0
  76. package/front_end/third_party/acorn-loose/package/dist/acorn-loose.js +27 -7
  77. package/front_end/third_party/acorn-loose/package/dist/acorn-loose.mjs +28 -8
  78. package/front_end/third_party/acorn-loose/package/package.json +2 -2
  79. package/front_end/third_party/codemirror.next/bundle.ts +4 -3
  80. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  81. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +39 -1
  82. package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
  83. package/front_end/third_party/codemirror.next/package.json +4 -4
  84. package/front_end/third_party/i18n/i18n-impl.ts +1 -1
  85. package/front_end/third_party/lit-html/README.chromium +2 -2
  86. package/front_end/third_party/lit-html/package/CHANGELOG.md +216 -28
  87. package/front_end/third_party/lit-html/package/LICENSE +9 -9
  88. package/front_end/third_party/lit-html/package/README.md +12 -162
  89. package/front_end/third_party/lit-html/package/async-directive.d.ts +23 -54
  90. package/front_end/third_party/lit-html/package/async-directive.d.ts.map +1 -1
  91. package/front_end/third_party/lit-html/package/async-directive.js +2 -7
  92. package/front_end/third_party/lit-html/package/async-directive.js.map +1 -1
  93. package/front_end/third_party/lit-html/package/development/async-directive.d.ts +23 -54
  94. package/front_end/third_party/lit-html/package/development/async-directive.d.ts.map +1 -1
  95. package/front_end/third_party/lit-html/package/development/async-directive.js +44 -194
  96. package/front_end/third_party/lit-html/package/development/async-directive.js.map +1 -1
  97. package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts +6 -5
  98. package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts.map +1 -1
  99. package/front_end/third_party/lit-html/package/development/directive-helpers.js +25 -9
  100. package/front_end/third_party/lit-html/package/development/directive-helpers.js.map +1 -1
  101. package/front_end/third_party/lit-html/package/development/directive.d.ts +3 -16
  102. package/front_end/third_party/lit-html/package/development/directive.d.ts.map +1 -1
  103. package/front_end/third_party/lit-html/package/development/directive.js +6 -1
  104. package/front_end/third_party/lit-html/package/development/directive.js.map +1 -1
  105. package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts +7 -14
  106. package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts.map +1 -1
  107. package/front_end/third_party/lit-html/package/development/directives/async-append.js +17 -58
  108. package/front_end/third_party/lit-html/package/development/directives/async-append.js.map +1 -1
  109. package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts +9 -14
  110. package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts.map +1 -1
  111. package/front_end/third_party/lit-html/package/development/directives/async-replace.js +57 -37
  112. package/front_end/third_party/lit-html/package/development/directives/async-replace.js.map +1 -1
  113. package/front_end/third_party/lit-html/package/development/directives/cache.d.ts +2 -3
  114. package/front_end/third_party/lit-html/package/development/directives/cache.d.ts.map +1 -1
  115. package/front_end/third_party/lit-html/package/development/directives/cache.js +4 -6
  116. package/front_end/third_party/lit-html/package/development/directives/cache.js.map +1 -1
  117. package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts +2 -2
  118. package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts.map +1 -1
  119. package/front_end/third_party/lit-html/package/development/directives/class-map.js +17 -7
  120. package/front_end/third_party/lit-html/package/development/directives/class-map.js.map +1 -1
  121. package/front_end/third_party/lit-html/package/development/directives/guard.d.ts +3 -2
  122. package/front_end/third_party/lit-html/package/development/directives/guard.d.ts.map +1 -1
  123. package/front_end/third_party/lit-html/package/development/directives/guard.js +3 -2
  124. package/front_end/third_party/lit-html/package/development/directives/guard.js.map +1 -1
  125. package/front_end/third_party/lit-html/package/development/directives/live.d.ts +4 -3
  126. package/front_end/third_party/lit-html/package/development/directives/live.d.ts.map +1 -1
  127. package/front_end/third_party/lit-html/package/development/directives/live.js +5 -7
  128. package/front_end/third_party/lit-html/package/development/directives/live.js.map +1 -1
  129. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts +58 -0
  130. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts.map +1 -0
  131. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js +85 -0
  132. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js.map +1 -0
  133. package/front_end/third_party/lit-html/package/development/directives/ref.d.ts +14 -11
  134. package/front_end/third_party/lit-html/package/development/directives/ref.d.ts.map +1 -1
  135. package/front_end/third_party/lit-html/package/development/directives/ref.js +13 -11
  136. package/front_end/third_party/lit-html/package/development/directives/ref.js.map +1 -1
  137. package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts +8 -4
  138. package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts.map +1 -1
  139. package/front_end/third_party/lit-html/package/development/directives/repeat.js +23 -9
  140. package/front_end/third_party/lit-html/package/development/directives/repeat.js.map +1 -1
  141. package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts +1 -2
  142. package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts.map +1 -1
  143. package/front_end/third_party/lit-html/package/development/directives/style-map.js +1 -2
  144. package/front_end/third_party/lit-html/package/development/directives/style-map.js.map +1 -1
  145. package/front_end/third_party/lit-html/package/development/directives/template-content.d.ts +1 -2
  146. package/front_end/third_party/lit-html/package/development/directives/template-content.js +1 -2
  147. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts +6 -4
  148. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts.map +1 -1
  149. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js +7 -5
  150. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js.map +1 -1
  151. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts +4 -1
  152. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts.map +1 -1
  153. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js +3 -0
  154. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js.map +1 -1
  155. package/front_end/third_party/lit-html/package/development/directives/until.d.ts +12 -8
  156. package/front_end/third_party/lit-html/package/development/directives/until.d.ts.map +1 -1
  157. package/front_end/third_party/lit-html/package/development/directives/until.js +63 -23
  158. package/front_end/third_party/lit-html/package/development/directives/until.js.map +1 -1
  159. package/front_end/third_party/lit-html/package/development/experimental-hydrate.d.ts.map +1 -1
  160. package/front_end/third_party/lit-html/package/development/experimental-hydrate.js +9 -8
  161. package/front_end/third_party/lit-html/package/development/experimental-hydrate.js.map +1 -1
  162. package/front_end/third_party/lit-html/package/development/lit-html.d.ts +81 -136
  163. package/front_end/third_party/lit-html/package/development/lit-html.d.ts.map +1 -1
  164. package/front_end/third_party/lit-html/package/development/lit-html.js +249 -76
  165. package/front_end/third_party/lit-html/package/development/lit-html.js.map +1 -1
  166. package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts +1 -41
  167. package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts.map +1 -1
  168. package/front_end/third_party/lit-html/package/development/polyfill-support.js +40 -21
  169. package/front_end/third_party/lit-html/package/development/polyfill-support.js.map +1 -1
  170. package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts +12 -10
  171. package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts.map +1 -1
  172. package/front_end/third_party/lit-html/package/development/private-ssr-support.js +11 -3
  173. package/front_end/third_party/lit-html/package/development/private-ssr-support.js.map +1 -1
  174. package/front_end/third_party/lit-html/package/development/static.d.ts.map +1 -1
  175. package/front_end/third_party/lit-html/package/development/static.js +6 -5
  176. package/front_end/third_party/lit-html/package/development/static.js.map +1 -1
  177. package/front_end/third_party/lit-html/package/directive-helpers.d.ts +6 -5
  178. package/front_end/third_party/lit-html/package/directive-helpers.d.ts.map +1 -1
  179. package/front_end/third_party/lit-html/package/directive-helpers.js +2 -2
  180. package/front_end/third_party/lit-html/package/directive-helpers.js.map +1 -1
  181. package/front_end/third_party/lit-html/package/directive.d.ts +3 -16
  182. package/front_end/third_party/lit-html/package/directive.d.ts.map +1 -1
  183. package/front_end/third_party/lit-html/package/directive.js +1 -1
  184. package/front_end/third_party/lit-html/package/directive.js.map +1 -1
  185. package/front_end/third_party/lit-html/package/directives/async-append.d.ts +7 -14
  186. package/front_end/third_party/lit-html/package/directives/async-append.d.ts.map +1 -1
  187. package/front_end/third_party/lit-html/package/directives/async-append.js +2 -6
  188. package/front_end/third_party/lit-html/package/directives/async-append.js.map +1 -1
  189. package/front_end/third_party/lit-html/package/directives/async-replace.d.ts +9 -14
  190. package/front_end/third_party/lit-html/package/directives/async-replace.d.ts.map +1 -1
  191. package/front_end/third_party/lit-html/package/directives/async-replace.js +2 -5
  192. package/front_end/third_party/lit-html/package/directives/async-replace.js.map +1 -1
  193. package/front_end/third_party/lit-html/package/directives/cache.d.ts +2 -3
  194. package/front_end/third_party/lit-html/package/directives/cache.d.ts.map +1 -1
  195. package/front_end/third_party/lit-html/package/directives/cache.js +2 -5
  196. package/front_end/third_party/lit-html/package/directives/cache.js.map +1 -1
  197. package/front_end/third_party/lit-html/package/directives/class-map.d.ts +2 -2
  198. package/front_end/third_party/lit-html/package/directives/class-map.d.ts.map +1 -1
  199. package/front_end/third_party/lit-html/package/directives/class-map.js +2 -4
  200. package/front_end/third_party/lit-html/package/directives/class-map.js.map +1 -1
  201. package/front_end/third_party/lit-html/package/directives/guard.d.ts +3 -2
  202. package/front_end/third_party/lit-html/package/directives/guard.d.ts.map +1 -1
  203. package/front_end/third_party/lit-html/package/directives/guard.js +2 -4
  204. package/front_end/third_party/lit-html/package/directives/guard.js.map +1 -1
  205. package/front_end/third_party/lit-html/package/directives/live.d.ts +4 -3
  206. package/front_end/third_party/lit-html/package/directives/live.d.ts.map +1 -1
  207. package/front_end/third_party/lit-html/package/directives/live.js +1 -4
  208. package/front_end/third_party/lit-html/package/directives/live.js.map +1 -1
  209. package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts +58 -0
  210. package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts.map +1 -0
  211. package/front_end/third_party/lit-html/package/directives/private-async-helpers.js +7 -0
  212. package/front_end/third_party/lit-html/package/directives/private-async-helpers.js.map +1 -0
  213. package/front_end/third_party/lit-html/package/directives/ref.d.ts +14 -11
  214. package/front_end/third_party/lit-html/package/directives/ref.d.ts.map +1 -1
  215. package/front_end/third_party/lit-html/package/directives/ref.js +2 -5
  216. package/front_end/third_party/lit-html/package/directives/ref.js.map +1 -1
  217. package/front_end/third_party/lit-html/package/directives/repeat.d.ts +8 -4
  218. package/front_end/third_party/lit-html/package/directives/repeat.d.ts.map +1 -1
  219. package/front_end/third_party/lit-html/package/directives/repeat.js +2 -5
  220. package/front_end/third_party/lit-html/package/directives/repeat.js.map +1 -1
  221. package/front_end/third_party/lit-html/package/directives/style-map.d.ts +1 -2
  222. package/front_end/third_party/lit-html/package/directives/style-map.d.ts.map +1 -1
  223. package/front_end/third_party/lit-html/package/directives/style-map.js +2 -4
  224. package/front_end/third_party/lit-html/package/directives/style-map.js.map +1 -1
  225. package/front_end/third_party/lit-html/package/directives/template-content.d.ts +1 -2
  226. package/front_end/third_party/lit-html/package/directives/template-content.js +2 -4
  227. package/front_end/third_party/lit-html/package/directives/template-content.js.map +1 -1
  228. package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts +6 -4
  229. package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts.map +1 -1
  230. package/front_end/third_party/lit-html/package/directives/unsafe-html.js +2 -4
  231. package/front_end/third_party/lit-html/package/directives/unsafe-html.js.map +1 -1
  232. package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts +4 -1
  233. package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts.map +1 -1
  234. package/front_end/third_party/lit-html/package/directives/unsafe-svg.js.map +1 -1
  235. package/front_end/third_party/lit-html/package/directives/until.d.ts +12 -8
  236. package/front_end/third_party/lit-html/package/directives/until.d.ts.map +1 -1
  237. package/front_end/third_party/lit-html/package/directives/until.js +2 -6
  238. package/front_end/third_party/lit-html/package/directives/until.js.map +1 -1
  239. package/front_end/third_party/lit-html/package/experimental-hydrate.d.ts.map +1 -1
  240. package/front_end/third_party/lit-html/package/experimental-hydrate.js +2 -5
  241. package/front_end/third_party/lit-html/package/experimental-hydrate.js.map +1 -1
  242. package/front_end/third_party/lit-html/package/lit-html.d.ts +81 -136
  243. package/front_end/third_party/lit-html/package/lit-html.d.ts.map +1 -1
  244. package/front_end/third_party/lit-html/package/lit-html.js +1 -1
  245. package/front_end/third_party/lit-html/package/lit-html.js.map +1 -1
  246. package/front_end/third_party/lit-html/package/package.json +75 -24
  247. package/front_end/third_party/lit-html/package/polyfill-support.d.ts +1 -41
  248. package/front_end/third_party/lit-html/package/polyfill-support.d.ts.map +1 -1
  249. package/front_end/third_party/lit-html/package/polyfill-support.js +1 -1
  250. package/front_end/third_party/lit-html/package/polyfill-support.js.map +1 -1
  251. package/front_end/third_party/lit-html/package/private-ssr-support.d.ts +12 -10
  252. package/front_end/third_party/lit-html/package/private-ssr-support.d.ts.map +1 -1
  253. package/front_end/third_party/lit-html/package/private-ssr-support.js +2 -2
  254. package/front_end/third_party/lit-html/package/private-ssr-support.js.map +1 -1
  255. package/front_end/third_party/lit-html/package/static.d.ts.map +1 -1
  256. package/front_end/third_party/lit-html/package/static.js +1 -1
  257. package/front_end/third_party/lit-html/package/static.js.map +1 -1
  258. package/front_end/third_party/marked/README.chromium +2 -2
  259. package/front_end/third_party/marked/marked.ts +2 -2
  260. package/front_end/third_party/marked/package/README.md +7 -1
  261. package/front_end/third_party/marked/package/bin/marked.js +214 -0
  262. package/front_end/third_party/marked/package/lib/marked.cjs +2907 -0
  263. package/front_end/third_party/marked/package/lib/marked.esm.d.ts +1 -3
  264. package/front_end/third_party/marked/package/lib/marked.esm.js +627 -586
  265. package/front_end/third_party/marked/package/lib/marked.umd.js +2913 -0
  266. package/front_end/third_party/marked/package/man/marked.1 +5 -24
  267. package/front_end/third_party/marked/package/man/marked.1.txt +21 -31
  268. package/front_end/third_party/marked/package/marked.min.js +1 -1
  269. package/front_end/third_party/marked/package/package.json +41 -32
  270. package/front_end/third_party/marked/package/src/Lexer.js +109 -108
  271. package/front_end/third_party/marked/package/src/Parser.js +38 -15
  272. package/front_end/third_party/marked/package/src/Renderer.js +5 -5
  273. package/front_end/third_party/marked/package/src/Slugger.js +2 -2
  274. package/front_end/third_party/marked/package/src/TextRenderer.js +2 -2
  275. package/front_end/third_party/marked/package/src/Tokenizer.js +215 -190
  276. package/front_end/third_party/marked/package/src/defaults.js +6 -9
  277. package/front_end/third_party/marked/package/src/helpers.js +16 -27
  278. package/front_end/third_party/marked/package/src/marked.js +146 -63
  279. package/front_end/third_party/marked/package/src/rules.js +20 -45
  280. package/front_end/third_party/wasmparser/README.chromium +2 -2
  281. package/front_end/third_party/wasmparser/package/.github/workflows/main.yml +47 -0
  282. package/front_end/third_party/wasmparser/package/CHANGELOG.md +12 -0
  283. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js +53 -53
  284. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js.map +1 -1
  285. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js +53 -53
  286. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js.map +1 -1
  287. package/front_end/third_party/wasmparser/package/package.json +1 -1
  288. package/front_end/third_party/wasmparser/package/src/WasmParser.ts +53 -53
  289. package/front_end/ui/components/text_editor/TextEditor.ts +29 -0
  290. package/front_end/ui/components/text_editor/config.ts +36 -14
  291. package/front_end/ui/components/text_editor/javascript.ts +14 -9
  292. package/front_end/ui/components/text_editor/theme.ts +29 -4
  293. package/front_end/ui/legacy/InspectorView.ts +1 -1
  294. package/front_end/ui/legacy/ViewManager.ts +6 -0
  295. package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +20 -0
  296. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +1 -0
  297. package/front_end/ui/legacy/components/utils/Linkifier.ts +49 -79
  298. package/front_end/ui/legacy/themeColors.css +2 -0
  299. package/inspector_overlay/main.ts +3 -0
  300. package/package.json +1 -1
@@ -3,39 +3,48 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { AsyncDirective } from '../async-directive.js';
7
- import { isPrimitive } from '../directive-helpers.js';
8
- import { directive } from '../directive.js';
9
6
  import { noChange } from '../lit-html.js';
10
-
7
+ import { directive } from '../directive.js';
8
+ import { isPrimitive } from '../directive-helpers.js';
9
+ import { AsyncDirective } from '../async-directive.js';
10
+ import { Pauser, PseudoWeakRef } from './private-async-helpers.js';
11
11
  const isPromise = (x) => {
12
12
  return !isPrimitive(x) && typeof x.then === 'function';
13
13
  };
14
14
  // Effectively infinity, but a SMI.
15
- const _infinity = 0x7fffffff;
16
- class UntilDirective extends AsyncDirective {
15
+ const _infinity = 0x3fffffff;
16
+ export class UntilDirective extends AsyncDirective {
17
17
  constructor() {
18
18
  super(...arguments);
19
- this._lastRenderedIndex = _infinity;
20
- this._values = [];
19
+ this.__lastRenderedIndex = _infinity;
20
+ this.__values = [];
21
+ this.__weakThis = new PseudoWeakRef(this);
22
+ this.__pauser = new Pauser();
21
23
  }
22
24
  render(...args) {
23
25
  var _a;
24
26
  return (_a = args.find((x) => !isPromise(x))) !== null && _a !== void 0 ? _a : noChange;
25
27
  }
26
28
  update(_part, args) {
27
- const previousValues = this._values;
29
+ const previousValues = this.__values;
28
30
  let previousLength = previousValues.length;
29
- this._values = args;
31
+ this.__values = args;
32
+ const weakThis = this.__weakThis;
33
+ const pauser = this.__pauser;
34
+ // If our initial render occurs while disconnected, ensure that the pauser
35
+ // and weakThis are in the disconnected state
36
+ if (!this.isConnected) {
37
+ this.disconnected();
38
+ }
30
39
  for (let i = 0; i < args.length; i++) {
31
40
  // If we've rendered a higher-priority value already, stop.
32
- if (i > this._lastRenderedIndex) {
41
+ if (i > this.__lastRenderedIndex) {
33
42
  break;
34
43
  }
35
44
  const value = args[i];
36
45
  // Render non-Promise values immediately
37
46
  if (!isPromise(value)) {
38
- this._lastRenderedIndex = i;
47
+ this.__lastRenderedIndex = i;
39
48
  // Since a lower-priority value will never overwrite a higher-priority
40
49
  // synchronous value, we can stop processing now.
41
50
  return value;
@@ -46,21 +55,45 @@ class UntilDirective extends AsyncDirective {
46
55
  }
47
56
  // We have a Promise that we haven't seen before, so priorities may have
48
57
  // changed. Forget what we rendered before.
49
- this._lastRenderedIndex = _infinity;
58
+ this.__lastRenderedIndex = _infinity;
50
59
  previousLength = 0;
51
- Promise.resolve(value).then((resolvedValue) => {
52
- const index = this._values.indexOf(value);
53
- // If state.values doesn't contain the value, we've re-rendered without
54
- // the value, so don't render it. Then, only render if the value is
55
- // higher-priority than what's already been rendered.
56
- if (index > -1 && index < this._lastRenderedIndex) {
57
- this._lastRenderedIndex = index;
58
- this.setValue(resolvedValue);
60
+ // Note, the callback avoids closing over `this` so that the directive
61
+ // can be gc'ed before the promise resolves; instead `this` is retrieved
62
+ // from `weakThis`, which can break the hard reference in the closure when
63
+ // the directive disconnects
64
+ Promise.resolve(value).then(async (result) => {
65
+ // If we're disconnected, wait until we're (maybe) reconnected
66
+ // The while loop here handles the case that the connection state
67
+ // thrashes, causing the pauser to resume and then get re-paused
68
+ while (pauser.get()) {
69
+ await pauser.get();
70
+ }
71
+ // If the callback gets here and there is no `this`, it means that the
72
+ // directive has been disconnected and garbage collected and we don't
73
+ // need to do anything else
74
+ const _this = weakThis.deref();
75
+ if (_this !== undefined) {
76
+ const index = _this.__values.indexOf(value);
77
+ // If state.values doesn't contain the value, we've re-rendered without
78
+ // the value, so don't render it. Then, only render if the value is
79
+ // higher-priority than what's already been rendered.
80
+ if (index > -1 && index < _this.__lastRenderedIndex) {
81
+ _this.__lastRenderedIndex = index;
82
+ _this.setValue(result);
83
+ }
59
84
  }
60
85
  });
61
86
  }
62
87
  return noChange;
63
88
  }
89
+ disconnected() {
90
+ this.__weakThis.disconnect();
91
+ this.__pauser.pause();
92
+ }
93
+ reconnected() {
94
+ this.__weakThis.reconnect(this);
95
+ this.__pauser.resume();
96
+ }
64
97
  }
65
98
  /**
66
99
  * Renders one of a series of values, including Promises, to a Part.
@@ -78,8 +111,15 @@ class UntilDirective extends AsyncDirective {
78
111
  *
79
112
  * Example:
80
113
  *
81
- * const content = fetch('./content.txt').then(r => r.text());
82
- * html`${until(content, html`<span>Loading...</span>`)}`
114
+ * ```js
115
+ * const content = fetch('./content.txt').then(r => r.text());
116
+ * html`${until(content, html`<span>Loading...</span>`)}`
117
+ * ```
83
118
  */
84
119
  export const until = directive(UntilDirective);
120
+ /**
121
+ * The type of the class that powers this directive. Necessary for naming the
122
+ * directive's return type.
123
+ */
124
+ // export type {UntilDirective};
85
125
  //# sourceMappingURL=until.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/directives/until.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAO,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAErD,MAAM,SAAS,GAAG,CAAC,CAAU,EAAE,EAAE;IAC/B,OAAO,CAAC,WAAW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O,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,aAAsB,EAAE,EAAE;gBACrD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC1C,uEAAuE;gBACvE,mEAAmE;gBACnE,qDAAqD;gBACrD,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,kBAAkB,EAAE;oBACjD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;oBAChC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;iBAC9B;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Part, noChange} from '../lit-html.js';\nimport {directive} from '../directive.js';\nimport {isPrimitive} from '../directive-helpers.js';\nimport {AsyncDirective} from '../async-directive.js';\n\nconst isPromise = (x: unknown) => {\n return !isPrimitive(x) && typeof (x as {then?: unknown}).then === 'function';\n};\n// Effectively infinity, but a SMI.\nconst _infinity = 0x7fffffff;\n\nclass UntilDirective extends AsyncDirective {\n private _lastRenderedIndex: number = _infinity;\n private _values: unknown[] = [];\n\n render(...args: Array<unknown>) {\n return args.find((x) => !isPromise(x)) ?? noChange;\n }\n\n update(_part: Part, args: Array<unknown>) {\n const previousValues = this._values;\n let previousLength = previousValues.length;\n this._values = args;\n\n for (let i = 0; i < args.length; i++) {\n // If we've rendered a higher-priority value already, stop.\n if (i > this._lastRenderedIndex) {\n break;\n }\n\n const value = args[i];\n\n // Render non-Promise values immediately\n if (!isPromise(value)) {\n this._lastRenderedIndex = i;\n // Since a lower-priority value will never overwrite a higher-priority\n // synchronous value, we can stop processing now.\n return value;\n }\n\n // If this is a Promise we've already handled, skip it.\n if (i < previousLength && value === previousValues[i]) {\n continue;\n }\n\n // We have a Promise that we haven't seen before, so priorities may have\n // changed. Forget what we rendered before.\n this._lastRenderedIndex = _infinity;\n previousLength = 0;\n\n Promise.resolve(value).then((resolvedValue: unknown) => {\n const index = this._values.indexOf(value);\n // If state.values doesn't contain the value, we've re-rendered without\n // the value, so don't render it. Then, only render if the value is\n // higher-priority than what's already been rendered.\n if (index > -1 && index < this._lastRenderedIndex) {\n this._lastRenderedIndex = index;\n this.setValue(resolvedValue);\n }\n });\n }\n\n return noChange;\n }\n}\n\n/**\n * Renders one of a series of values, including Promises, to a Part.\n *\n * Values are rendered in priority order, with the first argument having the\n * highest priority and the last argument having the lowest priority. If a\n * value is a Promise, low-priority values will be rendered until it resolves.\n *\n * The priority of values can be used to create placeholder content for async\n * data. For example, a Promise with pending content can be the first,\n * highest-priority, argument, and a non_promise loading indicator template can\n * be used as the second, lower-priority, argument. The loading indicator will\n * render immediately, and the primary content will render when the Promise\n * resolves.\n *\n * Example:\n *\n * const content = fetch('./content.txt').then(r => r.text());\n * html`${until(content, html`<span>Loading...</span>`)}`\n */\nexport const until = directive(UntilDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {UntilDirective};\n"]}
1
+ {"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/directives/until.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAO,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAEjE,MAAM,SAAS,GAAG,CAAC,CAAU,EAAE,EAAE;IAC/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AAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEQ,WAAW;QAClB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AAE/C;;;GAGG;AACH,gCAAgC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Part, noChange} from '../lit-html.js';\nimport {directive} from '../directive.js';\nimport {isPrimitive} from '../directive-helpers.js';\nimport {AsyncDirective} from '../async-directive.js';\nimport {Pauser, PseudoWeakRef} from './private-async-helpers.js';\n\nconst isPromise = (x: unknown) => {\n return !isPrimitive(x) && typeof (x as {then?: unknown}).then === 'function';\n};\n// Effectively infinity, but a SMI.\nconst _infinity = 0x3fffffff;\n\nexport class UntilDirective extends AsyncDirective {\n private __lastRenderedIndex: number = _infinity;\n private __values: unknown[] = [];\n private __weakThis = new PseudoWeakRef(this);\n private __pauser = new Pauser();\n\n render(...args: Array<unknown>) {\n return args.find((x) => !isPromise(x)) ?? noChange;\n }\n\n override update(_part: Part, args: Array<unknown>) {\n const previousValues = this.__values;\n let previousLength = previousValues.length;\n this.__values = args;\n\n const weakThis = this.__weakThis;\n const pauser = this.__pauser;\n\n // If our initial render occurs while disconnected, ensure that the pauser\n // and weakThis are in the disconnected state\n if (!this.isConnected) {\n this.disconnected();\n }\n\n for (let i = 0; i < args.length; i++) {\n // If we've rendered a higher-priority value already, stop.\n if (i > this.__lastRenderedIndex) {\n break;\n }\n\n const value = args[i];\n\n // Render non-Promise values immediately\n if (!isPromise(value)) {\n this.__lastRenderedIndex = i;\n // Since a lower-priority value will never overwrite a higher-priority\n // synchronous value, we can stop processing now.\n return value;\n }\n\n // If this is a Promise we've already handled, skip it.\n if (i < previousLength && value === previousValues[i]) {\n continue;\n }\n\n // We have a Promise that we haven't seen before, so priorities may have\n // changed. Forget what we rendered before.\n this.__lastRenderedIndex = _infinity;\n previousLength = 0;\n\n // Note, the callback avoids closing over `this` so that the directive\n // can be gc'ed before the promise resolves; instead `this` is retrieved\n // from `weakThis`, which can break the hard reference in the closure when\n // the directive disconnects\n Promise.resolve(value).then(async (result: unknown) => {\n // If we're disconnected, wait until we're (maybe) reconnected\n // The while loop here handles the case that the connection state\n // thrashes, causing the pauser to resume and then get re-paused\n while (pauser.get()) {\n await pauser.get();\n }\n // If the callback gets here and there is no `this`, it means that the\n // directive has been disconnected and garbage collected and we don't\n // need to do anything else\n const _this = weakThis.deref();\n if (_this !== undefined) {\n const index = _this.__values.indexOf(value);\n // If state.values doesn't contain the value, we've re-rendered without\n // the value, so don't render it. Then, only render if the value is\n // higher-priority than what's already been rendered.\n if (index > -1 && index < _this.__lastRenderedIndex) {\n _this.__lastRenderedIndex = index;\n _this.setValue(result);\n }\n }\n });\n }\n\n return noChange;\n }\n\n override disconnected() {\n this.__weakThis.disconnect();\n this.__pauser.pause();\n }\n\n override reconnected() {\n this.__weakThis.reconnect(this);\n this.__pauser.resume();\n }\n}\n\n/**\n * Renders one of a series of values, including Promises, to a Part.\n *\n * Values are rendered in priority order, with the first argument having the\n * highest priority and the last argument having the lowest priority. If a\n * value is a Promise, low-priority values will be rendered until it resolves.\n *\n * The priority of values can be used to create placeholder content for async\n * data. For example, a Promise with pending content can be the first,\n * highest-priority, argument, and a non_promise loading indicator template can\n * be used as the second, lower-priority, argument. The loading indicator will\n * render immediately, and the primary content will render when the Promise\n * resolves.\n *\n * Example:\n *\n * ```js\n * const content = fetch('./content.txt').then(r => r.text());\n * html`${until(content, html`<span>Loading...</span>`)}`\n * ```\n */\nexport const until = directive(UntilDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\n// export type {UntilDirective};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"experimental-hydrate.d.ts","sourceRoot":"","sources":["../src/experimental-hydrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAElD,OAAO,EAAW,aAAa,EAAK,MAAM,eAAe,CAAC;AA8D1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,OAAO,cACP,OAAO,aACP,OAAO,GAAG,gBAAgB,YAC5B,QAAQ,aAAa,CAAC,SA+DhC,CAAC;AAqPF,eAAO,MAAM,uBAAuB,mBAAoB,cAAc,WASrE,CAAC"}
1
+ {"version":3,"file":"experimental-hydrate.d.ts","sourceRoot":"","sources":["../src/experimental-hydrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAElD,OAAO,EAAW,aAAa,EAAO,MAAM,eAAe,CAAC;AA8D5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,OAAO,cACP,OAAO,aACP,OAAO,GAAG,gBAAgB,YAC5B,QAAQ,aAAa,CAAC,SAiEhC,CAAC;AAqPF,eAAO,MAAM,uBAAuB,mBAAoB,cAAc,WASrE,CAAC"}
@@ -3,11 +3,10 @@
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { isPrimitive, isSingleExpression, isTemplateResult, } from './directive-helpers.js';
6
+ import { noChange, _$LH } from './lit-html.js';
7
7
  import { PartType } from './directive.js';
8
- import { , noChange} from './lit-html.js';
9
-
10
- const { _TemplateInstance: TemplateInstance, _isIterable: isIterable, _resolveDirective: resolveDirective, _ChildPart: ChildPart, _ElementPart: ElementPart, } = _Σ;
8
+ import { isPrimitive, isSingleExpression, isTemplateResult, } from './directive-helpers.js';
9
+ const { _TemplateInstance: TemplateInstance, _isIterable: isIterable, _resolveDirective: resolveDirective, _ChildPart: ChildPart, _ElementPart: ElementPart, } = _$LH;
11
10
  /**
12
11
  * hydrate() operates on a container with server-side rendered content and
13
12
  * restores the client side data structures needed for lit-html updates such as
@@ -51,8 +50,9 @@ const { _TemplateInstance: TemplateInstance, _isIterable: isIterable, _resolveDi
51
50
  */
52
51
  export const hydrate = (rootValue, container, options = {}) => {
53
52
  // TODO(kschaaf): Do we need a helper for _$litPart$ ("part for node")?
53
+ // This property needs to remain unminified.
54
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- if (container._$litPart$ !== undefined) {
55
+ if (container['_$litPart$'] !== undefined) {
56
56
  throw new Error('container already contains a live render');
57
57
  }
58
58
  // Since render() creates a ChildPart to render into, we'll always have
@@ -98,8 +98,9 @@ export const hydrate = (rootValue, container, options = {}) => {
98
98
  }
99
99
  }
100
100
  console.assert(rootPart !== undefined, 'there should be exactly one root part in a render container');
101
+ // This property needs to remain unminified.
101
102
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
- container._$litPart$ = rootPart;
103
+ container['_$litPart$'] = rootPart;
103
104
  };
104
105
  const openChildPart = (rootValue, marker, stack, options) => {
105
106
  let value;
@@ -140,7 +141,7 @@ const openChildPart = (rootValue, marker, stack, options) => {
140
141
  // we need to decide what to do in this case. Note that this part won't be
141
142
  // retained by any parent TemplateInstance, since a primitive had been
142
143
  // rendered in its place.
143
- // https://github.com/Polymer/lit-html/issues/1434
144
+ // https://github.com/lit/lit/issues/1434
144
145
  // throw new Error('Hydration value mismatch: Found a TemplateInstance' +
145
146
  // 'where a leaf value was expected');
146
147
  part = new ChildPart(marker, null, state.part, options);
@@ -168,7 +169,7 @@ const openChildPart = (rootValue, marker, stack, options) => {
168
169
  // TODO(kschaaf): We can detect when a primitive is being hydrated on the
169
170
  // client where a TemplateResult was rendered on the server, but we need to
170
171
  // decide on a strategy for what to do next.
171
- // https://github.com/Polymer/lit-html/issues/1434
172
+ // https://github.com/lit/lit/issues/1434
172
173
  // if (marker.data !== 'lit-part') {
173
174
  // throw new Error('Hydration value mismatch: Primitive found where TemplateResult expected');
174
175
  // }
@@ -1 +1 @@
1
- {"version":3,"file":"experimental-hydrate.js","sourceRoot":"","sources":["../src/experimental-hydrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,QAAQ,EAAiB,EAAE,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAoB,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,EACJ,iBAAiB,EAAE,gBAAgB,EACnC,WAAW,EAAE,UAAU,EACvB,iBAAiB,EAAE,gBAAgB,EACnC,UAAU,EAAE,SAAS,EACrB,YAAY,EAAE,WAAW,GAC1B,GAAG,EAAE,CAAC;AAgDP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,SAAkB,EAClB,SAAqC,EACrC,UAAkC,EAAE,EACpC,EAAE;IACF,uEAAuE;IACvE,8DAA8D;IAC9D,IAAK,SAAiB,CAAC,UAAU,KAAK,SAAS,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IAED,uEAAuE;IACvE,yEAAyE;IACzE,yBAAyB;IACzB,IAAI,QAAQ,GAA0B,SAAS,CAAC;IAEhD,2EAA2E;IAC3E,sEAAsE;IACtE,eAAe;IACf,IAAI,gBAAgB,GAA0B,SAAS,CAAC;IAExD,mEAAmE;IACnE,YAAY;IACZ,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,MAAM,MAAM,GAAG,QAAQ,CAAC,gBAAgB,CACtC,SAAS,EACT,UAAU,CAAC,YAAY,EACvB,IAAI,EACJ,KAAK,CACN,CAAC;IACF,IAAI,MAAsB,CAAC;IAE3B,gDAAgD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\nimport type {TemplateResult} from './lit-html.js';\n\nimport {noChange, RenderOptions, _Σ} from './lit-html.js';\nimport {AttributePartInfo, PartType} from './directive.js';\nimport {\n isPrimitive,\n isSingleExpression,\n isTemplateResult,\n} from './directive-helpers.js';\n\nconst {\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n _ChildPart: ChildPart,\n _ElementPart: ElementPart,\n} = _Σ;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\ntype TemplateInstance = InstanceType<typeof TemplateInstance>;\n\n/**\n * Information needed to rehydrate a single TemplateResult.\n */\ntype ChildPartState =\n | {\n type: 'leaf';\n /** The ChildPart that the result is rendered to */\n part: ChildPart;\n }\n | {\n type: 'iterable';\n /** The ChildPart that the result is rendered to */\n part: ChildPart;\n value: Iterable<unknown>;\n iterator: Iterator<unknown>;\n done: boolean;\n }\n | {\n type: 'template-instance';\n /** The ChildPart that the result is rendered to */\n part: ChildPart;\n\n result: TemplateResult;\n\n /** The TemplateInstance created from the TemplateResult */\n instance: TemplateInstance;\n\n /**\n * The index of the next Template part to be hydrated. This is mutable and\n * updated as the tree walk discovers new part markers at the right level in\n * the template instance tree. Note there is only one Template part per\n * attribute with (one or more) bindings.\n */\n templatePartIndex: number;\n\n /**\n * The index of the next TemplateInstance part to be hydrated. This is used\n * to retrieve the value from the TemplateResult and initialize the\n * TemplateInstance parts' values for dirty-checking on first render.\n */\n instancePartIndex: number;\n };\n\n/**\n * hydrate() operates on a container with server-side rendered content and\n * restores the client side data structures needed for lit-html updates such as\n * TemplateInstances and Parts. After calling `hydrate`, lit-html will behave as\n * if it initially rendered the DOM, and any subsequent updates will update\n * efficiently, the same as if lit-html had rendered the DOM on the client.\n *\n * hydrate() must be called on DOM that adheres the to lit-ssr structure for\n * parts. ChildParts must be represented with both a start and end comment\n * marker, and ChildParts that contain a TemplateInstance must have the template\n * digest written into the comment data.\n *\n * Since render() encloses its output in a ChildPart, there must always be a root\n * ChildPart.\n *\n * Example (using for # ... for annotations in HTML)\n *\n * Given this input:\n *\n * html`<div class=${x}>${y}</div>`\n *\n * The SSR DOM is:\n *\n * <!--lit-part AEmR7W+R0Ak=--> # Start marker for the root ChildPart created\n * # by render(). Includes the digest of the\n * # template\n * <div class=\"TEST_X\">\n * <!--lit-node 0--> # Indicates there are attribute bindings here\n * # The number is the depth-first index of the parent\n * # node in the template.\n * <!--lit-part--> # Start marker for the ${x} expression\n * TEST_Y\n * <!--/lit-part--> # End marker for the ${x} expression\n * </div>\n *\n * <!--/lit-part--> # End marker for the root ChildPart\n *\n * @param rootValue\n * @param container\n * @param userOptions\n */\nexport const hydrate = (\n rootValue: unknown,\n container: Element | DocumentFragment,\n options: Partial<RenderOptions> = {}\n) => {\n // TODO(kschaaf): Do we need a helper for _$litPart$ (\"part for node\")?\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((container as any)._$litPart$ !== undefined) {\n throw new Error('container already contains a live render');\n }\n\n // Since render() creates a ChildPart to render into, we'll always have\n // exactly one root part. We need to hold a reference to it so we can set\n // it in the parts cache.\n let rootPart: ChildPart | undefined = undefined;\n\n // When we are in-between ChildPart markers, this is the current ChildPart.\n // It's needed to be able to set the ChildPart's endNode when we see a\n // close marker\n let currentChildPart: ChildPart | undefined = undefined;\n\n // Used to remember parent template state as we recurse into nested\n // templates\n const stack: Array<ChildPartState> = [];\n\n const walker = document.createTreeWalker(\n container,\n NodeFilter.SHOW_COMMENT,\n null,\n false\n );\n let marker: Comment | null;\n\n // Walk the DOM looking for part marker comments\n while ((marker = walker.nextNode() as Comment | null) !== null) {\n const markerText = marker.data;\n if (markerText.startsWith('lit-part')) {\n if (stack.length === 0 && rootPart !== undefined) {\n throw new Error('there must be only one root part per container');\n }\n // Create a new ChildPart and push it onto the stack\n currentChildPart = openChildPart(rootValue, marker, stack, options);\n rootPart ??= currentChildPart;\n } else if (markerText.startsWith('lit-node')) {\n // Create and hydrate attribute parts into the current ChildPart on the\n // stack\n createAttributeParts(marker, stack, options);\n // Remove `defer-hydration` attribute, if any\n const parent = marker.parentElement!;\n if (parent.hasAttribute('defer-hydration')) {\n parent.removeAttribute('defer-hydration');\n }\n } else if (markerText.startsWith('/lit-part')) {\n // Close the current ChildPart, and pop the previous one off the stack\n if (stack.length === 1 && currentChildPart !== rootPart) {\n throw new Error('internal error');\n }\n currentChildPart = closeChildPart(marker, currentChildPart, stack);\n }\n }\n console.assert(\n rootPart !== undefined,\n 'there should be exactly one root part in a render container'\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (container as any)._$litPart$ = rootPart;\n};\n\nconst openChildPart = (\n rootValue: unknown,\n marker: Comment,\n stack: Array<ChildPartState>,\n options: RenderOptions\n) => {\n let value: unknown;\n // We know the startNode now. We'll know the endNode when we get to\n // the matching marker and set it in closeChildPart()\n // TODO(kschaaf): Current constructor takes both nodes\n let part;\n if (stack.length === 0) {\n part = new ChildPart(marker, null, undefined, options);\n value = rootValue;\n } else {\n const state = stack[stack.length - 1];\n if (state.type === 'template-instance') {\n part = new ChildPart(marker, null, state.instance, options);\n state.instance._parts.push(part);\n value = state.result.values[state.instancePartIndex++];\n state.templatePartIndex++;\n } else if (state.type === 'iterable') {\n part = new ChildPart(marker, null, state.part, options);\n const result = state.iterator.next();\n if (result.done) {\n value = undefined;\n state.done = true;\n throw new Error('Unhandled shorter than expected iterable');\n } else {\n value = result.value;\n }\n (state.part._$committedValue as Array<ChildPart>).push(part);\n } else {\n // state.type === 'leaf'\n // TODO(kschaaf): This is unexpected, and likely a result of a primitive\n // been rendered on the client when a TemplateResult was rendered on the\n // server; this part will be hydrated but not used. We can detect it, but\n // we need to decide what to do in this case. Note that this part won't be\n // retained by any parent TemplateInstance, since a primitive had been\n // rendered in its place.\n // https://github.com/Polymer/lit-html/issues/1434\n // throw new Error('Hydration value mismatch: Found a TemplateInstance' +\n // 'where a leaf value was expected');\n part = new ChildPart(marker, null, state.part, options);\n }\n }\n\n // Initialize the ChildPart state depending on the type of value and push\n // it onto the stack. This logic closely follows the ChildPart commit()\n // cascade order:\n // 1. directive\n // 2. noChange\n // 3. primitive (note strings must be handled before iterables, since they\n // are iterable)\n // 4. TemplateResult\n // 5. Node (not yet implemented, but fallback handling is fine)\n // 6. Iterable\n // 7. nothing (handled in fallback)\n // 8. Fallback for everything else\n value = resolveDirective(part, value);\n if (value === noChange) {\n stack.push({part, type: 'leaf'});\n } else if (isPrimitive(value)) {\n stack.push({part, type: 'leaf'});\n part._$committedValue = value;\n // TODO(kschaaf): We can detect when a primitive is being hydrated on the\n // client where a TemplateResult was rendered on the server, but we need to\n // decide on a strategy for what to do next.\n // https://github.com/Polymer/lit-html/issues/1434\n // if (marker.data !== 'lit-part') {\n // throw new Error('Hydration value mismatch: Primitive found where TemplateResult expected');\n // }\n } else if (isTemplateResult(value)) {\n // Check for a template result digest\n const markerWithDigest = `lit-part ${digestForTemplateResult(value)}`;\n if (marker.data === markerWithDigest) {\n const template = ChildPart.prototype._$getTemplate(value);\n const instance = new TemplateInstance(template, part);\n stack.push({\n type: 'template-instance',\n instance,\n part,\n templatePartIndex: 0,\n instancePartIndex: 0,\n result: value,\n });\n // For TemplateResult values, we set the part value to the\n // generated TemplateInstance\n part._$committedValue = instance;\n } else {\n // TODO: if this isn't the server-rendered template, do we\n // need to stop hydrating this subtree? Clear it? Add tests.\n throw new Error(\n 'Hydration value mismatch: Unexpected TemplateResult rendered to part'\n );\n }\n } else if (isIterable(value)) {\n // currentChildPart.value will contain an array of ChildParts\n stack.push({\n part: part,\n type: 'iterable',\n value,\n iterator: value[Symbol.iterator](),\n done: false,\n });\n part._$committedValue = [];\n } else {\n // Fallback for everything else (nothing, Objects, Functions,\n // etc.): we just initialize the part's value\n // Note that `Node` value types are not currently supported during\n // SSR, so that part of the cascade is missing.\n stack.push({part: part, type: 'leaf'});\n part._$committedValue = value == null ? '' : value;\n }\n return part;\n};\n\nconst closeChildPart = (\n marker: Comment,\n part: ChildPart | undefined,\n stack: Array<ChildPartState>\n): ChildPart | undefined => {\n if (part === undefined) {\n throw new Error('unbalanced part marker');\n }\n\n part._$endNode = marker;\n\n const currentState = stack.pop()!;\n\n if (currentState.type === 'iterable') {\n if (!currentState.iterator.next().done) {\n throw new Error('unexpected longer than expected iterable');\n }\n }\n\n if (stack.length > 0) {\n const state = stack[stack.length - 1];\n return state.part;\n } else {\n return undefined;\n }\n};\n\nconst createAttributeParts = (\n comment: Comment,\n stack: Array<ChildPartState>,\n options: RenderOptions\n) => {\n // Get the nodeIndex from DOM. We're only using this for an integrity\n // check right now, we might not need it.\n const match = /lit-node (\\d+)/.exec(comment.data)!;\n const nodeIndex = parseInt(match[1]);\n\n // For void elements, the node the comment was referring to will be\n // the previousSibling; for non-void elements, the comment is guaranteed\n // to be the first child of the element (i.e. it won't have a previousSibling\n // meaning it should use the parentElement)\n const node = comment.previousSibling ?? comment.parentElement;\n\n const state = stack[stack.length - 1];\n if (state.type === 'template-instance') {\n const instance = state.instance;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // If the next template part is in attribute-position on the current node,\n // create the instance part for it and prime its state\n const templatePart = instance._$template.parts[state.templatePartIndex];\n if (\n templatePart === undefined ||\n (templatePart.type !== PartType.ATTRIBUTE &&\n templatePart.type !== PartType.ELEMENT) ||\n templatePart.index !== nodeIndex\n ) {\n break;\n }\n\n if (templatePart.type === PartType.ATTRIBUTE) {\n // The instance part is created based on the constructor saved in the\n // template part\n const instancePart = new templatePart.ctor(\n node as HTMLElement,\n templatePart.name,\n templatePart.strings,\n state.instance,\n options\n );\n\n const value = isSingleExpression(\n (instancePart as unknown) as AttributePartInfo\n )\n ? state.result.values[state.instancePartIndex]\n : state.result.values;\n\n // Setting the attribute value primes committed value with the resolved\n // directive value; we only then commit that value for event/property\n // parts since those were not serialized, and pass `noCommit` for the\n // others to avoid perf impact of touching the DOM unnecessarily\n const noCommit = !(\n instancePart.type === PartType.EVENT ||\n instancePart.type === PartType.PROPERTY\n );\n instancePart._$setValue(\n value,\n instancePart,\n state.instancePartIndex,\n noCommit\n );\n state.instancePartIndex += templatePart.strings.length - 1;\n instance._parts.push(instancePart);\n } else {\n // templatePart.type === PartType.ELEMENT\n const instancePart = new ElementPart(\n node as HTMLElement,\n state.instance,\n options\n );\n resolveDirective(\n instancePart,\n state.result.values[state.instancePartIndex++]\n );\n instance._parts.push(instancePart);\n }\n state.templatePartIndex++;\n }\n } else {\n throw new Error('internal error');\n }\n};\n\n// Number of 32 bit elements to use to create template digests\nconst digestSize = 2;\n// We need to specify a digest to use across rendering environments. This is a\n// simple digest build from a DJB2-ish hash modified from:\n// https://github.com/darkskyapp/string-hash/blob/master/index.js\n// It has been changed to an array of hashes to add additional bits.\n// Goals:\n// - Extremely low collision rate. We may not be able to detect collisions.\n// - Extremely fast.\n// - Extremely small code size.\n// - Safe to include in HTML comment text or attribute value.\n// - Easily specifiable and implementable in multiple languages.\n// We don't care about cryptographic suitability.\nexport const digestForTemplateResult = (templateResult: TemplateResult) => {\n const hashes = new Uint32Array(digestSize).fill(5381);\n\n for (const s of templateResult.strings) {\n for (let i = 0; i < s.length; i++) {\n hashes[i % digestSize] = (hashes[i % digestSize] * 33) ^ s.charCodeAt(i);\n }\n }\n return btoa(String.fromCharCode(...new Uint8Array(hashes.buffer)));\n};\n"]}
1
+ {"version":3,"file":"experimental-hydrate.js","sourceRoot":"","sources":["../src/experimental-hydrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,QAAQ,EAAiB,IAAI,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAoB,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,EACJ,iBAAiB,EAAE,gBAAgB,EACnC,WAAW,EAAE,UAAU,EACvB,iBAAiB,EAAE,gBAAgB,EACnC,UAAU,EAAE,SAAS,EACrB,YAAY,EAAE,WAAW,GAC1B,GAAG,IAAI,CAAC;AAgDT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AA8D;AAC9D,iEAAiE;AACjE,iDAAiD;AACjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,cAA8B,EAAE,EAAE;IACxE,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEtD,KAAK,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SAC1E;KACF;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {TemplateResult} from './lit-html.js';\n\nimport {noChange, RenderOptions, _$LH} from './lit-html.js';\nimport {AttributePartInfo, PartType} from './directive.js';\nimport {\n isPrimitive,\n isSingleExpression,\n isTemplateResult,\n} from './directive-helpers.js';\n\nconst {\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n _ChildPart: ChildPart,\n _ElementPart: ElementPart,\n} = _$LH;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\ntype TemplateInstance = InstanceType<typeof TemplateInstance>;\n\n/**\n * Information needed to rehydrate a single TemplateResult.\n */\ntype ChildPartState =\n | {\n type: 'leaf';\n /** The ChildPart that the result is rendered to */\n part: ChildPart;\n }\n | {\n type: 'iterable';\n /** The ChildPart that the result is rendered to */\n part: ChildPart;\n value: Iterable<unknown>;\n iterator: Iterator<unknown>;\n done: boolean;\n }\n | {\n type: 'template-instance';\n /** The ChildPart that the result is rendered to */\n part: ChildPart;\n\n result: TemplateResult;\n\n /** The TemplateInstance created from the TemplateResult */\n instance: TemplateInstance;\n\n /**\n * The index of the next Template part to be hydrated. This is mutable and\n * updated as the tree walk discovers new part markers at the right level in\n * the template instance tree. Note there is only one Template part per\n * attribute with (one or more) bindings.\n */\n templatePartIndex: number;\n\n /**\n * The index of the next TemplateInstance part to be hydrated. This is used\n * to retrieve the value from the TemplateResult and initialize the\n * TemplateInstance parts' values for dirty-checking on first render.\n */\n instancePartIndex: number;\n };\n\n/**\n * hydrate() operates on a container with server-side rendered content and\n * restores the client side data structures needed for lit-html updates such as\n * TemplateInstances and Parts. After calling `hydrate`, lit-html will behave as\n * if it initially rendered the DOM, and any subsequent updates will update\n * efficiently, the same as if lit-html had rendered the DOM on the client.\n *\n * hydrate() must be called on DOM that adheres the to lit-ssr structure for\n * parts. ChildParts must be represented with both a start and end comment\n * marker, and ChildParts that contain a TemplateInstance must have the template\n * digest written into the comment data.\n *\n * Since render() encloses its output in a ChildPart, there must always be a root\n * ChildPart.\n *\n * Example (using for # ... for annotations in HTML)\n *\n * Given this input:\n *\n * html`<div class=${x}>${y}</div>`\n *\n * The SSR DOM is:\n *\n * <!--lit-part AEmR7W+R0Ak=--> # Start marker for the root ChildPart created\n * # by render(). Includes the digest of the\n * # template\n * <div class=\"TEST_X\">\n * <!--lit-node 0--> # Indicates there are attribute bindings here\n * # The number is the depth-first index of the parent\n * # node in the template.\n * <!--lit-part--> # Start marker for the ${x} expression\n * TEST_Y\n * <!--/lit-part--> # End marker for the ${x} expression\n * </div>\n *\n * <!--/lit-part--> # End marker for the root ChildPart\n *\n * @param rootValue\n * @param container\n * @param userOptions\n */\nexport const hydrate = (\n rootValue: unknown,\n container: Element | DocumentFragment,\n options: Partial<RenderOptions> = {}\n) => {\n // TODO(kschaaf): Do we need a helper for _$litPart$ (\"part for node\")?\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((container as any)['_$litPart$'] !== undefined) {\n throw new Error('container already contains a live render');\n }\n\n // Since render() creates a ChildPart to render into, we'll always have\n // exactly one root part. We need to hold a reference to it so we can set\n // it in the parts cache.\n let rootPart: ChildPart | undefined = undefined;\n\n // When we are in-between ChildPart markers, this is the current ChildPart.\n // It's needed to be able to set the ChildPart's endNode when we see a\n // close marker\n let currentChildPart: ChildPart | undefined = undefined;\n\n // Used to remember parent template state as we recurse into nested\n // templates\n const stack: Array<ChildPartState> = [];\n\n const walker = document.createTreeWalker(\n container,\n NodeFilter.SHOW_COMMENT,\n null,\n false\n );\n let marker: Comment | null;\n\n // Walk the DOM looking for part marker comments\n while ((marker = walker.nextNode() as Comment | null) !== null) {\n const markerText = marker.data;\n if (markerText.startsWith('lit-part')) {\n if (stack.length === 0 && rootPart !== undefined) {\n throw new Error('there must be only one root part per container');\n }\n // Create a new ChildPart and push it onto the stack\n currentChildPart = openChildPart(rootValue, marker, stack, options);\n rootPart ??= currentChildPart;\n } else if (markerText.startsWith('lit-node')) {\n // Create and hydrate attribute parts into the current ChildPart on the\n // stack\n createAttributeParts(marker, stack, options);\n // Remove `defer-hydration` attribute, if any\n const parent = marker.parentElement!;\n if (parent.hasAttribute('defer-hydration')) {\n parent.removeAttribute('defer-hydration');\n }\n } else if (markerText.startsWith('/lit-part')) {\n // Close the current ChildPart, and pop the previous one off the stack\n if (stack.length === 1 && currentChildPart !== rootPart) {\n throw new Error('internal error');\n }\n currentChildPart = closeChildPart(marker, currentChildPart, stack);\n }\n }\n console.assert(\n rootPart !== undefined,\n 'there should be exactly one root part in a render container'\n );\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (container as any)['_$litPart$'] = rootPart;\n};\n\nconst openChildPart = (\n rootValue: unknown,\n marker: Comment,\n stack: Array<ChildPartState>,\n options: RenderOptions\n) => {\n let value: unknown;\n // We know the startNode now. We'll know the endNode when we get to\n // the matching marker and set it in closeChildPart()\n // TODO(kschaaf): Current constructor takes both nodes\n let part;\n if (stack.length === 0) {\n part = new ChildPart(marker, null, undefined, options);\n value = rootValue;\n } else {\n const state = stack[stack.length - 1];\n if (state.type === 'template-instance') {\n part = new ChildPart(marker, null, state.instance, options);\n state.instance._parts.push(part);\n value = state.result.values[state.instancePartIndex++];\n state.templatePartIndex++;\n } else if (state.type === 'iterable') {\n part = new ChildPart(marker, null, state.part, options);\n const result = state.iterator.next();\n if (result.done) {\n value = undefined;\n state.done = true;\n throw new Error('Unhandled shorter than expected iterable');\n } else {\n value = result.value;\n }\n (state.part._$committedValue as Array<ChildPart>).push(part);\n } else {\n // state.type === 'leaf'\n // TODO(kschaaf): This is unexpected, and likely a result of a primitive\n // been rendered on the client when a TemplateResult was rendered on the\n // server; this part will be hydrated but not used. We can detect it, but\n // we need to decide what to do in this case. Note that this part won't be\n // retained by any parent TemplateInstance, since a primitive had been\n // rendered in its place.\n // https://github.com/lit/lit/issues/1434\n // throw new Error('Hydration value mismatch: Found a TemplateInstance' +\n // 'where a leaf value was expected');\n part = new ChildPart(marker, null, state.part, options);\n }\n }\n\n // Initialize the ChildPart state depending on the type of value and push\n // it onto the stack. This logic closely follows the ChildPart commit()\n // cascade order:\n // 1. directive\n // 2. noChange\n // 3. primitive (note strings must be handled before iterables, since they\n // are iterable)\n // 4. TemplateResult\n // 5. Node (not yet implemented, but fallback handling is fine)\n // 6. Iterable\n // 7. nothing (handled in fallback)\n // 8. Fallback for everything else\n value = resolveDirective(part, value);\n if (value === noChange) {\n stack.push({part, type: 'leaf'});\n } else if (isPrimitive(value)) {\n stack.push({part, type: 'leaf'});\n part._$committedValue = value;\n // TODO(kschaaf): We can detect when a primitive is being hydrated on the\n // client where a TemplateResult was rendered on the server, but we need to\n // decide on a strategy for what to do next.\n // https://github.com/lit/lit/issues/1434\n // if (marker.data !== 'lit-part') {\n // throw new Error('Hydration value mismatch: Primitive found where TemplateResult expected');\n // }\n } else if (isTemplateResult(value)) {\n // Check for a template result digest\n const markerWithDigest = `lit-part ${digestForTemplateResult(value)}`;\n if (marker.data === markerWithDigest) {\n const template = ChildPart.prototype._$getTemplate(value);\n const instance = new TemplateInstance(template, part);\n stack.push({\n type: 'template-instance',\n instance,\n part,\n templatePartIndex: 0,\n instancePartIndex: 0,\n result: value,\n });\n // For TemplateResult values, we set the part value to the\n // generated TemplateInstance\n part._$committedValue = instance;\n } else {\n // TODO: if this isn't the server-rendered template, do we\n // need to stop hydrating this subtree? Clear it? Add tests.\n throw new Error(\n 'Hydration value mismatch: Unexpected TemplateResult rendered to part'\n );\n }\n } else if (isIterable(value)) {\n // currentChildPart.value will contain an array of ChildParts\n stack.push({\n part: part,\n type: 'iterable',\n value,\n iterator: value[Symbol.iterator](),\n done: false,\n });\n part._$committedValue = [];\n } else {\n // Fallback for everything else (nothing, Objects, Functions,\n // etc.): we just initialize the part's value\n // Note that `Node` value types are not currently supported during\n // SSR, so that part of the cascade is missing.\n stack.push({part: part, type: 'leaf'});\n part._$committedValue = value == null ? '' : value;\n }\n return part;\n};\n\nconst closeChildPart = (\n marker: Comment,\n part: ChildPart | undefined,\n stack: Array<ChildPartState>\n): ChildPart | undefined => {\n if (part === undefined) {\n throw new Error('unbalanced part marker');\n }\n\n part._$endNode = marker;\n\n const currentState = stack.pop()!;\n\n if (currentState.type === 'iterable') {\n if (!currentState.iterator.next().done) {\n throw new Error('unexpected longer than expected iterable');\n }\n }\n\n if (stack.length > 0) {\n const state = stack[stack.length - 1];\n return state.part;\n } else {\n return undefined;\n }\n};\n\nconst createAttributeParts = (\n comment: Comment,\n stack: Array<ChildPartState>,\n options: RenderOptions\n) => {\n // Get the nodeIndex from DOM. We're only using this for an integrity\n // check right now, we might not need it.\n const match = /lit-node (\\d+)/.exec(comment.data)!;\n const nodeIndex = parseInt(match[1]);\n\n // For void elements, the node the comment was referring to will be\n // the previousSibling; for non-void elements, the comment is guaranteed\n // to be the first child of the element (i.e. it won't have a previousSibling\n // meaning it should use the parentElement)\n const node = comment.previousSibling ?? comment.parentElement;\n\n const state = stack[stack.length - 1];\n if (state.type === 'template-instance') {\n const instance = state.instance;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // If the next template part is in attribute-position on the current node,\n // create the instance part for it and prime its state\n const templatePart = instance._$template.parts[state.templatePartIndex];\n if (\n templatePart === undefined ||\n (templatePart.type !== PartType.ATTRIBUTE &&\n templatePart.type !== PartType.ELEMENT) ||\n templatePart.index !== nodeIndex\n ) {\n break;\n }\n\n if (templatePart.type === PartType.ATTRIBUTE) {\n // The instance part is created based on the constructor saved in the\n // template part\n const instancePart = new templatePart.ctor(\n node as HTMLElement,\n templatePart.name,\n templatePart.strings,\n state.instance,\n options\n );\n\n const value = isSingleExpression(\n instancePart as unknown as AttributePartInfo\n )\n ? state.result.values[state.instancePartIndex]\n : state.result.values;\n\n // Setting the attribute value primes committed value with the resolved\n // directive value; we only then commit that value for event/property\n // parts since those were not serialized, and pass `noCommit` for the\n // others to avoid perf impact of touching the DOM unnecessarily\n const noCommit = !(\n instancePart.type === PartType.EVENT ||\n instancePart.type === PartType.PROPERTY\n );\n instancePart._$setValue(\n value,\n instancePart,\n state.instancePartIndex,\n noCommit\n );\n state.instancePartIndex += templatePart.strings.length - 1;\n instance._parts.push(instancePart);\n } else {\n // templatePart.type === PartType.ELEMENT\n const instancePart = new ElementPart(\n node as HTMLElement,\n state.instance,\n options\n );\n resolveDirective(\n instancePart,\n state.result.values[state.instancePartIndex++]\n );\n instance._parts.push(instancePart);\n }\n state.templatePartIndex++;\n }\n } else {\n throw new Error('internal error');\n }\n};\n\n// Number of 32 bit elements to use to create template digests\nconst digestSize = 2;\n// We need to specify a digest to use across rendering environments. This is a\n// simple digest build from a DJB2-ish hash modified from:\n// https://github.com/darkskyapp/string-hash/blob/master/index.js\n// It has been changed to an array of hashes to add additional bits.\n// Goals:\n// - Extremely low collision rate. We may not be able to detect collisions.\n// - Extremely fast.\n// - Extremely small code size.\n// - Safe to include in HTML comment text or attribute value.\n// - Easily specifiable and implementable in multiple languages.\n// We don't care about cryptographic suitability.\nexport const digestForTemplateResult = (templateResult: TemplateResult) => {\n const hashes = new Uint32Array(digestSize).fill(5381);\n\n for (const s of templateResult.strings) {\n for (let i = 0; i < s.length; i++) {\n hashes[i % digestSize] = (hashes[i % digestSize] * 33) ^ s.charCodeAt(i);\n }\n }\n return btoa(String.fromCharCode(...new Uint8Array(hashes.buffer)));\n};\n"]}