chrome-devtools-frontend 1.0.944427 → 1.0.944903

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 (251) 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/InspectorFrontendHostAPI.ts +5 -5
  4. package/front_end/core/i18n/locales/en-US.json +3 -15
  5. package/front_end/core/i18n/locales/en-XL.json +15 -27
  6. package/front_end/core/protocol_client/NodeURL.ts +1 -0
  7. package/front_end/core/sdk/CSSStyleSheetHeader.ts +2 -3
  8. package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +2 -3
  9. package/front_end/core/sdk/Cookie.ts +17 -0
  10. package/front_end/core/sdk/CookieModel.ts +1 -0
  11. package/front_end/core/sdk/DebuggerModel.ts +5 -4
  12. package/front_end/core/sdk/NetworkManager.ts +4 -1
  13. package/front_end/core/sdk/NetworkRequest.ts +2 -2
  14. package/front_end/core/sdk/Resource.ts +2 -2
  15. package/front_end/core/sdk/Script.ts +2 -3
  16. package/front_end/models/bindings/BreakpointManager.ts +3 -4
  17. package/front_end/models/bindings/ResourceMapping.ts +1 -2
  18. package/front_end/models/bindings/StylesSourceMapping.ts +1 -2
  19. package/front_end/models/persistence/IsolatedFileSystem.ts +7 -6
  20. package/front_end/models/persistence/IsolatedFileSystemManager.ts +10 -6
  21. package/front_end/models/persistence/PersistenceActions.ts +4 -1
  22. package/front_end/models/persistence/PlatformFileSystem.ts +3 -4
  23. package/front_end/models/text_utils/ContentProvider.ts +1 -2
  24. package/front_end/models/text_utils/StaticContentProvider.ts +2 -3
  25. package/front_end/models/workspace/UISourceCode.ts +2 -2
  26. package/front_end/panels/animation/animationTimeline.css +2 -0
  27. package/front_end/panels/application/ReportingApiView.ts +15 -1
  28. package/front_end/panels/application/components/EndpointsGrid.ts +63 -4
  29. package/front_end/panels/application/components/FrameDetailsView.ts +21 -34
  30. package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +1 -1
  31. package/front_end/panels/sources/DebuggerPlugin.ts +1 -1
  32. package/front_end/panels/sources/NavigatorView.ts +1 -1
  33. package/front_end/panels/sources/UISourceCodeFrame.ts +0 -1
  34. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +3 -34
  35. package/front_end/panels/timeline/TimelineUIUtils.ts +51 -3
  36. package/front_end/services/window_bounds/WindowBoundsService.ts +27 -0
  37. package/front_end/services/window_bounds/window_bounds.ts +9 -0
  38. package/front_end/third_party/codemirror.next/bundle.ts +1 -1
  39. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  40. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +8 -1
  41. package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
  42. package/front_end/third_party/codemirror.next/package.json +1 -1
  43. package/front_end/third_party/lit-html/README.chromium +2 -2
  44. package/front_end/third_party/lit-html/package/CHANGELOG.md +216 -28
  45. package/front_end/third_party/lit-html/package/LICENSE +9 -9
  46. package/front_end/third_party/lit-html/package/README.md +12 -162
  47. package/front_end/third_party/lit-html/package/async-directive.d.ts +23 -54
  48. package/front_end/third_party/lit-html/package/async-directive.d.ts.map +1 -1
  49. package/front_end/third_party/lit-html/package/async-directive.js +2 -7
  50. package/front_end/third_party/lit-html/package/async-directive.js.map +1 -1
  51. package/front_end/third_party/lit-html/package/development/async-directive.d.ts +23 -54
  52. package/front_end/third_party/lit-html/package/development/async-directive.d.ts.map +1 -1
  53. package/front_end/third_party/lit-html/package/development/async-directive.js +44 -194
  54. package/front_end/third_party/lit-html/package/development/async-directive.js.map +1 -1
  55. package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts +6 -5
  56. package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts.map +1 -1
  57. package/front_end/third_party/lit-html/package/development/directive-helpers.js +25 -9
  58. package/front_end/third_party/lit-html/package/development/directive-helpers.js.map +1 -1
  59. package/front_end/third_party/lit-html/package/development/directive.d.ts +3 -16
  60. package/front_end/third_party/lit-html/package/development/directive.d.ts.map +1 -1
  61. package/front_end/third_party/lit-html/package/development/directive.js +6 -1
  62. package/front_end/third_party/lit-html/package/development/directive.js.map +1 -1
  63. package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts +7 -14
  64. package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts.map +1 -1
  65. package/front_end/third_party/lit-html/package/development/directives/async-append.js +17 -58
  66. package/front_end/third_party/lit-html/package/development/directives/async-append.js.map +1 -1
  67. package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts +9 -14
  68. package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts.map +1 -1
  69. package/front_end/third_party/lit-html/package/development/directives/async-replace.js +57 -37
  70. package/front_end/third_party/lit-html/package/development/directives/async-replace.js.map +1 -1
  71. package/front_end/third_party/lit-html/package/development/directives/cache.d.ts +2 -3
  72. package/front_end/third_party/lit-html/package/development/directives/cache.d.ts.map +1 -1
  73. package/front_end/third_party/lit-html/package/development/directives/cache.js +4 -6
  74. package/front_end/third_party/lit-html/package/development/directives/cache.js.map +1 -1
  75. package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts +2 -2
  76. package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts.map +1 -1
  77. package/front_end/third_party/lit-html/package/development/directives/class-map.js +17 -7
  78. package/front_end/third_party/lit-html/package/development/directives/class-map.js.map +1 -1
  79. package/front_end/third_party/lit-html/package/development/directives/guard.d.ts +3 -2
  80. package/front_end/third_party/lit-html/package/development/directives/guard.d.ts.map +1 -1
  81. package/front_end/third_party/lit-html/package/development/directives/guard.js +3 -2
  82. package/front_end/third_party/lit-html/package/development/directives/guard.js.map +1 -1
  83. package/front_end/third_party/lit-html/package/development/directives/live.d.ts +4 -3
  84. package/front_end/third_party/lit-html/package/development/directives/live.d.ts.map +1 -1
  85. package/front_end/third_party/lit-html/package/development/directives/live.js +5 -7
  86. package/front_end/third_party/lit-html/package/development/directives/live.js.map +1 -1
  87. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts +58 -0
  88. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts.map +1 -0
  89. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js +85 -0
  90. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js.map +1 -0
  91. package/front_end/third_party/lit-html/package/development/directives/ref.d.ts +14 -11
  92. package/front_end/third_party/lit-html/package/development/directives/ref.d.ts.map +1 -1
  93. package/front_end/third_party/lit-html/package/development/directives/ref.js +13 -11
  94. package/front_end/third_party/lit-html/package/development/directives/ref.js.map +1 -1
  95. package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts +8 -4
  96. package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts.map +1 -1
  97. package/front_end/third_party/lit-html/package/development/directives/repeat.js +23 -9
  98. package/front_end/third_party/lit-html/package/development/directives/repeat.js.map +1 -1
  99. package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts +1 -2
  100. package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts.map +1 -1
  101. package/front_end/third_party/lit-html/package/development/directives/style-map.js +1 -2
  102. package/front_end/third_party/lit-html/package/development/directives/style-map.js.map +1 -1
  103. package/front_end/third_party/lit-html/package/development/directives/template-content.d.ts +1 -2
  104. package/front_end/third_party/lit-html/package/development/directives/template-content.js +1 -2
  105. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts +6 -4
  106. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts.map +1 -1
  107. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js +7 -5
  108. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js.map +1 -1
  109. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts +4 -1
  110. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts.map +1 -1
  111. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js +3 -0
  112. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js.map +1 -1
  113. package/front_end/third_party/lit-html/package/development/directives/until.d.ts +12 -8
  114. package/front_end/third_party/lit-html/package/development/directives/until.d.ts.map +1 -1
  115. package/front_end/third_party/lit-html/package/development/directives/until.js +63 -23
  116. package/front_end/third_party/lit-html/package/development/directives/until.js.map +1 -1
  117. package/front_end/third_party/lit-html/package/development/experimental-hydrate.d.ts.map +1 -1
  118. package/front_end/third_party/lit-html/package/development/experimental-hydrate.js +9 -8
  119. package/front_end/third_party/lit-html/package/development/experimental-hydrate.js.map +1 -1
  120. package/front_end/third_party/lit-html/package/development/lit-html.d.ts +81 -136
  121. package/front_end/third_party/lit-html/package/development/lit-html.d.ts.map +1 -1
  122. package/front_end/third_party/lit-html/package/development/lit-html.js +249 -76
  123. package/front_end/third_party/lit-html/package/development/lit-html.js.map +1 -1
  124. package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts +1 -41
  125. package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts.map +1 -1
  126. package/front_end/third_party/lit-html/package/development/polyfill-support.js +40 -21
  127. package/front_end/third_party/lit-html/package/development/polyfill-support.js.map +1 -1
  128. package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts +12 -10
  129. package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts.map +1 -1
  130. package/front_end/third_party/lit-html/package/development/private-ssr-support.js +11 -3
  131. package/front_end/third_party/lit-html/package/development/private-ssr-support.js.map +1 -1
  132. package/front_end/third_party/lit-html/package/development/static.d.ts.map +1 -1
  133. package/front_end/third_party/lit-html/package/development/static.js +6 -5
  134. package/front_end/third_party/lit-html/package/development/static.js.map +1 -1
  135. package/front_end/third_party/lit-html/package/directive-helpers.d.ts +6 -5
  136. package/front_end/third_party/lit-html/package/directive-helpers.d.ts.map +1 -1
  137. package/front_end/third_party/lit-html/package/directive-helpers.js +2 -2
  138. package/front_end/third_party/lit-html/package/directive-helpers.js.map +1 -1
  139. package/front_end/third_party/lit-html/package/directive.d.ts +3 -16
  140. package/front_end/third_party/lit-html/package/directive.d.ts.map +1 -1
  141. package/front_end/third_party/lit-html/package/directive.js +1 -1
  142. package/front_end/third_party/lit-html/package/directive.js.map +1 -1
  143. package/front_end/third_party/lit-html/package/directives/async-append.d.ts +7 -14
  144. package/front_end/third_party/lit-html/package/directives/async-append.d.ts.map +1 -1
  145. package/front_end/third_party/lit-html/package/directives/async-append.js +2 -6
  146. package/front_end/third_party/lit-html/package/directives/async-append.js.map +1 -1
  147. package/front_end/third_party/lit-html/package/directives/async-replace.d.ts +9 -14
  148. package/front_end/third_party/lit-html/package/directives/async-replace.d.ts.map +1 -1
  149. package/front_end/third_party/lit-html/package/directives/async-replace.js +2 -5
  150. package/front_end/third_party/lit-html/package/directives/async-replace.js.map +1 -1
  151. package/front_end/third_party/lit-html/package/directives/cache.d.ts +2 -3
  152. package/front_end/third_party/lit-html/package/directives/cache.d.ts.map +1 -1
  153. package/front_end/third_party/lit-html/package/directives/cache.js +2 -5
  154. package/front_end/third_party/lit-html/package/directives/cache.js.map +1 -1
  155. package/front_end/third_party/lit-html/package/directives/class-map.d.ts +2 -2
  156. package/front_end/third_party/lit-html/package/directives/class-map.d.ts.map +1 -1
  157. package/front_end/third_party/lit-html/package/directives/class-map.js +2 -4
  158. package/front_end/third_party/lit-html/package/directives/class-map.js.map +1 -1
  159. package/front_end/third_party/lit-html/package/directives/guard.d.ts +3 -2
  160. package/front_end/third_party/lit-html/package/directives/guard.d.ts.map +1 -1
  161. package/front_end/third_party/lit-html/package/directives/guard.js +2 -4
  162. package/front_end/third_party/lit-html/package/directives/guard.js.map +1 -1
  163. package/front_end/third_party/lit-html/package/directives/live.d.ts +4 -3
  164. package/front_end/third_party/lit-html/package/directives/live.d.ts.map +1 -1
  165. package/front_end/third_party/lit-html/package/directives/live.js +1 -4
  166. package/front_end/third_party/lit-html/package/directives/live.js.map +1 -1
  167. package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts +58 -0
  168. package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts.map +1 -0
  169. package/front_end/third_party/lit-html/package/directives/private-async-helpers.js +7 -0
  170. package/front_end/third_party/lit-html/package/directives/private-async-helpers.js.map +1 -0
  171. package/front_end/third_party/lit-html/package/directives/ref.d.ts +14 -11
  172. package/front_end/third_party/lit-html/package/directives/ref.d.ts.map +1 -1
  173. package/front_end/third_party/lit-html/package/directives/ref.js +2 -5
  174. package/front_end/third_party/lit-html/package/directives/ref.js.map +1 -1
  175. package/front_end/third_party/lit-html/package/directives/repeat.d.ts +8 -4
  176. package/front_end/third_party/lit-html/package/directives/repeat.d.ts.map +1 -1
  177. package/front_end/third_party/lit-html/package/directives/repeat.js +2 -5
  178. package/front_end/third_party/lit-html/package/directives/repeat.js.map +1 -1
  179. package/front_end/third_party/lit-html/package/directives/style-map.d.ts +1 -2
  180. package/front_end/third_party/lit-html/package/directives/style-map.d.ts.map +1 -1
  181. package/front_end/third_party/lit-html/package/directives/style-map.js +2 -4
  182. package/front_end/third_party/lit-html/package/directives/style-map.js.map +1 -1
  183. package/front_end/third_party/lit-html/package/directives/template-content.d.ts +1 -2
  184. package/front_end/third_party/lit-html/package/directives/template-content.js +2 -4
  185. package/front_end/third_party/lit-html/package/directives/template-content.js.map +1 -1
  186. package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts +6 -4
  187. package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts.map +1 -1
  188. package/front_end/third_party/lit-html/package/directives/unsafe-html.js +2 -4
  189. package/front_end/third_party/lit-html/package/directives/unsafe-html.js.map +1 -1
  190. package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts +4 -1
  191. package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts.map +1 -1
  192. package/front_end/third_party/lit-html/package/directives/unsafe-svg.js.map +1 -1
  193. package/front_end/third_party/lit-html/package/directives/until.d.ts +12 -8
  194. package/front_end/third_party/lit-html/package/directives/until.d.ts.map +1 -1
  195. package/front_end/third_party/lit-html/package/directives/until.js +2 -6
  196. package/front_end/third_party/lit-html/package/directives/until.js.map +1 -1
  197. package/front_end/third_party/lit-html/package/experimental-hydrate.d.ts.map +1 -1
  198. package/front_end/third_party/lit-html/package/experimental-hydrate.js +2 -5
  199. package/front_end/third_party/lit-html/package/experimental-hydrate.js.map +1 -1
  200. package/front_end/third_party/lit-html/package/lit-html.d.ts +81 -136
  201. package/front_end/third_party/lit-html/package/lit-html.d.ts.map +1 -1
  202. package/front_end/third_party/lit-html/package/lit-html.js +1 -1
  203. package/front_end/third_party/lit-html/package/lit-html.js.map +1 -1
  204. package/front_end/third_party/lit-html/package/package.json +75 -24
  205. package/front_end/third_party/lit-html/package/polyfill-support.d.ts +1 -41
  206. package/front_end/third_party/lit-html/package/polyfill-support.d.ts.map +1 -1
  207. package/front_end/third_party/lit-html/package/polyfill-support.js +1 -1
  208. package/front_end/third_party/lit-html/package/polyfill-support.js.map +1 -1
  209. package/front_end/third_party/lit-html/package/private-ssr-support.d.ts +12 -10
  210. package/front_end/third_party/lit-html/package/private-ssr-support.d.ts.map +1 -1
  211. package/front_end/third_party/lit-html/package/private-ssr-support.js +2 -2
  212. package/front_end/third_party/lit-html/package/private-ssr-support.js.map +1 -1
  213. package/front_end/third_party/lit-html/package/static.d.ts.map +1 -1
  214. package/front_end/third_party/lit-html/package/static.js +1 -1
  215. package/front_end/third_party/lit-html/package/static.js.map +1 -1
  216. package/front_end/third_party/marked/README.chromium +2 -2
  217. package/front_end/third_party/marked/marked.ts +2 -2
  218. package/front_end/third_party/marked/package/README.md +7 -1
  219. package/front_end/third_party/marked/package/bin/marked.js +214 -0
  220. package/front_end/third_party/marked/package/lib/marked.cjs +2907 -0
  221. package/front_end/third_party/marked/package/lib/marked.esm.d.ts +1 -3
  222. package/front_end/third_party/marked/package/lib/marked.esm.js +627 -586
  223. package/front_end/third_party/marked/package/lib/marked.umd.js +2913 -0
  224. package/front_end/third_party/marked/package/man/marked.1 +5 -24
  225. package/front_end/third_party/marked/package/man/marked.1.txt +21 -31
  226. package/front_end/third_party/marked/package/marked.min.js +1 -1
  227. package/front_end/third_party/marked/package/package.json +41 -32
  228. package/front_end/third_party/marked/package/src/Lexer.js +109 -108
  229. package/front_end/third_party/marked/package/src/Parser.js +38 -15
  230. package/front_end/third_party/marked/package/src/Renderer.js +5 -5
  231. package/front_end/third_party/marked/package/src/Slugger.js +2 -2
  232. package/front_end/third_party/marked/package/src/TextRenderer.js +2 -2
  233. package/front_end/third_party/marked/package/src/Tokenizer.js +215 -190
  234. package/front_end/third_party/marked/package/src/defaults.js +6 -9
  235. package/front_end/third_party/marked/package/src/helpers.js +16 -27
  236. package/front_end/third_party/marked/package/src/marked.js +146 -63
  237. package/front_end/third_party/marked/package/src/rules.js +20 -45
  238. package/front_end/third_party/wasmparser/README.chromium +2 -2
  239. package/front_end/third_party/wasmparser/package/.github/workflows/main.yml +47 -0
  240. package/front_end/third_party/wasmparser/package/CHANGELOG.md +12 -0
  241. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js +53 -53
  242. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js.map +1 -1
  243. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js +53 -53
  244. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js.map +1 -1
  245. package/front_end/third_party/wasmparser/package/package.json +1 -1
  246. package/front_end/third_party/wasmparser/package/src/WasmParser.ts +53 -53
  247. package/front_end/ui/components/text_editor/TextEditor.ts +29 -0
  248. package/front_end/ui/components/text_editor/config.ts +4 -2
  249. package/front_end/ui/legacy/ViewManager.ts +6 -0
  250. package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +20 -0
  251. package/package.json +1 -1
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
6
  import { Disconnectable, Part } from './lit-html';
