@zaly/tui 0.0.6 → 0.0.7
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/assets/schemas/theme.schema.json +272 -270
- package/assets/themes/kanagawa-dragon.json +3 -0
- package/assets/themes/kanagawa-wave.json +3 -0
- package/dist/{actions-CnVzKVID.d.mts → actions-DFboj3g5.d.mts} +4 -4
- package/dist/{actions-CnVzKVID.d.mts.map → actions-DFboj3g5.d.mts.map} +1 -1
- package/dist/ansi.d.mts +10 -11
- package/dist/ansi.d.mts.map +1 -1
- package/dist/{autocomplete-Dfw-yQDa.d.mts → autocomplete-CxzetPOo.d.mts} +4 -4
- package/dist/{autocomplete-Dfw-yQDa.d.mts.map → autocomplete-CxzetPOo.d.mts.map} +1 -1
- package/dist/{box-DepqUtuo.mjs → box-DLEcEvDH.mjs} +18 -11
- package/dist/box-DLEcEvDH.mjs.map +1 -0
- package/dist/{builder-DTz5mppV.mjs → builder-BgEcjj8Z.mjs} +5 -4
- package/dist/builder-BgEcjj8Z.mjs.map +1 -0
- package/dist/{callbacks-DcMBGQEO.mjs → callbacks-D132G8dy.mjs} +7 -6
- package/dist/callbacks-D132G8dy.mjs.map +1 -0
- package/dist/client-BltmwI6G.mjs +2 -0
- package/dist/{client-BBdtbLp4.mjs → client-xnCHMO2_.mjs} +62 -8
- package/dist/client-xnCHMO2_.mjs.map +1 -0
- package/dist/{clipboard-l_TWxxTf.mjs → clipboard-CNPBTX7j.mjs} +9 -7
- package/dist/{clipboard-l_TWxxTf.mjs.map → clipboard-CNPBTX7j.mjs.map} +1 -1
- package/dist/clipboard.d.mts +6 -7
- package/dist/clipboard.d.mts.map +1 -1
- package/dist/clipboard.mjs +1 -1
- package/dist/{ctx-DjJ1zSbs.mjs → ctx-ChO3St_a.mjs} +3 -3
- package/dist/{ctx-DjJ1zSbs.mjs.map → ctx-ChO3St_a.mjs.map} +1 -1
- package/dist/ctx-DZHBHjsB.mjs +2 -0
- package/dist/{divider-cclEAdPx.mjs → divider-l0-JPEIm.mjs} +2 -2
- package/dist/{divider-cclEAdPx.mjs.map → divider-l0-JPEIm.mjs.map} +1 -1
- package/dist/{files-Aw3iWpXD.d.mts → files-BUsa-RVl.d.mts} +3 -3
- package/dist/{files-Aw3iWpXD.d.mts.map → files-BUsa-RVl.d.mts.map} +1 -1
- package/dist/{github-DS00VoOj.d.mts → github-D89A3F9U.d.mts} +3 -3
- package/dist/{github-DS00VoOj.d.mts.map → github-D89A3F9U.d.mts.map} +1 -1
- package/dist/{image-BTxDPPiT.d.mts → image-34bU73bW.d.mts} +2 -2
- package/dist/{image-BTxDPPiT.d.mts.map → image-34bU73bW.d.mts.map} +1 -1
- package/dist/image.d.mts +14 -15
- package/dist/image.d.mts.map +1 -1
- package/dist/index.d.mts +13 -13
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{input-CRBuTrsL.mjs → input-D7fQEUdt.mjs} +3 -3
- package/dist/input-D7fQEUdt.mjs.map +1 -0
- package/dist/{input-B5Vy-iaa.d.mts → input-Dylds_sI.d.mts} +3 -3
- package/dist/input-Dylds_sI.d.mts.map +1 -0
- package/dist/{inspect-D6FW_QUo.d.mts → inspect-DPLRum7L.d.mts} +2 -2
- package/dist/{inspect-D6FW_QUo.d.mts.map → inspect-DPLRum7L.d.mts.map} +1 -1
- package/dist/{inspect-DE5goDzB.mjs → inspect-xdSq5Hjq.mjs} +3 -3
- package/dist/{inspect-DE5goDzB.mjs.map → inspect-xdSq5Hjq.mjs.map} +1 -1
- package/dist/kitty-JbCJC0iQ.mjs.map +1 -1
- package/dist/{log-Djvrxqk0.mjs → log-DrYLRdMW.mjs} +4 -4
- package/dist/{log-Djvrxqk0.mjs.map → log-DrYLRdMW.mjs.map} +1 -1
- package/dist/{logger-DDrt03So.mjs → logger-ClSgGf-a.mjs} +3 -3
- package/dist/logger-ClSgGf-a.mjs.map +1 -0
- package/dist/{markdown-CTlPe5ks.mjs → markdown-lRhc_4Cd.mjs} +7 -7
- package/dist/markdown-lRhc_4Cd.mjs.map +1 -0
- package/dist/markdown.d.mts +5 -5
- package/dist/markdown.d.mts.map +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/md.bun.d.mts +1 -2
- package/dist/md.bun.d.mts.map +1 -1
- package/dist/md.node.d.mts +1 -2
- package/dist/md.node.d.mts.map +1 -1
- package/dist/node-BZ7f6HzU.mjs.map +1 -1
- package/dist/{overlay-9xNgsuuy.mjs → overlay-9WXYiGgW.mjs} +2 -2
- package/dist/{overlay-9xNgsuuy.mjs.map → overlay-9WXYiGgW.mjs.map} +1 -1
- package/dist/{picker-cH-rc7-X.mjs → picker-BqHINl_a.mjs} +4 -4
- package/dist/picker-BqHINl_a.mjs.map +1 -0
- package/dist/{picker-D8OLb6kZ.d.mts → picker-JL8lZfRH.d.mts} +5 -5
- package/dist/{picker-D8OLb6kZ.d.mts.map → picker-JL8lZfRH.d.mts.map} +1 -1
- package/dist/queries-B_lOwEiE.mjs.map +1 -1
- package/dist/{queries-DH3bj74K.d.mts → queries-Cvalgu6P.d.mts} +3 -3
- package/dist/{queries-DH3bj74K.d.mts.map → queries-Cvalgu6P.d.mts.map} +1 -1
- package/dist/reactive-f7NpAi69.mjs.map +1 -1
- package/dist/{registry-w_w7gZr_.mjs → registry-CEpHcTa2.mjs} +2 -2
- package/dist/registry-CEpHcTa2.mjs.map +1 -0
- package/dist/{render-F8pVXN7h.mjs → render-DxIHVH9Y.mjs} +2 -2
- package/dist/{render-F8pVXN7h.mjs.map → render-DxIHVH9Y.mjs.map} +1 -1
- package/dist/{renderer-uMeDzF9B.mjs → renderer-Bz3tc2IT.mjs} +7 -7
- package/dist/renderer-Bz3tc2IT.mjs.map +1 -0
- package/dist/renderer-CuF4RYBZ.mjs +2 -0
- package/dist/{renderer-qSMVeNSV.mjs → renderer-DesbRwjQ.mjs} +2 -2
- package/dist/renderer-DesbRwjQ.mjs.map +1 -0
- package/dist/select-m7NE6Rwa.mjs.map +1 -1
- package/dist/{select-CbmAZdpt.d.mts → select-zGd5pbiB.d.mts} +3 -3
- package/dist/{select-CbmAZdpt.d.mts.map → select-zGd5pbiB.d.mts.map} +1 -1
- package/dist/services/logger.d.mts +1 -1
- package/dist/services/logger.mjs +1 -1
- package/dist/services/notifier.d.mts +3 -4
- package/dist/services/notifier.d.mts.map +1 -1
- package/dist/services/notifier.mjs +2 -2
- package/dist/services/notifier.mjs.map +1 -1
- package/dist/services/picker.d.mts +8 -9
- package/dist/services/picker.d.mts.map +1 -1
- package/dist/services/picker.mjs +10 -8
- package/dist/services/picker.mjs.map +1 -1
- package/dist/services/prompt.d.mts +8 -9
- package/dist/services/prompt.d.mts.map +1 -1
- package/dist/services/prompt.mjs +9 -7
- package/dist/services/prompt.mjs.map +1 -1
- package/dist/shiki/server.d.mts +1 -1
- package/dist/shiki/server.mjs +6 -2
- package/dist/shiki/server.mjs.map +1 -1
- package/dist/{shiki-BK-v9CtF.mjs → shiki-CcxiFWEF.mjs} +3 -3
- package/dist/{shiki-BK-v9CtF.mjs.map → shiki-CcxiFWEF.mjs.map} +1 -1
- package/dist/{shiki-B5NwIiot.mjs → shiki-D7l5--zz.mjs} +19 -5
- package/dist/shiki-D7l5--zz.mjs.map +1 -0
- package/dist/show-DR2x1YFc.mjs.map +1 -1
- package/dist/style.d.mts +7 -7
- package/dist/style.d.mts.map +1 -1
- package/dist/style.mjs +2 -2
- package/dist/{text-DILrol9j.mjs → text-BLz1tRoC.mjs} +4 -3
- package/dist/{text-DILrol9j.mjs.map → text-BLz1tRoC.mjs.map} +1 -1
- package/dist/{text-9lwQeqYr.d.mts → text-BefiXAFW.d.mts} +3 -3
- package/dist/{text-9lwQeqYr.d.mts.map → text-BefiXAFW.d.mts.map} +1 -1
- package/dist/{text-q26V6_Sc.mjs → text-CRZD9KTN.mjs} +3 -2
- package/dist/{text-q26V6_Sc.mjs.map → text-CRZD9KTN.mjs.map} +1 -1
- package/dist/text.d.mts +1 -1
- package/dist/text.mjs +1 -1
- package/dist/{theme.config-BptYUq4K.mjs → theme.config-DoW6LIcl.mjs} +250 -242
- package/dist/theme.config-DoW6LIcl.mjs.map +1 -0
- package/dist/themes.d.mts +8 -9
- package/dist/themes.d.mts.map +1 -1
- package/dist/themes.mjs +1 -1
- package/dist/tree-Bo1afYhe.mjs.map +1 -1
- package/dist/{tree-C28QOVIK.d.mts → tree-CArtDRec.d.mts} +3 -3
- package/dist/{tree-C28QOVIK.d.mts.map → tree-CArtDRec.d.mts.map} +1 -1
- package/dist/{types-B9Eh7k2v.d.mts → types-C0EOLZDc.d.mts} +7 -2
- package/dist/types-C0EOLZDc.d.mts.map +1 -0
- package/dist/{widget-M7jD8Rgg.d.mts → widget-DtJU2-BJ.d.mts} +2 -2
- package/dist/{widget-M7jD8Rgg.d.mts.map → widget-DtJU2-BJ.d.mts.map} +1 -1
- package/dist/widgets/autocomplete.d.mts +1 -1
- package/dist/widgets/autocomplete.mjs +2 -2
- package/dist/widgets/autocomplete.mjs.map +1 -1
- package/dist/widgets/box.d.mts +1 -1
- package/dist/widgets/box.mjs +1 -1
- package/dist/widgets/code.d.mts +4 -5
- package/dist/widgets/code.d.mts.map +1 -1
- package/dist/widgets/code.mjs +5 -5
- package/dist/widgets/completions/actions.d.mts +1 -1
- package/dist/widgets/completions/files.d.mts +1 -1
- package/dist/widgets/completions/github.d.mts +1 -1
- package/dist/widgets/completions/index.d.mts +3 -3
- package/dist/widgets/diff.d.mts +5 -6
- package/dist/widgets/diff.d.mts.map +1 -1
- package/dist/widgets/diff.mjs +3 -3
- package/dist/widgets/diff.mjs.map +1 -1
- package/dist/widgets/divider.d.mts +4 -5
- package/dist/widgets/divider.d.mts.map +1 -1
- package/dist/widgets/divider.mjs +1 -1
- package/dist/widgets/image.d.mts +1 -1
- package/dist/widgets/image.mjs +1 -1
- package/dist/widgets/image.mjs.map +1 -1
- package/dist/widgets/input.d.mts +1 -1
- package/dist/widgets/input.mjs +1 -1
- package/dist/widgets/log.d.mts +1 -1
- package/dist/widgets/log.mjs +1 -1
- package/dist/widgets/markdown.d.mts +8 -9
- package/dist/widgets/markdown.d.mts.map +1 -1
- package/dist/widgets/markdown.mjs +1 -1
- package/dist/widgets/overlay.d.mts +1 -1
- package/dist/widgets/overlay.mjs +1 -1
- package/dist/widgets/picker.d.mts +1 -1
- package/dist/widgets/picker.mjs +1 -1
- package/dist/widgets/progress.d.mts +5 -6
- package/dist/widgets/progress.d.mts.map +1 -1
- package/dist/widgets/select.d.mts +1 -1
- package/dist/widgets/show.d.mts +7 -7
- package/dist/widgets/show.d.mts.map +1 -1
- package/dist/widgets/spinner.d.mts +7 -8
- package/dist/widgets/spinner.d.mts.map +1 -1
- package/dist/widgets/spinner.mjs.map +1 -1
- package/dist/widgets/text.d.mts +1 -1
- package/dist/widgets/text.mjs +1 -1
- package/dist/widgets/tree.d.mts +1 -1
- package/dist/widgets/widget.d.mts +1 -1
- package/dist/worker-T6SdPzUH.mjs.map +1 -1
- package/package.json +8 -9
- package/dist/box-DepqUtuo.mjs.map +0 -1
- package/dist/builder-DTz5mppV.mjs.map +0 -1
- package/dist/callbacks-DcMBGQEO.mjs.map +0 -1
- package/dist/client-BBdtbLp4.mjs.map +0 -1
- package/dist/client-cIckDgAj.mjs +0 -2
- package/dist/ctx-Bt4VlRPg.mjs +0 -2
- package/dist/input-B5Vy-iaa.d.mts.map +0 -1
- package/dist/input-CRBuTrsL.mjs.map +0 -1
- package/dist/logger-DDrt03So.mjs.map +0 -1
- package/dist/markdown-CTlPe5ks.mjs.map +0 -1
- package/dist/picker-cH-rc7-X.mjs.map +0 -1
- package/dist/registry-w_w7gZr_.mjs.map +0 -1
- package/dist/renderer-Dgj_qEOA.mjs +0 -2
- package/dist/renderer-qSMVeNSV.mjs.map +0 -1
- package/dist/renderer-uMeDzF9B.mjs.map +0 -1
- package/dist/shiki-B5NwIiot.mjs.map +0 -1
- package/dist/theme.config-BptYUq4K.mjs.map +0 -1
- package/dist/types-B9Eh7k2v.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.config-DoW6LIcl.mjs","names":["_accessExpressionAsString_1._accessExpressionAsString","_assertGuard_1._assertGuard"],"sources":["../../../node_modules/.bun/typia@14.0.5+c99b9ff9268ec838/node_modules/typia/lib/TypeGuardError.mjs","../../../node_modules/.bun/typia@14.0.5+c99b9ff9268ec838/node_modules/typia/lib/internal/_assertGuard.mjs","../../../node_modules/.bun/typia@14.0.5+c99b9ff9268ec838/node_modules/typia/lib/internal/_accessExpressionAsString.mjs","../src/schemas/gen/theme.config.ts"],"sourcesContent":["//#region src/TypeGuardError.ts\n/**\n* Error thrown when type assertion fails.\n*\n* Thrown by {@link assert}, {@link assertGuard}, and other assert-family\n* functions when input doesn't match expected type `T`. Contains detailed\n* information about the first assertion failure:\n*\n* - `method`: Which typia function threw (e.g., `\"typia.assert\"`)\n* - `path`: Property path where error occurred (e.g., `\"input.user.age\"`)\n* - `expected`: Expected type string (e.g., `\"number & ExclusiveMinimum<19>\"`)\n* - `value`: Actual value that failed validation\n*\n* @template T Expected type (for type safety)\n*/\nvar TypeGuardError = class extends Error {\n\t/**\n\t* Creates a new TypeGuardError instance.\n\t*\n\t* @param props Error properties\n\t*/\n\tconstructor(props) {\n\t\tsuper(props.message || `Error on ${props.method}(): invalid type${props.path ? ` on ${props.path}` : \"\"}, expect to be ${props.expected}`);\n\t\tconst proto = new.target.prototype;\n\t\tif (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);\n\t\telse this.__proto__ = proto;\n\t\tthis.name = \"TypeGuardError\";\n\t\tthis.method = props.method;\n\t\tthis.path = props.path;\n\t\tthis.expected = props.expected;\n\t\tthis.value = props.value;\n\t\tif (props.description || props.value === void 0) this.description = props.description ?? [\n\t\t\t\"The value at this path is `undefined`.\",\n\t\t\t\"\",\n\t\t\t`Please fill the \\`${props.expected}\\` typed value next time.`\n\t\t].join(\"\\n\");\n\t}\n};\n//#endregion\nexport { TypeGuardError };\n\n//# sourceMappingURL=TypeGuardError.mjs.map","import { TypeGuardError } from \"../TypeGuardError.mjs\";\n//#region src/internal/_assertGuard.ts\nconst _assertGuard = (exceptionable, props, factory) => {\n\tif (exceptionable === true) {\n\t\tif (typeof factory === \"function\") throw factory(props);\n\t\tthrow new TypeGuardError(props);\n\t}\n\treturn false;\n};\n//#endregion\nexport { _assertGuard };\n\n//# sourceMappingURL=_assertGuard.mjs.map","//#region src/internal/_accessExpressionAsString.ts\nconst _accessExpressionAsString = (str) => variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;\nconst variable = (str) => reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);\nconst reserved = (str) => RESERVED.has(str);\nconst RESERVED = /* @__PURE__ */ new Set([\n\t\"break\",\n\t\"case\",\n\t\"catch\",\n\t\"class\",\n\t\"const\",\n\t\"continue\",\n\t\"debugger\",\n\t\"default\",\n\t\"delete\",\n\t\"do\",\n\t\"else\",\n\t\"enum\",\n\t\"export\",\n\t\"extends\",\n\t\"false\",\n\t\"finally\",\n\t\"for\",\n\t\"function\",\n\t\"if\",\n\t\"import\",\n\t\"in\",\n\t\"instanceof\",\n\t\"new\",\n\t\"null\",\n\t\"return\",\n\t\"super\",\n\t\"switch\",\n\t\"this\",\n\t\"throw\",\n\t\"true\",\n\t\"try\",\n\t\"typeof\",\n\t\"var\",\n\t\"void\",\n\t\"while\",\n\t\"with\"\n]);\n//#endregion\nexport { _accessExpressionAsString };\n\n//# sourceMappingURL=_accessExpressionAsString.mjs.map","import * as _assertGuard_1 from \"typia/lib/internal/_assertGuard\";\nimport * as _accessExpressionAsString_1 from \"typia/lib/internal/_accessExpressionAsString\";\nconst __typia_transform__accessExpressionAsString = _accessExpressionAsString_1._accessExpressionAsString;\n// oxlint-disable import/no-named-as-default-member\nimport type { ShikiTheme } from \"../../shiki/types.ts\";\nimport type { AnsiColorName, BrightAnsiColorName, Color, HexColor, Style, ThemeKey, } from \"../../style/types.ts\";\nimport type { Theme } from \"../../themes/types.ts\";\ntype UserStyle = Omit<Style, \"fg\" | \"bg\" | \"style\"> & {\n fg?: string;\n bg?: string;\n};\ntype UserTheme = {\n $schema?: string;\n shiki?: ShikiTheme;\n id: string;\n name?: string;\n} & Record<string, string | UserStyle>;\ntype ColorKeys<T> = {\n [K in keyof T]-?: [\n T[K]\n ] extends [\n Color\n ] ? K : never;\n}[keyof T];\nconst toBaseColor = (() => {\n const _iv0 = new Set([\"accent\", \"black\", \"blue\", \"border\", \"borderTitle\", \"brightBlack\", \"brightBlue\", \"brightCyan\", \"brightGray\", \"brightGreen\", \"brightGrey\", \"brightMagenta\", \"brightRed\", \"brightWhite\", \"brightYellow\", \"code\", \"codeTitle\", \"comment\", \"cyan\", \"delim\", \"diffAdd\", \"diffContext\", \"diffDel\", \"diffLine\", \"diffTitle\", \"divider\", \"error\", \"gray\", \"green\", \"grey\", \"gutter\", \"highlight\", \"id\", \"info\", \"inherit\", \"magenta\", \"mdBold\", \"mdCode\", \"mdCodeBlock\", \"mdCodeBlockTitle\", \"mdHeading\", \"mdHeading1\", \"mdHeading2\", \"mdHeading3\", \"mdHeading4\", \"mdHeading5\", \"mdHeading6\", \"mdHr\", \"mdItalic\", \"mdLink\", \"mdListBullet\", \"mdListChecked\", \"mdListUnchecked\", \"mdQuote\", \"mdStrikethrough\", \"mdTable\", \"mdTableHeader\", \"muted\", \"name\", \"optionActive\", \"optionDesc\", \"optionName\", \"overlay\", \"primary\", \"prompt\", \"quiet\", \"red\", \"selection\", \"shiki\", \"subtle\", \"success\", \"syntaxBoolean\", \"syntaxBracket\", \"syntaxConstant\", \"syntaxDelimiter\", \"syntaxField\", \"syntaxFunction\", \"syntaxNumber\", \"syntaxSpecial\", \"syntaxString\", \"text\", \"title\", \"ui\", \"warn\", \"white\", \"yellow\"]);\n const _av0 = new Set([\"accent\", \"black\", \"blue\", \"border\", \"borderTitle\", \"brightBlack\", \"brightBlue\", \"brightCyan\", \"brightGray\", \"brightGreen\", \"brightGrey\", \"brightMagenta\", \"brightRed\", \"brightWhite\", \"brightYellow\", \"code\", \"codeTitle\", \"comment\", \"cyan\", \"delim\", \"diffAdd\", \"diffContext\", \"diffDel\", \"diffLine\", \"diffTitle\", \"divider\", \"error\", \"gray\", \"green\", \"grey\", \"gutter\", \"highlight\", \"id\", \"info\", \"inherit\", \"magenta\", \"mdBold\", \"mdCode\", \"mdCodeBlock\", \"mdCodeBlockTitle\", \"mdHeading\", \"mdHeading1\", \"mdHeading2\", \"mdHeading3\", \"mdHeading4\", \"mdHeading5\", \"mdHeading6\", \"mdHr\", \"mdItalic\", \"mdLink\", \"mdListBullet\", \"mdListChecked\", \"mdListUnchecked\", \"mdQuote\", \"mdStrikethrough\", \"mdTable\", \"mdTableHeader\", \"muted\", \"name\", \"optionActive\", \"optionDesc\", \"optionName\", \"overlay\", \"primary\", \"prompt\", \"quiet\", \"red\", \"selection\", \"shiki\", \"subtle\", \"success\", \"syntaxBoolean\", \"syntaxBracket\", \"syntaxConstant\", \"syntaxDelimiter\", \"syntaxField\", \"syntaxFunction\", \"syntaxNumber\", \"syntaxSpecial\", \"syntaxString\", \"text\", \"title\", \"ui\", \"warn\", \"white\", \"yellow\"]);\n const _ae0 = \"(\\\"accent\\\" | \\\"black\\\" | \\\"blue\\\" | \\\"border\\\" | \\\"borderTitle\\\" | \\\"brightBlack\\\" | \\\"brightBlue\\\" | \\\"brightCyan\\\" | \\\"brightGray\\\" | \\\"brightGreen\\\" | \\\"brightGrey\\\" | \\\"brightMagenta\\\" | \\\"brightRed\\\" | \\\"brightWhite\\\" | \\\"brightYellow\\\" | \\\"code\\\" | \\\"codeTitle\\\" | \\\"comment\\\" | \\\"cyan\\\" | \\\"delim\\\" | \\\"diffAdd\\\" | \\\"diffContext\\\" | \\\"diffDel\\\" | \\\"diffLine\\\" | \\\"diffTitle\\\" | \\\"divider\\\" | \\\"error\\\" | \\\"gray\\\" | \\\"green\\\" | \\\"grey\\\" | \\\"gutter\\\" | \\\"highlight\\\" | \\\"id\\\" | \\\"info\\\" | \\\"inherit\\\" | \\\"magenta\\\" | \\\"mdBold\\\" | \\\"mdCode\\\" | \\\"mdCodeBlock\\\" | \\\"mdCodeBlockTitle\\\" | \\\"mdHeading\\\" | \\\"mdHeading1\\\" | \\\"mdHeading2\\\" | \\\"mdHeading3\\\" | \\\"mdHeading4\\\" | \\\"mdHeading5\\\" | \\\"mdHeading6\\\" | \\\"mdHr\\\" | \\\"mdItalic\\\" | \\\"mdLink\\\" | \\\"mdListBullet\\\" | \\\"mdListChecked\\\" | \\\"mdListUnchecked\\\" | \\\"mdQuote\\\" | \\\"mdStrikethrough\\\" | \\\"mdTable\\\" | \\\"mdTableHeader\\\" | \\\"muted\\\" | \\\"name\\\" | \\\"optionActive\\\" | \\\"optionDesc\\\" | \\\"optionName\\\" | \\\"overlay\\\" | \\\"primary\\\" | \\\"prompt\\\" | \\\"quiet\\\" | \\\"red\\\" | \\\"selection\\\" | \\\"shiki\\\" | \\\"subtle\\\" | \\\"success\\\" | \\\"syntaxBoolean\\\" | \\\"syntaxBracket\\\" | \\\"syntaxConstant\\\" | \\\"syntaxDelimiter\\\" | \\\"syntaxField\\\" | \\\"syntaxFunction\\\" | \\\"syntaxNumber\\\" | \\\"syntaxSpecial\\\" | \\\"syntaxString\\\" | \\\"text\\\" | \\\"title\\\" | \\\"ui\\\" | \\\"warn\\\" | \\\"white\\\" | \\\"yellow\\\" | `#${string}`)\";\n const __is = (input: any): input is HexColor | AnsiColorName | BrightAnsiColorName | ThemeKey | \"inherit\" => null !== input && undefined !== input && (true === _iv0.has(input) || \"string\" === typeof input && RegExp(/^#(.*)/).test(input));\n let _errorFactory: any;\n return (input: any, errorFactory?: (p: import(\"typia\").TypeGuardError.IProps) => Error): HexColor | AnsiColorName | BrightAnsiColorName | ThemeKey | \"inherit\" => {\n if (false === __is(input)) {\n _errorFactory = errorFactory;\n ((input: any, _path: string, _exceptionable: boolean = true) => (null !== input || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: _ae0,\n value: input\n }, _errorFactory)) && (undefined !== input || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: _ae0,\n value: input\n }, _errorFactory)) && (true === _av0.has(input) || \"string\" === typeof input && RegExp(/^#(.*)/).test(input) || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: _ae0,\n value: input\n }, _errorFactory)))(input, \"$input\", true);\n }\n return input;\n };\n})();\nconst toLightnessColor = (() => {\n const _iv0 = new Set([\"accent\", \"border\", \"borderTitle\", \"code\", \"codeTitle\", \"comment\", \"delim\", \"diffAdd\", \"diffContext\", \"diffDel\", \"diffLine\", \"diffTitle\", \"divider\", \"error\", \"gutter\", \"highlight\", \"id\", \"info\", \"mdBold\", \"mdCode\", \"mdCodeBlock\", \"mdCodeBlockTitle\", \"mdHeading\", \"mdHeading1\", \"mdHeading2\", \"mdHeading3\", \"mdHeading4\", \"mdHeading5\", \"mdHeading6\", \"mdHr\", \"mdItalic\", \"mdLink\", \"mdListBullet\", \"mdListChecked\", \"mdListUnchecked\", \"mdQuote\", \"mdStrikethrough\", \"mdTable\", \"mdTableHeader\", \"muted\", \"name\", \"optionActive\", \"optionDesc\", \"optionName\", \"overlay\", \"primary\", \"prompt\", \"quiet\", \"selection\", \"shiki\", \"subtle\", \"success\", \"syntaxBoolean\", \"syntaxBracket\", \"syntaxConstant\", \"syntaxDelimiter\", \"syntaxField\", \"syntaxFunction\", \"syntaxNumber\", \"syntaxSpecial\", \"syntaxString\", \"text\", \"title\", \"ui\", \"warn\"]);\n const _av0 = new Set([\"accent\", \"border\", \"borderTitle\", \"code\", \"codeTitle\", \"comment\", \"delim\", \"diffAdd\", \"diffContext\", \"diffDel\", \"diffLine\", \"diffTitle\", \"divider\", \"error\", \"gutter\", \"highlight\", \"id\", \"info\", \"mdBold\", \"mdCode\", \"mdCodeBlock\", \"mdCodeBlockTitle\", \"mdHeading\", \"mdHeading1\", \"mdHeading2\", \"mdHeading3\", \"mdHeading4\", \"mdHeading5\", \"mdHeading6\", \"mdHr\", \"mdItalic\", \"mdLink\", \"mdListBullet\", \"mdListChecked\", \"mdListUnchecked\", \"mdQuote\", \"mdStrikethrough\", \"mdTable\", \"mdTableHeader\", \"muted\", \"name\", \"optionActive\", \"optionDesc\", \"optionName\", \"overlay\", \"primary\", \"prompt\", \"quiet\", \"selection\", \"shiki\", \"subtle\", \"success\", \"syntaxBoolean\", \"syntaxBracket\", \"syntaxConstant\", \"syntaxDelimiter\", \"syntaxField\", \"syntaxFunction\", \"syntaxNumber\", \"syntaxSpecial\", \"syntaxString\", \"text\", \"title\", \"ui\", \"warn\"]);\n const _ae0 = \"(\\\"accent\\\" | \\\"border\\\" | \\\"borderTitle\\\" | \\\"code\\\" | \\\"codeTitle\\\" | \\\"comment\\\" | \\\"delim\\\" | \\\"diffAdd\\\" | \\\"diffContext\\\" | \\\"diffDel\\\" | \\\"diffLine\\\" | \\\"diffTitle\\\" | \\\"divider\\\" | \\\"error\\\" | \\\"gutter\\\" | \\\"highlight\\\" | \\\"id\\\" | \\\"info\\\" | \\\"mdBold\\\" | \\\"mdCode\\\" | \\\"mdCodeBlock\\\" | \\\"mdCodeBlockTitle\\\" | \\\"mdHeading\\\" | \\\"mdHeading1\\\" | \\\"mdHeading2\\\" | \\\"mdHeading3\\\" | \\\"mdHeading4\\\" | \\\"mdHeading5\\\" | \\\"mdHeading6\\\" | \\\"mdHr\\\" | \\\"mdItalic\\\" | \\\"mdLink\\\" | \\\"mdListBullet\\\" | \\\"mdListChecked\\\" | \\\"mdListUnchecked\\\" | \\\"mdQuote\\\" | \\\"mdStrikethrough\\\" | \\\"mdTable\\\" | \\\"mdTableHeader\\\" | \\\"muted\\\" | \\\"name\\\" | \\\"optionActive\\\" | \\\"optionDesc\\\" | \\\"optionName\\\" | \\\"overlay\\\" | \\\"primary\\\" | \\\"prompt\\\" | \\\"quiet\\\" | \\\"selection\\\" | \\\"shiki\\\" | \\\"subtle\\\" | \\\"success\\\" | \\\"syntaxBoolean\\\" | \\\"syntaxBracket\\\" | \\\"syntaxConstant\\\" | \\\"syntaxDelimiter\\\" | \\\"syntaxField\\\" | \\\"syntaxFunction\\\" | \\\"syntaxNumber\\\" | \\\"syntaxSpecial\\\" | \\\"syntaxString\\\" | \\\"text\\\" | \\\"title\\\" | \\\"ui\\\" | \\\"warn\\\" | `#${string}`)\";\n const __is = (input: any): input is HexColor | ThemeKey => null !== input && undefined !== input && (true === _iv0.has(input) || \"string\" === typeof input && RegExp(/^#(.*)/).test(input));\n let _errorFactory: any;\n return (input: any, errorFactory?: (p: import(\"typia\").TypeGuardError.IProps) => Error): HexColor | ThemeKey => {\n if (false === __is(input)) {\n _errorFactory = errorFactory;\n ((input: any, _path: string, _exceptionable: boolean = true) => (null !== input || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: _ae0,\n value: input\n }, _errorFactory)) && (undefined !== input || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: _ae0,\n value: input\n }, _errorFactory)) && (true === _av0.has(input) || \"string\" === typeof input && RegExp(/^#(.*)/).test(input) || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: _ae0,\n value: input\n }, _errorFactory)))(input, \"$input\", true);\n }\n return input;\n };\n})();\nconst toStyle = (() => {\n const _ao0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => _ao1(input, _path, true && _exceptionable) && ((undefined === input.fg || \"string\" === typeof input.fg || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".fg\",\n expected: \"(string | undefined)\",\n value: input.fg\n }, _errorFactory)) && (undefined === input.bg || \"string\" === typeof input.bg || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".bg\",\n expected: \"(string | undefined)\",\n value: input.bg\n }, _errorFactory)));\n const _ao1 = (input: any, _path: string, _exceptionable: boolean = true): boolean => (undefined === input.bold || \"boolean\" === typeof input.bold || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".bold\",\n expected: \"(boolean | undefined)\",\n value: input.bold\n }, _errorFactory)) && (undefined === input.dim || \"boolean\" === typeof input.dim || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".dim\",\n expected: \"(boolean | undefined)\",\n value: input.dim\n }, _errorFactory)) && (undefined === input.italic || \"boolean\" === typeof input.italic || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".italic\",\n expected: \"(boolean | undefined)\",\n value: input.italic\n }, _errorFactory)) && (undefined === input.underline || \"boolean\" === typeof input.underline || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".underline\",\n expected: \"(boolean | undefined)\",\n value: input.underline\n }, _errorFactory)) && (undefined === input.inverse || \"boolean\" === typeof input.inverse || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".inverse\",\n expected: \"(boolean | undefined)\",\n value: input.inverse\n }, _errorFactory)) && (undefined === input.strikethrough || \"boolean\" === typeof input.strikethrough || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssert\",\n path: _path + \".strikethrough\",\n expected: \"(boolean | undefined)\",\n value: input.strikethrough\n }, _errorFactory));\n const _io0 = (input: any): boolean => _io1(input) && ((undefined === input.fg || \"string\" === typeof input.fg) && (undefined === input.bg || \"string\" === typeof input.bg));\n const _io1 = (input: any): boolean => (undefined === input.bold || \"boolean\" === typeof input.bold) && (undefined === input.dim || \"boolean\" === typeof input.dim) && (undefined === input.italic || \"boolean\" === typeof input.italic) && (undefined === input.underline || \"boolean\" === typeof input.underline) && (undefined === input.inverse || \"boolean\" === typeof input.inverse) && (undefined === input.strikethrough || \"boolean\" === typeof input.strikethrough);\n const __is = (input: any): input is UserStyle => \"object\" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);\n let _errorFactory: any;\n return (input: any, errorFactory?: (p: import(\"typia\").TypeGuardError.IProps) => Error): UserStyle => {\n if (false === __is(input)) {\n _errorFactory = errorFactory;\n ((input: any, _path: string, _exceptionable: boolean = true) => (\"object\" === typeof input && null !== input && false === Array.isArray(input) || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: \"UserStyle\",\n value: input\n }, _errorFactory)) && _ao0(input, _path + \"\", true) || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssert\",\n path: _path + \"\",\n expected: \"UserStyle\",\n value: input\n }, _errorFactory))(input, \"$input\", true);\n }\n return input;\n };\n})();\nconst isColorKey = (() => {\n return (input: any): input is ColorKeys<Theme> => \"accent\" === input || \"error\" === input || \"info\" === input || \"primary\" === input || \"success\" === input || \"text\" === input || \"warn\" === input;\n})();\nfunction toColor(value: unknown) {\n if (typeof value !== \"string\")\n return toBaseColor(value); // will throw\n const color = value.replace(/[+-]\\d+/, \"\");\n if (value.match(/[+-]\\d+/))\n toLightnessColor(color);\n return toBaseColor(color);\n}\nconst validator = (() => {\n const _iv0 = new Set([\"andromeeda\", \"aurora-x\", \"ayu-dark\", \"ayu-light\", \"ayu-mirage\", \"catppuccin-frappe\", \"catppuccin-latte\", \"catppuccin-macchiato\", \"catppuccin-mocha\", \"dark-plus\", \"dracula\", \"dracula-soft\", \"everforest-dark\", \"everforest-light\", \"github-dark\", \"github-dark-default\", \"github-dark-dimmed\", \"github-dark-high-contrast\", \"github-light\", \"github-light-default\", \"github-light-high-contrast\", \"gruvbox-dark-hard\", \"gruvbox-dark-medium\", \"gruvbox-dark-soft\", \"gruvbox-light-hard\", \"gruvbox-light-medium\", \"gruvbox-light-soft\", \"horizon\", \"horizon-bright\", \"houston\", \"kanagawa-dragon\", \"kanagawa-lotus\", \"kanagawa-wave\", \"laserwave\", \"light-plus\", \"material-theme\", \"material-theme-darker\", \"material-theme-lighter\", \"material-theme-ocean\", \"material-theme-palenight\", \"min-dark\", \"min-light\", \"monokai\", \"night-owl\", \"night-owl-light\", \"nord\", \"one-dark-pro\", \"one-light\", \"plastic\", \"poimandres\", \"red\", \"rose-pine\", \"rose-pine-dawn\", \"rose-pine-moon\", \"slack-dark\", \"slack-ochin\", \"snazzy-light\", \"solarized-dark\", \"solarized-light\", \"synthwave-84\", \"tokyo-night\", \"vesper\", \"vitesse-black\", \"vitesse-dark\", \"vitesse-light\"]);\n const _av0 = new Set([\"andromeeda\", \"aurora-x\", \"ayu-dark\", \"ayu-light\", \"ayu-mirage\", \"catppuccin-frappe\", \"catppuccin-latte\", \"catppuccin-macchiato\", \"catppuccin-mocha\", \"dark-plus\", \"dracula\", \"dracula-soft\", \"everforest-dark\", \"everforest-light\", \"github-dark\", \"github-dark-default\", \"github-dark-dimmed\", \"github-dark-high-contrast\", \"github-light\", \"github-light-default\", \"github-light-high-contrast\", \"gruvbox-dark-hard\", \"gruvbox-dark-medium\", \"gruvbox-dark-soft\", \"gruvbox-light-hard\", \"gruvbox-light-medium\", \"gruvbox-light-soft\", \"horizon\", \"horizon-bright\", \"houston\", \"kanagawa-dragon\", \"kanagawa-lotus\", \"kanagawa-wave\", \"laserwave\", \"light-plus\", \"material-theme\", \"material-theme-darker\", \"material-theme-lighter\", \"material-theme-ocean\", \"material-theme-palenight\", \"min-dark\", \"min-light\", \"monokai\", \"night-owl\", \"night-owl-light\", \"nord\", \"one-dark-pro\", \"one-light\", \"plastic\", \"poimandres\", \"red\", \"rose-pine\", \"rose-pine-dawn\", \"rose-pine-moon\", \"slack-dark\", \"slack-ochin\", \"snazzy-light\", \"solarized-dark\", \"solarized-light\", \"synthwave-84\", \"tokyo-night\", \"vesper\", \"vitesse-black\", \"vitesse-dark\", \"vitesse-light\"]);\n const _ae0 = \"(\\\"andromeeda\\\" | \\\"aurora-x\\\" | \\\"ayu-dark\\\" | \\\"ayu-light\\\" | \\\"ayu-mirage\\\" | \\\"catppuccin-frappe\\\" | \\\"catppuccin-latte\\\" | \\\"catppuccin-macchiato\\\" | \\\"catppuccin-mocha\\\" | \\\"dark-plus\\\" | \\\"dracula\\\" | \\\"dracula-soft\\\" | \\\"everforest-dark\\\" | \\\"everforest-light\\\" | \\\"github-dark\\\" | \\\"github-dark-default\\\" | \\\"github-dark-dimmed\\\" | \\\"github-dark-high-contrast\\\" | \\\"github-light\\\" | \\\"github-light-default\\\" | \\\"github-light-high-contrast\\\" | \\\"gruvbox-dark-hard\\\" | \\\"gruvbox-dark-medium\\\" | \\\"gruvbox-dark-soft\\\" | \\\"gruvbox-light-hard\\\" | \\\"gruvbox-light-medium\\\" | \\\"gruvbox-light-soft\\\" | \\\"horizon\\\" | \\\"horizon-bright\\\" | \\\"houston\\\" | \\\"kanagawa-dragon\\\" | \\\"kanagawa-lotus\\\" | \\\"kanagawa-wave\\\" | \\\"laserwave\\\" | \\\"light-plus\\\" | \\\"material-theme\\\" | \\\"material-theme-darker\\\" | \\\"material-theme-lighter\\\" | \\\"material-theme-ocean\\\" | \\\"material-theme-palenight\\\" | \\\"min-dark\\\" | \\\"min-light\\\" | \\\"monokai\\\" | \\\"night-owl\\\" | \\\"night-owl-light\\\" | \\\"nord\\\" | \\\"one-dark-pro\\\" | \\\"one-light\\\" | \\\"plastic\\\" | \\\"poimandres\\\" | \\\"red\\\" | \\\"rose-pine\\\" | \\\"rose-pine-dawn\\\" | \\\"rose-pine-moon\\\" | \\\"slack-dark\\\" | \\\"slack-ochin\\\" | \\\"snazzy-light\\\" | \\\"solarized-dark\\\" | \\\"solarized-light\\\" | \\\"synthwave-84\\\" | \\\"tokyo-night\\\" | \\\"vesper\\\" | \\\"vitesse-black\\\" | \\\"vitesse-dark\\\" | \\\"vitesse-light\\\" | undefined)\";\n const _ao0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => (undefined === input.$schema || \"string\" === typeof input.$schema || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".$schema\",\n expected: \"(string | undefined)\",\n value: input.$schema\n }, _errorFactory)) && (undefined === input.shiki || true === _av0.has(input.shiki) || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".shiki\",\n expected: _ae0,\n value: input.shiki\n }, _errorFactory)) && (undefined === input.id || \"string\" === typeof input.id || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".id\",\n expected: \"(string | undefined)\",\n value: input.id\n }, _errorFactory)) && (undefined === input.name || \"string\" === typeof input.name || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".name\",\n expected: \"(string | undefined)\",\n value: input.name\n }, _errorFactory)) && (false === _exceptionable || Object.keys(input).every((key: any) => {\n if ([\"$schema\", \"shiki\", \"id\", \"name\"].some((prop: any) => key === prop))\n return true;\n const value = input[key];\n if (undefined === value)\n return true;\n return (null !== value || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + __typia_transform__accessExpressionAsString(key),\n expected: \"(UserStyle | string | undefined)\",\n value: value\n }, _errorFactory)) && (undefined === value || \"string\" === typeof value || (\"object\" === typeof value && null !== value && false === Array.isArray(value) || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + __typia_transform__accessExpressionAsString(key),\n expected: \"(UserStyle | string | undefined)\",\n value: value\n }, _errorFactory)) && _ao1(value, _path + __typia_transform__accessExpressionAsString(key), true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + __typia_transform__accessExpressionAsString(key),\n expected: \"(UserStyle | string | undefined)\",\n value: value\n }, _errorFactory));\n }));\n const _ao1 = (input: any, _path: string, _exceptionable: boolean = true): boolean => (undefined === input.bold || \"boolean\" === typeof input.bold || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".bold\",\n expected: \"(boolean | undefined)\",\n value: input.bold\n }, _errorFactory)) && (undefined === input.dim || \"boolean\" === typeof input.dim || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".dim\",\n expected: \"(boolean | undefined)\",\n value: input.dim\n }, _errorFactory)) && (undefined === input.italic || \"boolean\" === typeof input.italic || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".italic\",\n expected: \"(boolean | undefined)\",\n value: input.italic\n }, _errorFactory)) && (undefined === input.underline || \"boolean\" === typeof input.underline || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".underline\",\n expected: \"(boolean | undefined)\",\n value: input.underline\n }, _errorFactory)) && (undefined === input.inverse || \"boolean\" === typeof input.inverse || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".inverse\",\n expected: \"(boolean | undefined)\",\n value: input.inverse\n }, _errorFactory)) && (undefined === input.strikethrough || \"boolean\" === typeof input.strikethrough || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".strikethrough\",\n expected: \"(boolean | undefined)\",\n value: input.strikethrough\n }, _errorFactory)) && (undefined === input.fg || \"string\" === typeof input.fg || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".fg\",\n expected: \"(string | undefined)\",\n value: input.fg\n }, _errorFactory)) && (undefined === input.bg || \"string\" === typeof input.bg || _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + \".bg\",\n expected: \"(string | undefined)\",\n value: input.bg\n }, _errorFactory)) && (0 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every((key: any) => {\n if ([\"bold\", \"dim\", \"italic\", \"underline\", \"inverse\", \"strikethrough\", \"fg\", \"bg\"].some((prop: any) => key === prop))\n return true;\n const value = input[key];\n if (undefined === value)\n return true;\n return _assertGuard_1._assertGuard(_exceptionable, {\n method: \"typia.createAssertEquals\",\n path: _path + _accessExpressionAsString_1._accessExpressionAsString(key),\n expected: \"undefined\",\n value: value\n }, _errorFactory);\n })));\n const _io0 = (input: any, _exceptionable: boolean = true): boolean => (undefined === input.$schema || \"string\" === typeof input.$schema) && (undefined === input.shiki || true === _iv0.has(input.shiki)) && (undefined === input.id || \"string\" === typeof input.id) && (undefined === input.name || \"string\" === typeof input.name) && Object.keys(input).every((key: any) => {\n if ([\"$schema\", \"shiki\", \"id\", \"name\"].some((prop: any) => key === prop))\n return true;\n const value = input[key];\n if (undefined === value)\n return true;\n return null !== value && (undefined === value || \"string\" === typeof value || \"object\" === typeof value && null !== value && false === Array.isArray(value) && _io1(value, true && _exceptionable));\n });\n const _io1 = (input: any, _exceptionable: boolean = true): boolean => (undefined === input.bold || \"boolean\" === typeof input.bold) && (undefined === input.dim || \"boolean\" === typeof input.dim) && (undefined === input.italic || \"boolean\" === typeof input.italic) && (undefined === input.underline || \"boolean\" === typeof input.underline) && (undefined === input.inverse || \"boolean\" === typeof input.inverse) && (undefined === input.strikethrough || \"boolean\" === typeof input.strikethrough) && (undefined === input.fg || \"string\" === typeof input.fg) && (undefined === input.bg || \"string\" === typeof input.bg) && (0 === Object.keys(input).length || Object.keys(input).every((key: any) => {\n if ([\"bold\", \"dim\", \"italic\", \"underline\", \"inverse\", \"strikethrough\", \"fg\", \"bg\"].some((prop: any) => key === prop))\n return true;\n const value = input[key];\n if (undefined === value)\n return true;\n return false;\n }));\n const __is = (input: any, _exceptionable: boolean = true): input is Partial<UserTheme> => \"object\" === typeof input && null !== input && false === Array.isArray(input) && _io0(input, true);\n let _errorFactory: any;\n return (input: any, errorFactory?: (p: import(\"typia\").TypeGuardError.IProps) => Error): Partial<UserTheme> => {\n if (false === __is(input)) {\n _errorFactory = errorFactory;\n ((input: any, _path: string, _exceptionable: boolean = true) => (\"object\" === typeof input && null !== input && false === Array.isArray(input) || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssertEquals\",\n path: _path + \"\",\n expected: \"Partial<UserTheme>\",\n value: input\n }, _errorFactory)) && _ao0(input, _path + \"\", true) || _assertGuard_1._assertGuard(true, {\n method: \"typia.createAssertEquals\",\n path: _path + \"\",\n expected: \"Partial<UserTheme>\",\n value: input\n }, _errorFactory))(input, \"$input\", true);\n }\n return input;\n };\n})();\nconst skipSlots = new Set([\"$schema\", \"shiki\", \"id\", \"name\"]);\nexport function validateTheme(input: unknown): Partial<UserTheme> {\n const out = validator(input);\n for (const [slot, value] of Object.entries(out)) {\n if (skipSlots.has(slot) || value === undefined)\n continue;\n if (typeof value === \"string\" && toColor(value))\n continue;\n if (isColorKey(slot))\n toColor(value);\n const style = toStyle(value);\n if (style.fg !== undefined)\n toColor(style.fg);\n if (style.bg !== undefined)\n toColor(style.bg);\n }\n return out as unknown as Partial<Theme> & {\n $schema?: string;\n };\n}\n"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;;;;;;;;;AAeA,IAAI,iBAAiB,cAAc,MAAM;;;;;;CAMxC,YAAY,OAAO;EAClB,MAAM,MAAM,WAAW,YAAY,MAAM,OAAO,kBAAkB,MAAM,OAAO,OAAO,MAAM,SAAS,GAAG,iBAAiB,MAAM,UAAU;EACzI,MAAM,QAAQ,WAAW;EACzB,IAAI,OAAO,gBAAgB,OAAO,eAAe,MAAM,KAAK;OACvD,KAAK,YAAY;EACtB,KAAK,OAAO;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,OAAO,MAAM;EAClB,KAAK,WAAW,MAAM;EACtB,KAAK,QAAQ,MAAM;EACnB,IAAI,MAAM,eAAe,MAAM,UAAU,KAAK,GAAG,KAAK,cAAc,MAAM,eAAe;GACxF;GACA;GACA,qBAAqB,MAAM,SAAS;EACrC,CAAC,CAAC,KAAK,IAAI;CACZ;AACD;;;ACnCA,MAAM,gBAAgB,eAAe,OAAO,YAAY;CACvD,IAAI,kBAAkB,MAAM;EAC3B,IAAI,OAAO,YAAY,YAAY,MAAM,QAAQ,KAAK;EACtD,MAAM,I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B;GAChB,EAAE,OAAY,OAAe,iBAA0B,UAAU,aAAa,OAAO,SAAS,SAAS,SAAS,UAAU,MAAM,QAAQ,KAAK,KAAKC,aAA4B,MAAM;IAChL,QAAQ;IACR,MAAM,QAAQ;IACd,UAAU;IACV,OAAO;GACX,GAAG,aAAa,MAAM,KAAK,OAAO,QAAQ,IAAI,IAAI,KAAKA,aAA4B,MAAM;IACrF,QAAQ;IACR,MAAM,QAAQ;IACd,UAAU;IACV,OAAO;GACX,GAAG,aAAa,EAAA,CAAG,OAAO,UAAU,IAAI;EAC5C;EACA,OAAO;CACX;AACJ,EAAA,CAAG;AACH,MAAM,4BAAY,IAAI,IAAI;CAAC;CAAW;CAAS;CAAM;AAAM,CAAC;AAC5D,SAAgB,cAAc,OAAoC;CAC9D,MAAM,MAAM,UAAU,KAAK;CAC3B,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,GAAG,GAAG;EAC7C,IAAI,UAAU,IAAI,IAAI,KAAK,UAAU,KAAA,GACjC;EACJ,IAAI,OAAO,UAAU,YAAY,QAAQ,KAAK,GAC1C;EACJ,IAAI,WAAW,IAAI,GACf,QAAQ,KAAK;EACjB,MAAM,QAAQ,QAAQ,KAAK;EAC3B,IAAI,MAAM,OAAO,KAAA,GACb,QAAQ,MAAM,EAAE;EACpB,IAAI,MAAM,OAAO,KAAA,GACb,QAAQ,MAAM,EAAE;CACxB;CACA,OAAO;AAGX"}
|
package/dist/themes.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Theme } from "./types-
|
|
1
|
+
import { t as Theme } from "./types-C0EOLZDc.mjs";
|
|
2
2
|
//#region src/themes/builtin.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Async loader map for every built-in theme. Each entry returns the
|
|
@@ -54,15 +54,15 @@ declare const builtin: {
|
|
|
54
54
|
//#region src/themes/registry.d.ts
|
|
55
55
|
/** Built-in theme names plus the synthetic `"ansi"` palette (no JSON
|
|
56
56
|
* — falls back to `defaults` only). */
|
|
57
|
-
type BuiltinTheme = keyof typeof builtin | "ansi";
|
|
58
|
-
type AnyTheme = BuiltinTheme | (string & {});
|
|
59
|
-
type ThemeLoader = () => Promise<Partial<Theme>>;
|
|
57
|
+
export type BuiltinTheme = keyof typeof builtin | "ansi";
|
|
58
|
+
export type AnyTheme = BuiltinTheme | (string & {});
|
|
59
|
+
export type ThemeLoader = () => Promise<Partial<Theme>>;
|
|
60
60
|
/**
|
|
61
61
|
* Registry of built-in themes plus any registered at runtime. The
|
|
62
62
|
* registry never awaits — loaders return `Promise<Partial<Theme>>` so
|
|
63
63
|
* callers `await` explicitly.
|
|
64
64
|
*/
|
|
65
|
-
declare const themeRegistry: import("@zaly/shared/registry").Registry<ThemeLoader, {
|
|
65
|
+
export declare const themeRegistry: import("@zaly/shared/registry").Registry<ThemeLoader, {
|
|
66
66
|
readonly "ayu-dark": () => Promise<Partial<Theme>>;
|
|
67
67
|
readonly "catppuccin-frappe": () => Promise<Partial<Theme>>;
|
|
68
68
|
readonly "catppuccin-latte": () => Promise<Partial<Theme>>;
|
|
@@ -101,13 +101,12 @@ declare const themeRegistry: import("@zaly/shared/registry").Registry<ThemeLoade
|
|
|
101
101
|
/**
|
|
102
102
|
* Load a theme by name or path.
|
|
103
103
|
*/
|
|
104
|
-
declare function loadTheme(name?: string): Promise<Theme>;
|
|
105
|
-
declare function loadTheme(opts: {
|
|
104
|
+
export declare function loadTheme(name?: string): Promise<Theme>;
|
|
105
|
+
export declare function loadTheme(opts: {
|
|
106
106
|
name?: string;
|
|
107
107
|
path?: string;
|
|
108
108
|
}): Promise<Theme>;
|
|
109
109
|
/** TokyoNight Moon — the default. Sourced from `assets/themes/tokyonight-moon.json`. */
|
|
110
|
-
declare const defaultTheme: Theme;
|
|
110
|
+
export declare const defaultTheme: Theme;
|
|
111
111
|
//#endregion
|
|
112
|
-
export { AnyTheme, BuiltinTheme, ThemeLoader, defaultTheme, loadTheme, themeRegistry };
|
|
113
112
|
//# sourceMappingURL=themes.d.mts.map
|
package/dist/themes.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.d.mts","names":[],"sources":["../src/themes/builtin.ts","../src/themes/registry.ts"],"mappings":";;;;;;;;;;;;;;;;cAyBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"themes.d.mts","names":[],"sources":["../src/themes/builtin.ts","../src/themes/registry.ts"],"mappings":";;;;;;;;;;;;;;;;cAyBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YCbD,4BAA4B;YAC5B,WAAW;YACX,oBAAoB,QAAQ,QAAQ;;;;;;qBASnC,+CAAa,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAQJ,UAAU,gBAAgB,QAAQ;wBAClC,UAAU;EAAQ;EAAe;IAAkB,QAAQ;;qBA4CpE,cAAY"}
|
package/dist/themes.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as loadTheme, r as themeRegistry, t as defaultTheme } from "./registry-
|
|
1
|
+
import { n as loadTheme, r as themeRegistry, t as defaultTheme } from "./registry-CEpHcTa2.mjs";
|
|
2
2
|
export { defaultTheme, loadTheme, themeRegistry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-Bo1afYhe.mjs","names":[
|
|
1
|
+
{"version":3,"file":"tree-Bo1afYhe.mjs","names":[],"sources":["../src/widgets/tree.ts"],"sourcesContent":["import type { Reactive } from \"../core/reactive.ts\"\nimport type { Option, Select, SelectState } from \"./select.ts\"\n\nimport { stringWidth } from \"@zaly/shared/ansi\"\nimport { memo, unwrap } from \"../core/reactive.ts\"\nimport { select } from \"./select.ts\"\nimport { widget } from \"./widget.ts\"\n\nexport type TreeItem<T extends Option = Option> = T & {\n children?: TreeItem<T>[]\n icon?: string\n}\n\nexport type TreeProps<T extends TreeItem = TreeItem> = Omit<SelectState<T>, \"items\" | \"active\"> & {\n tree: Reactive<T>\n /** If true, the root node will be rendered and selectable. Defaults to false. */\n root?: boolean\n active?: T | ((item: T) => boolean)\n}\n\nconst icons = {\n // last: \"└─\",\n last: \"╰─\",\n middle: \"├─\",\n vertical: \"│ \",\n}\n\nexport type TreeNode<T extends TreeItem> = {\n last?: boolean\n parent?: T\n}\n\nclass Tree<T extends TreeItem> {\n nodes = new Map<T, TreeNode<T>>()\n items: T[] = []\n\n constructor(public root: T) {\n this.#build(root, undefined, true)\n }\n\n #build(item: T, parent?: T, last?: boolean) {\n this.nodes.set(item, { last, parent })\n this.items.push(item)\n const children = item.children ?? []\n for (let c = 0; c < children.length; c++) {\n const child = children[c] as T\n this.#build(child, item, c === children.length - 1)\n }\n }\n\n node(item: T) {\n return this.nodes.get(item)\n }\n}\n\nexport const tree = widget(\n <T extends TreeItem>(props: TreeProps<T>): Select<T> & { items: Reactive<T[]> } => {\n const builder = memo(() => new Tree(unwrap(props.tree)))\n const items = memo(() => (props.root === true ? builder().items : builder().items.slice(1)))\n\n const activeFn =\n typeof props.active === \"function\" ? props.active : (i: T) => i === props.active\n const active = props.active ? items().findIndex((i) => activeFn(i)) : -1\n\n const ret = select({ ...props, active: active === -1 ? 0 : active, items })\n\n ret.extendRenderer((prev) => (item, ctx) => {\n const t = builder()\n const path: string[] = []\n const s = ctx.style\n const itemNode = t.node(item)\n let n = t.node(item)\n while (n?.parent) {\n if (props.root !== true && n.parent === props.tree) break\n let icon = \"\"\n if (n !== itemNode) icon = n.last ? \" \" : icons.vertical\n else icon = n.last ? icons.last : icons.middle\n path.unshift(icon)\n n = t.node(n.parent)\n }\n const prefix = path.join(\"\")\n const prefixWidth = stringWidth(prefix)\n const text = prev(item, { ...ctx, prefixWidth, width: ctx.width - prefixWidth }).replace(\n /\\s/g,\n \" \"\n )\n return `${s.gutter(prefix)}${text}`\n })\n\n return Object.assign(ret, { items })\n }\n)\n"],"mappings":";;;;;AAoBA,MAAM,QAAQ;CA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AAQ;GAChB,IAAI,MAAM,SAAS,QAAQ,EAAE,WAAW,MAAM,MAAM;GACpD,IAAI,OAAO;GACX,IAAI,MAAM,UAAU,OAAO,EAAE,OAAO,OAAO,MAAM;QAC5C,OAAO,EAAE,OAAO,MAAM,OAAO,MAAM;GACxC,KAAK,QAAQ,IAAI;GACjB,IAAI,EAAE,KAAK,EAAE,MAAM;EACrB;EACA,MAAM,SAAS,KAAK,KAAK,EAAE;EAC3B,MAAM,cAAc,YAAY,MAAM;EACtC,MAAM,OAAO,KAAK,MAAM;GAAE,GAAG;GAAK;GAAa,OAAO,IAAI,QAAQ;EAAY,CAAC,CAAC,CAAC,QAC/E,OACA,GACF;EACA,OAAO,GAAG,EAAE,OAAO,MAAM,IAAI;CAC/B,CAAC;CAED,OAAO,OAAO,OAAO,KAAK,EAAE,MAAM,CAAC;AACrC,CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { nt as Reactive } from "./queries-
|
|
2
|
-
import { i as Select, o as SelectState, t as Option } from "./select-
|
|
1
|
+
import { nt as Reactive } from "./queries-Cvalgu6P.mjs";
|
|
2
|
+
import { i as Select, o as SelectState, t as Option } from "./select-zGd5pbiB.mjs";
|
|
3
3
|
//#region src/widgets/tree.d.ts
|
|
4
4
|
type TreeItem<T extends Option = Option> = T & {
|
|
5
5
|
children?: TreeItem<T>[];
|
|
@@ -20,4 +20,4 @@ declare const tree: <T extends TreeItem>(props: TreeProps<T>) => Select<T> & {
|
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
22
|
export { tree as i, TreeNode as n, TreeProps as r, TreeItem as t };
|
|
23
|
-
//# sourceMappingURL=tree-
|
|
23
|
+
//# sourceMappingURL=tree-CArtDRec.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-
|
|
1
|
+
{"version":3,"file":"tree-CArtDRec.d.mts","names":[],"sources":["../src/widgets/tree.ts"],"mappings":";;;KAQY,SAAS,UAAU,SAAS,UAAU;EAChD,WAAW,SAAS;EACpB;;KAGU,UAAU,UAAU,WAAW,YAAY,KAAK,YAAY;EACtE,MAAM,SAAS;;EAEf;EACA,SAAS,MAAM,MAAM;;KAUX,SAAS,UAAU;EAC7B;EACA,SAAS;;cA0BE,OACV,UAAU,UAAQ,OAAS,UAAU,OAAK,OAAO;EAAO,OAAO,SAAS"}
|
|
@@ -23,6 +23,11 @@ type ShikiResult = {
|
|
|
23
23
|
error?: string;
|
|
24
24
|
aborted?: boolean;
|
|
25
25
|
};
|
|
26
|
+
type ShikiWorkerMessage = {
|
|
27
|
+
type: "ready";
|
|
28
|
+
} | (ShikiResult & {
|
|
29
|
+
type: "result";
|
|
30
|
+
});
|
|
26
31
|
type ShikiOpts = {
|
|
27
32
|
theme?: ShikiTheme;
|
|
28
33
|
signal?: AbortSignal;
|
|
@@ -208,5 +213,5 @@ type Theme = {
|
|
|
208
213
|
diffTitle: ThemeValue;
|
|
209
214
|
};
|
|
210
215
|
//#endregion
|
|
211
|
-
export { ShikiRequest as _, AnsiStyle as a,
|
|
212
|
-
//# sourceMappingURL=types-
|
|
216
|
+
export { ShikiRequest as _, AnsiStyle as a, ShikiWorkerMessage as b, Color as c, RGB as d, Style as f, ShikiOpts as g, ShikiLanguage as h, AnsiColorName as i, ColorLightness as l, ShikiJob as m, ThemeValue as n, AnyStyle as o, ThemeKey as p, AnsiColor as r, BrightAnsiColorName as s, Theme as t, HexColor as u, ShikiResult as v, ShikiWorkerRequest as x, ShikiTheme as y };
|
|
217
|
+
//# sourceMappingURL=types-C0EOLZDc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-C0EOLZDc.d.mts","names":[],"sources":["../src/shiki/types.ts","../src/style/types.ts","../src/themes/types.ts"],"mappings":";;KAEY,aAAa;KACb,gBAAgB;KAEhB;EACV;EACA;EACA;EACA,QAAQ;EACR,SAAS;;KAGC,qBAAqB,KAAK;EACpC;EACA,MAAM;EACN;;KAGU,WAAW,qBAC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If,YAAY;EACZ,YAAY;;EAEZ,cAAc;EAId,SAAS;EACT,aAAa;EACb,SAAS;EACT,UAAU;EACV,WAAW"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as Node } from "./queries-
|
|
1
|
+
import { p as Node } from "./queries-Cvalgu6P.mjs";
|
|
2
2
|
//#region src/widgets/widget.d.ts
|
|
3
3
|
type Props = Record<string, unknown>;
|
|
4
4
|
/**
|
|
@@ -46,4 +46,4 @@ type Widget<A extends unknown[] = never[], N extends Node = Node> = (...args: A)
|
|
|
46
46
|
declare function widget<T extends Widget>(fn: T): T;
|
|
47
47
|
//#endregion
|
|
48
48
|
export { Widget as n, widget as r, Props as t };
|
|
49
|
-
//# sourceMappingURL=widget-
|
|
49
|
+
//# sourceMappingURL=widget-DtJU2-BJ.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-
|
|
1
|
+
{"version":3,"file":"widget-DtJU2-BJ.d.mts","names":[],"sources":["../src/widgets/widget.ts"],"mappings":";;KAIY,QAAQ;;;;;;;;;;;KAYR,OAAO,+BAA+B,UAAU,OAAO,YAAY,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkC3E,OAAO,UAAU,QAAQ,IAAI,IAAI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AutocompleteState, i as AutocompleteOptions, n as Autocomplete, o as CompletionSource, r as AutocompleteEvents, s as autocomplete, t as AcceptFn } from "../autocomplete-
|
|
1
|
+
import { a as AutocompleteState, i as AutocompleteOptions, n as Autocomplete, o as CompletionSource, r as AutocompleteEvents, s as autocomplete, t as AcceptFn } from "../autocomplete-CxzetPOo.mjs";
|
|
2
2
|
export { AcceptFn, Autocomplete, AutocompleteEvents, AutocompleteOptions, AutocompleteState, CompletionSource, autocomplete };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S as unwrap, f as effect, h as memo, y as signal } from "../reactive-f7NpAi69.mjs";
|
|
2
2
|
import { t as Node } from "../node-BZ7f6HzU.mjs";
|
|
3
|
-
import { t as picker } from "../picker-
|
|
4
|
-
import { t as Input } from "../input-
|
|
3
|
+
import { t as picker } from "../picker-BqHINl_a.mjs";
|
|
4
|
+
import { t as Input } from "../input-D7fQEUdt.mjs";
|
|
5
5
|
//#region src/widgets/autocomplete.ts
|
|
6
6
|
/**
|
|
7
7
|
* Autocomplete popup bound to an `Input`. Watches the input's value and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.mjs","names":["#sources","#opts","#match","#detect","#complete","#accept","#input","#replace"],"sources":["../../src/widgets/autocomplete.ts"],"sourcesContent":["import type { RenderCtx } from \"../core/ctx.ts\"\nimport type { BaseEvents } from \"../core/node.ts\"\nimport type { Accessor, Reactive, Ref } from \"../core/reactive.ts\"\nimport type { StyleState } from \"../core/state.ts\"\nimport type { SearchItems, SearchOptions } from \"../search/search.ts\"\nimport type { Option, OptionRender, Select } from \"./select.ts\"\n\nimport { Node } from \"../core/node.ts\"\nimport { effect, memo, signal, unwrap } from \"../core/reactive.ts\"\nimport { Input } from \"./input.ts\"\nimport { picker } from \"./picker.ts\"\n\n/** Called when the user picks `item` from this source. Return a string\n * to insert in place of the trigger + query range, or `undefined`\n * when the source handled the selection itself (dispatched an action,\n * opened a modal, …) and the trigger range should just be removed. */\nexport type AcceptFn<T> = (item: T, query: string) => string | undefined\n\n/** Single completion source. `triggers` are regexes run against the text\n * *before the cursor*; the first regex whose match ends in the trailing\n * word wins. The slice between match-end and the cursor becomes the\n * `query` passed to `complete`.\n *\n * `complete` receives a `match` helper bound to `query` — call it on\n * whatever string the source considers the matching field (action id,\n * file basename, contact email, etc.) and either filter or rank.\n *\n * `accept` controls what happens on selection. Default: insert\n * `item.value + \" \"`. Return `undefined` to have the source do its own\n * side effect (dispatch an action, open a picker, …) and just clear\n * the trigger range in the input.\n *\n * `render` is forwarded to the internal `Menu` so the source can carry\n * its own row presentation — handy when `T` isn't a plain `MenuItem`. */\nexport interface CompletionSource<T extends Option = Option> {\n triggers: readonly RegExp[]\n complete: Reactive<SearchItems<T>>\n accept?: AcceptFn<T>\n render?: OptionRender<T>\n}\n\n// oxlint-disable-next-line no-empty-interface\nexport interface AutocompleteState extends StyleState {}\n\nexport interface AutocompleteOptions extends SearchOptions {\n /** The `Input` to watch. Pass the node directly, or a `Ref<Input>`\n * populated by `node.ref(ref)` elsewhere in the tree — the latter\n * enables fully inline composition where the input doesn't need a\n * local binding. The ref is dereferenced on mount, so wiring is\n * type-safe and ordering-flexible (autocomplete can be constructed\n * before the Input is). */\n input: Input | Ref<Input>\n // Per-source item types are erased at this level — each source\n // declares its own `T` which is preserved within its own `complete`\n // / `accept` / `render` callbacks. The `complete` event payload is\n // consequently typed as `unknown`; callers discriminate by source\n // name and cast.\n sources: Record<string, CompletionSource<any>>\n /** Cap on rows the popup shows at once. Default: 8. */\n maxHeight?: Reactive<number>\n enabled?: Reactive<boolean>\n reverse?: boolean\n}\n\nexport interface AutocompleteEvents extends BaseEvents {\n /** Fired after an item is inserted into the input. Payload item type\n * is `unknown` because sources may have different `T`; discriminate\n * by source name and cast. */\n complete: { source: string; item: Option }\n}\n\ninterface Match {\n source: string\n /** Absolute start index of the trigger in the input value. */\n start: number\n /** Absolute end index of the trigger in the input value. */\n end: number\n /** The query (text between trigger-end and cursor). */\n query: string\n}\n\n// const AutocompleteBase = Node as unknown as abstract new <T extends MenuItem>(\n// ...args: ConstructorParameters<typeof Menu<T>>\n// ) => Node<MenuState<T>> & Emitter<MenuEvents<T> & EventMap>\n\n/**\n * Autocomplete popup bound to an `Input`. Watches the input's value and\n * cursor; when one of the configured sources' trigger regexes matches\n * the text before the cursor, the source's `complete(query)` is called\n * and the resulting items are shown in a `Menu` child.\n *\n * Selecting an item replaces the matched trigger-prefix + query with\n * the item's `value` and fires `\"complete\"` for apps that want to react\n * beyond plain text insertion.\n *\n * ```ts\n * autocomplete({\n * input: \"chat-input\",\n * sources: {\n * slash: {\n * triggers: [/^\\s*\\//],\n * complete: (q) => slashCommands.filter((c) => c.startsWith(q)),\n * },\n * },\n * }).on(\"complete\", (src, item) => { ... })\n * ```\n *\n * Positioning is layout-based — place the `Autocomplete` in your tree\n * (typically directly above the input inside the UI footer) and it\n * takes as many rows as it has items (up to `maxHeight`). When no\n * source matches, `visible` flips to `false` and the widget takes\n * zero rows, so the footer naturally collapses.\n */\nexport class Autocomplete extends Node<AutocompleteState, AutocompleteEvents> {\n static readonly type = \"autocomplete\"\n override readonly type = Autocomplete.type\n\n readonly select: Select\n #opts: AutocompleteOptions\n readonly #sources: Record<string, CompletionSource<any>>\n #match: Accessor<Match | undefined>\n\n constructor(opts: AutocompleteOptions) {\n super({ visible: false })\n this.#opts = opts\n this.#sources = opts.sources\n\n const [cancelled, cancel] = signal(false)\n\n this.#match = memo(() => {\n const ret = this.#detect()\n if (ret) cancel(false)\n return ret\n })\n\n const source = memo(() => {\n const m = this.#match()\n return m ? this.#sources[m.source] : undefined\n })\n\n const visible = memo(\n () => this.enabled && this.#match() !== undefined && !cancelled() && this.select.count > 0\n )\n\n // Use an effect instead of setting a signal, since Node.show/hide overwrites the signal\n effect(() => {\n if (visible()) this.show()\n else this.hide()\n })\n\n this.select = picker({\n ...opts,\n items: memo(() => unwrap(source()?.complete) ?? []),\n maxHeight: opts.maxHeight ?? 8,\n pattern: memo(() => this.#match()?.query ?? \"\"),\n render: memo(() => source()?.render),\n visible,\n })\n\n this.add(this.select)\n this.select.bind(this.#opts.input)\n\n // Bridge menu events to input rewrite. Tab completes by inserting the\n // item's value; Enter selects, giving the source a chance to execute.\n this.select.on(\"complete\", ({ item }) => this.#complete(item))\n this.select.on(\"accept\", ({ item }) => this.#accept(item))\n this.select.on(\"close\", () => cancel(true))\n }\n\n get #input(): Input | undefined {\n if (this.#opts.input instanceof Input) return this.#opts.input\n return this.#opts.input()\n }\n\n get enabled(): boolean {\n return unwrap(this.#opts.enabled) ?? true\n }\n\n #detect(): Match | undefined {\n if (!this.#input) return undefined\n const value = this.#input.state.value ?? \"\"\n const cursor = this.#input.state.cursor ?? 0\n const before = value.slice(0, cursor)\n for (const [name, src] of Object.entries(this.#sources)) {\n for (const rx of src.triggers) {\n // `exec` with /g wouldn't help — we want the *last* match whose\n // tail reaches the cursor, since the relevant trigger is the one\n // just typed. Scan with a sticky-ish loop and keep the latest hit.\n const re = new RegExp(rx.source, rx.flags.replace(\"g\", \"\"))\n let searchFrom = 0\n let best: { start: number; end: number } | undefined\n while (searchFrom <= before.length) {\n const m = re.exec(before.slice(searchFrom))\n if (m === null) break\n const start = searchFrom + m.index\n const end = start + m[0].length\n best = { end, start }\n searchFrom = end\n }\n if (best === undefined) continue\n // The query is text from trigger-end to cursor. Reject if there's\n // whitespace between them — that means the trigger word is over.\n const query = before.slice(best.end)\n if (/\\s/.test(query)) continue\n return { end: best.end, query, source: name, start: best.start }\n }\n }\n return undefined\n }\n\n #complete(item: Option): void {\n const match = this.#match()\n if (match === undefined) return\n // Completion keeps the trigger (`/`, `@`, ...) and only replaces the query.\n this.#replace(item, defaultAccept(item), match.end)\n }\n\n #accept(item: Option): void {\n const match = this.#match()\n if (match === undefined) return\n const source = this.#sources[match.source]\n // Source-provided accept wins on Enter; default is `item.value + \" \"` when\n // the item looks MenuItem-shaped, otherwise a no-op clear.\n this.#replace(\n item,\n source.accept ? source.accept(item, match.query) : defaultAccept(item),\n match.start\n )\n }\n\n #replace(item: Option, accepted: string | undefined, start: number): void {\n const match = this.#match()\n if (match === undefined || !this.#input) return\n const value = this.#input.state.value ?? \"\"\n const cursor = this.#input.state.cursor ?? 0\n const tail = value.slice(cursor)\n accepted ??= \"\"\n const newValue = value.slice(0, start) + accepted + tail\n\n if (newValue.trim() === \"\") {\n // In case the source fully consumed the input, add the fully completed value\n // to the input history. When not fully consumed, submit will add the completed\n // value to the history, so we don't need to do it here.\n const completed = value.slice(0, match.end) + defaultAccept(item) + tail\n if (completed.trim() !== \"\") this.#input.historyAdd(completed)\n }\n\n this.#input.state.set({\n cursor: start + accepted.length,\n value: newValue,\n })\n void this.emit(\"complete\", { item, source: match.source })\n this.hide()\n }\n\n protected _render(ctx: RenderCtx): string[] | Promise<string[]> {\n // Menu does all the layout. We're just a wrapper node so callers\n // can place the popup in their tree and so the `visible` toggle\n // flows through one handle.\n return this.select.render(ctx)\n }\n}\n\n/** Default `accept` fallback used when a source doesn't provide one.\n * Assumes the item is `MenuItem`-shaped and inserts `value + \" \"` —\n * matches the old `trailingSpace: true` behaviour. Returns `undefined`\n * (clear-only) when the item has no `text`. */\nfunction defaultAccept(item: Option): string {\n return `${item.text} `\n}\n\n/**\n * Factory for `Autocomplete`. See the class doc for the full API.\n */\nexport function autocomplete(opts: AutocompleteOptions): Autocomplete {\n return new Autocomplete(opts)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHA,IAAa,eAAb,MAAa,qBAAqB,KAA4C;CAC5E,OAAgB,OAAO;CACvB,OAAyB,aAAa;CAEtC;CACA;CACA;CACA;CAEA,YAAY,MAA2B;EACrC,MAAM,EAAE,SAAS,MAAM,CAAC;EACxB,KAAKC,QAAQ;EACb,KAAKD,WAAW,KAAK;EAErB,MAAM,CAAC,WAAW,UAAU,OAAO,KAAK;EAExC,KAAKE,SAAS,WAAW;GACvB,MAAM,MAAM,KAAKC,QAAQ;GACzB,IAAI,KAAK,OAAO,KAAK;GACrB,OAAO;EACT,CAAC;EAED,MAAM,SAAS,WAAW;GACxB,MAAM,IAAI,KAAKD,OAAO;GACtB,OAAO,IAAI,KAAKF,SAAS,EAAE,UAAU,KAAA;EACvC,CAAC;EAED,MAAM,UAAU,WACR,KAAK,WAAW,KAAKE,OAAO,MAAM,KAAA,KAAa,CAAC,UAAU,KAAK,KAAK,OAAO,QAAQ,CAC3F;EAGA,aAAa;GACX,IAAI,QAAQ,GAAG,KAAK,KAAK;QACpB,KAAK,KAAK;EACjB,CAAC;EAED,KAAK,SAAS,OAAO;GACnB,GAAG;GACH,OAAO,WA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Q,MAAM;EAAO,CAAC;EACzD,KAAK,KAAK;CACZ;CAEA,QAAkB,KAA8C;EAI9D,OAAO,KAAK,OAAO,OAAO,GAAG;CAC/B;AACF;;;;;AAMA,SAAS,cAAc,MAAsB;CAC3C,OAAO,GAAG,KAAK,KAAK;AACtB;;;;AAKA,SAAgB,aAAa,MAAyC;CACpE,OAAO,IAAI,aAAa,IAAI;AAC9B"}
|
|
1
|
+
{"version":3,"file":"autocomplete.mjs","names":[],"sources":["../../src/widgets/autocomplete.ts"],"sourcesContent":["import type { RenderCtx } from \"../core/ctx.ts\"\nimport type { BaseEvents } from \"../core/node.ts\"\nimport type { Accessor, Reactive, Ref } from \"../core/reactive.ts\"\nimport type { StyleState } from \"../core/state.ts\"\nimport type { SearchItems, SearchOptions } from \"../search/search.ts\"\nimport type { Option, OptionRender, Select } from \"./select.ts\"\n\nimport { Node } from \"../core/node.ts\"\nimport { effect, memo, signal, unwrap } from \"../core/reactive.ts\"\nimport { Input } from \"./input.ts\"\nimport { picker } from \"./picker.ts\"\n\n/** Called when the user picks `item` from this source. Return a string\n * to insert in place of the trigger + query range, or `undefined`\n * when the source handled the selection itself (dispatched an action,\n * opened a modal, …) and the trigger range should just be removed. */\nexport type AcceptFn<T> = (item: T, query: string) => string | undefined\n\n/** Single completion source. `triggers` are regexes run against the text\n * *before the cursor*; the first regex whose match ends in the trailing\n * word wins. The slice between match-end and the cursor becomes the\n * `query` passed to `complete`.\n *\n * `complete` receives a `match` helper bound to `query` — call it on\n * whatever string the source considers the matching field (action id,\n * file basename, contact email, etc.) and either filter or rank.\n *\n * `accept` controls what happens on selection. Default: insert\n * `item.value + \" \"`. Return `undefined` to have the source do its own\n * side effect (dispatch an action, open a picker, …) and just clear\n * the trigger range in the input.\n *\n * `render` is forwarded to the internal `Menu` so the source can carry\n * its own row presentation — handy when `T` isn't a plain `MenuItem`. */\nexport interface CompletionSource<T extends Option = Option> {\n triggers: readonly RegExp[]\n complete: Reactive<SearchItems<T>>\n accept?: AcceptFn<T>\n render?: OptionRender<T>\n}\n\n// oxlint-disable-next-line no-empty-interface\nexport interface AutocompleteState extends StyleState {}\n\nexport interface AutocompleteOptions extends SearchOptions {\n /** The `Input` to watch. Pass the node directly, or a `Ref<Input>`\n * populated by `node.ref(ref)` elsewhere in the tree — the latter\n * enables fully inline composition where the input doesn't need a\n * local binding. The ref is dereferenced on mount, so wiring is\n * type-safe and ordering-flexible (autocomplete can be constructed\n * before the Input is). */\n input: Input | Ref<Input>\n // Per-source item types are erased at this level — each source\n // declares its own `T` which is preserved within its own `complete`\n // / `accept` / `render` callbacks. The `complete` event payload is\n // consequently typed as `unknown`; callers discriminate by source\n // name and cast.\n sources: Record<string, CompletionSource<any>>\n /** Cap on rows the popup shows at once. Default: 8. */\n maxHeight?: Reactive<number>\n enabled?: Reactive<boolean>\n reverse?: boolean\n}\n\nexport interface AutocompleteEvents extends BaseEvents {\n /** Fired after an item is inserted into the input. Payload item type\n * is `unknown` because sources may have different `T`; discriminate\n * by source name and cast. */\n complete: { source: string; item: Option }\n}\n\ninterface Match {\n source: string\n /** Absolute start index of the trigger in the input value. */\n start: number\n /** Absolute end index of the trigger in the input value. */\n end: number\n /** The query (text between trigger-end and cursor). */\n query: string\n}\n\n// const AutocompleteBase = Node as unknown as abstract new <T extends MenuItem>(\n// ...args: ConstructorParameters<typeof Menu<T>>\n// ) => Node<MenuState<T>> & Emitter<MenuEvents<T> & EventMap>\n\n/**\n * Autocomplete popup bound to an `Input`. Watches the input's value and\n * cursor; when one of the configured sources' trigger regexes matches\n * the text before the cursor, the source's `complete(query)` is called\n * and the resulting items are shown in a `Menu` child.\n *\n * Selecting an item replaces the matched trigger-prefix + query with\n * the item's `value` and fires `\"complete\"` for apps that want to react\n * beyond plain text insertion.\n *\n * ```ts\n * autocomplete({\n * input: \"chat-input\",\n * sources: {\n * slash: {\n * triggers: [/^\\s*\\//],\n * complete: (q) => slashCommands.filter((c) => c.startsWith(q)),\n * },\n * },\n * }).on(\"complete\", (src, item) => { ... })\n * ```\n *\n * Positioning is layout-based — place the `Autocomplete` in your tree\n * (typically directly above the input inside the UI footer) and it\n * takes as many rows as it has items (up to `maxHeight`). When no\n * source matches, `visible` flips to `false` and the widget takes\n * zero rows, so the footer naturally collapses.\n */\nexport class Autocomplete extends Node<AutocompleteState, AutocompleteEvents> {\n static readonly type = \"autocomplete\"\n override readonly type = Autocomplete.type\n\n readonly select: Select\n #opts: AutocompleteOptions\n readonly #sources: Record<string, CompletionSource<any>>\n #match: Accessor<Match | undefined>\n\n constructor(opts: AutocompleteOptions) {\n super({ visible: false })\n this.#opts = opts\n this.#sources = opts.sources\n\n const [cancelled, cancel] = signal(false)\n\n this.#match = memo(() => {\n const ret = this.#detect()\n if (ret) cancel(false)\n return ret\n })\n\n const source = memo(() => {\n const m = this.#match()\n return m ? this.#sources[m.source] : undefined\n })\n\n const visible = memo(\n () => this.enabled && this.#match() !== undefined && !cancelled() && this.select.count > 0\n )\n\n // Use an effect instead of setting a signal, since Node.show/hide overwrites the signal\n effect(() => {\n if (visible()) this.show()\n else this.hide()\n })\n\n this.select = picker({\n ...opts,\n items: memo(() => unwrap(source()?.complete) ?? []),\n maxHeight: opts.maxHeight ?? 8,\n pattern: memo(() => this.#match()?.query ?? \"\"),\n render: memo(() => source()?.render),\n visible,\n })\n\n this.add(this.select)\n this.select.bind(this.#opts.input)\n\n // Bridge menu events to input rewrite. Tab completes by inserting the\n // item's value; Enter selects, giving the source a chance to execute.\n this.select.on(\"complete\", ({ item }) => this.#complete(item))\n this.select.on(\"accept\", ({ item }) => this.#accept(item))\n this.select.on(\"close\", () => cancel(true))\n }\n\n get #input(): Input | undefined {\n if (this.#opts.input instanceof Input) return this.#opts.input\n return this.#opts.input()\n }\n\n get enabled(): boolean {\n return unwrap(this.#opts.enabled) ?? true\n }\n\n #detect(): Match | undefined {\n if (!this.#input) return undefined\n const value = this.#input.state.value ?? \"\"\n const cursor = this.#input.state.cursor ?? 0\n const before = value.slice(0, cursor)\n for (const [name, src] of Object.entries(this.#sources)) {\n for (const rx of src.triggers) {\n // `exec` with /g wouldn't help — we want the *last* match whose\n // tail reaches the cursor, since the relevant trigger is the one\n // just typed. Scan with a sticky-ish loop and keep the latest hit.\n const re = new RegExp(rx.source, rx.flags.replace(\"g\", \"\"))\n let searchFrom = 0\n let best: { start: number; end: number } | undefined\n while (searchFrom <= before.length) {\n const m = re.exec(before.slice(searchFrom))\n if (m === null) break\n const start = searchFrom + m.index\n const end = start + m[0].length\n best = { end, start }\n searchFrom = end\n }\n if (best === undefined) continue\n // The query is text from trigger-end to cursor. Reject if there's\n // whitespace between them — that means the trigger word is over.\n const query = before.slice(best.end)\n if (/\\s/.test(query)) continue\n return { end: best.end, query, source: name, start: best.start }\n }\n }\n return undefined\n }\n\n #complete(item: Option): void {\n const match = this.#match()\n if (match === undefined) return\n // Completion keeps the trigger (`/`, `@`, ...) and only replaces the query.\n this.#replace(item, defaultAccept(item), match.end)\n }\n\n #accept(item: Option): void {\n const match = this.#match()\n if (match === undefined) return\n const source = this.#sources[match.source]\n // Source-provided accept wins on Enter; default is `item.value + \" \"` when\n // the item looks MenuItem-shaped, otherwise a no-op clear.\n this.#replace(\n item,\n source.accept ? source.accept(item, match.query) : defaultAccept(item),\n match.start\n )\n }\n\n #replace(item: Option, accepted: string | undefined, start: number): void {\n const match = this.#match()\n if (match === undefined || !this.#input) return\n const value = this.#input.state.value ?? \"\"\n const cursor = this.#input.state.cursor ?? 0\n const tail = value.slice(cursor)\n accepted ??= \"\"\n const newValue = value.slice(0, start) + accepted + tail\n\n if (newValue.trim() === \"\") {\n // In case the source fully consumed the input, add the fully completed value\n // to the input history. When not fully consumed, submit will add the completed\n // value to the history, so we don't need to do it here.\n const completed = value.slice(0, match.end) + defaultAccept(item) + tail\n if (completed.trim() !== \"\") this.#input.historyAdd(completed)\n }\n\n this.#input.state.set({\n cursor: start + accepted.length,\n value: newValue,\n })\n void this.emit(\"complete\", { item, source: match.source })\n this.hide()\n }\n\n protected _render(ctx: RenderCtx): string[] | Promise<string[]> {\n // Menu does all the layout. We're just a wrapper node so callers\n // can place the popup in their tree and so the `visible` toggle\n // flows through one handle.\n return this.select.render(ctx)\n }\n}\n\n/** Default `accept` fallback used when a source doesn't provide one.\n * Assumes the item is `MenuItem`-shaped and inserts `value + \" \"` —\n * matches the old `trailingSpace: true` behaviour. Returns `undefined`\n * (clear-only) when the item has no `text`. */\nfunction defaultAccept(item: Option): string {\n return `${item.text} `\n}\n\n/**\n * Factory for `Autocomplete`. See the class doc for the full API.\n */\nexport function autocomplete(opts: AutocompleteOptions): Autocomplete {\n return new Autocomplete(opts)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHA,IAAa,eAAb,MAAa,qBAAqB,KAA4C;CAC5E,OAAgB,OAAO;CACvB,OAAyB,aAAa;CAEtC;CACA;CACA;CACA;CAEA,YAAY,MAA2B;EACrC,MAAM,EAAE,SAAS,MAAM,CAAC;EACxB,KAAK,QAAQ;EACb,KAAK,WAAW,KAAK;EAErB,MAAM,CAAC,WAAW,UAAU,OAAO,KAAK;EAExC,KAAK,SAAS,WAAW;GACvB,MAAM,MAAM,KAAK,QAAQ;GACzB,IAAI,KAAK,OAAO,KAAK;GACrB,OAAO;EACT,CAAC;EAED,MAAM,SAAS,WAAW;GACxB,MAAM,IAAI,KAAK,OAAO;GACtB,OAAO,IAAI,KAAK,SAAS,EAAE,UAAU,KAAA;EACvC,CAAC;EAED,MAAM,UAAU,WACR,KAAK,WAAW,KAAK,OAAO,MAAM,KAAA,KAAa,CAAC,UAAU,KAAK,KAAK,OAAO,QAAQ,CAC3F;EAGA,aAAa;GACX,IAAI,QAAQ,GAAG,KAAK,KAAK;QACpB,KAAK,KAAK;EACjB,CAAC;EAED,KAAK,SAAS,OAAO;GACnB,GAAG;GACH,OAAO,WAAW,OAAO,OAAO,CAAC,EAAE,QAAQ,KAAK,CAAC,CAAC;GAClD,WAAW,KAAK,aAAa;GAC7B,SAAS,WAAW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A,SAAS,cAAc,MAAsB;CAC3C,OAAO,GAAG,KAAK,KAAK;AACtB;;;;AAKA,SAAgB,aAAa,MAAyC;CACpE,OAAO,IAAI,aAAa,IAAI;AAC9B"}
|
package/dist/widgets/box.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { B as Padding, R as Box, V as box, z as BoxStyle } from "../queries-
|
|
1
|
+
import { B as Padding, R as Box, V as box, z as BoxStyle } from "../queries-Cvalgu6P.mjs";
|
|
2
2
|
export { Box, BoxStyle, Padding, box };
|
package/dist/widgets/box.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as box, t as Box } from "../box-
|
|
1
|
+
import { n as box, t as Box } from "../box-DLEcEvDH.mjs";
|
|
2
2
|
export { Box, box };
|
package/dist/widgets/code.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as Box, X as State, nt as Reactive } from "../queries-
|
|
2
|
-
import { o as AnyStyle } from "../types-
|
|
1
|
+
import { R as Box, X as State, nt as Reactive } from "../queries-Cvalgu6P.mjs";
|
|
2
|
+
import { o as AnyStyle } from "../types-C0EOLZDc.mjs";
|
|
3
3
|
//#region src/widgets/code.d.ts
|
|
4
|
-
interface CodeState {
|
|
4
|
+
export interface CodeState {
|
|
5
5
|
/** Source to render. Plain string or reactive accessor — pass a
|
|
6
6
|
* signal for streaming bash output / tool results. */
|
|
7
7
|
code: Reactive<string>;
|
|
@@ -42,7 +42,6 @@ interface CodeState {
|
|
|
42
42
|
* painting, so rows committed to scrollback always reflect the
|
|
43
43
|
* resolved highlight rather than the initial plain source.
|
|
44
44
|
*/
|
|
45
|
-
declare const code: (props: State<CodeState>) => Box<{}>;
|
|
45
|
+
export declare const code: (props: State<CodeState>) => Box<{}>;
|
|
46
46
|
//#endregion
|
|
47
|
-
export { CodeState, code };
|
|
48
47
|
//# sourceMappingURL=code.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.mts","names":[],"sources":["../../src/widgets/code.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"code.d.mts","names":[],"sources":["../../src/widgets/code.ts"],"mappings":";;;iBAciB;;;EAGf,MAAM;;;EAGN,OAAO;;;;EAIP;;;EAGA,QAAQ;;EAER;EACA,QAAQ;EACR;EACA,eAAe;EACf,SAAS;EACT,QAAQ;EACR,QAAQ,cAAc;;;;;;;;;;;;;;;;;;;;qBAqBX,OAAI,OAAkB,MAAM,eAAN"}
|
package/dist/widgets/code.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { S as unwrap, h as memo, r as createAsync, w as useContext } from "../reactive-f7NpAi69.mjs";
|
|
2
|
-
import { n as box } from "../box-
|
|
3
|
-
import { a as formatLines } from "../text-
|
|
4
|
-
import { n as text } from "../text-
|
|
5
|
-
import { t as RenderContext } from "../render-
|
|
6
|
-
import { t as codeToAnsi } from "../shiki-
|
|
2
|
+
import { n as box } from "../box-DLEcEvDH.mjs";
|
|
3
|
+
import { a as formatLines } from "../text-CRZD9KTN.mjs";
|
|
4
|
+
import { n as text } from "../text-BLz1tRoC.mjs";
|
|
5
|
+
import { t as RenderContext } from "../render-DxIHVH9Y.mjs";
|
|
6
|
+
import { t as codeToAnsi } from "../shiki-CcxiFWEF.mjs";
|
|
7
7
|
import { t as widget } from "../widget-BkMwhY2p.mjs";
|
|
8
8
|
import { t as show } from "../show-DR2x1YFc.mjs";
|
|
9
9
|
import { extname } from "pathe";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions-
|
|
1
|
+
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions-DFboj3g5.mjs";
|
|
2
2
|
export { ActionCompletionItem, ActionsSourceOptions, actionsSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as filesSource, t as FilesSourceOptions } from "../../files-
|
|
1
|
+
import { n as filesSource, t as FilesSourceOptions } from "../../files-BUsa-RVl.mjs";
|
|
2
2
|
export { FilesSourceOptions, filesSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-
|
|
1
|
+
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-D89A3F9U.mjs";
|
|
2
2
|
export { GithubFetcher, GithubItem, GithubSourceOptions, GithubState, githubSource };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions-
|
|
2
|
-
import { n as filesSource, t as FilesSourceOptions } from "../../files-
|
|
3
|
-
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-
|
|
1
|
+
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions-DFboj3g5.mjs";
|
|
2
|
+
import { n as filesSource, t as FilesSourceOptions } from "../../files-BUsa-RVl.mjs";
|
|
3
|
+
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-D89A3F9U.mjs";
|
|
4
4
|
export { ActionCompletionItem, ActionsSourceOptions, FilesSourceOptions, GithubFetcher, GithubItem, GithubSourceOptions, GithubState, actionsSource, filesSource, githubSource };
|
package/dist/widgets/diff.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { J as Layout, P as RenderCtx, X as State, nt as Reactive, p as Node } from "../queries-
|
|
2
|
-
import { t as WrapMode } from "../text-
|
|
1
|
+
import { J as Layout, P as RenderCtx, X as State, nt as Reactive, p as Node } from "../queries-Cvalgu6P.mjs";
|
|
2
|
+
import { t as WrapMode } from "../text-BefiXAFW.mjs";
|
|
3
3
|
//#region src/widgets/diff.d.ts
|
|
4
|
-
interface DiffState {
|
|
4
|
+
export interface DiffState {
|
|
5
5
|
/** Pre-state file content. Plain string or reactive accessor —
|
|
6
6
|
* pass a signal to live-update the diff as either side changes. */
|
|
7
7
|
original: Reactive<string>;
|
|
@@ -30,7 +30,7 @@ interface DiffState {
|
|
|
30
30
|
* would in the actual file — multi-line strings, block comments, etc.
|
|
31
31
|
* don't get truncated by the hunk window.
|
|
32
32
|
*/
|
|
33
|
-
declare class Diff extends Node<DiffState> {
|
|
33
|
+
export declare class Diff extends Node<DiffState> {
|
|
34
34
|
#private;
|
|
35
35
|
constructor(state: DiffState);
|
|
36
36
|
get input(): {
|
|
@@ -51,7 +51,6 @@ declare class Diff extends Node<DiffState> {
|
|
|
51
51
|
* })
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
declare function diff(state: State<DiffState>): Diff;
|
|
54
|
+
export declare function diff(state: State<DiffState>): Diff;
|
|
55
55
|
//#endregion
|
|
56
|
-
export { Diff, DiffState, diff };
|
|
57
56
|
//# sourceMappingURL=diff.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.mts","names":[],"sources":["../../src/widgets/diff.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"diff.d.mts","names":[],"sources":["../../src/widgets/diff.ts"],"mappings":";;;iBAeiB;;;EAGf,UAAU;;;EAGV,UAAU;;;;EAIV,OAAO;;;EAGP;;EAEA;EACA,OAAO;;;;;;;;;;;;;qBAuBI,aAAa,KAAK;;EAI7B,YAAY,OAAO;MA+Bf;IAAW;IAAkB;;YAOjB,QAAQ,KAAK,YAAY;EAmBhC,UAAU;;;;;;;;;;;;;wBA4BL,KAAK,OAAO,MAAM,aAAa"}
|
package/dist/widgets/diff.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { S as unwrap, h as memo, r as createAsync, w as useContext } from "../reactive-f7NpAi69.mjs";
|
|
2
2
|
import { t as Node } from "../node-BZ7f6HzU.mjs";
|
|
3
|
-
import { r as countLines, t as calcLayout } from "../text-
|
|
4
|
-
import { t as RenderContext } from "../render-
|
|
5
|
-
import { t as codeToAnsi } from "../shiki-
|
|
3
|
+
import { r as countLines, t as calcLayout } from "../text-CRZD9KTN.mjs";
|
|
4
|
+
import { t as RenderContext } from "../render-DxIHVH9Y.mjs";
|
|
5
|
+
import { t as codeToAnsi } from "../shiki-CcxiFWEF.mjs";
|
|
6
6
|
import { splitAnsi, stringWidth, wrapAnsi } from "@zaly/shared/ansi";
|
|
7
7
|
import { basename, extname } from "pathe";
|
|
8
8
|
//#region src/widgets/diff.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.mjs","names":["#lang","#highlighted","#norm"],"sources":["../../src/widgets/diff.ts"],"sourcesContent":["import type { RenderCtx } from \"../core/ctx.ts\"\nimport type { Accessor, Reactive } from \"../core/reactive.ts\"\nimport type { Layout, State } from \"../core/state.ts\"\nimport type { WrapMode } from \"../layout/text.ts\"\n\nimport { splitAnsi, stringWidth, wrapAnsi } from \"@zaly/shared/ansi\"\nimport { basename, extname } from \"pathe\"\n// oxlint-disable no-nested-ternary\n// oxlint-disable typescript/no-unnecessary-condition\nimport { Node } from \"../core/node.ts\"\nimport { createAsync, memo, unwrap, useContext } from \"../core/reactive.ts\"\nimport { RenderContext } from \"../core/render.ts\"\nimport { calcLayout, countLines } from \"../layout/text.ts\"\nimport { codeToAnsi } from \"../shiki/shiki.ts\"\n\nexport interface DiffState {\n /** Pre-state file content. Plain string or reactive accessor —\n * pass a signal to live-update the diff as either side changes. */\n original: Reactive<string>\n /** Post-state file content. The widget runs `diffLines` between\n * `original` and `modified` and renders the resulting hunks. */\n modified: Reactive<string>\n /** Optional file path. Drives the default `lang` (extension or\n * basename — shiki recognises both `.ts` and `Dockerfile`-style\n * names) and `title` when those aren't set explicitly. */\n path?: Reactive<string>\n /** Language for syntax highlighting (any shiki-bundled name or\n * alias). Defaults from `path` when set. */\n lang?: string\n /** Lines of surrounding context per hunk. Default: 3. */\n context?: number\n wrap?: WrapMode\n}\n\ntype DiffOpts = {\n original: string[]\n originalHi: string[]\n modified: string[]\n modifiedHi: string[]\n context: number\n ctx: RenderCtx\n}\n\n/**\n * Show a unified diff between two file contents with syntax-highlighted\n * rows. Added rows carry a green backdrop and `+` prefix; removed rows\n * carry a red backdrop and `-` prefix; context rows show both line\n * numbers with a neutral gutter.\n *\n * Both sides are highlighted as complete files (via shiki) before the\n * diff is assembled, so context around an edit tokenizes the way it\n * would in the actual file — multi-line strings, block comments, etc.\n * don't get truncated by the hunk window.\n */\nexport class Diff extends Node<DiffState> {\n #lang: Accessor<string | undefined>\n #highlighted: Accessor<{ original: string; modified: string }>\n\n constructor(state: DiffState) {\n super({ wrap: \"word\", ...state })\n\n this.#lang = memo(() => {\n const path = unwrap(this.state.path)\n return this.state.lang ?? (path !== undefined ? langFromPath(path) : undefined)\n })\n\n const context = useContext(RenderContext)\n this.#highlighted = createAsync(\n async () => {\n const lang = this.#lang()\n const input = this.input\n if (!lang) return input\n const theme = context?.style().theme.shiki\n const [original, modified] = await Promise.all([\n codeToAnsi(input.original, lang, { theme }),\n codeToAnsi(input.modified, lang, { theme }),\n ])\n return { modified, original }\n },\n {\n initialValue: this.input,\n }\n )\n }\n\n #norm(s: string): string {\n return s.replaceAll(\"\\r\\n\", \"\\n\").replaceAll(\"\\r\", \"\")\n }\n\n get input(): { original: string; modified: string } {\n return {\n modified: this.#norm(unwrap(this.state.modified)),\n original: this.#norm(unwrap(this.state.original)),\n }\n }\n\n protected async _render(ctx: RenderCtx): Promise<string[]> {\n const highlighted = this.#highlighted()\n const input = this.input\n const layout = this.layout()\n const width = Math.min(ctx.width, layout.width)\n\n const opts: DiffOpts = {\n context: this.state.context ?? 3,\n ctx: { ...ctx, width },\n modified: input.modified.split(\"\\n\"),\n modifiedHi: highlighted.modified.split(\"\\n\"),\n original: input.original.split(\"\\n\"),\n originalHi: highlighted.original.split(\"\\n\"),\n }\n\n this.state.wrap ??= \"word\"\n return await buildDiffRows(opts)\n }\n\n override layout(): Layout {\n const input = this.input\n const original = calcLayout(input.original, { wrap: this.state.wrap })\n const modified = calcLayout(input.modified, { wrap: this.state.wrap })\n const numWidth = Math.max(\n 1,\n countLines(unwrap(this.state.original)),\n countLines(unwrap(this.state.modified))\n ).toString().length\n const padding = numWidth * 2 + 4 + 4\n return {\n minWidth: Math.max(original.minWidth, modified.minWidth) + padding,\n width: Math.max(original.width, modified.width) + padding,\n }\n }\n}\n\n/**\n * Factory for `Diff`.\n *\n * ```ts\n * diff({\n * original: \"function foo() {}\\n\",\n * modified: \"function foo(x) {}\\n\",\n * path: \"foo.ts\",\n * })\n * ```\n */\nexport function diff(state: State<DiffState>): Diff {\n return new Diff(state)\n}\n\n// ---------- internals ----------\n\ntype DiffRow =\n | { type: \"context\"; origNum: number; newNum: number; content: string }\n | { type: \"remove\"; origNum: number; content: string }\n | { type: \"add\"; newNum: number; content: string }\n\nasync function buildDiffRows(opts: DiffOpts): Promise<string[]> {\n const context = opts.context\n // Async-import keeps cold start snappy — only the diff widget pulls\n // in the library, and it lands at first render rather than at module\n // load.\n const { diffArrays } = await import(\"diff\")\n const segments = diffArrays(opts.original, opts.modified)\n const {\n original: origLines,\n modified: modLines,\n originalHi: origHi,\n modifiedHi: modHi,\n ctx,\n } = opts\n\n // Annotate each line in the diff with its kind + (orig, mod) indices.\n // The flattened list is the row-order the diff would print without\n // any hunking; we compute hunks (with surrounding context) on top.\n interface Annotated {\n kind: \"equal\" | \"remove\" | \"add\"\n origIdx?: number\n modIdx?: number\n }\n const ann: Annotated[] = []\n let oI = 0\n let mI = 0\n for (const seg of segments) {\n if (seg.added) {\n for (const _ of seg.value) ann.push({ kind: \"add\", modIdx: mI++ })\n } else if (seg.removed) {\n for (const _ of seg.value) ann.push({ kind: \"remove\", origIdx: oI++ })\n } else {\n for (const _ of seg.value) ann.push({ kind: \"equal\", modIdx: mI++, origIdx: oI++ })\n }\n }\n\n // Find hunks: ranges around each non-equal line, expanded by `context`,\n // merged when adjacent ranges touch.\n const ranges: { start: number; end: number }[] = []\n for (let i = 0; i < ann.length; i++) {\n if (ann[i].kind === \"equal\") continue\n const start = Math.max(0, i - context)\n const end = Math.min(ann.length - 1, i + context)\n const last = ranges.at(-1)\n if (last && start <= last.end + 1) last.end = Math.max(last.end, end)\n else ranges.push({ end, start })\n }\n if (ranges.length === 0) return [] // nothing changed\n\n // Emit rows for each hunk. (Between hunks we just skip the equal\n // lines — a `…` divider is a future polish.)\n const rows: DiffRow[] = []\n for (const r of ranges) {\n for (let i = r.start; i <= r.end; i++) {\n const a = ann[i]\n if (a.kind === \"equal\") {\n rows.push({\n content: modHi[a.modIdx!] ?? origHi[a.origIdx!] ?? \"\",\n newNum: a.modIdx! + 1,\n origNum: a.origIdx! + 1,\n type: \"context\",\n })\n } else if (a.kind === \"remove\") {\n rows.push({\n content: origHi[a.origIdx!] ?? \"\",\n origNum: a.origIdx! + 1,\n type: \"remove\",\n })\n } else {\n rows.push({\n content: modHi[a.modIdx!] ?? \"\",\n newNum: a.modIdx! + 1,\n type: \"add\",\n })\n }\n }\n }\n\n return renderRows(ctx, rows, origLines.length, modLines.length)\n}\n\nfunction renderRows(\n ctx: RenderCtx,\n rows: DiffRow[],\n origTotal: number,\n modTotal: number\n): string[] {\n const numWidth = Math.max(String(origTotal).length, String(modTotal).length, 1)\n const s = ctx.style\n\n // Two-column gutter: original line number | new line number | space.\n // - Context rows show both numbers.\n // - Remove rows show only the original number; new column blank.\n // - Add rows show only the new number; original column blank.\n // Wrapped continuation lines reuse the row style but emit a blank\n // gutter so the line number isn't repeated per visual row.\n const gutterWidth = numWidth * 2 + 4 // \"<orig> <new> \"\n const contentWidth = Math.max(0, ctx.width - gutterWidth)\n const blankGutter = \" \".repeat(gutterWidth - 2) + s.dim(\"↪ \")\n\n const styles = {\n add: \"diffAdd\",\n context: \"diffContext\",\n remove: \"diffDel\",\n } as const\n\n const out: string[] = []\n for (const r of rows) {\n const origStr = r.type === \"add\" ? \"\" : String(r.origNum)\n const newStr = r.type === \"remove\" ? \"\" : String(r.newNum)\n const gutterStyle = s.bg(`${styles[r.type]}+10`)\n const gutter = gutterStyle(` ${pad(origStr, numWidth)} ${pad(newStr, numWidth)} `)\n\n const prefix = r.type === \"add\" ? \" + \" : r.type === \"remove\" ? \" - \" : \" \"\n const innerWidth = Math.max(0, contentWidth - stringWidth(prefix) - 1)\n\n // Hard-wrap the content. Char-wrap (vs. word-wrap) keeps code\n // diffs honest — splitting by word boundaries would shift columns\n // mid-line and make alignment confusing.\n const wrapped =\n innerWidth > 0 && stringWidth(r.content) > innerWidth\n ? splitAnsi(wrapAnsi(r.content, innerWidth, { mode: \"word\" }))\n : [r.content]\n\n const rowStyle = s.bg(styles[r.type])\n for (let i = 0; i < wrapped.length; i++) {\n const wline = wrapped[i]\n const pw = Math.max(0, innerWidth - stringWidth(wline) + 1)\n const bodyLine = (i === 0 ? prefix : \" \") + wline + \" \".repeat(pw)\n const styledBody = rowStyle?.(bodyLine) ?? bodyLine\n out.push((i === 0 ? gutter : gutterStyle(blankGutter)) + styledBody)\n }\n }\n return out\n}\n\nfunction pad(s: string, width: number): string {\n return s.length >= width ? s : \" \".repeat(width - s.length) + s\n}\n\n/** Resolve a file path to a shiki language identifier. Falls back from\n * extension to basename — shiki natively recognises `dockerfile`,\n * `makefile`, `cmakelists.txt`, etc. */\nfunction langFromPath(path: string): string | undefined {\n const ext = extname(path).slice(1).toLowerCase()\n if (ext) return ext\n const base = basename(path).toLowerCase()\n return base || undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,IAAa,OAAb,cAA0B,KAAgB;CACxC;CACA;CAEA,YAAY,OAAkB;EAC5B,MAAM;GAAE,MAAM;GAAQ,GAAG;EAAM,CAAC;EAEhC,KAAKA,QAAQ,WAAW;GACtB,MAAM,OAAO,OAAO,KAAK,MAAM,IAAI;GACnC,OAAO,KAAK,MAAM,SAAS,SAAS,KAAA,IAAY,aAAa,IAAI,IAAI,KAAA;EACvE,CAAC;EAED,MAAM,UAAU,WAAW,aAAa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S,IAAI,CAAC,CAAC,YAClB,KAAK,KAAA;AACjB"}
|
|
1
|
+
{"version":3,"file":"diff.mjs","names":[],"sources":["../../src/widgets/diff.ts"],"sourcesContent":["import type { RenderCtx } from \"../core/ctx.ts\"\nimport type { Accessor, Reactive } from \"../core/reactive.ts\"\nimport type { Layout, State } from \"../core/state.ts\"\nimport type { WrapMode } from \"../layout/text.ts\"\n\nimport { splitAnsi, stringWidth, wrapAnsi } from \"@zaly/shared/ansi\"\nimport { basename, extname } from \"pathe\"\n// oxlint-disable no-nested-ternary\n// oxlint-disable typescript/no-unnecessary-condition\nimport { Node } from \"../core/node.ts\"\nimport { createAsync, memo, unwrap, useContext } from \"../core/reactive.ts\"\nimport { RenderContext } from \"../core/render.ts\"\nimport { calcLayout, countLines } from \"../layout/text.ts\"\nimport { codeToAnsi } from \"../shiki/shiki.ts\"\n\nexport interface DiffState {\n /** Pre-state file content. Plain string or reactive accessor —\n * pass a signal to live-update the diff as either side changes. */\n original: Reactive<string>\n /** Post-state file content. The widget runs `diffLines` between\n * `original` and `modified` and renders the resulting hunks. */\n modified: Reactive<string>\n /** Optional file path. Drives the default `lang` (extension or\n * basename — shiki recognises both `.ts` and `Dockerfile`-style\n * names) and `title` when those aren't set explicitly. */\n path?: Reactive<string>\n /** Language for syntax highlighting (any shiki-bundled name or\n * alias). Defaults from `path` when set. */\n lang?: string\n /** Lines of surrounding context per hunk. Default: 3. */\n context?: number\n wrap?: WrapMode\n}\n\ntype DiffOpts = {\n original: string[]\n originalHi: string[]\n modified: string[]\n modifiedHi: string[]\n context: number\n ctx: RenderCtx\n}\n\n/**\n * Show a unified diff between two file contents with syntax-highlighted\n * rows. Added rows carry a green backdrop and `+` prefix; removed rows\n * carry a red backdrop and `-` prefix; context rows show both line\n * numbers with a neutral gutter.\n *\n * Both sides are highlighted as complete files (via shiki) before the\n * diff is assembled, so context around an edit tokenizes the way it\n * would in the actual file — multi-line strings, block comments, etc.\n * don't get truncated by the hunk window.\n */\nexport class Diff extends Node<DiffState> {\n #lang: Accessor<string | undefined>\n #highlighted: Accessor<{ original: string; modified: string }>\n\n constructor(state: DiffState) {\n super({ wrap: \"word\", ...state })\n\n this.#lang = memo(() => {\n const path = unwrap(this.state.path)\n return this.state.lang ?? (path !== undefined ? langFromPath(path) : undefined)\n })\n\n const context = useContext(RenderContext)\n this.#highlighted = createAsync(\n async () => {\n const lang = this.#lang()\n const input = this.input\n if (!lang) return input\n const theme = context?.style().theme.shiki\n const [original, modified] = await Promise.all([\n codeToAnsi(input.original, lang, { theme }),\n codeToAnsi(input.modified, lang, { theme }),\n ])\n return { modified, original }\n },\n {\n initialValue: this.input,\n }\n )\n }\n\n #norm(s: string): string {\n return s.replaceAll(\"\\r\\n\", \"\\n\").replaceAll(\"\\r\", \"\")\n }\n\n get input(): { original: string; modified: string } {\n return {\n modified: this.#norm(unwrap(this.state.modified)),\n original: this.#norm(unwrap(this.state.original)),\n }\n }\n\n protected async _render(ctx: RenderCtx): Promise<string[]> {\n const highlighted = this.#highlighted()\n const input = this.input\n const layout = this.layout()\n const width = Math.min(ctx.width, layout.width)\n\n const opts: DiffOpts = {\n context: this.state.context ?? 3,\n ctx: { ...ctx, width },\n modified: input.modified.split(\"\\n\"),\n modifiedHi: highlighted.modified.split(\"\\n\"),\n original: input.original.split(\"\\n\"),\n originalHi: highlighted.original.split(\"\\n\"),\n }\n\n this.state.wrap ??= \"word\"\n return await buildDiffRows(opts)\n }\n\n override layout(): Layout {\n const input = this.input\n const original = calcLayout(input.original, { wrap: this.state.wrap })\n const modified = calcLayout(input.modified, { wrap: this.state.wrap })\n const numWidth = Math.max(\n 1,\n countLines(unwrap(this.state.original)),\n countLines(unwrap(this.state.modified))\n ).toString().length\n const padding = numWidth * 2 + 4 + 4\n return {\n minWidth: Math.max(original.minWidth, modified.minWidth) + padding,\n width: Math.max(original.width, modified.width) + padding,\n }\n }\n}\n\n/**\n * Factory for `Diff`.\n *\n * ```ts\n * diff({\n * original: \"function foo() {}\\n\",\n * modified: \"function foo(x) {}\\n\",\n * path: \"foo.ts\",\n * })\n * ```\n */\nexport function diff(state: State<DiffState>): Diff {\n return new Diff(state)\n}\n\n// ---------- internals ----------\n\ntype DiffRow =\n | { type: \"context\"; origNum: number; newNum: number; content: string }\n | { type: \"remove\"; origNum: number; content: string }\n | { type: \"add\"; newNum: number; content: string }\n\nasync function buildDiffRows(opts: DiffOpts): Promise<string[]> {\n const context = opts.context\n // Async-import keeps cold start snappy — only the diff widget pulls\n // in the library, and it lands at first render rather than at module\n // load.\n const { diffArrays } = await import(\"diff\")\n const segments = diffArrays(opts.original, opts.modified)\n const {\n original: origLines,\n modified: modLines,\n originalHi: origHi,\n modifiedHi: modHi,\n ctx,\n } = opts\n\n // Annotate each line in the diff with its kind + (orig, mod) indices.\n // The flattened list is the row-order the diff would print without\n // any hunking; we compute hunks (with surrounding context) on top.\n interface Annotated {\n kind: \"equal\" | \"remove\" | \"add\"\n origIdx?: number\n modIdx?: number\n }\n const ann: Annotated[] = []\n let oI = 0\n let mI = 0\n for (const seg of segments) {\n if (seg.added) {\n for (const _ of seg.value) ann.push({ kind: \"add\", modIdx: mI++ })\n } else if (seg.removed) {\n for (const _ of seg.value) ann.push({ kind: \"remove\", origIdx: oI++ })\n } else {\n for (const _ of seg.value) ann.push({ kind: \"equal\", modIdx: mI++, origIdx: oI++ })\n }\n }\n\n // Find hunks: ranges around each non-equal line, expanded by `context`,\n // merged when adjacent ranges touch.\n const ranges: { start: number; end: number }[] = []\n for (let i = 0; i < ann.length; i++) {\n if (ann[i].kind === \"equal\") continue\n const start = Math.max(0, i - context)\n const end = Math.min(ann.length - 1, i + context)\n const last = ranges.at(-1)\n if (last && start <= last.end + 1) last.end = Math.max(last.end, end)\n else ranges.push({ end, start })\n }\n if (ranges.length === 0) return [] // nothing changed\n\n // Emit rows for each hunk. (Between hunks we just skip the equal\n // lines — a `…` divider is a future polish.)\n const rows: DiffRow[] = []\n for (const r of ranges) {\n for (let i = r.start; i <= r.end; i++) {\n const a = ann[i]\n if (a.kind === \"equal\") {\n rows.push({\n content: modHi[a.modIdx!] ?? origHi[a.origIdx!] ?? \"\",\n newNum: a.modIdx! + 1,\n origNum: a.origIdx! + 1,\n type: \"context\",\n })\n } else if (a.kind === \"remove\") {\n rows.push({\n content: origHi[a.origIdx!] ?? \"\",\n origNum: a.origIdx! + 1,\n type: \"remove\",\n })\n } else {\n rows.push({\n content: modHi[a.modIdx!] ?? \"\",\n newNum: a.modIdx! + 1,\n type: \"add\",\n })\n }\n }\n }\n\n return renderRows(ctx, rows, origLines.length, modLines.length)\n}\n\nfunction renderRows(\n ctx: RenderCtx,\n rows: DiffRow[],\n origTotal: number,\n modTotal: number\n): string[] {\n const numWidth = Math.max(String(origTotal).length, String(modTotal).length, 1)\n const s = ctx.style\n\n // Two-column gutter: original line number | new line number | space.\n // - Context rows show both numbers.\n // - Remove rows show only the original number; new column blank.\n // - Add rows show only the new number; original column blank.\n // Wrapped continuation lines reuse the row style but emit a blank\n // gutter so the line number isn't repeated per visual row.\n const gutterWidth = numWidth * 2 + 4 // \"<orig> <new> \"\n const contentWidth = Math.max(0, ctx.width - gutterWidth)\n const blankGutter = \" \".repeat(gutterWidth - 2) + s.dim(\"↪ \")\n\n const styles = {\n add: \"diffAdd\",\n context: \"diffContext\",\n remove: \"diffDel\",\n } as const\n\n const out: string[] = []\n for (const r of rows) {\n const origStr = r.type === \"add\" ? \"\" : String(r.origNum)\n const newStr = r.type === \"remove\" ? \"\" : String(r.newNum)\n const gutterStyle = s.bg(`${styles[r.type]}+10`)\n const gutter = gutterStyle(` ${pad(origStr, numWidth)} ${pad(newStr, numWidth)} `)\n\n const prefix = r.type === \"add\" ? \" + \" : r.type === \"remove\" ? \" - \" : \" \"\n const innerWidth = Math.max(0, contentWidth - stringWidth(prefix) - 1)\n\n // Hard-wrap the content. Char-wrap (vs. word-wrap) keeps code\n // diffs honest — splitting by word boundaries would shift columns\n // mid-line and make alignment confusing.\n const wrapped =\n innerWidth > 0 && stringWidth(r.content) > innerWidth\n ? splitAnsi(wrapAnsi(r.content, innerWidth, { mode: \"word\" }))\n : [r.content]\n\n const rowStyle = s.bg(styles[r.type])\n for (let i = 0; i < wrapped.length; i++) {\n const wline = wrapped[i]\n const pw = Math.max(0, innerWidth - stringWidth(wline) + 1)\n const bodyLine = (i === 0 ? prefix : \" \") + wline + \" \".repeat(pw)\n const styledBody = rowStyle?.(bodyLine) ?? bodyLine\n out.push((i === 0 ? gutter : gutterStyle(blankGutter)) + styledBody)\n }\n }\n return out\n}\n\nfunction pad(s: string, width: number): string {\n return s.length >= width ? s : \" \".repeat(width - s.length) + s\n}\n\n/** Resolve a file path to a shiki language identifier. Falls back from\n * extension to basename — shiki natively recognises `dockerfile`,\n * `makefile`, `cmakelists.txt`, etc. */\nfunction langFromPath(path: string): string | undefined {\n const ext = extname(path).slice(1).toLowerCase()\n if (ext) return ext\n const base = basename(path).toLowerCase()\n return base || undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,IAAa,OAAb,cAA0B,KAAgB;CACxC;CACA;CAEA,YAAY,OAAkB;EAC5B,MAAM;GAAE,MAAM;GAAQ,GAAG;EAAM,CAAC;EAEhC,KAAK,QAAQ,WAAW;GACtB,MAAM,OAAO,OAAO,KAAK,MAAM,IAAI;GACnC,OAAO,KAAK,MAAM,SAAS,SAAS,KAAA,IAAY,aAAa,IAAI,IAAI,KAAA;EACvE,CAAC;EAED,MAAM,UAAU,WAAW,aAAa;EACxC,KAAK,eAAe,YAClB,YAAY;GACV,MAAM,OAAO,KAAK,MAAM;GACxB,MAAM,QAAQ,KAAK;GACnB,IAAI,CAAC,MAAM,OAAO;GAClB,MAAM,QAAQ,SAAS,MAAM,CAAC,CAAC,MAAM;GACrC,MAAM,CAAC,UAAU,YAAY,MAAM,QAAQ,IAAI,CAC7C,WAAW,MAAM,UAAU,MAAM,EAAE,MAAM,CAAC,GAC1C,WAAW,MAAM,UAAU,MAAM,EAAE,MAAM,CAAC,CAC5C,C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AS,QAAQ,QAAQ,EAAE,SAAS,WAAW,QAAQ;EACxE,MAAM,aAAa,KAAK,IAAI,GAAG,eAAe,YAAY,MAAM,IAAI,CAAC;EAKrE,MAAM,UACJ,aAAa,KAAK,YAAY,EAAE,OAAO,IAAI,aACvC,UAAU,SAAS,EAAE,SAAS,YAAY,EAAE,MAAM,OAAO,CAAC,CAAC,IAC3D,CAAC,EAAE,OAAO;EAEhB,MAAM,WAAW,EAAE,GAAG,OAAO,EAAE,KAAK;EACpC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,QAAQ,QAAQ;GACtB,MAAM,KAAK,KAAK,IAAI,GAAG,aAAa,YAAY,KAAK,IAAI,CAAC;GAC1D,MAAM,YAAY,MAAM,IAAI,SAAS,SAAS,QAAQ,IAAI,OAAO,EAAE;GACnE,MAAM,aAAa,WAAW,QAAQ,KAAK;GAC3C,IAAI,MAAM,MAAM,IAAI,SAAS,YAAY,WAAW,KAAK,UAAU;EACrE;CACF;CACA,OAAO;AACT;AAEA,SAAS,IAAI,GAAW,OAAuB;CAC7C,OAAO,EAAE,UAAU,QAAQ,IAAI,IAAI,OAAO,QAAQ,EAAE,MAAM,IAAI;AAChE;;;;AAKA,SAAS,aAAa,MAAkC;CACtD,MAAM,MAAM,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY;CAC/C,IAAI,KAAK,OAAO;CAEhB,OADa,SAAS,IAAI,CAAC,CAAC,YAClB,KAAK,KAAA;AACjB"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { H as Text } from "../queries-
|
|
2
|
-
import { f as Style } from "../types-
|
|
1
|
+
import { H as Text } from "../queries-Cvalgu6P.mjs";
|
|
2
|
+
import { f as Style } from "../types-C0EOLZDc.mjs";
|
|
3
3
|
//#region src/widgets/divider.d.ts
|
|
4
|
-
type DividerState = Style & {
|
|
4
|
+
export type DividerState = Style & {
|
|
5
5
|
char?: string;
|
|
6
6
|
length?: number;
|
|
7
7
|
};
|
|
8
|
-
declare function divider(state?: DividerState): Text;
|
|
8
|
+
export declare function divider(state?: DividerState): Text;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { DividerState, divider };
|
|
11
10
|
//# sourceMappingURL=divider.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"divider.d.mts","names":[],"sources":["../../src/widgets/divider.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"divider.d.mts","names":[],"sources":["../../src/widgets/divider.ts"],"mappings":";;;YAKY,eAAe;EACzB;EACA;;wBAGc,QAAQ,QAAO,eAAsC"}
|