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,124 +3,9 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- /**
7
- * Overview:
8
- *
9
- * This module is designed to add support for an async `setValue` API and
10
- * `disconnected` callback to directives with the least impact on the core
11
- * runtime or payload when that feature is not used.
12
- *
13
- * The strategy is to introduce a `AsyncDirective` subclass of
14
- * `Directive` that climbs the "parent" tree in its constructor to note which
15
- * branches of lit-html's "logical tree" of data structures contain such
16
- * directives and thus need to be crawled when a subtree is being cleared (or
17
- * manually disconnected) in order to run the `disconnected` callback.
18
- *
19
- * The "nodes" of the logical tree include Parts, TemplateInstances (for when a
20
- * TemplateResult is committed to a value of a ChildPart), and Directives; these
21
- * all implement a common interface called `DisconnectableChild`. Each has a
22
- * `_$parent` reference which is set during construction in the core code, and a
23
- * `_$disconnectableChildren` field which is initially undefined.
24
- *
25
- * The sparse tree created by means of the `AsyncDirective` constructor
26
- * crawling up the `_$parent` tree and placing a `_$disconnectableChildren` Set
27
- * on each parent that includes each child that contains a
28
- * `AsyncDirective` directly or transitively via its children. In order
29
- * disconnect (or reconnect) a tree, the `_$setChildPartConnected` API is patched
30
- * onto ChildParts as a directive climbs the parent tree, which is called by the
31
- * core when clearing a part if it exists. When called, that method iterates
32
- * over the sparse tree of Set<DisconnectableChildren> built up by
33
- * AsyncDirectives, and calls `_$setDirectiveConnected` on any
34
- * directives that are encountered in that tree, running the required callbacks.
35
- *
36
- * A given "logical tree" of lit-html data-structures might look like this:
37
- *
38
- * ChildPart(N1) _$dC=[D2,T3]
39
- * ._directive
40
- * AsyncDirective(D2)
41
- * ._value // user value was TemplateResult
42
- * TemplateInstance(T3) _$dC=[A4,A6,N10,N12]
43
- * ._parts[]
44
- * AttributePart(A4) _$dC=[D5]
45
- * ._directives[]
46
- * AsyncDirective(D5)
47
- * AttributePart(A6) _$dC=[D7,D8]
48
- * ._directives[]
49
- * AsyncDirective(D7)
50
- * Directive(D8) _$dC=[D9]
51
- * ._directive
52
- * AsyncDirective(D9)
53
- * ChildPart(N10) _$dC=[D11]
54
- * ._directive
55
- * AsyncDirective(D11)
56
- * ._value
57
- * string
58
- * ChildPart(N12) _$dC=[D13,N14,N16]
59
- * ._directive
60
- * AsyncDirective(D13)
61
- * ._value // user value was iterable
62
- * Array<ChildPart>
63
- * ChildPart(N14) _$dC=[D15]
64
- * ._value
65
- * string
66
- * ChildPart(N16) _$dC=[D17,T18]
67
- * ._directive
68
- * AsyncDirective(D17)
69
- * ._value // user value was TemplateResult
70
- * TemplateInstance(T18) _$dC=[A19,A21,N25]
71
- * ._parts[]
72
- * AttributePart(A19) _$dC=[D20]
73
- * ._directives[]
74
- * AsyncDirective(D20)
75
- * AttributePart(A21) _$dC=[22,23]
76
- * ._directives[]
77
- * AsyncDirective(D22)
78
- * Directive(D23) _$dC=[D24]
79
- * ._directive
80
- * AsyncDirective(D24)
81
- * ChildPart(N25) _$dC=[D26]
82
- * ._directive
83
- * AsyncDirective(D26)
84
- * ._value
85
- * string
86
- *
87
- * Example 1: The directive in ChildPart(N12) updates and returns `nothing`. The
88
- * ChildPart will _clear() itself, and so we need to disconnect the "value" of
89
- * the ChildPart (but not its directive). In this case, when `_clear()` calls
90
- * `_$setChildPartConnected()`, we don't iterate all of the
91
- * _$disconnectableChildren, rather we do a value-specific disconnection: i.e.
92
- * since the _value was an Array<ChildPart> (because an iterable had been
93
- * committed), we iterate the array of ChildParts (N14, N16) and run
94
- * `setConnected` on them (which does recurse down the full tree of
95
- * `_$disconnectableChildren` below it, and also removes N14 and N16 from N12's
96
- * `_$disconnectableChildren`). Once the values have been disconnected, we then
97
- * check whether the ChildPart(N12)'s list of `_$disconnectableChildren` is empty
98
- * (and would remove it from its parent TemplateInstance(T3) if so), but since
99
- * it would still contain its directive D13, it stays in the disconnectable
100
- * tree.
101
- *
102
- * Example 2: In the course of Example 1, `setConnected` will reach
103
- * ChildPart(N16); in this case the entire part is being disconnected, so we
104
- * simply iterate all of N16's `_$disconnectableChildren` (D17,T18) and
105
- * recursively run `setConnected` on them. Note that we only remove children
106
- * from `_$disconnectableChildren` for the top-level values being disconnected
107
- * on a clear; doing this bookkeeping lower in the tree is wasteful since it's
108
- * all being thrown away.
109
- *
110
- * Example 3: If the LitElement containing the entire tree above becomes
111
- * disconnected, it will run `childPart.setConnected()` (which calls
112
- * `childPart._$setChildPartConnected()` if it exists); in this case, we
113
- * recursively run `setConnected()` over the entire tree, without removing any
114
- * children from `_$disconnectableChildren`, since this tree is required to
115
- * re-connect the tree, which does the same operation, simply passing
116
- * `isConnectd: true` down the tree, signaling which callback to run.
117
- */
118
6
  import { isSingleExpression } from './directive-helpers.js';
119
7
  import { Directive, PartType } from './directive.js';
120
- import { noChange, } from './lit-html.js';
121
-
122
8
  export { directive } from './directive.js';
123
-
124
9
  const DEV_MODE = true;
125
10
  /**
126
11
  * Recursively walks down the tree of Parts/TemplateInstances/Directives to set
@@ -129,23 +14,24 @@ const DEV_MODE = true;
129
14
  *
130
15
  * @return True if there were children to disconnect; false otherwise
131
16
  */
