ember-source 7.1.0-alpha.5 → 7.2.0-alpha.1

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 (196) hide show
  1. package/build-metadata.json +3 -3
  2. package/dist/dev/packages/@ember/-internals/glimmer/index.js +11 -11
  3. package/dist/dev/packages/@ember/-internals/views/index.js +0 -1
  4. package/dist/dev/packages/@ember/-internals/views/lib/views/core_view.js +1 -1
  5. package/dist/dev/packages/@ember/application/index.js +1 -1
  6. package/dist/dev/packages/@ember/application/instance.js +1 -1
  7. package/dist/dev/packages/@ember/component/helper.js +1 -1
  8. package/dist/dev/packages/@ember/component/index.js +7 -7
  9. package/dist/dev/packages/@ember/component/template-only.js +1 -1
  10. package/dist/dev/packages/@ember/engine/index.js +1 -3
  11. package/dist/dev/packages/@ember/helper/index.js +8 -18
  12. package/dist/dev/packages/@ember/modifier/index.js +2 -2
  13. package/dist/dev/packages/@ember/modifier/on.js +1 -1
  14. package/dist/dev/packages/@ember/reactive/collections.js +2 -0
  15. package/dist/dev/packages/@ember/renderer/index.js +1 -1
  16. package/dist/dev/packages/@ember/routing/index.js +3 -3
  17. package/dist/dev/packages/@ember/routing/route.js +2 -2
  18. package/dist/dev/packages/@ember/routing/router-service.js +1 -1
  19. package/dist/dev/packages/@ember/template-compiler/lib/compile-options.js +3 -3
  20. package/dist/dev/packages/@ember/template-compiler/lib/template.js +3 -3
  21. package/dist/dev/packages/@ember/template-factory/index.js +1 -1
  22. package/dist/dev/packages/@glimmer/destroyable/index.js +1 -1
  23. package/dist/dev/packages/@glimmer/manager/index.js +3 -3
  24. package/dist/dev/packages/@glimmer/node/index.js +2 -2
  25. package/dist/dev/packages/@glimmer/opcode-compiler/index.js +2 -5
  26. package/dist/dev/packages/@glimmer/program/index.js +4 -4
  27. package/dist/dev/packages/@glimmer/runtime/index.js +10 -12
  28. package/dist/dev/packages/@glimmer/vm/index.js +1 -1
  29. package/dist/dev/packages/ember/version.js +1 -1
  30. package/dist/dev/packages/ember-template-compiler/index.js +2 -2
  31. package/dist/dev/packages/shared-chunks/{api-AYt3zE12.js → api-BAmlf_CN.js} +1 -1
  32. package/dist/dev/packages/shared-chunks/{api-WvJPuo9z.js → api-BawZUDYD.js} +1 -1
  33. package/dist/dev/packages/shared-chunks/assert-Zqc4wiAV.js +6 -0
  34. package/dist/dev/packages/shared-chunks/{compiler-CXB_8GdR.js → compiler-QUSl_urU.js} +2 -3
  35. package/dist/dev/packages/shared-chunks/{curly-CvC8E_4-.js → curly-BBzF_bI8.js} +1 -1
  36. package/dist/dev/packages/shared-chunks/curried-BZnYakIg.js +5 -0
  37. package/dist/dev/packages/shared-chunks/{debug-to-string-CFb7h0lY.js → debug-to-string-C6LsA_qz.js} +1 -2
  38. package/dist/dev/packages/shared-chunks/{element-C-QcIABg.js → element-DQJOvSlQ.js} +2 -2
  39. package/dist/dev/packages/shared-chunks/{element-builder-kHVx0F__.js → element-builder--iTIJyCB.js} +1 -1
  40. package/dist/dev/packages/shared-chunks/{get-CpJjYeJO.js → get-D5b5QlqE.js} +2 -2
  41. package/dist/dev/packages/shared-chunks/{hash-D3BENmhU.js → hash-BRRFQJ99.js} +2 -2
  42. package/dist/dev/packages/shared-chunks/{helper-DlC4YesW.js → helper-Do7NCZHI.js} +2 -2
  43. package/dist/dev/packages/shared-chunks/{index-CTxkmV78.js → index-CwnQYqK5.js} +15 -15
  44. package/dist/dev/packages/shared-chunks/{index-DmGmwWPJ.js → index-CyZiGiEI.js} +5 -6
  45. package/dist/dev/packages/shared-chunks/{internal-CbQSKXEm.js → internal-CAL-jHZt.js} +2 -2
  46. package/dist/dev/packages/shared-chunks/{internal-helper-Dsl9_7H_.js → internal-helper-Ez7zbEIa.js} +1 -1
  47. package/dist/dev/packages/shared-chunks/{invoke-B6j6DdDz.js → invoke-B8M5fQQS.js} +2 -2
  48. package/dist/dev/packages/shared-chunks/{on-D8QwT-eN.js → on-BueSMv9L.js} +2 -2
  49. package/dist/dev/packages/shared-chunks/{or-DBU9Ge4r.js → or-O0eJQ4K-.js} +1 -1
  50. package/dist/dev/packages/shared-chunks/{program-context-CqcQMsfa.js → program-context-CadjldRr.js} +4 -3
  51. package/dist/{prod/packages/shared-chunks/registers-DoamZwaG.js → dev/packages/shared-chunks/registers-C_W2qYHJ.js} +1 -1
  52. package/dist/dev/packages/shared-chunks/{rehydrate-builder-DdzXTaJk.js → rehydrate-builder-DCyIgnCR.js} +2 -2
  53. package/dist/dev/packages/shared-chunks/{render-DDdabL30.js → render-CpKaO-BO.js} +9 -8
  54. package/dist/dev/packages/shared-chunks/{chunk-3SQBS3Y5-Cj4eryg1.js → runtime-CYyqkz5q-BOdRhmsS.js} +4 -59
  55. package/dist/dev/packages/shared-chunks/{serialize-builder-B3u9Wr3n.js → serialize-builder-DxgGRvH_.js} +1 -1
  56. package/dist/dev/packages/shared-chunks/{setup-registry-XxD0xvgf.js → setup-registry-BC5VMvei.js} +7 -7
  57. package/dist/dev/packages/shared-chunks/syscall-ops-BPFtDquC.js +133 -0
  58. package/dist/dev/packages/shared-chunks/{template-kM-7TTcc.js → template-R_5UMHhb.js} +1 -1
  59. package/dist/dev/packages/shared-chunks/{template-only-Yluyu0DY.js → template-only-BqOt8bDl.js} +1 -1
  60. package/dist/dev/packages/shared-chunks/{textarea-C0Us0PNJ.js → textarea-WSlUEr0y.js} +3 -3
  61. package/dist/dev/packages/shared-chunks/{unique-id-A83bjEE-.js → unique-id-CgmHQiwi.js} +1 -1
  62. package/dist/dev/packages/shared-chunks/{untouchable-this-cH6_N2LJ.js → untouchable-this-B3DVwpHS.js} +6 -6
  63. package/dist/dev/packages/shared-chunks/vm-ops-ImHv0Wtg.js +12 -0
  64. package/dist/prod/packages/@ember/-internals/container/index.js +2 -3
  65. package/dist/prod/packages/@ember/-internals/glimmer/index.js +9 -9
  66. package/dist/prod/packages/@ember/-internals/meta/lib/meta.js +0 -2
  67. package/dist/prod/packages/@ember/-internals/metal/index.js +16 -17
  68. package/dist/prod/packages/@ember/-internals/routing/index.js +1 -2
  69. package/dist/prod/packages/@ember/-internals/runtime/lib/ext/rsvp.js +0 -1
  70. package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +4 -5
  71. package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +1 -2
  72. package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +0 -1
  73. package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +2 -3
  74. package/dist/prod/packages/@ember/-internals/utils/index.js +0 -1
  75. package/dist/prod/packages/@ember/-internals/views/index.js +0 -1
  76. package/dist/prod/packages/@ember/-internals/views/lib/mixins/action_support.js +1 -2
  77. package/dist/prod/packages/@ember/-internals/views/lib/system/event_dispatcher.js +2 -3
  78. package/dist/prod/packages/@ember/-internals/views/lib/system/utils.js +0 -1
  79. package/dist/prod/packages/@ember/-internals/views/lib/views/core_view.js +2 -2
  80. package/dist/prod/packages/@ember/-internals/views/lib/views/states.js +0 -1
  81. package/dist/prod/packages/@ember/application/index.js +3 -3
  82. package/dist/prod/packages/@ember/application/instance.js +3 -4
  83. package/dist/prod/packages/@ember/application/namespace.js +1 -2
  84. package/dist/prod/packages/@ember/array/index.js +5 -6
  85. package/dist/prod/packages/@ember/array/proxy.js +5 -6
  86. package/dist/prod/packages/@ember/component/helper.js +1 -1
  87. package/dist/prod/packages/@ember/component/index.js +7 -8
  88. package/dist/prod/packages/@ember/controller/index.js +3 -3
  89. package/dist/prod/packages/@ember/debug/data-adapter.js +1 -1
  90. package/dist/prod/packages/@ember/engine/index.js +3 -6
  91. package/dist/prod/packages/@ember/engine/instance.js +0 -1
  92. package/dist/prod/packages/@ember/helper/index.js +5 -15
  93. package/dist/prod/packages/@ember/modifier/on.js +1 -1
  94. package/dist/prod/packages/@ember/object/-internals.js +0 -1
  95. package/dist/prod/packages/@ember/object/compat.js +1 -2
  96. package/dist/prod/packages/@ember/object/computed.js +2 -2
  97. package/dist/prod/packages/@ember/object/core.js +5 -6
  98. package/dist/prod/packages/@ember/object/evented.js +2 -2
  99. package/dist/prod/packages/@ember/object/events.js +1 -1
  100. package/dist/prod/packages/@ember/object/index.js +8 -8
  101. package/dist/prod/packages/@ember/object/internals.js +0 -1
  102. package/dist/prod/packages/@ember/object/lib/computed/computed_macros.js +4 -5
  103. package/dist/prod/packages/@ember/object/lib/computed/reduce_computed_macros.js +2 -3
  104. package/dist/prod/packages/@ember/object/mixin.js +4 -5
  105. package/dist/prod/packages/@ember/object/observable.js +7 -8
  106. package/dist/prod/packages/@ember/object/observers.js +1 -1
  107. package/dist/prod/packages/@ember/object/promise-proxy-mixin.js +3 -3
  108. package/dist/prod/packages/@ember/reactive/collections.js +2 -0
  109. package/dist/prod/packages/@ember/renderer/index.js +1 -1
  110. package/dist/prod/packages/@ember/routing/history-location.js +0 -1
  111. package/dist/prod/packages/@ember/routing/index.js +2 -3
  112. package/dist/prod/packages/@ember/routing/lib/dsl.js +0 -2
  113. package/dist/prod/packages/@ember/routing/lib/generate_controller.js +1 -2
  114. package/dist/prod/packages/@ember/routing/lib/routing-service.js +2 -3
  115. package/dist/prod/packages/@ember/routing/lib/utils.js +1 -2
  116. package/dist/prod/packages/@ember/routing/none-location.js +0 -1
  117. package/dist/prod/packages/@ember/routing/route.js +8 -9
  118. package/dist/prod/packages/@ember/routing/router-service.js +3 -4
  119. package/dist/prod/packages/@ember/routing/router.js +3 -4
  120. package/dist/prod/packages/@ember/runloop/index.js +1 -2
  121. package/dist/prod/packages/@ember/service/index.js +1 -1
  122. package/dist/prod/packages/@ember/template-compiler/lib/compile-options.js +3 -4
  123. package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-against-attrs.js +0 -1
  124. package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-against-named-outlets.js +0 -1
  125. package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-input-helper-without-block.js +0 -1
  126. package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-reserved-named-arguments.js +0 -2
  127. package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-each-track-array.js +0 -1
  128. package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-in-element.js +0 -1
  129. package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-resolutions.js +0 -1
  130. package/dist/prod/packages/@ember/template-compiler/lib/template.js +2 -2
  131. package/dist/prod/packages/@ember/template-factory/index.js +1 -1
  132. package/dist/prod/packages/@ember/utils/lib/compare.js +0 -1
  133. package/dist/prod/packages/@ember/utils/lib/is_empty.js +1 -1
  134. package/dist/prod/packages/@glimmer/node/index.js +2 -2
  135. package/dist/prod/packages/@glimmer/opcode-compiler/index.js +2 -5
  136. package/dist/prod/packages/@glimmer/program/index.js +2 -2
  137. package/dist/prod/packages/@glimmer/runtime/index.js +9 -11
  138. package/dist/prod/packages/@glimmer/tracking/index.js +1 -1
  139. package/dist/prod/packages/@glimmer/vm/index.js +1 -1
  140. package/dist/prod/packages/ember/version.js +1 -1
  141. package/dist/prod/packages/ember-template-compiler/index.js +2 -3
  142. package/dist/prod/packages/shared-chunks/{alias-CLuFeKoV.js → alias-DBW_V5vD.js} +5 -6
  143. package/dist/prod/packages/shared-chunks/{array-DHdr4__s.js → array-D6Couewv.js} +2 -3
  144. package/dist/prod/packages/shared-chunks/assert-Zqc4wiAV.js +6 -0
  145. package/dist/prod/packages/shared-chunks/{chain-tags-BJqcuCM1.js → chain-tags-C9rFtQ_x.js} +0 -1
  146. package/dist/prod/packages/shared-chunks/{compiler-DjQtTQGk.js → compiler-c4yUVrl_.js} +2 -3
  147. package/dist/prod/packages/shared-chunks/{computed-2Udcmflw.js → computed-DjCIU_ht.js} +3 -4
  148. package/dist/prod/packages/shared-chunks/{container-D5NwW5Fd.js → container-BYOnjnwz.js} +0 -1
  149. package/dist/prod/packages/shared-chunks/{curly-BsqvV8G0.js → curly-ZzX43b50.js} +2 -3
  150. package/dist/prod/packages/shared-chunks/curried-BZnYakIg.js +5 -0
  151. package/dist/prod/packages/shared-chunks/{debug-render-tree-BLtnOSbb.js → debug-render-tree-CF5O4-WI.js} +4 -4
  152. package/dist/prod/packages/shared-chunks/{decorator-DBCISop4.js → decorator-9ikVwsjY.js} +0 -1
  153. package/dist/prod/packages/shared-chunks/{element-BjFr0tO0.js → element-DUOVW5Ho.js} +0 -1
  154. package/dist/prod/packages/shared-chunks/{element-builder-BPjq0rxK.js → element-builder-CnlTPNyw.js} +1 -1
  155. package/dist/prod/packages/shared-chunks/{events-970OxD6Q.js → events-DYrYz3V8.js} +0 -1
  156. package/dist/prod/packages/shared-chunks/{get-D5wxdTkY.js → get-t0-itmA-.js} +2 -2
  157. package/dist/prod/packages/shared-chunks/{get_properties-BcAC5sGx.js → get_properties-Nn08mLAH.js} +1 -1
  158. package/dist/prod/packages/shared-chunks/{hash-DcUe-meU.js → hash-mcs3pEFO.js} +1 -1
  159. package/dist/prod/packages/shared-chunks/{helper-Da672z4a.js → helper-DLjV2ZZW.js} +0 -1
  160. package/dist/prod/packages/shared-chunks/{index--2U-v2nf.js → index-Bj71BDDA.js} +4 -5
  161. package/dist/prod/packages/shared-chunks/{index-D87qoERP.js → index-qDFz6Mfe.js} +14 -14
  162. package/dist/prod/packages/shared-chunks/{injected_property-D9B-fPiH.js → injected_property--eJunJph.js} +2 -3
  163. package/dist/prod/packages/shared-chunks/{invoke-Dr_CRwA_.js → invoke-Cj5zMqHz.js} +1 -1
  164. package/dist/prod/packages/shared-chunks/{libraries-DaXpIDYN.js → libraries-_k-4KK5_.js} +1 -2
  165. package/dist/prod/packages/shared-chunks/{observers-Co4JALkS.js → observers-CDkeR0nI.js} +2 -2
  166. package/dist/prod/packages/shared-chunks/{on-C3ZQiUUD.js → on-B5NVufs_.js} +1 -1
  167. package/dist/prod/packages/shared-chunks/{or-oTVMuHc8.js → or-3AxY5TPj.js} +1 -1
  168. package/dist/prod/packages/shared-chunks/{program-context-CGMN-aQM.js → program-context-B8HKU7wu.js} +4 -3
  169. package/dist/prod/packages/shared-chunks/{property_get-hWJ0nGhW.js → property_get-CAFdpRyu.js} +0 -1
  170. package/dist/prod/packages/shared-chunks/{property_set-Dj5-ScWk.js → property_set-BunbMFtp.js} +3 -4
  171. package/dist/{dev/packages/shared-chunks/registers-DoamZwaG.js → prod/packages/shared-chunks/registers-C_W2qYHJ.js} +1 -1
  172. package/dist/prod/packages/shared-chunks/{rehydrate-builder-BKg2X6Lo.js → rehydrate-builder-DJ8k-6fg.js} +2 -2
  173. package/dist/prod/packages/shared-chunks/{render-nx5-PsDW.js → render-DkJJmoI4.js} +7 -6
  174. package/dist/prod/packages/shared-chunks/{chunk-3SQBS3Y5-Cj4eryg1.js → runtime-CYyqkz5q-BOdRhmsS.js} +4 -59
  175. package/dist/prod/packages/shared-chunks/{serialize-builder-BGbC30SN.js → serialize-builder-R3Ozg0sC.js} +1 -1
  176. package/dist/prod/packages/shared-chunks/{set_properties-oPyURk67.js → set_properties-LT3RzRmJ.js} +2 -2
  177. package/dist/prod/packages/shared-chunks/{setup-registry-TiaKLj5k.js → setup-registry-C2KfZJWI.js} +7 -8
  178. package/dist/prod/packages/shared-chunks/syscall-ops-BPFtDquC.js +133 -0
  179. package/dist/prod/packages/shared-chunks/{textarea-CPKZ1c_O.js → textarea-CHqL0Rdh.js} +3 -4
  180. package/dist/prod/packages/shared-chunks/{tracked-CffAABMz.js → tracked-DAVrVqJl.js} +2 -3
  181. package/dist/prod/packages/shared-chunks/vm-ops-ImHv0Wtg.js +12 -0
  182. package/docs/data.json +28 -48
  183. package/lib/index.js +0 -1
  184. package/package.json +13 -11
  185. package/types/stable/@ember/-internals/views/index.d.ts +0 -1
  186. package/types/stable/@ember/helper/index.d.ts +0 -10
  187. package/types/stable/index.d.ts +0 -1
  188. package/dist/dev/packages/@ember/-internals/views/lib/component_lookup.js +0 -14
  189. package/dist/dev/packages/shared-chunks/assert-CUCJBR2C.js +0 -19
  190. package/dist/dev/packages/shared-chunks/curried-BVwSNqpf.js +0 -628
  191. package/dist/dev/packages/shared-chunks/opcode-metadata-9iSW5JGP.js +0 -285
  192. package/dist/prod/packages/@ember/-internals/views/lib/component_lookup.js +0 -14
  193. package/dist/prod/packages/shared-chunks/assert-CUCJBR2C.js +0 -19
  194. package/dist/prod/packages/shared-chunks/curried-BVwSNqpf.js +0 -628
  195. package/dist/prod/packages/shared-chunks/opcode-metadata-9iSW5JGP.js +0 -285
  196. package/types/stable/@ember/-internals/views/lib/component_lookup.d.ts +0 -8