7
- export { AttributePart, BooleanAttributePart, ChildPart, ElementPart, EventPart, Part, } from './lit-html';
7
+ export { AttributePart, BooleanAttributePart, ChildPart, ElementPart, EventPart, Part, PropertyPart, } from './lit-html';
8
8
  export interface DirectiveClass {
9
9
  new (part: PartInfo): Directive;
10
10
  }
@@ -18,10 +18,6 @@ export declare type DirectiveParameters<C extends Directive> = Parameters<C['ren
18
18
  * returns a DirectiveResult object that captures the arguments.
19
19
  */
20
20
  export interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {
21
- /** @internal */
22
- _$litDirective$: C;
23
- /** @internal */
24
- values: DirectiveParameters<InstanceType<C>>;
25
21
  }
26
22
  export declare const PartType: {
27
23
  readonly ATTRIBUTE: 1;
@@ -61,18 +57,9 @@ export declare const directive: <C extends DirectiveClass>(c: C) => (...values:
61
57
  * implement `render` and/or `update`, and then pass their subclass to
62
58
  * `directive`.
63
59
  */
64
- export declare abstract class Directive {
65
- __part: Part;
66
- __attributeIndex: number | undefined;
67
- __directive?: Directive;
68
- _$parent: Disconnectable;
69
- _$disconnetableChildren?: Set<Disconnectable>;
70
- _$setDirectiveConnected?(isConnected: boolean): void;
60
+ export declare abstract class Directive implements Disconnectable {
71
61
  constructor(_partInfo: PartInfo);
72
- /** @internal */
73
- _$initialize(part: Part, parent: Disconnectable, attributeIndex: number | undefined): void;
74
- /** @internal */
75
- _$resolve(part: Part, props: Array<unknown>): unknown;
62
+ get _$isConnected(): boolean;
76
63
  abstract render(...props: Array<unknown>): unknown;
77
64
  update(_part: Part, props: Array<unknown>): unknown;
78
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../src/directive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,cAAc,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AAEhD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,SAAS,EACT,IAAI,GACL,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,KAAK,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;CACjC;AAED;;;GAGG;AACH,oBAAY,mBAAmB,CAAC,CAA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,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EACT,OAAO,QAAQ,CAAC,SAAS,GACzB,OAAO,QAAQ,CAAC,QAAQ,GACxB,OAAO,QAAQ,CAAC,iBAAiB,GACjC,OAAO,QAAQ,CAAC,KAAK,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,QAAQ,CAAC,OAAO,CAAC;CACxC;AAED;;;;;GAKG;AACH,oBAAY,QAAQ,GAAG,aAAa,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,SAAS,8GAMlB,CAAC;AAEL;;;;GAIG;AACH,8BAAsB,SAAU,YAAW,cAAc;gBAkB3C,SAAS,EAAE,QAAQ;IAG/B,IAAI,aAAa,YAEhB;IAiBD,QAAQ,CAAC,MAAM,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO;IAElD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO;CAGpD"}
@@ -16,7 +16,8 @@ export const PartType = {
16
16
  * function has the same parameters as the directive's render() method.
17
17
  */
18
18
  export const directive = (c) => (...values) => ({
19
- _$litDirective$: c,
19
+ // This property needs to remain unminified.
20
+ ['_$litDirective$']: c,
20
21
  values,
21
22
  });
22
23
  /**
@@ -26,6 +27,10 @@ export const directive = (c) => (...values) => ({
26
27
  */
27
28
  export class Directive {
28
29
  constructor(_partInfo) { }
30
+ // See comment in Disconnectable interface for why this is a getter
31
+ get _$isConnected() {
32
+ return this._$parent._$isConnected;
33
+ }
29
34
  /** @internal */
30
35
  _$initialize(part, parent, attributeIndex) {
31
36
  this.__part = part;
@@ -1 +1 @@
1
- {"version":3,"file":"directive.js","sourceRoot":"","sources":["../src/directive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkCH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,iBAAiB,EAAE,CAAC;IACpB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;CACF,CAAC;AA+BX;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAA2B,CAAI,EAAE,EAAE,CAAC,CAC3D,GAAG,MAA4C,EAC3B,EAAE,CAAC,CAAC;IACxB,eAAe,EAAE,CAAC;IAClB,MAAM;CACP,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,OAAgB,SAAS;IAiB7B,YAAY,SAAmB,IAAG,CAAC;IAEnC,gBAAgB;IAChB,YAAY,CACV,IAAU,EACV,MAAsB,EACtB,cAAkC;QAElC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,cAAc,CAAC;IACzC,CAAC;IACD,gBAAgB;IAChB,SAAS,CAAC,IAAU,EAAE,KAAqB;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAID,MAAM,CAAC,KAAW,EAAE,KAAqB;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Disconnectable, Part} from './lit-html';\n\nexport {\n AttributePart,\n BooleanAttributePart,\n ChildPart,\n ElementPart,\n EventPart,\n Part,\n} from './lit-html';\n\nexport interface DirectiveClass {\n new (part: PartInfo): Directive;\n}\n\n/**\n * This utility type extracts the signature of a directive class's render()\n * method so we can use it for the type of the generated directive function.\n */\nexport type DirectiveParameters<C extends Directive> = Parameters<C['render']>;\n\n/**\n * A generated directive function doesn't evaluate the directive, but just\n * returns a DirectiveResult object that captures the arguments.\n */\nexport interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {\n /** @internal */\n _$litDirective$: C;\n /** @internal */\n values: DirectiveParameters<InstanceType<C>>;\n}\n\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n} as const;\n\nexport type PartType = typeof PartType[keyof typeof PartType];\n\nexport interface ChildPartInfo {\n readonly type: typeof PartType.CHILD;\n}\n\nexport interface AttributePartInfo {\n readonly type:\n | typeof PartType.ATTRIBUTE\n | typeof PartType.PROPERTY\n | typeof PartType.BOOLEAN_ATTRIBUTE\n | typeof PartType.EVENT;\n readonly strings?: ReadonlyArray<string>;\n readonly name: string;\n readonly tagName: string;\n}\n\nexport interface ElementPartInfo {\n readonly type: typeof PartType.ELEMENT;\n}\n\n/**\n * Information about the part a directive is bound to.\n *\n * This is useful for checking that a directive is attached to a valid part,\n * such as with directive that can only be used on attribute bindings.\n */\nexport type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;\n\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive = <C extends DirectiveClass>(c: C) => (\n ...values: DirectiveParameters<InstanceType<C>>\n): DirectiveResult<C> => ({\n _$litDirective$: c,\n values,\n});\n\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport abstract class Directive {\n //@internal\n __part!: Part;\n //@internal\n __attributeIndex: number | undefined;\n //@internal\n __directive?: Directive;\n\n //@internal\n _$parent!: Disconnectable;\n\n // These will only exist on the AsyncDirective subclass\n //@internal\n _$disconnetableChildren?: Set<Disconnectable>;\n //@internal\n _$setDirectiveConnected?(isConnected: boolean): void;\n\n constructor(_partInfo: PartInfo) {}\n\n /** @internal */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n return this.update(part, props);\n }\n\n abstract render(...props: Array<unknown>): unknown;\n\n update(_part: Part, props: Array<unknown>): unknown {\n return this.render(...props);\n }\n}\n"]}
1
+ {"version":3,"file":"directive.js","sourceRoot":"","sources":["../src/directive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqCH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,iBAAiB,EAAE,CAAC;IACpB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;CACF,CAAC;AA+BX;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GACpB,CAA2B,CAAI,EAAE,EAAE,CACnC,CAAC,GAAG,MAA4C,EAAsB,EAAE,CAAC,CAAC;IACxE,4CAA4C;IAC5C,CAAC,iBAAiB,CAAC,EAAE,CAAC;IACtB,MAAM;CACP,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,OAAgB,SAAS;IAkB7B,YAAY,SAAmB,IAAG,CAAC;IAEnC,mEAAmE;IACnE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;IACrC,CAAC;IAED,gBAAgB;IAChB,YAAY,CACV,IAAU,EACV,MAAsB,EACtB,cAAkC;QAElC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,cAAc,CAAC;IACzC,CAAC;IACD,gBAAgB;IAChB,SAAS,CAAC,IAAU,EAAE,KAAqB;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAID,MAAM,CAAC,KAAW,EAAE,KAAqB;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Disconnectable, Part} from './lit-html';\n\nexport {\n AttributePart,\n BooleanAttributePart,\n ChildPart,\n ElementPart,\n EventPart,\n Part,\n PropertyPart,\n} from './lit-html';\n\nexport interface DirectiveClass {\n new (part: PartInfo): Directive;\n}\n\n/**\n * This utility type extracts the signature of a directive class's render()\n * method so we can use it for the type of the generated directive function.\n */\nexport type DirectiveParameters<C extends Directive> = Parameters<C['render']>;\n\n/**\n * A generated directive function doesn't evaluate the directive, but just\n * returns a DirectiveResult object that captures the arguments.\n */\nexport interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {\n /**\n * This property needs to remain unminified.\n * @internal */\n ['_$litDirective$']: C;\n /** @internal */\n values: DirectiveParameters<InstanceType<C>>;\n}\n\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n} as const;\n\nexport type PartType = typeof PartType[keyof typeof PartType];\n\nexport interface ChildPartInfo {\n readonly type: typeof PartType.CHILD;\n}\n\nexport interface AttributePartInfo {\n readonly type:\n | typeof PartType.ATTRIBUTE\n | typeof PartType.PROPERTY\n | typeof PartType.BOOLEAN_ATTRIBUTE\n | typeof PartType.EVENT;\n readonly strings?: ReadonlyArray<string>;\n readonly name: string;\n readonly tagName: string;\n}\n\nexport interface ElementPartInfo {\n readonly type: typeof PartType.ELEMENT;\n}\n\n/**\n * Information about the part a directive is bound to.\n *\n * This is useful for checking that a directive is attached to a valid part,\n * such as with directive that can only be used on attribute bindings.\n */\nexport type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;\n\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive =\n <C extends DirectiveClass>(c: C) =>\n (...values: DirectiveParameters<InstanceType<C>>): DirectiveResult<C> => ({\n // This property needs to remain unminified.\n ['_$litDirective$']: c,\n values,\n });\n\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport abstract class Directive implements Disconnectable {\n //@internal\n __part!: Part;\n //@internal\n __attributeIndex: number | undefined;\n //@internal\n __directive?: Directive;\n\n //@internal\n _$parent!: Disconnectable;\n\n // These will only exist on the AsyncDirective subclass\n //@internal\n _$disconnectableChildren?: Set<Disconnectable>;\n // This property needs to remain unminified.\n //@internal\n ['_$notifyDirectiveConnectionChanged']?(isConnected: boolean): void;\n\n constructor(_partInfo: PartInfo) {}\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n /** @internal */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n return this.update(part, props);\n }\n\n abstract render(...props: Array<unknown>): unknown;\n\n update(_part: Part, props: Array<unknown>): unknown {\n return this.render(...props);\n }\n}\n"]}
@@ -3,21 +3,14 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { AsyncDirective } from '../async-directive.js';
6
+ import { ChildPart } from '../lit-html.js';
7
7
  import { DirectiveParameters, PartInfo } from '../directive.js';
8
- import { ChildPart, noChange } from '../lit-html.js';
9
-
10
- declare type Mapper<T> = (v: T, index?: number) => unknown;
11
- declare class AsyncAppendDirective extends AsyncDirective {
12
- private _value?;
13
- private _reconnectResolver?;
14
- private _reconnectPromise?;
8
+ import { AsyncReplaceDirective } from './async-replace.js';
9
+ declare class AsyncAppendDirective extends AsyncReplaceDirective {
10
+ private __childPart;
15
11
  constructor(partInfo: PartInfo);
16
- render<T>(value: AsyncIterable<T>, _mapper?: Mapper<T>): symbol;
17
- update(part: ChildPart, [value, mapper]: DirectiveParameters<this>): typeof noChange | undefined;
18
- private __iterate;
19
- disconnected(): void;
20
- reconnected(): void;
12
+ update(part: ChildPart, params: DirectiveParameters<this>): typeof import("../lit-html.js").noChange | undefined;
13
+ protected commitValue(value: unknown, index: number): void;
21
14
  }
22
15
  /**
23
16
  * A directive that renders the items of an async iterable[1], appending new
@@ -37,7 +30,7 @@ declare class AsyncAppendDirective extends AsyncDirective {
37
30
  * @param mapper An optional function that maps from (value, index) to another
38
31
  * value. Useful for generating templates for each item in the iterable.
39
32
  */
40
- export declare const asyncAppend: (value: AsyncIterable<unknown>, _mapper?: Mapper<unknown> | undefined) => import("../directive.js").DirectiveResult<typeof AsyncAppendDirective>;
33
+ export declare const asyncAppend: (value: AsyncIterable<unknown>, _mapper?: ((v: unknown, index?: number | undefined) => unknown) | undefined) => import("../directive.js").DirectiveResult<typeof AsyncAppendDirective>;
41
34
  /**
42
35
  * The type of the class that powers this directive. Necessary for naming the
43
36
  * directive's return type.
@@ -1 +1 @@
1
- {"version":3,"file":"async-append.d.ts","sourceRoot":"","sources":["../../src/directives/async-append.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAEL,mBAAmB,EACnB,QAAQ,EAET,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAOrD,aAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,C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"}
@@ -3,73 +3,32 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { AsyncDirective } from '../async-directive.js';
7
- import { clearPart, insertPart, setChildPartValue, } from '../directive-helpers.js';
8
6
  import { directive, PartType, } from '../directive.js';
9
- import { noChange } from '../lit-html.js';
10
-
11
- class AsyncAppendDirective extends AsyncDirective {
7
+ import { AsyncReplaceDirective } from './async-replace.js';
8
+ import { clearPart, insertPart, setChildPartValue, } from '../directive-helpers.js';
9
+ class AsyncAppendDirective extends AsyncReplaceDirective {
10
+ // Override AsyncReplace to narrow the allowed part type to ChildPart only
12
11
  constructor(partInfo) {
13
12
  super(partInfo);
14
13
  if (partInfo.type !== PartType.CHILD) {
15
14
  throw new Error('asyncAppend can only be used in child expressions');
16
15
  }
17
16
  }
18
- // @ts-expect-error value not used, but we want a nice parameter for docs
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- render(value, _mapper) {
21
- return noChange;
22
- }
23
- update(part, [value, mapper]) {
24
- // If we've already set up this particular iterable, we don't need
25
- // to do anything.
26
- if (value === this._value) {
27
- return;
28
- }
29
- this._value = value;
30
- this.__iterate(part, mapper);
31
- return noChange;
17
+ // Override AsyncReplace to save the part since we need to append into it
18
+ update(part, params) {
19
+ this.__childPart = part;
20
+ return super.update(part, params);
32
21
  }
33
- // Separate function to avoid an iffe in update; update can't be async
34
- // because its return value must be `noChange`
35
- async __iterate(part, mapper) {
36
- let i = 0;
37
- const { _value: value } = this;
38
- for await (let v of value) {
39
- // Check to make sure that value is the still the current value of
40
- // the part, and if not bail because a new value owns this part
41
- if (this._value !== value) {
42
- break;
43
- }
44
- // If we were disconnected, pause until reconnected
45
- if (this._reconnectPromise) {
46
- await this._reconnectPromise;
47
- }
48
- // When we get the first value, clear the part. This lets the
49
- // previous value display until we can replace it.
50
- if (i === 0) {
51
- clearPart(part);
52
- }
53
- // As a convenience, because functional-programming-style
54
- // transforms of iterables and async iterables requires a library,
55
- // we accept a mapper function. This is especially convenient for
56
- // rendering a template for each item.
57
- if (mapper !== undefined) {
58
- v = mapper(v, i);
59
- }
60
- const newPart = insertPart(part);
61
- setChildPartValue(newPart, v);
62
- i++;
22
+ // Override AsyncReplace to append rather than replace
23
+ commitValue(value, index) {
24
+ // When we get the first value, clear the part. This lets the
25
+ // previous value display until we can replace it.
26
+ if (index === 0) {
27
+ clearPart(this.__childPart);
63
28
  }
64
- }
65
- disconnected() {
66
- // Pause iteration while disconnected
67
- this._reconnectPromise = new Promise((resolve) => (this._reconnectResolver = resolve));
68
- }
69
- reconnected() {
70
- // Resume iteration when reconnected
71
- this._reconnectPromise = undefined;
72
- this._reconnectResolver();
29
+ // Create and insert a new part and set its value to the next value
30
+ const newPart = insertPart(this.__childPart);
31
+ setChildPartValue(newPart, value);
73
32
  }
74
33
  }
75
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"async-append.js","sourceRoot":"","sources":["../../src/directives/async-append.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAY,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,SAAS,EAGT,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACL,SAAS,EACT,UAAU,EACV,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,oBAAqB,SAAQ,cAAc;IAK/C,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACtE;IACH,CAAC;IAED,yEAAyE;IACzE,6DAA6D;IAC7D,MAAM,CAAI,KAAuB,EAAE,OAAmB;QACpD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,IAAe,EAAE,C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GAAG,OAAO,CAAC,CACjD,CAAC;IACJ,CAAC;IAED,WAAW;QACT,oCAAoC;QACpC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,kBAAmB,EAAE,CAAC;IAC7B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart, noChange} from '../lit-html.js';\nimport {\n directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {AsyncDirective} from '../async-directive.js';\nimport {\n clearPart,\n insertPart,\n setChildPartValue,\n} from '../directive-helpers.js';\n\ntype Mapper<T> = (v: T, index?: number) => unknown;\n\nclass AsyncAppendDirective extends AsyncDirective {\n private _value?: AsyncIterable<unknown>;\n private _reconnectResolver?: () => void;\n private _reconnectPromise?: Promise<void>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('asyncAppend can only be used in child expressions');\n }\n }\n\n // @ts-expect-error value not used, but we want a nice parameter for docs\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n render<T>(value: AsyncIterable<T>, _mapper?: Mapper<T>) {\n return noChange;\n }\n\n update(part: ChildPart, [value, mapper]: DirectiveParameters<this>) {\n // If we've already set up this particular iterable, we don't need\n // to do anything.\n if (value === this._value) {\n return;\n }\n this._value = value;\n this.__iterate(part, mapper);\n return noChange;\n }\n\n // Separate function to avoid an iffe in update; update can't be async\n // because its return value must be `noChange`\n private async __iterate(part: ChildPart, mapper?: Mapper<unknown>) {\n let i = 0;\n const {_value: value} = this;\n for await (let v of value!) {\n // Check to make sure that value is the still the current value of\n // the part, and if not bail because a new value owns this part\n if (this._value !== value) {\n break;\n }\n\n // If we were disconnected, pause until reconnected\n if (this._reconnectPromise) {\n await this._reconnectPromise;\n }\n\n // When we get the first value, clear the part. This lets the\n // previous value display until we can replace it.\n if (i === 0) {\n clearPart(part);\n }\n // As a convenience, because functional-programming-style\n // transforms of iterables and async iterables requires a library,\n // we accept a mapper function. This is especially convenient for\n // rendering a template for each item.\n if (mapper !== undefined) {\n v = mapper(v, i);\n }\n const newPart = insertPart(part);\n setChildPartValue(newPart, v);\n i++;\n }\n }\n\n disconnected() {\n // Pause iteration while disconnected\n this._reconnectPromise = new Promise(\n (resolve) => (this._reconnectResolver = resolve)\n );\n }\n\n reconnected() {\n // Resume iteration when reconnected\n this._reconnectPromise = undefined;\n this._reconnectResolver!();\n }\n}\n\n/**\n * A directive that renders the items of an async iterable[1], appending new\n * values after previous values, similar to the built-in support for iterables.\n * This directive is usable only in child expressions.\n *\n * Async iterables are objects with a [Symbol.asyncIterator] method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is appended to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncAppend = directive(AsyncAppendDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {AsyncAppendDirective};\n"]}
1
+ {"version":3,"file":"async-append.js","sourceRoot":"","sources":["../../src/directives/async-append.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,SAAS,EAGT,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,SAAS,EACT,UAAU,EACV,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,oBAAqB,SAAQ,qBAAqB;IAGtD,0EAA0E;IAC1E,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACtE;IACH,CAAC;IAED,yEAAyE;IAChE,MAAM,CAAC,IAAe,EAAE,MAAiC;QAChE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,sDAAsD;IACnC,WAAW,CAAC,KAAc,EAAE,KAAa;QAC1D,6DAA6D;QAC7D,kDAAkD;QAClD,IAAI,KAAK,KAAK,CAAC,EAAE;YACf,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC7B;QACD,mEAAmE;QACnE,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC7C,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart} from '../lit-html.js';\nimport {\n directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {AsyncReplaceDirective} from './async-replace.js';\nimport {\n clearPart,\n insertPart,\n setChildPartValue,\n} from '../directive-helpers.js';\n\nclass AsyncAppendDirective extends AsyncReplaceDirective {\n private __childPart!: ChildPart;\n\n // Override AsyncReplace to narrow the allowed part type to ChildPart only\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('asyncAppend can only be used in child expressions');\n }\n }\n\n // Override AsyncReplace to save the part since we need to append into it\n override update(part: ChildPart, params: DirectiveParameters<this>) {\n this.__childPart = part;\n return super.update(part, params);\n }\n\n // Override AsyncReplace to append rather than replace\n protected override commitValue(value: unknown, index: number) {\n // When we get the first value, clear the part. This lets the\n // previous value display until we can replace it.\n if (index === 0) {\n clearPart(this.__childPart);\n }\n // Create and insert a new part and set its value to the next value\n const newPart = insertPart(this.__childPart);\n setChildPartValue(newPart, value);\n }\n}\n\n/**\n * A directive that renders the items of an async iterable[1], appending new\n * values after previous values, similar to the built-in support for iterables.\n * This directive is usable only in child expressions.\n *\n * Async iterables are objects with a [Symbol.asyncIterator] method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is appended to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncAppend = directive(AsyncAppendDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {AsyncAppendDirective};\n"]}
@@ -3,18 +3,17 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { AsyncDirective } from '../async-directive.js';
7
- import { DirectiveParameters } from '../directive.js';
8
6
  import { ChildPart, noChange } from '../lit-html.js';
9
-
7
+ import { DirectiveParameters } from '../directive.js';
8
+ import { AsyncDirective } from '../async-directive.js';
10
9
  declare type Mapper<T> = (v: T, index?: number) => unknown;
11
- declare class AsyncReplaceDirective extends AsyncDirective {
12
- private _value?;
13
- private _reconnectResolver?;
14
- private _reconnectPromise?;
10
+ export declare class AsyncReplaceDirective extends AsyncDirective {
11
+ private __value?;
12
+ private __weakThis;
13
+ private __pauser;
15
14
  render<T>(value: AsyncIterable<T>, _mapper?: Mapper<T>): symbol;
16
15
  update(_part: ChildPart, [value, mapper]: DirectiveParameters<this>): typeof noChange | undefined;
17
- private __iterate;
16
+ protected commitValue(value: unknown, _index: number): void;
18
17
  disconnected(): void;
19
18
  reconnected(): void;
20
19
  }
@@ -23,7 +22,7 @@ declare class AsyncReplaceDirective extends AsyncDirective {
23
22
  * previous values with new values, so that only one value is ever rendered
24
23
  * at a time. This directive may be used in any expression type.
25
24
  *
26
- * Async iterables are objects with a [Symbol.asyncIterator] method, which
25
+ * Async iterables are objects with a `[Symbol.asyncIterator]` method, which
27
26
  * returns an iterator who's `next()` method returns a Promise. When a new
28
27
  * value is available, the Promise resolves and the value is rendered to the
29
28
  * Part controlled by the directive. If another value other than this
@@ -37,9 +36,5 @@ declare class AsyncReplaceDirective extends AsyncDirective {
37
36
  * value. Useful for generating templates for each item in the iterable.
38
37
  */
39
38
  export declare const asyncReplace: (value: AsyncIterable<unknown>, _mapper?: Mapper<unknown> | undefined) => import("../directive.js").DirectiveResult<typeof AsyncReplaceDirective>;
40
- /**
41
- * The type of the class that powers this directive. Necessary for naming the
42
- * directive's return type.
43
- */
44
- export type { AsyncReplaceDirective };
39
+ export {};
45
40
  //# sourceMappingURL=async-replace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-replace.d.ts","sourceRoot":"","sources":["../../src/directives/async-replace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAY,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAErD,aAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;AAEnD,cAAM,qBAAsB,SAAQ,cAAc;IAChD,OAAO,CAAC,MAAM,CAAC,CAAyB;IACxC,OAAO,CAAC,kBAAkB,CAA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AAE,MAAM;IAI3C,YAAY;IAKZ,WAAW;CAIrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,mJAAmC,CAAC"}
@@ -3,60 +3,80 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { AsyncDirective } from '../async-directive.js';
7
- import { directive } from '../directive.js';
8
6
  import { noChange } from '../lit-html.js';
9
-
10
- class AsyncReplaceDirective extends AsyncDirective {
7
+ import { directive } from '../directive.js';
8
+ import { AsyncDirective } from '../async-directive.js';
9
+ import { Pauser, PseudoWeakRef, forAwaitOf } from './private-async-helpers.js';
10
+ export class AsyncReplaceDirective extends AsyncDirective {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.__weakThis = new PseudoWeakRef(this);
14
+ this.__pauser = new Pauser();
15
+ }
11
16
  // @ts-expect-error value not used, but we want a nice parameter for docs
12
17
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
18
  render(value, _mapper) {
14
19
  return noChange;
15
20
  }
16
21
  update(_part, [value, mapper]) {
22
+ // If our initial render occurs while disconnected, ensure that the pauser
23
+ // and weakThis are in the disconnected state
24
+ if (!this.isConnected) {
25
+ this.disconnected();
26
+ }
17
27
  // If we've already set up this particular iterable, we don't need
18
28
  // to do anything.
19
- if (value === this._value) {
29
+ if (value === this.__value) {
20
30
  return;
21
31
  }
22
- this._value = value;
23
- this.__iterate(mapper);
24
- return noChange;
25
- }
26
- // Separate function to avoid an iffe in update; update can't be async
27
- // because its return value must be `noChange`
28
- async __iterate(mapper) {
32
+ this.__value = value;
29
33
  let i = 0;
30
- const { _value: value } = this;
31
- for await (let v of value) {
32
- // Check to make sure that value is the still the current value of
33
- // the part, and if not bail because a new value owns this part
34
- if (this._value !== value) {
35
- break;
36
- }
37
- // If we were disconnected, pause until reconnected
38
- if (this._reconnectPromise) {
39
- await this._reconnectPromise;
34
+ const { __weakThis: weakThis, __pauser: pauser } = this;
35
+ // Note, the callback avoids closing over `this` so that the directive
36
+ // can be gc'ed before the promise resolves; instead `this` is retrieved
37
+ // from `weakThis`, which can break the hard reference in the closure when
38
+ // the directive disconnects
39
+ forAwaitOf(value, async (v) => {
40
+ // The while loop here handles the case that the connection state
41
+ // thrashes, causing the pauser to resume and then get re-paused
42
+ while (pauser.get()) {
43
+ await pauser.get();
40
44
  }
41
- // As a convenience, because functional-programming-style
42
- // transforms of iterables and async iterables requires a library,
43
- // we accept a mapper function. This is especially convenient for
44
- // rendering a template for each item.
45
- if (mapper !== undefined) {
46
- v = mapper(v, i);
45
+ // If the callback gets here and there is no `this`, it means that the
46
+ // directive has been disconnected and garbage collected and we don't
47
+ // need to do anything else
48
+ const _this = weakThis.deref();
49
+ if (_this !== undefined) {
50
+ // Check to make sure that value is the still the current value of
51
+ // the part, and if not bail because a new value owns this part
52
+ if (_this.__value !== value) {
53
+ return false;
54
+ }
55
+ // As a convenience, because functional-programming-style
56
+ // transforms of iterables and async iterables requires a library,
57
+ // we accept a mapper function. This is especially convenient for
58
+ // rendering a template for each item.
59
+ if (mapper !== undefined) {
60
+ v = mapper(v, i);
61
+ }
62
+ _this.commitValue(v, i);
63
+ i++;
47
64
  }
48
- this.setValue(v);
49
- i++;
50
- }
65
+ return true;
66
+ });
67
+ return noChange;
68
+ }
69
+ // Override point for AsyncAppend to append rather than replace
70
+ commitValue(value, _index) {
71
+ this.setValue(value);
51
72
  }
52
73
  disconnected() {
53
- // Pause iteration while disconnected
54
- this._reconnectPromise = new Promise((resolve) => (this._reconnectResolver = resolve));
74
+ this.__weakThis.disconnect();
75
+ this.__pauser.pause();
55
76
  }
56
77
  reconnected() {
57
- // Resume iteration when reconnected
58
- this._reconnectPromise = undefined;
59
- this._reconnectResolver();
78
+ this.__weakThis.reconnect(this);
79
+ this.__pauser.resume();
60
80
  }
61
81
  }
62
82
  /**
@@ -64,7 +84,7 @@ class AsyncReplaceDirective extends AsyncDirective {
64
84
  * previous values with new values, so that only one value is ever rendered
65
85
  * at a time. This directive may be used in any expression type.
66
86
  *
67
- * Async iterables are objects with a [Symbol.asyncIterator] method, which
87
+ * Async iterables are objects with a `[Symbol.asyncIterator]` method, which
68
88
  * returns an iterator who's `next()` method returns a Promise. When a new
69
89
  * value is available, the Promise resolves and the value is rendered to the
70
90
  * Part controlled by the directive. If another value other than this
@@ -1 +1 @@
1
- {"version":3,"file":"async-replace.js","sourceRoot":"","sources":["../../src/directives/async-replace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAY,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAC,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAIrD,MAAM,qBAAsB,SAAQ,cAAc;IAKhD,yEAAyE;IACzE,6DAA6D;IAC7D,MAAM,CAAI,KAAuB,EAAE,OAAmB;QACpD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,KAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAA4B;QACjE,kEAAkE;QAClE,kBAAkB;QAClB,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE;YACzB,OAAO;SACR;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,sEAAsE;IACtE,8CAA8C;IACtC,KAAK,CAAC,SAAS,CAAC,MAAwB;QAC9C,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,MAAM,EAAC,MAAM,EAAE,KAAK,EAAC,GAAG,IAAI,CAAC;QAC7B,IAAI,KAAK,EAAE,IAAI,CAAC,IAAI,KAAM,EAAE;YAC1B,kEAAkE;YAClE,+DAA+D;YAC/D,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE;gBACzB,MAAM;aACP;YAED,mDAAmD;YACnD,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC1B,MAAM,IAAI,CAAC,iBAAiB,CAAC;aAC9B;YAED,yDAAyD;YACzD,kEAAkE;YAClE,iEAAiE;YACjE,sCAAsC;YACtC,IAAI,MAAM,KAAK,SAAS,EAAE;gBACxB,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAClB;YAED,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,EAAE,CAAC;SACL;IACH,CAAC;IAED,YAAY;QACV,qCAAqC;QACrC,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAClC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,CACjD,CAAC;IACJ,CAAC;IAED,WAAW;QACT,oCAAoC;QACpC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,kBAAmB,EAAE,CAAC;IAC7B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart, noChange} from '../lit-html.js';\nimport {directive, DirectiveParameters} from '../directive.js';\nimport {AsyncDirective} from '../async-directive.js';\n\ntype Mapper<T> = (v: T, index?: number) => unknown;\n\nclass AsyncReplaceDirective extends AsyncDirective {\n private _value?: AsyncIterable<unknown>;\n private _reconnectResolver?: () => void;\n private _reconnectPromise?: Promise<void>;\n\n // @ts-expect-error value not used, but we want a nice parameter for docs\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n render<T>(value: AsyncIterable<T>, _mapper?: Mapper<T>) {\n return noChange;\n }\n\n update(_part: ChildPart, [value, mapper]: DirectiveParameters<this>) {\n // If we've already set up this particular iterable, we don't need\n // to do anything.\n if (value === this._value) {\n return;\n }\n this._value = value;\n this.__iterate(mapper);\n return noChange;\n }\n\n // Separate function to avoid an iffe in update; update can't be async\n // because its return value must be `noChange`\n private async __iterate(mapper?: Mapper<unknown>) {\n let i = 0;\n const {_value: value} = this;\n for await (let v of value!) {\n // Check to make sure that value is the still the current value of\n // the part, and if not bail because a new value owns this part\n if (this._value !== value) {\n break;\n }\n\n // If we were disconnected, pause until reconnected\n if (this._reconnectPromise) {\n await this._reconnectPromise;\n }\n\n // As a convenience, because functional-programming-style\n // transforms of iterables and async iterables requires a library,\n // we accept a mapper function. This is especially convenient for\n // rendering a template for each item.\n if (mapper !== undefined) {\n v = mapper(v, i);\n }\n\n this.setValue(v);\n i++;\n }\n }\n\n disconnected() {\n // Pause iteration while disconnected\n this._reconnectPromise = new Promise(\n (resolve) => (this._reconnectResolver = resolve)\n );\n }\n\n reconnected() {\n // Resume iteration when reconnected\n this._reconnectPromise = undefined;\n this._reconnectResolver!();\n }\n}\n\n/**\n * A directive that renders the items of an async iterable[1], replacing\n * previous values with new values, so that only one value is ever rendered\n * at a time. This directive may be used in any expression type.\n *\n * Async iterables are objects with a [Symbol.asyncIterator] method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is rendered to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncReplace = directive(AsyncReplaceDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {AsyncReplaceDirective};\n"]}
1
+ {"version":3,"file":"async-replace.js","sourceRoot":"","sources":["../../src/directives/async-replace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAY,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnD,OA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KAAK,SAAS,EAAE;gBACvB,kEAAkE;gBAClE,+DAA+D;gBAC/D,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,EAAE;oBAC3B,OAAO,KAAK,CAAC;iBACd;gBAED,yDAAyD;gBACzD,kEAAkE;gBAClE,iEAAiE;gBACjE,sCAAsC;gBACtC,IAAI,MAAM,KAAK,SAAS,EAAE;oBACxB,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBAClB;gBAED,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACxB,CAAC,EAAE,CAAC;aACL;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,+DAA+D;IACrD,WAAW,CAAC,KAAc,EAAE,MAAc;QAClD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAEQ,YAAY;QACnB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEQ,WAAW;QAClB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart, noChange} from '../lit-html.js';\nimport {directive, DirectiveParameters} from '../directive.js';\nimport {AsyncDirective} from '../async-directive.js';\nimport {Pauser, PseudoWeakRef, forAwaitOf} from './private-async-helpers.js';\n\ntype Mapper<T> = (v: T, index?: number) => unknown;\n\nexport class AsyncReplaceDirective extends AsyncDirective {\n private __value?: AsyncIterable<unknown>;\n private __weakThis = new PseudoWeakRef(this);\n private __pauser = new Pauser();\n\n // @ts-expect-error value not used, but we want a nice parameter for docs\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n render<T>(value: AsyncIterable<T>, _mapper?: Mapper<T>) {\n return noChange;\n }\n\n override update(\n _part: ChildPart,\n [value, mapper]: DirectiveParameters<this>\n ) {\n // If our initial render occurs while disconnected, ensure that the pauser\n // and weakThis are in the disconnected state\n if (!this.isConnected) {\n this.disconnected();\n }\n // If we've already set up this particular iterable, we don't need\n // to do anything.\n if (value === this.__value) {\n return;\n }\n this.__value = value;\n let i = 0;\n const {__weakThis: weakThis, __pauser: pauser} = this;\n // Note, the callback avoids closing over `this` so that the directive\n // can be gc'ed before the promise resolves; instead `this` is retrieved\n // from `weakThis`, which can break the hard reference in the closure when\n // the directive disconnects\n forAwaitOf(value, async (v: unknown) => {\n // The while loop here handles the case that the connection state\n // thrashes, causing the pauser to resume and then get re-paused\n while (pauser.get()) {\n await pauser.get();\n }\n // If the callback gets here and there is no `this`, it means that the\n // directive has been disconnected and garbage collected and we don't\n // need to do anything else\n const _this = weakThis.deref();\n if (_this !== undefined) {\n // Check to make sure that value is the still the current value of\n // the part, and if not bail because a new value owns this part\n if (_this.__value !== value) {\n return false;\n }\n\n // As a convenience, because functional-programming-style\n // transforms of iterables and async iterables requires a library,\n // we accept a mapper function. This is especially convenient for\n // rendering a template for each item.\n if (mapper !== undefined) {\n v = mapper(v, i);\n }\n\n _this.commitValue(v, i);\n i++;\n }\n return true;\n });\n return noChange;\n }\n\n // Override point for AsyncAppend to append rather than replace\n protected commitValue(value: unknown, _index: number) {\n this.setValue(value);\n }\n\n override disconnected() {\n this.__weakThis.disconnect();\n this.__pauser.pause();\n }\n\n override reconnected() {\n this.__weakThis.reconnect(this);\n this.__pauser.resume();\n }\n}\n\n/**\n * A directive that renders the items of an async iterable[1], replacing\n * previous values with new values, so that only one value is ever rendered\n * at a time. This directive may be used in any expression type.\n *\n * Async iterables are objects with a `[Symbol.asyncIterator]` method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is rendered to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncReplace = directive(AsyncReplaceDirective);\n"]}
@@ -3,9 +3,8 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
7
6
  import { ChildPart } from '../lit-html.js';
8
-
7
+ import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
9
8
  declare class CacheDirective extends Directive {
10
9
  private _templateCache;
11
10
  private _value?;
@@ -19,7 +18,7 @@ declare class CacheDirective extends Directive {
19
18
  *
20
19
  * Example:
21
20
  *
22
- * ```
21
+ * ```js
23
22
  * let checked = false;
24
23
  *
25
24
  * html`
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/directives/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAiB,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACT,MAAM,iBAAiB,CAAC;AASzB,cAAM,cAAe,SAAQ,SAAS;IACpC,OAAO,CAAC,cAAc,CAAkD;IACxE,OAAO,CAAC,MAAM,CAAC,CAAiB;gBAEpB,QAAQ,EAAE,QAAQ;IAI9B,MAAM,CAAC,CAAC,EAAE,OAAO;IAMjB,MAAM,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CA+ChE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,kFAA4B,CAAC;AAE/C;;;GAGG;AACH,YAAY,EAAC,cAAc,EAAC,CAAC"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/directives/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,SAAS,EAIV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACT,MAAM,iBAAiB,CAAC;AASzB,cAAM,cAAe,SAAQ,SAAS;IACpC,OAAO,CAAC,cAAc,CAAiD;IACvE,OAAO,CAAC,MAAM,CAAC,CAAiB;gBAEpB,QAAQ,EAAE,QAAQ;IAI9B,MAAM,CAAC,CAAC,EAAE,OAAO;IAMR,MAAM,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CA8CzE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,kFAA4B,CAAC;AAE/C;;;GAGG;AACH,YAAY,EAAC,cAAc,EAAC,CAAC"}
@@ -3,10 +3,9 @@
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { clearPart, getCommittedValue, insertPart, isTemplateResult, setCommittedValue, } from '../directive-helpers.js';
6
+ import { render, nothing, } from '../lit-html.js';
7
7
  import { directive, Directive, } from '../directive.js';
8
- import { nothing , render} from '../lit-html.js';
9
-
8
+ import { clearPart, getCommittedValue, insertPart, isTemplateResult, setCommittedValue, } from '../directive-helpers.js';
10
9
  class CacheDirective extends Directive {
11
10
  constructor(partInfo) {
12
11
  super(partInfo);
@@ -30,12 +29,12 @@ class CacheDirective extends Directive {
30
29
  if (cachedContainerPart === undefined) {
31
30
  const fragment = document.createDocumentFragment();
32
31
  cachedContainerPart = render(nothing, fragment);
32
+ cachedContainerPart.setConnected(false);
33
33
  this._templateCache.set(this._value.strings, cachedContainerPart);
34
34
  }
35
35
  // Move into cache
36
36
  setCommittedValue(cachedContainerPart, [childPart]);
37
37
  insertPart(cachedContainerPart, undefined, childPart);
38
- childPart.setConnected(false);
39
38
  }
40
39
  // If the new value is a TemplateResult and the previous value is not,
41
40
  // or is a different Template as the previous value, restore the child
@@ -51,7 +50,6 @@ class CacheDirective extends Directive {
51
50
  clearPart(containerPart);
52
51
  insertPart(containerPart, undefined, cachedPart);
53
52
  setCommittedValue(containerPart, [cachedPart]);
54
- cachedPart.setConnected(true);
55
53
  }
56
54
  }
57
55
  this._value = v;
@@ -68,7 +66,7 @@ class CacheDirective extends Directive {
68
66
  *
69
67
  * Example:
70
68
  *
71
- * ```
69
+ * ```js
72
70
  * let checked = false;
73
71
  *
74
72
  * html`
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/directives/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA4B,MAAM,EAAE,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EACL,SAAS,EACT,SAAS,GAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,cAAe,SAAQ,SAAS;IAIpC,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAJV,mBAAc,GAAG,IAAI,OAAO,EAAmC,CAAC;IAKxE,CAAC;IAED,MAAM,CAAC,CAAU;QACf,wEAAwE;QACxE,iDAAiD;QACjD,OAAO,CAAC,CAAC,CAAC,CAAC;IACb,CAAC;IAED,MAAM,CAAC,aAAwB,EAAE,CAAC,CAAC,CAA4B;QAC7D,sEAAsE;QACtE,wEAAwE;QACxE,kBAAkB;QAClB,IACE,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC;YAC7B,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,I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EAAG,CAAC;oBACpC,iCAAiC;oBACjC,SAAS,CAAC,aAAa,CAAC,CAAC;oBACzB,UAAU,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;oBACjD,iBAAiB,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;oBAC/C,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;iBAC/B;aACF;YACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjB;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;SACzB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {TemplateResult, ChildPart, render, nothing} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n} from '../directive.js';\nimport {\n clearPart,\n getCommittedValue,\n insertPart,\n isTemplateResult,\n setCommittedValue,\n} from '../directive-helpers.js';\n\nclass CacheDirective extends Directive {\n private _templateCache = new WeakMap<TemplateStringsArray, ChildPart>();\n private _value?: TemplateResult;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n }\n\n render(v: unknown) {\n // Return an array of the value to induce lit-html to create a ChildPart\n // for the value that we can move into the cache.\n return [v];\n }\n\n update(containerPart: ChildPart, [v]: DirectiveParameters<this>) {\n // If the previous value is a TemplateResult and the new value is not,\n // or is a different Template as the previous value, move the child part\n // into the cache.\n if (\n isTemplateResult(this._value) &&\n (!isTemplateResult(v) || this._value.strings !== v.strings)\n ) {\n // This is always an array because we return [v] in render()\n const partValue = getCommittedValue(containerPart) as Array<ChildPart>;\n const childPart = partValue.pop()!;\n let cachedContainerPart = this._templateCache.get(this._value.strings);\n if (cachedContainerPart === undefined) {\n const fragment = document.createDocumentFragment();\n cachedContainerPart = render(nothing, fragment);\n this._templateCache.set(this._value.strings, cachedContainerPart);\n }\n // Move into cache\n setCommittedValue(cachedContainerPart, [childPart]);\n insertPart(cachedContainerPart, undefined, childPart);\n childPart.setConnected(false);\n }\n // If the new value is a TemplateResult and the previous value is not,\n // or is a different Template as the previous value, restore the child\n // part from the cache.\n if (isTemplateResult(v)) {\n if (!isTemplateResult(this._value) || this._value.strings !== v.strings) {\n const cachedContainerPart = this._templateCache.get(v.strings);\n if (cachedContainerPart !== undefined) {\n // Move the cached part back into the container part value\n const partValue = getCommittedValue(\n cachedContainerPart\n ) as Array<ChildPart>;\n const cachedPart = partValue.pop()!;\n // Move cached part back into DOM\n clearPart(containerPart);\n insertPart(containerPart, undefined, cachedPart);\n setCommittedValue(containerPart, [cachedPart]);\n cachedPart.setConnected(true);\n }\n }\n this._value = v;\n } else {\n this._value = undefined;\n }\n return this.render(v);\n }\n}\n\n/**\n * Enables fast switching between multiple templates by caching the DOM nodes\n * and TemplateInstances produced by the templates.\n *\n * Example:\n *\n * ```\n * let checked = false;\n *\n * html`\n * ${cache(checked ? html`input is checked` : html`input is not checked`)}\n * `\n * ```\n */\nexport const cache = directive(CacheDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {CacheDirective};\n"]}
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/directives/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,MAAM,EACN,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EACT,SAAS,GAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,cAAe,SAAQ,SAAS;IAIpC,YAAY,QAAkB;QAC5B,KAAK,CAAC,Q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I,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,EAAE;gBACvE,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBAC/D,IAAI,mBAAmB,KAAK,SAAS,EAAE;oBACrC,0DAA0D;oBAC1D,MAAM,SAAS,GAAG,iBAAiB,CACjC,mBAAmB,CACA,CAAC;oBACtB,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,EAAG,CAAC;oBACpC,iCAAiC;oBACjC,SAAS,CAAC,aAAa,CAAC,CAAC;oBACzB,UAAU,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;oBACjD,iBAAiB,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;iBAChD;aACF;YACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjB;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;SACzB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {\n TemplateResult,\n ChildPart,\n RootPart,\n render,\n nothing,\n} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n} from '../directive.js';\nimport {\n clearPart,\n getCommittedValue,\n insertPart,\n isTemplateResult,\n setCommittedValue,\n} from '../directive-helpers.js';\n\nclass CacheDirective extends Directive {\n private _templateCache = new WeakMap<TemplateStringsArray, RootPart>();\n private _value?: TemplateResult;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n }\n\n render(v: unknown) {\n // Return an array of the value to induce lit-html to create a ChildPart\n // for the value that we can move into the cache.\n return [v];\n }\n\n override update(containerPart: ChildPart, [v]: DirectiveParameters<this>) {\n // If the previous value is a TemplateResult and the new value is not,\n // or is a different Template as the previous value, move the child part\n // into the cache.\n if (\n isTemplateResult(this._value) &&\n (!isTemplateResult(v) || this._value.strings !== v.strings)\n ) {\n // This is always an array because we return [v] in render()\n const partValue = getCommittedValue(containerPart) as Array<ChildPart>;\n const childPart = partValue.pop()!;\n let cachedContainerPart = this._templateCache.get(this._value.strings);\n if (cachedContainerPart === undefined) {\n const fragment = document.createDocumentFragment();\n cachedContainerPart = render(nothing, fragment);\n cachedContainerPart.setConnected(false);\n this._templateCache.set(this._value.strings, cachedContainerPart);\n }\n // Move into cache\n setCommittedValue(cachedContainerPart, [childPart]);\n insertPart(cachedContainerPart, undefined, childPart);\n }\n // If the new value is a TemplateResult and the previous value is not,\n // or is a different Template as the previous value, restore the child\n // part from the cache.\n if (isTemplateResult(v)) {\n if (!isTemplateResult(this._value) || this._value.strings !== v.strings) {\n const cachedContainerPart = this._templateCache.get(v.strings);\n if (cachedContainerPart !== undefined) {\n // Move the cached part back into the container part value\n const partValue = getCommittedValue(\n cachedContainerPart\n ) as Array<ChildPart>;\n const cachedPart = partValue.pop()!;\n // Move cached part back into DOM\n clearPart(containerPart);\n insertPart(containerPart, undefined, cachedPart);\n setCommittedValue(containerPart, [cachedPart]);\n }\n }\n this._value = v;\n } else {\n this._value = undefined;\n }\n return this.render(v);\n }\n}\n\n/**\n * Enables fast switching between multiple templates by caching the DOM nodes\n * and TemplateInstances produced by the templates.\n *\n * Example:\n *\n * ```js\n * let checked = false;\n *\n * html`\n * ${cache(checked ? html`input is checked` : html`input is not checked`)}\n * `\n * ```\n */\nexport const cache = directive(CacheDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {CacheDirective};\n"]}
@@ -3,9 +3,8 @@
3
3
  * Copyright 2018 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
7
6
  import { AttributePart, noChange } from '../lit-html.js';
8
-
7
+ import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
9
8
  /**
10
9
  * A key-value set of class names to truthy values.
11
10
  */
@@ -18,6 +17,7 @@ declare class ClassMapDirective extends Directive {
18
17
  * Used to unset existing values when a new ClassInfo object is applied.
19
18
  */
20
19
  private _previousClasses?;
20
+ private _staticClasses?;
21
21
  constructor(partInfo: PartInfo);
22
22
  render(classInfo: ClassInfo): string;
23
23
  update(part: AttributePart, [classInfo]: DirectiveParameters<this>): string | typeof noChange;
@@ -1 +1 @@
1
- {"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../src/directives/class-map.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EAET,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CACpD;AAED,cAAM,iBAAkB,SAAQ,SAAS;IACvC;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAC,CAAc;gBAE3B,QAAQ,EAAE,QAAQ;IAc9B,MAAM,CAAC,SAAS,EAAE,SAAS;IAM3B,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CAyCnE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,+FAA+B,CAAC;AAErD;;;GAGG;AACH,YAAY,EAAC,iBAAiB,EAAC,CAAC"}
1
+ {"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../src/directives/class-map.ts"],"names":[],"mappings":"AAA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