chrome-devtools-frontend 1.0.943986 → 1.0.945579

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 (335) hide show
  1. package/config/gni/devtools_grd_files.gni +4 -0
  2. package/config/gni/devtools_image_files.gni +1 -0
  3. package/front_end/Images/src/circled_exclamation_icon.svg +3 -0
  4. package/front_end/core/common/ParsedURL.ts +1 -1
  5. package/front_end/core/host/UserMetrics.ts +2 -1
  6. package/front_end/core/i18n/i18nImpl.ts +7 -4
  7. package/front_end/core/i18n/locales/en-US.json +3 -72
  8. package/front_end/core/i18n/locales/en-XL.json +15 -84
  9. package/front_end/core/protocol_client/NodeURL.ts +1 -0
  10. package/front_end/core/sdk/CSSMetadata.ts +0 -1
  11. package/front_end/core/sdk/CSSStyleDeclaration.ts +4 -0
  12. package/front_end/core/sdk/CSSStyleSheetHeader.ts +2 -3
  13. package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +2 -3
  14. package/front_end/core/sdk/Cookie.ts +17 -0
  15. package/front_end/core/sdk/CookieModel.ts +1 -0
  16. package/front_end/core/sdk/DebuggerModel.ts +5 -4
  17. package/front_end/core/sdk/NetworkManager.ts +4 -1
  18. package/front_end/core/sdk/NetworkRequest.ts +2 -2
  19. package/front_end/core/sdk/OverlayModel.ts +0 -9
  20. package/front_end/core/sdk/Resource.ts +2 -2
  21. package/front_end/core/sdk/Script.ts +2 -3
  22. package/front_end/core/sdk/sdk-meta.ts +0 -26
  23. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +0 -13
  24. package/front_end/entrypoints/main/MainImpl.ts +4 -0
  25. package/front_end/generated/protocol.d.ts +0 -4
  26. package/front_end/models/bindings/BreakpointManager.ts +3 -4
  27. package/front_end/models/bindings/ResourceMapping.ts +1 -2
  28. package/front_end/models/bindings/StylesSourceMapping.ts +1 -2
  29. package/front_end/models/emulation/EmulatedDevices.ts +2 -4
  30. package/front_end/models/persistence/IsolatedFileSystem.ts +7 -6
  31. package/front_end/models/persistence/PersistenceActions.ts +4 -1
  32. package/front_end/models/persistence/PlatformFileSystem.ts +3 -4
  33. package/front_end/models/text_utils/ContentProvider.ts +1 -2
  34. package/front_end/models/text_utils/StaticContentProvider.ts +2 -3
  35. package/front_end/models/workspace/UISourceCode.ts +2 -2
  36. package/front_end/models/workspace_diff/WorkspaceDiff.ts +20 -6
  37. package/front_end/panels/animation/animationTimeline.css +2 -0
  38. package/front_end/panels/application/BackForwardCacheStrings.ts +15 -75
  39. package/front_end/panels/application/BackForwardCacheView.ts +8 -1
  40. package/front_end/panels/application/ReportingApiView.ts +15 -1
  41. package/front_end/panels/application/components/EndpointsGrid.ts +63 -4
  42. package/front_end/panels/application/components/FrameDetailsView.ts +21 -34
  43. package/front_end/panels/changes/ChangesView.ts +8 -7
  44. package/front_end/panels/console/ConsolePinPane.ts +1 -0
  45. package/front_end/panels/console/ConsolePrompt.ts +121 -171
  46. package/front_end/panels/console/ConsoleView.ts +1 -1
  47. package/front_end/panels/console/consoleView.css +1 -1
  48. package/front_end/panels/css_overview/cssOverviewCompletedView.css +2 -2
  49. package/front_end/panels/elements/AccessibilityTreeUtils.ts +2 -1
  50. package/front_end/panels/elements/ElementsTreeElement.ts +1 -0
  51. package/front_end/panels/elements/StyleEditorWidget.ts +13 -2
  52. package/front_end/panels/elements/StylePropertyHighlighter.ts +29 -19
  53. package/front_end/panels/elements/StylePropertyTreeElement.ts +8 -12
  54. package/front_end/panels/elements/StylesSidebarPane.ts +36 -10
  55. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +27 -3
  56. package/front_end/panels/emulation/DeviceModeView.ts +3 -0
  57. package/front_end/panels/help/ReleaseNoteText.ts +3 -1
  58. package/front_end/panels/network/NetworkDataGridNode.ts +5 -1
  59. package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +1 -1
  60. package/front_end/panels/sources/BreakpointEditDialog.ts +1 -0
  61. package/front_end/panels/sources/DebuggerPlugin.ts +1 -1
  62. package/front_end/panels/sources/NavigatorView.ts +1 -1
  63. package/front_end/panels/sources/UISourceCodeFrame.ts +0 -1
  64. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +3 -34
  65. package/front_end/panels/timeline/TimelineUIUtils.ts +51 -3
  66. package/front_end/services/window_bounds/WindowBoundsService.ts +27 -0
  67. package/front_end/services/window_bounds/window_bounds.ts +9 -0
  68. package/front_end/third_party/acorn/README.chromium +2 -2
  69. package/front_end/third_party/acorn/acorn.ts +1 -1
  70. package/front_end/third_party/acorn/package/CHANGELOG.md +31 -1
  71. package/front_end/third_party/acorn/package/README.md +1 -1
  72. package/front_end/third_party/acorn/package/dist/acorn.d.ts +3 -0
  73. package/front_end/third_party/acorn/package/dist/acorn.js +772 -708
  74. package/front_end/third_party/acorn/package/dist/acorn.mjs +767 -703
  75. package/front_end/third_party/acorn/package/dist/bin.js +47 -21
  76. package/front_end/third_party/acorn/package/package.json +1 -1
  77. package/front_end/third_party/acorn-loose/README.chromium +2 -2
  78. package/front_end/third_party/acorn-loose/package/CHANGELOG.md +12 -0
  79. package/front_end/third_party/acorn-loose/package/dist/acorn-loose.js +27 -7
  80. package/front_end/third_party/acorn-loose/package/dist/acorn-loose.mjs +28 -8
  81. package/front_end/third_party/acorn-loose/package/package.json +2 -2
  82. package/front_end/third_party/codemirror.next/bundle.ts +4 -3
  83. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  84. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +39 -1
  85. package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
  86. package/front_end/third_party/codemirror.next/package.json +4 -4
  87. package/front_end/third_party/i18n/i18n-impl.ts +1 -1
  88. package/front_end/third_party/lit-html/README.chromium +2 -2
  89. package/front_end/third_party/lit-html/package/CHANGELOG.md +216 -28
  90. package/front_end/third_party/lit-html/package/LICENSE +9 -9
  91. package/front_end/third_party/lit-html/package/README.md +12 -162
  92. package/front_end/third_party/lit-html/package/async-directive.d.ts +23 -54
  93. package/front_end/third_party/lit-html/package/async-directive.d.ts.map +1 -1
  94. package/front_end/third_party/lit-html/package/async-directive.js +2 -7
  95. package/front_end/third_party/lit-html/package/async-directive.js.map +1 -1
  96. package/front_end/third_party/lit-html/package/development/async-directive.d.ts +23 -54
  97. package/front_end/third_party/lit-html/package/development/async-directive.d.ts.map +1 -1
  98. package/front_end/third_party/lit-html/package/development/async-directive.js +44 -194
  99. package/front_end/third_party/lit-html/package/development/async-directive.js.map +1 -1
  100. package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts +6 -5
  101. package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts.map +1 -1
  102. package/front_end/third_party/lit-html/package/development/directive-helpers.js +25 -9
  103. package/front_end/third_party/lit-html/package/development/directive-helpers.js.map +1 -1
  104. package/front_end/third_party/lit-html/package/development/directive.d.ts +3 -16
  105. package/front_end/third_party/lit-html/package/development/directive.d.ts.map +1 -1
  106. package/front_end/third_party/lit-html/package/development/directive.js +6 -1
  107. package/front_end/third_party/lit-html/package/development/directive.js.map +1 -1
  108. package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts +7 -14
  109. package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts.map +1 -1
  110. package/front_end/third_party/lit-html/package/development/directives/async-append.js +17 -58
  111. package/front_end/third_party/lit-html/package/development/directives/async-append.js.map +1 -1
  112. package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts +9 -14
  113. package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts.map +1 -1
  114. package/front_end/third_party/lit-html/package/development/directives/async-replace.js +57 -37
  115. package/front_end/third_party/lit-html/package/development/directives/async-replace.js.map +1 -1
  116. package/front_end/third_party/lit-html/package/development/directives/cache.d.ts +2 -3
  117. package/front_end/third_party/lit-html/package/development/directives/cache.d.ts.map +1 -1
  118. package/front_end/third_party/lit-html/package/development/directives/cache.js +4 -6
  119. package/front_end/third_party/lit-html/package/development/directives/cache.js.map +1 -1
  120. package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts +2 -2
  121. package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts.map +1 -1
  122. package/front_end/third_party/lit-html/package/development/directives/class-map.js +17 -7
  123. package/front_end/third_party/lit-html/package/development/directives/class-map.js.map +1 -1
  124. package/front_end/third_party/lit-html/package/development/directives/guard.d.ts +3 -2
  125. package/front_end/third_party/lit-html/package/development/directives/guard.d.ts.map +1 -1
  126. package/front_end/third_party/lit-html/package/development/directives/guard.js +3 -2
  127. package/front_end/third_party/lit-html/package/development/directives/guard.js.map +1 -1
  128. package/front_end/third_party/lit-html/package/development/directives/live.d.ts +4 -3
  129. package/front_end/third_party/lit-html/package/development/directives/live.d.ts.map +1 -1
  130. package/front_end/third_party/lit-html/package/development/directives/live.js +5 -7
  131. package/front_end/third_party/lit-html/package/development/directives/live.js.map +1 -1
  132. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts +58 -0
  133. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts.map +1 -0
  134. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js +85 -0
  135. package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js.map +1 -0
  136. package/front_end/third_party/lit-html/package/development/directives/ref.d.ts +14 -11
  137. package/front_end/third_party/lit-html/package/development/directives/ref.d.ts.map +1 -1
  138. package/front_end/third_party/lit-html/package/development/directives/ref.js +13 -11
  139. package/front_end/third_party/lit-html/package/development/directives/ref.js.map +1 -1
  140. package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts +8 -4
  141. package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts.map +1 -1
  142. package/front_end/third_party/lit-html/package/development/directives/repeat.js +23 -9
  143. package/front_end/third_party/lit-html/package/development/directives/repeat.js.map +1 -1
  144. package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts +1 -2
  145. package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts.map +1 -1
  146. package/front_end/third_party/lit-html/package/development/directives/style-map.js +1 -2
  147. package/front_end/third_party/lit-html/package/development/directives/style-map.js.map +1 -1
  148. package/front_end/third_party/lit-html/package/development/directives/template-content.d.ts +1 -2
  149. package/front_end/third_party/lit-html/package/development/directives/template-content.js +1 -2
  150. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts +6 -4
  151. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts.map +1 -1
  152. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js +7 -5
  153. package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js.map +1 -1
  154. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts +4 -1
  155. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts.map +1 -1
  156. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js +3 -0
  157. package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js.map +1 -1
  158. package/front_end/third_party/lit-html/package/development/directives/until.d.ts +12 -8
  159. package/front_end/third_party/lit-html/package/development/directives/until.d.ts.map +1 -1
  160. package/front_end/third_party/lit-html/package/development/directives/until.js +63 -23
  161. package/front_end/third_party/lit-html/package/development/directives/until.js.map +1 -1
  162. package/front_end/third_party/lit-html/package/development/experimental-hydrate.d.ts.map +1 -1
  163. package/front_end/third_party/lit-html/package/development/experimental-hydrate.js +9 -8
  164. package/front_end/third_party/lit-html/package/development/experimental-hydrate.js.map +1 -1
  165. package/front_end/third_party/lit-html/package/development/lit-html.d.ts +81 -136
  166. package/front_end/third_party/lit-html/package/development/lit-html.d.ts.map +1 -1
  167. package/front_end/third_party/lit-html/package/development/lit-html.js +249 -76
  168. package/front_end/third_party/lit-html/package/development/lit-html.js.map +1 -1
  169. package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts +1 -41
  170. package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts.map +1 -1
  171. package/front_end/third_party/lit-html/package/development/polyfill-support.js +40 -21
  172. package/front_end/third_party/lit-html/package/development/polyfill-support.js.map +1 -1
  173. package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts +12 -10
  174. package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts.map +1 -1
  175. package/front_end/third_party/lit-html/package/development/private-ssr-support.js +11 -3
  176. package/front_end/third_party/lit-html/package/development/private-ssr-support.js.map +1 -1
  177. package/front_end/third_party/lit-html/package/development/static.d.ts.map +1 -1
  178. package/front_end/third_party/lit-html/package/development/static.js +6 -5
  179. package/front_end/third_party/lit-html/package/development/static.js.map +1 -1
  180. package/front_end/third_party/lit-html/package/directive-helpers.d.ts +6 -5
  181. package/front_end/third_party/lit-html/package/directive-helpers.d.ts.map +1 -1
  182. package/front_end/third_party/lit-html/package/directive-helpers.js +2 -2
  183. package/front_end/third_party/lit-html/package/directive-helpers.js.map +1 -1
  184. package/front_end/third_party/lit-html/package/directive.d.ts +3 -16
  185. package/front_end/third_party/lit-html/package/directive.d.ts.map +1 -1
  186. package/front_end/third_party/lit-html/package/directive.js +1 -1
  187. package/front_end/third_party/lit-html/package/directive.js.map +1 -1
  188. package/front_end/third_party/lit-html/package/directives/async-append.d.ts +7 -14
  189. package/front_end/third_party/lit-html/package/directives/async-append.d.ts.map +1 -1
  190. package/front_end/third_party/lit-html/package/directives/async-append.js +2 -6
  191. package/front_end/third_party/lit-html/package/directives/async-append.js.map +1 -1
  192. package/front_end/third_party/lit-html/package/directives/async-replace.d.ts +9 -14
  193. package/front_end/third_party/lit-html/package/directives/async-replace.d.ts.map +1 -1
  194. package/front_end/third_party/lit-html/package/directives/async-replace.js +2 -5
  195. package/front_end/third_party/lit-html/package/directives/async-replace.js.map +1 -1
  196. package/front_end/third_party/lit-html/package/directives/cache.d.ts +2 -3
  197. package/front_end/third_party/lit-html/package/directives/cache.d.ts.map +1 -1
  198. package/front_end/third_party/lit-html/package/directives/cache.js +2 -5
  199. package/front_end/third_party/lit-html/package/directives/cache.js.map +1 -1
  200. package/front_end/third_party/lit-html/package/directives/class-map.d.ts +2 -2
  201. package/front_end/third_party/lit-html/package/directives/class-map.d.ts.map +1 -1
  202. package/front_end/third_party/lit-html/package/directives/class-map.js +2 -4
  203. package/front_end/third_party/lit-html/package/directives/class-map.js.map +1 -1
  204. package/front_end/third_party/lit-html/package/directives/guard.d.ts +3 -2
  205. package/front_end/third_party/lit-html/package/directives/guard.d.ts.map +1 -1
  206. package/front_end/third_party/lit-html/package/directives/guard.js +2 -4
  207. package/front_end/third_party/lit-html/package/directives/guard.js.map +1 -1
  208. package/front_end/third_party/lit-html/package/directives/live.d.ts +4 -3
  209. package/front_end/third_party/lit-html/package/directives/live.d.ts.map +1 -1
  210. package/front_end/third_party/lit-html/package/directives/live.js +1 -4
  211. package/front_end/third_party/lit-html/package/directives/live.js.map +1 -1
  212. package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts +58 -0
  213. package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts.map +1 -0
  214. package/front_end/third_party/lit-html/package/directives/private-async-helpers.js +7 -0
  215. package/front_end/third_party/lit-html/package/directives/private-async-helpers.js.map +1 -0
  216. package/front_end/third_party/lit-html/package/directives/ref.d.ts +14 -11
  217. package/front_end/third_party/lit-html/package/directives/ref.d.ts.map +1 -1
  218. package/front_end/third_party/lit-html/package/directives/ref.js +2 -5
  219. package/front_end/third_party/lit-html/package/directives/ref.js.map +1 -1
  220. package/front_end/third_party/lit-html/package/directives/repeat.d.ts +8 -4
  221. package/front_end/third_party/lit-html/package/directives/repeat.d.ts.map +1 -1
  222. package/front_end/third_party/lit-html/package/directives/repeat.js +2 -5
  223. package/front_end/third_party/lit-html/package/directives/repeat.js.map +1 -1
  224. package/front_end/third_party/lit-html/package/directives/style-map.d.ts +1 -2
  225. package/front_end/third_party/lit-html/package/directives/style-map.d.ts.map +1 -1
  226. package/front_end/third_party/lit-html/package/directives/style-map.js +2 -4
  227. package/front_end/third_party/lit-html/package/directives/style-map.js.map +1 -1
  228. package/front_end/third_party/lit-html/package/directives/template-content.d.ts +1 -2
  229. package/front_end/third_party/lit-html/package/directives/template-content.js +2 -4
  230. package/front_end/third_party/lit-html/package/directives/template-content.js.map +1 -1
  231. package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts +6 -4
  232. package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts.map +1 -1
  233. package/front_end/third_party/lit-html/package/directives/unsafe-html.js +2 -4
  234. package/front_end/third_party/lit-html/package/directives/unsafe-html.js.map +1 -1
  235. package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts +4 -1
  236. package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts.map +1 -1
  237. package/front_end/third_party/lit-html/package/directives/unsafe-svg.js.map +1 -1
  238. package/front_end/third_party/lit-html/package/directives/until.d.ts +12 -8
  239. package/front_end/third_party/lit-html/package/directives/until.d.ts.map +1 -1
  240. package/front_end/third_party/lit-html/package/directives/until.js +2 -6
  241. package/front_end/third_party/lit-html/package/directives/until.js.map +1 -1
  242. package/front_end/third_party/lit-html/package/experimental-hydrate.d.ts.map +1 -1
  243. package/front_end/third_party/lit-html/package/experimental-hydrate.js +2 -5
  244. package/front_end/third_party/lit-html/package/experimental-hydrate.js.map +1 -1
  245. package/front_end/third_party/lit-html/package/lit-html.d.ts +81 -136
  246. package/front_end/third_party/lit-html/package/lit-html.d.ts.map +1 -1
  247. package/front_end/third_party/lit-html/package/lit-html.js +1 -1
  248. package/front_end/third_party/lit-html/package/lit-html.js.map +1 -1
  249. package/front_end/third_party/lit-html/package/package.json +75 -24
  250. package/front_end/third_party/lit-html/package/polyfill-support.d.ts +1 -41
  251. package/front_end/third_party/lit-html/package/polyfill-support.d.ts.map +1 -1
  252. package/front_end/third_party/lit-html/package/polyfill-support.js +1 -1
  253. package/front_end/third_party/lit-html/package/polyfill-support.js.map +1 -1
  254. package/front_end/third_party/lit-html/package/private-ssr-support.d.ts +12 -10
  255. package/front_end/third_party/lit-html/package/private-ssr-support.d.ts.map +1 -1
  256. package/front_end/third_party/lit-html/package/private-ssr-support.js +2 -2
  257. package/front_end/third_party/lit-html/package/private-ssr-support.js.map +1 -1
  258. package/front_end/third_party/lit-html/package/static.d.ts.map +1 -1
  259. package/front_end/third_party/lit-html/package/static.js +1 -1
  260. package/front_end/third_party/lit-html/package/static.js.map +1 -1
  261. package/front_end/third_party/marked/README.chromium +2 -2
  262. package/front_end/third_party/marked/marked.ts +2 -2
  263. package/front_end/third_party/marked/package/README.md +7 -1
  264. package/front_end/third_party/marked/package/bin/marked.js +214 -0
  265. package/front_end/third_party/marked/package/lib/marked.cjs +2907 -0
  266. package/front_end/third_party/marked/package/lib/marked.esm.d.ts +1 -3
  267. package/front_end/third_party/marked/package/lib/marked.esm.js +627 -586
  268. package/front_end/third_party/marked/package/lib/marked.umd.js +2913 -0
  269. package/front_end/third_party/marked/package/man/marked.1 +5 -24
  270. package/front_end/third_party/marked/package/man/marked.1.txt +21 -31
  271. package/front_end/third_party/marked/package/marked.min.js +1 -1
  272. package/front_end/third_party/marked/package/package.json +41 -32
  273. package/front_end/third_party/marked/package/src/Lexer.js +109 -108
  274. package/front_end/third_party/marked/package/src/Parser.js +38 -15
  275. package/front_end/third_party/marked/package/src/Renderer.js +5 -5
  276. package/front_end/third_party/marked/package/src/Slugger.js +2 -2
  277. package/front_end/third_party/marked/package/src/TextRenderer.js +2 -2
  278. package/front_end/third_party/marked/package/src/Tokenizer.js +215 -190
  279. package/front_end/third_party/marked/package/src/defaults.js +6 -9
  280. package/front_end/third_party/marked/package/src/helpers.js +16 -27
  281. package/front_end/third_party/marked/package/src/marked.js +146 -63
  282. package/front_end/third_party/marked/package/src/rules.js +20 -45
  283. package/front_end/third_party/wasmparser/README.chromium +2 -2
  284. package/front_end/third_party/wasmparser/package/.github/workflows/main.yml +47 -0
  285. package/front_end/third_party/wasmparser/package/CHANGELOG.md +12 -0
  286. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js +53 -53
  287. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js.map +1 -1
  288. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js +53 -53
  289. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js.map +1 -1
  290. package/front_end/third_party/wasmparser/package/package.json +1 -1
  291. package/front_end/third_party/wasmparser/package/src/WasmParser.ts +53 -53
  292. package/front_end/ui/components/adorners/Adorner.ts +14 -14
  293. package/front_end/ui/components/buttons/Button.ts +116 -42
  294. package/front_end/ui/components/data_grid/DataGrid.ts +122 -122
  295. package/front_end/ui/components/data_grid/DataGridController.ts +42 -42
  296. package/front_end/ui/components/diff_view/DiffView.ts +4 -4
  297. package/front_end/ui/components/docs/button/basic.html +3 -0
  298. package/front_end/ui/components/docs/button/basic.ts +16 -0
  299. package/front_end/ui/components/expandable_list/ExpandableList.ts +11 -11
  300. package/front_end/ui/components/icon_button/Icon.ts +24 -21
  301. package/front_end/ui/components/icon_button/IconButton.ts +31 -31
  302. package/front_end/ui/components/issue_counter/IssueCounter.ts +52 -52
  303. package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +42 -42
  304. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspector.ts +67 -67
  305. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +22 -22
  306. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorPane.ts +36 -36
  307. package/front_end/ui/components/linear_memory_inspector/LinearMemoryNavigator.ts +19 -19
  308. package/front_end/ui/components/linear_memory_inspector/LinearMemoryValueInterpreter.ts +25 -25
  309. package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +52 -52
  310. package/front_end/ui/components/linear_memory_inspector/ValueInterpreterDisplay.ts +21 -21
  311. package/front_end/ui/components/linear_memory_inspector/ValueInterpreterSettings.ts +6 -6
  312. package/front_end/ui/components/markdown_view/MarkdownImage.ts +14 -14
  313. package/front_end/ui/components/markdown_view/MarkdownLink.ts +8 -8
  314. package/front_end/ui/components/markdown_view/MarkdownView.ts +6 -6
  315. package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +33 -33
  316. package/front_end/ui/components/report_view/ReportView.ts +18 -18
  317. package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +53 -53
  318. package/front_end/ui/components/settings/SettingCheckbox.ts +15 -15
  319. package/front_end/ui/components/survey_link/SurveyLink.ts +28 -28
  320. package/front_end/ui/components/text_editor/TextEditor.ts +65 -36
  321. package/front_end/ui/components/text_editor/config.ts +36 -14
  322. package/front_end/ui/components/text_editor/javascript.ts +20 -15
  323. package/front_end/ui/components/text_editor/theme.ts +29 -4
  324. package/front_end/ui/components/text_prompt/TextPrompt.ts +19 -19
  325. package/front_end/ui/components/tree_outline/TreeOutline.ts +56 -56
  326. package/front_end/ui/legacy/Infobar.ts +9 -0
  327. package/front_end/ui/legacy/InspectorView.ts +1 -1
  328. package/front_end/ui/legacy/ViewManager.ts +6 -0
  329. package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +20 -0
  330. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +1 -0
  331. package/front_end/ui/legacy/components/utils/Linkifier.ts +49 -79
  332. package/front_end/ui/legacy/tabbedPane.css +1 -1
  333. package/front_end/ui/legacy/themeColors.css +2 -0
  334. package/inspector_overlay/main.ts +3 -0
  335. package/package.json +1 -1
