@immediately-run/sdk 0.94.0 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/components/FileRouter.cjs +4 -1
  2. package/dist/components/FileRouter.cjs.map +1 -1
  3. package/dist/components/FileRouter.js +4 -1
  4. package/dist/components/FileRouter.js.map +1 -1
  5. package/dist/components/HeadingAnchor.cjs.map +1 -1
  6. package/dist/components/HeadingAnchor.d.cts +4 -3
  7. package/dist/components/HeadingAnchor.d.ts +4 -3
  8. package/dist/components/HeadingAnchor.js.map +1 -1
  9. package/dist/components/Prose.cjs +72 -0
  10. package/dist/components/Prose.cjs.map +1 -0
  11. package/dist/components/Prose.d.cts +23 -0
  12. package/dist/components/Prose.d.ts +23 -0
  13. package/dist/components/Prose.js +49 -0
  14. package/dist/components/Prose.js.map +1 -0
  15. package/dist/index.cjs +6 -0
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +2 -0
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.js +4 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/loading.cjs +2 -6
  22. package/dist/loading.cjs.map +1 -1
  23. package/dist/loading.js +2 -6
  24. package/dist/loading.js.map +1 -1
  25. package/dist/proseStyles.cjs +181 -0
  26. package/dist/proseStyles.cjs.map +1 -0
  27. package/dist/proseStyles.d.cts +36 -0
  28. package/dist/proseStyles.d.ts +36 -0
  29. package/dist/proseStyles.js +153 -0
  30. package/dist/proseStyles.js.map +1 -0
  31. package/dist/proseTokens.cjs +235 -0
  32. package/dist/proseTokens.cjs.map +1 -0
  33. package/dist/proseTokens.d.cts +80 -0
  34. package/dist/proseTokens.d.ts +80 -0
  35. package/dist/proseTokens.js +204 -0
  36. package/dist/proseTokens.js.map +1 -0
  37. package/dist/proseTokensHook.cjs +116 -0
  38. package/dist/proseTokensHook.cjs.map +1 -0
  39. package/dist/proseTokensHook.d.cts +10 -0
  40. package/dist/proseTokensHook.d.ts +10 -0
  41. package/dist/proseTokensHook.js +99 -0
  42. package/dist/proseTokensHook.js.map +1 -0
  43. package/dist/styleElement.cjs +37 -0
  44. package/dist/styleElement.cjs.map +1 -0
  45. package/dist/styleElement.d.cts +13 -0
  46. package/dist/styleElement.d.ts +13 -0
  47. package/dist/styleElement.js +14 -0
  48. package/dist/styleElement.js.map +1 -0
  49. package/dist/version.cjs +1 -1
  50. package/dist/version.cjs.map +1 -1
  51. package/dist/version.d.cts +1 -1
  52. package/dist/version.d.ts +1 -1
  53. package/dist/version.js +1 -1
  54. package/dist/version.js.map +1 -1
  55. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/loading.tsx"],"sourcesContent":["// In-app loading primitives (LOADING_UX_SPEC §9, Surface E; design brief 19).\n//\n// Opt-in, presentational components an app author drops in for IN-APP waits (a\n// React.lazy chunk, a slow fetch, a pending action) so they match the platform's\n// loading language for free. Per product_values §3 this is convenience — a plain\n// app that ignores it still works.\n//\n// TRUST BOUNDARY (read brief 19): these render INSIDE the app's iframe, under the\n// app's principal — presentational only, NO capability, NO host round-trip. They\n// share the token VOCABULARY (radii, the shimmer sweep, soft placeholder fills)\n// with the host skeletons, but they are deliberately NOT the host's trusted chrome:\n// no reserved landmark, no wordmark, no \"platform is loading\" framing. They use\n// ordinary app a11y (`aria-hidden` for decorative skeletons, `role=\"status\"` for an\n// indeterminate indicator) — never the host's reserved landmark/accessible name\n// (that is the trusted-path control, reserved to the host). An in-app loader that\n// mimicked host chrome would be a spoofing vector.\n//\n// Self-contained: the SDK ships no CSS pipeline, so the keyframes are injected once\n// into the document and everything else is inline styles — zero config for the author.\nimport { useEffect, useLayoutEffect, useState, type CSSProperties, type ReactNode } from 'react';\n\n/** Loading timing constants, matching the host (LOADING_UX_SPEC §3, the 2026-06-22\n * design bundle). Exported so authors who hand-roll still match the platform. */\nexport const LOADING_TIMINGS = {\n /** Below this, NO spinner appears — a fast wait never flashes one (§6.2 floor). */\n spinThresholdMs: 150,\n /** The reveal cross-fade duration the host uses. */\n fadeMs: 150,\n /** One slow shimmer sweep across a placeholder. */\n shimmerMs: 1900,\n} as const;\n\n/** The in-app skeleton archetypes (the same shapes as the host §4.1 catalog). */\nexport type SkeletonArchetype = 'panel.list' | 'panel.tree' | 'panel.editor' | 'panel.conversation' | 'generic';\n\nconst STYLE_ID = 'ir-sdk-loading-styles';\nconst STYLE_TEXT = `\n@keyframes ir-sdk-sweep{0%{transform:translateX(-130%)}60%,100%{transform:translateX(130%)}}\n@keyframes ir-sdk-spin{to{transform:rotate(360deg)}}\n.ir-sdk-shim{position:relative;overflow:hidden}\n.ir-sdk-shim::after{content:\"\";position:absolute;inset:0;background:linear-gradient(100deg,transparent 28%,rgba(127,127,127,.18) 50%,transparent 72%);transform:translateX(-130%);animation:ir-sdk-sweep ${LOADING_TIMINGS.shimmerMs}ms ease-in-out infinite}\n.ir-sdk-spin{animation:ir-sdk-spin .8s linear infinite}\n@media (prefers-reduced-motion:reduce){.ir-sdk-shim::after{display:none}.ir-sdk-spin{animation:none}}\n`;\n\n/** Inject the shimmer/spin keyframes once (idempotent, browser-only). */\nfunction ensureLoadingStyles(): void {\n if (typeof document === 'undefined') return;\n if (document.getElementById(STYLE_ID)) return;\n const el = document.createElement('style');\n el.id = STYLE_ID;\n el.textContent = STYLE_TEXT;\n document.head.appendChild(el);\n}\n\n/** Ensure the loading keyframes exist before the component paints. */\nfunction useLoadingStyles(): void {\n useLayoutEffect(() => {\n ensureLoadingStyles();\n }, []);\n}\n\n// A soft, low-contrast placeholder fill that reads on a light OR dark app surface.\nconst PLACEHOLDER: CSSProperties = {\n background: 'rgba(127,127,127,0.20)',\n borderRadius: 6,\n};\n\n/** A single placeholder bar — compose these into a custom skeleton shape. */\nexport function SkeletonRow({\n width = '100%',\n height = 12,\n style,\n}: {\n width?: number | string;\n height?: number | string;\n style?: CSSProperties;\n}) {\n useLoadingStyles();\n return <div className=\"ir-sdk-shim\" aria-hidden=\"true\" style={{ ...PLACEHOLDER, width, height, ...style }} />;\n}\n\nfunction rows(specs: Array<CSSProperties & { key: number }>): ReactNode {\n return specs.map(({ key, ...s }) => (\n <div key={key} className=\"ir-sdk-shim\" aria-hidden=\"true\" style={{ ...PLACEHOLDER, ...s }} />\n ));\n}\n\n/** A shaped, in-app skeleton matching the host archetypes — for an app's own lazy\n * region (e.g. `<Suspense fallback={<Skeleton archetype=\"panel.list\" />}>`).\n * Decorative (`aria-hidden`); pair it with `aria-busy` on the region it stands in. */\nexport function Skeleton({ archetype = 'generic', style }: { archetype?: SkeletonArchetype; style?: CSSProperties }) {\n useLoadingStyles();\n const wrap: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n gap: 10,\n padding: 12,\n width: '100%',\n boxSizing: 'border-box',\n ...style,\n };\n let body: ReactNode;\n switch (archetype) {\n case 'panel.list':\n body = rows([0, 1, 2, 3, 4].map((key) => ({ key, height: 14 })));\n break;\n case 'panel.tree':\n body = rows([0, 1, 2, 3, 4].map((key) => ({ key, height: 14, marginLeft: (key % 3) * 16 })));\n break;\n case 'panel.editor':\n body = rows([62, 88, 73, 41, 80].map((w, key) => ({ key, height: 11, width: `${w}%` })));\n break;\n case 'panel.conversation':\n body = rows(\n [0, 1, 2, 3].map((key) => ({\n key,\n height: 40,\n width: '70%',\n borderRadius: 12,\n alignSelf: key % 2 ? 'flex-end' : 'flex-start',\n })),\n );\n break;\n case 'generic':\n default:\n body = (\n <>\n <div\n className=\"ir-sdk-shim\"\n aria-hidden=\"true\"\n style={{ ...PLACEHOLDER, height: 16, width: '45%', borderRadius: 4 }}\n />\n {rows([0, 1].map((key) => ({ key, height: 56, borderRadius: 8 })))}\n </>\n );\n }\n return (\n <div aria-hidden=\"true\" style={wrap}>\n {body}\n </div>\n );\n}\n\n/** Become true after `ms`, so a fast wait never flashes an indicator (§6.2 floor). */\nfunction useDelayedFlag(ms: number): boolean {\n const [on, setOn] = useState(false);\n useEffect(() => {\n const t = setTimeout(() => setOn(true), ms);\n return () => clearTimeout(t);\n }, [ms]);\n return on;\n}\n\n/** An indeterminate spinner for waits where a shaped skeleton doesn't fit (a pending\n * button, a small inline fetch). Wired to the host's ~150 ms-before-spin rule: it\n * renders nothing until the threshold, so a fast wait shows no flash. Reduced motion\n * stills the rotation (the ring stays as a static indicator). In-app a11y only. */\nexport function Spinner({\n size = 18,\n thresholdMs = LOADING_TIMINGS.spinThresholdMs,\n label = 'Loading',\n}: {\n size?: number;\n thresholdMs?: number;\n label?: string;\n}) {\n useLoadingStyles();\n const show = useDelayedFlag(thresholdMs);\n if (!show) return null;\n return (\n <span\n className=\"ir-sdk-spin\"\n role=\"status\"\n aria-label={label}\n style={{\n display: 'inline-block',\n width: size,\n height: size,\n border: '2px solid rgba(127,127,127,0.3)',\n borderTopColor: 'currentColor',\n borderRadius: '50%',\n boxSizing: 'border-box',\n }}\n />\n );\n}\n\n/** Wrap an in-app region whose content is still loading: shows a centered spinner\n * (past the 150 ms floor) with `aria-busy`, then reveals `children`. For a shaped\n * wait, pass a `<Skeleton>` as `fallback` instead. App a11y only — not host chrome. */\nexport function LoadingRegion({\n loading,\n fallback,\n label = 'Loading',\n children,\n}: {\n loading: boolean;\n fallback?: ReactNode;\n label?: string;\n children?: ReactNode;\n}) {\n useLoadingStyles();\n if (!loading) return <>{children}</>;\n return (\n <div\n aria-busy=\"true\"\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: '100%',\n minHeight: 48,\n }}\n >\n {fallback ?? <Spinner label={label} />}\n </div>\n );\n}\n"],"mappings":";AA+ES,SAgDD,UAhDC,KAgDD,YAhDC;AA5DT,SAAS,WAAW,iBAAiB,gBAAoD;AAIlF,MAAM,kBAAkB;AAAA;AAAA,EAE7B,iBAAiB;AAAA;AAAA,EAEjB,QAAQ;AAAA;AAAA,EAER,WAAW;AACb;AAKA,MAAM,WAAW;AACjB,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA,2MAIwL,gBAAgB,SAAS;AAAA;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M,QAAO;AAClB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,OAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,WAAW;AAAA,MACb;AAAA;AAAA,EACF;AAEJ;AAKO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAKG;AACD,mBAAiB;AACjB,MAAI,CAAC,QAAS,QAAO,gCAAG,UAAS;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,WAAW;AAAA,MACb;AAAA,MAEC,sBAAY,oBAAC,WAAQ,OAAc;AAAA;AAAA,EACtC;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../src/loading.tsx"],"sourcesContent":["// In-app loading primitives (LOADING_UX_SPEC §9, Surface E; design brief 19).\n//\n// Opt-in, presentational components an app author drops in for IN-APP waits (a\n// React.lazy chunk, a slow fetch, a pending action) so they match the platform's\n// loading language for free. Per product_values §3 this is convenience — a plain\n// app that ignores it still works.\n//\n// TRUST BOUNDARY (read brief 19): these render INSIDE the app's iframe, under the\n// app's principal — presentational only, NO capability, NO host round-trip. They\n// share the token VOCABULARY (radii, the shimmer sweep, soft placeholder fills)\n// with the host skeletons, but they are deliberately NOT the host's trusted chrome:\n// no reserved landmark, no wordmark, no \"platform is loading\" framing. They use\n// ordinary app a11y (`aria-hidden` for decorative skeletons, `role=\"status\"` for an\n// indeterminate indicator) — never the host's reserved landmark/accessible name\n// (that is the trusted-path control, reserved to the host). An in-app loader that\n// mimicked host chrome would be a spoofing vector.\n//\n// Self-contained: the SDK ships no CSS pipeline, so the keyframes are injected once\n// into the document and everything else is inline styles — zero config for the author.\nimport { useEffect, useLayoutEffect, useState, type CSSProperties, type ReactNode } from 'react';\nimport { ensureStyleElement } from './styleElement';\n\n/** Loading timing constants, matching the host (LOADING_UX_SPEC §3, the 2026-06-22\n * design bundle). Exported so authors who hand-roll still match the platform. */\nexport const LOADING_TIMINGS = {\n /** Below this, NO spinner appears — a fast wait never flashes one (§6.2 floor). */\n spinThresholdMs: 150,\n /** The reveal cross-fade duration the host uses. */\n fadeMs: 150,\n /** One slow shimmer sweep across a placeholder. */\n shimmerMs: 1900,\n} as const;\n\n/** The in-app skeleton archetypes (the same shapes as the host §4.1 catalog). */\nexport type SkeletonArchetype = 'panel.list' | 'panel.tree' | 'panel.editor' | 'panel.conversation' | 'generic';\n\nconst STYLE_ID = 'ir-sdk-loading-styles';\nconst STYLE_TEXT = `\n@keyframes ir-sdk-sweep{0%{transform:translateX(-130%)}60%,100%{transform:translateX(130%)}}\n@keyframes ir-sdk-spin{to{transform:rotate(360deg)}}\n.ir-sdk-shim{position:relative;overflow:hidden}\n.ir-sdk-shim::after{content:\"\";position:absolute;inset:0;background:linear-gradient(100deg,transparent 28%,rgba(127,127,127,.18) 50%,transparent 72%);transform:translateX(-130%);animation:ir-sdk-sweep ${LOADING_TIMINGS.shimmerMs}ms ease-in-out infinite}\n.ir-sdk-spin{animation:ir-sdk-spin .8s linear infinite}\n@media (prefers-reduced-motion:reduce){.ir-sdk-shim::after{display:none}.ir-sdk-spin{animation:none}}\n`;\n\n/** Inject the shimmer/spin keyframes once (idempotent, browser-only). */\nfunction ensureLoadingStyles(): void {\n ensureStyleElement(STYLE_ID, STYLE_TEXT);\n}\n\n/** Ensure the loading keyframes exist before the component paints. */\nfunction useLoadingStyles(): void {\n useLayoutEffect(() => {\n ensureLoadingStyles();\n }, []);\n}\n\n// A soft, low-contrast placeholder fill that reads on a light OR dark app surface.\nconst PLACEHOLDER: CSSProperties = {\n background: 'rgba(127,127,127,0.20)',\n borderRadius: 6,\n};\n\n/** A single placeholder bar — compose these into a custom skeleton shape. */\nexport function SkeletonRow({\n width = '100%',\n height = 12,\n style,\n}: {\n width?: number | string;\n height?: number | string;\n style?: CSSProperties;\n}) {\n useLoadingStyles();\n return <div className=\"ir-sdk-shim\" aria-hidden=\"true\" style={{ ...PLACEHOLDER, width, height, ...style }} />;\n}\n\nfunction rows(specs: Array<CSSProperties & { key: number }>): ReactNode {\n return specs.map(({ key, ...s }) => (\n <div key={key} className=\"ir-sdk-shim\" aria-hidden=\"true\" style={{ ...PLACEHOLDER, ...s }} />\n ));\n}\n\n/** A shaped, in-app skeleton matching the host archetypes — for an app's own lazy\n * region (e.g. `<Suspense fallback={<Skeleton archetype=\"panel.list\" />}>`).\n * Decorative (`aria-hidden`); pair it with `aria-busy` on the region it stands in. */\nexport function Skeleton({ archetype = 'generic', style }: { archetype?: SkeletonArchetype; style?: CSSProperties }) {\n useLoadingStyles();\n const wrap: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n gap: 10,\n padding: 12,\n width: '100%',\n boxSizing: 'border-box',\n ...style,\n };\n let body: ReactNode;\n switch (archetype) {\n case 'panel.list':\n body = rows([0, 1, 2, 3, 4].map((key) => ({ key, height: 14 })));\n break;\n case 'panel.tree':\n body = rows([0, 1, 2, 3, 4].map((key) => ({ key, height: 14, marginLeft: (key % 3) * 16 })));\n break;\n case 'panel.editor':\n body = rows([62, 88, 73, 41, 80].map((w, key) => ({ key, height: 11, width: `${w}%` })));\n break;\n case 'panel.conversation':\n body = rows(\n [0, 1, 2, 3].map((key) => ({\n key,\n height: 40,\n width: '70%',\n borderRadius: 12,\n alignSelf: key % 2 ? 'flex-end' : 'flex-start',\n })),\n );\n break;\n case 'generic':\n default:\n body = (\n <>\n <div\n className=\"ir-sdk-shim\"\n aria-hidden=\"true\"\n style={{ ...PLACEHOLDER, height: 16, width: '45%', borderRadius: 4 }}\n />\n {rows([0, 1].map((key) => ({ key, height: 56, borderRadius: 8 })))}\n </>\n );\n }\n return (\n <div aria-hidden=\"true\" style={wrap}>\n {body}\n </div>\n );\n}\n\n/** Become true after `ms`, so a fast wait never flashes an indicator (§6.2 floor). */\nfunction useDelayedFlag(ms: number): boolean {\n const [on, setOn] = useState(false);\n useEffect(() => {\n const t = setTimeout(() => setOn(true), ms);\n return () => clearTimeout(t);\n }, [ms]);\n return on;\n}\n\n/** An indeterminate spinner for waits where a shaped skeleton doesn't fit (a pending\n * button, a small inline fetch). Wired to the host's ~150 ms-before-spin rule: it\n * renders nothing until the threshold, so a fast wait shows no flash. Reduced motion\n * stills the rotation (the ring stays as a static indicator). In-app a11y only. */\nexport function Spinner({\n size = 18,\n thresholdMs = LOADING_TIMINGS.spinThresholdMs,\n label = 'Loading',\n}: {\n size?: number;\n thresholdMs?: number;\n label?: string;\n}) {\n useLoadingStyles();\n const show = useDelayedFlag(thresholdMs);\n if (!show) return null;\n return (\n <span\n className=\"ir-sdk-spin\"\n role=\"status\"\n aria-label={label}\n style={{\n display: 'inline-block',\n width: size,\n height: size,\n border: '2px solid rgba(127,127,127,0.3)',\n borderTopColor: 'currentColor',\n borderRadius: '50%',\n boxSizing: 'border-box',\n }}\n />\n );\n}\n\n/** Wrap an in-app region whose content is still loading: shows a centered spinner\n * (past the 150 ms floor) with `aria-busy`, then reveals `children`. For a shaped\n * wait, pass a `<Skeleton>` as `fallback` instead. App a11y only — not host chrome. */\nexport function LoadingRegion({\n loading,\n fallback,\n label = 'Loading',\n children,\n}: {\n loading: boolean;\n fallback?: ReactNode;\n label?: string;\n children?: ReactNode;\n}) {\n useLoadingStyles();\n if (!loading) return <>{children}</>;\n return (\n <div\n aria-busy=\"true\"\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: '100%',\n minHeight: 48,\n }}\n >\n {fallback ?? <Spinner label={label} />}\n </div>\n );\n}\n"],"mappings":";AA2ES,SAgDD,UAhDC,KAgDD,YAhDC;AAxDT,SAAS,WAAW,iBAAiB,gBAAoD;A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IG;AACD,mBAAiB;AACjB,QAAM,OAAO,eAAe,WAAW;AACvC,MAAI,CAAC,KAAM,QAAO;AAClB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,OAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,WAAW;AAAA,MACb;AAAA;AAAA,EACF;AAEJ;AAKO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAKG;AACD,mBAAiB;AACjB,MAAI,CAAC,QAAS,QAAO,gCAAG,UAAS;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,WAAW;AAAA,MACb;AAAA,MAEC,sBAAY,oBAAC,WAAQ,OAAc;AAAA;AAAA,EACtC;AAEJ;","names":[]}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var proseStyles_exports = {};
