@nascentdigital/funnel-core 4.4.4

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 (368) hide show
  1. package/dist/app/AppConfig.d.ts +41 -0
  2. package/dist/app/AppConfig.js +93 -0
  3. package/dist/app/BrandConfig.d.ts +13 -0
  4. package/dist/app/BrandConfig.js +2 -0
  5. package/dist/app/FeaturesConfig.d.ts +6 -0
  6. package/dist/app/FeaturesConfig.js +2 -0
  7. package/dist/app/RegionsConfig.d.ts +43 -0
  8. package/dist/app/RegionsConfig.js +113 -0
  9. package/dist/app/UIConfig.d.ts +4 -0
  10. package/dist/app/UIConfig.js +2 -0
  11. package/dist/app/index.d.ts +5 -0
  12. package/dist/app/index.js +21 -0
  13. package/dist/consent/ConsentCategory.d.ts +12 -0
  14. package/dist/consent/ConsentCategory.js +28 -0
  15. package/dist/consent/ConsentService.d.ts +15 -0
  16. package/dist/consent/ConsentService.js +37 -0
  17. package/dist/consent/index.d.ts +2 -0
  18. package/dist/consent/index.js +18 -0
  19. package/dist/errors/IsometricError.d.ts +19 -0
  20. package/dist/errors/IsometricError.js +30 -0
  21. package/dist/errors/IsometricErrorModule.d.ts +11 -0
  22. package/dist/errors/IsometricErrorModule.js +2 -0
  23. package/dist/errors/IsometricErrorUtils.d.ts +9 -0
  24. package/dist/errors/IsometricErrorUtils.js +85 -0
  25. package/dist/errors/SerializedIsometricError.d.ts +10 -0
  26. package/dist/errors/SerializedIsometricError.js +15 -0
  27. package/dist/errors/api/ApiError.d.ts +15 -0
  28. package/dist/errors/api/ApiError.js +23 -0
  29. package/dist/errors/api/ApiErrors.d.ts +7 -0
  30. package/dist/errors/api/ApiErrors.js +67 -0
  31. package/dist/errors/api/ArgumentError.d.ts +7 -0
  32. package/dist/errors/api/ArgumentError.js +18 -0
  33. package/dist/errors/api/ConcurrencyError.d.ts +4 -0
  34. package/dist/errors/api/ConcurrencyError.js +11 -0
  35. package/dist/errors/api/ConflictError.d.ts +4 -0
  36. package/dist/errors/api/ConflictError.js +11 -0
  37. package/dist/errors/api/DependencyError.d.ts +4 -0
  38. package/dist/errors/api/DependencyError.js +11 -0
  39. package/dist/errors/api/IllegalStateError.d.ts +4 -0
  40. package/dist/errors/api/IllegalStateError.js +11 -0
  41. package/dist/errors/api/InvalidOperationError.d.ts +4 -0
  42. package/dist/errors/api/InvalidOperationError.js +11 -0
  43. package/dist/errors/api/NotAuthenticatedError.d.ts +4 -0
  44. package/dist/errors/api/NotAuthenticatedError.js +11 -0
  45. package/dist/errors/api/NotAuthorizedError.d.ts +4 -0
  46. package/dist/errors/api/NotAuthorizedError.js +11 -0
  47. package/dist/errors/api/NotAvailableError.d.ts +4 -0
  48. package/dist/errors/api/NotAvailableError.js +11 -0
  49. package/dist/errors/api/NotFoundError.d.ts +4 -0
  50. package/dist/errors/api/NotFoundError.js +11 -0
  51. package/dist/errors/api/NotImplementedError.d.ts +4 -0
  52. package/dist/errors/api/NotImplementedError.js +11 -0
  53. package/dist/errors/api/OfflineError.d.ts +4 -0
  54. package/dist/errors/api/OfflineError.js +11 -0
  55. package/dist/errors/api/RangeError.d.ts +4 -0
  56. package/dist/errors/api/RangeError.js +11 -0
  57. package/dist/errors/api/ServerError.d.ts +4 -0
  58. package/dist/errors/api/ServerError.js +11 -0
  59. package/dist/errors/api/TimeoutError.d.ts +4 -0
  60. package/dist/errors/api/TimeoutError.js +11 -0
  61. package/dist/errors/api/index.d.ts +16 -0
  62. package/dist/errors/api/index.js +32 -0
  63. package/dist/errors/index.d.ts +5 -0
  64. package/dist/errors/index.js +26 -0
  65. package/dist/forms/FormModel.d.ts +47 -0
  66. package/dist/forms/FormModel.js +149 -0
  67. package/dist/forms/Forms.d.ts +15 -0
  68. package/dist/forms/Forms.js +35 -0
  69. package/dist/forms/IFormService.d.ts +6 -0
  70. package/dist/forms/IFormService.js +2 -0
  71. package/dist/forms/TranslateSchema.d.ts +8 -0
  72. package/dist/forms/TranslateSchema.js +2 -0
  73. package/dist/forms/index.d.ts +4 -0
  74. package/dist/forms/index.js +20 -0
  75. package/dist/index.d.ts +10 -0
  76. package/dist/index.js +49 -0
  77. package/dist/regionalization/Country.d.ts +266 -0
  78. package/dist/regionalization/Country.js +338 -0
  79. package/dist/regionalization/Language.d.ts +199 -0
  80. package/dist/regionalization/Language.js +237 -0
  81. package/dist/regionalization/Locale.d.ts +28 -0
  82. package/dist/regionalization/Locale.js +49 -0
  83. package/dist/regionalization/Localized.d.ts +10 -0
  84. package/dist/regionalization/Localized.js +36 -0
  85. package/dist/regionalization/LocalizedCopy.d.ts +9 -0
  86. package/dist/regionalization/LocalizedCopy.js +26 -0
  87. package/dist/regionalization/Regionalization.d.ts +50 -0
  88. package/dist/regionalization/Regionalization.js +260 -0
  89. package/dist/regionalization/Regions.d.ts +2 -0
  90. package/dist/regionalization/Regions.js +2 -0
  91. package/dist/regionalization/index.d.ts +7 -0
  92. package/dist/regionalization/index.js +23 -0
  93. package/dist/schema/Asset.d.ts +23 -0
  94. package/dist/schema/Asset.js +36 -0
  95. package/dist/schema/AssetScope.d.ts +75 -0
  96. package/dist/schema/AssetScope.js +146 -0
  97. package/dist/schema/Block.d.ts +105 -0
  98. package/dist/schema/Block.js +122 -0
  99. package/dist/schema/ChangeSet.d.ts +108 -0
  100. package/dist/schema/ChangeSet.js +187 -0
  101. package/dist/schema/Collection.d.ts +197 -0
  102. package/dist/schema/Collection.js +165 -0
  103. package/dist/schema/CollectionModel.d.ts +30 -0
  104. package/dist/schema/CollectionModel.js +383 -0
  105. package/dist/schema/CollectionSnapshot.d.ts +11 -0
  106. package/dist/schema/CollectionSnapshot.js +12 -0
  107. package/dist/schema/Fields.d.ts +31 -0
  108. package/dist/schema/Fields.js +21 -0
  109. package/dist/schema/Form.d.ts +31 -0
  110. package/dist/schema/Form.js +23 -0
  111. package/dist/schema/LinkedCollectionModel.d.ts +9 -0
  112. package/dist/schema/LinkedCollectionModel.js +19 -0
  113. package/dist/schema/LinkedData.d.ts +44 -0
  114. package/dist/schema/LinkedData.js +288 -0
  115. package/dist/schema/LinkedPageModel.d.ts +11 -0
  116. package/dist/schema/LinkedPageModel.js +26 -0
  117. package/dist/schema/Optional.d.ts +23 -0
  118. package/dist/schema/Optional.js +34 -0
  119. package/dist/schema/Page.d.ts +299 -0
  120. package/dist/schema/Page.js +244 -0
  121. package/dist/schema/PageModel.d.ts +58 -0
  122. package/dist/schema/PageModel.js +881 -0
  123. package/dist/schema/PageQuery.d.ts +60 -0
  124. package/dist/schema/PageQuery.js +116 -0
  125. package/dist/schema/PageRoute.d.ts +7 -0
  126. package/dist/schema/PageRoute.js +48 -0
  127. package/dist/schema/PageSnapshot.d.ts +11 -0
  128. package/dist/schema/PageSnapshot.js +12 -0
  129. package/dist/schema/Section.d.ts +71 -0
  130. package/dist/schema/Section.js +35 -0
  131. package/dist/schema/Seo.d.ts +13 -0
  132. package/dist/schema/Seo.js +25 -0
  133. package/dist/schema/Site.d.ts +40 -0
  134. package/dist/schema/Site.js +87 -0
  135. package/dist/schema/SiteModel.d.ts +5 -0
  136. package/dist/schema/SiteModel.js +10 -0
  137. package/dist/schema/Tag.d.ts +28 -0
  138. package/dist/schema/Tag.js +59 -0
  139. package/dist/schema/TagGroup.d.ts +26 -0
  140. package/dist/schema/TagGroup.js +64 -0
  141. package/dist/schema/field/Field.d.ts +179 -0
  142. package/dist/schema/field/Field.js +309 -0
  143. package/dist/schema/field/base/AssetField.d.ts +148 -0
  144. package/dist/schema/field/base/AssetField.js +206 -0
  145. package/dist/schema/field/base/BooleanField.d.ts +21 -0
  146. package/dist/schema/field/base/BooleanField.js +38 -0
  147. package/dist/schema/field/base/CollectionField.d.ts +34 -0
  148. package/dist/schema/field/base/CollectionField.js +85 -0
  149. package/dist/schema/field/base/DateField.d.ts +21 -0
  150. package/dist/schema/field/base/DateField.js +37 -0
  151. package/dist/schema/field/base/DynamicPagesField.d.ts +36 -0
  152. package/dist/schema/field/base/DynamicPagesField.js +50 -0
  153. package/dist/schema/field/base/EmbeddedVideoField.d.ts +45 -0
  154. package/dist/schema/field/base/EmbeddedVideoField.js +176 -0
  155. package/dist/schema/field/base/EnumField.d.ts +40 -0
  156. package/dist/schema/field/base/EnumField.js +131 -0
  157. package/dist/schema/field/base/FormField.d.ts +25 -0
  158. package/dist/schema/field/base/FormField.js +48 -0
  159. package/dist/schema/field/base/LinkField.d.ts +103 -0
  160. package/dist/schema/field/base/LinkField.js +201 -0
  161. package/dist/schema/field/base/PageField.d.ts +46 -0
  162. package/dist/schema/field/base/PageField.js +83 -0
  163. package/dist/schema/field/base/RichTextField.d.ts +71 -0
  164. package/dist/schema/field/base/RichTextField.js +196 -0
  165. package/dist/schema/field/base/TextField.d.ts +33 -0
  166. package/dist/schema/field/base/TextField.js +86 -0
  167. package/dist/schema/field/base/TimestampField.d.ts +25 -0
  168. package/dist/schema/field/base/TimestampField.js +41 -0
  169. package/dist/schema/field/base/index.d.ts +13 -0
  170. package/dist/schema/field/base/index.js +29 -0
  171. package/dist/schema/field/composite/ListField.d.ts +47 -0
  172. package/dist/schema/field/composite/ListField.js +107 -0
  173. package/dist/schema/field/composite/ObjectField.d.ts +56 -0
  174. package/dist/schema/field/composite/ObjectField.js +19 -0
  175. package/dist/schema/field/composite/index.d.ts +2 -0
  176. package/dist/schema/field/composite/index.js +18 -0
  177. package/dist/schema/field/index.d.ts +3 -0
  178. package/dist/schema/field/index.js +19 -0
  179. package/dist/schema/index.d.ts +25 -0
  180. package/dist/schema/index.js +41 -0
  181. package/dist/services/EventBus.d.ts +17 -0
  182. package/dist/services/EventBus.js +37 -0
  183. package/dist/services/humanVerification/IHumanVerification.d.ts +8 -0
  184. package/dist/services/humanVerification/IHumanVerification.js +2 -0
  185. package/dist/services/humanVerification/index.d.ts +1 -0
  186. package/dist/services/humanVerification/index.js +17 -0
  187. package/dist/services/index.d.ts +3 -0
  188. package/dist/services/index.js +19 -0
  189. package/dist/services/leadGen/Contact.d.ts +40 -0
  190. package/dist/services/leadGen/Contact.js +38 -0
  191. package/dist/services/leadGen/ILeadGen.d.ts +16 -0
  192. package/dist/services/leadGen/ILeadGen.js +2 -0
  193. package/dist/services/leadGen/index.d.ts +2 -0
  194. package/dist/services/leadGen/index.js +18 -0
  195. package/dist/types/BoxedValue.d.ts +3 -0
  196. package/dist/types/BoxedValue.js +2 -0
  197. package/dist/types/Callback.d.ts +9 -0
  198. package/dist/types/Callback.js +2 -0
  199. package/dist/types/DateString.d.ts +35 -0
  200. package/dist/types/DateString.js +172 -0
  201. package/dist/types/FilterConditionally.d.ts +3 -0
  202. package/dist/types/FilterConditionally.js +2 -0
  203. package/dist/types/MaybeConditionalValue.d.ts +8 -0
  204. package/dist/types/MaybeConditionalValue.js +12 -0
  205. package/dist/types/Ordinal.d.ts +17 -0
  206. package/dist/types/Ordinal.js +38 -0
  207. package/dist/types/OverridableStringUnion.d.ts +2 -0
  208. package/dist/types/OverridableStringUnion.js +2 -0
  209. package/dist/types/PartialBy.d.ts +1 -0
  210. package/dist/types/PartialBy.js +2 -0
  211. package/dist/types/PickData.d.ts +6 -0
  212. package/dist/types/PickData.js +2 -0
  213. package/dist/types/Provider.d.ts +4 -0
  214. package/dist/types/Provider.js +2 -0
  215. package/dist/types/RequiredBy.d.ts +1 -0
  216. package/dist/types/RequiredBy.js +2 -0
  217. package/dist/types/Result.d.ts +16 -0
  218. package/dist/types/Result.js +2 -0
  219. package/dist/types/Timestamp.d.ts +17 -0
  220. package/dist/types/Timestamp.js +57 -0
  221. package/dist/types/Transform.d.ts +4 -0
  222. package/dist/types/Transform.js +2 -0
  223. package/dist/types/index.d.ts +14 -0
  224. package/dist/types/index.js +30 -0
  225. package/dist/ui/Accessible.d.ts +5 -0
  226. package/dist/ui/Accessible.js +15 -0
  227. package/dist/ui/BlockThemes.d.ts +19 -0
  228. package/dist/ui/BlockThemes.js +29 -0
  229. package/dist/ui/ColorMode.d.ts +12 -0
  230. package/dist/ui/ColorMode.js +49 -0
  231. package/dist/ui/File.d.ts +43 -0
  232. package/dist/ui/File.js +55 -0
  233. package/dist/ui/FileType.d.ts +8 -0
  234. package/dist/ui/FileType.js +48 -0
  235. package/dist/ui/ImageSource.d.ts +12 -0
  236. package/dist/ui/ImageSource.js +48 -0
  237. package/dist/ui/MimeType.d.ts +28 -0
  238. package/dist/ui/MimeType.js +110 -0
  239. package/dist/ui/Placement.d.ts +21 -0
  240. package/dist/ui/Placement.js +135 -0
  241. package/dist/ui/Position.d.ts +6 -0
  242. package/dist/ui/Position.js +42 -0
  243. package/dist/ui/Selector.d.ts +6 -0
  244. package/dist/ui/Selector.js +23 -0
  245. package/dist/ui/SemanticColor.d.ts +8 -0
  246. package/dist/ui/SemanticColor.js +237 -0
  247. package/dist/ui/Visual.d.ts +24 -0
  248. package/dist/ui/Visual.js +66 -0
  249. package/dist/ui/block-layout/BlockLayout.d.ts +99 -0
  250. package/dist/ui/block-layout/BlockLayout.js +286 -0
  251. package/dist/ui/block-layout/index.d.ts +1 -0
  252. package/dist/ui/block-layout/index.js +17 -0
  253. package/dist/ui/browser/BlurHasher.d.ts +13 -0
  254. package/dist/ui/browser/BlurHasher.js +76 -0
  255. package/dist/ui/browser/Browser.d.ts +107 -0
  256. package/dist/ui/browser/Browser.js +313 -0
  257. package/dist/ui/browser/ImageProxy.d.ts +30 -0
  258. package/dist/ui/browser/ImageProxy.js +132 -0
  259. package/dist/ui/browser/InputEvent.d.ts +13 -0
  260. package/dist/ui/browser/InputEvent.js +2 -0
  261. package/dist/ui/browser/SVGProxy.d.ts +9 -0
  262. package/dist/ui/browser/SVGProxy.js +59 -0
  263. package/dist/ui/browser/VideoProxy.d.ts +42 -0
  264. package/dist/ui/browser/VideoProxy.js +235 -0
  265. package/dist/ui/browser/index.d.ts +6 -0
  266. package/dist/ui/browser/index.js +22 -0
  267. package/dist/ui/fields/Field.d.ts +80 -0
  268. package/dist/ui/fields/Field.js +298 -0
  269. package/dist/ui/fields/FieldList.d.ts +80 -0
  270. package/dist/ui/fields/FieldList.js +421 -0
  271. package/dist/ui/fields/FieldListValidator.d.ts +9 -0
  272. package/dist/ui/fields/FieldListValidator.js +37 -0
  273. package/dist/ui/fields/FieldModel.d.ts +15 -0
  274. package/dist/ui/fields/FieldModel.js +28 -0
  275. package/dist/ui/fields/FieldSerializer.d.ts +13 -0
  276. package/dist/ui/fields/FieldSerializer.js +71 -0
  277. package/dist/ui/fields/FieldValidator.d.ts +19 -0
  278. package/dist/ui/fields/FieldValidator.js +98 -0
  279. package/dist/ui/fields/ObjectField.d.ts +75 -0
  280. package/dist/ui/fields/ObjectField.js +288 -0
  281. package/dist/ui/fields/errors.json +44 -0
  282. package/dist/ui/fields/index.d.ts +7 -0
  283. package/dist/ui/fields/index.js +23 -0
  284. package/dist/ui/fields/validators/AssetValidator.d.ts +9 -0
  285. package/dist/ui/fields/validators/AssetValidator.js +25 -0
  286. package/dist/ui/fields/validators/DateValidator.d.ts +9 -0
  287. package/dist/ui/fields/validators/DateValidator.js +41 -0
  288. package/dist/ui/fields/validators/EnumValidator.d.ts +10 -0
  289. package/dist/ui/fields/validators/EnumValidator.js +77 -0
  290. package/dist/ui/fields/validators/GenericValidator.d.ts +6 -0
  291. package/dist/ui/fields/validators/GenericValidator.js +22 -0
  292. package/dist/ui/fields/validators/LinkValidator.d.ts +9 -0
  293. package/dist/ui/fields/validators/LinkValidator.js +146 -0
  294. package/dist/ui/fields/validators/RichTextValidator.d.ts +6 -0
  295. package/dist/ui/fields/validators/RichTextValidator.js +35 -0
  296. package/dist/ui/fields/validators/TextValidator.d.ts +10 -0
  297. package/dist/ui/fields/validators/TextValidator.js +138 -0
  298. package/dist/ui/fields/validators/TimestampValidator.d.ts +9 -0
  299. package/dist/ui/fields/validators/TimestampValidator.js +41 -0
  300. package/dist/ui/fields/validators/ValidatorHelper.d.ts +23 -0
  301. package/dist/ui/fields/validators/ValidatorHelper.js +55 -0
  302. package/dist/ui/fields/validators/index.d.ts +8 -0
  303. package/dist/ui/fields/validators/index.js +24 -0
  304. package/dist/ui/geometry/AspectRatio.d.ts +27 -0
  305. package/dist/ui/geometry/AspectRatio.js +77 -0
  306. package/dist/ui/geometry/Bounds.d.ts +4 -0
  307. package/dist/ui/geometry/Bounds.js +11 -0
  308. package/dist/ui/geometry/Frame.d.ts +3 -0
  309. package/dist/ui/geometry/Frame.js +2 -0
  310. package/dist/ui/geometry/Insets.d.ts +14 -0
  311. package/dist/ui/geometry/Insets.js +14 -0
  312. package/dist/ui/geometry/PixelSize.d.ts +1 -0
  313. package/dist/ui/geometry/PixelSize.js +2 -0
  314. package/dist/ui/geometry/Point.d.ts +7 -0
  315. package/dist/ui/geometry/Point.js +15 -0
  316. package/dist/ui/geometry/Rect.d.ts +19 -0
  317. package/dist/ui/geometry/Rect.js +68 -0
  318. package/dist/ui/geometry/ScreenSize.d.ts +1 -0
  319. package/dist/ui/geometry/ScreenSize.js +2 -0
  320. package/dist/ui/geometry/Size.d.ts +7 -0
  321. package/dist/ui/geometry/Size.js +9 -0
  322. package/dist/ui/geometry/index.d.ts +9 -0
  323. package/dist/ui/geometry/index.js +25 -0
  324. package/dist/ui/index.d.ts +18 -0
  325. package/dist/ui/index.js +34 -0
  326. package/dist/ui/responsive/Breakpoint.d.ts +8 -0
  327. package/dist/ui/responsive/Breakpoint.js +24 -0
  328. package/dist/ui/responsive/BreakpointObserver.d.ts +16 -0
  329. package/dist/ui/responsive/BreakpointObserver.js +104 -0
  330. package/dist/ui/responsive/Breakpoints.d.ts +5 -0
  331. package/dist/ui/responsive/Breakpoints.js +15 -0
  332. package/dist/ui/responsive/ResponsiveValue.d.ts +7 -0
  333. package/dist/ui/responsive/ResponsiveValue.js +26 -0
  334. package/dist/ui/responsive/index.d.ts +4 -0
  335. package/dist/ui/responsive/index.js +20 -0
  336. package/dist/ui/richtext/LexicalUtils.d.ts +31 -0
  337. package/dist/ui/richtext/LexicalUtils.js +314 -0
  338. package/dist/ui/richtext/StyledTextNode.d.ts +33 -0
  339. package/dist/ui/richtext/StyledTextNode.js +101 -0
  340. package/dist/ui/richtext/index.d.ts +2 -0
  341. package/dist/ui/richtext/index.js +18 -0
  342. package/dist/utils/ArrayUtils.d.ts +17 -0
  343. package/dist/utils/ArrayUtils.js +66 -0
  344. package/dist/utils/ByteSize.d.ts +19 -0
  345. package/dist/utils/ByteSize.js +33 -0
  346. package/dist/utils/DateUtils.d.ts +15 -0
  347. package/dist/utils/DateUtils.js +100 -0
  348. package/dist/utils/Deferral.d.ts +28 -0
  349. package/dist/utils/Deferral.js +107 -0
  350. package/dist/utils/Duration.d.ts +7 -0
  351. package/dist/utils/Duration.js +35 -0
  352. package/dist/utils/Fn.d.ts +14 -0
  353. package/dist/utils/Fn.js +52 -0
  354. package/dist/utils/ObjectUtils.d.ts +89 -0
  355. package/dist/utils/ObjectUtils.js +159 -0
  356. package/dist/utils/Random.d.ts +15 -0
  357. package/dist/utils/Random.js +72 -0
  358. package/dist/utils/StringUtils.d.ts +10 -0
  359. package/dist/utils/StringUtils.js +51 -0
  360. package/dist/utils/UrlUtils.d.ts +22 -0
  361. package/dist/utils/UrlUtils.js +119 -0
  362. package/dist/utils/Value.d.ts +23 -0
  363. package/dist/utils/Value.js +122 -0
  364. package/dist/utils/index.d.ts +12 -0
  365. package/dist/utils/index.js +28 -0
  366. package/dist/utils/isDefined.d.ts +1 -0
  367. package/dist/utils/isDefined.js +6 -0
  368. package/package.json +64 -0
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LexicalUtils = void 0;
4
+ const selection_1 = require("@lexical/selection");
5
+ const lexical_1 = require("lexical");
6
+ const utils_1 = require("../../utils");
7
+ const geometry_1 = require("../geometry");
8
+ const StyledTextNode_1 = require("./StyledTextNode");
9
+ // extensions
10
+ var LexicalUtils;
11
+ (function (LexicalUtils) {
12
+ // guards
13
+ function isSerializedTextNode(node) {
14
+ return utils_1.ObjectUtils.hasKeys(node, 'text', 'detail', 'format')
15
+ && typeof node.text === 'string'
16
+ && typeof node.detail === 'number'
17
+ && typeof node.format === 'number';
18
+ }
19
+ LexicalUtils.isSerializedTextNode = isSerializedTextNode;
20
+ function isSerializedParagraphNode(node) {
21
+ return node.type === 'paragraph'
22
+ && utils_1.ObjectUtils.hasKeys(node, 'textFormat', 'textStyle')
23
+ && typeof node.textFormat === 'number'
24
+ && typeof node.textStyle === 'string';
25
+ }
26
+ LexicalUtils.isSerializedParagraphNode = isSerializedParagraphNode;
27
+ function isSerializedHeadingNode(node) {
28
+ return node.type === 'heading';
29
+ }
30
+ LexicalUtils.isSerializedHeadingNode = isSerializedHeadingNode;
31
+ function isSerializedQuoteNode(node) {
32
+ return node.type === 'quote';
33
+ }
34
+ LexicalUtils.isSerializedQuoteNode = isSerializedQuoteNode;
35
+ function isSerializedListNode(node) {
36
+ return node.type === 'list'
37
+ && utils_1.ObjectUtils.hasKeys(node, 'listType', 'start', 'tag')
38
+ && typeof node.listType === 'string'
39
+ && typeof node.start === 'number'
40
+ && typeof node.tag === 'string';
41
+ }
42
+ LexicalUtils.isSerializedListNode = isSerializedListNode;
43
+ function isSerializedHrNode(node) {
44
+ return node.type === 'horizontalrule';
45
+ }
46
+ LexicalUtils.isSerializedHrNode = isSerializedHrNode;
47
+ function isSerializedListItemNode(node) {
48
+ return node.type === 'listitem'
49
+ && utils_1.ObjectUtils.hasKeys(node, 'value')
50
+ && typeof node.value === 'number';
51
+ }
52
+ LexicalUtils.isSerializedListItemNode = isSerializedListItemNode;
53
+ function isSerializedLinkNode(node) {
54
+ return node.type === 'link'
55
+ && utils_1.ObjectUtils.hasKeys(node, 'url')
56
+ && typeof node.url === 'string';
57
+ }
58
+ LexicalUtils.isSerializedLinkNode = isSerializedLinkNode;
59
+ function isSerializedElementNode(node) {
60
+ return utils_1.ObjectUtils.hasKeys(node, 'children', 'indent')
61
+ && Array.isArray(node.children)
62
+ && typeof node.indent === 'number';
63
+ }
64
+ LexicalUtils.isSerializedElementNode = isSerializedElementNode;
65
+ // methods
66
+ function rootToString(root) {
67
+ // skip if there's no root
68
+ if (!root) {
69
+ return '';
70
+ }
71
+ // helper
72
+ const nodeToString = (node) => {
73
+ if (LexicalUtils.isSerializedElementNode(node)) {
74
+ // render contents
75
+ return LexicalUtils.isSerializedHrNode(node)
76
+ ? '-'
77
+ : node.children.map(nodeToString).join('');
78
+ }
79
+ // or render text
80
+ else if (node.type === 'text' && LexicalUtils.isSerializedTextNode(node)) {
81
+ return node.text;
82
+ }
83
+ // or render 'styled' node
84
+ else if (StyledTextNode_1.StyledTextNode.Data.filter(node)) {
85
+ return node.text;
86
+ }
87
+ // or render line break
88
+ else if (node.type === 'horizontalrule') {
89
+ return '-';
90
+ }
91
+ // or skip unknown node
92
+ else {
93
+ return '';
94
+ }
95
+ };
96
+ // process nodes
97
+ return root.children.map(nodeToString).join('');
98
+ }
99
+ LexicalUtils.rootToString = rootToString;
100
+ function replaceTextNodes({ selection: selectionRaw, onReplaceNode }) {
101
+ // skip if it's not a range
102
+ const selection = selectionRaw === undefined
103
+ ? (0, lexical_1.$getSelection)()
104
+ : selectionRaw;
105
+ if (!(0, lexical_1.$isRangeSelection)(selection)) {
106
+ console.debug('[LexicalUtils/replaceTextNodes] no range selected');
107
+ return false;
108
+ }
109
+ // get selected nodes
110
+ const selectedTextNodes = [];
111
+ (0, selection_1.$forEachSelectedTextNode)(textNode => selectedTextNodes.push(textNode));
112
+ const selectedTextNodesLength = selectedTextNodes.length;
113
+ // skip if there is no selection
114
+ const { anchor, focus } = selection;
115
+ const isBackward = selection.isBackward();
116
+ const startPoint = isBackward ? focus : anchor;
117
+ const endPoint = isBackward ? anchor : focus;
118
+ if (selectedTextNodesLength === 0) {
119
+ // handle case where selection is on a text node
120
+ const node = startPoint.getNode();
121
+ if (startPoint.is(endPoint)
122
+ && startPoint.type === 'text'
123
+ && startPoint.offset === endPoint.offset
124
+ && node instanceof lexical_1.TextNode) {
125
+ // determine start offset
126
+ const text = node.getTextContent();
127
+ let startOffset = startPoint.offset;
128
+ while (startOffset > 0 && text[startOffset - 1] !== ' ') {
129
+ --startOffset;
130
+ }
131
+ // determine end offset
132
+ const textLength = text.length;
133
+ let endOffset = startPoint.offset;
134
+ while (endOffset < textLength && text[endOffset] !== ' ') {
135
+ ++endOffset;
136
+ }
137
+ // split text
138
+ const splitNodes = node.splitText(startOffset, endOffset);
139
+ const replacement = onReplaceNode(startOffset === 0 ? splitNodes[0] : splitNodes[1]);
140
+ // adjust selection
141
+ if (startPoint.type === 'text') {
142
+ startPoint.set(replacement.__key, 0, 'text');
143
+ }
144
+ if (endPoint.type === 'text') {
145
+ endPoint.set(replacement.__key, endOffset - startOffset, 'text');
146
+ }
147
+ return true;
148
+ }
149
+ // otherwise, assume there's nothing to select
150
+ else {
151
+ console.debug('[LexicalUtils/replaceTextNodes] no text selected');
152
+ return false;
153
+ }
154
+ }
155
+ // get selected text nodes (or stop
156
+ console.debug('[LexicalUtils/replaceTextNodes] toggling style on text nodes', selectedTextNodes);
157
+ // assume starting at beginning of selection
158
+ let firstIndex = 0;
159
+ let firstNode = selectedTextNodes[0];
160
+ let startOffset = startPoint.type === 'element' ? 0 : startPoint.offset;
161
+ // move selection if it's at the end of a text node
162
+ if (startPoint.type === 'text' && startOffset === firstNode.getTextContentSize()) {
163
+ console.debug('[LexicalUtils/replaceTextNodes] adjusting selection from the end of previous node');
164
+ firstIndex = 1;
165
+ firstNode = selectedTextNodes[1];
166
+ startOffset = 0;
167
+ }
168
+ console.debug('[LexicalUtils/replaceTextNodes] resolved selection start', {
169
+ isBackward, startPoint, endPoint, firstNode
170
+ });
171
+ // stop if there's no first node
172
+ if (firstNode == null) {
173
+ console.debug('[LexicalUtils/replaceTextNodes] no first node to process');
174
+ return false;
175
+ }
176
+ // find end of selection
177
+ const lastIndex = selectedTextNodesLength - 1;
178
+ let lastNode = selectedTextNodes[lastIndex];
179
+ const endOffset = endPoint.type === 'text'
180
+ ? endPoint.offset
181
+ : lastNode.getTextContentSize();
182
+ console.debug('[LexicalUtils/replaceTextNodes] resolved selection end', {
183
+ lastIndex, endOffset, lastNode
184
+ });
185
+ // handle single node selection
186
+ if (firstNode.is(lastNode)) {
187
+ console.debug('[LexicalUtils/replaceTextNodes] handling single node selection');
188
+ // skip if there's no selection
189
+ if (startOffset === endOffset) {
190
+ console.debug('[LexicalUtils/replaceTextNodes] no selection to process');
191
+ return false;
192
+ }
193
+ // format the entire node if selected (or if it's a token
194
+ if ((0, lexical_1.$isTokenOrSegmented)(firstNode)
195
+ || (startOffset === 0 && endOffset === firstNode.getTextContentSize())) {
196
+ console.debug('[LexicalUtils/replaceTextNodes] formatting entire node');
197
+ onReplaceNode(firstNode);
198
+ }
199
+ // or split the node if it's partially selected and style the selected fragment
200
+ else {
201
+ console.debug('[LexicalUtils/replaceTextNodes] partial node selection');
202
+ // determine the replacement
203
+ const splitNodes = firstNode.splitText(startOffset, endOffset);
204
+ const replacement = onReplaceNode(startOffset === 0 ? splitNodes[0] : splitNodes[1]);
205
+ // adjust selection
206
+ if (startPoint.type === 'text') {
207
+ startPoint.set(replacement.__key, 0, 'text');
208
+ }
209
+ if (endPoint.type === 'text') {
210
+ endPoint.set(replacement.__key, endOffset - startOffset, 'text');
211
+ }
212
+ }
213
+ }
214
+ // TODO: handle multiple nodes being replaced
215
+ else {
216
+ console.debug('[LexicalUtils/replaceTextNodes] handling multi node selection');
217
+ // split the first node if it isn't fully selected
218
+ if (startOffset !== 0 && !(0, lexical_1.$isTokenOrSegmented)(firstNode)) {
219
+ [, firstNode] = firstNode.splitText(startOffset);
220
+ startOffset = 0;
221
+ }
222
+ // TODO: should we merge nodes?
223
+ // style the first mode
224
+ onReplaceNode(firstNode);
225
+ // skip last node of the end offset is 0
226
+ if (endOffset > 0) {
227
+ // split last node if it isn't fully selected
228
+ if (endOffset !== lastNode.getTextContentSize() && !(0, lexical_1.$isTokenOrSegmented)(lastNode)) {
229
+ [lastNode] = lastNode.splitText(endOffset);
230
+ }
231
+ // toggle style on last node
232
+ onReplaceNode(lastNode);
233
+ }
234
+ // process all nodes in between
235
+ for (let i = firstIndex + 1; i < lastIndex; i++) {
236
+ onReplaceNode(selectedTextNodes[i]);
237
+ }
238
+ // update start/end selection (if able to)
239
+ if (startPoint.type === 'text') {
240
+ startPoint.set(firstNode.__key, startOffset, 'text');
241
+ }
242
+ if (endPoint.type === 'text') {
243
+ endPoint.set(lastNode.__key, endOffset, 'text');
244
+ }
245
+ }
246
+ // indicate success
247
+ return true;
248
+ }
249
+ LexicalUtils.replaceTextNodes = replaceTextNodes;
250
+ function findContainer(node, types) {
251
+ // search for match within ancestors
252
+ let parent = node;
253
+ while (parent) {
254
+ // stop if a match is found
255
+ for (const klass of types) {
256
+ if (parent instanceof klass) {
257
+ return parent;
258
+ }
259
+ }
260
+ // keep walking upwards
261
+ parent = parent.getParent();
262
+ }
263
+ // return undefined if there's no match
264
+ return undefined;
265
+ }
266
+ LexicalUtils.findContainer = findContainer;
267
+ function getSelectionRect({ editor, selection: selectionRaw, coerce = false, allowEmpty = false }) {
268
+ var _a, _b;
269
+ // skip if there's no selection
270
+ if (!selectionRaw) {
271
+ return;
272
+ }
273
+ // use given range
274
+ let selection;
275
+ if ((0, lexical_1.$isRangeSelection)(selectionRaw)) {
276
+ selection = selectionRaw;
277
+ }
278
+ // or coerce if allowed
279
+ else if (coerce) {
280
+ const [focusNode] = selectionRaw.getNodes();
281
+ const parentNode = findContainer(focusNode, typeof coerce === 'boolean' ? [lexical_1.ElementNode] : coerce);
282
+ const textNodes = (_a = parentNode === null || parentNode === void 0 ? void 0 : parentNode.getAllTextNodes()) !== null && _a !== void 0 ? _a : [];
283
+ if (textNodes.length > 0) {
284
+ const [anchorNode] = textNodes;
285
+ const focusNode = (_b = utils_1.ArrayUtils.last(textNodes)) !== null && _b !== void 0 ? _b : anchorNode;
286
+ selection = (0, lexical_1.$createRangeSelection)();
287
+ selection.setTextNodeRange(anchorNode, 0, focusNode, focusNode.getTextContentSize());
288
+ }
289
+ }
290
+ // skip if there's no node OR no selection
291
+ if (!selection) {
292
+ return;
293
+ }
294
+ // or skip if we require content and it's empty
295
+ else if (!allowEmpty && selection.getTextContent().length === 0) {
296
+ return;
297
+ }
298
+ // skip if there's no dom range
299
+ const domRange = (0, selection_1.createDOMRange)(editor, selection.anchor.getNode(), selection.anchor.offset, selection.focus.getNode(), selection.focus.offset);
300
+ if (!domRange) {
301
+ return undefined;
302
+ }
303
+ // or skip if there's no selection
304
+ const [anchorRect] = (0, selection_1.createRectsFromDOMRange)(editor, domRange);
305
+ if (!anchorRect) {
306
+ return undefined;
307
+ }
308
+ // or show popup
309
+ else {
310
+ return geometry_1.Rect.fromRect(anchorRect);
311
+ }
312
+ }
313
+ LexicalUtils.getSelectionRect = getSelectionRect;
314
+ })(LexicalUtils || (exports.LexicalUtils = LexicalUtils = {}));
@@ -0,0 +1,33 @@
1
+ import { type EditorConfig, LexicalCommand, type LexicalNode, SerializedLexicalNode, SerializedTextNode, TextNode } from 'lexical';
2
+ export declare class StyledTextNode extends TextNode {
3
+ $config(): import("lexical").StaticNodeConfigRecord<"styled", {
4
+ extends: typeof TextNode;
5
+ stateConfigs: {
6
+ stateConfig: import("lexical").StateConfig<"styled", StyledTextNode.Style>;
7
+ flat: true;
8
+ }[];
9
+ }>;
10
+ getStyleFormat(): StyledTextNode.Style;
11
+ createDOM(config: EditorConfig): HTMLElement;
12
+ updateDOM(prevNode: this, element: HTMLElement, config: EditorConfig): boolean;
13
+ }
14
+ export declare namespace StyledTextNode {
15
+ type Data = Omit<SerializedTextNode, 'type'> & {
16
+ type: typeof Type;
17
+ styled?: Style;
18
+ };
19
+ namespace Data {
20
+ function filter(node: SerializedLexicalNode): node is Data;
21
+ }
22
+ type Style = 'priority' | 'accent' | 'subtle';
23
+ namespace Style {
24
+ const values: ReadonlyArray<Style>;
25
+ function filter(value: string): value is Style;
26
+ function coerce(value: any): Style;
27
+ function updateClasses(element: HTMLElement, style: Style): void;
28
+ }
29
+ const FORMAT_STYLED_TEXT_COMMAND: LexicalCommand<Style>;
30
+ const Type: "styled";
31
+ function $createStyledTextNode(text: string, style: Style): StyledTextNode;
32
+ function $isStyledTextNode(node: LexicalNode | null | undefined): node is StyledTextNode;
33
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StyledTextNode = void 0;
4
+ const lexical_1 = require("lexical");
5
+ const utils_1 = require("../../utils");
6
+ // node
7
+ class StyledTextNode extends lexical_1.TextNode {
8
+ $config() {
9
+ return this.config(StyledTextNode.Type, {
10
+ extends: lexical_1.TextNode,
11
+ stateConfigs: [{ stateConfig: styledState, flat: true }]
12
+ });
13
+ }
14
+ getStyleFormat() {
15
+ return (0, lexical_1.$getState)(this, styledState);
16
+ }
17
+ createDOM(config) {
18
+ // update element based on current styles
19
+ const element = super.createDOM(config);
20
+ const style = (0, lexical_1.$getState)(this, styledState);
21
+ StyledTextNode.Style.updateClasses(element, style);
22
+ // return element
23
+ return element;
24
+ }
25
+ updateDOM(prevNode, element, config) {
26
+ var _a;
27
+ // skip if already handled
28
+ if (super.updateDOM(prevNode, element, config)) {
29
+ return true;
30
+ }
31
+ // update style if it's not changed
32
+ const [style] = (_a = (0, lexical_1.$getStateChange)(this, prevNode, styledState)) !== null && _a !== void 0 ? _a : [];
33
+ if (style) {
34
+ StyledTextNode.Style.updateClasses(element, style);
35
+ }
36
+ // mark as handled
37
+ return false;
38
+ }
39
+ }
40
+ exports.StyledTextNode = StyledTextNode;
41
+ // extensions
42
+ (function (StyledTextNode) {
43
+ let Data;
44
+ (function (Data) {
45
+ // methods
46
+ function filter(node) {
47
+ return node.type === 'styled';
48
+ }
49
+ Data.filter = filter;
50
+ })(Data = StyledTextNode.Data || (StyledTextNode.Data = {}));
51
+ let Style;
52
+ (function (Style) {
53
+ // values
54
+ Style.values = [
55
+ 'priority', 'accent', 'subtle'
56
+ ];
57
+ // methods
58
+ function filter(value) {
59
+ return Style.values.includes(value);
60
+ }
61
+ Style.filter = filter;
62
+ function coerce(value) {
63
+ return utils_1.Value.typeOf(value) === 'string' && filter(value)
64
+ ? value
65
+ : 'priority';
66
+ }
67
+ Style.coerce = coerce;
68
+ function updateClasses(element, style) {
69
+ // remove unused classes
70
+ const { classList } = element;
71
+ switch (style) {
72
+ case 'priority':
73
+ classList.add('priority', 'text-primary', 'font-bold');
74
+ break;
75
+ case 'accent':
76
+ classList.add('accent', 'bg-primary-tint/faded');
77
+ break;
78
+ case 'subtle':
79
+ classList.add('subtle', 'text-ix-disabled-content', 'font-bold');
80
+ break;
81
+ }
82
+ }
83
+ Style.updateClasses = updateClasses;
84
+ })(Style = StyledTextNode.Style || (StyledTextNode.Style = {}));
85
+ // values
86
+ StyledTextNode.FORMAT_STYLED_TEXT_COMMAND = (0, lexical_1.createCommand)('styledText.insert');
87
+ StyledTextNode.Type = 'styled';
88
+ // methods
89
+ function $createStyledTextNode(text, style) {
90
+ return (0, lexical_1.$setState)((0, lexical_1.$create)(StyledTextNode).setTextContent(text), styledState, style);
91
+ }
92
+ StyledTextNode.$createStyledTextNode = $createStyledTextNode;
93
+ function $isStyledTextNode(node) {
94
+ return node instanceof StyledTextNode;
95
+ }
96
+ StyledTextNode.$isStyledTextNode = $isStyledTextNode;
97
+ })(StyledTextNode || (exports.StyledTextNode = StyledTextNode = {}));
98
+ // helpers
99
+ const styledState = (0, lexical_1.createState)('styled', {
100
+ parse: value => StyledTextNode.Style.coerce(value)
101
+ });
@@ -0,0 +1,2 @@
1
+ export * from './LexicalUtils';
2
+ export * from './StyledTextNode';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./LexicalUtils"), exports);
18
+ __exportStar(require("./StyledTextNode"), exports);
@@ -0,0 +1,17 @@
1
+ import { JsonValue } from 'type-fest';
2
+ import { Transform } from '../types';
3
+ export declare namespace ArrayUtils {
4
+ function coerce<T>(maybeArray: T[] | T | undefined | null): T[];
5
+ function first<T>(array: ReadonlyArray<T>): T | undefined;
6
+ function last<T>(array: ReadonlyArray<T>): T | undefined;
7
+ /**
8
+ * Creates a sequential array of items from [start, end] inclusive, incrementing by 1.
9
+ *
10
+ * @param end - the end of the series (inclusive)
11
+ * @param start - the first element in the series (inclusive - defaults to 0)
12
+ */
13
+ function series(end: number, start?: number): number[];
14
+ function fill<T extends JsonValue>(count: number, generatorOrValue: Transform<number, T> | T): T[];
15
+ function circularIndex(arrayOrLength: ReadonlyArray<unknown> | number, index: number): number;
16
+ function circularGet<T>(array: ReadonlyArray<T>, index: number): T;
17
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArrayUtils = void 0;
4
+ // namespace
5
+ var ArrayUtils;
6
+ (function (ArrayUtils) {
7
+ function coerce(maybeArray) {
8
+ return maybeArray
9
+ ? Array.isArray(maybeArray)
10
+ ? maybeArray
11
+ : [maybeArray]
12
+ : [];
13
+ }
14
+ ArrayUtils.coerce = coerce;
15
+ function first(array) {
16
+ return array.length > 0
17
+ ? array[0]
18
+ : undefined;
19
+ }
20
+ ArrayUtils.first = first;
21
+ function last(array) {
22
+ return array.length > 0
23
+ ? array[array.length - 1]
24
+ : undefined;
25
+ }
26
+ ArrayUtils.last = last;
27
+ /**
28
+ * Creates a sequential array of items from [start, end] inclusive, incrementing by 1.
29
+ *
30
+ * @param end - the end of the series (inclusive)
31
+ * @param start - the first element in the series (inclusive - defaults to 0)
32
+ */
33
+ function series(end, start = 0) {
34
+ // determine size
35
+ const size = end - start + 1;
36
+ // create array + populate
37
+ const series = Array(size);
38
+ for (let i = 0; i < size; ++i) {
39
+ series[i] = i + start;
40
+ }
41
+ // return series
42
+ return series;
43
+ }
44
+ ArrayUtils.series = series;
45
+ function fill(count, generatorOrValue) {
46
+ // create array
47
+ if (typeof generatorOrValue === 'function') {
48
+ return Array(count).fill(undefined)
49
+ .map((_, index) => generatorOrValue(index));
50
+ }
51
+ // or just fill it with the value
52
+ else {
53
+ return Array(count).fill(generatorOrValue);
54
+ }
55
+ }
56
+ ArrayUtils.fill = fill;
57
+ function circularIndex(arrayOrLength, index) {
58
+ const length = typeof arrayOrLength === 'number' ? arrayOrLength : arrayOrLength.length;
59
+ return (index % length + length) % length;
60
+ }
61
+ ArrayUtils.circularIndex = circularIndex;
62
+ function circularGet(array, index) {
63
+ return array[circularIndex(array, index)];
64
+ }
65
+ ArrayUtils.circularGet = circularGet;
66
+ })(ArrayUtils || (exports.ArrayUtils = ArrayUtils = {}));
@@ -0,0 +1,19 @@
1
+ export declare class ByteSize {
2
+ private _bytes;
3
+ constructor(bytes: number);
4
+ get value(): number;
5
+ set value(bytes: number);
6
+ components({ precision }?: ByteSize.ComponentsOptions): ByteSize.Components;
7
+ static fromKb(kiloBytes: number): ByteSize;
8
+ static formMb(megabytes: number): ByteSize;
9
+ }
10
+ export declare namespace ByteSize {
11
+ type Components = {
12
+ size: string;
13
+ units: string;
14
+ unitsLong: string;
15
+ };
16
+ type ComponentsOptions = {
17
+ precision?: number;
18
+ };
19
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ByteSize = void 0;
7
+ const byte_size_1 = __importDefault(require("byte-size"));
8
+ // namespace
9
+ class ByteSize {
10
+ constructor(bytes) {
11
+ // initialize instance variables
12
+ this._bytes = bytes;
13
+ }
14
+ get value() {
15
+ return this._bytes;
16
+ }
17
+ set value(bytes) {
18
+ this._bytes = bytes;
19
+ }
20
+ components({ precision = 1 } = {}) {
21
+ // parse bytes
22
+ const { value: size, unit: units, long: unitsLong } = (0, byte_size_1.default)(this._bytes, { precision });
23
+ // return components
24
+ return { size, units, unitsLong };
25
+ }
26
+ static fromKb(kiloBytes) {
27
+ return new ByteSize(kiloBytes * 1000);
28
+ }
29
+ static formMb(megabytes) {
30
+ return new ByteSize(megabytes * 1000000);
31
+ }
32
+ }
33
+ exports.ByteSize = ByteSize;
@@ -0,0 +1,15 @@
1
+ export declare namespace DateUtils {
2
+ type DateLike = number | Date;
3
+ type Resolution = 'second' | 'minute';
4
+ const minute = 60;
5
+ const hour: number;
6
+ const day: number;
7
+ function ageInSeconds(from: DateLike, to?: DateLike): number;
8
+ function ageInWeeks(from: DateLike, to?: DateLike): number;
9
+ type FormatOptions = {
10
+ variant?: FormatVariant;
11
+ };
12
+ type FormatVariant = 'datetime' | 'date' | 'full-numeric';
13
+ function format(time: DateLike, { variant }?: FormatOptions): string;
14
+ function formatAge(from: DateLike, resolution?: Resolution): string;
15
+ }