@@ -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,CAAC,CAAa;IACxC,OAAO,CAAC,iBAAiB,CAAC,CAAgB;IAI1C,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAItD,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;YAarD,SAAS;IA4BvB,YAAY;IAOZ,WAAW;CAKZ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,mJAAmC,CAAC;AAE7D;;;GAGG;AACH,YAAY,EAAC,qBAAqB,EAAC,CAAC"}
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;AAGrD,aAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;AAEnD,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,OAAO,CAAC,OAAO,CAAC,CAAyB;IACzC,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,QAAQ,CAAgB;IAIhC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAI7C,MAAM,CACb,KAAK,EAAE,SAAS,EAChB,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;IAqD5C,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;IAI3C,YAAY;IAKZ,WAAW;CAIrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,mJAAmC,CAAC"}
@@ -1,10 +1,7 @@
1
- import{AsyncDirective as e}from"../async-directive.js";
2
- import{directive as i}from"../directive.js";
3
- import{noChange as t}from"../lit-html.js";
4
-
1
+ import{noChange as t}from"../lit-html.js";import{directive as i}from"../directive.js";import{AsyncDirective as s}from"../async-directive.js";import{PseudoWeakRef as r,Pauser as e,forAwaitOf as n}from"./private-async-helpers.js";
5
2
  /**
6
3
  * @license
7
4
  * Copyright 2017 Google LLC
8
5
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const s=i(class extends e{render(i,e){return t}update(i,[e,s]){if(e!==this.vt)return this.vt=e,this.Σft(s),t}async Σft(t){let i=0;const{vt:e}=this;for await(let s of e){if(this.vt!==e)break;this.wt&&await this.wt,void 0!==t&&(s=t(s,i)),this.setValue(s),i++}}disconnected(){this.wt=new Promise((t=>this.yt=t))}reconnected(){this.wt=void 0,this.yt()}});export{s as asyncReplace};
6
+ */class o extends s{constructor(){super(...arguments),this._$CG=new r(this),this._$CK=new e}render(i,s){return t}update(i,[s,r]){if(this.isConnected||this.disconnected(),s===this._$CJ)return;this._$CJ=s;let e=0;const{_$CG:o,_$CK:h}=this;return n(s,(async t=>{for(;h.get();)await h.get();const i=o.deref();if(void 0!==i){if(i._$CJ!==s)return!1;void 0!==r&&(t=r(t,e)),i.commitValue(t,e),e++}return!0})),t}commitValue(t,i){this.setValue(t)}disconnected(){this._$CG.disconnect(),this._$CK.pause()}reconnected(){this._$CG.reconnect(this),this._$CK.resume()}}const h=i(o);export{o as AsyncReplaceDirective,h as asyncReplace};
10
7
  //# sourceMappingURL=async-replace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-replace.js","sources":["../src/directives/async-replace.ts"],"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"],"names":["asyncReplace","directive","AsyncDirective","[object Object]","value","_mapper","noChange","_part","mapper","this","_value","__iterate","i","vt","v","_reconnectPromise","undefined","setValue","Promise","resolve","_reconnectResolver"],"mappings":";;;;;SAgGaA,EAAeC,EApF5B,cAAoCC,EAOlCC,OAAUC,EAAyBC,GACjC,OAAOC,EAGTH,OAAOI,GAAmBH,EAAOI,IAG/B,GAAIJ,IAAUK,KAAKC,GAKnB,OAFAD,KAAKC,GAASN,EACdK,KAAKE,IAAUH,GACRF,EAKDH,UAAgBK,GACtB,IAAII,EAAI,EACR,MAAOC,GAAQT,GAASK,KACxB,UAAW,IAAIK,KAAKV,EAAQ,CAG1B,GAAIK,KAAKC,KAAWN,EAClB,MAIEK,KAAKM,UACDN,KAAKM,QAOEC,IAAXR,IACFM,EAAIN,EAAOM,EAAGF,IAGhBH,KAAKQ,SAASH,GACdF,KAIJT,eAEEM,KAAKM,GAAoB,IAAIG,SAC1BC,GAAaV,KAAKW,GAAqBD,IAI5ChB,cAEEM,KAAKM,QAAoBC,EACzBP,KAAKW"}
