magic-pill 9.0.0-next.0 → 9.0.0-next.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +6 -2
  3. package/dist/MagicPill/MagicPill.js +194 -2
  4. package/dist/MagicPill/MagicPill.mjs +194 -2
  5. package/dist/MagicPill/choreography.js +132 -2
  6. package/dist/MagicPill/choreography.mjs +125 -2
  7. package/dist/Pill/Pill.js +106 -2
  8. package/dist/Pill/Pill.mjs +106 -2
  9. package/dist/Pill/PillAction.js +67 -2
  10. package/dist/Pill/PillAction.mjs +67 -2
  11. package/dist/Pill/PillContext.js +26 -2
  12. package/dist/Pill/PillContext.mjs +24 -2
  13. package/dist/Pill/PillPanel.js +90 -2
  14. package/dist/Pill/PillPanel.mjs +89 -2
  15. package/dist/Pill/parts.js +46 -2
  16. package/dist/Pill/parts.mjs +43 -2
  17. package/dist/PillNavbar/PillNavbar.js +44 -2
  18. package/dist/PillNavbar/PillNavbar.mjs +44 -2
  19. package/dist/PillNavbar/matchPath.js +34 -2
  20. package/dist/PillNavbar/matchPath.mjs +34 -2
  21. package/dist/PillNotification/PillNotification.js +64 -2
  22. package/dist/PillNotification/PillNotification.mjs +63 -2
  23. package/dist/icons/ArrowIcon.js +21 -2
  24. package/dist/icons/ArrowIcon.mjs +21 -2
  25. package/dist/icons/BoxIcon.js +21 -2
  26. package/dist/icons/BoxIcon.mjs +21 -2
  27. package/dist/icons/CheckIcon.js +17 -2
  28. package/dist/icons/CheckIcon.mjs +17 -2
  29. package/dist/icons/CloseIcon.js +17 -2
  30. package/dist/icons/CloseIcon.mjs +17 -2
  31. package/dist/icons/CouponIcon.js +17 -2
  32. package/dist/icons/CouponIcon.mjs +17 -2
  33. package/dist/icons/DocumentIcon.js +17 -2
  34. package/dist/icons/DocumentIcon.mjs +17 -2
  35. package/dist/icons/HelpIcon.js +17 -2
  36. package/dist/icons/HelpIcon.mjs +17 -2
  37. package/dist/icons/InfoIcon.js +17 -2
  38. package/dist/icons/InfoIcon.mjs +17 -2
  39. package/dist/icons/MailIcon.js +17 -2
  40. package/dist/icons/MailIcon.mjs +17 -2
  41. package/dist/icons/PhoneIcon.js +21 -2
  42. package/dist/icons/PhoneIcon.mjs +21 -2
  43. package/dist/icons/PlusIcon.js +17 -2
  44. package/dist/icons/PlusIcon.mjs +17 -2
  45. package/dist/icons/UndoIcon.js +21 -2
  46. package/dist/icons/UndoIcon.mjs +21 -2
  47. package/dist/index.js +50 -1
  48. package/dist/index.mjs +24 -1
  49. package/dist/store/store.js +104 -2
  50. package/dist/store/store.mjs +102 -2
  51. package/dist/store/usePillQueue.js +17 -2
  52. package/dist/store/usePillQueue.mjs +17 -2
  53. package/dist/styles.css +125 -35
  54. package/dist/utils/inputModality.js +23 -0
  55. package/dist/utils/inputModality.mjs +22 -0
  56. package/dist/utils/react.js +23 -2
  57. package/dist/utils/react.mjs +21 -2
  58. package/dist/utils/url.js +22 -2
  59. package/dist/utils/url.mjs +22 -2
  60. package/package.json +3 -2
  61. package/dist/MagicPill/MagicPill.js.map +0 -1
  62. package/dist/MagicPill/MagicPill.mjs.map +0 -1
  63. package/dist/MagicPill/choreography.js.map +0 -1
  64. package/dist/MagicPill/choreography.mjs.map +0 -1
  65. package/dist/Pill/Pill.js.map +0 -1
  66. package/dist/Pill/Pill.mjs.map +0 -1
  67. package/dist/Pill/PillAction.js.map +0 -1
  68. package/dist/Pill/PillAction.mjs.map +0 -1
  69. package/dist/Pill/PillContext.js.map +0 -1
  70. package/dist/Pill/PillContext.mjs.map +0 -1
  71. package/dist/Pill/PillPanel.js.map +0 -1
  72. package/dist/Pill/PillPanel.mjs.map +0 -1
  73. package/dist/Pill/parts.js.map +0 -1
  74. package/dist/Pill/parts.mjs.map +0 -1
  75. package/dist/PillNavbar/PillNavbar.js.map +0 -1
  76. package/dist/PillNavbar/PillNavbar.mjs.map +0 -1
  77. package/dist/PillNavbar/matchPath.js.map +0 -1
  78. package/dist/PillNavbar/matchPath.mjs.map +0 -1
  79. package/dist/PillNotification/PillNotification.js.map +0 -1
  80. package/dist/PillNotification/PillNotification.mjs.map +0 -1
  81. package/dist/icons/ArrowIcon.js.map +0 -1
  82. package/dist/icons/ArrowIcon.mjs.map +0 -1
  83. package/dist/icons/BoxIcon.js.map +0 -1
  84. package/dist/icons/BoxIcon.mjs.map +0 -1
  85. package/dist/icons/CheckIcon.js.map +0 -1
  86. package/dist/icons/CheckIcon.mjs.map +0 -1
  87. package/dist/icons/CloseIcon.js.map +0 -1
  88. package/dist/icons/CloseIcon.mjs.map +0 -1
  89. package/dist/icons/CouponIcon.js.map +0 -1
  90. package/dist/icons/CouponIcon.mjs.map +0 -1
  91. package/dist/icons/DocumentIcon.js.map +0 -1
  92. package/dist/icons/DocumentIcon.mjs.map +0 -1
  93. package/dist/icons/HelpIcon.js.map +0 -1
  94. package/dist/icons/HelpIcon.mjs.map +0 -1
  95. package/dist/icons/InfoIcon.js.map +0 -1
  96. package/dist/icons/InfoIcon.mjs.map +0 -1
  97. package/dist/icons/MailIcon.js.map +0 -1
  98. package/dist/icons/MailIcon.mjs.map +0 -1
  99. package/dist/icons/PhoneIcon.js.map +0 -1
  100. package/dist/icons/PhoneIcon.mjs.map +0 -1
  101. package/dist/icons/PlusIcon.js.map +0 -1
  102. package/dist/icons/PlusIcon.mjs.map +0 -1
  103. package/dist/icons/UndoIcon.js.map +0 -1
  104. package/dist/icons/UndoIcon.mjs.map +0 -1
  105. package/dist/store/store.js.map +0 -1
  106. package/dist/store/store.mjs.map +0 -1
  107. package/dist/store/usePillQueue.js.map +0 -1
  108. package/dist/store/usePillQueue.mjs.map +0 -1
  109. package/dist/utils/react.js.map +0 -1
  110. package/dist/utils/react.mjs.map +0 -1
  111. package/dist/utils/url.js.map +0 -1
  112. package/dist/utils/url.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.mjs","names":["devWarn","EMPTY_STATE","lastId","isServer","createStore","name","items","state","hosts","listeners","commit","next","listener","replace","id","input","item","patch","queued","reason","dismissed","stores","getStore","store","controllers","pill","controller"],"sources":["../../src/store/store.ts"],"sourcesContent":["// No \"use client\" and no React: the store and pill() can be imported from any\n// module and called from anywhere on the client, including outside React.\nimport type { ReactNode } from \"react\";\n\nimport type { PillVariant } from \"../Pill/types\";\nimport type { PillNotificationProps } from \"../PillNotification/PillNotification\";\nimport { devWarn } from \"../utils/react\";\n\nexport type DismissReason = \"timeout\" | \"action\" | \"dismissed\" | \"cleared\";\n\ninterface NotifyCommon {\n /**\n * Reusing the id of a queued or visible notification updates it in place\n * (e.g. \"Saving…\" → \"Saved\") instead of queueing a new one.\n */\n id?: string;\n variant?: PillVariant;\n /**\n * Milliseconds the notification stays once fully shown. Default: the host's\n * `duration` (5000). `Infinity` keeps it until dismissed. The countdown\n * pauses on hover, focus, an open panel and a hidden browser tab, and\n * starts again from the full duration afterwards.\n */\n duration?: number;\n /**\n * What screen readers announce. Default: the text of the message (or of the\n * whole pill for a `render` notification). `false` announces nothing.\n */\n announce?: string | false;\n onDismiss?: (id: string, reason: DismissReason) => void;\n}\n\n/** The built-in notification template, as data. */\nexport interface NotifyOptions extends NotifyCommon, Omit<PillNotificationProps, \"linkComponent\" | \"classNames\"> {\n render?: undefined;\n}\n\n/** Your own template, with the queue, timing and animation of the host. */\nexport interface NotifyRenderOptions extends NotifyCommon {\n render: (notification: { id: string; dismiss: () => void }) => ReactNode;\n}\n\nexport type NotifyInput = NotifyOptions | NotifyRenderOptions;\n\nexport interface QueuedNotification {\n readonly id: string;\n readonly input: NotifyInput;\n}\n\nexport interface PillQueueState {\n /** The notification the pill shows (or is about to show). */\n readonly current: QueuedNotification | null;\n /** The ones waiting behind it, first in, first out. */\n readonly queued: readonly QueuedNotification[];\n}\n\nexport interface PillController {\n readonly name: string;\n /**\n * Queue a notification (first in, first out). Returns its id.\n * Calls made before the host mounts are kept and shown once it mounts.\n */\n notify: (input: NotifyInput) => string;\n update: (id: string, patch: Partial<NotifyOptions>) => void;\n /** Dismiss one notification, or the visible one when called without an id. */\n dismiss: (id?: string) => void;\n /** Empty the queue and dismiss the visible notification. */\n clear: () => void;\n}\n\n/** One named pill's queue. Internal: the host uses more than the controller exposes. */\nexport interface PillStore {\n getState: () => PillQueueState;\n subscribe: (listener: () => void) => () => void;\n notify: (input: NotifyInput) => string;\n update: (id: string, patch: Partial<NotifyOptions>) => void;\n dismiss: (id: string | undefined, reason: DismissReason) => void;\n clear: () => void;\n /** Counts mounted hosts, to warn about two hosts with the same name. Returns the cleanup. */\n registerHost: () => () => void;\n}\n\nexport const EMPTY_STATE: PillQueueState = Object.freeze({ current: null, queued: Object.freeze([]) });\n\nlet lastId = 0;\n\n// On the server, a module-level queue would be shared by every request\nconst isServer = () => typeof document === \"undefined\";\n\nfunction createStore(name: string): PillStore {\n let items: readonly QueuedNotification[] = [];\n let state: PillQueueState = EMPTY_STATE;\n let hosts = 0;\n const listeners = new Set<() => void>();\n\n const commit = (next: readonly QueuedNotification[]) => {\n items = next;\n state = next.length === 0 ? EMPTY_STATE : { current: next[0], queued: next.slice(1) };\n listeners.forEach((listener) => listener());\n };\n\n const replace = (id: string, input: NotifyInput) =>\n commit(items.map((item) => (item.id === id ? { id, input } : item)));\n\n return {\n getState: () => state,\n\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n\n notify(input) {\n const id = input.id ?? `mp-${++lastId}`;\n if (isServer()) {\n devWarn(`pill(\"${name}\").notify() was called on the server and does nothing: call it from client code.`);\n return id;\n }\n if (items.some((item) => item.id === id)) {\n replace(id, input);\n } else {\n commit([...items, { id, input }]);\n }\n return id;\n },\n\n update(id, patch) {\n const item = items.find((queued) => queued.id === id);\n if (item) {\n replace(id, { ...item.input, ...patch } as NotifyInput);\n }\n },\n\n dismiss(id, reason) {\n const item = id === undefined ? items[0] : items.find((queued) => queued.id === id);\n if (!item) return;\n commit(items.filter((queued) => queued !== item));\n item.input.onDismiss?.(item.id, reason);\n },\n\n clear() {\n const dismissed = items;\n if (dismissed.length === 0) return;\n commit([]);\n dismissed.forEach((item) => item.input.onDismiss?.(item.id, \"cleared\"));\n },\n\n registerHost() {\n hosts += 1;\n if (hosts > 1) {\n devWarn(`Several <MagicPill name=\"${name}\"> are mounted. Give each one its own name.`);\n }\n return () => {\n hosts -= 1;\n };\n },\n };\n}\n\nconst stores = new Map<string, PillStore>();\n\n/** The store of the pill with this name, created on first use. */\nexport function getStore(name: string): PillStore {\n let store = stores.get(name);\n if (!store) {\n store = createStore(name);\n stores.set(name, store);\n }\n return store;\n}\n\nconst controllers = new Map<string, PillController>();\n\n/** Control the <MagicPill> with this name (default \"main\") from anywhere. */\nexport function pill(name = \"main\"): PillController {\n let controller = controllers.get(name);\n if (!controller) {\n const store = getStore(name);\n controller = Object.freeze({\n name,\n notify: (input: NotifyInput) => store.notify(input),\n update: (id: string, patch: Partial<NotifyOptions>) => store.update(id, patch),\n dismiss: (id?: string) => store.dismiss(id, \"dismissed\"),\n clear: () => store.clear(),\n });\n controllers.set(name, controller);\n }\n return controller;\n}\n\n/** Tests only: forget every store. */\nexport function resetStores(): void {\n stores.clear();\n controllers.clear();\n}\n"],"mappings":"A,6CAkFA,MAAaC,EAA8B,OAAO,OAAO,CAAE,QAAS,KAAM,OAAQ,OAAO,OAAO,CAAC,CAAC,CAAE,CAAC,EAErG,IAAIC,EAAS,EAGb,MAAMC,MAAiB,OAAO,SAAa,IAE3C,SAASC,EAAYC,EAAyB,CAC5C,IAAIC,EAAuC,CAAC,EACxCC,EAAwBN,EACxBO,EAAQ,EACNC,kBAAY,IAAI,IAEhBC,EAAUC,GAAwC,CACtDL,EAAQK,EACRJ,EAAQI,EAAK,SAAW,EAAIV,EAAc,CAAE,QAASU,EAAK,GAAI,OAAQA,EAAK,MAAM,CAAC,CAAE,EACpFF,EAAU,QAASG,GAAaA,EAAS,CAAC,CAC5C,EAEMC,GAAWC,EAAYC,IAC3BL,EAAOJ,EAAM,IAAKU,GAAUA,EAAK,KAAOF,EAAK,CAAEA,KAAIC,OAAM,EAAIC,CAAK,CAAC,EAErE,MAAO,CACL,aAAgBT,EAEhB,UAAUK,EAAU,CAElB,OADAH,EAAU,IAAIG,CAAQ,MACTH,EAAU,OAAOG,CAAQ,CACxC,EAEA,OAAOG,EAAO,CACZ,IAAMD,EAAKC,EAAM,IAAM,MAAM,EAAEb,IAU/B,OATIC,EAAS,GACXH,EAAQ,SAASK,EAAK,iFAAiF,EAChGS,IAELR,EAAM,KAAMU,GAASA,EAAK,KAAOF,CAAE,EACrCD,EAAQC,EAAIC,CAAK,EAEjBL,EAAO,CAAC,GAAGJ,EAAO,CAAEQ,KAAIC,OAAM,CAAC,CAAC,EAE3BD,EACT,EAEA,OAAOA,EAAIG,EAAO,CAChB,IAAMD,EAAOV,EAAM,KAAMY,GAAWA,EAAO,KAAOJ,CAAE,EAChDE,GACFH,EAAQC,EAAI,CAAE,GAAGE,EAAK,MAAO,GAAGC,CAAM,CAAgB,CAE1D,EAEA,QAAQH,EAAIK,EAAQ,CAClB,IAAMH,EAAOF,IAAO,IAAA,GAAYR,EAAM,GAAKA,EAAM,KAAMY,GAAWA,EAAO,KAAOJ,CAAE,EAC7EE,IACLN,EAAOJ,EAAM,OAAQY,GAAWA,IAAWF,CAAI,CAAC,EAChDA,EAAK,MAAM,YAAYA,EAAK,GAAIG,CAAM,EACxC,EAEA,OAAQ,CACN,IAAMC,EAAYd,EACdc,EAAU,SAAW,IACzBV,EAAO,CAAC,CAAC,EACTU,EAAU,QAASJ,GAASA,EAAK,MAAM,YAAYA,EAAK,GAAI,SAAS,CAAC,EACxE,EAEA,cAAe,CAKb,MAJAR,IAAS,EACLA,EAAQ,GACVR,EAAQ,4BAA4BK,EAAK,4CAA4C,MAE1E,CACXG,GACF,CACF,CACF,CACF,CAEA,MAAMa,kBAAS,IAAI,IAGnB,SAAgBC,EAASjB,EAAyB,CAChD,IAAIkB,EAAQF,EAAO,IAAIhB,CAAI,EAK3B,OAJKkB,IACHA,EAAQnB,EAAYC,CAAI,EACxBgB,EAAO,IAAIhB,EAAMkB,CAAK,GAEjBA,CACT,CAEA,MAAMC,kBAAc,IAAI,IAGxB,SAAgBC,EAAKpB,EAAO,OAAwB,CAClD,IAAIqB,EAAaF,EAAY,IAAInB,CAAI,EACrC,GAAI,CAACqB,EAAY,CACf,IAAMH,EAAQD,EAASjB,CAAI,EAC3BqB,EAAa,OAAO,OAAO,CACzBrB,OACA,OAASU,GAAuBQ,EAAM,OAAOR,CAAK,EAClD,QAASD,EAAYG,IAAkCM,EAAM,OAAOT,EAAIG,CAAK,EAC7E,QAAUH,GAAgBS,EAAM,QAAQT,EAAI,WAAW,EACvD,UAAaS,EAAM,MAAM,CAC3B,CAAC,EACDC,EAAY,IAAInB,EAAMqB,CAAU,CAClC,CACA,OAAOA,CACT,C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePillQueue.js","names":["EMPTY_STATE","getStore","useSyncExternalStore","react","require_store","getServerSnapshot","name","store"],"sources":["../../src/store/usePillQueue.ts"],"sourcesContent":["\"use client\"\nimport { useSyncExternalStore } from \"react\";\n\nimport { EMPTY_STATE, getStore, type PillQueueState } from \"./store\";\n\n// The server never holds notifications (see store.ts), and hydration must match it\nconst getServerSnapshot = () => EMPTY_STATE;\n\n/**\n * Headless access to a pill's queue, to build your own host or display\n * (like react-hot-toast's useToaster). <MagicPill> is built on it.\n */\nexport function usePillQueue(name = \"main\"): PillQueueState {\n const store = getStore(name);\n return useSyncExternalStore(store.subscribe, store.getState, getServerSnapshot);\n}\n"],"mappings":"A,kEAMMK,MAA0BL,EAAAA,Y,qBAMhC,SAA6BM,EAAO,OAAwB,CAC1D,IAAMC,EAAQN,EAAAA,SAASK,CAAI,EAC3B,OAAA,EAAOJ,EAAAA,qBAAAA,CAAqBK,EAAM,UAAWA,EAAM,SAAUF,CAAiB,CAChF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePillQueue.mjs","names":["useSyncExternalStore","EMPTY_STATE","getStore","getServerSnapshot","usePillQueue","name","store"],"sources":["../../src/store/usePillQueue.ts"],"sourcesContent":["\"use client\"\nimport { useSyncExternalStore } from \"react\";\n\nimport { EMPTY_STATE, getStore, type PillQueueState } from \"./store\";\n\n// The server never holds notifications (see store.ts), and hydration must match it\nconst getServerSnapshot = () => EMPTY_STATE;\n\n/**\n * Headless access to a pill's queue, to build your own host or display\n * (like react-hot-toast's useToaster). <MagicPill> is built on it.\n */\nexport function usePillQueue(name = \"main\"): PillQueueState {\n const store = getStore(name);\n return useSyncExternalStore(store.subscribe, store.getState, getServerSnapshot);\n}\n"],"mappings":"A,kHAMA,MAAMG,MAA0BF,EAMhC,SAAgBG,EAAaC,EAAO,OAAwB,CAC1D,IAAMC,EAAQJ,EAASG,CAAI,EAC3B,OAAOL,EAAqBM,EAAM,UAAWA,EAAM,SAAUH,CAAiB,CAChF,C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.js","names":["version","react","INERT_VALUE","message","inert","refs","node","ref"],"sources":["../../src/utils/react.ts"],"sourcesContent":["import { version, type Ref, type RefCallback } from \"react\";\n\n// Bundlers replace `process.env.NODE_ENV`; the typeof guard covers the rest.\ndeclare const process: { env: { NODE_ENV?: string } } | undefined;\n\n/** Warn in development builds only. */\nexport function devWarn(message: string): void {\n if (typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\") {\n console.warn(`[magic-pill] ${message}`);\n }\n}\n\n// React 19 knows `inert` as a boolean attribute. React 18 doesn't: it drops\n// `true` with a warning, so it needs an empty string, which React 19 treats as false.\nconst INERT_VALUE = Number.parseInt(version, 10) >= 19 ? true : \"\";\n\n/** Spread on an element to make it inert (unfocusable, hidden from assistive technology). */\nexport function inertProps(inert: boolean): { inert?: boolean } {\n return inert ? ({ inert: INERT_VALUE } as { inert: boolean }) : {};\n}\n\n/** Combine refs (React 18 compatible: no ref cleanup functions). */\nexport function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }\n };\n}\n"],"mappings":"A,uBAcA,MAAME,EAAc,OAAO,SAASF,EAAAA,QAAS,EAAE,GAAK,IAAY,G,gBARhE,SAAwBG,EAAuB,CACzC,OAAO,QAAY,KAAe,QAAQ,IAAI,WAAa,cAC7D,QAAQ,KAAK,gBAAgBA,GAAS,CAE1C,E,mBAOA,SAA2BC,EAAqC,CAC9D,OAAOA,EAAS,CAAE,MAAOF,CAAY,EAA2B,CAAC,CACnE,E,kBAGA,SAA6B,GAAGG,EAA8C,CAC5E,MAAQC,IAAS,CACf,IAAK,IAAMC,KAAOF,EACZ,OAAOE,GAAQ,WACjBA,EAAID,CAAI,EACCC,IACTA,EAAI,QAAUD,EAGpB,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.mjs","names":["version","devWarn","message","INERT_VALUE","inertProps","inert","mergeRefs","refs","node","ref"],"sources":["../../src/utils/react.ts"],"sourcesContent":["import { version, type Ref, type RefCallback } from \"react\";\n\n// Bundlers replace `process.env.NODE_ENV`; the typeof guard covers the rest.\ndeclare const process: { env: { NODE_ENV?: string } } | undefined;\n\n/** Warn in development builds only. */\nexport function devWarn(message: string): void {\n if (typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\") {\n console.warn(`[magic-pill] ${message}`);\n }\n}\n\n// React 19 knows `inert` as a boolean attribute. React 18 doesn't: it drops\n// `true` with a warning, so it needs an empty string, which React 19 treats as false.\nconst INERT_VALUE = Number.parseInt(version, 10) >= 19 ? true : \"\";\n\n/** Spread on an element to make it inert (unfocusable, hidden from assistive technology). */\nexport function inertProps(inert: boolean): { inert?: boolean } {\n return inert ? ({ inert: INERT_VALUE } as { inert: boolean }) : {};\n}\n\n/** Combine refs (React 18 compatible: no ref cleanup functions). */\nexport function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }\n };\n}\n"],"mappings":"A,gCAMA,SAAgBC,EAAQC,EAAuB,CACzC,OAAO,QAAY,KAAe,QAAQ,IAAI,WAAa,cAC7D,QAAQ,KAAK,gBAAgBA,GAAS,CAE1C,CAIA,MAAMC,EAAc,OAAO,SAASH,EAAS,EAAE,GAAK,IAAY,GAGhE,SAAgBI,EAAWC,EAAqC,CAC9D,OAAOA,EAAS,CAAE,MAAOF,CAAY,EAA2B,CAAC,CACnE,CAGA,SAAgBG,EAAa,GAAGC,EAA8C,CAC5E,MAAQC,IAAS,CACf,IAAK,IAAMC,KAAOF,EACZ,OAAOE,GAAQ,WACjBA,EAAID,CAAI,EACCC,IACTA,EAAI,QAAUD,EAGpB,CACF,C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.js","names":["ALLOWED_SCHEMES","href","normalised","scheme"],"sources":["../../src/utils/url.ts"],"sourcesContent":["// Link safety (L16): React 18 renders `javascript:` URLs as-is, so every href\n// the library renders goes through this check first.\n\nconst ALLOWED_SCHEMES = new Set([\"http\", \"https\", \"mailto\", \"tel\"]);\n\n/**\n * Whether an href is safe to render: relative URLs (including `#…`, `?…`\n * and `//host`), or absolute URLs with an `http(s):`, `mailto:` or `tel:` scheme.\n *\n * It normalises the URL the way browsers do before reading the scheme\n * (leading spaces and control characters dropped, tabs and newlines removed),\n * so `\" java\\tscript:…\"` is caught too.\n */\nexport function isSafeHref(href: string): boolean {\n const normalised = href\n .replace(/^[\\x00-\\x20]+/, \"\")\n .replace(/[\\t\\n\\r]/g, \"\");\n const scheme = /^([a-z][a-z\\d+.-]*):/i.exec(normalised);\n return scheme === null || ALLOWED_SCHEMES.has(scheme[1].toLowerCase());\n}\n"],"mappings":"AAGA,MAAMA,kBAAkB,IAAI,IAAI,CAAC,OAAQ,QAAS,SAAU,KAAK,CAAC,E,mBAUlE,SAA2BC,EAAuB,CAChD,IAAMC,EAAaD,EAChB,QAAQ,gBAAiB,EAAE,CAAC,CAC5B,QAAQ,YAAa,EAAE,EACpBE,EAAS,wBAAwB,KAAKD,CAAU,EACtD,OAAOC,IAAW,MAAQH,EAAgB,IAAIG,EAAO,EAAE,CAAC,YAAY,CAAC,CACvE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.mjs","names":["ALLOWED_SCHEMES","isSafeHref","href","normalised","scheme"],"sources":["../../src/utils/url.ts"],"sourcesContent":["// Link safety (L16): React 18 renders `javascript:` URLs as-is, so every href\n// the library renders goes through this check first.\n\nconst ALLOWED_SCHEMES = new Set([\"http\", \"https\", \"mailto\", \"tel\"]);\n\n/**\n * Whether an href is safe to render: relative URLs (including `#…`, `?…`\n * and `//host`), or absolute URLs with an `http(s):`, `mailto:` or `tel:` scheme.\n *\n * It normalises the URL the way browsers do before reading the scheme\n * (leading spaces and control characters dropped, tabs and newlines removed),\n * so `\" java\\tscript:…\"` is caught too.\n */\nexport function isSafeHref(href: string): boolean {\n const normalised = href\n .replace(/^[\\x00-\\x20]+/, \"\")\n .replace(/[\\t\\n\\r]/g, \"\");\n const scheme = /^([a-z][a-z\\d+.-]*):/i.exec(normalised);\n return scheme === null || ALLOWED_SCHEMES.has(scheme[1].toLowerCase());\n}\n"],"mappings":"AAGA,MAAMA,kBAAkB,IAAI,IAAI,CAAC,OAAQ,QAAS,SAAU,KAAK,CAAC,EAUlE,SAAgBC,EAAWC,EAAuB,CAChD,IAAMC,EAAaD,EAChB,QAAQ,gBAAiB,EAAE,CAAC,CAC5B,QAAQ,YAAa,EAAE,EACpBE,EAAS,wBAAwB,KAAKD,CAAU,EACtD,OAAOC,IAAW,MAAQJ,EAAgB,IAAII,EAAO,EAAE,CAAC,YAAY,CAAC,CACvE,C"}