@cosense-toolbox/tailwind 0.1.0-beta.2

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/modifiers.ts","../src/styles.generated.ts","../src/index.ts"],"sourcesContent":["/**\n * modifiers.ts — `cosense-link:underline` のように、記事の中の特定の要素にだけ utility を当てる modifier。\n * typography の `prose-a:` にあたる。\n *\n * 対象は HTML の要素名ではなく Cosense の記法で選ぶ。`toHtml` は同じ `<a>` をリンク・タグ・\n * アイコンに使い分けるので、要素名で選ぶと区別できないため。class 名は parser の既定\n * (`defaultClassNames`) に合わせている。\n */\n\nexport interface Modifier {\n /** modifier の名前。`{className}-{name}:` になる */\n readonly name: string\n /** 当てる先のセレクタ。`.cosense` の子孫として探す */\n readonly target: string\n /** 対応する Cosense の記法 (README の表に出す) */\n readonly notation: string\n}\n\nexport const MODIFIERS: readonly Modifier[] = [\n { name: \"title\", target: \".title\", notation: \"タイトル (1 行目)\" },\n { name: \"line\", target: \".line\", notation: \"各行\" },\n {\n name: \"heading\",\n target: \".decoration[data-size-level]\",\n notation: \"`[** 見出し]` などの大きな文字\",\n },\n { name: \"strong\", target: \"strong\", notation: \"`[[太字]]` `[* 太字]`\" },\n { name: \"em\", target: \"em\", notation: \"`[/ 斜体]`\" },\n { name: \"s\", target: \"s\", notation: \"`[- 打ち消し]`\" },\n { name: \"u\", target: \"u\", notation: \"`[_ 下線]`\" },\n {\n name: \"link\",\n target: \".link\",\n notation: \"リンクすべて (`[ページ]` `[https://…]` `[/project/ページ]`)\",\n },\n { name: \"link-external\", target: \".link-external\", notation: \"外部リンク `[https://…]`\" },\n {\n name: \"link-project\",\n target: \".link-project\",\n notation: \"別プロジェクトへのリンク `[/project/ページ]`\",\n },\n { name: \"hashtag\", target: \".hashtag\", notation: \"`#タグ`\" },\n { name: \"code\", target: \".code\", notation: \"`` `コード` ``\" },\n {\n name: \"code-block\",\n target: \".code-block > code\",\n notation: \"`code:ファイル名` のブロックの各行\",\n },\n {\n name: \"code-filename\",\n target: \".code-block-start\",\n notation: \"`code:ファイル名` のファイル名\",\n },\n { name: \"quote\", target: \".quote\", notation: \"`>` で始まる引用\" },\n { name: \"table\", target: \".table\", notation: \"`table:名前` の表\" },\n { name: \"td\", target: \".table td\", notation: \"表のセル\" },\n { name: \"image\", target: \".image\", notation: \"画像\" },\n { name: \"icon\", target: \".icon\", notation: \"`[ユーザー名.icon]`\" },\n { name: \"formula\", target: \".formula\", notation: \"`[$ 数式]`\" },\n]\n","/**\n * 生成物。編集しない。\n * packages/style/style.css から `bun run generate` で作る。\n */\nimport type { CosenseStyles } from './extract'\n\nexport const styles: CosenseStyles = {\n \"root\": {\n \"font-family\": \"var(--cosense-font, \\\"Open Sans\\\", Helvetica, Arial, \\\"Hiragino Sans\\\", sans-serif)\",\n \"font-size\": \"var(--cosense-font-size, 15px)\",\n \"line-height\": \"var(--cosense-line-height, 1.87)\",\n \"color\": \"var(--cosense-text, var(--page-text-color, #4a4a4a))\",\n \"background\": \"var(--cosense-bg, var(--page-bg, #fefefe))\",\n \"text-align\": \"left\",\n \"word-wrap\": \"break-word\"\n },\n \"rules\": [\n {\n \"selector\": {\n \"body\": \".title\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"margin\": \"0 0 0.77em\",\n \"font-size\": \"1.73em\",\n \"font-weight\": \"700\",\n \"line-height\": \"1.62\",\n \"color\": \"var(--cosense-title, var(--line-title-color, var(--page-text-color, #4a4a4a)))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"position\": \"relative\",\n \"min-height\": \"1em\",\n \"font-variant-ligatures\": \"no-common-ligatures\"\n }\n },\n {\n \"selector\": {\n \"body\": \".indent-mark\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"position\": \"absolute\",\n \"left\": \"0\",\n \"top\": \"0\",\n \"height\": \"1em\",\n \"color\": \"transparent\"\n }\n },\n {\n \"selector\": {\n \"body\": \".pad\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"display\": \"inline-block\",\n \"width\": \"var(--cosense-indent, 1.5em)\",\n \"height\": \"1em\",\n \"overflow\": \"hidden\"\n }\n },\n {\n \"selector\": {\n \"body\": \".dot\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"position\": \"absolute\",\n \"right\": \"0.65em\",\n \"top\": \"0.7em\",\n \"width\": \"6px\",\n \"height\": \"6px\",\n \"border-radius\": \"50%\",\n \"background\": \"var(--cosense-text, var(--page-text-color, #555))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".link\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"color\": \"var(--cosense-link, var(--page-link-color, #3d72f5))\",\n \"text-decoration\": \"none\",\n \"-webkit-tap-highlight-color\": \"rgba(0, 0, 0, 0.2)\"\n }\n },\n {\n \"selector\": {\n \"body\": \".hashtag\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"color\": \"var(--cosense-link, var(--page-link-color, #3d72f5))\",\n \"text-decoration\": \"none\",\n \"-webkit-tap-highlight-color\": \"rgba(0, 0, 0, 0.2)\"\n }\n },\n {\n \"selector\": {\n \"body\": \".code\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-family\": \"var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)\",\n \"color\": \"var(--cosense-code-text, var(--code-color, #342d9c))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".code-start\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-family\": \"var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)\",\n \"color\": \"var(--cosense-code-text, var(--code-color, #342d9c))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".code-body\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-family\": \"var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)\",\n \"color\": \"var(--cosense-code-text, var(--code-color, #342d9c))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".monospace\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-family\": \"var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)\",\n \"color\": \"var(--cosense-code-text, var(--code-color, #342d9c))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".code\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"padding\": \"0 0.2em\",\n \"border-radius\": \"4px\",\n \"font-size\": \"90%\",\n \"word-wrap\": \"break-word\",\n \"background\": \"var(--cosense-code-bg, var(--code-bg, rgba(0, 0, 0, 0.04)))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".monospace\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"padding\": \"0 0.2em\",\n \"border-radius\": \"4px\",\n \"font-size\": \"90%\",\n \"word-wrap\": \"break-word\",\n \"background\": \"var(--cosense-code-bg, var(--code-bg, rgba(0, 0, 0, 0.04)))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".code-block-start\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"padding\": \"1px 2px\",\n \"font-size\": \"0.95em\",\n \"color\": \"var(--cosense-badge-text, #342d9c)\",\n \"background\": \"var(--cosense-badge-bg, #ffcfc6)\"\n }\n },\n {\n \"selector\": {\n \"body\": \".quote\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"display\": \"block\",\n \"margin\": \"0\",\n \"padding-left\": \"3px\",\n \"border-left\": \"solid 1px #a0a0a0\",\n \"background\": \"var(--cosense-quote-bg, var(--quote-bg-color, rgba(0, 0, 0, 0.05)))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".table\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"margin\": \"0\",\n \"border-collapse\": \"collapse\",\n \"caption-side\": \"top\"\n }\n },\n {\n \"selector\": {\n \"body\": \".image\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"display\": \"inline-block\",\n \"max-width\": \"100%\",\n \"max-height\": \"300px\",\n \"vertical-align\": \"bottom\"\n }\n },\n {\n \"selector\": {\n \"body\": \".formula\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"margin\": \"auto 6px\",\n \"font-family\": \"var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)\",\n \"font-style\": \"italic\"\n }\n },\n {\n \"selector\": {\n \"body\": \".table caption\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"padding\": \"1px 2px\",\n \"text-align\": \"center\",\n \"font-size\": \"0.9em\",\n \"color\": \"var(--cosense-badge-text, #342d9c)\",\n \"background\": \"var(--cosense-badge-bg, #ffcfc6)\"\n }\n },\n {\n \"selector\": {\n \"body\": \".table td\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"padding\": \"0 2px 0 8px\",\n \"white-space\": \"nowrap\"\n }\n },\n {\n \"selector\": {\n \"body\": \"img.icon\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"display\": \"inline-block\",\n \"position\": \"relative\",\n \"top\": \"-0.3em\",\n \"height\": \"1.3em\",\n \"max-width\": \"100%\",\n \"vertical-align\": \"baseline\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"1\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"1\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"2\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"2\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"3\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"3\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"4\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"4\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"5\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"5\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"6\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"6\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"7\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"7\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"8\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"8\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"9\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"9\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent=\\\"10\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-depth\": \"10\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"padding-left\": \"calc(var(--cosense-indent, 1.5em) * var(--cosense-depth, 0))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".link:hover\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"color\": \"var(--cosense-link-hover, var(--page-link-hover-color, #0d4ff3))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".hashtag:hover\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"color\": \"var(--cosense-link-hover, var(--page-link-hover-color, #0d4ff3))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".image[data-large]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"margin\": \"3px 0\",\n \"max-width\": \"95%\",\n \"max-height\": \"none\"\n }\n },\n {\n \"selector\": {\n \"body\": \".decoration[data-size-level=\\\"1\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-size\": \"1.2em\"\n }\n },\n {\n \"selector\": {\n \"body\": \".decoration[data-size-level=\\\"2\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-size\": \"1.44em\"\n }\n },\n {\n \"selector\": {\n \"body\": \".decoration[data-size-level=\\\"3\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-size\": \"1.73em\"\n }\n },\n {\n \"selector\": {\n \"body\": \".decoration[data-size-level=\\\"4\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"font-size\": \"2.07em\"\n }\n },\n {\n \"selector\": {\n \"body\": \".decoration[data-size-level]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"display\": \"inline-block\",\n \"line-height\": \"1.6\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line[data-indent]\",\n \"pseudo\": \"::before\"\n },\n \"declarations\": {\n \"content\": \"\\\"\\\"\",\n \"position\": \"absolute\",\n \"top\": \"0.7em\",\n \"left\": \"calc(var(--cosense-indent, 1.5em) * var(--cosense-depth, 0) - 1.05em)\",\n \"width\": \"6px\",\n \"height\": \"6px\",\n \"border-radius\": \"50%\",\n \"background\": \"var(--cosense-text, var(--page-text-color, #555))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line:has(> .indent-mark)\",\n \"pseudo\": \"::before\"\n },\n \"declarations\": {\n \"content\": \"none\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block > code\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"display\": \"block\",\n \"min-height\": \"1.7em\",\n \"line-height\": \"1.7em\",\n \"tab-size\": \"4\",\n \"background\": \"var(--cosense-code-bg, var(--code-bg, rgba(0, 0, 0, 0.04)))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".table td:nth-child(odd)\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"background\": \"rgba(0, 0, 0, 0.04)\"\n }\n },\n {\n \"selector\": {\n \"body\": \".table td:nth-child(even)\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"background\": \"rgba(0, 0, 0, 0.06)\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block > .code-body\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"margin-left\": \"calc(var(--cosense-indent, 1.5em) * -1)\",\n \"padding-left\": \"var(--cosense-indent, 1.5em)\",\n \"white-space\": \"pre-wrap\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block[data-line-digits=\\\"1\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-line-digits\": \"1\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block[data-line-digits=\\\"2\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-line-digits\": \"2\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block[data-line-digits=\\\"3\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-line-digits\": \"3\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block[data-line-digits=\\\"4\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-line-digits\": \"4\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block[data-line-digits=\\\"5\\\"]\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"--cosense-line-digits\": \"5\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block:not(:has(> .code-start))\",\n \"pseudo\": \"::before\"\n },\n \"declarations\": {\n \"content\": \"none\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block[data-line]\",\n \"pseudo\": \"::before\"\n },\n \"declarations\": {\n \"content\": \"attr(data-line)\",\n \"top\": \"0\",\n \"left\": \"calc(var(--cosense-indent, 1.5em) * (var(--cosense-depth, 1) - 1))\",\n \"width\": \"calc(0.6em + var(--cosense-line-digits, 5) * 1ch)\",\n \"height\": \"auto\",\n \"display\": \"flex\",\n \"justify-content\": \"flex-end\",\n \"white-space\": \"nowrap\",\n \"border-radius\": \"0\",\n \"background\": \"none\",\n \"font-family\": \"var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)\",\n \"line-height\": \"1.7em\",\n \"color\": \"var(--cosense-line-number, rgba(0, 0, 0, 0.35))\"\n }\n },\n {\n \"selector\": {\n \"body\": \".line.code-block[data-line] > .code-body\",\n \"pseudo\": \"\"\n },\n \"declarations\": {\n \"padding-left\": \"calc(0.6em + (var(--cosense-line-digits, 5) + 1) * 1ch)\"\n }\n }\n ]\n}\n","/**\n * `@cosense-toolbox/tailwind` — `class=\"cosense\"` を付けた要素の中に、Cosense 記法の既定の見た目を当てる。\n * typography の `prose` と同じ使い方をする。\n *\n * ```css\n * @import \"tailwindcss\";\n * @plugin \"@cosense-toolbox/tailwind\";\n * ```\n *\n * 当てるスタイルは `@cosense-toolbox/style` の style.css と同じもの。`cosense-link:underline` のような\n * modifier で、記事の中の特定の記法にだけ utility を当てられる。\n */\nimport plugin, { type PluginAPI } from \"tailwindcss/plugin\"\n\nimport type { Declarations, StyleRule } from \"./extract\"\nimport { type Modifier, MODIFIERS } from \"./modifiers\"\nimport { styles } from \"./styles.generated\"\n\nexport interface CosenseTailwindOptions {\n /**\n * スタイルを当てる class 名。`not-{className}` を付けた要素とその中身には当てない。\n *\n * @defaultValue `'cosense'`\n */\n readonly className?: string\n}\n\ntype Components = Parameters<PluginAPI[\"addComponents\"]>[0]\n\n/** 生成したデータは readonly なので、Tailwind の可変の型に合わせる (中身は書き換えない)。 */\nconst mutable = (declarations: Declarations) => declarations as Record<string, string | string[]>\n\n/**\n * `not-{className}` を付けた要素とその中を除く条件。`:where()` の中なので詳細度を増やさない。\n */\nconst outside = (className: string): string =>\n `:not(:where([class~=\"not-${className}\"],[class~=\"not-${className}\"] *))`\n\n/**\n * 1 つのルールのセレクタ。本文を `:where()` で包み、どのルールも `.cosense` と同じ詳細度にする。\n * 除く条件は擬似要素より前に付ける。\n *\n * 詳細度を揃えるので、ルールどうしの勝ち負けは並び順だけで決まる。生成したデータは元の詳細度の\n * 低い順に並んでいるので、style.css と同じ勝ち負けになる。後ろに出る `cosense-link:` などの\n * modifier や、同じ詳細度の utility が既定のスタイルに勝てるのは、このため。\n */\nconst selectorOf = ({ selector }: StyleRule, className: string): string =>\n `& :where(${selector.body})${outside(className)}${selector.pseudo}`\n\n/**\n * ルールごとに別のオブジェクトにする。1 つのオブジェクトのキーにすると、同じセレクタのルールが\n * 後のもので上書きされてしまうため。Tailwind は並べた順のまま `.cosense` の中に出す。\n */\nconst componentsOf = (className: string): Components => [\n { [`.${className}`]: mutable(styles.root) },\n ...styles.rules.map((rule) => ({\n [`.${className}`]: { [selectorOf(rule, className)]: mutable(rule.declarations) },\n })),\n]\n\n/** `cosense-link:` なら `.cosense-link\\:underline :is(…)` のように、中の対象だけに当てる。 */\nconst modifierOf = (modifier: Modifier, className: string): string =>\n `& :is(:where(${modifier.target})${outside(className)})`\n\n/** class 名に使えない記号を、CSS のセレクタ用にエスケープする。 */\nconst escapeClassChar = (char: string): string => (/[A-Za-z0-9_-]/.test(char) ? char : `\\\\${char}`)\n\n/**\n * `cosense-deco-[|]:` の `[...]` に書いた記号の装飾。`toHtml` は装飾を\n * `<span class=\"decoration deco-|\">` のように記号ごとの class で出すので、それを選ぶ。\n * 記号を並べると (`[-/]`)、それらをすべて持つ装飾に当たる。\n *\n * Tailwind は `[...]` の中の `_` を空白に変える。下線の記号 `_` は `[\\_]` と書く (Tailwind の決まり)。\n */\nconst decorationOf = (markers: string, className: string): string => {\n const classes = [...new Set(markers)].map((marker) => `.deco-${escapeClassChar(marker)}`).join(\"\")\n return `& :is(:where(.decoration${classes})${outside(className)})`\n}\n\n/** Tailwind の型を公開する型定義に書き出せるよう、型を明示する。 */\ntype CosensePlugin = ReturnType<typeof plugin.withOptions<CosenseTailwindOptions>>\n\nconst cosense: CosensePlugin = plugin.withOptions<CosenseTailwindOptions>(\n (options) =>\n ({ addComponents, addVariant, matchVariant }) => {\n const className = options?.className ?? \"cosense\"\n addComponents(componentsOf(className))\n for (const modifier of MODIFIERS) {\n addVariant(`${className}-${modifier.name}`, modifierOf(modifier, className))\n }\n // 記号は `[...]` にそのまま書く (`cosense-deco-[|]:`)。名前を覚えなくて済むようにするため。\n matchVariant(`${className}-deco`, (markers) => decorationOf(markers, className))\n },\n)\n\nexport default cosense\n"],"mappings":";;AAkBA,MAAa,YAAiC;CAC5C;EAAE,MAAM;EAAS,QAAQ;EAAU,UAAU;CAAc;CAC3D;EAAE,MAAM;EAAQ,QAAQ;EAAS,UAAU;CAAK;CAChD;EACE,MAAM;EACN,QAAQ;EACR,UAAU;CACZ;CACA;EAAE,MAAM;EAAU,QAAQ;EAAU,UAAU;CAAoB;CAClE;EAAE,MAAM;EAAM,QAAQ;EAAM,UAAU;CAAW;CACjD;EAAE,MAAM;EAAK,QAAQ;EAAK,UAAU;CAAa;CACjD;EAAE,MAAM;EAAK,QAAQ;EAAK,UAAU;CAAW;CAC/C;EACE,MAAM;EACN,QAAQ;EACR,UAAU;CACZ;CACA;EAAE,MAAM;EAAiB,QAAQ;EAAkB,UAAU;CAAsB;CACnF;EACE,MAAM;EACN,QAAQ;EACR,UAAU;CACZ;CACA;EAAE,MAAM;EAAW,QAAQ;EAAY,UAAU;CAAQ;CACzD;EAAE,MAAM;EAAQ,QAAQ;EAAS,UAAU;CAAc;CACzD;EACE,MAAM;EACN,QAAQ;EACR,UAAU;CACZ;CACA;EACE,MAAM;EACN,QAAQ;EACR,UAAU;CACZ;CACA;EAAE,MAAM;EAAS,QAAQ;EAAU,UAAU;CAAa;CAC1D;EAAE,MAAM;EAAS,QAAQ;EAAU,UAAU;CAAgB;CAC7D;EAAE,MAAM;EAAM,QAAQ;EAAa,UAAU;CAAO;CACpD;EAAE,MAAM;EAAS,QAAQ;EAAU,UAAU;CAAK;CAClD;EAAE,MAAM;EAAQ,QAAQ;EAAS,UAAU;CAAiB;CAC5D;EAAE,MAAM;EAAW,QAAQ;EAAY,UAAU;CAAW;AAC9D;;;ACrDA,MAAa,SAAwB;CACnC,QA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;GACA,gBAAgB;IACd,eAAe;IACf,SAAS;GACX;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,cAAc;GAChB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,cAAc;GAChB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,aAAa;IACb,SAAS;IACT,cAAc;GAChB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,cAAc;GAChB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,UAAU;IACV,mBAAmB;IACnB,gBAAgB;GAClB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,aAAa;IACb,cAAc;IACd,kBAAkB;GACpB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,UAAU;IACV,eAAe;IACf,cAAc;GAChB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,cAAc;IACd,aAAa;IACb,SAAS;IACT,cAAc;GAChB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,eAAe;GACjB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,WAAW;IACX,YAAY;IACZ,OAAO;IACP,UAAU;IACV,aAAa;IACb,kBAAkB;GACpB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,IACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,mBAAmB,KACrB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,gBAAgB,+DAClB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,SAAS,mEACX;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,SAAS,mEACX;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB;IACd,UAAU;IACV,aAAa;IACb,cAAc;GAChB;EACF;EACA;GACE,YAAY;IACV,QAAQ;IACR,UAAU;GACZ;GACA,gBAAgB,EACd,aAAa,QACf;EACF;EACA;GACE,YAAY;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,KAAK,EACvD,EAAE,GAAG,QAAQ,SAAS,EAAE;AAClE;AAKA,MAAM,UAAyB,OAAO,aACnC,aACE,EAAE,eAAe,YAAY,mBAAmB;CAC/C,MAAM,YAAY,SAAS,aAAa;CACxC,cAAc,aAAa,SAAS,CAAC;CACrC,KAAK,MAAM,YAAY,WACrB,WAAW,GAAG,UAAU,GAAG,SAAS,QAAQ,WAAW,UAAU,SAAS,CAAC;CAG7E,aAAa,GAAG,UAAU,SAAS,YAAY,aAAa,SAAS,SAAS,CAAC;AACjF,CACJ"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@cosense-toolbox/tailwind",
3
+ "version": "0.1.0-beta.2",
4
+ "description": "Tailwind CSS plugin: add class=\"cosense\" and the Cosense notation HTML inside it gets the default look.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=20"
10
+ },
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.mjs",
13
+ "types": "./dist/index.d.mts",
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./dist/index.d.mts",
18
+ "default": "./dist/index.mjs"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.cts",
22
+ "default": "./dist/index.cjs"
23
+ }
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "scripts": {
33
+ "generate": "bun scripts/generate.ts",
34
+ "compare": "bun scripts/compare.ts",
35
+ "build": "tsdown",
36
+ "dev": "tsdown --watch",
37
+ "typecheck": "tsc --noEmit",
38
+ "test": "vitest run",
39
+ "prepublishOnly": "bun run build"
40
+ },
41
+ "peerDependencies": {
42
+ "tailwindcss": ">=4.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@cosense-toolbox/parser": "0.1.0-beta.2",
46
+ "@tailwindcss/node": "^4.3.3",
47
+ "effect": "^3.22.1",
48
+ "postcss": "^8.5.28",
49
+ "playwright-core": "^1.56.1",
50
+ "postcss-selector-parser": "^7.1.6",
51
+ "tailwindcss": "^4.3.3",
52
+ "tsdown": "^0.22.14",
53
+ "typescript": "^6.0.0",
54
+ "vitest": "^2.1.8"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public",
58
+ "tag": "beta",
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "keywords": [
62
+ "cosense",
63
+ "scrapbox",
64
+ "tailwindcss",
65
+ "tailwind-plugin",
66
+ "typography"
67
+ ],
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "git+https://github.com/qaynam/cosense-toolbox.git",
71
+ "directory": "packages/tailwind"
72
+ }
73
+ }