1
+ {"version":3,"file":"async-replace.js","sources":["../src/directives/async-replace.ts"],"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"],"names":["AsyncReplaceDirective","AsyncDirective","constructor","this","PseudoWeakRef","Pauser","render","value","_mapper","noChange","update","_part","mapper","isConnected","disconnected","__value","i","__weakThis","weakThis","__pauser","pauser","forAwaitOf","async","v","get","_this","deref","undefined","commitValue","_index","setValue","disconnect","pause","reconnected","reconnect","resume","asyncReplace","directive"],"mappings":";;;;;SAaaA,UAA8BC,EAA3CC,kCAEUC,UAAa,IAAIC,EAAcD,MAC/BA,UAAW,IAAIE,EAIvBC,OAAUC,EAAyBC,GACjC,OAAOC,EAGAC,OACPC,GACCJ,EAAOK,IASR,GALKT,KAAKU,aACRV,KAAKW,eAIHP,IAAUJ,KAAKY,KACjB,OAEFZ,KAAKY,KAAUR,EACf,IAAIS,EAAI,EACR,MAAOC,KAAYC,EAAUC,KAAUC,GAAUjB,KAmCjD,OA9BAkB,EAAWd,GAAOe,MAAOC,IAGvB,KAAOH,EAAOI,aACNJ,EAAOI,MAKf,MAAMC,EAAQP,EAASQ,QACvB,QAAcC,IAAVF,EAAqB,CAGvB,GAAIA,EAAMV,OAAYR,EACpB,OAAO,OAOMoB,IAAXf,IACFW,EAAIX,EAAOW,EAAGP,IAGhBS,EAAMG,YAAYL,EAAGP,GACrBA,IAEF,OAAO,KAEFP,EAICmB,YAAYrB,EAAgBsB,GACpC1B,KAAK2B,SAASvB,GAGPO,eACPX,KAAKc,KAAWc,aAChB5B,KAAKgB,KAASa,QAGPC,cACP9B,KAAKc,KAAWiB,UAAU/B,MAC1BA,KAAKgB,KAASgB,gBAsBLC,EAAeC,EAAUrC"}
@@ -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"}
@@ -1,10 +1,7 @@
1
- import{clearPart as c,getCommittedValue as r,insertPart as n,isTemplateResult as o,setCommittedValue as h}from"../directive-helpers.js";
2
- import{directive as s,Directive as e}from"../directive.js";
3
- import{nothing as i,render as t}from"../lit-html.js";
4
-
1
+ import{render as t,nothing as i}from"../lit-html.js";import{directive as s,Directive as e}from"../directive.js";import{isTemplateResult as o,getCommittedValue as r,setCommittedValue as h,insertPart as n,clearPart as c}from"../directive-helpers.js";
5
2
  /**
6
3
  * @license
7
4
  * Copyright 2017 Google LLC
8
5
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const d=s(class extends e{constructor(t){super(t),this._t=new WeakMap}render(t){return[t]}update(s,[e]){if(o(this.vt)&&(!o(e)||this.vt.strings!==e.strings)){const e=r(s).pop();let o=this._t.get(this.vt.strings);if(void 0===o){const s=document.createDocumentFragment();o=t(i,s),this._t.set(this.vt.strings,o)}h(o,[e]),n(o,void 0,e),e.setConnected(!1)}if(o(e)){if(!o(this.vt)||this.vt.strings!==e.strings){const t=this._t.get(e.strings);if(void 0!==t){const i=r(t).pop();c(s),n(s,void 0,i),h(s,[i]),i.setConnected(!0)}}this.vt=e}else this.vt=void 0;return this.render(e)}});export{d as cache};
6
+ */const d=s(class extends e{constructor(t){super(t),this.tt=new WeakMap}render(t){return[t]}update(s,[e]){if(o(this.it)&&(!o(e)||this.it.strings!==e.strings)){const e=r(s).pop();let o=this.tt.get(this.it.strings);if(void 0===o){const s=document.createDocumentFragment();o=t(i,s),o.setConnected(!1),this.tt.set(this.it.strings,o)}h(o,[e]),n(o,void 0,e)}if(o(e)){if(!o(this.it)||this.it.strings!==e.strings){const t=this.tt.get(e.strings);if(void 0!==t){const i=r(t).pop();c(s),n(s,void 0,i),h(s,[i])}}this.it=e}else this.it=void 0;return this.render(e)}});export{d as cache};
10
7
  //# sourceMappingURL=cache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sources":["../src/directives/cache.ts"],"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"],"names":["cache","directive","Directive","[object Object]","partInfo","super","this","WeakMap","v","containerPart","isTemplateResult","_value","strings","childPart","getCommittedValue","pop","cachedContainerPart","_templateCache","get","undefined","fragment","document","createDocumentFragment","render","nothing","set","setCommittedValue","insertPart","setConnected","cachedPart","clearPart"],"mappings":";;;;;SAkGaA,EAAQC,EA7ErB,cAA6BC,EAI3BC,YAAYC,GACVC,MAAMD,GAJAE,QAAiB,IAAIC,QAO7BJ,OAAOK,GAGL,MAAO,CAACA,GAGVL,OAAOM,GAA2BD,IAIhC,GACEE,EAAiBJ,KAAKK,OACpBD,EAAiBF,IAAMF,KAAKK,GAAOC,UAAYJ,EAAEI,SACnD,CAEA,MACMC,EADYC,EAAkBL,GACRM,MAC5B,IAAIC,EAAsBV,KAAKW,GAAeC,IAAIZ,KAAKK,GAAOC,SAC9D,QAA4BO,IAAxBH,EAAmC,CACrC,MAAMI,EAAWC,SAASC,yBAC1BN,EAAsBO,EAAOC,EAASJ,GACtCd,KAAKW,GAAeQ,IAAInB,KAAKK,GAAOC,QAASI,GAG/CU,EAAkBV,EAAqB,CAACH,IACxCc,EAAWX,OAAqBG,EAAWN,GAC3CA,EAAUe,cAAa,GAKzB,GAAIlB,EAAiBF,GAAI,CACvB,IAAKE,EAAiBJ,KAAKK,KAAWL,KAAKK,GAAOC,UAAYJ,EAAEI,QAAS,CACvE,MAAMI,EAAsBV,KAAKW,GAAeC,IAAIV,EAAEI,SACtD,QAA4BO,IAAxBH,EAAmC,CAErC,MAGMa,EAHYf,EAChBE,GAE2BD,MAE7Be,EAAUrB,GACVkB,EAAWlB,OAAeU,EAAWU,GACrCH,EAAkBjB,EAAe,CAACoB,IAClCA,EAAWD,cAAa,IAG5BtB,KAAKK,GAASH,OAEdF,KAAKK,QAASQ,EAEhB,OAAOb,KAAKiB,OAAOf"}
