@milaboratories/pl-model-common 1.25.1 → 1.25.3

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 (288) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/author_marker.d.ts +9 -6
  3. package/dist/base32_encode.cjs +40 -46
  4. package/dist/base32_encode.cjs.map +1 -1
  5. package/dist/base32_encode.js +40 -45
  6. package/dist/base32_encode.js.map +1 -1
  7. package/dist/base64.cjs +5 -4
  8. package/dist/base64.cjs.map +1 -1
  9. package/dist/base64.d.ts +10 -6
  10. package/dist/base64.js +5 -3
  11. package/dist/base64.js.map +1 -1
  12. package/dist/block_state.d.ts +21 -23
  13. package/dist/bmodel/block_config.cjs +9 -10
  14. package/dist/bmodel/block_config.cjs.map +1 -1
  15. package/dist/bmodel/block_config.d.ts +53 -72
  16. package/dist/bmodel/block_config.js +9 -9
  17. package/dist/bmodel/block_config.js.map +1 -1
  18. package/dist/bmodel/code.cjs +7 -6
  19. package/dist/bmodel/code.cjs.map +1 -1
  20. package/dist/bmodel/code.d.ts +17 -13
  21. package/dist/bmodel/code.js +6 -4
  22. package/dist/bmodel/code.js.map +1 -1
  23. package/dist/bmodel/container.d.ts +46 -44
  24. package/dist/bmodel/index.cjs +3 -0
  25. package/dist/bmodel/index.d.ts +5 -6
  26. package/dist/bmodel/index.js +3 -0
  27. package/dist/bmodel/normalization.cjs +90 -106
  28. package/dist/bmodel/normalization.cjs.map +1 -1
  29. package/dist/bmodel/normalization.d.ts +7 -3
  30. package/dist/bmodel/normalization.js +90 -105
  31. package/dist/bmodel/normalization.js.map +1 -1
  32. package/dist/bmodel/types.d.ts +4 -1
  33. package/dist/branding.d.ts +5 -5
  34. package/dist/common_types.d.ts +19 -15
  35. package/dist/driver_kit.d.ts +25 -17
  36. package/dist/drivers/ChunkedStreamReader.cjs +168 -203
  37. package/dist/drivers/ChunkedStreamReader.cjs.map +1 -1
  38. package/dist/drivers/ChunkedStreamReader.d.ts +104 -100
  39. package/dist/drivers/ChunkedStreamReader.js +168 -202
  40. package/dist/drivers/ChunkedStreamReader.js.map +1 -1
  41. package/dist/drivers/blob.cjs +15 -17
  42. package/dist/drivers/blob.cjs.map +1 -1
  43. package/dist/drivers/blob.d.ts +35 -35
  44. package/dist/drivers/blob.js +14 -15
  45. package/dist/drivers/blob.js.map +1 -1
  46. package/dist/drivers/index.cjs +18 -0
  47. package/dist/drivers/index.d.ts +29 -9
  48. package/dist/drivers/index.js +18 -0
  49. package/dist/drivers/interfaces.d.ts +17 -14
  50. package/dist/drivers/log.cjs +4 -3
  51. package/dist/drivers/log.cjs.map +1 -1
  52. package/dist/drivers/log.d.ts +52 -49
  53. package/dist/drivers/log.js +4 -2
  54. package/dist/drivers/log.js.map +1 -1
  55. package/dist/drivers/ls.cjs +16 -19
  56. package/dist/drivers/ls.cjs.map +1 -1
  57. package/dist/drivers/ls.d.ts +73 -76
  58. package/dist/drivers/ls.js +16 -17
  59. package/dist/drivers/ls.js.map +1 -1
  60. package/dist/drivers/pframe/column_filter.d.ts +19 -15
  61. package/dist/drivers/pframe/data_info.cjs +201 -252
  62. package/dist/drivers/pframe/data_info.cjs.map +1 -1
  63. package/dist/drivers/pframe/data_info.d.ts +84 -109
  64. package/dist/drivers/pframe/data_info.js +201 -250
  65. package/dist/drivers/pframe/data_info.js.map +1 -1
  66. package/dist/drivers/pframe/data_types.cjs +38 -63
  67. package/dist/drivers/pframe/data_types.cjs.map +1 -1
  68. package/dist/drivers/pframe/data_types.d.ts +91 -93
  69. package/dist/drivers/pframe/data_types.js +38 -61
  70. package/dist/drivers/pframe/data_types.js.map +1 -1
  71. package/dist/drivers/pframe/driver.cjs +7 -0
  72. package/dist/drivers/pframe/driver.cjs.map +1 -0
  73. package/dist/drivers/pframe/driver.d.ts +50 -45
  74. package/dist/drivers/pframe/driver.js +6 -0
  75. package/dist/drivers/pframe/driver.js.map +1 -0
  76. package/dist/drivers/pframe/filter_spec.d.ts +127 -123
  77. package/dist/drivers/pframe/find_columns.d.ts +21 -17
  78. package/dist/drivers/pframe/index.cjs +15 -0
  79. package/dist/drivers/pframe/index.d.ts +23 -16
  80. package/dist/drivers/pframe/index.js +15 -0
  81. package/dist/drivers/pframe/linker_columns.cjs +184 -238
  82. package/dist/drivers/pframe/linker_columns.cjs.map +1 -1
  83. package/dist/drivers/pframe/linker_columns.d.ts +45 -38
  84. package/dist/drivers/pframe/linker_columns.js +184 -236
  85. package/dist/drivers/pframe/linker_columns.js.map +1 -1
  86. package/dist/drivers/pframe/pframe.d.ts +26 -21
  87. package/dist/drivers/pframe/query/index.cjs +1 -0
  88. package/dist/drivers/pframe/query/index.d.ts +3 -4
  89. package/dist/drivers/pframe/query/index.js +1 -0
  90. package/dist/drivers/pframe/query/query_common.d.ts +205 -247
  91. package/dist/drivers/pframe/query/query_data.d.ts +25 -23
  92. package/dist/drivers/pframe/query/query_spec.d.ts +30 -29
  93. package/dist/drivers/pframe/query/utils.cjs +164 -183
  94. package/dist/drivers/pframe/query/utils.cjs.map +1 -1
  95. package/dist/drivers/pframe/query/utils.d.ts +13 -12
  96. package/dist/drivers/pframe/query/utils.js +164 -181
  97. package/dist/drivers/pframe/query/utils.js.map +1 -1
  98. package/dist/drivers/pframe/spec/anchored.cjs +178 -216
  99. package/dist/drivers/pframe/spec/anchored.cjs.map +1 -1
  100. package/dist/drivers/pframe/spec/anchored.d.ts +53 -49
  101. package/dist/drivers/pframe/spec/anchored.js +176 -214
  102. package/dist/drivers/pframe/spec/anchored.js.map +1 -1
  103. package/dist/drivers/pframe/spec/filtered_column.cjs +8 -7
  104. package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -1
  105. package/dist/drivers/pframe/spec/filtered_column.d.ts +20 -17
  106. package/dist/drivers/pframe/spec/filtered_column.js +8 -6
  107. package/dist/drivers/pframe/spec/filtered_column.js.map +1 -1
  108. package/dist/drivers/pframe/spec/ids.cjs +16 -14
  109. package/dist/drivers/pframe/spec/ids.cjs.map +1 -1
  110. package/dist/drivers/pframe/spec/ids.d.ts +13 -8
  111. package/dist/drivers/pframe/spec/ids.js +14 -12
  112. package/dist/drivers/pframe/spec/ids.js.map +1 -1
  113. package/dist/drivers/pframe/spec/index.cjs +6 -0
  114. package/dist/drivers/pframe/spec/index.d.ts +6 -7
  115. package/dist/drivers/pframe/spec/index.js +6 -0
  116. package/dist/drivers/pframe/spec/native_id.cjs +16 -16
  117. package/dist/drivers/pframe/spec/native_id.cjs.map +1 -1
  118. package/dist/drivers/pframe/spec/native_id.d.ts +9 -4
  119. package/dist/drivers/pframe/spec/native_id.js +13 -13
  120. package/dist/drivers/pframe/spec/native_id.js.map +1 -1
  121. package/dist/drivers/pframe/spec/selectors.cjs +72 -112
  122. package/dist/drivers/pframe/spec/selectors.cjs.map +1 -1
  123. package/dist/drivers/pframe/spec/selectors.d.ts +99 -94
  124. package/dist/drivers/pframe/spec/selectors.js +72 -110
  125. package/dist/drivers/pframe/spec/selectors.js.map +1 -1
  126. package/dist/drivers/pframe/spec/spec.cjs +282 -324
  127. package/dist/drivers/pframe/spec/spec.cjs.map +1 -1
  128. package/dist/drivers/pframe/spec/spec.d.ts +263 -272
  129. package/dist/drivers/pframe/spec/spec.js +281 -322
  130. package/dist/drivers/pframe/spec/spec.js.map +1 -1
  131. package/dist/drivers/pframe/table.d.ts +28 -24
  132. package/dist/drivers/pframe/table_calculate.cjs +117 -147
  133. package/dist/drivers/pframe/table_calculate.cjs.map +1 -1
  134. package/dist/drivers/pframe/table_calculate.d.ts +219 -220
  135. package/dist/drivers/pframe/table_calculate.js +117 -145
  136. package/dist/drivers/pframe/table_calculate.js.map +1 -1
  137. package/dist/drivers/pframe/table_common.cjs +13 -14
  138. package/dist/drivers/pframe/table_common.cjs.map +1 -1
  139. package/dist/drivers/pframe/table_common.d.ts +24 -19
  140. package/dist/drivers/pframe/table_common.js +13 -13
  141. package/dist/drivers/pframe/table_common.js.map +1 -1
  142. package/dist/drivers/pframe/unique_values.d.ts +23 -18
  143. package/dist/drivers/upload.d.ts +21 -18
  144. package/dist/drivers/urls.cjs +5 -6
  145. package/dist/drivers/urls.cjs.map +1 -1
  146. package/dist/drivers/urls.d.ts +12 -9
  147. package/dist/drivers/urls.js +5 -5
  148. package/dist/drivers/urls.js.map +1 -1
  149. package/dist/errors.cjs +65 -86
  150. package/dist/errors.cjs.map +1 -1
  151. package/dist/errors.d.ts +36 -33
  152. package/dist/errors.js +65 -85
  153. package/dist/errors.js.map +1 -1
  154. package/dist/flags/block_flags.cjs +7 -6
  155. package/dist/flags/block_flags.cjs.map +1 -1
  156. package/dist/flags/block_flags.d.ts +12 -8
  157. package/dist/flags/block_flags.js +7 -5
  158. package/dist/flags/block_flags.js.map +1 -1
  159. package/dist/flags/flag_utils.cjs +69 -108
  160. package/dist/flags/flag_utils.cjs.map +1 -1
  161. package/dist/flags/flag_utils.d.ts +40 -42
  162. package/dist/flags/flag_utils.js +70 -107
  163. package/dist/flags/flag_utils.js.map +1 -1
  164. package/dist/flags/type_utils.d.ts +12 -11
  165. package/dist/httpAuth.cjs +16 -20
  166. package/dist/httpAuth.cjs.map +1 -1
  167. package/dist/httpAuth.d.ts +10 -7
  168. package/dist/httpAuth.js +16 -19
  169. package/dist/httpAuth.js.map +1 -1
  170. package/dist/index.cjs +176 -179
  171. package/dist/index.d.ts +58 -20
  172. package/dist/index.js +37 -34
  173. package/dist/json.cjs +10 -8
  174. package/dist/json.cjs.map +1 -1
  175. package/dist/json.d.ts +18 -18
  176. package/dist/json.js +8 -6
  177. package/dist/json.js.map +1 -1
  178. package/dist/navigation.cjs +3 -2
  179. package/dist/navigation.cjs.map +1 -1
  180. package/dist/navigation.d.ts +18 -21
  181. package/dist/navigation.js +3 -1
  182. package/dist/navigation.js.map +1 -1
  183. package/dist/plid.cjs +16 -20
  184. package/dist/plid.cjs.map +1 -1
  185. package/dist/plid.d.ts +11 -7
  186. package/dist/plid.js +15 -18
  187. package/dist/plid.js.map +1 -1
  188. package/dist/pool/entry.d.ts +11 -11
  189. package/dist/pool/index.d.ts +3 -4
  190. package/dist/pool/query.cjs +21 -43
  191. package/dist/pool/query.cjs.map +1 -1
  192. package/dist/pool/query.d.ts +25 -20
  193. package/dist/pool/query.js +20 -40
  194. package/dist/pool/query.js.map +1 -1
  195. package/dist/pool/spec.cjs +40 -47
  196. package/dist/pool/spec.cjs.map +1 -1
  197. package/dist/pool/spec.d.ts +33 -31
  198. package/dist/pool/spec.js +40 -45
  199. package/dist/pool/spec.js.map +1 -1
  200. package/dist/ref.cjs +51 -71
  201. package/dist/ref.cjs.map +1 -1
  202. package/dist/ref.d.ts +36 -33
  203. package/dist/ref.js +50 -69
  204. package/dist/ref.js.map +1 -1
  205. package/dist/utag.d.ts +18 -14
  206. package/dist/util.cjs +8 -7
  207. package/dist/util.cjs.map +1 -1
  208. package/dist/util.d.ts +5 -2
  209. package/dist/util.js +8 -6
  210. package/dist/util.js.map +1 -1
  211. package/dist/value_or_error.cjs +7 -3
  212. package/dist/value_or_error.cjs.map +1 -1
  213. package/dist/value_or_error.d.ts +9 -6
  214. package/dist/value_or_error.js +7 -2
  215. package/dist/value_or_error.js.map +1 -1
  216. package/package.json +6 -6
  217. package/src/flags/block_flags.ts +2 -1
  218. package/src/flags/flag_utils.ts +0 -22
  219. package/dist/author_marker.d.ts.map +0 -1
  220. package/dist/base32_encode.d.ts +0 -8
  221. package/dist/base32_encode.d.ts.map +0 -1
  222. package/dist/base64.d.ts.map +0 -1
  223. package/dist/block_state.d.ts.map +0 -1
  224. package/dist/bmodel/block_config.d.ts.map +0 -1
  225. package/dist/bmodel/code.d.ts.map +0 -1
  226. package/dist/bmodel/container.d.ts.map +0 -1
  227. package/dist/bmodel/index.d.ts.map +0 -1
  228. package/dist/bmodel/normalization.d.ts.map +0 -1
  229. package/dist/bmodel/types.d.ts.map +0 -1
  230. package/dist/branding.d.ts.map +0 -1
  231. package/dist/common_types.d.ts.map +0 -1
  232. package/dist/driver_kit.d.ts.map +0 -1
  233. package/dist/drivers/ChunkedStreamReader.d.ts.map +0 -1
  234. package/dist/drivers/blob.d.ts.map +0 -1
  235. package/dist/drivers/index.d.ts.map +0 -1
  236. package/dist/drivers/interfaces.d.ts.map +0 -1
  237. package/dist/drivers/log.d.ts.map +0 -1
  238. package/dist/drivers/ls.d.ts.map +0 -1
  239. package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
  240. package/dist/drivers/pframe/data_info.d.ts.map +0 -1
  241. package/dist/drivers/pframe/data_types.d.ts.map +0 -1
  242. package/dist/drivers/pframe/driver.d.ts.map +0 -1
  243. package/dist/drivers/pframe/filter_spec.d.ts.map +0 -1
  244. package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
  245. package/dist/drivers/pframe/index.d.ts.map +0 -1
  246. package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
  247. package/dist/drivers/pframe/pframe.d.ts.map +0 -1
  248. package/dist/drivers/pframe/query/index.d.ts.map +0 -1
  249. package/dist/drivers/pframe/query/query_common.d.ts.map +0 -1
  250. package/dist/drivers/pframe/query/query_data.d.ts.map +0 -1
  251. package/dist/drivers/pframe/query/query_spec.d.ts.map +0 -1
  252. package/dist/drivers/pframe/query/utils.d.ts.map +0 -1
  253. package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
  254. package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
  255. package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
  256. package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
  257. package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
  258. package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
  259. package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
  260. package/dist/drivers/pframe/table.d.ts.map +0 -1
  261. package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
  262. package/dist/drivers/pframe/table_common.d.ts.map +0 -1
  263. package/dist/drivers/pframe/type_util.d.ts +0 -5
  264. package/dist/drivers/pframe/type_util.d.ts.map +0 -1
  265. package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
  266. package/dist/drivers/upload.d.ts.map +0 -1
  267. package/dist/drivers/urls.d.ts.map +0 -1
  268. package/dist/errors.d.ts.map +0 -1
  269. package/dist/flags/block_flags.d.ts.map +0 -1
  270. package/dist/flags/flag_utils.d.ts.map +0 -1
  271. package/dist/flags/index.d.ts +0 -4
  272. package/dist/flags/index.d.ts.map +0 -1
  273. package/dist/flags/type_utils.d.ts.map +0 -1
  274. package/dist/httpAuth.d.ts.map +0 -1
  275. package/dist/index.cjs.map +0 -1
  276. package/dist/index.d.ts.map +0 -1
  277. package/dist/index.js.map +0 -1
  278. package/dist/json.d.ts.map +0 -1
  279. package/dist/navigation.d.ts.map +0 -1
  280. package/dist/plid.d.ts.map +0 -1
  281. package/dist/pool/entry.d.ts.map +0 -1
  282. package/dist/pool/index.d.ts.map +0 -1
  283. package/dist/pool/query.d.ts.map +0 -1
  284. package/dist/pool/spec.d.ts.map +0 -1
  285. package/dist/ref.d.ts.map +0 -1
  286. package/dist/utag.d.ts.map +0 -1
  287. package/dist/util.d.ts.map +0 -1
  288. package/dist/value_or_error.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sources":["../src/errors.ts"],"sourcesContent":["/**\n * Just for convenience, usually it is an Error with name 'AbortError'\n */\nexport class AbortError extends Error {\n name = \"AbortError\";\n}\n\n/**\n * Throw this to show a message without stack trace in UI\n */\nexport class UiError extends Error {\n name = \"UiError\";\n}\n\nexport function isAbortError(error: unknown): error is Error & { name: \"AbortError\" } {\n return error instanceof Error && error.name === \"AbortError\";\n}\n\nexport function hasAbortError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return error.name === \"AbortError\" || hasAbortError(error.cause);\n}\n\nexport function isAggregateError(error: unknown): error is AggregateError {\n return error instanceof Error && error.name === \"AggregateError\";\n}\n\nexport class PFrameError extends Error {\n name = \"PFrameError\";\n}\n\nexport function isPFrameError(error: unknown): error is PFrameError {\n return error instanceof Error && error.name === \"PFrameError\";\n}\n\nexport class PFrameDriverError extends PFrameError {\n name = \"PFrameError.Driver\";\n}\n\nexport function isPFrameDriverError(error: unknown): error is PFrameDriverError {\n return error instanceof Error && error.name === \"PFrameError.Driver\";\n}\n\nfunction stringifyValue(value: unknown): string {\n if (typeof value === \"string\") {\n return `String value was thrown: ${value}`;\n }\n\n if (value && typeof value === \"object\") {\n try {\n return `Plain object was thrown: ${JSON.stringify(value)}`;\n } catch (jsonError) {\n const errorMessage = jsonError instanceof Error ? jsonError.message : String(jsonError);\n return `Non-serializable object was thrown (JSON.stringify failed: ${errorMessage}): ${String(value)}`;\n }\n }\n\n return String(`Non-Error value (${typeof value}) was thrown: ${value}`);\n}\n\nexport function ensureError(value: unknown): Error {\n if (value instanceof Error) {\n return value;\n }\n\n return new Error(stringifyValue(value));\n}\n\n// Error serialization for IPC/network transmission (Error objects can't be JSON serialized)\n\nexport type SerializedError = {\n name: string;\n message: string;\n stack: string | undefined;\n cause?: SerializedError;\n};\n\nexport function deserializeError(obj: SerializedError): Error {\n const cause = obj.cause ? deserializeError(obj.cause) : undefined;\n\n const error = new Error(obj.message, cause !== undefined ? { cause } : undefined);\n error.name = obj.name || \"Error\";\n error.stack = obj.stack;\n\n return error;\n}\n\nexport function serializeError(e: unknown): SerializedError {\n const error = ensureError(e);\n const cause = error.cause ? serializeError(error.cause) : undefined;\n\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n ...(error.cause !== undefined && { cause }),\n };\n}\n\nexport type ResultOrError<S, F = Error> =\n | {\n value: S;\n error?: undefined;\n }\n | {\n error: F;\n };\n\nexport function unwrapResult<T>(result: ResultOrError<T, Error | SerializedError>): T {\n if (result.error) {\n throw result.error instanceof Error ? result.error : deserializeError(result.error);\n }\n return result.value;\n}\n\nexport function serializeResult<T>(result: ResultOrError<T>): ResultOrError<T, SerializedError> {\n if (result.error) {\n return { error: serializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function deserializeResult<T>(result: ResultOrError<T, SerializedError>): ResultOrError<T> {\n if (result.error) {\n return { error: deserializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function wrapCallback<T>(callback: () => T): ResultOrError<T> {\n try {\n const value = callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport async function wrapAsyncCallback<T>(callback: () => Promise<T>): Promise<ResultOrError<T>> {\n try {\n const value = await callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport function wrapAndSerialize<T>(callback: () => T): ResultOrError<T, SerializedError> {\n const result = wrapCallback(callback);\n return serializeResult(result);\n}\n\nexport async function wrapAndSerializeAsync<T>(\n callback: () => Promise<T>,\n): Promise<ResultOrError<T, SerializedError>> {\n const result = await wrapAsyncCallback(callback);\n return serializeResult(result);\n}\n"],"names":[],"mappings":"AAAA;;AAEG;AACG,MAAO,UAAW,SAAQ,KAAK,CAAA;IACnC,IAAI,GAAG,YAAY;AACpB;AAED;;AAEG;AACG,MAAO,OAAQ,SAAQ,KAAK,CAAA;IAChC,IAAI,GAAG,SAAS;AACjB;AAEK,SAAU,YAAY,CAAC,KAAc,EAAA;IACzC,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;AAC9D;AAEM,SAAU,aAAa,CAAC,KAAc,EAAA;AAC1C,IAAA,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,EAAE;AAC7B,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,OAAO,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC;AAClE;AAEM,SAAU,gBAAgB,CAAC,KAAc,EAAA;IAC7C,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB;AAClE;AAEM,MAAO,WAAY,SAAQ,KAAK,CAAA;IACpC,IAAI,GAAG,aAAa;AACrB;AAEK,SAAU,aAAa,CAAC,KAAc,EAAA;IAC1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AM,CAAC,KAAK,CAAC,EAAE;IAClD;AACA,IAAA,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;AAChC;AAEM,SAAU,YAAY,CAAI,QAAiB,EAAA;AAC/C,IAAA,IAAI;AACF,QAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;QACxB,OAAO,EAAE,KAAK,EAAE;IAClB;IAAE,OAAO,KAAK,EAAE;QACd,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE;IACtC;AACF;AAEO,eAAe,iBAAiB,CAAI,QAA0B,EAAA;AACnE,IAAA,IAAI;AACF,QAAA,MAAM,KAAK,GAAG,MAAM,QAAQ,EAAE;QAC9B,OAAO,EAAE,KAAK,EAAE;IAClB;IAAE,OAAO,KAAK,EAAE;QACd,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE;IACtC;AACF;AAEM,SAAU,gBAAgB,CAAI,QAAiB,EAAA;AACnD,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC;AACrC,IAAA,OAAO,eAAe,CAAC,MAAM,CAAC;AAChC;AAEO,eAAe,qBAAqB,CACzC,QAA0B,EAAA;AAE1B,IAAA,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAAC;AAChD,IAAA,OAAO,eAAe,CAAC,MAAM,CAAC;AAChC;;;;"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Just for convenience, usually it is an Error with name 'AbortError'\n */\nexport class AbortError extends Error {\n name = \"AbortError\";\n}\n\n/**\n * Throw this to show a message without stack trace in UI\n */\nexport class UiError extends Error {\n name = \"UiError\";\n}\n\nexport function isAbortError(error: unknown): error is Error & { name: \"AbortError\" } {\n return error instanceof Error && error.name === \"AbortError\";\n}\n\nexport function hasAbortError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return error.name === \"AbortError\" || hasAbortError(error.cause);\n}\n\nexport function isAggregateError(error: unknown): error is AggregateError {\n return error instanceof Error && error.name === \"AggregateError\";\n}\n\nexport class PFrameError extends Error {\n name = \"PFrameError\";\n}\n\nexport function isPFrameError(error: unknown): error is PFrameError {\n return error instanceof Error && error.name === \"PFrameError\";\n}\n\nexport class PFrameDriverError extends PFrameError {\n name = \"PFrameError.Driver\";\n}\n\nexport function isPFrameDriverError(error: unknown): error is PFrameDriverError {\n return error instanceof Error && error.name === \"PFrameError.Driver\";\n}\n\nfunction stringifyValue(value: unknown): string {\n if (typeof value === \"string\") {\n return `String value was thrown: ${value}`;\n }\n\n if (value && typeof value === \"object\") {\n try {\n return `Plain object was thrown: ${JSON.stringify(value)}`;\n } catch (jsonError) {\n const errorMessage = jsonError instanceof Error ? jsonError.message : String(jsonError);\n return `Non-serializable object was thrown (JSON.stringify failed: ${errorMessage}): ${String(value)}`;\n }\n }\n\n return String(`Non-Error value (${typeof value}) was thrown: ${value}`);\n}\n\nexport function ensureError(value: unknown): Error {\n if (value instanceof Error) {\n return value;\n }\n\n return new Error(stringifyValue(value));\n}\n\n// Error serialization for IPC/network transmission (Error objects can't be JSON serialized)\n\nexport type SerializedError = {\n name: string;\n message: string;\n stack: string | undefined;\n cause?: SerializedError;\n};\n\nexport function deserializeError(obj: SerializedError): Error {\n const cause = obj.cause ? deserializeError(obj.cause) : undefined;\n\n const error = new Error(obj.message, cause !== undefined ? { cause } : undefined);\n error.name = obj.name || \"Error\";\n error.stack = obj.stack;\n\n return error;\n}\n\nexport function serializeError(e: unknown): SerializedError {\n const error = ensureError(e);\n const cause = error.cause ? serializeError(error.cause) : undefined;\n\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n ...(error.cause !== undefined && { cause }),\n };\n}\n\nexport type ResultOrError<S, F = Error> =\n | {\n value: S;\n error?: undefined;\n }\n | {\n error: F;\n };\n\nexport function unwrapResult<T>(result: ResultOrError<T, Error | SerializedError>): T {\n if (result.error) {\n throw result.error instanceof Error ? result.error : deserializeError(result.error);\n }\n return result.value;\n}\n\nexport function serializeResult<T>(result: ResultOrError<T>): ResultOrError<T, SerializedError> {\n if (result.error) {\n return { error: serializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function deserializeResult<T>(result: ResultOrError<T, SerializedError>): ResultOrError<T> {\n if (result.error) {\n return { error: deserializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function wrapCallback<T>(callback: () => T): ResultOrError<T> {\n try {\n const value = callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport async function wrapAsyncCallback<T>(callback: () => Promise<T>): Promise<ResultOrError<T>> {\n try {\n const value = await callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport function wrapAndSerialize<T>(callback: () => T): ResultOrError<T, SerializedError> {\n const result = wrapCallback(callback);\n return serializeResult(result);\n}\n\nexport async function wrapAndSerializeAsync<T>(\n callback: () => Promise<T>,\n): Promise<ResultOrError<T, SerializedError>> {\n const result = await wrapAsyncCallback(callback);\n return serializeResult(result);\n}\n"],"mappings":";;;;AAGA,IAAa,aAAb,cAAgC,MAAM;CACpC,OAAO;;;;;AAMT,IAAa,UAAb,cAA6B,MAAM;CACjC,OAAO;;AAGT,SAAgB,aAAa,OAAyD;AACpF,QAAO,iBAAiB,SAAS,MAAM,SAAS;;AAGlD,SAAgB,cAAc,OAAyB;AACrD,KAAI,EAAE,iBAAiB,OACrB,QAAO;AAGT,QAAO,MAAM,SAAS,gBAAgB,cAAc,MAAM,MAAM;;AAGlE,SAAgB,iBAAiB,OAAyC;AACxE,QAAO,iBAAiB,SAAS,MAAM,SAAS;;AAGlD,IAAa,cAAb,cAAiC,MAAM;CACrC,OAAO;;AAGT,SAAgB,cAAc,OAAsC;AAClE,QAAO,iBAAiB,SAAS,MAAM,SAAS;;AAGlD,IAAa,oBAAb,cAAuC,YAAY;CACjD,OAAO;;AAGT,SAAgB,oBAAoB,OAA4C;AAC9E,QAAO,iBAAiB,SAAS,MAAM,SAA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,MAAM,EAAE;AAElD,QAAO,EAAE,OAAO,OAAO,OAAO;;AAGhC,SAAgB,aAAgB,UAAqC;AACnE,KAAI;AAEF,SAAO,EAAE,OADK,UAAU,EACR;UACT,OAAO;AACd,SAAO,EAAE,OAAO,YAAY,MAAM,EAAE;;;AAIxC,eAAsB,kBAAqB,UAAuD;AAChG,KAAI;AAEF,SAAO,EAAE,OADK,MAAM,UAAU,EACd;UACT,OAAO;AACd,SAAO,EAAE,OAAO,YAAY,MAAM,EAAE;;;AAIxC,SAAgB,iBAAoB,UAAsD;AAExF,QAAO,gBADQ,aAAa,SAAS,CACP;;AAGhC,eAAsB,sBACpB,UAC4C;AAE5C,QAAO,gBADQ,MAAM,kBAAkB,SAAS,CAClB"}