132
- const setChildrenConnected = (parent, isConnected) => {
17
+ const notifyChildrenConnectedChanged = (parent, isConnected) => {
133
18
  var _a, _b;
134
- const children = parent._$disconnetableChildren;
19
+ const children = parent._$disconnectableChildren;
135
20
  if (children === undefined) {
136
21
  return false;
137
22
  }
138
23
  for (const obj of children) {
139
- // The existence of `_$setDirectiveConnected` is used as a "brand" to
24
+ // The existence of `_$notifyDirectiveConnectionChanged` is used as a "brand" to
140
25
  // disambiguate AsyncDirectives from other DisconnectableChildren
141
26
  // (as opposed to using an instanceof check to know when to call it); the
142
27
  // redundancy of "Directive" in the API name is to avoid conflicting with
143
- // `_$setChildPartConnected`, which exists `ChildParts` which are also in
28
+ // `_$notifyConnectionChanged`, which exists `ChildParts` which are also in
144
29
  // this list
145
30
  // Disconnect Directive (and any nested directives contained within)
146
- (_b = (_a = obj)._$setDirectiveConnected) === null || _b === void 0 ? void 0 : _b.call(_a, isConnected, false);
31
+ // This property needs to remain unminified.
32
+ (_b = (_a = obj)['_$notifyDirectiveConnectionChanged']) === null || _b === void 0 ? void 0 : _b.call(_a, isConnected, false);
147
33
  // Disconnect Part/TemplateInstance
148
- setChildrenConnected(obj, isConnected);
34
+ notifyChildrenConnectedChanged(obj, isConnected);
149
35
  }
150
36
  return true;
151
37
  };
@@ -161,7 +47,7 @@ const removeDisconnectableFromParent = (obj) => {
161
47
  if ((parent = obj._$parent) === undefined) {
162
48
  break;
163
49
  }
164
- children = parent._$disconnetableChildren;
50
+ children = parent._$disconnectableChildren;
165
51
  children.delete(obj);
166
52
  obj = parent;
167
53
  } while ((children === null || children === void 0 ? void 0 : children.size) === 0);
@@ -170,9 +56,9 @@ const addDisconnectableToParent = (obj) => {
170
56
  // Climb the parent tree, creating a sparse tree of children needing
171
57
  // disconnection
172
58
  for (let parent; (parent = obj._$parent); obj = parent) {
173
- let children = parent._$disconnetableChildren;
59
+ let children = parent._$disconnectableChildren;
174
60
  if (children === undefined) {
175
- parent._$disconnetableChildren = children = new Set();
61
+ parent._$disconnectableChildren = children = new Set();
176
62
  }
177
63
  else if (children.has(obj)) {
178
64
  // Once we've reached a parent that already contains this child, we
@@ -191,7 +77,7 @@ const addDisconnectableToParent = (obj) => {
191
77
  * the core code when parts are moved between different parents.
192
78
  */
193
79
  function reparentDisconnectables(newParent) {
194
- if (this._$disconnetableChildren !== undefined) {
80
+ if (this._$disconnectableChildren !== undefined) {
195
81
  removeDisconnectableFromParent(this);
196
82
  this._$parent = newParent;
197
83
  addDisconnectableToParent(this);
@@ -221,9 +107,9 @@ function reparentDisconnectables(newParent) {
221
107
  * core code when parts are cleared or the connection state is changed by the
222
108
  * user.
223
109
  */
224
- function setChildPartConnected(isConnected, isClearingValue = false, fromPartIndex = 0) {
110
+ function notifyChildPartConnectedChanged(isConnected, isClearingValue = false, fromPartIndex = 0) {
225
111
  const value = this._$committedValue;
226
- const children = this._$disconnetableChildren;
112
+ const children = this._$disconnectableChildren;
227
113
  if (children === undefined || children.size === 0) {
228
114
  return;
229
115
  }
@@ -233,7 +119,7 @@ function setChildPartConnected(isConnected, isClearingValue = false, fromPartInd
233
119
  // disconnected and removed from this ChildPart's disconnectable
234
120
  // children (starting at `fromPartIndex` in the case of truncation)
235
121
  for (let i = fromPartIndex; i < value.length; i++) {
236
- setChildrenConnected(value[i], false);
122
+ notifyChildrenConnectedChanged(value[i], false);
237
123
  removeDisconnectableFromParent(value[i]);
238
124
  }
239
125
  }
@@ -241,12 +127,12 @@ function setChildPartConnected(isConnected, isClearingValue = false, fromPartInd
241
127
  // TemplateInstance case: If the value has disconnectable children (will
242
128
  // only be in the case that it is a TemplateInstance), we disconnect it
243
129
  // and remove it from this ChildPart's disconnectable children
244
- setChildrenConnected(value, false);
130
+ notifyChildrenConnectedChanged(value, false);
245
131
  removeDisconnectableFromParent(value);
246
132
  }
247
133
  }
248
134
  else {
249
- setChildrenConnected(this, isConnected);
135
+ notifyChildrenConnectedChanged(this, isConnected);
250
136
  }
251
137
  }
252
138
  /**
@@ -256,28 +142,32 @@ const installDisconnectAPI = (obj) => {
256
142
  var _a, _b;
257
143
  var _c, _d;
258
144
  if (obj.type == PartType.CHILD) {
259
- (_a = (_c = obj)._$setChildPartConnected) !== null && _a !== void 0 ? _a : (_c._$setChildPartConnected = setChildPartConnected);
145
+ (_a = (_c = obj)._$notifyConnectionChanged) !== null && _a !== void 0 ? _a : (_c._$notifyConnectionChanged = notifyChildPartConnectedChanged);
260
146
  (_b = (_d = obj)._$reparentDisconnectables) !== null && _b !== void 0 ? _b : (_d._$reparentDisconnectables = reparentDisconnectables);
261
147
  }
262
148
  };
263
149
  /**
264
150
  * An abstract `Directive` base class whose `disconnected` method will be
265
151
  * called when the part containing the directive is cleared as a result of
266
- * re-rendering, or when the user calls `part.setDirectiveConnection(false)` on
267
- * a part that was previously rendered containing the directive.
152
+ * re-rendering, or when the user calls `part.setConnected(false)` on
153
+ * a part that was previously rendered containing the directive (as happens
154
+ * when e.g. a LitElement disconnects from the DOM).
268
155
  *
269
- * If `part.setDirectiveConnection(true)` is subsequently called on a
156
+ * If `part.setConnected(true)` is subsequently called on a
270
157
  * containing part, the directive's `reconnected` method will be called prior
271
158
  * to its next `update`/`render` callbacks. When implementing `disconnected`,
272
159
  * `reconnected` should also be implemented to be compatible with reconnection.
160
+ *
161
+ * Note that updates may occur while the directive is disconnected. As such,
162
+ * directives should generally check the `this.isConnected` flag during
163
+ * render/update to determine whether it is safe to subscribe to resources
164
+ * that may prevent garbage collection.
273
165
  */
274
166
  export class AsyncDirective extends Directive {
275
167
  constructor() {
276
168
  super(...arguments);
277
- this.isConnected = true;
278
- this._pendingValue = noChange;
279
169
  // @internal
280
- this._$disconnetableChildren = undefined;
170
+ this._$disconnectableChildren = undefined;
281
171
  }
282
172
  /**
283
173
  * Initialize the part with internal fields
@@ -288,7 +178,9 @@ export class AsyncDirective extends Directive {
288
178
  _$initialize(part, parent, attributeIndex) {
289
179
  super._$initialize(part, parent, attributeIndex);
290
180
  addDisconnectableToParent(this);
181
+ this.isConnected = part._$isConnected;
291
182
  }
183
+ // This property needs to remain unminified.
292
184
  /**
293
185
  * Called from the core code when a directive is going away from a part (in
294
186
  * which case `shouldRemoveFromParent` should be true), and from the
@@ -301,55 +193,21 @@ export class AsyncDirective extends Directive {
301
193
  * removed; false when the tree is being disconnected
302
194
  * @internal
303
195
  */
304
- _$setDirectiveConnected(isConnected, isClearingDirective = true) {
305
- this._setConnected(isConnected);
306
- if (isClearingDirective) {
307
- setChildrenConnected(this, isConnected);
308
- removeDisconnectableFromParent(this);
309
- }
310
- }
311
- /**
312
- * Private method used to set the connection state of the directive and call
313
- * the respective `disconnected` or `reconnected` callback. Note thatsince
314
- * `isConnected` defaults to true, we do not run `reconnected` on first
315
- * render.
316
- *
317
- * If a call to `setValue` was made while disconnected, flush it to the part
318
- * before reconnecting.
319
- *
320
- * @param isConnected
321
- * @internal
322
- */
323
- _setConnected(isConnected) {
196
+ ['_$notifyDirectiveConnectionChanged'](isConnected, isClearingDirective = true) {
324
197
  var _a, _b;
325
198
  if (isConnected !== this.isConnected) {
199
+ this.isConnected = isConnected;
326
200
  if (isConnected) {
327
- this.isConnected = true;
328
- if (this._pendingValue !== noChange) {
329
- this.setValue(this._pendingValue);
330
- this._pendingValue = noChange;
331
- }
332
201
  (_a = this.reconnected) === null || _a === void 0 ? void 0 : _a.call(this);
333
202
  }
334
203
  else {
335
- this.isConnected = false;
336
204
  (_b = this.disconnected) === null || _b === void 0 ? void 0 : _b.call(this);
337
205
  }
338
206
  }
339
- }
340
- /**
341
- * Override of the base `_resolve` method to ensure `reconnected` is run
342
- * prior to the next render.
343
- *
344
- * @override
345
- * @internal
346
- */
347
- _$resolve(part, props) {
348
- if (!this.isConnected) {
349
- throw new Error(`AsyncDirective ${this.constructor.name} was ` +
350
- `rendered while its tree was disconnected.`);
207
+ if (isClearingDirective) {
208
+ notifyChildrenConnectedChanged(this, isConnected);
209
+ removeDisconnectableFromParent(this);
351
210
  }
352
- return super._$resolve(part, props);
353
211
  }
354
212
  /**
355
213
  * Sets the value of the directive's Part outside the normal `update`/`render`
@@ -358,30 +216,22 @@ export class AsyncDirective extends Directive {
358
216
  * This method should not be called synchronously from a directive's `update`
359
217
  * or `render`.
360
218
  *
361
- * If the method is called while the part is disconnected, the value will be
362
- * queued until directive is reconnected.
363
- *
364
219
  * @param directive The directive to update
365
220
  * @param value The value to set
366
221
  */
367
222
  setValue(value) {
368
- if (this.isConnected) {
369
- if (isSingleExpression(this.__part)) {
370
- this.__part._$setValue(value, this);
371
- }
372
- else {
373
- // this.__attributeIndex will be defined in this case, but
374
- // assert it in dev mode
375
- if (DEV_MODE && this.__attributeIndex === undefined) {
376
- throw new Error(`Expected this.__attributeIndex to be a number`);
377
- }
378
- const newValues = [...this.__part._$committedValue];
379
- newValues[this.__attributeIndex] = value;
380
- this.__part._$setValue(newValues, this, 0);
381
- }
223
+ if (isSingleExpression(this.__part)) {
224
+ this.__part._$setValue(value, this);
382
225
  }
383
226
  else {
384
- this._pendingValue = value;
227
+ // this.__attributeIndex will be defined in this case, but
228
+ // assert it in dev mode
229
+ if (DEV_MODE && this.__attributeIndex === undefined) {
230
+ throw new Error(`Expected this.__attributeIndex to be a number`);
231
+ }
232
+ const newValues = [...this.__part._$committedValue];
233
+ newValues[this.__attributeIndex] = value;
234
+ this.__part._$setValue(newValues, this, 0);
385
235
  }
386
236
  }
387
237
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"async-directive.js","sourceRoot":"","sources":["../src/async-directive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+GG;AAEH,OAAO,EAIL,QAAQ,GAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,SAAS,EAAY,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,oBAA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BAAiB,CAAC,GAAG,KAAK,CAAC;gBACzC,IAAI,CAAC,MAAwB,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;aAC/D;SACF;aAAM;YACL,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;SAC5B;IACH,CAAC;IAED;;;;;OAKG;IACO,YAAY,KAAI,CAAC;IACjB,WAAW,KAAI,CAAC;CAC3B","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Overview:\n *\n * This module is designed to add support for an async `setValue` API and\n * `disconnected` callback to directives with the least impact on the core\n * runtime or payload when that feature is not used.\n *\n * The strategy is to introduce a `AsyncDirective` subclass of\n * `Directive` that climbs the \"parent\" tree in its constructor to note which\n * branches of lit-html's \"logical tree\" of data structures contain such\n * directives and thus need to be crawled when a subtree is being cleared (or\n * manually disconnected) in order to run the `disconnected` callback.\n *\n * The \"nodes\" of the logical tree include Parts, TemplateInstances (for when a\n * TemplateResult is committed to a value of a ChildPart), and Directives; these\n * all implement a common interface called `DisconnectableChild`. Each has a\n * `_$parent` reference which is set during construction in the core code, and a\n * `_$disconnectableChildren` field which is initially undefined.\n *\n * The sparse tree created by means of the `AsyncDirective` constructor\n * crawling up the `_$parent` tree and placing a `_$disconnectableChildren` Set\n * on each parent that includes each child that contains a\n * `AsyncDirective` directly or transitively via its children. In order\n * disconnect (or reconnect) a tree, the `_$setChildPartConnected` API is patched\n * onto ChildParts as a directive climbs the parent tree, which is called by the\n * core when clearing a part if it exists. When called, that method iterates\n * over the sparse tree of Set<DisconnectableChildren> built up by\n * AsyncDirectives, and calls `_$setDirectiveConnected` on any\n * directives that are encountered in that tree, running the required callbacks.\n *\n * A given \"logical tree\" of lit-html data-structures might look like this:\n *\n * ChildPart(N1) _$dC=[D2,T3]\n * ._directive\n * AsyncDirective(D2)\n * ._value // user value was TemplateResult\n * TemplateInstance(T3) _$dC=[A4,A6,N10,N12]\n * ._parts[]\n * AttributePart(A4) _$dC=[D5]\n * ._directives[]\n * AsyncDirective(D5)\n * AttributePart(A6) _$dC=[D7,D8]\n * ._directives[]\n * AsyncDirective(D7)\n * Directive(D8) _$dC=[D9]\n * ._directive\n * AsyncDirective(D9)\n * ChildPart(N10) _$dC=[D11]\n * ._directive\n * AsyncDirective(D11)\n * ._value\n * string\n * ChildPart(N12) _$dC=[D13,N14,N16]\n * ._directive\n * AsyncDirective(D13)\n * ._value // user value was iterable\n * Array<ChildPart>\n * ChildPart(N14) _$dC=[D15]\n * ._value\n * string\n * ChildPart(N16) _$dC=[D17,T18]\n * ._directive\n * AsyncDirective(D17)\n * ._value // user value was TemplateResult\n * TemplateInstance(T18) _$dC=[A19,A21,N25]\n * ._parts[]\n * AttributePart(A19) _$dC=[D20]\n * ._directives[]\n * AsyncDirective(D20)\n * AttributePart(A21) _$dC=[22,23]\n * ._directives[]\n * AsyncDirective(D22)\n * Directive(D23) _$dC=[D24]\n * ._directive\n * AsyncDirective(D24)\n * ChildPart(N25) _$dC=[D26]\n * ._directive\n * AsyncDirective(D26)\n * ._value\n * string\n *\n * Example 1: The directive in ChildPart(N12) updates and returns `nothing`. The\n * ChildPart will _clear() itself, and so we need to disconnect the \"value\" of\n * the ChildPart (but not its directive). In this case, when `_clear()` calls\n * `_$setChildPartConnected()`, we don't iterate all of the\n * _$disconnectableChildren, rather we do a value-specific disconnection: i.e.\n * since the _value was an Array<ChildPart> (because an iterable had been\n * committed), we iterate the array of ChildParts (N14, N16) and run\n * `setConnected` on them (which does recurse down the full tree of\n * `_$disconnectableChildren` below it, and also removes N14 and N16 from N12's\n * `_$disconnectableChildren`). Once the values have been disconnected, we then\n * check whether the ChildPart(N12)'s list of `_$disconnectableChildren` is empty\n * (and would remove it from its parent TemplateInstance(T3) if so), but since\n * it would still contain its directive D13, it stays in the disconnectable\n * tree.\n *\n * Example 2: In the course of Example 1, `setConnected` will reach\n * ChildPart(N16); in this case the entire part is being disconnected, so we\n * simply iterate all of N16's `_$disconnectableChildren` (D17,T18) and\n * recursively run `setConnected` on them. Note that we only remove children\n * from `_$disconnectableChildren` for the top-level values being disconnected\n * on a clear; doing this bookkeeping lower in the tree is wasteful since it's\n * all being thrown away.\n *\n * Example 3: If the LitElement containing the entire tree above becomes\n * disconnected, it will run `childPart.setConnected()` (which calls\n * `childPart._$setChildPartConnected()` if it exists); in this case, we\n * recursively run `setConnected()` over the entire tree, without removing any\n * children from `_$disconnectableChildren`, since this tree is required to\n * re-connect the tree, which does the same operation, simply passing\n * `isConnectd: true` down the tree, signaling which callback to run.\n */\n\nimport {\n AttributePart,\n ChildPart,\n Disconnectable,\n noChange,\n Part,\n} from './lit-html.js';\nimport {isSingleExpression} from './directive-helpers.js';\nimport {Directive, PartInfo, PartType} from './directive.js';\nexport {directive} from './directive.js';\n\nconst DEV_MODE = true;\n\n/**\n * Recursively walks down the tree of Parts/TemplateInstances/Directives to set\n * the connected state of directives and run `disconnected`/ `reconnected`\n * callbacks.\n *\n * @return True if there were children to disconnect; false otherwise\n */\nconst setChildrenConnected = (\n parent: Disconnectable,\n isConnected: boolean\n): boolean => {\n const children = parent._$disconnetableChildren;\n if (children === undefined) {\n return false;\n }\n for (const obj of children) {\n // The existence of `_$setDirectiveConnected` is used as a \"brand\" to\n // disambiguate AsyncDirectives from other DisconnectableChildren\n // (as opposed to using an instanceof check to know when to call it); the\n // redundancy of \"Directive\" in the API name is to avoid conflicting with\n // `_$setChildPartConnected`, which exists `ChildParts` which are also in\n // this list\n // Disconnect Directive (and any nested directives contained within)\n (obj as AsyncDirective)._$setDirectiveConnected?.(isConnected, false);\n // Disconnect Part/TemplateInstance\n setChildrenConnected(obj, isConnected);\n }\n return true;\n};\n\n/**\n * Removes the given child from its parent list of disconnectable children, and\n * if the parent list becomes empty as a result, removes the parent from its\n * parent, and so forth up the tree when that causes subsequent parent lists to\n * become empty.\n */\nconst removeDisconnectableFromParent = (obj: Disconnectable) => {\n let parent, children;\n do {\n if ((parent = obj._$parent) === undefined) {\n break;\n }\n children = parent._$disconnetableChildren!;\n children.delete(obj);\n obj = parent;\n } while (children?.size === 0);\n};\n\nconst addDisconnectableToParent = (obj: Disconnectable) => {\n // Climb the parent tree, creating a sparse tree of children needing\n // disconnection\n for (let parent; (parent = obj._$parent); obj = parent) {\n let children = parent._$disconnetableChildren;\n if (children === undefined) {\n parent._$disconnetableChildren = children = new Set();\n } else if (children.has(obj)) {\n // Once we've reached a parent that already contains this child, we\n // can short-circuit\n break;\n }\n children.add(obj);\n installDisconnectAPI(parent);\n }\n};\n\n/**\n * Changes the parent reference of the ChildPart, and updates the sparse tree of\n * Disconnectable children accordingly.\n *\n * Note, this method will be patched onto ChildPart instances and called from\n * the core code when parts are moved between different parents.\n */\nfunction reparentDisconnectables(this: ChildPart, newParent: Disconnectable) {\n if (this._$disconnetableChildren !== undefined) {\n removeDisconnectableFromParent(this);\n this._$parent = newParent;\n addDisconnectableToParent(this);\n } else {\n this._$parent = newParent;\n }\n}\n\n/**\n * Sets the connected state on any directives contained within the committed\n * value of this part (i.e. within a TemplateInstance or iterable of\n * ChildParts) and runs their `disconnected`/`reconnected`s, as well as within\n * any directives stored on the ChildPart (when `valueOnly` is false).\n *\n * `isClearingValue` should be passed as `true` on a top-level part that is\n * clearing itself, and not as a result of recursively disconnecting directives\n * as part of a `clear` operation higher up the tree. This both ensures that any\n * directive on this ChildPart that produced a value that caused the clear\n * operation is not disconnected, and also serves as a performance optimization\n * to avoid needless bookkeeping when a subtree is going away; when clearing a\n * subtree, only the top-most part need to remove itself from the parent.\n *\n * `fromPartIndex` is passed only in the case of a partial `_clear` running as a\n * result of truncating an iterable.\n *\n * Note, this method will be patched onto ChildPart instances and called from the\n * core code when parts are cleared or the connection state is changed by the\n * user.\n */\nfunction setChildPartConnected(\n this: ChildPart,\n isConnected: boolean,\n isClearingValue = false,\n fromPartIndex = 0\n) {\n const value = this._$committedValue;\n const children = this._$disconnetableChildren;\n if (children === undefined || children.size === 0) {\n return;\n }\n if (isClearingValue) {\n if (Array.isArray(value)) {\n // Iterable case: Any ChildParts created by the iterable should be\n // disconnected and removed from this ChildPart's disconnectable\n // children (starting at `fromPartIndex` in the case of truncation)\n for (let i = fromPartIndex; i < value.length; i++) {\n setChildrenConnected(value[i], false);\n removeDisconnectableFromParent(value[i]);\n }\n } else if (value != null) {\n // TemplateInstance case: If the value has disconnectable children (will\n // only be in the case that it is a TemplateInstance), we disconnect it\n // and remove it from this ChildPart's disconnectable children\n setChildrenConnected(value as Disconnectable, false);\n removeDisconnectableFromParent(value as Disconnectable);\n }\n } else {\n setChildrenConnected(this, isConnected);\n }\n}\n\n/**\n * Patches disconnection API onto ChildParts.\n */\nconst installDisconnectAPI = (obj: Disconnectable) => {\n if ((obj as ChildPart).type == PartType.CHILD) {\n (obj as ChildPart)._$setChildPartConnected ??= setChildPartConnected;\n (obj as ChildPart)._$reparentDisconnectables ??= reparentDisconnectables;\n }\n};\n\n/**\n * An abstract `Directive` base class whose `disconnected` method will be\n * called when the part containing the directive is cleared as a result of\n * re-rendering, or when the user calls `part.setDirectiveConnection(false)` on\n * a part that was previously rendered containing the directive.\n *\n * If `part.setDirectiveConnection(true)` is subsequently called on a\n * containing part, the directive's `reconnected` method will be called prior\n * to its next `update`/`render` callbacks. When implementing `disconnected`,\n * `reconnected` should also be implemented to be compatible with reconnection.\n */\nexport abstract class AsyncDirective extends Directive {\n isConnected = true;\n private _pendingValue: unknown = noChange;\n // @internal\n _$disconnetableChildren?: Set<Disconnectable> = undefined;\n /**\n * Initialize the part with internal fields\n * @param part\n * @param parent\n * @param attributeIndex\n */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n super._$initialize(part, parent, attributeIndex);\n addDisconnectableToParent(this);\n }\n /**\n * Called from the core code when a directive is going away from a part (in\n * which case `shouldRemoveFromParent` should be true), and from the\n * `setChildrenConnected` helper function when recursively changing the\n * connection state of a tree (in which case `shouldRemoveFromParent` should\n * be false).\n *\n * @param isConnected\n * @param isClearingDirective - True when the directive itself is being\n * removed; false when the tree is being disconnected\n * @internal\n */\n _$setDirectiveConnected(isConnected: boolean, isClearingDirective = true) {\n this._setConnected(isConnected);\n if (isClearingDirective) {\n setChildrenConnected(this, isConnected);\n removeDisconnectableFromParent(this);\n }\n }\n /**\n * Private method used to set the connection state of the directive and call\n * the respective `disconnected` or `reconnected` callback. Note thatsince\n * `isConnected` defaults to true, we do not run `reconnected` on first\n * render.\n *\n * If a call to `setValue` was made while disconnected, flush it to the part\n * before reconnecting.\n *\n * @param isConnected\n * @internal\n */\n private _setConnected(isConnected: boolean) {\n if (isConnected !== this.isConnected) {\n if (isConnected) {\n this.isConnected = true;\n if (this._pendingValue !== noChange) {\n this.setValue(this._pendingValue);\n this._pendingValue = noChange;\n }\n this.reconnected?.();\n } else {\n this.isConnected = false;\n this.disconnected?.();\n }\n }\n }\n\n /**\n * Override of the base `_resolve` method to ensure `reconnected` is run\n * prior to the next render.\n *\n * @override\n * @internal\n */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n if (!this.isConnected) {\n throw new Error(\n `AsyncDirective ${this.constructor.name} was ` +\n `rendered while its tree was disconnected.`\n );\n }\n return super._$resolve(part, props);\n }\n\n /**\n * Sets the value of the directive's Part outside the normal `update`/`render`\n * lifecycle of a directive.\n *\n * This method should not be called synchronously from a directive's `update`\n * or `render`.\n *\n * If the method is called while the part is disconnected, the value will be\n * queued until directive is reconnected.\n *\n * @param directive The directive to update\n * @param value The value to set\n */\n setValue(value: unknown) {\n if (this.isConnected) {\n if (isSingleExpression((this.__part as unknown) as PartInfo)) {\n this.__part._$setValue(value, this);\n } else {\n // this.__attributeIndex will be defined in this case, but\n // assert it in dev mode\n if (DEV_MODE && this.__attributeIndex === undefined) {\n throw new Error(`Expected this.__attributeIndex to be a number`);\n }\n const newValues = [...(this.__part._$committedValue as Array<unknown>)];\n newValues[this.__attributeIndex!] = value;\n (this.__part as AttributePart)._$setValue(newValues, this, 0);\n }\n } else {\n this._pendingValue = value;\n }\n }\n\n /**\n * User callbacks for implementing logic to release any resources/subscriptions\n * that may have been retained by this directive. Since directives may also be\n * re-connected, `reconnected` should also be implemented to restore the\n * working state of the directive prior to the next render.\n */\n protected disconnected() {}\n protected reconnected() {}\n}\n"]}
1
+ {"version":3,"file":"async-directive.js","sourceRoot":"","sources":["../src/async-directive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqHH,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,SAAS,EAAY,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,8BAA8B,GAAG,CACrC,MAAsB,EACtB,WAAoB,EACX,EAAE;;IACX,MAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC;IACjD,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;QAC1B,gFAAgF;QAChF,iEAAiE;QACjE,yEAAyE;QACzE,yEAAyE;QACzE,2EAA2E;QAC3E,YAAY;QACZ,oEAAoE;QACpE,4CAA4C;QAC5C,MAAA,MAAC,GAAsB,EAAC,oCAAoC,CAAC,mDAC3D,WAAW,EACX,KAAK,CACN,CAAC;QACF,mCAAmC;QACnC,8BAA8B,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;KAClD;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,8BAA8B,GAAG,CAAC,GAAmB,EAAE,EAAE;IAC7D,IAAI,MAAM,EAAE,QAAQ,CAAC;IACrB,GAAG;QACD,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;YACzC,MAAM;SACP;QACD,QAAQ,GAAG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E,IAAI,EAAE,CAAC,CAAC,CAAC;SAC/D;IACH,CAAC;IAED;;;;;OAKG;IACO,YAAY,KAAI,CAAC;IACjB,WAAW,KAAI,CAAC;CAC3B","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Overview:\n *\n * This module is designed to add support for an async `setValue` API and\n * `disconnected` callback to directives with the least impact on the core\n * runtime or payload when that feature is not used.\n *\n * The strategy is to introduce a `AsyncDirective` subclass of\n * `Directive` that climbs the \"parent\" tree in its constructor to note which\n * branches of lit-html's \"logical tree\" of data structures contain such\n * directives and thus need to be crawled when a subtree is being cleared (or\n * manually disconnected) in order to run the `disconnected` callback.\n *\n * The \"nodes\" of the logical tree include Parts, TemplateInstances (for when a\n * TemplateResult is committed to a value of a ChildPart), and Directives; these\n * all implement a common interface called `DisconnectableChild`. Each has a\n * `_$parent` reference which is set during construction in the core code, and a\n * `_$disconnectableChildren` field which is initially undefined.\n *\n * The sparse tree created by means of the `AsyncDirective` constructor\n * crawling up the `_$parent` tree and placing a `_$disconnectableChildren` Set\n * on each parent that includes each child that contains a\n * `AsyncDirective` directly or transitively via its children. In order to\n * notify connection state changes and disconnect (or reconnect) a tree, the\n * `_$notifyConnectionChanged` API is patched onto ChildParts as a directive\n * climbs the parent tree, which is called by the core when clearing a part if\n * it exists. When called, that method iterates over the sparse tree of\n * Set<DisconnectableChildren> built up by AsyncDirectives, and calls\n * `_$notifyDirectiveConnectionChanged` on any directives that are encountered\n * in that tree, running the required callbacks.\n *\n * A given \"logical tree\" of lit-html data-structures might look like this:\n *\n * ChildPart(N1) _$dC=[D2,T3]\n * ._directive\n * AsyncDirective(D2)\n * ._value // user value was TemplateResult\n * TemplateInstance(T3) _$dC=[A4,A6,N10,N12]\n * ._parts[]\n * AttributePart(A4) _$dC=[D5]\n * ._directives[]\n * AsyncDirective(D5)\n * AttributePart(A6) _$dC=[D7,D8]\n * ._directives[]\n * AsyncDirective(D7)\n * Directive(D8) _$dC=[D9]\n * ._directive\n * AsyncDirective(D9)\n * ChildPart(N10) _$dC=[D11]\n * ._directive\n * AsyncDirective(D11)\n * ._value\n * string\n * ChildPart(N12) _$dC=[D13,N14,N16]\n * ._directive\n * AsyncDirective(D13)\n * ._value // user value was iterable\n * Array<ChildPart>\n * ChildPart(N14) _$dC=[D15]\n * ._value\n * string\n * ChildPart(N16) _$dC=[D17,T18]\n * ._directive\n * AsyncDirective(D17)\n * ._value // user value was TemplateResult\n * TemplateInstance(T18) _$dC=[A19,A21,N25]\n * ._parts[]\n * AttributePart(A19) _$dC=[D20]\n * ._directives[]\n * AsyncDirective(D20)\n * AttributePart(A21) _$dC=[22,23]\n * ._directives[]\n * AsyncDirective(D22)\n * Directive(D23) _$dC=[D24]\n * ._directive\n * AsyncDirective(D24)\n * ChildPart(N25) _$dC=[D26]\n * ._directive\n * AsyncDirective(D26)\n * ._value\n * string\n *\n * Example 1: The directive in ChildPart(N12) updates and returns `nothing`. The\n * ChildPart will _clear() itself, and so we need to disconnect the \"value\" of\n * the ChildPart (but not its directive). In this case, when `_clear()` calls\n * `_$notifyConnectionChanged()`, we don't iterate all of the\n * _$disconnectableChildren, rather we do a value-specific disconnection: i.e.\n * since the _value was an Array<ChildPart> (because an iterable had been\n * committed), we iterate the array of ChildParts (N14, N16) and run\n * `setConnected` on them (which does recurse down the full tree of\n * `_$disconnectableChildren` below it, and also removes N14 and N16 from N12's\n * `_$disconnectableChildren`). Once the values have been disconnected, we then\n * check whether the ChildPart(N12)'s list of `_$disconnectableChildren` is empty\n * (and would remove it from its parent TemplateInstance(T3) if so), but since\n * it would still contain its directive D13, it stays in the disconnectable\n * tree.\n *\n * Example 2: In the course of Example 1, `setConnected` will reach\n * ChildPart(N16); in this case the entire part is being disconnected, so we\n * simply iterate all of N16's `_$disconnectableChildren` (D17,T18) and\n * recursively run `setConnected` on them. Note that we only remove children\n * from `_$disconnectableChildren` for the top-level values being disconnected\n * on a clear; doing this bookkeeping lower in the tree is wasteful since it's\n * all being thrown away.\n *\n * Example 3: If the LitElement containing the entire tree above becomes\n * disconnected, it will run `childPart.setConnected()` (which calls\n * `childPart._$notifyConnectionChanged()` if it exists); in this case, we\n * recursively run `setConnected()` over the entire tree, without removing any\n * children from `_$disconnectableChildren`, since this tree is required to\n * re-connect the tree, which does the same operation, simply passing\n * `isConnectd: true` down the tree, signaling which callback to run.\n */\n\nimport {AttributePart, ChildPart, Disconnectable, Part} from './lit-html.js';\nimport {isSingleExpression} from './directive-helpers.js';\nimport {Directive, PartInfo, PartType} from './directive.js';\nexport {directive} from './directive.js';\n\nconst DEV_MODE = true;\n\n/**\n * Recursively walks down the tree of Parts/TemplateInstances/Directives to set\n * the connected state of directives and run `disconnected`/ `reconnected`\n * callbacks.\n *\n * @return True if there were children to disconnect; false otherwise\n */\nconst notifyChildrenConnectedChanged = (\n parent: Disconnectable,\n isConnected: boolean\n): boolean => {\n const children = parent._$disconnectableChildren;\n if (children === undefined) {\n return false;\n }\n for (const obj of children) {\n // The existence of `_$notifyDirectiveConnectionChanged` is used as a \"brand\" to\n // disambiguate AsyncDirectives from other DisconnectableChildren\n // (as opposed to using an instanceof check to know when to call it); the\n // redundancy of \"Directive\" in the API name is to avoid conflicting with\n // `_$notifyConnectionChanged`, which exists `ChildParts` which are also in\n // this list\n // Disconnect Directive (and any nested directives contained within)\n // This property needs to remain unminified.\n (obj as AsyncDirective)['_$notifyDirectiveConnectionChanged']?.(\n isConnected,\n false\n );\n // Disconnect Part/TemplateInstance\n notifyChildrenConnectedChanged(obj, isConnected);\n }\n return true;\n};\n\n/**\n * Removes the given child from its parent list of disconnectable children, and\n * if the parent list becomes empty as a result, removes the parent from its\n * parent, and so forth up the tree when that causes subsequent parent lists to\n * become empty.\n */\nconst removeDisconnectableFromParent = (obj: Disconnectable) => {\n let parent, children;\n do {\n if ((parent = obj._$parent) === undefined) {\n break;\n }\n children = parent._$disconnectableChildren!;\n children.delete(obj);\n obj = parent;\n } while (children?.size === 0);\n};\n\nconst addDisconnectableToParent = (obj: Disconnectable) => {\n // Climb the parent tree, creating a sparse tree of children needing\n // disconnection\n for (let parent; (parent = obj._$parent); obj = parent) {\n let children = parent._$disconnectableChildren;\n if (children === undefined) {\n parent._$disconnectableChildren = children = new Set();\n } else if (children.has(obj)) {\n // Once we've reached a parent that already contains this child, we\n // can short-circuit\n break;\n }\n children.add(obj);\n installDisconnectAPI(parent);\n }\n};\n\n/**\n * Changes the parent reference of the ChildPart, and updates the sparse tree of\n * Disconnectable children accordingly.\n *\n * Note, this method will be patched onto ChildPart instances and called from\n * the core code when parts are moved between different parents.\n */\nfunction reparentDisconnectables(this: ChildPart, newParent: Disconnectable) {\n if (this._$disconnectableChildren !== undefined) {\n removeDisconnectableFromParent(this);\n this._$parent = newParent;\n addDisconnectableToParent(this);\n } else {\n this._$parent = newParent;\n }\n}\n\n/**\n * Sets the connected state on any directives contained within the committed\n * value of this part (i.e. within a TemplateInstance or iterable of\n * ChildParts) and runs their `disconnected`/`reconnected`s, as well as within\n * any directives stored on the ChildPart (when `valueOnly` is false).\n *\n * `isClearingValue` should be passed as `true` on a top-level part that is\n * clearing itself, and not as a result of recursively disconnecting directives\n * as part of a `clear` operation higher up the tree. This both ensures that any\n * directive on this ChildPart that produced a value that caused the clear\n * operation is not disconnected, and also serves as a performance optimization\n * to avoid needless bookkeeping when a subtree is going away; when clearing a\n * subtree, only the top-most part need to remove itself from the parent.\n *\n * `fromPartIndex` is passed only in the case of a partial `_clear` running as a\n * result of truncating an iterable.\n *\n * Note, this method will be patched onto ChildPart instances and called from the\n * core code when parts are cleared or the connection state is changed by the\n * user.\n */\nfunction notifyChildPartConnectedChanged(\n this: ChildPart,\n isConnected: boolean,\n isClearingValue = false,\n fromPartIndex = 0\n) {\n const value = this._$committedValue;\n const children = this._$disconnectableChildren;\n if (children === undefined || children.size === 0) {\n return;\n }\n if (isClearingValue) {\n if (Array.isArray(value)) {\n // Iterable case: Any ChildParts created by the iterable should be\n // disconnected and removed from this ChildPart's disconnectable\n // children (starting at `fromPartIndex` in the case of truncation)\n for (let i = fromPartIndex; i < value.length; i++) {\n notifyChildrenConnectedChanged(value[i], false);\n removeDisconnectableFromParent(value[i]);\n }\n } else if (value != null) {\n // TemplateInstance case: If the value has disconnectable children (will\n // only be in the case that it is a TemplateInstance), we disconnect it\n // and remove it from this ChildPart's disconnectable children\n notifyChildrenConnectedChanged(value as Disconnectable, false);\n removeDisconnectableFromParent(value as Disconnectable);\n }\n } else {\n notifyChildrenConnectedChanged(this, isConnected);\n }\n}\n\n/**\n * Patches disconnection API onto ChildParts.\n */\nconst installDisconnectAPI = (obj: Disconnectable) => {\n if ((obj as ChildPart).type == PartType.CHILD) {\n (obj as ChildPart)._$notifyConnectionChanged ??=\n notifyChildPartConnectedChanged;\n (obj as ChildPart)._$reparentDisconnectables ??= reparentDisconnectables;\n }\n};\n\n/**\n * An abstract `Directive` base class whose `disconnected` method will be\n * called when the part containing the directive is cleared as a result of\n * re-rendering, or when the user calls `part.setConnected(false)` on\n * a part that was previously rendered containing the directive (as happens\n * when e.g. a LitElement disconnects from the DOM).\n *\n * If `part.setConnected(true)` is subsequently called on a\n * containing part, the directive's `reconnected` method will be called prior\n * to its next `update`/`render` callbacks. When implementing `disconnected`,\n * `reconnected` should also be implemented to be compatible with reconnection.\n *\n * Note that updates may occur while the directive is disconnected. As such,\n * directives should generally check the `this.isConnected` flag during\n * render/update to determine whether it is safe to subscribe to resources\n * that may prevent garbage collection.\n */\nexport abstract class AsyncDirective extends Directive {\n // As opposed to other Disconnectables, AsyncDirectives always get notified\n // when the RootPart connection changes, so the public `isConnected`\n // is a locally stored variable initialized via its part's getter and synced\n // via `_$notifyDirectiveConnectionChanged`. This is cheaper than using\n // the _$isConnected getter, which has to look back up the tree each time.\n /**\n * The connection state for this Directive.\n */\n isConnected!: boolean;\n\n // @internal\n override _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /**\n * Initialize the part with internal fields\n * @param part\n * @param parent\n * @param attributeIndex\n */\n override _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n super._$initialize(part, parent, attributeIndex);\n addDisconnectableToParent(this);\n this.isConnected = part._$isConnected;\n }\n // This property needs to remain unminified.\n /**\n * Called from the core code when a directive is going away from a part (in\n * which case `shouldRemoveFromParent` should be true), and from the\n * `setChildrenConnected` helper function when recursively changing the\n * connection state of a tree (in which case `shouldRemoveFromParent` should\n * be false).\n *\n * @param isConnected\n * @param isClearingDirective - True when the directive itself is being\n * removed; false when the tree is being disconnected\n * @internal\n */\n override ['_$notifyDirectiveConnectionChanged'](\n isConnected: boolean,\n isClearingDirective = true\n ) {\n if (isConnected !== this.isConnected) {\n this.isConnected = isConnected;\n if (isConnected) {\n this.reconnected?.();\n } else {\n this.disconnected?.();\n }\n }\n if (isClearingDirective) {\n notifyChildrenConnectedChanged(this, isConnected);\n removeDisconnectableFromParent(this);\n }\n }\n\n /**\n * Sets the value of the directive's Part outside the normal `update`/`render`\n * lifecycle of a directive.\n *\n * This method should not be called synchronously from a directive's `update`\n * or `render`.\n *\n * @param directive The directive to update\n * @param value The value to set\n */\n setValue(value: unknown) {\n if (isSingleExpression(this.__part as unknown as PartInfo)) {\n this.__part._$setValue(value, this);\n } else {\n // this.__attributeIndex will be defined in this case, but\n // assert it in dev mode\n if (DEV_MODE && this.__attributeIndex === undefined) {\n throw new Error(`Expected this.__attributeIndex to be a number`);\n }\n const newValues = [...(this.__part._$committedValue as Array<unknown>)];\n newValues[this.__attributeIndex!] = value;\n (this.__part as AttributePart)._$setValue(newValues, this, 0);\n }\n }\n\n /**\n * User callbacks for implementing logic to release any resources/subscriptions\n * that may have been retained by this directive. Since directives may also be\n * re-connected, `reconnected` should also be implemented to restore the\n * working state of the directive prior to the next render.\n */\n protected disconnected() {}\n protected reconnected() {}\n}\n"]}
@@ -3,15 +3,15 @@
3
3
  * Copyright 2020 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { DirectiveClass, DirectiveResult, PartInfo } from './directive.js';
7
- import { DirectiveParent, Part, TemplateResult } from './lit-html.js';
8
-
6
+ import { Part, DirectiveParent, TemplateResult } from './lit-html.js';
7
+ import { DirectiveResult, DirectiveClass, PartInfo } from './directive.js';
8
+ declare type Primitive = null | undefined | boolean | number | string | symbol | bigint;
9
9
  /**
10
10
  * Tests if a value is a primitive value.
11
11
  *
12
12
  * See https://tc39.github.io/ecma262/#sec-typeof-operator
13
13
  */
14
- export declare const isPrimitive: (value: unknown) => value is string | number | bigint | boolean | symbol | null | undefined;
14
+ export declare const isPrimitive: (value: unknown) => value is Primitive;
15
15
  export declare const TemplateResultType: {
16
16
  readonly HTML: 1;
17
17
  readonly SVG: 2;
@@ -20,7 +20,7 @@ export declare type TemplateResultType = typeof TemplateResultType[keyof typeof
20
20
  /**
21
21
  * Tests if a value is a TemplateResult.
22
22
  */
23
- export declare const isTemplateResult: (value: unknown, type?: 1 | 2 | undefined) => value is TemplateResult<1 | 2>;
23
+ export declare const isTemplateResult: (value: unknown, type?: TemplateResultType | undefined) => value is TemplateResult<1 | 2>;
24
24
  /**
25
25
  * Tests if a value is a DirectiveResult.
26
26
  */
@@ -102,4 +102,5 @@ export declare const getCommittedValue: (part: import("./lit-html.js").ChildPart
102
102
  */
103
103
  export declare const removePart: (part: import("./lit-html.js").ChildPart) => void;
104
104
  export declare const clearPart: (part: import("./lit-html.js").ChildPart) => void;
105
+ export {};
105
106
  //# sourceMappingURL=directive-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"directive-helpers.d.ts","sourceRoot":"","sources":["../src/directive-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAK,IAAI,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACxE,OAAO,EACL,eAAe,EACf,cAAc,EACd,QAAQ,EAET,MAAM,gBAAgB,CAAC;AAgBxB;;;;GAIG;AACH,eAAO,MAAM,WAAW,UAAW,OAAO,4EACkC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O,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX,oBAAY,kBAAkB,GAC5B,OAAO,kBAAkB,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB,UACpB,OAAO,0EAMwC,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,6CAEe,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,cAAc,GAAG,SAEnB,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,SAAU,QAAQ,YACE,CAAC;AAIpD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,wMAqDtB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,gEAErB,OAAO,oBACG,eAAe,MAIjC,CAAC;AAMF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,SAAU,IAAI,UAAS,OAAO,YAC3B,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,sDAA6C,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,UAAU,mDAStB,CAAC;AAEF,eAAO,MAAM,SAAS,mDAErB,CAAC"}
@@ -4,10 +4,11 @@
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
6
  var _a, _b;
7
- import { _Σ } from './lit-html.js';
8
- const { _ChildPart: ChildPart } = _Σ;
7
+ import { _$LH } from './lit-html.js';
8
+ const { _ChildPart: ChildPart } = _$LH;
9
9
  const ENABLE_SHADYDOM_NOPATCH = true;
10
- const wrap = ENABLE_SHADYDOM_NOPATCH && ((_a = window.ShadyDOM) === null || _a === void 0 ? void 0 : _a.inUse) &&
10
+ const wrap = ENABLE_SHADYDOM_NOPATCH &&
11
+ ((_a = window.ShadyDOM) === null || _a === void 0 ? void 0 : _a.inUse) &&
11
12
  ((_b = window.ShadyDOM) === null || _b === void 0 ? void 0 : _b.noPatch) === true
12
13
  ? window.ShadyDOM.wrap
13
14
  : (node) => node;
@@ -27,17 +28,22 @@ export const TemplateResultType = {
27
28
  export const isTemplateResult = (value, type) => {
28
29
  var _a, _b;
29
30
  return type === undefined
30
- ? ((_a = value) === null || _a === void 0 ? void 0 : _a._$litType$) !== undefined
31
- : ((_b = value) === null || _b === void 0 ? void 0 : _b._$litType$) === type;
31
+ ? // This property needs to remain unminified.
32
+ ((_a = value) === null || _a === void 0 ? void 0 : _a['_$litType$']) !== undefined
33
+ : ((_b = value) === null || _b === void 0 ? void 0 : _b['_$litType$']) === type;
32
34
  };
33
35
  /**
34
36
  * Tests if a value is a DirectiveResult.
35
37
  */
36
- export const isDirectiveResult = (value) => { var _a; return ((_a = value) === null || _a === void 0 ? void 0 : _a._$litDirective$) !== undefined; };
38
+ export const isDirectiveResult = (value) => { var _a;
39
+ // This property needs to remain unminified.
40
+ return ((_a = value) === null || _a === void 0 ? void 0 : _a['_$litDirective$']) !== undefined; };
37
41
  /**
38
42
  * Retrieves the Directive class for a DirectiveResult
39
43
  */
40
- export const getDirectiveClass = (value) => { var _a; return (_a = value) === null || _a === void 0 ? void 0 : _a._$litDirective$; };
44
+ export const getDirectiveClass = (value) => { var _a;
45
+ // This property needs to remain unminified.
46
+ return (_a = value) === null || _a === void 0 ? void 0 : _a['_$litDirective$']; };
41
47
  /**
42
48
  * Tests whether a part has only a single-expression with no strings to
43
49
  * interpolate between.
@@ -71,7 +77,8 @@ export const insertPart = (containerPart, refPart, part) => {
71
77
  }
72
78
  else {
73
79
  const endNode = wrap(part._$endNode).nextSibling;
74
- const parentChanged = part._$parent !== containerPart;
80
+ const oldParent = part._$parent;
81
+ const parentChanged = oldParent !== containerPart;
75
82
  if (parentChanged) {
76
83
  (_a = part._$reparentDisconnectables) === null || _a === void 0 ? void 0 : _a.call(part, containerPart);
77
84
  // Note that although `_$reparentDisconnectables` updates the part's
@@ -79,6 +86,15 @@ export const insertPart = (containerPart, refPart, part) => {
79
86
  // method only exists if Disconnectables are present, so we need to
80
87
  // unconditionally set it here
81
88
  part._$parent = containerPart;
89
+ // Since the _$isConnected getter is somewhat costly, only
90
+ // read it once we know the subtree has directives that need
91
+ // to be notified
92
+ let newConnectionState;
93
+ if (part._$notifyConnectionChanged !== undefined &&
94
+ (newConnectionState = containerPart._$isConnected) !==
95
+ oldParent._$isConnected) {
96
+ part._$notifyConnectionChanged(newConnectionState);
97
+ }
82
98
  }
83
99
  if (endNode !== refNode || parentChanged) {
84
100
  let start = part._$startNode;
@@ -148,7 +164,7 @@ export const getCommittedValue = (part) => part._$committedValue;
148
164
  */
149
165
  export const removePart = (part) => {
150
166
  var _a;
151
- (_a = part._$setChildPartConnected) === null || _a === void 0 ? void 0 : _a.call(part, false, true);
167
+ (_a = part._$notifyConnectionChanged) === null || _a === void 0 ? void 0 : _a.call(part, false, true);
152
168
  let start = part._$startNode;
153
169
  const end = wrap(part._$endNode).nextSibling;
154
170
  while (start !== end) {
@@ -1 +1 @@
1
- {"version":3,"file":"directive-helpers.js","sourceRoot":"","sources":["../src/directive-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,EAAE,EAAwC,MAAM,eAAe,CAAC;AASxE,MAAM,EAAC,UAAU,EAAE,SAAS,EAAC,GAAG,EAAE,CAAC;AAInC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,MAAM,IAAI,GACR,uBAAuB,WACvB,MAAM,CAAC,QAAQ,0CAAE,KAAK,CAAA;IACtB,OAAA,MAAM,CAAC,QAAQ,0CAAE,OAAO,MAAK,IAAI;IAC/B,CAAC,CAAC,MAAM,CAAC,QAAS,CAAC,IAAI;IACvB,CAAC,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC;AAE3B;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAsB,EAAE,CAChE,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK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C;AAEF,4EAA4E;AAC5E,qEAAqE;AACrE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAU,EAAE,QAAiB,WAAW,EAAE,EAAE,CAC5E,CAAC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAe,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC;AAE5E;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAe,EAAE,EAAE;;IAC5C,MAAA,IAAI,CAAC,uBAAuB,+CAA5B,IAAI,EAA2B,KAAK,EAAE,IAAI,EAAE;IAC5C,IAAI,KAAK,GAAqB,IAAI,CAAC,WAAW,CAAC;IAC/C,MAAM,GAAG,GAAqB,IAAI,CAAC,IAAI,CAAC,SAAU,CAAC,CAAC,WAAW,CAAC;IAChE,OAAO,KAAK,KAAK,GAAG,EAAE;QACpB,MAAM,CAAC,GAAqB,IAAI,CAAC,KAAM,CAAC,CAAC,WAAW,CAAC;QACpD,IAAI,CAAC,KAAM,CAAe,CAAC,MAAM,EAAE,CAAC;QACrC,KAAK,GAAG,CAAC,CAAC;KACX;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAe,EAAE,EAAE;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {_Σ, Part, DirectiveParent, TemplateResult} from './lit-html.js';\nimport {\n DirectiveResult,\n DirectiveClass,\n PartInfo,\n AttributePartInfo,\n} from './directive.js';\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\n\nconst {_ChildPart: ChildPart} = _Σ;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\n\nconst ENABLE_SHADYDOM_NOPATCH = true;\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM!.wrap\n : (node: Node) => node;\n\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\n\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n} as const;\n\nexport type TemplateResultType = typeof TemplateResultType[keyof typeof TemplateResultType];\n\n/**\n * Tests if a value is a TemplateResult.\n */\nexport const isTemplateResult = (\n value: unknown,\n type?: TemplateResultType\n): value is TemplateResult =>\n type === undefined\n ? (value as TemplateResult)?._$litType$ !== undefined\n : (value as TemplateResult)?._$litType$ === type;\n\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value: unknown): value is DirectiveResult =>\n (value as DirectiveResult)?._$litDirective$ !== undefined;\n\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value: unknown): DirectiveClass | undefined =>\n (value as DirectiveResult)?._$litDirective$;\n\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part: PartInfo) =>\n (part as AttributePartInfo).strings === undefined;\n\nconst createMarker = () => document.createComment('');\n\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (\n containerPart: ChildPart,\n refPart?: ChildPart,\n part?: ChildPart\n): ChildPart => {\n const container = wrap(containerPart._$startNode).parentNode!;\n\n const refNode =\n refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(\n startNode,\n endNode,\n containerPart,\n containerPart.options\n );\n } else {\n const endNode = wrap(part._$endNode!).nextSibling;\n const parentChanged = part._$parent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n }\n if (endNode !== refNode || parentChanged) {\n let start: Node | null = part._$startNode;\n while (start !== endNode) {\n const n: Node | null = wrap(start!).nextSibling;\n wrap(container).insertBefore(start!, refNode);\n start = n;\n }\n }\n }\n\n return part;\n};\n\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = <T extends ChildPart>(\n part: T,\n value: unknown,\n directiveParent: DirectiveParent = part\n): T => {\n part._$setValue(value, directiveParent);\n return part;\n};\n\n// A sentinal value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part: Part, value: unknown = RESET_VALUE) =>\n (part._$committedValue = value);\n\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being commited.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part: ChildPart) => part._$committedValue;\n\n/**\n * Removes a ChildPart from the DOM, including any of its content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part: ChildPart) => {\n part._$setChildPartConnected?.(false, true);\n let start: ChildNode | null = part._$startNode;\n const end: ChildNode | null = wrap(part._$endNode!).nextSibling;\n while (start !== end) {\n const n: ChildNode | null = wrap(start!).nextSibling;\n (wrap(start!) as ChildNode).remove();\n start = n;\n }\n};\n\nexport const clearPart = (part: ChildPart) => {\n part._$clear();\n};\n"]}
1
+ {"version":3,"file":"directive-helpers.js","sourceRoot":"","sources":["../src/directive-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAwC,MAAM,eAAe,CAAC;AAS1E,MAAM,EAAC,UAAU,EAAE,SAAS,EAAC,GAAG,IAAI,CAAC;AAIrC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,MAAM,IAAI,GACR,uBAAuB;KACvB,MAAA,MAAM,CAAC,QAAQ,0CAAE,KAAK,CAAA;IACtB,CAAA,MAAA,MAAM,CAAC,QAAQ,0CAAE,OAAO,MAAK,IAAI;IAC/B,CAAC,CAAC,MAAM,CAAC,QAAS,CAAC,IAAI;IACvB,CAAC,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC;AAE3B;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAsB,EAAE,CAChE,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,KAAK,I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AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAe,EAAE,EAAE;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {_$LH, Part, DirectiveParent, TemplateResult} from './lit-html.js';\nimport {\n DirectiveResult,\n DirectiveClass,\n PartInfo,\n AttributePartInfo,\n} from './directive.js';\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\n\nconst {_ChildPart: ChildPart} = _$LH;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\n\nconst ENABLE_SHADYDOM_NOPATCH = true;\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM!.wrap\n : (node: Node) => node;\n\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\n\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n} as const;\n\nexport type TemplateResultType =\n typeof TemplateResultType[keyof typeof TemplateResultType];\n\n/**\n * Tests if a value is a TemplateResult.\n */\nexport const isTemplateResult = (\n value: unknown,\n type?: TemplateResultType\n): value is TemplateResult =>\n type === undefined\n ? // This property needs to remain unminified.\n (value as TemplateResult)?.['_$litType$'] !== undefined\n : (value as TemplateResult)?.['_$litType$'] === type;\n\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value: unknown): value is DirectiveResult =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'] !== undefined;\n\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value: unknown): DirectiveClass | undefined =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'];\n\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part: PartInfo) =>\n (part as AttributePartInfo).strings === undefined;\n\nconst createMarker = () => document.createComment('');\n\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (\n containerPart: ChildPart,\n refPart?: ChildPart,\n part?: ChildPart\n): ChildPart => {\n const container = wrap(containerPart._$startNode).parentNode!;\n\n const refNode =\n refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(\n startNode,\n endNode,\n containerPart,\n containerPart.options\n );\n } else {\n const endNode = wrap(part._$endNode!).nextSibling;\n const oldParent = part._$parent;\n const parentChanged = oldParent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n // Since the _$isConnected getter is somewhat costly, only\n // read it once we know the subtree has directives that need\n // to be notified\n let newConnectionState;\n if (\n part._$notifyConnectionChanged !== undefined &&\n (newConnectionState = containerPart._$isConnected) !==\n oldParent!._$isConnected\n ) {\n part._$notifyConnectionChanged(newConnectionState);\n }\n }\n if (endNode !== refNode || parentChanged) {\n let start: Node | null = part._$startNode;\n while (start !== endNode) {\n const n: Node | null = wrap(start!).nextSibling;\n wrap(container).insertBefore(start!, refNode);\n start = n;\n }\n }\n }\n\n return part;\n};\n\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = <T extends ChildPart>(\n part: T,\n value: unknown,\n directiveParent: DirectiveParent = part\n): T => {\n part._$setValue(value, directiveParent);\n return part;\n};\n\n// A sentinal value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part: Part, value: unknown = RESET_VALUE) =>\n (part._$committedValue = value);\n\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being commited.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part: ChildPart) => part._$committedValue;\n\n/**\n * Removes a ChildPart from the DOM, including any of its content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part: ChildPart) => {\n part._$notifyConnectionChanged?.(false, true);\n let start: ChildNode | null = part._$startNode;\n const end: ChildNode | null = wrap(part._$endNode!).nextSibling;\n while (start !== end) {\n const n: ChildNode | null = wrap(start!).nextSibling;\n (wrap(start!) as ChildNode).remove();\n start = n;\n }\n};\n\nexport const clearPart = (part: ChildPart) => {\n part._$clear();\n};\n"]}