1
+ {"version":3,"file":"cache.js","sources":["../src/directives/cache.ts"],"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"],"names":["cache","directive","Directive","constructor","partInfo","super","this","WeakMap","render","v","update","containerPart","isTemplateResult","_value","strings","childPart","getCommittedValue","pop","cachedContainerPart","_templateCache","get","undefined","fragment","document","createDocumentFragment","nothing","setConnected","set","setCommittedValue","insertPart","cachedPart","clearPart"],"mappings":";;;;;SAuGaA,EAAQC,EA5ErB,cAA6BC,EAI3BC,YAAYC,GACVC,MAAMD,GAJAE,QAAiB,IAAIC,QAO7BC,OAAOC,GAGL,MAAO,CAACA,GAGDC,OAAOC,GAA2BF,IAIzC,GACEG,EAAiBN,KAAKO,OACpBD,EAAiBH,IAAMH,KAAKO,GAAOC,UAAYL,EAAEK,SACnD,CAEA,MACMC,EADYC,EAAkBL,GACRM,MAC5B,IAAIC,EAAsBZ,KAAKa,GAAeC,IAAId,KAAKO,GAAOC,SAC9D,QAA4BO,IAAxBH,EAAmC,CACrC,MAAMI,EAAWC,SAASC,yBAC1BN,EAAsBV,EAAOiB,EAASH,GACtCJ,EAAoBQ,cAAa,GACjCpB,KAAKa,GAAeQ,IAAIrB,KAAKO,GAAOC,QAASI,GAG/CU,EAAkBV,EAAqB,CAACH,IACxCc,EAAWX,OAAqBG,EAAWN,GAK7C,GAAIH,EAAiBH,GAAI,CACvB,IAAKG,EAAiBN,KAAKO,KAAWP,KAAKO,GAAOC,UAAYL,EAAEK,QAAS,CACvE,MAAMI,EAAsBZ,KAAKa,GAAeC,IAAIX,EAAEK,SACtD,QAA4BO,IAAxBH,EAAmC,CAErC,MAGMY,EAHYd,EAChBE,GAE2BD,MAE7Bc,EAAUpB,GACVkB,EAAWlB,OAAeU,EAAWS,GACrCF,EAAkBjB,EAAe,CAACmB,KAGtCxB,KAAKO,GAASJ,OAEdH,KAAKO,QAASQ,EAEhB,OAAOf,KAAKE,OAAOC"}
@@ -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":"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;IACvC,OAAO,CAAC,cAAc,CAAC,CAAc;gBAEzB,QAAQ,EAAE,QAAQ;IAc9B,MAAM,CAAC,SAAS,EAAE,SAAS;IAWlB,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CAoD5E;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,+FAA+B,CAAC;AAErD;;;GAGG;AACH,YAAY,EAAC,iBAAiB,EAAC,CAAC"}
@@ -1,9 +1,7 @@
1
- import{directive as s,Directive as r,PartType as i}from"../directive.js";
2
- import{noChange as t}from"../lit-html.js";
3
-
1
+ import{noChange as t}from"../lit-html.js";import{directive as i,Directive as s,PartType as r}from"../directive.js";
4
2
  /**
5
3
  * @license
6
4
  * Copyright 2018 Google LLC
7
5
  * SPDX-License-Identifier: BSD-3-Clause
8
- */const e=s(class extends r{constructor(t){var s;if(super(t),t.type!==i.ATTRIBUTE||"class"!==t.name||(null===(s=t.strings)||void 0===s?void 0:s.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).filter((s=>t[s])).join(" ")}update(s,[r]){if(void 0===this.bt){this.bt=new Set;for(const t in r)r[t]&&this.bt.add(t);return this.render(r)}const i=s.element.classList;this.bt.forEach((t=>{t in r||(i.remove(t),this.bt.delete(t))}));for(const t in r){const s=!!r[t];s!==this.bt.has(t)&&(s?(i.add(t),this.bt.add(t)):(i.remove(t),this.bt.delete(t)))}return t}});export{e as classMap};
6
+ */const o=i(class extends s{constructor(t){var i;if(super(t),t.type!==r.ATTRIBUTE||"class"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((i=>t[i])).join(" ")+" "}update(i,[s]){var r,o;if(void 0===this.st){this.st=new Set,void 0!==i.strings&&(this.et=new Set(i.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in s)s[t]&&!(null===(r=this.et)||void 0===r?void 0:r.has(t))&&this.st.add(t);return this.render(s)}const e=i.element.classList;this.st.forEach((t=>{t in s||(e.remove(t),this.st.delete(t))}));for(const t in s){const i=!!s[t];i===this.st.has(t)||(null===(o=this.et)||void 0===o?void 0:o.has(t))||(i?(e.add(t),this.st.add(t)):(e.remove(t),this.st.delete(t)))}return t}});export{o as classMap};
9
7
  //# sourceMappingURL=class-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"class-map.js","sources":["../src/directives/class-map.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\n\n/**\n * A key-value set of class names to truthy values.\n */\nexport interface ClassInfo {\n readonly [name: string]: string | boolean | number;\n}\n\nclass ClassMapDirective extends Directive {\n /**\n * Stores the ClassInfo object applied to a given AttributePart.\n * Used to unset existing values when a new ClassInfo object is applied.\n */\n private _previousClasses?: Set<string>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'class' ||\n (partInfo.strings?.length as number) > 2\n ) {\n throw new Error(\n '`classMap()` can only be used in the `class` attribute ' +\n 'and must be the only part in the attribute.'\n );\n }\n }\n\n render(classInfo: ClassInfo) {\n return Object.keys(classInfo)\n .filter((key) => classInfo[key])\n .join(' ');\n }\n\n update(part: AttributePart, [classInfo]: DirectiveParameters<this>) {\n // Remember dynamic classes on the first render\n if (this._previousClasses === undefined) {\n this._previousClasses = new Set();\n for (const name in classInfo) {\n if (classInfo[name]) {\n this._previousClasses.add(name);\n }\n }\n return this.render(classInfo);\n }\n\n const classList = part.element.classList;\n\n // Remove old classes that no longer apply\n // We use forEach() instead of for-of so that we don't require down-level\n // iteration.\n this._previousClasses.forEach((name) => {\n if (!(name in classInfo)) {\n classList.remove(name);\n this._previousClasses!.delete(name);\n }\n });\n\n // Add or remove classes based on their classMap value\n for (const name in classInfo) {\n // We explicitly want a loose truthy check of `value` because it seems\n // more convenient that '' and 0 are skipped.\n const value = !!classInfo[name];\n if (value !== this._previousClasses.has(name)) {\n if (value) {\n classList.add(name);\n this._previousClasses.add(name);\n } else {\n classList.remove(name);\n this._previousClasses.delete(name);\n }\n }\n }\n return noChange;\n }\n}\n\n/**\n * A directive that applies dynamic CSS classes.\n *\n * This must be used in the `class` attribute and must be the only part used in\n * the attribute. It takes each property in the `classInfo` argument and adds\n * the property name to the element's `classList` if the property value is\n * truthy; if the property value is falsey, the property name is removed from\n * the element's `class`.\n *\n * For example `{foo: bar}` applies the class `foo` if the value of `bar` is\n * truthy.\n *\n * @param classInfo\n */\nexport const classMap = directive(ClassMapDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {ClassMapDirective};\n"],"names":["classMap","directive","Directive","[object Object]","partInfo","super","type","PartType","ATTRIBUTE","name","strings","length","Error","classInfo","Object","keys","filter","key","join","part","undefined","this","_previousClasses","Set","add","render","classList","element","forEach","remove","delete","value","has","noChange"],"mappings":";;;;;SA0GaA,EAAWC,EApFxB,cAAgCC,EAO9BC,YAAYC,SAEV,GADAC,MAAMD,GAEJA,EAASE,OAASC,EAASC,WACT,UAAlBJ,EAASK,iBACRL,EAASM,8BAASC,QAAoB,EAEvC,MAAUC,MACR,sGAMNT,OAAOU,GACL,OAAOC,OAAOC,KAAKF,GAChBG,QAAQC,GAAQJ,EAAUI,KAC1BC,KAAK,KAGVf,OAAOgB,GAAsBN,IAE3B,QAA8BO,IAA1BC,KAAKC,GAAgC,CACvCD,KAAKC,GAAmB,IAAIC,IAC5B,IAAK,MAAMd,KAAQI,EACbA,EAAUJ,IACZY,KAAKC,GAAiBE,IAAIf,GAG9B,OAAOY,KAAKI,OAAOZ,GAGrB,MAAMa,EAAYP,EAAKQ,QAAQD,UAK/BL,KAAKC,GAAiBM,SAASnB,IACvBA,KAAQI,IACZa,EAAUG,OAAOpB,GACjBY,KAAKC,GAAkBQ,OAAOrB,OAKlC,IAAK,MAAMA,KAAQI,EAAW,CAG5B,MAAMkB,IAAUlB,EAAUJ,GACtBsB,IAAUV,KAAKC,GAAiBU,IAAIvB,KAClCsB,GACFL,EAAUF,IAAIf,GACdY,KAAKC,GAAiBE,IAAIf,KAE1BiB,EAAUG,OAAOpB,GACjBY,KAAKC,GAAiBQ,OAAOrB,KAInC,OAAOwB"}
1
+ {"version":3,"file":"class-map.js","sources":["../src/directives/class-map.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\n\n/**\n * A key-value set of class names to truthy values.\n */\nexport interface ClassInfo {\n readonly [name: string]: string | boolean | number;\n}\n\nclass ClassMapDirective extends Directive {\n /**\n * Stores the ClassInfo object applied to a given AttributePart.\n * Used to unset existing values when a new ClassInfo object is applied.\n */\n private _previousClasses?: Set<string>;\n private _staticClasses?: Set<string>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'class' ||\n (partInfo.strings?.length as number) > 2\n ) {\n throw new Error(\n '`classMap()` can only be used in the `class` attribute ' +\n 'and must be the only part in the attribute.'\n );\n }\n }\n\n render(classInfo: ClassInfo) {\n // Add spaces to ensure separation from static classes\n return (\n ' ' +\n Object.keys(classInfo)\n .filter((key) => classInfo[key])\n .join(' ') +\n ' '\n );\n }\n\n override update(part: AttributePart, [classInfo]: DirectiveParameters<this>) {\n // Remember dynamic classes on the first render\n if (this._previousClasses === undefined) {\n this._previousClasses = new Set();\n if (part.strings !== undefined) {\n this._staticClasses = new Set(\n part.strings\n .join(' ')\n .split(/\\s/)\n .filter((s) => s !== '')\n );\n }\n for (const name in classInfo) {\n if (classInfo[name] && !this._staticClasses?.has(name)) {\n this._previousClasses.add(name);\n }\n }\n return this.render(classInfo);\n }\n\n const classList = part.element.classList;\n\n // Remove old classes that no longer apply\n // We use forEach() instead of for-of so that we don't require down-level\n // iteration.\n this._previousClasses.forEach((name) => {\n if (!(name in classInfo)) {\n classList.remove(name);\n this._previousClasses!.delete(name);\n }\n });\n\n // Add or remove classes based on their classMap value\n for (const name in classInfo) {\n // We explicitly want a loose truthy check of `value` because it seems\n // more convenient that '' and 0 are skipped.\n const value = !!classInfo[name];\n if (\n value !== this._previousClasses.has(name) &&\n !this._staticClasses?.has(name)\n ) {\n if (value) {\n classList.add(name);\n this._previousClasses.add(name);\n } else {\n classList.remove(name);\n this._previousClasses.delete(name);\n }\n }\n }\n return noChange;\n }\n}\n\n/**\n * A directive that applies dynamic CSS classes.\n *\n * This must be used in the `class` attribute and must be the only part used in\n * the attribute. It takes each property in the `classInfo` argument and adds\n * the property name to the element's `classList` if the property value is\n * truthy; if the property value is falsey, the property name is removed from\n * the element's `class`.\n *\n * For example `{foo: bar}` applies the class `foo` if the value of `bar` is\n * truthy.\n *\n * @param classInfo\n */\nexport const classMap = directive(ClassMapDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {ClassMapDirective};\n"],"names":["classMap","directive","Directive","constructor","partInfo","super","type","PartType","ATTRIBUTE","name","strings","length","Error","render","classInfo","Object","keys","filter","key","join","update","part","undefined","this","_previousClasses","Set","_staticClasses","split","s","has","add","classList","element","forEach","remove","delete","value","noChange"],"mappings":";;;;;SA2HaA,EAAWC,EArGxB,cAAgCC,EAQ9BC,YAAYC,SAEV,GADAC,MAAMD,GAEJA,EAASE,OAASC,EAASC,WACT,UAAlBJ,EAASK,iBACRL,EAASM,8BAASC,QAAoB,EAEvC,MAAUC,MACR,sGAMNC,OAAOC,GAEL,MACE,IACAC,OAAOC,KAAKF,GACTG,QAAQC,GAAQJ,EAAUI,KAC1BC,KAAK,KACR,IAIKC,OAAOC,GAAsBP,YAEpC,QAA8BQ,IAA1BC,KAAKC,GAAgC,CACvCD,KAAKC,GAAmB,IAAIC,SACPH,IAAjBD,EAAKX,UACPa,KAAKG,GAAiB,IAAID,IACxBJ,EAAKX,QACFS,KAAK,KACLQ,MAAM,MACNV,QAAQW,GAAY,KAANA,MAGrB,IAAK,MAAMnB,KAAQK,EACbA,EAAUL,gBAAUc,KAAKG,yBAAgBG,IAAIpB,KAC/Cc,KAAKC,GAAiBM,IAAIrB,GAG9B,OAAOc,KAAKV,OAAOC,GAGrB,MAAMiB,EAAYV,EAAKW,QAAQD,UAK/BR,KAAKC,GAAiBS,SAASxB,IACvBA,KAAQK,IACZiB,EAAUG,OAAOzB,GACjBc,KAAKC,GAAkBW,OAAO1B,OAKlC,IAAK,MAAMA,KAAQK,EAAW,CAG5B,MAAMsB,IAAUtB,EAAUL,GAExB2B,IAAUb,KAAKC,GAAiBK,IAAIpB,eACnCc,KAAKG,yBAAgBG,IAAIpB,MAEtB2B,GACFL,EAAUD,IAAIrB,GACdc,KAAKC,GAAiBM,IAAIrB,KAE1BsB,EAAUG,OAAOzB,GACjBc,KAAKC,GAAiBW,OAAO1B,KAInC,OAAO4B"}
@@ -3,9 +3,8 @@
3
3
  * Copyright 2018 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { Directive, DirectiveParameters } from '../directive.js';
7
6
  import { Part } from '../lit-html.js';
8
-
7
+ import { Directive, DirectiveParameters } from '../directive.js';
9
8
  declare class GuardDirective extends Directive {
10
9
  private _previousValue;
11
10
  render(_value: unknown, f: () => unknown): unknown;
@@ -28,6 +27,7 @@ declare class GuardDirective extends Directive {
28
27
  * <div>
29
28
  * ${guard([user.id, company.id], () => html`...`)}
30
29
  * </div>
30
+ * `
31
31
  * ```
32
32
  *
33
33
  * In this case, the template only rerenders if either `user.id` or `company.id`
@@ -43,6 +43,7 @@ declare class GuardDirective extends Directive {
43
43
  * <div>
44
44
  * ${guard([immutableItems], () => immutableItems.map(i => html`${i}`))}
45
45
  * </div>
46
+ * `
46
47
  * ```
47
48
  *
48
49
  * In this case, items are mapped over only when the array reference changes.
@@ -1 +1 @@
1
- {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/directives/guard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAY,SAAS,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAK1E,cAAM,cAAe,SAAQ,SAAS;IACpC,OAAO,CAAC,cAAc,CAAyB;IAE/C,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,OAAO;IAIxC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CAqB1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,KAAK,6BAlEiB,OAAO,qEAkEI,CAAC;AAE/C;;;GAGG;AACH,YAAY,EAAC,cAAc,EAAC,CAAC"}
1
+ {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/directives/guard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAY,SAAS,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAK1E,cAAM,cAAe,SAAQ,SAAS;IACpC,OAAO,CAAC,cAAc,CAAyB;IAE/C,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,OAAO;IAI/B,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CAqBnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,KAAK,6BApEiB,OAAO,qEAoEI,CAAC;AAE/C;;;GAGG;AACH,YAAY,EAAC,cAAc,EAAC,CAAC"}
@@ -1,10 +1,8 @@
1
- import{directive as t,Directive as s}from"../directive.js";
2
- import{noChange as r}from"../lit-html.js";
3
-
1
+ import{noChange as r}from"../lit-html.js";import{directive as t,Directive as s}from"../directive.js";
4
2
  /**
5
3
  * @license
6
4
  * Copyright 2018 Google LLC
7
5
  * SPDX-License-Identifier: BSD-3-Clause
8
6
  */
9
- const e={},i=t(class extends s{constructor(){super(...arguments),this.$t=e}render(r,t){return t()}update(t,[s,e]){if(Array.isArray(s)){if(Array.isArray(this.$t)&&this.$t.length===s.length&&s.every(((r,t)=>r===this.$t[t])))return r}else if(this.$t===s)return r;return this.$t=Array.isArray(s)?Array.from(s):s,this.render(s,e)}});export{i as guard};
7
+ const e={},i=t(class extends s{constructor(){super(...arguments),this.ot=e}render(r,t){return t()}update(t,[s,e]){if(Array.isArray(s)){if(Array.isArray(this.ot)&&this.ot.length===s.length&&s.every(((r,t)=>r===this.ot[t])))return r}else if(this.ot===s)return r;return this.ot=Array.isArray(s)?Array.from(s):s,this.render(s,e)}});export{i as guard};
10
8
  //# sourceMappingURL=guard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sources":["../src/directives/guard.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {noChange, Part} from '../lit-html.js';\nimport {directive, Directive, DirectiveParameters} from '../directive.js';\n\n// A sentinal that indicates guard() hasn't rendered anything yet\nconst initialValue = {};\n\nclass GuardDirective extends Directive {\n private _previousValue: unknown = initialValue;\n\n render(_value: unknown, f: () => unknown) {\n return f();\n }\n\n update(_part: Part, [value, f]: DirectiveParameters<this>) {\n if (Array.isArray(value)) {\n // Dirty-check arrays by item\n if (\n Array.isArray(this._previousValue) &&\n this._previousValue.length === value.length &&\n value.every((v, i) => v === (this._previousValue as Array<unknown>)[i])\n ) {\n return noChange;\n }\n } else if (this._previousValue === value) {\n // Dirty-check non-arrays by identity\n return noChange;\n }\n\n // Copy the value if it's an array so that if it's mutated we don't forget\n // what the previous values were.\n this._previousValue = Array.isArray(value) ? Array.from(value) : value;\n const r = this.render(value, f);\n return r;\n }\n}\n\n/**\n * Prevents re-render of a template function until a single value or an array of\n * values changes.\n *\n * Values are checked against previous values with strict equality (`===`), and\n * so the check won't detect nested property changes inside objects or arrays.\n * Arrays values have each item checked against the previous value at the same\n * index with strict equality. Nested arrays are also checked only by strict\n * equality.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([user.id, company.id], () => html`...`)}\n * </div>\n * ```\n *\n * In this case, the template only rerenders if either `user.id` or `company.id`\n * changes.\n *\n * guard() is useful with immutable data patterns, by preventing expensive work\n * until data updates.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([immutableItems], () => immutableItems.map(i => html`${i}`))}\n * </div>\n * ```\n *\n * In this case, items are mapped over only when the array reference changes.\n *\n * @param value the value to check before re-rendering\n * @param f the template function\n */\nexport const guard = directive(GuardDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {GuardDirective};\n"],"names":["initialValue","guard","directive","Directive","[object Object]","this","_value","f","_part","value","Array","isArray","_previousValue","length","every","v","i","noChange","from","render"],"mappings":";;;;;;AAUA,MAAMA,EAAe,GAuERC,EAAQC,EArErB,cAA6BC,EAA7BC,kCACUC,QAA0BL,EAElCI,OAAOE,EAAiBC,GACtB,OAAOA,IAGTH,OAAOI,GAAcC,EAAOF,IAC1B,GAAIG,MAAMC,QAAQF,IAEhB,GACEC,MAAMC,QAAQN,KAAKO,KACnBP,KAAKO,GAAeC,SAAWJ,EAAMI,QACrCJ,EAAMK,OAAM,CAACC,EAAGC,IAAMD,IAAOV,KAAKO,GAAkCI,KAEpE,OAAOC,OAEJ,GAAIZ,KAAKO,KAAmBH,EAEjC,OAAOQ,EAOT,OAFAZ,KAAKO,GAAiBF,MAAMC,QAAQF,GAASC,MAAMQ,KAAKT,GAASA,EACvDJ,KAAKc,OAAOV,EAAOF"}
1
+ {"version":3,"file":"guard.js","sources":["../src/directives/guard.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {noChange, Part} from '../lit-html.js';\nimport {directive, Directive, DirectiveParameters} from '../directive.js';\n\n// A sentinal that indicates guard() hasn't rendered anything yet\nconst initialValue = {};\n\nclass GuardDirective extends Directive {\n private _previousValue: unknown = initialValue;\n\n render(_value: unknown, f: () => unknown) {\n return f();\n }\n\n override update(_part: Part, [value, f]: DirectiveParameters<this>) {\n if (Array.isArray(value)) {\n // Dirty-check arrays by item\n if (\n Array.isArray(this._previousValue) &&\n this._previousValue.length === value.length &&\n value.every((v, i) => v === (this._previousValue as Array<unknown>)[i])\n ) {\n return noChange;\n }\n } else if (this._previousValue === value) {\n // Dirty-check non-arrays by identity\n return noChange;\n }\n\n // Copy the value if it's an array so that if it's mutated we don't forget\n // what the previous values were.\n this._previousValue = Array.isArray(value) ? Array.from(value) : value;\n const r = this.render(value, f);\n return r;\n }\n}\n\n/**\n * Prevents re-render of a template function until a single value or an array of\n * values changes.\n *\n * Values are checked against previous values with strict equality (`===`), and\n * so the check won't detect nested property changes inside objects or arrays.\n * Arrays values have each item checked against the previous value at the same\n * index with strict equality. Nested arrays are also checked only by strict\n * equality.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([user.id, company.id], () => html`...`)}\n * </div>\n * `\n * ```\n *\n * In this case, the template only rerenders if either `user.id` or `company.id`\n * changes.\n *\n * guard() is useful with immutable data patterns, by preventing expensive work\n * until data updates.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([immutableItems], () => immutableItems.map(i => html`${i}`))}\n * </div>\n * `\n * ```\n *\n * In this case, items are mapped over only when the array reference changes.\n *\n * @param value the value to check before re-rendering\n * @param f the template function\n */\nexport const guard = directive(GuardDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {GuardDirective};\n"],"names":["initialValue","guard","directive","Directive","constructor","this","render","_value","f","update","_part","value","Array","isArray","_previousValue","length","every","v","i","noChange","from"],"mappings":";;;;;;AAUA,MAAMA,EAAe,GAyERC,EAAQC,EAvErB,cAA6BC,EAA7BC,kCACUC,QAA0BL,EAElCM,OAAOC,EAAiBC,GACtB,OAAOA,IAGAC,OAAOC,GAAcC,EAAOH,IACnC,GAAII,MAAMC,QAAQF,IAEhB,GACEC,MAAMC,QAAQR,KAAKS,KACnBT,KAAKS,GAAeC,SAAWJ,EAAMI,QACrCJ,EAAMK,OAAM,CAACC,EAAGC,IAAMD,IAAOZ,KAAKS,GAAkCI,KAEpE,OAAOC,OAEJ,GAAId,KAAKS,KAAmBH,EAEjC,OAAOQ,EAOT,OAFAd,KAAKS,GAAiBF,MAAMC,QAAQF,GAASC,MAAMQ,KAAKT,GAASA,EACvDN,KAAKC,OAAOK,EAAOH"}
@@ -3,9 +3,8 @@
3
3
  * Copyright 2020 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
7
6
  import { AttributePart } from '../lit-html.js';
8
-
7
+ import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
9
8
  declare class LiveDirective extends Directive {
10
9
  constructor(partInfo: PartInfo);
11
10
  render(value: unknown): unknown;
@@ -25,7 +24,9 @@ declare class LiveDirective extends Directive {
25
24
  * it alone. If this is not what you want--if you want to overwrite the DOM
26
25
  * value with the bound value no matter what--use the `live()` directive:
27
26
  *
28
- * html`<input .value=${live(x)}>`
27
+ * ```js
28
+ * html`<input .value=${live(x)}>`
29
+ * ```
29
30
  *
30
31
  * `live()` performs a strict equality check agains the live DOM value, and if
31
32
  * the new value is equal to the live value, does nothing. This means that
@@ -1 +1 @@
1
- {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../src/directives/live.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAoB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EAET,MAAM,iBAAiB,CAAC;AAGzB,cAAM,aAAc,SAAQ,SAAS;gBACvB,QAAQ,EAAE,QAAQ;IAkB9B,MAAM,CAAC,KAAK,EAAE,OAAO;IAIrB,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CA6B/D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,IAAI,qFAA2B,CAAC;AAE7C;;;GAGG;AACH,YAAY,EAAC,aAAa,EAAC,CAAC"}
1
+ {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../src/directives/live.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAoB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EAET,MAAM,iBAAiB,CAAC;AAGzB,cAAM,aAAc,SAAQ,SAAS;gBACvB,QAAQ,EAAE,QAAQ;IAkB9B,MAAM,CAAC,KAAK,EAAE,OAAO;IAIZ,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CA0BxE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,IAAI,qFAA2B,CAAC;AAE7C;;;GAGG;AACH,YAAY,EAAC,aAAa,EAAC,CAAC"}
@@ -1,7 +1,4 @@
1
- import{isSingleExpression as o,setCommittedValue as s}from"../directive-helpers.js";
2
- import{directive as i,Directive as t,PartType as n}from"../directive.js";
3
- import{noChange as r,nothing as e}from"../lit-html.js";
4
-
1
+ import{noChange as r,nothing as e}from"../lit-html.js";import{directive as i,Directive as t,PartType as n}from"../directive.js";import{isSingleExpression as o,setCommittedValue as s}from"../directive-helpers.js";
5
2
  /**
6
3
  * @license
7
4
  * Copyright 2020 Google LLC
@@ -1 +1 @@
1
- {"version":3,"file":"live.js","sources":["../src/directives/live.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange, nothing} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {isSingleExpression, setCommittedValue} from '../directive-helpers.js';\n\nclass LiveDirective extends Directive {\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n !(\n partInfo.type === PartType.PROPERTY ||\n partInfo.type === PartType.ATTRIBUTE ||\n partInfo.type === PartType.BOOLEAN_ATTRIBUTE\n )\n ) {\n throw new Error(\n 'The `live` directive is not allowed on child or event bindings'\n );\n }\n if (!isSingleExpression(partInfo)) {\n throw new Error('`live` bindings can only contain a single expression');\n }\n }\n\n render(value: unknown) {\n return value;\n }\n\n update(part: AttributePart, [value]: DirectiveParameters<this>) {\n if (value === noChange || value === nothing) {\n return value;\n }\n const element = part.element;\n const name = part.name;\n\n // TODO (justinfagnani): This is essentially implementing a getLiveValue()\n // method for each part type. Should that be moved into the AttributePart\n // interface?\n if (part.type === PartType.PROPERTY) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (value === (element as any)[name]) {\n return noChange;\n }\n } else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {\n if (!!value === element.hasAttribute(name)) {\n return noChange;\n }\n } else if (part.type === PartType.ATTRIBUTE) {\n if (element.getAttribute(name) === String(value)) {\n return noChange;\n }\n }\n // Resets the part's value, causing its dirty-check to fail so that it\n // always sets the value.\n setCommittedValue(part);\n return value;\n }\n}\n\n/**\n * Checks binding values against live DOM values, instead of previously bound\n * values, when determining whether to update the value.\n *\n * This is useful for cases where the DOM value may change from outside of\n * lit-html, such as with a binding to an `<input>` element's `value` property,\n * a content editable elements text, or to a custom element that changes it's\n * own properties or attributes.\n *\n * In these cases if the DOM value changes, but the value set through lit-html\n * bindings hasn't, lit-html won't know to update the DOM value and will leave\n * it alone. If this is not what you want--if you want to overwrite the DOM\n * value with the bound value no matter what--use the `live()` directive:\n *\n * html`<input .value=${live(x)}>`\n *\n * `live()` performs a strict equality check agains the live DOM value, and if\n * the new value is equal to the live value, does nothing. This means that\n * `live()` should not be used when the binding will cause a type conversion. If\n * you use `live()` with an attribute binding, make sure that only strings are\n * passed in, or the binding will update every render.\n */\nexport const live = directive(LiveDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {LiveDirective};\n"],"names":["live","directive","Directive","[object Object]","partInfo","super","type","PartType","PROPERTY","ATTRIBUTE","BOOLEAN_ATTRIBUTE","Error","isSingleExpression","value","part","noChange","nothing","element","name","hasAttribute","getAttribute","String","setCommittedValue"],"mappings":";;;;;SA4FaA,EAAOC,EA5EpB,cAA4BC,EAC1BC,YAAYC,GAEV,GADAC,MAAMD,GAGFA,EAASE,OAASC,EAASC,UAC3BJ,EAASE,OAASC,EAASE,WAC3BL,EAASE,OAASC,EAASG,kBAG7B,MAAUC,MACR,kEAGJ,IAAKC,EAAmBR,GACtB,MAAUO,MAAM,wDAIpBR,OAAOU,GACL,OAAOA,EAGTV,OAAOW,GAAsBD,IAC3B,GAAIA,IAAUE,GAAYF,IAAUG,EAClC,OAAOH,EAET,MAAMI,EAAUH,EAAKG,QACfC,EAAOJ,EAAKI,KAKlB,GAAIJ,EAAKR,OAASC,EAASC,UAEzB,GAAIK,IAAWI,EAAgBC,GAC7B,OAAOH,OAEJ,GAAID,EAAKR,OAASC,EAASG,mBAChC,KAAMG,IAAUI,EAAQE,aAAaD,GACnC,OAAOH,OAEJ,GAAID,EAAKR,OAASC,EAASE,WAC5BQ,EAAQG,aAAaF,KAAiBL,EAAPQ,GACjC,OAAON,EAMX,OADAO,EAAkBR,GACXD"}
1
+ {"version":3,"file":"live.js","sources":["../src/directives/live.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange, nothing} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {isSingleExpression, setCommittedValue} from '../directive-helpers.js';\n\nclass LiveDirective extends Directive {\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n !(\n partInfo.type === PartType.PROPERTY ||\n partInfo.type === PartType.ATTRIBUTE ||\n partInfo.type === PartType.BOOLEAN_ATTRIBUTE\n )\n ) {\n throw new Error(\n 'The `live` directive is not allowed on child or event bindings'\n );\n }\n if (!isSingleExpression(partInfo)) {\n throw new Error('`live` bindings can only contain a single expression');\n }\n }\n\n render(value: unknown) {\n return value;\n }\n\n override update(part: AttributePart, [value]: DirectiveParameters<this>) {\n if (value === noChange || value === nothing) {\n return value;\n }\n const element = part.element;\n const name = part.name;\n\n if (part.type === PartType.PROPERTY) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (value === (element as any)[name]) {\n return noChange;\n }\n } else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {\n if (!!value === element.hasAttribute(name)) {\n return noChange;\n }\n } else if (part.type === PartType.ATTRIBUTE) {\n if (element.getAttribute(name) === String(value)) {\n return noChange;\n }\n }\n // Resets the part's value, causing its dirty-check to fail so that it\n // always sets the value.\n setCommittedValue(part);\n return value;\n }\n}\n\n/**\n * Checks binding values against live DOM values, instead of previously bound\n * values, when determining whether to update the value.\n *\n * This is useful for cases where the DOM value may change from outside of\n * lit-html, such as with a binding to an `<input>` element's `value` property,\n * a content editable elements text, or to a custom element that changes it's\n * own properties or attributes.\n *\n * In these cases if the DOM value changes, but the value set through lit-html\n * bindings hasn't, lit-html won't know to update the DOM value and will leave\n * it alone. If this is not what you want--if you want to overwrite the DOM\n * value with the bound value no matter what--use the `live()` directive:\n *\n * ```js\n * html`<input .value=${live(x)}>`\n * ```\n *\n * `live()` performs a strict equality check agains the live DOM value, and if\n * the new value is equal to the live value, does nothing. This means that\n * `live()` should not be used when the binding will cause a type conversion. If\n * you use `live()` with an attribute binding, make sure that only strings are\n * passed in, or the binding will update every render.\n */\nexport const live = directive(LiveDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {LiveDirective};\n"],"names":["live","directive","Directive","constructor","partInfo","super","type","PartType","PROPERTY","ATTRIBUTE","BOOLEAN_ATTRIBUTE","Error","isSingleExpression","render","value","update","part","noChange","nothing","element","name","hasAttribute","getAttribute","String","setCommittedValue"],"mappings":";;;;;SA2FaA,EAAOC,EA3EpB,cAA4BC,EAC1BC,YAAYC,GAEV,GADAC,MAAMD,GAGFA,EAASE,OAASC,EAASC,UAC3BJ,EAASE,OAASC,EAASE,WAC3BL,EAASE,OAASC,EAASG,kBAG7B,MAAUC,MACR,kEAGJ,IAAKC,EAAmBR,GACtB,MAAUO,MAAM,wDAIpBE,OAAOC,GACL,OAAOA,EAGAC,OAAOC,GAAsBF,IACpC,GAAIA,IAAUG,GAAYH,IAAUI,EAClC,OAAOJ,EAET,MAAMK,EAAUH,EAAKG,QACfC,EAAOJ,EAAKI,KAElB,GAAIJ,EAAKV,OAASC,EAASC,UAEzB,GAAIM,IAAWK,EAAgBC,GAC7B,OAAOH,OAEJ,GAAID,EAAKV,OAASC,EAASG,mBAChC,KAAMI,IAAUK,EAAQE,aAAaD,GACnC,OAAOH,OAEJ,GAAID,EAAKV,OAASC,EAASE,WAC5BU,EAAQG,aAAaF,KAAiBN,EAAPS,GACjC,OAAON,EAMX,OADAO,EAAkBR,GACXF"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Helper to iterate an AsyncIterable in its own closure.
8
+ * @param iterable The iterable to iterate
9
+ * @param callback The callback to call for each value. If the callback returns
10
+ * `false`, the loop will be broken.
11
+ */
12
+ export declare const forAwaitOf: <T>(iterable: AsyncIterable<T>, callback: (value: T) => Promise<boolean>) => Promise<void>;
13
+ /**
14
+ * Holds a reference to an instance that can be disconnected and reconnected,
15
+ * so that a closure over the ref (e.g. in a then function to a promise) does
16
+ * not strongly hold a ref to the instance. Approximates a WeakRef but must
17
+ * be manually connected & disconnected to the backing instance.
18
+ */
19
+ export declare class PseudoWeakRef<T> {
20
+ private _ref?;
21
+ constructor(ref: T);
22
+ /**
23
+ * Disassociates the ref with the backing instance.
24
+ */
25
+ disconnect(): void;
26
+ /**
27
+ * Reassociates the ref with the backing instance.
28
+ */
29
+ reconnect(ref: T): void;
30
+ /**
31
+ * Retrieves the backing instance (will be undefined when disconnected)
32
+ */
33
+ deref(): T | undefined;
34
+ }
35
+ /**
36
+ * A helper to pause and resume waiting on a condition in an async function
37
+ */
38
+ export declare class Pauser {
39
+ private _promise?;
40
+ private _resolve?;
41
+ /**
42
+ * When paused, returns a promise to be awaited; when unpaused, returns
43
+ * undefined. Note that in the microtask between the pauser being resumed
44
+ * an an await of this promise resolving, the pauser could be paused again,
45
+ * hence callers should check the promise in a loop when awaiting.
46
+ * @returns A promise to be awaited when paused or undefined
47
+ */
48
+ get(): Promise<void> | undefined;
49
+ /**
50
+ * Creates a promise to be awaited
51
+ */
52
+ pause(): void;
53
+ /**
54
+ * Resolves the promise which may be awaited
55
+ */
56
+ resume(): void;
57
+ }
58
+ //# sourceMappingURL=private-async-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-async-helpers.d.ts","sourceRoot":"","sources":["../../src/directives/private-async-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,UAAU,0DAEG,QAAQ,OAAO,CAAC,kBAOzC,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,aAAa,CAAC,CAAC;IAC1B,OAAO,CAAC,IAAI,CAAC,CAAI;gBACL,GAAG,EAAE,CAAC;IAGlB;;OAEG;IACH,UAAU;IAGV;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,CAAC;IAGhB;;OAEG;IACH,KAAK;CAGN;AAED;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,CAA4B;IAC7C,OAAO,CAAC,QAAQ,CAAC,CAAyB;IAC1C;;;;;;OAMG;IACH,GAAG;IAGH;;OAEG;IACH,KAAK;IAGL;;OAEG;IACH,MAAM;CAIP"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ const t=async(t,s)=>{for await(const i of t)if(!1===await s(i))return};class s{constructor(t){this.U=t}disconnect(){this.U=void 0}reconnect(t){this.U=t}deref(){return this.U}}class i{constructor(){this.Y=void 0,this.q=void 0}get(){return this.Y}pause(){var t;null!==(t=this.Y)&&void 0!==t||(this.Y=new Promise((t=>this.q=t)))}resume(){var t;null===(t=this.q)||void 0===t||t.call(this),this.Y=this.q=void 0}}export{i as Pauser,s as PseudoWeakRef,t as forAwaitOf};
7
+ //# sourceMappingURL=private-async-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-async-helpers.js","sources":["../src/directives/private-async-helpers.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// Note, this module is not included in package exports so that it's private to\n// our first-party directives. If it ends up being useful, we can open it up and\n// export it.\n\n/**\n * Helper to iterate an AsyncIterable in its own closure.\n * @param iterable The iterable to iterate\n * @param callback The callback to call for each value. If the callback returns\n * `false`, the loop will be broken.\n */\nexport const forAwaitOf = async <T>(\n iterable: AsyncIterable<T>,\n callback: (value: T) => Promise<boolean>\n) => {\n for await (const v of iterable) {\n if ((await callback(v)) === false) {\n return;\n }\n }\n};\n\n/**\n * Holds a reference to an instance that can be disconnected and reconnected,\n * so that a closure over the ref (e.g. in a then function to a promise) does\n * not strongly hold a ref to the instance. Approximates a WeakRef but must\n * be manually connected & disconnected to the backing instance.\n */\nexport class PseudoWeakRef<T> {\n private _ref?: T;\n constructor(ref: T) {\n this._ref = ref;\n }\n /**\n * Disassociates the ref with the backing instance.\n */\n disconnect() {\n this._ref = undefined;\n }\n /**\n * Reassociates the ref with the backing instance.\n */\n reconnect(ref: T) {\n this._ref = ref;\n }\n /**\n * Retrieves the backing instance (will be undefined when disconnected)\n */\n deref() {\n return this._ref;\n }\n}\n\n/**\n * A helper to pause and resume waiting on a condition in an async function\n */\nexport class Pauser {\n private _promise?: Promise<void> = undefined;\n private _resolve?: () => void = undefined;\n /**\n * When paused, returns a promise to be awaited; when unpaused, returns\n * undefined. Note that in the microtask between the pauser being resumed\n * an an await of this promise resolving, the pauser could be paused again,\n * hence callers should check the promise in a loop when awaiting.\n * @returns A promise to be awaited when paused or undefined\n */\n get() {\n return this._promise;\n }\n /**\n * Creates a promise to be awaited\n */\n pause() {\n this._promise ??= new Promise((resolve) => (this._resolve = resolve));\n }\n /**\n * Resolves the promise which may be awaited\n */\n resume() {\n this._resolve?.();\n this._promise = this._resolve = undefined;\n }\n}\n"],"names":["forAwaitOf","async","iterable","callback","v","PseudoWeakRef","constructor","ref","this","_ref","disconnect","undefined","reconnect","deref","Pauser","get","_promise","pause","Promise","resolve","_resolve","resume"],"mappings":";;;;;MAgBaA,EAAaC,MACxBC,EACAC,KAEA,UAAW,MAAMC,KAAKF,EACpB,IAA4B,UAAjBC,EAASC,GAClB,cAWOC,EAEXC,YAAYC,GACVC,KAAKC,EAAOF,EAKdG,aACEF,KAAKC,OAAOE,EAKdC,UAAUL,GACRC,KAAKC,EAAOF,EAKdM,QACE,OAAOL,KAAKC,SAOHK,EAAbR,cACUE,YAA2BG,EAC3BH,YAAwBG,EAQhCI,MACE,OAAOP,KAAKQ,EAKdC,wBACET,KAAKQ,iBAALR,KAAKQ,EAAa,IAAIE,SAASC,GAAaX,KAAKY,EAAWD,KAK9DE,yBACEb,KAAKY,uBAALZ,MACAA,KAAKQ,EAAWR,KAAKY,OAAWT"}
@@ -3,13 +3,15 @@
3
3
  * Copyright 2020 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- import { AsyncDirective } from '../async-directive.js';
7
6
  import { ElementPart } from '../lit-html.js';
8
-
7
+ import { AsyncDirective } from '../async-directive.js';
9
8
  /**
10
9
  * Creates a new Ref object, which is container for a reference to an element.
11
10
  */
12
11
  export declare const createRef: <T = Element>() => Ref<T>;
12
+ /**
13
+ * An object that holds a ref value.
14
+ */
13
15
  declare class Ref<T = Element> {
14
16
  /**
15
17
  * The current Element value of the ref, or else `undefined` if the ref is no
@@ -17,6 +19,7 @@ declare class Ref<T = Element> {
17
19
  */
18
20
  readonly value?: T;
19
21
  }
22
+ export type { Ref };
20
23
  export declare type RefOrCallback = Ref | ((el: Element | undefined) => void);
21
24
  declare class RefDirective extends AsyncDirective {
22
25
  private _element?;
@@ -43,16 +46,16 @@ declare class RefDirective extends AsyncDirective {
43
46
  * removed in a subsequent render, it will first be called with `undefined`,
44
47
  * followed by another call with the new element it was rendered to (if any).
45
48
  *
46
- * @example
47
- *
48
- * // Using Ref object
49
- * const inputRef = createRef();
50
- * render(html`<input ${ref(inputRef)}>`, container);
51
- * inputRef.value.focus();
49
+ * ```js
50
+ * // Using Ref object
51
+ * const inputRef = createRef();
52
+ * render(html`<input ${ref(inputRef)}>`, container);
53
+ * inputRef.value.focus();
52
54
  *
53
- * // Using callback
54
- * const callback = (inputElement) => inputElement.focus();
55
- * render(html`<input ${ref(callback)}>`, container);
55
+ * // Using callback
56
+ * const callback = (inputElement) => inputElement.focus();
57
+ * render(html`<input ${ref(callback)}>`, container);
58
+ * ```
56
59
  */
57
60
  export declare const ref: (_ref: RefOrCallback) => import("../directive.js").DirectiveResult<typeof RefDirective>;
58
61
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/directives/ref.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAU,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAY,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,SAAS,2BAAkC,CAAC;AAEzD,cAAM,GAAG,CAAC,CAAC,GAAG,OAAO;IACnB;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACpB;AAcD,oBAAY,aAAa,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,KAAK,IAAI,CAAC,CAAC;AAEtE,cAAM,YAAa,SAAQ,cAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,CAAU;IAC3B,OAAO,CAAC,IAAI,CAAC,CAAgB;IAC7B,OAAO,CAAC,QAAQ,CAAU;IAE1B,MAAM,CAAC,IAAI,EAAE,aAAa;IAI1B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAiB3D,OAAO,CAAC,eAAe;IAqBvB,OAAO,KAAK,kBAAkB,GAI7B;IAED,YAAY;IAUZ,WAAW;CAKZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,GAAG,yFAA0B,CAAC;AAE3C;;;GAGG;AACH,YAAY,EAAC,YAAY,EAAC,CAAC"}
1
+ {"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/directives/ref.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAU,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAY,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,SAAS,2BAAkC,CAAC;AAEzD;;GAEG;AACH,cAAM,GAAG,CAAC,CAAC,GAAG,OAAO;IACnB;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACpB;AAED,YAAY,EAAC,GAAG,EAAC,CAAC;AAYlB,oBAAY,aAAa,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,KAAK,IAAI,CAAC,CAAC;AAEtE,cAAM,YAAa,SAAQ,cAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,CAAU;IAC3B,OAAO,CAAC,IAAI,CAAC,CAAgB;IAC7B,OAAO,CAAC,QAAQ,CAAU;IAE1B,MAAM,CAAC,IAAI,EAAE,aAAa;IAIjB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAiBpE,OAAO,CAAC,eAAe;IAqBvB,OAAO,KAAK,kBAAkB,GAI7B;IAEQ,YAAY;IAUZ,WAAW;CAKrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,GAAG,yFAA0B,CAAC;AAE3C;;;GAGG;AACH,YAAY,EAAC,YAAY,EAAC,CAAC"}
@@ -1,10 +1,7 @@
1
- import{AsyncDirective as s}from"../async-directive.js";
2
- import{directive as i}from"../directive.js";
3
- import{nothing as t}from"../lit-html.js";
4
-
1
+ import{nothing as t}from"../lit-html.js";import{AsyncDirective as i}from"../async-directive.js";import{directive as s}from"../directive.js";
5
2
  /**
6
3
  * @license
7
4
  * Copyright 2020 Google LLC
8
5
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const e=()=>new o;class o{}const h=new WeakMap,n=i(class extends s{render(i){return t}update(i,[s]){var e;const o=s!==this.gt;return o&&void 0!==this.gt&&this.xt(void 0),(o||this.Tt!==this.Et)&&(this.gt=s,this.At=null===(e=i.options)||void 0===e?void 0:e.host,this.xt(this.Et=i.element)),t}xt(t){"function"==typeof this.gt?(void 0!==h.get(this.gt)&&this.gt.call(this.At,void 0),h.set(this.gt,t),void 0!==t&&this.gt.call(this.At,t)):this.gt.value=t}get Tt(){var t;return"function"==typeof this.gt?h.get(this.gt):null===(t=this.gt)||void 0===t?void 0:t.value}disconnected(){this.Tt===this.Et&&this.xt(void 0)}reconnected(){this.xt(this.Et)}});export{e as createRef,n as ref};
6
+ */const e=()=>new o;class o{}const h=new WeakMap,n=s(class extends i{render(i){return t}update(i,[s]){var e;const o=s!==this.U;return o&&void 0!==this.U&&this.nt(void 0),(o||this.rt!==this.lt)&&(this.U=s,this.ht=null===(e=i.options)||void 0===e?void 0:e.host,this.nt(this.lt=i.element)),t}nt(t){"function"==typeof this.U?(void 0!==h.get(this.U)&&this.U.call(this.ht,void 0),h.set(this.U,t),void 0!==t&&this.U.call(this.ht,t)):this.U.value=t}get rt(){var t;return"function"==typeof this.U?h.get(this.U):null===(t=this.U)||void 0===t?void 0:t.value}disconnected(){this.rt===this.lt&&this.nt(void 0)}reconnected(){this.nt(this.lt)}});export{e as createRef,n as ref};
10
7
  //# sourceMappingURL=ref.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ref.js","sources":["../src/directives/ref.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport {nothing, ElementPart} from '../lit-html.js';\nimport {directive, AsyncDirective} from '../async-directive.js';\n\n/**\n * Creates a new Ref object, which is container for a reference to an element.\n */\nexport const createRef = <T = Element>() => new Ref<T>();\n\nclass Ref<T = Element> {\n /**\n * The current Element value of the ref, or else `undefined` if the ref is no\n * longer rendered.\n */\n readonly value?: T;\n}\n\ninterface RefInternal {\n value: Element | undefined;\n}\n\n// When callbacks are used for refs, this map tracks the last value the callback\n// was called with, for ensuring a directive doesn't clear the ref if the ref\n// has already been rendered to a new spot\nconst lastElementForCallback: WeakMap<\n Function,\n Element | undefined\n> = new WeakMap();\n\nexport type RefOrCallback = Ref | ((el: Element | undefined) => void);\n\nclass RefDirective extends AsyncDirective {\n private _element?: Element;\n private _ref?: RefOrCallback;\n private _context: unknown;\n\n render(_ref: RefOrCallback) {\n return nothing;\n }\n\n update(part: ElementPart, [ref]: Parameters<this['render']>) {\n const refChanged = ref !== this._ref;\n if (refChanged && this._ref !== undefined) {\n // The ref passed to the directive has changed;\n // unset the previous ref's value\n this._updateRefValue(undefined);\n }\n if (refChanged || this._lastElementForRef !== this._element) {\n // We either got a new ref or this is the first render;\n // store the ref/element & update the ref value\n this._ref = ref;\n this._context = part.options?.host;\n this._updateRefValue((this._element = part.element));\n }\n return nothing;\n }\n\n private _updateRefValue(element: Element | undefined) {\n if (typeof this._ref === 'function') {\n // If the current ref was called with a previous value, call with\n // `undefined`; We do this to ensure callbacks are called in a consistent\n // way regardless of whether a ref might be moving up in the tree (in\n // which case it would otherwise be called with the new value before the\n // previous one unsets it) and down in the tree (where it would be unset\n // before being set)\n if (lastElementForCallback.get(this._ref) !== undefined) {\n this._ref.call(this._context, undefined);\n }\n lastElementForCallback.set(this._ref, element);\n // Call the ref with the new element value\n if (element !== undefined) {\n this._ref.call(this._context, element);\n }\n } else {\n (this._ref as RefInternal)!.value = element;\n }\n }\n\n private get _lastElementForRef() {\n return typeof this._ref === 'function'\n ? lastElementForCallback.get(this._ref)\n : this._ref?.value;\n }\n\n disconnected() {\n // Only clear the box if our element is still the one in it (i.e. another\n // directive instance hasn't rendered its element to it before us); that\n // only happens in the event of the directive being cleared (not via manual\n // disconnection)\n if (this._lastElementForRef === this._element) {\n this._updateRefValue(undefined);\n }\n }\n\n reconnected() {\n // If we were manually disconnected, we can safely put our element back in\n // the box, since no rendering could have occurred to change its state\n this._updateRefValue(this._element);\n }\n}\n\n/**\n * Sets the value of a Ref object or calls a ref callback with the element it's\n * bound to.\n *\n * A Ref object acts as a container for a reference to an element. A ref\n * callback is a function that takes an element as its only argument.\n *\n * The ref directive sets the value of the Ref object or calls the ref callback\n * during rendering, if the referenced element changed.\n *\n * Note: If a ref callback is rendered to a different element position or is\n * removed in a subsequent render, it will first be called with `undefined`,\n * followed by another call with the new element it was rendered to (if any).\n *\n * @example\n *\n * // Using Ref object\n * const inputRef = createRef();\n * render(html`<input ${ref(inputRef)}>`, container);\n * inputRef.value.focus();\n *\n * // Using callback\n * const callback = (inputElement) => inputElement.focus();\n * render(html`<input ${ref(callback)}>`, container);\n */\nexport const ref = directive(RefDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {RefDirective};\n"],"names":["createRef","Ref","lastElementForCallback","WeakMap","ref","directive","AsyncDirective","[object Object]","_ref","nothing","part","refChanged","this","undefined","_updateRefValue","_lastElementForRef","_element","_context","options","host","element","get","call","set","value","Tt"],"mappings":";;;;;SAWaA,EAAY,IAAmB,IAAIC,EAEhD,MAAMA,GAeN,MAAMC,EAGF,IAAIC,QAmGKC,EAAMC,EA/FnB,cAA2BC,EAKzBC,OAAOC,GACL,OAAOC,EAGTF,OAAOG,GAAoBN,UACzB,MAAMO,EAAaP,IAAQQ,KAAKJ,GAahC,OAZIG,QAA4BE,IAAdD,KAAKJ,IAGrBI,KAAKE,QAAgBD,IAEnBF,GAAcC,KAAKG,KAAuBH,KAAKI,MAGjDJ,KAAKJ,GAAOJ,EACZQ,KAAKK,aAAWP,EAAKQ,8BAASC,KAC9BP,KAAKE,GAAiBF,KAAKI,GAAWN,EAAKU,UAEtCX,EAGDF,GAAgBa,GACG,mBAAdR,KAAKJ,SAOgCK,IAA1CX,EAAuBmB,IAAIT,KAAKJ,KAClCI,KAAKJ,GAAKc,KAAKV,KAAKK,QAAUJ,GAEhCX,EAAuBqB,IAAIX,KAAKJ,GAAMY,QAEtBP,IAAZO,GACFR,KAAKJ,GAAKc,KAAKV,KAAKK,GAAUG,IAG/BR,KAAKJ,GAAsBgB,MAAQJ,EAIxCK,eACE,MAA4B,mBAAdb,KAAKJ,GACfN,EAAuBmB,IAAIT,KAAKJ,cAChCI,KAAKJ,yBAAMgB,MAGjBjB,eAKMK,KAAKG,KAAuBH,KAAKI,IACnCJ,KAAKE,QAAgBD,GAIzBN,cAGEK,KAAKE,GAAgBF,KAAKI"}
1
+ {"version":3,"file":"ref.js","sources":["../src/directives/ref.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport {nothing, ElementPart} from '../lit-html.js';\nimport {directive, AsyncDirective} from '../async-directive.js';\n\n/**\n * Creates a new Ref object, which is container for a reference to an element.\n */\nexport const createRef = <T = Element>() => new Ref<T>();\n\n/**\n * An object that holds a ref value.\n */\nclass Ref<T = Element> {\n /**\n * The current Element value of the ref, or else `undefined` if the ref is no\n * longer rendered.\n */\n readonly value?: T;\n}\n\nexport type {Ref};\n\ninterface RefInternal {\n value: Element | undefined;\n}\n\n// When callbacks are used for refs, this map tracks the last value the callback\n// was called with, for ensuring a directive doesn't clear the ref if the ref\n// has already been rendered to a new spot\nconst lastElementForCallback: WeakMap<Function, Element | undefined> =\n new WeakMap();\n\nexport type RefOrCallback = Ref | ((el: Element | undefined) => void);\n\nclass RefDirective extends AsyncDirective {\n private _element?: Element;\n private _ref?: RefOrCallback;\n private _context: unknown;\n\n render(_ref: RefOrCallback) {\n return nothing;\n }\n\n override update(part: ElementPart, [ref]: Parameters<this['render']>) {\n const refChanged = ref !== this._ref;\n if (refChanged && this._ref !== undefined) {\n // The ref passed to the directive has changed;\n // unset the previous ref's value\n this._updateRefValue(undefined);\n }\n if (refChanged || this._lastElementForRef !== this._element) {\n // We either got a new ref or this is the first render;\n // store the ref/element & update the ref value\n this._ref = ref;\n this._context = part.options?.host;\n this._updateRefValue((this._element = part.element));\n }\n return nothing;\n }\n\n private _updateRefValue(element: Element | undefined) {\n if (typeof this._ref === 'function') {\n // If the current ref was called with a previous value, call with\n // `undefined`; We do this to ensure callbacks are called in a consistent\n // way regardless of whether a ref might be moving up in the tree (in\n // which case it would otherwise be called with the new value before the\n // previous one unsets it) and down in the tree (where it would be unset\n // before being set)\n if (lastElementForCallback.get(this._ref) !== undefined) {\n this._ref.call(this._context, undefined);\n }\n lastElementForCallback.set(this._ref, element);\n // Call the ref with the new element value\n if (element !== undefined) {\n this._ref.call(this._context, element);\n }\n } else {\n (this._ref as RefInternal)!.value = element;\n }\n }\n\n private get _lastElementForRef() {\n return typeof this._ref === 'function'\n ? lastElementForCallback.get(this._ref)\n : this._ref?.value;\n }\n\n override disconnected() {\n // Only clear the box if our element is still the one in it (i.e. another\n // directive instance hasn't rendered its element to it before us); that\n // only happens in the event of the directive being cleared (not via manual\n // disconnection)\n if (this._lastElementForRef === this._element) {\n this._updateRefValue(undefined);\n }\n }\n\n override reconnected() {\n // If we were manually disconnected, we can safely put our element back in\n // the box, since no rendering could have occurred to change its state\n this._updateRefValue(this._element);\n }\n}\n\n/**\n * Sets the value of a Ref object or calls a ref callback with the element it's\n * bound to.\n *\n * A Ref object acts as a container for a reference to an element. A ref\n * callback is a function that takes an element as its only argument.\n *\n * The ref directive sets the value of the Ref object or calls the ref callback\n * during rendering, if the referenced element changed.\n *\n * Note: If a ref callback is rendered to a different element position or is\n * removed in a subsequent render, it will first be called with `undefined`,\n * followed by another call with the new element it was rendered to (if any).\n *\n * ```js\n * // Using Ref object\n * const inputRef = createRef();\n * render(html`<input ${ref(inputRef)}>`, container);\n * inputRef.value.focus();\n *\n * // Using callback\n * const callback = (inputElement) => inputElement.focus();\n * render(html`<input ${ref(callback)}>`, container);\n * ```\n */\nexport const ref = directive(RefDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {RefDirective};\n"],"names":["createRef","Ref","lastElementForCallback","WeakMap","ref","directive","AsyncDirective","render","_ref","nothing","update","part","refChanged","this","undefined","_updateRefValue","_lastElementForRef","_element","_context","options","host","element","get","call","set","value","disconnected","reconnected"],"mappings":";;;;;SAWaA,EAAY,IAAmB,IAAIC,EAKhD,MAAMA,GAiBN,MAAMC,EACJ,IAAIC,QAmGOC,EAAMC,EA/FnB,cAA2BC,EAKzBC,OAAOC,GACL,OAAOC,EAGAC,OAAOC,GAAoBP,UAClC,MAAMQ,EAAaR,IAAQS,KAAKL,EAahC,OAZII,QAA4BE,IAAdD,KAAKL,GAGrBK,KAAKE,QAAgBD,IAEnBF,GAAcC,KAAKG,KAAuBH,KAAKI,MAGjDJ,KAAKL,EAAOJ,EACZS,KAAKK,aAAWP,EAAKQ,8BAASC,KAC9BP,KAAKE,GAAiBF,KAAKI,GAAWN,EAAKU,UAEtCZ,EAGDM,GAAgBM,GACG,mBAAdR,KAAKL,QAOgCM,IAA1CZ,EAAuBoB,IAAIT,KAAKL,IAClCK,KAAKL,EAAKe,KAAKV,KAAKK,QAAUJ,GAEhCZ,EAAuBsB,IAAIX,KAAKL,EAAMa,QAEtBP,IAAZO,GACFR,KAAKL,EAAKe,KAAKV,KAAKK,GAAUG,IAG/BR,KAAKL,EAAsBiB,MAAQJ,EAI5BL,eACV,MAA4B,mBAAdH,KAAKL,EACfN,EAAuBoB,IAAIT,KAAKL,aAChCK,KAAKL,wBAAMiB,MAGRC,eAKHb,KAAKG,KAAuBH,KAAKI,IACnCJ,KAAKE,QAAgBD,GAIhBa,cAGPd,KAAKE,GAAgBF,KAAKI"}