@@ -1,12 +1,13 @@
1
- 'use strict';
2
1
 
3
- const AllSupportsFeatureFlags = ["supportsLazyState"];
2
+ //#region src/flags/block_flags.ts
3
+ const AllSupportsFeatureFlags = ["supportsLazyState", "supportsPframeQueryRanking"];
4
4
  const AllRequiresFeatureFlags = [
5
- "requiresUIAPIVersion",
6
- "requiresCreatePTable",
7
- "requiresModelAPIVersion",
5
+ "requiresUIAPIVersion",
6
+ "requiresCreatePTable",
7
+ "requiresModelAPIVersion"
8
8
  ];
9
9
 
10
+ //#endregion
10
11
  exports.AllRequiresFeatureFlags = AllRequiresFeatureFlags;
11
12
  exports.AllSupportsFeatureFlags = AllSupportsFeatureFlags;
12
- //# sourceMappingURL=block_flags.cjs.map
13
+ //# sourceMappingURL=block_flags.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"block_flags.cjs","sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTable?: number;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTable\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"names":[],"mappings":";;AAuBO,MAAM,uBAAuB,GAAG,CAAC,mBAAmB;AAEpD,MAAM,uBAAuB,GAAG;IACrC,sBAAsB;IACtB,sBAAsB;IACtB,yBAAyB;;;;;;"}
1
+ {"version":3,"file":"block_flags.cjs","names":[],"sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly supportsPframeQueryRanking?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTable?: number;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\", \"supportsPframeQueryRanking\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTable\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"mappings":";;AAwBA,MAAa,0BAA0B,CAAC,qBAAqB,6BAA6B;AAE1F,MAAa,0BAA0B;CACrC;CACA;CACA;CACD"}
@@ -1,3 +1,4 @@
1
+ //#region src/flags/block_flags.d.ts
1
2
  /**
2
3
  * Block-specific feature flags. Define flags that are interpreted by the desktop app to select
3
4
  * appropriate API to expose into Model and UI runtimes.
@@ -6,16 +7,19 @@
6
7
  * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well
7
8
  * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block
8
9
  */
9
- export type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> & Record<`requires${string}`, boolean | number | undefined>;
10
+ type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> & Record<`requires${string}`, boolean | number | undefined>;
10
11
  /**
11
12
  * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.
12
13
  */
13
- export type BlockCodeKnownFeatureFlags = {
14
- readonly supportsLazyState?: boolean;
15
- readonly requiresModelAPIVersion?: number;
16
- readonly requiresUIAPIVersion?: number;
17
- readonly requiresCreatePTable?: number;
14
+ type BlockCodeKnownFeatureFlags = {
15
+ readonly supportsLazyState?: boolean;
16
+ readonly supportsPframeQueryRanking?: boolean;
17
+ readonly requiresModelAPIVersion?: number;
18
+ readonly requiresUIAPIVersion?: number;
19
+ readonly requiresCreatePTable?: number;
18
20
  };
19
- export declare const AllSupportsFeatureFlags: readonly ["supportsLazyState"];
20
- export declare const AllRequiresFeatureFlags: readonly ["requiresUIAPIVersion", "requiresCreatePTable", "requiresModelAPIVersion"];
21
+ declare const AllSupportsFeatureFlags: readonly ["supportsLazyState", "supportsPframeQueryRanking"];
22
+ declare const AllRequiresFeatureFlags: readonly ["requiresUIAPIVersion", "requiresCreatePTable", "requiresModelAPIVersion"];
23
+ //#endregion
24
+ export { AllRequiresFeatureFlags, AllSupportsFeatureFlags, BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags };
21
25
  //# sourceMappingURL=block_flags.d.ts.map
@@ -1,9 +1,11 @@
1
- const AllSupportsFeatureFlags = ["supportsLazyState"];
1
+ //#region src/flags/block_flags.ts
2
+ const AllSupportsFeatureFlags = ["supportsLazyState", "supportsPframeQueryRanking"];
2
3
  const AllRequiresFeatureFlags = [
3
- "requiresUIAPIVersion",
4
- "requiresCreatePTable",
5
- "requiresModelAPIVersion",
4
+ "requiresUIAPIVersion",
5
+ "requiresCreatePTable",
6
+ "requiresModelAPIVersion"
6
7
  ];
7
8
 
9
+ //#endregion
8
10
  export { AllRequiresFeatureFlags, AllSupportsFeatureFlags };
9
- //# sourceMappingURL=block_flags.js.map
11
+ //# sourceMappingURL=block_flags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"block_flags.js","sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTable?: number;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTable\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"names":[],"mappings":"AAuBO,MAAM,uBAAuB,GAAG,CAAC,mBAAmB;AAEpD,MAAM,uBAAuB,GAAG;IACrC,sBAAsB;IACtB,sBAAsB;IACtB,yBAAyB;;;;;"}
1
+ {"version":3,"file":"block_flags.js","names":[],"sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly supportsPframeQueryRanking?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTable?: number;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\", \"supportsPframeQueryRanking\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTable\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"mappings":";AAwBA,MAAa,0BAA0B,CAAC,qBAAqB,6BAA6B;AAE1F,MAAa,0BAA0B;CACrC;CACA;CACA;CACD"}
@@ -1,123 +1,84 @@
1
- 'use strict';
2
1
 
2
+ //#region src/flags/flag_utils.ts
3
3
  function checkBlockFlag(flags, flag, flagValue = true) {
4
- if (flags === undefined)
5
- return false;
6
- return flags[flag] === flagValue;
4
+ if (flags === void 0) return false;
5
+ return flags[flag] === flagValue;
7
6
  }
8
7
  /**
9
- * Extracts all requirements from the feature flags.
10
- * @param flags - The feature flags.
11
- * @returns A set of requirements.
12
- */
8
+ * Extracts all requirements from the feature flags.
9
+ * @param flags - The feature flags.
10
+ * @returns A set of requirements.
11
+ */
13
12
  function extractAllRequirements(flags) {
14
- if (flags === undefined)
15
- return new Set();
16
- return new Set(Object.entries(flags)
17
- .filter(([key, value]) => key.startsWith("requires") && value === true)
18
- .map(([key]) => key));
13
+ if (flags === void 0) return /* @__PURE__ */ new Set();
14
+ return new Set(Object.entries(flags).filter(([key, value]) => key.startsWith("requires") && value === true).map(([key]) => key));
19
15
  }
20
16
  /**
21
- * Extracts all supports from the feature flags.
22
- * @param flags - The feature flags.
23
- * @returns A set of supports.
24
- */
17
+ * Extracts all supports from the feature flags.
18
+ * @param flags - The feature flags.
19
+ * @returns A set of supports.
20
+ */
25
21
  function extractAllSupports(flags) {
26
- if (flags === undefined)
27
- return new Set();
28
- return new Set(Object.entries(flags)
29
- .filter(([key, value]) => key.startsWith("supports") && value === true)
30
- .map(([key]) => key));
31
- }
32
- /**
33
- * Merges two feature flag objects with type-aware logic:
34
- * - `supports*` (boolean): OR — `true` if either side is `true`
35
- * - `requires*` (numeric): MAX — take the higher version requirement
36
- */
37
- function mergeFeatureFlags(base, override) {
38
- const result = { ...base };
39
- for (const [key, value] of Object.entries(override)) {
40
- if (value === undefined)
41
- continue;
42
- const existing = result[key];
43
- if (typeof value === "boolean") {
44
- result[key] = existing || value;
45
- }
46
- else if (typeof value === "number") {
47
- result[key] = Math.max(existing ?? 0, value);
48
- }
49
- }
50
- return result;
51
- }
52
- class IncompatibleFlagsError extends Error {
53
- incompatibleFlags;
54
- name = "IncompatibleFlagsError";
55
- constructor(incompatibleFlags) {
56
- super(`Some of the block requirements are not supported by the runtime: ${Array.from(incompatibleFlags.entries())
57
- .map(([key, value]) => `${key}: ${value}`)
58
- .join(", ")}`);
59
- this.incompatibleFlags = incompatibleFlags;
60
- }
61
- }
62
- class RuntimeCapabilities {
63
- supportedRequirements = new Map();
64
- /**
65
- * Adds a supported requirement to the runtime capabilities.
66
- * @param requirement - The requirement.
67
- * @param value - The value of the requirement. If not provided, defaults to true.
68
- */
69
- addSupportedRequirement(requirement, value = true) {
70
- if (!this.supportedRequirements.has(requirement)) {
71
- this.supportedRequirements.set(requirement, new Set());
72
- }
73
- this.supportedRequirements.get(requirement).add(value);
74
- return this;
75
- }
76
- /**
77
- * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.
78
- * @param blockFlags - The block flags.
79
- * @returns A map of incompatible flags, or undefined if the block flags are compatible.
80
- */
81
- getIncompatibleFlags(blockFlags) {
82
- if (blockFlags === undefined)
83
- return undefined;
84
- const incompatibleFlags = new Map();
85
- for (const [key, value] of Object.entries(blockFlags)) {
86
- if (key.startsWith("requires")) {
87
- if (value === undefined)
88
- continue;
89
- const supportedValues = this.supportedRequirements.get(key);
90
- if (supportedValues === undefined || !supportedValues.has(value)) {
91
- incompatibleFlags.set(key, value);
92
- }
93
- }
94
- }
95
- return incompatibleFlags.size === 0 ? undefined : incompatibleFlags;
96
- }
97
- /**
98
- * Checks if the block flags are compatible with the runtime capabilities.
99
- * @param blockFlags - The block flags.
100
- * @returns True if the block flags are compatible, false otherwise.
101
- */
102
- checkCompatibility(blockFlags) {
103
- return this.getIncompatibleFlags(blockFlags) === undefined;
104
- }
105
- /**
106
- * Throws an error if the block flags are incompatible with the runtime capabilities.
107
- * @param blockFlags - The block flags.
108
- * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.
109
- */
110
- throwIfIncompatible(blockFlags) {
111
- const incompatibleFlags = this.getIncompatibleFlags(blockFlags);
112
- if (incompatibleFlags !== undefined)
113
- throw new IncompatibleFlagsError(incompatibleFlags);
114
- }
22
+ if (flags === void 0) return /* @__PURE__ */ new Set();
23
+ return new Set(Object.entries(flags).filter(([key, value]) => key.startsWith("supports") && value === true).map(([key]) => key));
115
24
  }
25
+ var IncompatibleFlagsError = class extends Error {
26
+ name = "IncompatibleFlagsError";
27
+ constructor(incompatibleFlags) {
28
+ super(`Some of the block requirements are not supported by the runtime: ${Array.from(incompatibleFlags.entries()).map(([key, value]) => `${key}: ${value}`).join(", ")}`);
29
+ this.incompatibleFlags = incompatibleFlags;
30
+ }
31
+ };
32
+ var RuntimeCapabilities = class {
33
+ supportedRequirements = /* @__PURE__ */ new Map();
34
+ /**
35
+ * Adds a supported requirement to the runtime capabilities.
36
+ * @param requirement - The requirement.
37
+ * @param value - The value of the requirement. If not provided, defaults to true.
38
+ */
39
+ addSupportedRequirement(requirement, value = true) {
40
+ if (!this.supportedRequirements.has(requirement)) this.supportedRequirements.set(requirement, /* @__PURE__ */ new Set());
41
+ this.supportedRequirements.get(requirement).add(value);
42
+ return this;
43
+ }
44
+ /**
45
+ * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.
46
+ * @param blockFlags - The block flags.
47
+ * @returns A map of incompatible flags, or undefined if the block flags are compatible.
48
+ */
49
+ getIncompatibleFlags(blockFlags) {
50
+ if (blockFlags === void 0) return void 0;
51
+ const incompatibleFlags = /* @__PURE__ */ new Map();
52
+ for (const [key, value] of Object.entries(blockFlags)) if (key.startsWith("requires")) {
53
+ if (value === void 0) continue;
54
+ const supportedValues = this.supportedRequirements.get(key);
55
+ if (supportedValues === void 0 || !supportedValues.has(value)) incompatibleFlags.set(key, value);
56
+ }
57
+ return incompatibleFlags.size === 0 ? void 0 : incompatibleFlags;
58
+ }
59
+ /**
60
+ * Checks if the block flags are compatible with the runtime capabilities.
61
+ * @param blockFlags - The block flags.
62
+ * @returns True if the block flags are compatible, false otherwise.
63
+ */
64
+ checkCompatibility(blockFlags) {
65
+ return this.getIncompatibleFlags(blockFlags) === void 0;
66
+ }
67
+ /**
68
+ * Throws an error if the block flags are incompatible with the runtime capabilities.
69
+ * @param blockFlags - The block flags.
70
+ * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.
71
+ */
72
+ throwIfIncompatible(blockFlags) {
73
+ const incompatibleFlags = this.getIncompatibleFlags(blockFlags);
74
+ if (incompatibleFlags !== void 0) throw new IncompatibleFlagsError(incompatibleFlags);
75
+ }
76
+ };
116
77
 
78
+ //#endregion
117
79
  exports.IncompatibleFlagsError = IncompatibleFlagsError;
118
80
  exports.RuntimeCapabilities = RuntimeCapabilities;
119
81
  exports.checkBlockFlag = checkBlockFlag;
120
82
  exports.extractAllRequirements = extractAllRequirements;
121
83
  exports.extractAllSupports = extractAllSupports;
122
- exports.mergeFeatureFlags = mergeFeatureFlags;
123
- //# sourceMappingURL=flag_utils.cjs.map
84
+ //# sourceMappingURL=flag_utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"flag_utils.cjs","sources":["../../src/flags/flag_utils.ts"],"sourcesContent":["import type { BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags } from \"./block_flags\";\nimport type { FilterKeysByPrefix } from \"./type_utils\";\n\nexport function checkBlockFlag(\n flags: BlockCodeFeatureFlags | undefined,\n flag: keyof BlockCodeKnownFeatureFlags,\n flagValue: boolean | number = true,\n): boolean {\n if (flags === undefined) return false;\n return flags[flag] === flagValue;\n}\n\n/**\n * Extracts all requirements from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of requirements.\n */\nexport function extractAllRequirements(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`requires${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"requires\") && value === true)\n .map(([key]) => key as `requires${string}`),\n );\n}\n\n/**\n * Extracts all supports from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of supports.\n */\nexport function extractAllSupports(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`supports${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"supports\") && value === true)\n .map(([key]) => key as `supports${string}`),\n );\n}\n\n/**\n * Merges two feature flag objects with type-aware logic:\n * - `supports*` (boolean): OR — `true` if either side is `true`\n * - `requires*` (numeric): MAX — take the higher version requirement\n */\nexport function mergeFeatureFlags(\n base: BlockCodeKnownFeatureFlags,\n override: BlockCodeKnownFeatureFlags,\n): BlockCodeKnownFeatureFlags {\n const result: Record<string, boolean | number | undefined> = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (value === undefined) continue;\n const existing = result[key];\n if (typeof value === \"boolean\") {\n result[key] = (existing as boolean | undefined) || value;\n } else if (typeof value === \"number\") {\n result[key] = Math.max((existing as number) ?? 0, value);\n }\n }\n return result as BlockCodeKnownFeatureFlags;\n}\n\nexport class IncompatibleFlagsError extends Error {\n name = \"IncompatibleFlagsError\";\n constructor(public readonly incompatibleFlags: Map<`requires${string}`, number | boolean>) {\n super(\n `Some of the block requirements are not supported by the runtime: ${Array.from(\n incompatibleFlags.entries(),\n )\n .map(([key, value]) => `${key}: ${value}`)\n .join(\", \")}`,\n );\n }\n}\n\n/**\n * A type that represents a supported requirement.\n * @remarks\n * This type is used to represent a supported requirement.\n * It is a subtype of `BlockCodeKnownFeatureFlags` and is used to represent a supported requirement.\n * It is used to represent a supported requirement.\n */\nexport type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, \"requires\">;\n\nexport class RuntimeCapabilities {\n private readonly supportedRequirements: Map<`requires${string}`, Set<number | boolean>> =\n new Map();\n\n /**\n * Adds a supported requirement to the runtime capabilities.\n * @param requirement - The requirement.\n * @param value - The value of the requirement. If not provided, defaults to true.\n */\n public addSupportedRequirement(\n requirement: SupportedRequirement,\n value: number | boolean = true,\n ): this {\n if (!this.supportedRequirements.has(requirement)) {\n this.supportedRequirements.set(requirement, new Set());\n }\n this.supportedRequirements.get(requirement)!.add(value);\n return this;\n }\n\n /**\n * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.\n * @param blockFlags - The block flags.\n * @returns A map of incompatible flags, or undefined if the block flags are compatible.\n */\n public getIncompatibleFlags(\n blockFlags: BlockCodeFeatureFlags | undefined,\n ): Map<`requires${string}`, number | boolean> | undefined {\n if (blockFlags === undefined) return undefined;\n const incompatibleFlags = new Map<`requires${string}`, number | boolean>();\n for (const [key, value] of Object.entries(blockFlags)) {\n if (key.startsWith(\"requires\")) {\n if (value === undefined) continue;\n const supportedValues = this.supportedRequirements.get(key as `requires${string}`);\n if (supportedValues === undefined || !supportedValues.has(value as number | boolean)) {\n incompatibleFlags.set(key as `requires${string}`, value as number | boolean);\n }\n }\n }\n return incompatibleFlags.size === 0 ? undefined : incompatibleFlags;\n }\n\n /**\n * Checks if the block flags are compatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @returns True if the block flags are compatible, false otherwise.\n */\n public checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean {\n return this.getIncompatibleFlags(blockFlags) === undefined;\n }\n\n /**\n * Throws an error if the block flags are incompatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.\n */\n public throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined) {\n const incompatibleFlags = this.getIncompatibleFlags(blockFlags);\n if (incompatibleFlags !== undefined) throw new IncompatibleFlagsError(incompatibleFlags);\n }\n}\n"],"names":[],"mappings":";;AAGM,SAAU,cAAc,CAC5B,KAAwC,EACxC,IAAsC,EACtC,YAA8B,IAAI,EAAA;IAElC,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;AACrC,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS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AC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;AACrD,YAAA,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAC9B,IAAI,KAAK,KAAK,SAAS;oBAAE;gBACzB,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAA0B,CAAC;AAClF,gBAAA,IAAI,eAAe,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAyB,CAAC,EAAE;AACpF,oBAAA,iBAAiB,CAAC,GAAG,CAAC,GAA0B,EAAE,KAAyB,CAAC;gBAC9E;YACF;QACF;AACA,QAAA,OAAO,iBAAiB,CAAC,IAAI,KAAK,CAAC,GAAG,SAAS,GAAG,iBAAiB;IACrE;AAEA;;;;AAIG;AACI,IAAA,kBAAkB,CAAC,UAA6C,EAAA;QACrE,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,SAAS;IAC5D;AAEA;;;;AAIG;AACI,IAAA,mBAAmB,CAAC,UAA6C,EAAA;QACtE,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC;QAC/D,IAAI,iBAAiB,KAAK,SAAS;AAAE,YAAA,MAAM,IAAI,sBAAsB,CAAC,iBAAiB,CAAC;IAC1F;AACD;;;;;;;;;"}
1
+ {"version":3,"file":"flag_utils.cjs","names":[],"sources":["../../src/flags/flag_utils.ts"],"sourcesContent":["import type { BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags } from \"./block_flags\";\nimport type { FilterKeysByPrefix } from \"./type_utils\";\n\nexport function checkBlockFlag(\n flags: BlockCodeFeatureFlags | undefined,\n flag: keyof BlockCodeKnownFeatureFlags,\n flagValue: boolean | number = true,\n): boolean {\n if (flags === undefined) return false;\n return flags[flag] === flagValue;\n}\n\n/**\n * Extracts all requirements from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of requirements.\n */\nexport function extractAllRequirements(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`requires${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"requires\") && value === true)\n .map(([key]) => key as `requires${string}`),\n );\n}\n\n/**\n * Extracts all supports from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of supports.\n */\nexport function extractAllSupports(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`supports${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"supports\") && value === true)\n .map(([key]) => key as `supports${string}`),\n );\n}\n\nexport class IncompatibleFlagsError extends Error {\n name = \"IncompatibleFlagsError\";\n constructor(public readonly incompatibleFlags: Map<`requires${string}`, number | boolean>) {\n super(\n `Some of the block requirements are not supported by the runtime: ${Array.from(\n incompatibleFlags.entries(),\n )\n .map(([key, value]) => `${key}: ${value}`)\n .join(\", \")}`,\n );\n }\n}\n\n/**\n * A type that represents a supported requirement.\n * @remarks\n * This type is used to represent a supported requirement.\n * It is a subtype of `BlockCodeKnownFeatureFlags` and is used to represent a supported requirement.\n * It is used to represent a supported requirement.\n */\nexport type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, \"requires\">;\n\nexport class RuntimeCapabilities {\n private readonly supportedRequirements: Map<`requires${string}`, Set<number | boolean>> =\n new Map();\n\n /**\n * Adds a supported requirement to the runtime capabilities.\n * @param requirement - The requirement.\n * @param value - The value of the requirement. If not provided, defaults to true.\n */\n public addSupportedRequirement(\n requirement: SupportedRequirement,\n value: number | boolean = true,\n ): this {\n if (!this.supportedRequirements.has(requirement)) {\n this.supportedRequirements.set(requirement, new Set());\n }\n this.supportedRequirements.get(requirement)!.add(value);\n return this;\n }\n\n /**\n * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.\n * @param blockFlags - The block flags.\n * @returns A map of incompatible flags, or undefined if the block flags are compatible.\n */\n public getIncompatibleFlags(\n blockFlags: BlockCodeFeatureFlags | undefined,\n ): Map<`requires${string}`, number | boolean> | undefined {\n if (blockFlags === undefined) return undefined;\n const incompatibleFlags = new Map<`requires${string}`, number | boolean>();\n for (const [key, value] of Object.entries(blockFlags)) {\n if (key.startsWith(\"requires\")) {\n if (value === undefined) continue;\n const supportedValues = this.supportedRequirements.get(key as `requires${string}`);\n if (supportedValues === undefined || !supportedValues.has(value as number | boolean)) {\n incompatibleFlags.set(key as `requires${string}`, value as number | boolean);\n }\n }\n }\n return incompatibleFlags.size === 0 ? undefined : incompatibleFlags;\n }\n\n /**\n * Checks if the block flags are compatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @returns True if the block flags are compatible, false otherwise.\n */\n public checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean {\n return this.getIncompatibleFlags(blockFlags) === undefined;\n }\n\n /**\n * Throws an error if the block flags are incompatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.\n */\n public throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined) {\n const incompatibleFlags = this.getIncompatibleFlags(blockFlags);\n if (incompatibleFlags !== undefined) throw new IncompatibleFlagsError(incompatibleFlags);\n }\n}\n"],"mappings":";;AAGA,SAAgB,eACd,OACA,MACA,YAA8B,MACrB;AACT,KAAI,UAAU,OAAW,QAAO;AAChC,QAAO,MAAM,UAAU;;;;;;;AAQzB,SAAgB,uBACd,OAC0B;AAC1B,KAAI,UAAU,OAAW,wBAAO,IAAI,KAAK;AACzC,QAAO,IAAI,IACT,OAAO,QAAQ,MAAM,CAClB,QAAQ,CAAC,KAAK,WAAW,IAAI,WAAW,WAAW,IAAI,UAAU,KAAK,CACtE,KAAK,CAAC,SAAS,IAA2B,CAC9C;;;;;;;AAQH,SAAgB,mBACd,OAC0B;AAC1B,KAAI,UAAU,OAAW,wBAAO,IAAI,KAAK;AACzC,QAAO,IAAI,IACT,OAAO,QAAQ,MAAM,CAClB,QAAQ,CAAC,KAAK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2
- import type { FilterKeysByPrefix } from "./type_utils";
3
- export declare function checkBlockFlag(flags: BlockCodeFeatureFlags | undefined, flag: keyof BlockCodeKnownFeatureFlags, flagValue?: boolean | number): boolean;
1
+ import { BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags } from "./block_flags.js";
2
+ import { FilterKeysByPrefix } from "./type_utils.js";
3
+
4
+ //#region src/flags/flag_utils.d.ts
5
+ declare function checkBlockFlag(flags: BlockCodeFeatureFlags | undefined, flag: keyof BlockCodeKnownFeatureFlags, flagValue?: boolean | number): boolean;
4
6
  /**
5
7
  * Extracts all requirements from the feature flags.
6
8
  * @param flags - The feature flags.
7
9
  * @returns A set of requirements.
8
10
  */
9
- export declare function extractAllRequirements(flags: BlockCodeFeatureFlags | undefined): Set<`requires${string}`>;
11
+ declare function extractAllRequirements(flags: BlockCodeFeatureFlags | undefined): Set<`requires${string}`>;
10
12
  /**
11
13
  * Extracts all supports from the feature flags.
12
14
  * @param flags - The feature flags.
13
15
  * @returns A set of supports.
14
16
  */
15
- export declare function extractAllSupports(flags: BlockCodeFeatureFlags | undefined): Set<`supports${string}`>;
16
- /**
17
- * Merges two feature flag objects with type-aware logic:
18
- * - `supports*` (boolean): OR — `true` if either side is `true`
19
- * - `requires*` (numeric): MAX take the higher version requirement
20
- */
21
- export declare function mergeFeatureFlags(base: BlockCodeKnownFeatureFlags, override: BlockCodeKnownFeatureFlags): BlockCodeKnownFeatureFlags;
22
- export declare class IncompatibleFlagsError extends Error {
23
- readonly incompatibleFlags: Map<`requires${string}`, number | boolean>;
24
- name: string;
25
- constructor(incompatibleFlags: Map<`requires${string}`, number | boolean>);
17
+ declare function extractAllSupports(flags: BlockCodeFeatureFlags | undefined): Set<`supports${string}`>;
18
+ declare class IncompatibleFlagsError extends Error {
19
+ readonly incompatibleFlags: Map<`requires${string}`, number | boolean>;
20
+ name: string;
21
+ constructor(incompatibleFlags: Map<`requires${string}`, number | boolean>);
26
22
  }
27
23
  /**
28
24
  * A type that represents a supported requirement.
@@ -31,32 +27,34 @@ export declare class IncompatibleFlagsError extends Error {
31
27
  * It is a subtype of `BlockCodeKnownFeatureFlags` and is used to represent a supported requirement.
32
28
  * It is used to represent a supported requirement.
33
29
  */
34
- export type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, "requires">;
35
- export declare class RuntimeCapabilities {
36
- private readonly supportedRequirements;
37
- /**
38
- * Adds a supported requirement to the runtime capabilities.
39
- * @param requirement - The requirement.
40
- * @param value - The value of the requirement. If not provided, defaults to true.
41
- */
42
- addSupportedRequirement(requirement: SupportedRequirement, value?: number | boolean): this;
43
- /**
44
- * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.
45
- * @param blockFlags - The block flags.
46
- * @returns A map of incompatible flags, or undefined if the block flags are compatible.
47
- */
48
- getIncompatibleFlags(blockFlags: BlockCodeFeatureFlags | undefined): Map<`requires${string}`, number | boolean> | undefined;
49
- /**
50
- * Checks if the block flags are compatible with the runtime capabilities.
51
- * @param blockFlags - The block flags.
52
- * @returns True if the block flags are compatible, false otherwise.
53
- */
54
- checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean;
55
- /**
56
- * Throws an error if the block flags are incompatible with the runtime capabilities.
57
- * @param blockFlags - The block flags.
58
- * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.
59
- */
60
- throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined): void;
30
+ type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, "requires">;
31
+ declare class RuntimeCapabilities {
32
+ private readonly supportedRequirements;
33
+ /**
34
+ * Adds a supported requirement to the runtime capabilities.
35
+ * @param requirement - The requirement.
36
+ * @param value - The value of the requirement. If not provided, defaults to true.
37
+ */
38
+ addSupportedRequirement(requirement: SupportedRequirement, value?: number | boolean): this;
39
+ /**
40
+ * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.
41
+ * @param blockFlags - The block flags.
42
+ * @returns A map of incompatible flags, or undefined if the block flags are compatible.
43
+ */
44
+ getIncompatibleFlags(blockFlags: BlockCodeFeatureFlags | undefined): Map<`requires${string}`, number | boolean> | undefined;
45
+ /**
46
+ * Checks if the block flags are compatible with the runtime capabilities.
47
+ * @param blockFlags - The block flags.
48
+ * @returns True if the block flags are compatible, false otherwise.
49
+ */
50
+ checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean;
51
+ /**
52
+ * Throws an error if the block flags are incompatible with the runtime capabilities.
53
+ * @param blockFlags - The block flags.
54
+ * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.
55
+ */
56
+ throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined): void;
61
57
  }
58
+ //#endregion
59
+ export { IncompatibleFlagsError, RuntimeCapabilities, SupportedRequirement, checkBlockFlag, extractAllRequirements, extractAllSupports };
62
60
  //# sourceMappingURL=flag_utils.d.ts.map