@@ -1,628 +0,0 @@
1
- import { b as assertNever } from './assert-CUCJBR2C.js';
2
-
3
- const ANNOTATION_STYLES = ['background-color: oklch(93% 0.03 300); color: oklch(34% 0.18 300)', 'background-color: oklch(93% 0.03 250); color: oklch(34% 0.18 250)', 'background-color: oklch(93% 0.03 200); color: oklch(34% 0.18 200)', 'background-color: oklch(93% 0.03 150); color: oklch(34% 0.18 150)', 'background-color: oklch(93% 0.03 100); color: oklch(34% 0.18 100)', 'background-color: oklch(93% 0.03 50); color: oklch(34% 0.18 50)', 'background-color: oklch(93% 0.03 0); color: oklch(34% 0.18 0)'];
4
-
5
- /**
6
- * The `LogFragmentBuffer` is responsible for collecting the fragments that are logged to the
7
- * `DebugLogger` so that they can be accumulated during a group and flushed together.
8
- *
9
- * This queuing serves two purposes:
10
- *
11
- * 1. To allow the individual fragments that make up a single line to append their values to
12
- * the current line. To accomplish this, each fragment can append static content and its
13
- * formatting specifier (e.g. `%o`) to the accumulated {@link #template} *and* append the
14
- * value to format to the {@link #substitutions} array.
15
- * 2. To allow logs that refer to objects to be represented as footnotes in the current line,
16
- * with the footnote to be printed in a later line.
17
- *
18
- * This allows a list of fragments, each of which represent formattable values, to be flattened
19
- * into a single template string and an array of values to format.
20
- *
21
- * ## Footnotes
22
- *
23
- * An opcode slice containing constant references will be logged like this:
24
- *
25
- * ```
26
- * ...
27
- * 362. (PushArgs names=[] block-names=[] flags=16)
28
- * 366. (Helper helper=[0])
29
- * [0] glimmerHelper()
30
- * 368. (PopFrame)
31
- * 369. (Fetch register=$v0)
32
- * 371. (Primitive constant="/index.html")
33
- * ...
34
- * ```
35
- *
36
- * The fragment for line `366` includes an `ObjectFragment` for the helper value. When logged,
37
- * the object will be represented as a footnote and the value will be printed in a later
38
- * line.
39
- */
40
- class LogFragmentBuffer {
41
- /**
42
- * The first parameter to the `console.log` family of APIs is a *template* that can use
43
- * format specifiers (e.g. `%c`, `%o`, and `%O`) to refer to subsequent parameters.
44
- *
45
- * When a fragment is appended to a line,
46
- */
47
- #template = '';
48
-
49
- /**
50
- * Each format specified in the {@link #template} corresponds to a value in the
51
- * `#substitutions` array.
52
- */
53
- #substitutions = [];
54
-
55
- /**
56
- * The logging options for the buffer, which currently only contains `showSubtle`.
57
- *
58
- * When fragments call the buffer's {@linkcode append} method, they specify whether the
59
- * content to append is subtle or not. If the buffer is not configured to show subtle
60
- * content, the content is not appended.
61
- *
62
- * This allows fragments to append content to the buffer without having to know how the
63
- * buffer is configured.
64
- */
65
- #options;
66
-
67
- /**
68
- * A single line can produce multiple queued log entries. This happens when fragments
69
- * append *footnotes* to the buffer. A *reference* to the footnote is appended to the
70
- * primary line, and a line containing the *value* of the footnote is appended to the
71
- * `#queued` array.
72
- *
73
- * Both the primary line and any queued footnotes are flushed together when the buffer
74
- * is flushed.
75
- */
76
- #footnotes = [];
77
- #nextFootnote = 1;
78
- #style = 0;
79
- constructor(options) {
80
- this.#options = options;
81
- }
82
-
83
- /**
84
- * Add a footnoted value to the current buffer.
85
- *
86
- * If the `subtle` option is set, the fragment will only be printed if the buffer is configured
87
- * to show subtle content.
88
- *
89
- * This method takes two callbacks: `add` and `append`.
90
- *
91
- * The `append` callback behaves like {@linkcode append}, but without the `subtle` argument. If
92
- * `addFootnoted` is called with `subtle: false`, then the callback will never be called, so
93
- * there is no need to pass the `subtle` argument again.
94
- *
95
- * The `add` callback is responsible for appending the footnote itself to the buffer. The first
96
- * parameter to `add` (`useNumber`) specifies whether the caller has used the footnote number
97
- * to refer to the footnote.
98
- *
99
- * This is typically true, but fragments can specify an alternative annotation that should be used
100
- * instead of the default footnote number. In that case, the footnote number is not used, and the
101
- * next footnote is free to use it.
102
- *
103
- * The `add` callback also takes a template string and an optional list of substitutions, which
104
- * describe the way the footnote itself should be formatted.
105
- */
106
- addFootnoted(subtle, add) {
107
- if (subtle && !this.#options.showSubtle) return;
108
- const child = new LogFragmentBuffer(this.#options);
109
- const style = ANNOTATION_STYLES[this.#style++ % ANNOTATION_STYLES.length];
110
- const usedNumber = add({
111
- n: this.#nextFootnote,
112
- style
113
- }, child);
114
- if (usedNumber) {
115
- this.#nextFootnote += 1;
116
- }
117
- this.#footnotes.push({
118
- type: 'line',
119
- subtle: false,
120
- template: child.#template,
121
- substitutions: child.#substitutions
122
- });
123
- this.#footnotes.push(...child.#footnotes);
124
- }
125
-
126
- /**
127
- * Append a fragment to the current buffer.
128
- *
129
- * If the `subtle` option is set, the fragment will only be printed if the buffer is configured
130
- * to show subtle content.
131
- */
132
- append(subtle, template, ...substitutions) {
133
- if (subtle && !this.#options.showSubtle) return;
134
- this.#template += template;
135
- this.#substitutions.push(...substitutions);
136
- }
137
- #mapLine(line) {
138
- if (line.subtle && !this.#options.showSubtle) return [];
139
- return [{
140
- type: 'line',
141
- line: [line.template, ...line.substitutions]
142
- }];
143
- }
144
- flush() {
145
- return [{
146
- type: 'line',
147
- line: [this.#template, ...this.#substitutions]
148
- }, ...this.#footnotes.flatMap(queued => this.#mapLine(queued))];
149
- }
150
- }
151
-
152
- // inspired by https://github.com/ChromeDevTools/devtools-frontend/blob/c2c17396c9e0da3f1ce6514c3a946f88a06b17f2/front_end/ui/legacy/themeColors.css#L65
153
- const STYLES = {
154
- var: 'color: grey',
155
- varReference: 'color: blue; text-decoration: underline',
156
- varBinding: 'color: blue;',
157
- specialVar: 'color: blue',
158
- prop: 'color: grey',
159
- specialProp: 'color: red',
160
- token: 'color: green',
161
- def: 'color: blue',
162
- builtin: 'color: blue',
163
- punct: 'color: GrayText',
164
- kw: 'color: rgb(185 0 99 / 100%);',
165
- type: 'color: teal',
166
- number: 'color: blue',
167
- string: 'color: red',
168
- null: 'color: grey',
169
- specialString: 'color: darkred',
170
- atom: 'color: blue',
171
- attrName: 'color: orange',
172
- attrValue: 'color: blue',
173
- boolean: 'color: blue',
174
- comment: 'color: green',
175
- meta: 'color: grey',
176
- register: 'color: purple',
177
- constant: 'color: purple',
178
- dim: 'color: grey',
179
- internals: 'color: lightgrey; font-style: italic',
180
- diffAdd: 'color: Highlight',
181
- diffDelete: 'color: SelectedItemText; background-color: SelectedItem',
182
- diffChange: 'color: MarkText; background-color: Mark',
183
- sublabel: 'font-style: italic; color: grey',
184
- error: 'color: red',
185
- label: 'text-decoration: underline',
186
- errorLabel: 'color: darkred; font-style: italic',
187
- errorMessage: 'color: darkred; text-decoration: underline',
188
- stack: 'color: grey; font-style: italic',
189
- unbold: 'font-weight: normal',
190
- pointer: 'background-color: lavender; color: indigo',
191
- pointee: 'background-color: lavender; color: indigo',
192
- focus: 'font-weight: bold',
193
- focusColor: 'background-color: lightred; color: darkred'
194
- };
195
- function mergeStyle(a, b) {
196
- if (a && b) {
197
- return `${a}; ${b}`;
198
- } else {
199
- return a || b;
200
- }
201
- }
202
-
203
- function intoFormat(format) {
204
- if (typeof format === 'string') {
205
- return {
206
- style: STYLES[format]
207
- };
208
- } else {
209
- return format;
210
- }
211
- }
212
- function formats(...formats) {
213
- return formats.map(c => intoFormat(c).style).join('; ');
214
- }
215
-
216
- const FORMATTERS = {
217
- value: '%O',
218
- string: '%s',
219
- integer: '%d',
220
- float: '%f',
221
- special: '%o'
222
- };
223
-
224
- /**
225
- * A leaf fragment that represents an arbitrary value.
226
- *
227
- * When the value is a primitive, the fragment is appended to the buffer as if it was an instance of
228
- * the appropriate leaf fragment type (e.g. strings are appended as if they were `StringFragment`).
229
- *
230
- * Otherwise, `ValueFragment` is appended to the current line as a footnote reference and the value
231
- * itself is appended to a later line that *defines* the footnote using the `%O` format specifier.
232
- */
233
-
234
- /**
235
- * A leaf fragment that represents a string value.
236
- *
237
- * Corresponds to the `%s` format specifier.
238
- */
239
-
240
- /**
241
- * A leaf fragment that represents an integer value.
242
- *
243
- * Corresponds to the `%d` format specifier.
244
- */
245
-
246
- /**
247
- * A leaf fragment that represents a float value.
248
- *
249
- * Corresponds to the `%f` format specifier.
250
- */
251
-
252
- /**
253
- * A leaf fragment that represents a DOM node.
254
- *
255
- * Corresponds to the `%o` format specifier.
256
- */
257
-
258
- /**
259
- * The list of leaf fragment types correspond exactly to the list of console.log
260
- * format specifiers.
261
- */
262
-
263
- /**
264
- * @import { StyleName } from './styles';
265
- */
266
-
267
- /**
268
- * Fragment is the most fundamental building block of the debug logger.
269
- *
270
- */
271
- class Fragment {
272
- static integer(value, options) {
273
- return new Fragment({
274
- kind: 'integer',
275
- value,
276
- ...options
277
- });
278
- }
279
- static float(value, options) {
280
- return new Fragment({
281
- kind: 'float',
282
- value,
283
- ...options
284
- });
285
- }
286
- static string(value, options) {
287
- return new Fragment({
288
- kind: 'string',
289
- value,
290
- ...options
291
- });
292
- }
293
- static special(value, options) {
294
- return new Fragment({
295
- kind: 'special',
296
- value,
297
- ...options
298
- });
299
- }
300
- #type;
301
- constructor(type) {
302
- this.#type = type;
303
- }
304
-
305
- /**
306
- * A subtle fragment is only printed if the `showSubtle` option is set.
307
- *
308
- * Returns true if this fragment is a subtle leaf or is a multi fragment
309
- * with all subtle leaves.
310
- */
311
- isSubtle() {
312
- return this.leaves().every(leaf => leaf.#type.subtle);
313
- }
314
-
315
- /**
316
- * If the current fragment is not empty, apply `ifPresent` to the current
317
- * fragment. Otherwise, do nothing.
318
- *
319
- * If the current fragment is subtle, the result is also subtle.
320
- */
321
- map(ifPresent) {
322
- if (this.isEmpty()) return this;
323
- const fragment = ifPresent(this);
324
- return this.isSubtle() ? fragment.subtle() : fragment;
325
- }
326
-
327
- /**
328
- * A fragment is empty if it should not be printed with the provided display options.
329
- *
330
- * This means that if a fragment is subtle and `showSubtle` is false, the fragment is empty.
331
- */
332
- isEmpty(options = {
333
- showSubtle: true
334
- }) {
335
- return this.leaves().every(leaf => !leaf.#shouldShow(options));
336
- }
337
-
338
- /**
339
- * Returns an array of {@linkcode LeafFragment}s that make up the current
340
- * fragment.
341
- *
342
- * This effectively flattens any number of nested multi-fragments into a flat array of leaf
343
- * fragments.
344
- */
345
- leaves() {
346
- if (this.#type.kind === 'multi') {
347
- return this.#type.value.flatMap(f => f.leaves());
348
- } else if (this.#type.kind === 'string' && this.#type.value === '') {
349
- return [];
350
- } else {
351
- return [this];
352
- }
353
- }
354
-
355
- /**
356
- * Returns a fragment with the specified subtle status without mutating the current fragment.
357
- *
358
- * If `isSubtle` is true, the fragment will also be styled with the `subtle` style.
359
- */
360
- subtle(isSubtle = true) {
361
- if (!this.isSubtle() && !isSubtle) {
362
- return this;
363
- }
364
- const fragment = this.#subtle(isSubtle);
365
- return isSubtle ? fragment.styleAll('dim') : fragment;
366
- }
367
- #subtle(isSubtle) {
368
- if (this.#type.kind === 'multi') {
369
- return new Fragment({
370
- ...this.#type,
371
- value: this.leaves().flatMap(f => f.subtle(isSubtle).leaves())
372
- });
373
- } else {
374
- return new Fragment({
375
- ...this.#type,
376
- subtle: isSubtle
377
- });
378
- }
379
- }
380
-
381
- /**
382
- * Apply the specified styles to the current fragment (if it's a leaf) or all
383
- * of its children (if it's a multi-fragment).
384
- *
385
- * Keep in mind that merging styles might be very difficult to undo, so treat
386
- * this as a low-level operation, and prefer to use higher-level concepts like
387
- * `subtle` if you can instead.
388
- */
389
- styleAll(...allFormats) {
390
- if (allFormats.length === 0) return this;
391
- if (this.#type.kind === 'multi') {
392
- return new Fragment({
393
- ...this.#type,
394
- value: this.#type.value.flatMap(f => f.styleAll(...allFormats).leaves())
395
- });
396
- } else {
397
- return new Fragment({
398
- ...this.#type,
399
- style: mergeStyle(this.#type.style, formats(...allFormats))
400
- });
401
- }
402
- }
403
-
404
- /**
405
- * Convert the current fragment into a string with no additional formatting.
406
- * The primary purpose for this method is to support converting a fragment
407
- * into a string for inclusion in thrown Errors. If you're going to *log*
408
- * a fragment, log it using `DebugLogger` and don't convert it to
409
- * a string first.
410
- */
411
- stringify(options) {
412
- return this.leaves().filter(leaf => leaf.#shouldShow(options)).map(leaf => {
413
- const fragment = leaf.#type;
414
- if (fragment.kind === 'value') {
415
- return `<object>`;
416
- } else {
417
- // eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
418
- return String(fragment.value);
419
- }
420
- }).join('');
421
- }
422
-
423
- /**
424
- * Should the current fragment be printed with the provided display options?
425
- *
426
- * Importantly, if the current fragment contains subtle content but the `showSubtle` option is
427
- * false, `#shouldShow` will return false.
428
- *
429
- * @see isEmpty
430
- */
431
- #shouldShow(options) {
432
- return this.leaves().some(leaf => {
433
- const fragment = leaf.#type;
434
- if (fragment.subtle && !options.showSubtle) {
435
- return false;
436
- } else if (fragment.kind === 'string' && fragment.value === '') {
437
- return false;
438
- }
439
- return true;
440
- });
441
- }
442
-
443
- /**
444
- * Convert this fragment into a Loggable for logging through the `DebugLogger`.
445
- */
446
- toLoggable(options) {
447
- const buffer = new LogFragmentBuffer(options);
448
- for (const leaf of this.leaves()) {
449
- leaf.appendTo(buffer);
450
- }
451
- return buffer.flush();
452
- }
453
-
454
- /**
455
- * Append this fragment to the low-level `LogFragmentBuffer`.
456
- */
457
- appendTo(buffer) {
458
- const fragment = this.#type;
459
- const subtle = this.isSubtle();
460
-
461
- // If the fragment is a multi fragment, append each of its leaves to the buffer
462
- // and return.
463
- if (fragment.kind === 'multi') {
464
- for (const f of fragment.value) {
465
- f.appendTo(buffer);
466
- }
467
- return;
468
- }
469
-
470
- // If the fragment is a value fragment and the value is a primitive, give it special
471
- // treatment since we can trivially serialize it.
472
- if (fragment.kind === 'value') {
473
- // If the value is a string or number, convert it into a string, float or integer
474
- // fragment and append that instead. This means that strings and numbers are
475
- // represented the same way in logs whether they are explicitly created as string,
476
- // float or integer fragments *or* whether they are the value of a value fragment.
477
- if (typeof fragment.value === 'string') {
478
- return Fragment.string(JSON.stringify(fragment.value), {
479
- style: STYLES.string,
480
- subtle
481
- }).appendTo(buffer);
482
- } else if (typeof fragment.value === 'number') {
483
- const f = fragment.value % 1 === 0 ? Fragment.integer : Fragment.float;
484
- return f(fragment.value, {
485
- style: STYLES.number,
486
- subtle
487
- }).appendTo(buffer);
488
-
489
- // Alternatively, if the value of a `value` fragment is `null` or `undefined`,
490
- // append the string `null` or `undefined`, respectively with the `null` style.
491
- } else if (fragment.value === null || fragment.value === undefined) {
492
- return Fragment.string('null', {
493
- style: STYLES.null,
494
- subtle: this.isSubtle()
495
- }).appendTo(buffer);
496
-
497
- // Finally, if the value of a `value` fragment is boolean, append the string
498
- // `true` or `false` with the `boolean` style.
499
- } else if (typeof fragment.value === 'boolean') {
500
- return Fragment.string(String(fragment.value), {
501
- style: STYLES.boolean,
502
- subtle
503
- }).appendTo(buffer);
504
- }
505
-
506
- // All other values (i.e. objects and functions) are represented as footnotes and
507
- // are handled below.
508
- }
509
- switch (fragment.kind) {
510
- // strings are appended using %s
511
- case 'string':
512
- // integers are appended using %d
513
- case 'integer':
514
- // floats are appended using %f
515
- case 'float':
516
- buffer.append(fragment.subtle ?? false, `%c${FORMATTERS[fragment.kind]}`, fragment.style, fragment.value);
517
- break;
518
- // the remaining value types are represented as footnotes
519
- // dom nodes are appended to the footnote line using %o
520
- case 'special':
521
- // values are appended to the footnote line using %O
522
- case 'value':
523
- {
524
- // If a fragment has an associated annotation, we'll use the annotation as the
525
- // footnote rather than the footnote number.
526
- const override = fragment.kind === 'value' ? fragment.display : undefined;
527
- buffer.addFootnoted(fragment.subtle ?? false, ({
528
- n,
529
- style
530
- }, footnote) => {
531
- const appendValueAsFootnote = ref => void footnote.append(subtle, `%c| %c[${ref}]%c ${FORMATTERS[fragment.kind]}`, STYLES.dim, style, '', fragment.value);
532
- if (override) {
533
- if ('inline' in override) {
534
- override.inline.subtle(subtle).appendTo(footnote);
535
- return false;
536
- }
537
- buffer.append(subtle, `%c[${override.ref}]%c`, style, '');
538
- if (override.footnote) {
539
- frag`${as.dim('| ')}${override.footnote}`.subtle(subtle).appendTo(footnote);
540
- } else {
541
- appendValueAsFootnote(override.ref);
542
- }
543
- return false;
544
- }
545
- buffer.append(subtle, `%c[${n}]%c`, style, '');
546
- appendValueAsFootnote(String(n));
547
- return true;
548
- });
549
- break;
550
- }
551
- default:
552
- assertNever(fragment);
553
- }
554
- }
555
- }
556
- function intoFragment(value) {
557
- const fragments = intoFragments(value);
558
- const [first, ...rest] = fragments;
559
- if (first !== undefined && rest.length === 0) {
560
- return first;
561
- }
562
- return new Fragment({
563
- kind: 'multi',
564
- value: fragments
565
- });
566
- }
567
- function intoFragments(value) {
568
- if (Array.isArray(value)) {
569
- return value.flatMap(intoFragments);
570
- } else if (typeof value === 'object' && value !== null) {
571
- return value.leaves();
572
- } else {
573
- return [intoLeafFragment(value)];
574
- }
575
- }
576
- function intoLeafFragment(value) {
577
- if (value === null) {
578
- return new Fragment({
579
- kind: 'value',
580
- value: null
581
- });
582
- } else if (typeof value === 'number') {
583
- return new Fragment({
584
- kind: 'integer',
585
- value
586
- });
587
- } else if (typeof value === 'string') {
588
- // If the string contains only whitespace and punctuation, we can treat it as a
589
- // punctuation fragment.
590
- if (/^[\s\p{P}\p{Sm}]*$/u.test(value)) {
591
- return new Fragment({
592
- kind: 'string',
593
- value,
594
- style: STYLES.punct
595
- });
596
- } else {
597
- return new Fragment({
598
- kind: 'string',
599
- value
600
- });
601
- }
602
- } else {
603
- return value;
604
- }
605
- }
606
- function frag(strings, ...values) {
607
- const buffer = [];
608
- strings.forEach((string, i) => {
609
- buffer.push(...intoFragment(string).leaves());
610
- const dynamic = values[i];
611
- if (dynamic) {
612
- buffer.push(...intoFragment(dynamic).leaves());
613
- }
614
- });
615
- return new Fragment({
616
- kind: 'multi',
617
- value: buffer
618
- });
619
- }
620
- const as = Object.fromEntries(Object.entries(STYLES).map(([k, v]) => [k, value => intoFragment(value).styleAll({
621
- style: v
622
- })]));
623
-
624
- const CURRIED_COMPONENT = 0;
625
- const CURRIED_HELPER = 1;
626
- const CURRIED_MODIFIER = 2;
627
-
628
- export { CURRIED_MODIFIER as C, CURRIED_HELPER as a, CURRIED_COMPONENT as b };