@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.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/author_marker.d.ts +9 -6
- package/dist/base32_encode.cjs +40 -46
- package/dist/base32_encode.cjs.map +1 -1
- package/dist/base32_encode.js +40 -45
- package/dist/base32_encode.js.map +1 -1
- package/dist/base64.cjs +5 -4
- package/dist/base64.cjs.map +1 -1
- package/dist/base64.d.ts +10 -6
- package/dist/base64.js +5 -3
- package/dist/base64.js.map +1 -1
- package/dist/block_state.d.ts +21 -23
- package/dist/bmodel/block_config.cjs +9 -10
- package/dist/bmodel/block_config.cjs.map +1 -1
- package/dist/bmodel/block_config.d.ts +53 -72
- package/dist/bmodel/block_config.js +9 -9
- package/dist/bmodel/block_config.js.map +1 -1
- package/dist/bmodel/code.cjs +7 -6
- package/dist/bmodel/code.cjs.map +1 -1
- package/dist/bmodel/code.d.ts +17 -13
- package/dist/bmodel/code.js +6 -4
- package/dist/bmodel/code.js.map +1 -1
- package/dist/bmodel/container.d.ts +46 -44
- package/dist/bmodel/index.cjs +3 -0
- package/dist/bmodel/index.d.ts +5 -6
- package/dist/bmodel/index.js +3 -0
- package/dist/bmodel/normalization.cjs +90 -106
- package/dist/bmodel/normalization.cjs.map +1 -1
- package/dist/bmodel/normalization.d.ts +7 -3
- package/dist/bmodel/normalization.js +90 -105
- package/dist/bmodel/normalization.js.map +1 -1
- package/dist/bmodel/types.d.ts +4 -1
- package/dist/branding.d.ts +5 -5
- package/dist/common_types.d.ts +19 -15
- package/dist/driver_kit.d.ts +25 -17
- package/dist/drivers/ChunkedStreamReader.cjs +168 -203
- package/dist/drivers/ChunkedStreamReader.cjs.map +1 -1
- package/dist/drivers/ChunkedStreamReader.d.ts +104 -100
- package/dist/drivers/ChunkedStreamReader.js +168 -202
- package/dist/drivers/ChunkedStreamReader.js.map +1 -1
- package/dist/drivers/blob.cjs +15 -17
- package/dist/drivers/blob.cjs.map +1 -1
- package/dist/drivers/blob.d.ts +35 -35
- package/dist/drivers/blob.js +14 -15
- package/dist/drivers/blob.js.map +1 -1
- package/dist/drivers/index.cjs +18 -0
- package/dist/drivers/index.d.ts +29 -9
- package/dist/drivers/index.js +18 -0
- package/dist/drivers/interfaces.d.ts +17 -14
- package/dist/drivers/log.cjs +4 -3
- package/dist/drivers/log.cjs.map +1 -1
- package/dist/drivers/log.d.ts +52 -49
- package/dist/drivers/log.js +4 -2
- package/dist/drivers/log.js.map +1 -1
- package/dist/drivers/ls.cjs +16 -19
- package/dist/drivers/ls.cjs.map +1 -1
- package/dist/drivers/ls.d.ts +73 -76
- package/dist/drivers/ls.js +16 -17
- package/dist/drivers/ls.js.map +1 -1
- package/dist/drivers/pframe/column_filter.d.ts +19 -15
- package/dist/drivers/pframe/data_info.cjs +201 -252
- package/dist/drivers/pframe/data_info.cjs.map +1 -1
- package/dist/drivers/pframe/data_info.d.ts +84 -109
- package/dist/drivers/pframe/data_info.js +201 -250
- package/dist/drivers/pframe/data_info.js.map +1 -1
- package/dist/drivers/pframe/data_types.cjs +38 -63
- package/dist/drivers/pframe/data_types.cjs.map +1 -1
- package/dist/drivers/pframe/data_types.d.ts +91 -93
- package/dist/drivers/pframe/data_types.js +38 -61
- package/dist/drivers/pframe/data_types.js.map +1 -1
- package/dist/drivers/pframe/driver.cjs +7 -0
- package/dist/drivers/pframe/driver.cjs.map +1 -0
- package/dist/drivers/pframe/driver.d.ts +50 -45
- package/dist/drivers/pframe/driver.js +6 -0
- package/dist/drivers/pframe/driver.js.map +1 -0
- package/dist/drivers/pframe/filter_spec.d.ts +127 -123
- package/dist/drivers/pframe/find_columns.d.ts +21 -17
- package/dist/drivers/pframe/index.cjs +15 -0
- package/dist/drivers/pframe/index.d.ts +23 -16
- package/dist/drivers/pframe/index.js +15 -0
- package/dist/drivers/pframe/linker_columns.cjs +184 -238
- package/dist/drivers/pframe/linker_columns.cjs.map +1 -1
- package/dist/drivers/pframe/linker_columns.d.ts +45 -38
- package/dist/drivers/pframe/linker_columns.js +184 -236
- package/dist/drivers/pframe/linker_columns.js.map +1 -1
- package/dist/drivers/pframe/pframe.d.ts +26 -21
- package/dist/drivers/pframe/query/index.cjs +1 -0
- package/dist/drivers/pframe/query/index.d.ts +3 -4
- package/dist/drivers/pframe/query/index.js +1 -0
- package/dist/drivers/pframe/query/query_common.d.ts +205 -247
- package/dist/drivers/pframe/query/query_data.d.ts +25 -23
- package/dist/drivers/pframe/query/query_spec.d.ts +30 -29
- package/dist/drivers/pframe/query/utils.cjs +164 -183
- package/dist/drivers/pframe/query/utils.cjs.map +1 -1
- package/dist/drivers/pframe/query/utils.d.ts +13 -12
- package/dist/drivers/pframe/query/utils.js +164 -181
- package/dist/drivers/pframe/query/utils.js.map +1 -1
- package/dist/drivers/pframe/spec/anchored.cjs +178 -216
- package/dist/drivers/pframe/spec/anchored.cjs.map +1 -1
- package/dist/drivers/pframe/spec/anchored.d.ts +53 -49
- package/dist/drivers/pframe/spec/anchored.js +176 -214
- package/dist/drivers/pframe/spec/anchored.js.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.cjs +8 -7
- package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts +20 -17
- package/dist/drivers/pframe/spec/filtered_column.js +8 -6
- package/dist/drivers/pframe/spec/filtered_column.js.map +1 -1
- package/dist/drivers/pframe/spec/ids.cjs +16 -14
- package/dist/drivers/pframe/spec/ids.cjs.map +1 -1
- package/dist/drivers/pframe/spec/ids.d.ts +13 -8
- package/dist/drivers/pframe/spec/ids.js +14 -12
- package/dist/drivers/pframe/spec/ids.js.map +1 -1
- package/dist/drivers/pframe/spec/index.cjs +6 -0
- package/dist/drivers/pframe/spec/index.d.ts +6 -7
- package/dist/drivers/pframe/spec/index.js +6 -0
- package/dist/drivers/pframe/spec/native_id.cjs +16 -16
- package/dist/drivers/pframe/spec/native_id.cjs.map +1 -1
- package/dist/drivers/pframe/spec/native_id.d.ts +9 -4
- package/dist/drivers/pframe/spec/native_id.js +13 -13
- package/dist/drivers/pframe/spec/native_id.js.map +1 -1
- package/dist/drivers/pframe/spec/selectors.cjs +72 -112
- package/dist/drivers/pframe/spec/selectors.cjs.map +1 -1
- package/dist/drivers/pframe/spec/selectors.d.ts +99 -94
- package/dist/drivers/pframe/spec/selectors.js +72 -110
- package/dist/drivers/pframe/spec/selectors.js.map +1 -1
- package/dist/drivers/pframe/spec/spec.cjs +282 -324
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -1
- package/dist/drivers/pframe/spec/spec.d.ts +263 -272
- package/dist/drivers/pframe/spec/spec.js +281 -322
- package/dist/drivers/pframe/spec/spec.js.map +1 -1
- package/dist/drivers/pframe/table.d.ts +28 -24
- package/dist/drivers/pframe/table_calculate.cjs +117 -147
- package/dist/drivers/pframe/table_calculate.cjs.map +1 -1
- package/dist/drivers/pframe/table_calculate.d.ts +219 -220
- package/dist/drivers/pframe/table_calculate.js +117 -145
- package/dist/drivers/pframe/table_calculate.js.map +1 -1
- package/dist/drivers/pframe/table_common.cjs +13 -14
- package/dist/drivers/pframe/table_common.cjs.map +1 -1
- package/dist/drivers/pframe/table_common.d.ts +24 -19
- package/dist/drivers/pframe/table_common.js +13 -13
- package/dist/drivers/pframe/table_common.js.map +1 -1
- package/dist/drivers/pframe/unique_values.d.ts +23 -18
- package/dist/drivers/upload.d.ts +21 -18
- package/dist/drivers/urls.cjs +5 -6
- package/dist/drivers/urls.cjs.map +1 -1
- package/dist/drivers/urls.d.ts +12 -9
- package/dist/drivers/urls.js +5 -5
- package/dist/drivers/urls.js.map +1 -1
- package/dist/errors.cjs +65 -86
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +36 -33
- package/dist/errors.js +65 -85
- package/dist/errors.js.map +1 -1
- package/dist/flags/block_flags.cjs +7 -6
- package/dist/flags/block_flags.cjs.map +1 -1
- package/dist/flags/block_flags.d.ts +12 -8
- package/dist/flags/block_flags.js +7 -5
- package/dist/flags/block_flags.js.map +1 -1
- package/dist/flags/flag_utils.cjs +69 -108
- package/dist/flags/flag_utils.cjs.map +1 -1
- package/dist/flags/flag_utils.d.ts +40 -42
- package/dist/flags/flag_utils.js +70 -107
- package/dist/flags/flag_utils.js.map +1 -1
- package/dist/flags/type_utils.d.ts +12 -11
- package/dist/httpAuth.cjs +16 -20
- package/dist/httpAuth.cjs.map +1 -1
- package/dist/httpAuth.d.ts +10 -7
- package/dist/httpAuth.js +16 -19
- package/dist/httpAuth.js.map +1 -1
- package/dist/index.cjs +176 -179
- package/dist/index.d.ts +58 -20
- package/dist/index.js +37 -34
- package/dist/json.cjs +10 -8
- package/dist/json.cjs.map +1 -1
- package/dist/json.d.ts +18 -18
- package/dist/json.js +8 -6
- package/dist/json.js.map +1 -1
- package/dist/navigation.cjs +3 -2
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.d.ts +18 -21
- package/dist/navigation.js +3 -1
- package/dist/navigation.js.map +1 -1
- package/dist/plid.cjs +16 -20
- package/dist/plid.cjs.map +1 -1
- package/dist/plid.d.ts +11 -7
- package/dist/plid.js +15 -18
- package/dist/plid.js.map +1 -1
- package/dist/pool/entry.d.ts +11 -11
- package/dist/pool/index.d.ts +3 -4
- package/dist/pool/query.cjs +21 -43
- package/dist/pool/query.cjs.map +1 -1
- package/dist/pool/query.d.ts +25 -20
- package/dist/pool/query.js +20 -40
- package/dist/pool/query.js.map +1 -1
- package/dist/pool/spec.cjs +40 -47
- package/dist/pool/spec.cjs.map +1 -1
- package/dist/pool/spec.d.ts +33 -31
- package/dist/pool/spec.js +40 -45
- package/dist/pool/spec.js.map +1 -1
- package/dist/ref.cjs +51 -71
- package/dist/ref.cjs.map +1 -1
- package/dist/ref.d.ts +36 -33
- package/dist/ref.js +50 -69
- package/dist/ref.js.map +1 -1
- package/dist/utag.d.ts +18 -14
- package/dist/util.cjs +8 -7
- package/dist/util.cjs.map +1 -1
- package/dist/util.d.ts +5 -2
- package/dist/util.js +8 -6
- package/dist/util.js.map +1 -1
- package/dist/value_or_error.cjs +7 -3
- package/dist/value_or_error.cjs.map +1 -1
- package/dist/value_or_error.d.ts +9 -6
- package/dist/value_or_error.js +7 -2
- package/dist/value_or_error.js.map +1 -1
- package/package.json +6 -6
- package/src/flags/block_flags.ts +2 -1
- package/src/flags/flag_utils.ts +0 -22
- package/dist/author_marker.d.ts.map +0 -1
- package/dist/base32_encode.d.ts +0 -8
- package/dist/base32_encode.d.ts.map +0 -1
- package/dist/base64.d.ts.map +0 -1
- package/dist/block_state.d.ts.map +0 -1
- package/dist/bmodel/block_config.d.ts.map +0 -1
- package/dist/bmodel/code.d.ts.map +0 -1
- package/dist/bmodel/container.d.ts.map +0 -1
- package/dist/bmodel/index.d.ts.map +0 -1
- package/dist/bmodel/normalization.d.ts.map +0 -1
- package/dist/bmodel/types.d.ts.map +0 -1
- package/dist/branding.d.ts.map +0 -1
- package/dist/common_types.d.ts.map +0 -1
- package/dist/driver_kit.d.ts.map +0 -1
- package/dist/drivers/ChunkedStreamReader.d.ts.map +0 -1
- package/dist/drivers/blob.d.ts.map +0 -1
- package/dist/drivers/index.d.ts.map +0 -1
- package/dist/drivers/interfaces.d.ts.map +0 -1
- package/dist/drivers/log.d.ts.map +0 -1
- package/dist/drivers/ls.d.ts.map +0 -1
- package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
- package/dist/drivers/pframe/data_info.d.ts.map +0 -1
- package/dist/drivers/pframe/data_types.d.ts.map +0 -1
- package/dist/drivers/pframe/driver.d.ts.map +0 -1
- package/dist/drivers/pframe/filter_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/index.d.ts.map +0 -1
- package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/pframe.d.ts.map +0 -1
- package/dist/drivers/pframe/query/index.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_common.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_data.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/query/utils.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
- package/dist/drivers/pframe/table.d.ts.map +0 -1
- package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
- package/dist/drivers/pframe/table_common.d.ts.map +0 -1
- package/dist/drivers/pframe/type_util.d.ts +0 -5
- package/dist/drivers/pframe/type_util.d.ts.map +0 -1
- package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
- package/dist/drivers/upload.d.ts.map +0 -1
- package/dist/drivers/urls.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/flags/block_flags.d.ts.map +0 -1
- package/dist/flags/flag_utils.d.ts.map +0 -1
- package/dist/flags/index.d.ts +0 -4
- package/dist/flags/index.d.ts.map +0 -1
- package/dist/flags/type_utils.d.ts.map +0 -1
- package/dist/httpAuth.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/json.d.ts.map +0 -1
- package/dist/navigation.d.ts.map +0 -1
- package/dist/plid.d.ts.map +0 -1
- package/dist/pool/entry.d.ts.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/query.d.ts.map +0 -1
- package/dist/pool/spec.d.ts.map +0 -1
- package/dist/ref.d.ts.map +0 -1
- package/dist/utag.d.ts.map +0 -1
- package/dist/util.d.ts.map +0 -1
- package/dist/value_or_error.d.ts.map +0 -1
package/dist/errors.js.map
CHANGED
|
@@ -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"],"
|
|
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,SAAS;;AAGlD,SAAS,eAAe,OAAwB;AAC9C,KAAI,OAAO,UAAU,SACnB,QAAO,4BAA4B;AAGrC,KAAI,SAAS,OAAO,UAAU,SAC5B,KAAI;AACF,SAAO,4BAA4B,KAAK,UAAU,MAAM;UACjD,WAAW;AAElB,SAAO,8DADc,qBAAqB,QAAQ,UAAU,UAAU,OAAO,UAAU,CACL,KAAK,OAAO,MAAM;;AAIxG,QAAO,OAAO,oBAAoB,OAAO,MAAM,gBAAgB,QAAQ;;AAGzE,SAAgB,YAAY,OAAuB;AACjD,KAAI,iBAAiB,MACnB,QAAO;AAGT,QAAO,IAAI,MAAM,eAAe,MAAM,CAAC;;AAYzC,SAAgB,iBAAiB,KAA6B;CAC5D,MAAM,QAAQ,IAAI,QAAQ,iBAAiB,IAAI,MAAM,GAAG;CAExD,MAAM,QAAQ,IAAI,MAAM,IAAI,SAAS,UAAU,SAAY,EAAE,OAAO,GAAG,OAAU;AACjF,OAAM,OAAO,IAAI,QAAQ;AACzB,OAAM,QAAQ,IAAI;AAElB,QAAO;;AAGT,SAAgB,eAAe,GAA6B;CAC1D,MAAM,QAAQ,YAAY,EAAE;CAC5B,MAAM,QAAQ,MAAM,QAAQ,eAAe,MAAM,MAAM,GAAG;AAE1D,QAAO;EACL,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,OAAO,MAAM;EACb,GAAI,MAAM,UAAU,UAAa,EAAE,OAAO;EAC3C;;AAYH,SAAgB,aAAgB,QAAsD;AACpF,KAAI,OAAO,MACT,OAAM,OAAO,iBAAiB,QAAQ,OAAO,QAAQ,iBAAiB,OAAO,MAAM;AAErF,QAAO,OAAO;;AAGhB,SAAgB,gBAAmB,QAA6D;AAC9F,KAAI,OAAO,MACT,QAAO,EAAE,OAAO,eAAe,OAAO,MAAM,EAAE;AAEhD,QAAO,EAAE,OAAO,OAAO,OAAO;;AAGhC,SAAgB,kBAAqB,QAA6D;AAChG,KAAI,OAAO,MACT,QAAO,EAAE,OAAO,iBAAiB,OAAO,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
|
-
|
|
2
|
+
//#region src/flags/block_flags.ts
|
|
3
|
+
const AllSupportsFeatureFlags = ["supportsLazyState", "supportsPframeQueryRanking"];
|
|
4
4
|
const AllRequiresFeatureFlags = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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"],"
|
|
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
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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
|
-
|
|
1
|
+
//#region src/flags/block_flags.ts
|
|
2
|
+
const AllSupportsFeatureFlags = ["supportsLazyState", "supportsPframeQueryRanking"];
|
|
2
3
|
const AllRequiresFeatureFlags = [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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"],"
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
return flags[flag] === flagValue;
|
|
4
|
+
if (flags === void 0) return false;
|
|
5
|
+
return flags[flag] === flagValue;
|
|
7
6
|
}
|
|
8
7
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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\
|
|
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,WAAW,IAAI,WAAW,WAAW,IAAI,UAAU,KAAK,CACtE,KAAK,CAAC,SAAS,IAA2B,CAC9C;;AAGH,IAAa,yBAAb,cAA4C,MAAM;CAChD,OAAO;CACP,YAAY,AAAgB,mBAA+D;AACzF,QACE,oEAAoE,MAAM,KACxE,kBAAkB,SAAS,CAC5B,CACE,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,IAAI,QAAQ,CACzC,KAAK,KAAK,GACd;EAPyB;;;AAoB9B,IAAa,sBAAb,MAAiC;CAC/B,AAAiB,wCACf,IAAI,KAAK;;;;;;CAOX,AAAO,wBACL,aACA,QAA0B,MACpB;AACN,MAAI,CAAC,KAAK,sBAAsB,IAAI,YAAY,CAC9C,MAAK,sBAAsB,IAAI,6BAAa,IAAI,KAAK,CAAC;AAExD,OAAK,sBAAsB,IAAI,YAAY,CAAE,IAAI,MAAM;AACvD,SAAO;;;;;;;CAQT,AAAO,qBACL,YACwD;AACxD,MAAI,eAAe,OAAW,QAAO;EACrC,MAAM,oCAAoB,IAAI,KAA4C;AAC1E,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,WAAW,CACnD,KAAI,IAAI,WAAW,WAAW,EAAE;AAC9B,OAAI,UAAU,OAAW;GACzB,MAAM,kBAAkB,KAAK,sBAAsB,IAAI,IAA2B;AAClF,OAAI,oBAAoB,UAAa,CAAC,gBAAgB,IAAI,MAA0B,CAClF,mBAAkB,IAAI,KAA4B,MAA0B;;AAIlF,SAAO,kBAAkB,SAAS,IAAI,SAAY;;;;;;;CAQpD,AAAO,mBAAmB,YAAwD;AAChF,SAAO,KAAK,qBAAqB,WAAW,KAAK;;;;;;;CAQnD,AAAO,oBAAoB,YAA+C;EACxE,MAAM,oBAAoB,KAAK,qBAAqB,WAAW;AAC/D,MAAI,sBAAsB,OAAW,OAAM,IAAI,uBAAuB,kBAAkB"}
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|