20
+ __export(proseStyles_exports, {
21
+ PROSE_CLASS: () => PROSE_CLASS,
22
+ PROSE_STYLE_ID: () => PROSE_STYLE_ID,
23
+ PROSE_STYLE_TEXT: () => PROSE_STYLE_TEXT,
24
+ PROSE_TOKENS: () => PROSE_TOKENS,
25
+ ensureProseStyles: () => ensureProseStyles,
26
+ isProseFile: () => isProseFile
27
+ });
28
+ module.exports = __toCommonJS(proseStyles_exports);
29
+ var import_styleElement = require("./styleElement");
30
+ const PROSE_CLASS = "ir-prose";
31
+ const PROSE_STYLE_ID = "ir-sdk-prose-styles";
32
+ const SANS = 'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif';
33
+ const MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace';
34
+ const same = (name, value) => ({ name, light: value, dark: value });
35
+ const PROSE_TOKENS = [
36
+ same("bg", "transparent"),
37
+ { name: "ink", light: "#1f2328", dark: "#d6dae0" },
38
+ { name: "ink-2", light: "#59636e", dark: "#8b949e" },
39
+ { name: "ink-3", light: "#8c959f", dark: "#6e7681" },
40
+ { name: "line", light: "#d8dee4", dark: "#2a2f37" },
41
+ { name: "panel", light: "#f3f4f6", dark: "#1a1e24" },
42
+ { name: "accent", light: "#0969da", dark: "#6cb6ff" },
43
+ same("sans", SANS),
44
+ same("disp", "var(--sans, var(--_ir-sans))"),
45
+ same("mono", MONO),
46
+ same("disp-weight", "700"),
47
+ same("prose-measure", "68ch"),
48
+ same("prose-leading", "1.65"),
49
+ same("page-gutter", "clamp(1.25rem, 5vw, 3rem)"),
50
+ same("radius-shape", "8px"),
51
+ same("prose-size", "1.0625rem"),
52
+ same("prose-flow", "1.1em")
53
+ ];
54
+ const t = (name) => `var(--${name}, var(--_ir-${name}))`;
55
+ const declarations = (pick, only) => PROSE_TOKENS.filter(only ?? (() => true)).map((token) => `--_ir-${token.name}: ${pick(token)};`).join(" ");
56
+ const P = `.${PROSE_CLASS}`;
57
+ const GUTTER_ANCHOR_MIN_WIDTH = "48rem";
58
+ const HEADINGS = ":is(h1, h2, h3, h4, h5, h6)";
59
+ const PROSE_STYLE_TEXT = `@layer ir.defaults {
60
+ ${P} { ${declarations((token) => token.light)} }
61
+ ${P}[data-theme="dark"] { ${declarations(
62
+ (token) => token.dark,
63
+ (token) => token.dark !== token.light
64
+ )} }
65
+ ${P} {
66
+ box-sizing: border-box;
67
+ min-height: 100dvh;
68
+ background: ${t("bg")};
69
+ color: ${t("ink")};
70
+ font: 400 ${t("prose-size")} / ${t("prose-leading")} ${t("sans")};
71
+ font-kerning: normal;
72
+ -webkit-font-smoothing: antialiased;
73
+ overflow-wrap: break-word;
74
+ padding-block: clamp(1.5rem, 6vw, 4rem) 6rem;
75
+ display: grid;
76
+ align-content: start;
77
+ grid-template-columns:
78
+ minmax(${t("page-gutter")}, 1fr)
79
+ min(${t("prose-measure")}, 100% - 2 * ${t("page-gutter")})
80
+ minmax(${t("page-gutter")}, 1fr);
81
+ }
82
+ ${P} > * { grid-column: 2; min-inline-size: 0; margin-block: 0; }
83
+ ${P} > * + * { margin-block-start: ${t("prose-flow")}; }
84
+
85
+ ${P} ${HEADINGS} {
86
+ position: relative;
87
+ font-family: ${t("disp")};
88
+ font-weight: ${t("disp-weight")};
89
+ color: ${t("ink")};
90
+ line-height: 1.25;
91
+ letter-spacing: -0.011em;
92
+ text-wrap: balance;
93
+ scroll-margin-top: 1.5rem;
94
+ }
95
+ ${P} h1 { font-size: 2.25em; letter-spacing: -0.022em; line-height: 1.15; }
96
+ ${P} h2 { font-size: 1.5em; padding-block-end: 0.3em; border-block-end: 1px solid ${t("line")}; }
97
+ ${P} h3 { font-size: 1.2em; }
98
+ ${P} h4 { font-size: 1em; }
99
+ ${P} :is(h5, h6) { font-size: 0.875em; text-transform: uppercase; letter-spacing: 0.04em; color: ${t("ink-2")}; }
100
+ ${P} > ${HEADINGS}:not(:first-child) { margin-block-start: 2.2em; }
101
+ ${P} > :is(h1, h2, h3, h4) + * { margin-block-start: 0.7em; }
102
+
103
+ ${P} .ir-heading-anchor { color: ${t("ink-3")}; text-decoration: none; font-weight: 400; }
104
+ ${P} .ir-heading-anchor:hover { color: ${t("accent")}; }
105
+ @media (hover: hover) and (width >= ${GUTTER_ANCHOR_MIN_WIDTH}) {
106
+ ${P} .ir-heading-anchor {
107
+ position: absolute;
108
+ inset-inline-end: 100%;
109
+ inline-size: 1.2em;
110
+ padding-inline-end: 0.35em;
111
+ text-align: end;
112
+ opacity: 0;
113
+ transition: opacity 120ms ease;
114
+ }
115
+ ${P} ${HEADINGS}:hover .ir-heading-anchor,
116
+ ${P} .ir-heading-anchor:focus-visible { opacity: 1; }
117
+ }
118
+ @media (hover: none), (width < ${GUTTER_ANCHOR_MIN_WIDTH}) {
119
+ ${P} .ir-heading-anchor {
120
+ float: inline-end;
121
+ min-inline-size: 24px;
122
+ min-block-size: 24px;
123
+ margin-inline-start: 0.5em;
124
+ text-align: center;
125
+ font-size: 0.8em;
126
+ opacity: 0.45;
127
+ }
128
+ }
129
+
130
+ ${P} a { color: ${t(
131
+ "accent"
132
+ )}; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
133
+ ${P} strong { font-weight: 650; }
134
+ ${P} :not(pre) > code {
135
+ font-family: ${t("mono")};
136
+ font-size: 0.86em;
137
+ background: ${t("panel")};
138
+ padding: 0.12em 0.36em;
139
+ border-radius: 5px;
140
+ }
141
+ ${P} a code { color: inherit; }
142
+ ${P} pre {
143
+ font-family: ${t("mono")};
144
+ font-size: 0.85em;
145
+ line-height: 1.55;
146
+ background: ${t("panel")};
147
+ padding: 1em 1.2em;
148
+ border-radius: ${t("radius-shape")};
149
+ overflow-x: auto;
150
+ tab-size: 2;
151
+ }
152
+ ${P} pre code { font: inherit; background: none; padding: 0; }
153
+ ${P} :is(ul, ol) { padding-inline-start: 1.5em; }
154
+ ${P} li + li, ${P} li > :is(ul, ol) { margin-block-start: 0.35em; }
155
+ ${P} li::marker { color: ${t("ink-2")}; }
156
+ ${P} li.task-list-item { list-style: none; margin-inline-start: -1.3em; }
157
+ ${P} input[type="checkbox"] { margin-inline-end: 0.5em; accent-color: ${t("accent")}; }
158
+ ${P} blockquote { padding-inline-start: 1em; border-inline-start: 3px solid ${t("line")}; color: ${t("ink-2")}; }
159
+ ${P} hr { border: 0; border-block-start: 1px solid ${t("line")}; }
160
+ ${P} > hr, ${P} > hr + * { margin-block-start: calc(2.5 * ${t("prose-size")}); }
161
+ ${P} > hr + ${HEADINGS}:not(:first-child) { margin-block-start: max(2.2em, 2.5 * ${t("prose-size")}); }
162
+ ${P} :is(img, video) { max-width: 100%; height: auto; border-radius: ${t("radius-shape")}; }
163
+ ${P} table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 0.94em; font-variant-numeric: tabular-nums; }
164
+ ${P} :is(th, td) { padding: 0.45em 0.8em; border: 1px solid ${t("line")}; text-align: start; }
165
+ ${P} th { background: ${t("panel")}; }
166
+ }
167
+ `;
168
+ const isProseFile = (path) => /\.mdx?$/i.test(path);
169
+ function ensureProseStyles() {
170
+ (0, import_styleElement.ensureStyleElement)(PROSE_STYLE_ID, PROSE_STYLE_TEXT, { first: true });
171
+ }
172
+ // Annotate the CommonJS export names for ESM import in node:
173
+ 0 && (module.exports = {
174
+ PROSE_CLASS,
175
+ PROSE_STYLE_ID,
176
+ PROSE_STYLE_TEXT,
177
+ PROSE_TOKENS,
178
+ ensureProseStyles,
179
+ isProseFile
180
+ });
181
+ //# sourceMappingURL=proseStyles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/proseStyles.ts"],"sourcesContent":["// The default typography for rendered Markdown (MARKDOWN_SYNTAX_SPEC §16).\n//\n// A published library cannot `import './prose.css'` — the sandbox bundler evaluates a\n// dist CSS import as JavaScript — so the stylesheet is text generated here and injected\n// once through `ensureStyleElement`, the guard `loading.tsx` shares.\n\n//\n// Two properties carry the design:\n// - every rule sits in `@layer ir.defaults`, so any unlayered author rule beats it\n// whatever its specificity, with no `!important` on either side;\n// - the public tokens (Grove's names, 02-theme-contract §2) are only ever READ, as\n// `var(--ink, var(--_ir-ink))`. The defaults live in private `--_ir-*` properties.\n// An app or theme that already defines `--ink` higher in the tree therefore flows\n// into its prose, and an author's value set on the article wins over the default.\n\nimport { ensureStyleElement } from './styleElement';\n\n/** The class on the element that wraps rendered Markdown. */\nexport const PROSE_CLASS = 'ir-prose';\n\n/** The id of the injected `<style>` element (one per document). */\nexport const PROSE_STYLE_ID = 'ir-sdk-prose-styles';\n\n/** One public token: its name (no leading dashes) and its default per polarity. */\nexport interface ProseToken {\n readonly name: string;\n readonly light: string;\n readonly dark: string;\n}\n\nconst SANS = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif';\nconst MONO = 'ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, Consolas, monospace';\n\n/** Both polarities share one value. */\nconst same = (name: string, value: string): ProseToken => ({ name, light: value, dark: value });\n\n/**\n * The token table — the one home of every name an author may set (the author token file\n * reads its allow-list from here). Names are Grove's wherever Grove has one with the same\n * meaning; `prose-size` and `prose-flow` are the only new ones.\n *\n * `bg` defaults to transparent because the sandbox already paints `<html>` per polarity\n * (sandbox `themeCanvas.ts`); repeating its colours here would be a second copy.\n */\nexport const PROSE_TOKENS: readonly ProseToken[] = [\n same('bg', 'transparent'),\n { name: 'ink', light: '#1f2328', dark: '#d6dae0' },\n { name: 'ink-2', light: '#59636e', dark: '#8b949e' },\n { name: 'ink-3', light: '#8c959f', dark: '#6e7681' },\n { name: 'line', light: '#d8dee4', dark: '#2a2f37' },\n { name: 'panel', light: '#f3f4f6', dark: '#1a1e24' },\n { name: 'accent', light: '#0969da', dark: '#6cb6ff' },\n same('sans', SANS),\n same('disp', 'var(--sans, var(--_ir-sans))'),\n same('mono', MONO),\n same('disp-weight', '700'),\n same('prose-measure', '68ch'),\n same('prose-leading', '1.65'),\n same('page-gutter', 'clamp(1.25rem, 5vw, 3rem)'),\n same('radius-shape', '8px'),\n same('prose-size', '1.0625rem'),\n same('prose-flow', '1.1em'),\n];\n\n/** Read a public token with its private default behind it. */\nconst t = (name: string): string => `var(--${name}, var(--_ir-${name}))`;\n\nconst declarations = (pick: (token: ProseToken) => string, only?: (token: ProseToken) => boolean): string =>\n PROSE_TOKENS.filter(only ?? (() => true))\n .map((token) => `--_ir-${token.name}: ${pick(token)};`)\n .join(' ');\n\nconst P = `.${PROSE_CLASS}`;\n\n/**\n * The narrowest viewport that keeps the heading anchor in the gutter. Below it the side\n * column shrinks to `--page-gutter` (20px), narrower than an h1's `#`, so the anchor\n * floats to the line end as on touch devices instead of being clipped at the edge.\n */\nconst GUTTER_ANCHOR_MIN_WIDTH = '48rem';\nconst HEADINGS = ':is(h1, h2, h3, h4, h5, h6)';\n\n/** The whole default stylesheet. */\nexport const PROSE_STYLE_TEXT = `@layer ir.defaults {\n${P} { ${declarations((token) => token.light)} }\n${P}[data-theme=\"dark\"] { ${declarations(\n (token) => token.dark,\n (token) => token.dark !== token.light,\n)} }\n${P} {\n box-sizing: border-box;\n min-height: 100dvh;\n background: ${t('bg')};\n color: ${t('ink')};\n font: 400 ${t('prose-size')} / ${t('prose-leading')} ${t('sans')};\n font-kerning: normal;\n -webkit-font-smoothing: antialiased;\n overflow-wrap: break-word;\n padding-block: clamp(1.5rem, 6vw, 4rem) 6rem;\n display: grid;\n align-content: start;\n grid-template-columns:\n minmax(${t('page-gutter')}, 1fr)\n min(${t('prose-measure')}, 100% - 2 * ${t('page-gutter')})\n minmax(${t('page-gutter')}, 1fr);\n}\n${P} > * { grid-column: 2; min-inline-size: 0; margin-block: 0; }\n${P} > * + * { margin-block-start: ${t('prose-flow')}; }\n\n${P} ${HEADINGS} {\n position: relative;\n font-family: ${t('disp')};\n font-weight: ${t('disp-weight')};\n color: ${t('ink')};\n line-height: 1.25;\n letter-spacing: -0.011em;\n text-wrap: balance;\n scroll-margin-top: 1.5rem;\n}\n${P} h1 { font-size: 2.25em; letter-spacing: -0.022em; line-height: 1.15; }\n${P} h2 { font-size: 1.5em; padding-block-end: 0.3em; border-block-end: 1px solid ${t('line')}; }\n${P} h3 { font-size: 1.2em; }\n${P} h4 { font-size: 1em; }\n${P} :is(h5, h6) { font-size: 0.875em; text-transform: uppercase; letter-spacing: 0.04em; color: ${t('ink-2')}; }\n${P} > ${HEADINGS}:not(:first-child) { margin-block-start: 2.2em; }\n${P} > :is(h1, h2, h3, h4) + * { margin-block-start: 0.7em; }\n\n${P} .ir-heading-anchor { color: ${t('ink-3')}; text-decoration: none; font-weight: 400; }\n${P} .ir-heading-anchor:hover { color: ${t('accent')}; }\n@media (hover: hover) and (width >= ${GUTTER_ANCHOR_MIN_WIDTH}) {\n ${P} .ir-heading-anchor {\n position: absolute;\n inset-inline-end: 100%;\n inline-size: 1.2em;\n padding-inline-end: 0.35em;\n text-align: end;\n opacity: 0;\n transition: opacity 120ms ease;\n }\n ${P} ${HEADINGS}:hover .ir-heading-anchor,\n ${P} .ir-heading-anchor:focus-visible { opacity: 1; }\n}\n@media (hover: none), (width < ${GUTTER_ANCHOR_MIN_WIDTH}) {\n ${P} .ir-heading-anchor {\n float: inline-end;\n min-inline-size: 24px;\n min-block-size: 24px;\n margin-inline-start: 0.5em;\n text-align: center;\n font-size: 0.8em;\n opacity: 0.45;\n }\n}\n\n${P} a { color: ${t(\n 'accent',\n)}; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }\n${P} strong { font-weight: 650; }\n${P} :not(pre) > code {\n font-family: ${t('mono')};\n font-size: 0.86em;\n background: ${t('panel')};\n padding: 0.12em 0.36em;\n border-radius: 5px;\n}\n${P} a code { color: inherit; }\n${P} pre {\n font-family: ${t('mono')};\n font-size: 0.85em;\n line-height: 1.55;\n background: ${t('panel')};\n padding: 1em 1.2em;\n border-radius: ${t('radius-shape')};\n overflow-x: auto;\n tab-size: 2;\n}\n${P} pre code { font: inherit; background: none; padding: 0; }\n${P} :is(ul, ol) { padding-inline-start: 1.5em; }\n${P} li + li, ${P} li > :is(ul, ol) { margin-block-start: 0.35em; }\n${P} li::marker { color: ${t('ink-2')}; }\n${P} li.task-list-item { list-style: none; margin-inline-start: -1.3em; }\n${P} input[type=\"checkbox\"] { margin-inline-end: 0.5em; accent-color: ${t('accent')}; }\n${P} blockquote { padding-inline-start: 1em; border-inline-start: 3px solid ${t('line')}; color: ${t('ink-2')}; }\n${P} hr { border: 0; border-block-start: 1px solid ${t('line')}; }\n${P} > hr, ${P} > hr + * { margin-block-start: calc(2.5 * ${t('prose-size')}); }\n${P} > hr + ${HEADINGS}:not(:first-child) { margin-block-start: max(2.2em, 2.5 * ${t('prose-size')}); }\n${P} :is(img, video) { max-width: 100%; height: auto; border-radius: ${t('radius-shape')}; }\n${P} table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 0.94em; font-variant-numeric: tabular-nums; }\n${P} :is(th, td) { padding: 0.45em 0.8em; border: 1px solid ${t('line')}; text-align: start; }\n${P} th { background: ${t('panel')}; }\n}\n`;\n\n/** Markdown and MDX files get the prose wrapper; app components and HTML do not. The\n * extensions are the ones the transpiler compiles as MDX (`.md`, `.mdx`); a `.markdown`\n * file is not compiled, so wrapping it would style nothing it renders. */\nexport const isProseFile = (path: string): boolean => /\\.mdx?$/i.test(path);\n\n/**\n * Inject the default stylesheet once per document (idempotent, browser-only).\n *\n * It goes FIRST in `<head>`. Cascade layers rank by the order they first appear, later\n * layers winning, so a sheet appended after an app's own CSS would rank `ir.defaults`\n * above the app's layered rules (Tailwind's `base`/`components`/`utilities`, say).\n * First in the document makes it the lowest layer; unlayered rules beat it either way.\n */\nexport function ensureProseStyles(): void {\n ensureStyleElement(PROSE_STYLE_ID, PROSE_STYLE_TEXT, { first: true });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,0BAAmC;AAG5B,MAAM,cAAc;AAGpB,MAAM,i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ACD,CAAC;AAAA,iBACc,EAAE,MAAM,CAAC;AAAA;AAAA,gBAEV,EAAE,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA,EAIxB,CAAC;AAAA,EACD,CAAC;AAAA,iBACc,EAAE,MAAM,CAAC;AAAA;AAAA;AAAA,gBAGV,EAAE,OAAO,CAAC;AAAA;AAAA,mBAEP,EAAE,cAAc,CAAC;AAAA;AAAA;AAAA;AAAA,EAIlC,CAAC;AAAA,EACD,CAAC;AAAA,EACD,CAAC,aAAa,CAAC;AAAA,EACf,CAAC,wBAAwB,EAAE,OAAO,CAAC;AAAA,EACnC,CAAC;AAAA,EACD,CAAC,qEAAqE,EAAE,QAAQ,CAAC;AAAA,EACjF,CAAC,2EAA2E,EAAE,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC;AAAA,EAC3G,CAAC,kDAAkD,EAAE,MAAM,CAAC;AAAA,EAC5D,CAAC,UAAU,CAAC,8CAA8C,EAAE,YAAY,CAAC;AAAA,EACzE,CAAC,WAAW,QAAQ,6DAA6D,EAAE,YAAY,CAAC;AAAA,EAChG,CAAC,oEAAoE,EAAE,cAAc,CAAC;AAAA,EACtF,CAAC;AAAA,EACD,CAAC,2DAA2D,EAAE,MAAM,CAAC;AAAA,EACrE,CAAC,qBAAqB,EAAE,OAAO,CAAC;AAAA;AAAA;AAO3B,MAAM,cAAc,CAAC,SAA0B,WAAW,KAAK,IAAI;AAUnE,SAAS,oBAA0B;AACxC,8CAAmB,gBAAgB,kBAAkB,EAAE,OAAO,KAAK,CAAC;AACtE;","names":[]}
@@ -0,0 +1,36 @@
1
+ /** The class on the element that wraps rendered Markdown. */
2
+ declare const PROSE_CLASS = "ir-prose";
3
+ /** The id of the injected `<style>` element (one per document). */
4
+ declare const PROSE_STYLE_ID = "ir-sdk-prose-styles";
5
+ /** One public token: its name (no leading dashes) and its default per polarity. */
6
+ interface ProseToken {
7
+ readonly name: string;
8
+ readonly light: string;
9
+ readonly dark: string;
10
+ }
11
+ /**
12
+ * The token table — the one home of every name an author may set (the author token file
13
+ * reads its allow-list from here). Names are Grove's wherever Grove has one with the same
14
+ * meaning; `prose-size` and `prose-flow` are the only new ones.
15
+ *
16
+ * `bg` defaults to transparent because the sandbox already paints `<html>` per polarity
17
+ * (sandbox `themeCanvas.ts`); repeating its colours here would be a second copy.
18
+ */
19
+ declare const PROSE_TOKENS: readonly ProseToken[];
20
+ /** The whole default stylesheet. */
21
+ declare const PROSE_STYLE_TEXT: string;
22
+ /** Markdown and MDX files get the prose wrapper; app components and HTML do not. The
23
+ * extensions are the ones the transpiler compiles as MDX (`.md`, `.mdx`); a `.markdown`
24
+ * file is not compiled, so wrapping it would style nothing it renders. */
25
+ declare const isProseFile: (path: string) => boolean;
26
+ /**
27
+ * Inject the default stylesheet once per document (idempotent, browser-only).
28
+ *
29
+ * It goes FIRST in `<head>`. Cascade layers rank by the order they first appear, later
30
+ * layers winning, so a sheet appended after an app's own CSS would rank `ir.defaults`
31
+ * above the app's layered rules (Tailwind's `base`/`components`/`utilities`, say).
32
+ * First in the document makes it the lowest layer; unlayered rules beat it either way.
33
+ */
34
+ declare function ensureProseStyles(): void;
35
+
36
+ export { PROSE_CLASS, PROSE_STYLE_ID, PROSE_STYLE_TEXT, PROSE_TOKENS, type ProseToken, ensureProseStyles, isProseFile };
@@ -0,0 +1,36 @@
1
+ /** The class on the element that wraps rendered Markdown. */
2
+ declare const PROSE_CLASS = "ir-prose";
3
+ /** The id of the injected `<style>` element (one per document). */
4
+ declare const PROSE_STYLE_ID = "ir-sdk-prose-styles";
5
+ /** One public token: its name (no leading dashes) and its default per polarity. */
6
+ interface ProseToken {
7
+ readonly name: string;
8
+ readonly light: string;
9
+ readonly dark: string;
10
+ }
11
+ /**
12
+ * The token table — the one home of every name an author may set (the author token file
13
+ * reads its allow-list from here). Names are Grove's wherever Grove has one with the same
14
+ * meaning; `prose-size` and `prose-flow` are the only new ones.
15
+ *
16
+ * `bg` defaults to transparent because the sandbox already paints `<html>` per polarity
17
+ * (sandbox `themeCanvas.ts`); repeating its colours here would be a second copy.
18
+ */
19
+ declare const PROSE_TOKENS: readonly ProseToken[];
20
+ /** The whole default stylesheet. */
21
+ declare const PROSE_STYLE_TEXT: string;
22
+ /** Markdown and MDX files get the prose wrapper; app components and HTML do not. The
23
+ * extensions are the ones the transpiler compiles as MDX (`.md`, `.mdx`); a `.markdown`
24
+ * file is not compiled, so wrapping it would style nothing it renders. */
25
+ declare const isProseFile: (path: string) => boolean;
26
+ /**
27
+ * Inject the default stylesheet once per document (idempotent, browser-only).
28
+ *
29
+ * It goes FIRST in `<head>`. Cascade layers rank by the order they first appear, later
30
+ * layers winning, so a sheet appended after an app's own CSS would rank `ir.defaults`
31
+ * above the app's layered rules (Tailwind's `base`/`components`/`utilities`, say).
32
+ * First in the document makes it the lowest layer; unlayered rules beat it either way.
33
+ */
34
+ declare function ensureProseStyles(): void;
35
+
36
+ export { PROSE_CLASS, PROSE_STYLE_ID, PROSE_STYLE_TEXT, PROSE_TOKENS, type ProseToken, ensureProseStyles, isProseFile };
@@ -0,0 +1,153 @@
1
+ import "./chunk-VHAA22YE.js";
2
+ import { ensureStyleElement } from "./styleElement.js";
3
+ const PROSE_CLASS = "ir-prose";
4
+ const PROSE_STYLE_ID = "ir-sdk-prose-styles";
5
+ const SANS = 'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif';
6
+ const MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace';
7
+ const same = (name, value) => ({ name, light: value, dark: value });
8
+ const PROSE_TOKENS = [
9
+ same("bg", "transparent"),
10
+ { name: "ink", light: "#1f2328", dark: "#d6dae0" },
11
+ { name: "ink-2", light: "#59636e", dark: "#8b949e" },
12
+ { name: "ink-3", light: "#8c959f", dark: "#6e7681" },
13
+ { name: "line", light: "#d8dee4", dark: "#2a2f37" },
14
+ { name: "panel", light: "#f3f4f6", dark: "#1a1e24" },
15
+ { name: "accent", light: "#0969da", dark: "#6cb6ff" },
16
+ same("sans", SANS),
17
+ same("disp", "var(--sans, var(--_ir-sans))"),
18
+ same("mono", MONO),
19
+ same("disp-weight", "700"),
20
+ same("prose-measure", "68ch"),
21
+ same("prose-leading", "1.65"),
22
+ same("page-gutter", "clamp(1.25rem, 5vw, 3rem)"),
23
+ same("radius-shape", "8px"),
24
+ same("prose-size", "1.0625rem"),
25
+ same("prose-flow", "1.1em")
26
+ ];
27
+ const t = (name) => `var(--${name}, var(--_ir-${name}))`;
28
+ const declarations = (pick, only) => PROSE_TOKENS.filter(only ?? (() => true)).map((token) => `--_ir-${token.name}: ${pick(token)};`).join(" ");
29
+ const P = `.${PROSE_CLASS}`;
30
+ const GUTTER_ANCHOR_MIN_WIDTH = "48rem";
31
+ const HEADINGS = ":is(h1, h2, h3, h4, h5, h6)";
32
+ const PROSE_STYLE_TEXT = `@layer ir.defaults {
33
+ ${P} { ${declarations((token) => token.light)} }
34
+ ${P}[data-theme="dark"] { ${declarations(
35
+ (token) => token.dark,
36
+ (token) => token.dark !== token.light
37
+ )} }
38
+ ${P} {
39
+ box-sizing: border-box;
40
+ min-height: 100dvh;
41
+ background: ${t("bg")};
42
+ color: ${t("ink")};
43
+ font: 400 ${t("prose-size")} / ${t("prose-leading")} ${t("sans")};
44
+ font-kerning: normal;
45
+ -webkit-font-smoothing: antialiased;
46
+ overflow-wrap: break-word;
47
+ padding-block: clamp(1.5rem, 6vw, 4rem) 6rem;
48
+ display: grid;
49
+ align-content: start;
50
+ grid-template-columns:
51
+ minmax(${t("page-gutter")}, 1fr)
52
+ min(${t("prose-measure")}, 100% - 2 * ${t("page-gutter")})
53
+ minmax(${t("page-gutter")}, 1fr);
54
+ }
55
+ ${P} > * { grid-column: 2; min-inline-size: 0; margin-block: 0; }
56
+ ${P} > * + * { margin-block-start: ${t("prose-flow")}; }
57
+
58
+ ${P} ${HEADINGS} {
59
+ position: relative;
60
+ font-family: ${t("disp")};
61
+ font-weight: ${t("disp-weight")};
62
+ color: ${t("ink")};
63
+ line-height: 1.25;
64
+ letter-spacing: -0.011em;
65
+ text-wrap: balance;
66
+ scroll-margin-top: 1.5rem;
67
+ }
68
+ ${P} h1 { font-size: 2.25em; letter-spacing: -0.022em; line-height: 1.15; }
69
+ ${P} h2 { font-size: 1.5em; padding-block-end: 0.3em; border-block-end: 1px solid ${t("line")}; }
70
+ ${P} h3 { font-size: 1.2em; }
71
+ ${P} h4 { font-size: 1em; }
72
+ ${P} :is(h5, h6) { font-size: 0.875em; text-transform: uppercase; letter-spacing: 0.04em; color: ${t("ink-2")}; }
73
+ ${P} > ${HEADINGS}:not(:first-child) { margin-block-start: 2.2em; }
74
+ ${P} > :is(h1, h2, h3, h4) + * { margin-block-start: 0.7em; }
75
+
76
+ ${P} .ir-heading-anchor { color: ${t("ink-3")}; text-decoration: none; font-weight: 400; }
77
+ ${P} .ir-heading-anchor:hover { color: ${t("accent")}; }
78
+ @media (hover: hover) and (width >= ${GUTTER_ANCHOR_MIN_WIDTH}) {
79
+ ${P} .ir-heading-anchor {
80
+ position: absolute;
81
+ inset-inline-end: 100%;
82
+ inline-size: 1.2em;
83
+ padding-inline-end: 0.35em;
84
+ text-align: end;
85
+ opacity: 0;
86
+ transition: opacity 120ms ease;
87
+ }
88
+ ${P} ${HEADINGS}:hover .ir-heading-anchor,
89
+ ${P} .ir-heading-anchor:focus-visible { opacity: 1; }
90
+ }
91
+ @media (hover: none), (width < ${GUTTER_ANCHOR_MIN_WIDTH}) {
92
+ ${P} .ir-heading-anchor {
93
+ float: inline-end;
94
+ min-inline-size: 24px;
95
+ min-block-size: 24px;
96
+ margin-inline-start: 0.5em;
97
+ text-align: center;
98
+ font-size: 0.8em;
99
+ opacity: 0.45;
100
+ }
101
+ }
102
+
103
+ ${P} a { color: ${t(
104
+ "accent"
105
+ )}; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
106
+ ${P} strong { font-weight: 650; }
107
+ ${P} :not(pre) > code {
108
+ font-family: ${t("mono")};
109
+ font-size: 0.86em;
110
+ background: ${t("panel")};
111
+ padding: 0.12em 0.36em;
112
+ border-radius: 5px;
113
+ }
114
+ ${P} a code { color: inherit; }
115
+ ${P} pre {
116
+ font-family: ${t("mono")};
117
+ font-size: 0.85em;
118
+ line-height: 1.55;
119
+ background: ${t("panel")};
120
+ padding: 1em 1.2em;
121
+ border-radius: ${t("radius-shape")};
122
+ overflow-x: auto;
123
+ tab-size: 2;
124
+ }
125
+ ${P} pre code { font: inherit; background: none; padding: 0; }
126
+ ${P} :is(ul, ol) { padding-inline-start: 1.5em; }
127
+ ${P} li + li, ${P} li > :is(ul, ol) { margin-block-start: 0.35em; }
128
+ ${P} li::marker { color: ${t("ink-2")}; }
129
+ ${P} li.task-list-item { list-style: none; margin-inline-start: -1.3em; }
130
+ ${P} input[type="checkbox"] { margin-inline-end: 0.5em; accent-color: ${t("accent")}; }
131
+ ${P} blockquote { padding-inline-start: 1em; border-inline-start: 3px solid ${t("line")}; color: ${t("ink-2")}; }
132
+ ${P} hr { border: 0; border-block-start: 1px solid ${t("line")}; }
133
+ ${P} > hr, ${P} > hr + * { margin-block-start: calc(2.5 * ${t("prose-size")}); }
134
+ ${P} > hr + ${HEADINGS}:not(:first-child) { margin-block-start: max(2.2em, 2.5 * ${t("prose-size")}); }
135
+ ${P} :is(img, video) { max-width: 100%; height: auto; border-radius: ${t("radius-shape")}; }
136
+ ${P} table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 0.94em; font-variant-numeric: tabular-nums; }
137
+ ${P} :is(th, td) { padding: 0.45em 0.8em; border: 1px solid ${t("line")}; text-align: start; }
138
+ ${P} th { background: ${t("panel")}; }
139
+ }
140
+ `;
141
+ const isProseFile = (path) => /\.mdx?$/i.test(path);
142
+ function ensureProseStyles() {
143
+ ensureStyleElement(PROSE_STYLE_ID, PROSE_STYLE_TEXT, { first: true });
144
+ }
145
+ export {
146
+ PROSE_CLASS,
147
+ PROSE_STYLE_ID,
148
+ PROSE_STYLE_TEXT,
149
+ PROSE_TOKENS,
150
+ ensureProseStyles,
151
+ isProseFile
152
+ };
153
+ //# sourceMappingURL=proseStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/proseStyles.ts"],"sourcesContent":["// The default typography for rendered Markdown (MARKDOWN_SYNTAX_SPEC §16).\n//\n// A published library cannot `import './prose.css'` — the sandbox bundler evaluates a\n// dist CSS import as JavaScript — so the stylesheet is text generated here and injected\n// once through `ensureStyleElement`, the guard `loading.tsx` shares.\n\n//\n// Two properties carry the design:\n// - every rule sits in `@layer ir.defaults`, so any unlayered author rule beats it\n// whatever its specificity, with no `!important` on either side;\n// - the public tokens (Grove's names, 02-theme-contract §2) are only ever READ, as\n// `var(--ink, var(--_ir-ink))`. The defaults live in private `--_ir-*` properties.\n// An app or theme that already defines `--ink` higher in the tree therefore flows\n// into its prose, and an author's value set on the article wins over the default.\n\nimport { ensureStyleElement } from './styleElement';\n\n/** The class on the element that wraps rendered Markdown. */\nexport const PROSE_CLASS = 'ir-prose';\n\n/** The id of the injected `<style>` element (one per document). */\nexport const PROSE_STYLE_ID = 'ir-sdk-prose-styles';\n\n/** One public token: its name (no leading dashes) and its default per polarity. */\nexport interface ProseToken {\n readonly name: string;\n readonly light: string;\n readonly dark: string;\n}\n\nconst SANS = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif';\nconst MONO = 'ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, Consolas, monospace';\n\n/** Both polarities share one value. */\nconst same = (name: string, value: string): ProseToken => ({ name, light: value, dark: value });\n\n/**\n * The token table — the one home of every name an author may set (the author token file\n * reads its allow-list from here). Names are Grove's wherever Grove has one with the same\n * meaning; `prose-size` and `prose-flow` are the only new ones.\n *\n * `bg` defaults to transparent because the sandbox already paints `<html>` per polarity\n * (sandbox `themeCanvas.ts`); repeating its colours here would be a second copy.\n */\nexport const PROSE_TOKENS: readonly ProseToken[] = [\n same('bg', 'transparent'),\n { name: 'ink', light: '#1f2328', dark: '#d6dae0' },\n { name: 'ink-2', light: '#59636e', dark: '#8b949e' },\n { name: 'ink-3', light: '#8c959f', dark: '#6e7681' },\n { name: 'line', light: '#d8dee4', dark: '#2a2f37' },\n { name: 'panel', light: '#f3f4f6', dark: '#1a1e24' },\n { name: 'accent', light: '#0969da', dark: '#6cb6ff' },\n same('sans', SANS),\n same('disp', 'var(--sans, var(--_ir-sans))'),\n same('mono', MONO),\n same('disp-weight', '700'),\n same('prose-measure', '68ch'),\n same('prose-leading', '1.65'),\n same('page-gutter', 'clamp(1.25rem, 5vw, 3rem)'),\n same('radius-shape', '8px'),\n same('prose-size', '1.0625rem'),\n same('prose-flow', '1.1em'),\n];\n\n/** Read a public token with its private default behind it. */\nconst t = (name: string): string => `var(--${name}, var(--_ir-${name}))`;\n\nconst declarations = (pick: (token: ProseToken) => string, only?: (token: ProseToken) => boolean): string =>\n PROSE_TOKENS.filter(only ?? (() => true))\n .map((token) => `--_ir-${token.name}: ${pick(token)};`)\n .join(' ');\n\nconst P = `.${PROSE_CLASS}`;\n\n/**\n * The narrowest viewport that keeps the heading anchor in the gutter. Below it the side\n * column shrinks to `--page-gutter` (20px), narrower than an h1's `#`, so the anchor\n * floats to the line end as on touch devices instead of being clipped at the edge.\n */\nconst GUTTER_ANCHOR_MIN_WIDTH = '48rem';\nconst HEADINGS = ':is(h1, h2, h3, h4, h5, h6)';\n\n/** The whole default stylesheet. */\nexport const PROSE_STYLE_TEXT = `@layer ir.defaults {\n${P} { ${declarations((token) => token.light)} }\n${P}[data-theme=\"dark\"] { ${declarations(\n (token) => token.dark,\n (token) => token.dark !== token.light,\n)} }\n${P} {\n box-sizing: border-box;\n min-height: 100dvh;\n background: ${t('bg')};\n color: ${t('ink')};\n font: 400 ${t('prose-size')} / ${t('prose-leading')} ${t('sans')};\n font-kerning: normal;\n -webkit-font-smoothing: antialiased;\n overflow-wrap: break-word;\n padding-block: clamp(1.5rem, 6vw, 4rem) 6rem;\n display: grid;\n align-content: start;\n grid-template-columns:\n minmax(${t('page-gutter')}, 1fr)\n min(${t('prose-measure')}, 100% - 2 * ${t('page-gutter')})\n minmax(${t('page-gutter')}, 1fr);\n}\n${P} > * { grid-column: 2; min-inline-size: 0; margin-block: 0; }\n${P} > * + * { margin-block-start: ${t('prose-flow')}; }\n\n${P} ${HEADINGS} {\n position: relative;\n font-family: ${t('disp')};\n font-weight: ${t('disp-weight')};\n color: ${t('ink')};\n line-height: 1.25;\n letter-spacing: -0.011em;\n text-wrap: balance;\n scroll-margin-top: 1.5rem;\n}\n${P} h1 { font-size: 2.25em; letter-spacing: -0.022em; line-height: 1.15; }\n${P} h2 { font-size: 1.5em; padding-block-end: 0.3em; border-block-end: 1px solid ${t('line')}; }\n${P} h3 { font-size: 1.2em; }\n${P} h4 { font-size: 1em; }\n${P} :is(h5, h6) { font-size: 0.875em; text-transform: uppercase; letter-spacing: 0.04em; color: ${t('ink-2')}; }\n${P} > ${HEADINGS}:not(:first-child) { margin-block-start: 2.2em; }\n${P} > :is(h1, h2, h3, h4) + * { margin-block-start: 0.7em; }\n\n${P} .ir-heading-anchor { color: ${t('ink-3')}; text-decoration: none; font-weight: 400; }\n${P} .ir-heading-anchor:hover { color: ${t('accent')}; }\n@media (hover: hover) and (width >= ${GUTTER_ANCHOR_MIN_WIDTH}) {\n ${P} .ir-heading-anchor {\n position: absolute;\n inset-inline-end: 100%;\n inline-size: 1.2em;\n padding-inline-end: 0.35em;\n text-align: end;\n opacity: 0;\n transition: opacity 120ms ease;\n }\n ${P} ${HEADINGS}:hover .ir-heading-anchor,\n ${P} .ir-heading-anchor:focus-visible { opacity: 1; }\n}\n@media (hover: none), (width < ${GUTTER_ANCHOR_MIN_WIDTH}) {\n ${P} .ir-heading-anchor {\n float: inline-end;\n min-inline-size: 24px;\n min-block-size: 24px;\n margin-inline-start: 0.5em;\n text-align: center;\n font-size: 0.8em;\n opacity: 0.45;\n }\n}\n\n${P} a { color: ${t(\n 'accent',\n)}; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }\n${P} strong { font-weight: 650; }\n${P} :not(pre) > code {\n font-family: ${t('mono')};\n font-size: 0.86em;\n background: ${t('panel')};\n padding: 0.12em 0.36em;\n border-radius: 5px;\n}\n${P} a code { color: inherit; }\n${P} pre {\n font-family: ${t('mono')};\n font-size: 0.85em;\n line-height: 1.55;\n background: ${t('panel')};\n padding: 1em 1.2em;\n border-radius: ${t('radius-shape')};\n overflow-x: auto;\n tab-size: 2;\n}\n${P} pre code { font: inherit; background: none; padding: 0; }\n${P} :is(ul, ol) { padding-inline-start: 1.5em; }\n${P} li + li, ${P} li > :is(ul, ol) { margin-block-start: 0.35em; }\n${P} li::marker { color: ${t('ink-2')}; }\n${P} li.task-list-item { list-style: none; margin-inline-start: -1.3em; }\n${P} input[type=\"checkbox\"] { margin-inline-end: 0.5em; accent-color: ${t('accent')}; }\n${P} blockquote { padding-inline-start: 1em; border-inline-start: 3px solid ${t('line')}; color: ${t('ink-2')}; }\n${P} hr { border: 0; border-block-start: 1px solid ${t('line')}; }\n${P} > hr, ${P} > hr + * { margin-block-start: calc(2.5 * ${t('prose-size')}); }\n${P} > hr + ${HEADINGS}:not(:first-child) { margin-block-start: max(2.2em, 2.5 * ${t('prose-size')}); }\n${P} :is(img, video) { max-width: 100%; height: auto; border-radius: ${t('radius-shape')}; }\n${P} table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 0.94em; font-variant-numeric: tabular-nums; }\n${P} :is(th, td) { padding: 0.45em 0.8em; border: 1px solid ${t('line')}; text-align: start; }\n${P} th { background: ${t('panel')}; }\n}\n`;\n\n/** Markdown and MDX files get the prose wrapper; app components and HTML do not. The\n * extensions are the ones the transpiler compiles as MDX (`.md`, `.mdx`); a `.markdown`\n * file is not compiled, so wrapping it would style nothing it renders. */\nexport const isProseFile = (path: string): boolean => /\\.mdx?$/i.test(path);\n\n/**\n * Inject the default stylesheet once per document (idempotent, browser-only).\n *\n * It goes FIRST in `<head>`. Cascade layers rank by the order they first appear, later\n * layers winning, so a sheet appended after an app's own CSS would rank `ir.defaults`\n * above the app's layered rules (Tailwind's `base`/`components`/`utilities`, say).\n * First in the document makes it the lowest layer; unlayered rules beat it either way.\n */\nexport function ensureProseStyles(): void {\n ensureStyleElement(PROSE_STYLE_ID, PROSE_STYLE_TEXT, { first: true });\n}\n"],"mappings":";AAeA,SAAS,0BAA0B;AAG5B,MAAM,cAAc;AAGpB,MAAM,iBAAiB;AAS9B,MAAM,OAAO;AACb,MAAM,OAAO;AAGb,MAAM,OAAO,CAAC,MAAc,WAA+B,EAAE,MAAM,OAAO,OAAO,MAAM,MAAM;AAUtF,MAAM,eAAsC;AAAA,EACjD,KAAK,MAAM,aAAa;AAAA,EACxB,EAAE,MAAM,OAAO,OAAO,WAAW,MAAM,UAAU;AAAA,EACjD,EAAE,MAAM,SAAS,OAAO,WAAW,MAAM,UAAU;AAAA,EACnD,EAAE,MAAM,SAAS,OAAO,WAAW,MAAM,UAAU;AAAA,EACnD,EAAE,MAAM,QAAQ,OAAO,WAAW,MAAM,UAAU;AAAA,EAClD,EAAE,MAAM,SAAS,OAAO,WAAW,MAAM,UAAU;AAAA,EACnD,EAAE,MAAM,UAAU,OAAO,WAAW,MAAM,UAAU;AAAA,EACpD,KAAK,QAAQ,IAAI;AAAA,EACjB,KAAK,QAAQ,8BAA8B;AAAA,EAC3C,KAAK,QAAQ,IAAI;AAAA,EACjB,KAAK,eAAe,KAAK;AAAA,EACzB,KAAK,iBAAiB,MAAM;AAAA,EAC5B,KAAK,iBAAiB,MAAM;AAAA,EAC5B,KAAK,eAAe,2BAA2B;AAAA,EAC/C,KAAK,gBAAgB,KAAK;AAAA,EAC1B,KAAK,cAAc,WAAW;AAAA,EAC9B,KAAK,cAAc,OAAO;AAC5B;AAGA,MAAM,IAAI,CAAC,SAAyB,SAAS,IAAI,eAAe,IAAI;AAEpE,MAAM,eAAe,CAAC,MAAqC,SACzD,aAAa,OAAO,SAAS,MAAM,KAAK,EACrC,IAAI,C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