github-stars-organizer 0.0.0-stage → 0.1.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 (33) hide show
  1. package/LICENSE +662 -0
  2. package/README.md +32 -2
  3. package/dist/THIRD-PARTY-LICENSES.txt +79 -0
  4. package/dist/app/THIRD-PARTY-LICENSES.txt +1964 -0
  5. package/dist/app/assets/backups-DxRMQO9O.js +1 -0
  6. package/dist/app/assets/badge-Ba4FNylI.js +1 -0
  7. package/dist/app/assets/button-ZbiqMfUE.js +14 -0
  8. package/dist/app/assets/coerce-B4B_TTls.js +1 -0
  9. package/dist/app/assets/download-CzXogqy0.js +1 -0
  10. package/dist/app/assets/esm-hHQKpih6.js +393 -0
  11. package/dist/app/assets/explore-CrybvCPL.js +33 -0
  12. package/dist/app/assets/history-C-bdlEYN.js +1 -0
  13. package/dist/app/assets/index-B6vy4QhK.css +2 -0
  14. package/dist/app/assets/index-C_V67CMR.js +10 -0
  15. package/dist/app/assets/list._listId-BHMtNFq8.js +1 -0
  16. package/dist/app/assets/list._listId-tfkSZzxB.js +2 -0
  17. package/dist/app/assets/local-sync-DQzF1V9q.js +1 -0
  18. package/dist/app/assets/opfs-worker-accoEoax-B2IN8tCs.js +5890 -0
  19. package/dist/app/assets/registry-BKuxwL5K.js +4 -0
  20. package/dist/app/assets/routes-C_O77OAA.js +1 -0
  21. package/dist/app/assets/routes-lhdAnl7w.js +2 -0
  22. package/dist/app/assets/schemas-D_ddKDHk.js +39 -0
  23. package/dist/app/assets/space-grotesk-latin-ext-wght-normal-D9tNdqV9.woff2 +0 -0
  24. package/dist/app/assets/space-grotesk-latin-wght-normal-BhU9QXUp.woff2 +0 -0
  25. package/dist/app/assets/space-grotesk-vietnamese-wght-normal-D0rl6rjA.woff2 +0 -0
  26. package/dist/app/assets/star-DgcTDj5Y.js +7 -0
  27. package/dist/app/assets/sync-persistence-f8LlQoHO.js +2 -0
  28. package/dist/app/favicon.svg +1 -0
  29. package/dist/app/icons.svg +24 -0
  30. package/dist/app/index.html +33 -0
  31. package/dist/app/og.jpg +0 -0
  32. package/dist/cli.js +7111 -0
  33. package/package.json +25 -4
@@ -0,0 +1 @@
1
+ import{H as e,K as t,Q as n,R as r,U as i,V as a,W as o,et as s,n as c,rt as l,t as u}from"./button-ZbiqMfUE.js";import{t as d}from"./download-CzXogqy0.js";import{t as ee}from"./history-C-bdlEYN.js";import{Pn as f,a as p,at as m,c as h,d as te,g,i as _,it as v,n as ne,o as y,r as b,rt as re,s as x,u as S,y as C}from"./schemas-D_ddKDHk.js";import{t as w}from"./local-sync-DQzF1V9q.js";var T=r(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),E=l(s(),1),D=n();function ie({...e}){return(0,D.jsx)(te,{"data-slot":`dialog`,...e})}function ae({...e}){return(0,D.jsx)(g,{"data-slot":`dialog-portal`,...e})}function O({className:e,...t}){return(0,D.jsx)(m,{"data-slot":`dialog-overlay`,className:c(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function k({className:e,children:t,showCloseButton:n=!0,...r}){return(0,D.jsxs)(ae,{children:[(0,D.jsx)(O,{}),(0,D.jsxs)(C,{"data-slot":`dialog-content`,className:c(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,D.jsxs)(v,{"data-slot":`dialog-close`,render:(0,D.jsx)(u,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,D.jsx)(f,{}),(0,D.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function A({className:e,...t}){return(0,D.jsx)(`div`,{"data-slot":`dialog-header`,className:c(`flex flex-col gap-2`,e),...t})}function j({className:e,showCloseButton:t=!1,children:n,...r}){return(0,D.jsxs)(`div`,{"data-slot":`dialog-footer`,className:c(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,D.jsx)(v,{render:(0,D.jsx)(u,{variant:`outline`}),children:`Close`})]})}function M({className:e,...t}){return(0,D.jsx)(S,{"data-slot":`dialog-title`,className:c(`font-heading text-base leading-none font-medium`,e),...t})}function N({className:e,...t}){return(0,D.jsx)(re,{"data-slot":`dialog-description`,className:c(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}var P=`github-stars-organizer-backup`,F=x({githubId:y().int(),nodeId:h(),fullName:h()}),I=F.extend({starredAt:h()}),L=x({id:h(),name:h(),description:h().nullable(),isPrivate:_(),repos:b(F)}),R=x({repos:b(x({githubId:y().int(),notes:h().nullable(),usefulnessRating:y().int().min(1).max(5).nullable()})),tags:b(x({id:h(),name:h(),color:h()})),repoTags:b(x({githubId:y().int(),tagId:h()}))}),z=x({format:p(P),version:p(1),createdAt:h(),login:h(),reason:ne([`launch`,`manual`,`before-restore`,`uploaded`]),stars:b(I),lists:b(L),local:R.optional()}),B=class extends Error{};function V(e){let t=z.safeParse(e);if(t.success)return t.data;let n=e;if(n?.format!==`github-stars-organizer-backup`)throw new B(`This file isn't a Stars Organizer backup.`);if(typeof n.version==`number`&&n.version>1)throw new B("This backup was made by a newer version. Update with `npx github-stars-organizer@latest`.");let r=t.error.issues[0];throw new B(`This backup is damaged (${r.path.join(`.`)}: ${r.message}).`)}x({local:R.optional()});function H(e){return e.restar.length+e.recreateLists.length+e.addToLists.length}function U({repos:e,tags:t,repo_tags:n}){let r=new Map(e.map(e=>[e.id,e.github_id]));return{repos:e.filter(e=>e.notes||e.usefulness_rating!==null).map(e=>({githubId:e.github_id,notes:e.notes||null,usefulnessRating:e.usefulness_rating})),tags:t.map(({id:e,name:t,color:n})=>({id:e,name:t,color:n})),repoTags:n.flatMap(e=>{let t=r.get(e.repo_id);return t===void 0?[]:[{githubId:t,tagId:e.tag_id}]})}}function W(e,t,n){let r=new Map(t.repos.map(e=>[e.github_id,e])),i=e.repos.flatMap(e=>{let t=r.get(e.githubId);if(!t)return[];let n={id:t.id};return!t.notes&&e.notes&&(n.notes=e.notes),t.usefulness_rating===null&&e.usefulnessRating!==null&&(n.usefulness_rating=e.usefulnessRating),Object.keys(n).length>1?[n]:[]}),a=new Map(t.tags.map(e=>[e.name.toLowerCase(),e.id])),o=[],s=new Map;for(let t of e.tags){let e=a.get(t.name.toLowerCase());if(e){s.set(t.id,e);continue}let r={id:n(),name:t.name,color:t.color};o.push(r),a.set(r.name.toLowerCase(),r.id),s.set(t.id,r.id)}let c=new Set(t.repo_tags.map(e=>`${e.repo_id}:${e.tag_id}`));return{repos:i,tags:o,repo_tags:e.repoTags.flatMap(e=>{let t=r.get(e.githubId),i=s.get(e.tagId);if(!t||!i)return[];let a=`${t.id}:${i}`;return c.has(a)?[]:(c.add(a),[{id:n(),repo_id:t.id,tag_id:i}])})}}async function G(){return await Promise.all([a.preload(),i.preload(),e.preload()]),{repos:a.toArray,tags:i.toArray,repo_tags:e.toArray}}async function K(){return t.backUpNow({local:U(await G())})}async function q(e){let n=await t.readBackup(e.id),r=n.local?n:{...n,local:U(await G())},i=URL.createObjectURL(new Blob([JSON.stringify(r,null,2)],{type:`application/json`})),a=document.createElement(`a`);a.href=i,a.download=`stars-organizer-${n.login}-${e.id}.json`,a.click(),URL.revokeObjectURL(i)}async function J(e){let n;try{n=JSON.parse(await e.text())}catch{throw Error(`${e.name} isn't a JSON file.`)}return t.uploadBackup(V(n))}async function oe(t){let n=W(t,await G(),()=>crypto.randomUUID());return await o(()=>{for(let e of n.repos)a.update(e.id,t=>{Object.assign(t,e)});n.tags.length&&i.insert(n.tags),n.repo_tags.length&&e.insert(n.repo_tags)}),{notesAndRatings:n.repos.length,tags:n.tags.length,tagLinks:n.repo_tags.length}}async function se(e){let n=await t.applyRestore({backupId:e.id});await w();let{local:r}=await t.readBackup(e.id);return{...n,local:r?await oe(r):null}}var ce={launch:`On launch`,manual:`Backed up by hand`,"before-restore":`Before a restore`,uploaded:`From a file`},Y=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function X(e){return e instanceof Error?e.message:String(e)}function Z(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function le(){return(0,D.jsx)(ue,{})}function ue(){let[e,n]=(0,E.useState)(null),[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(null),l=(0,E.useRef)(null);async function f(){n(await t.listBackups())}(0,E.useEffect)(()=>{f().catch(e=>i(`Couldn't read the backups: ${X(e)}`))},[]);async function p(e,t){o(!0),i(e);try{i(await t()),await f()}catch(e){i(X(e))}finally{o(!1)}}function m(){p(`Backing up...`,async()=>{let e=await K();return`Backed up ${Z(e.stars,`star`)} and ${Z(e.lists,`List`)}, with your tags, ratings and notes.`})}function h(e){e&&p(`Reading ${e.name}...`,async()=>(c(await J(e)),`Kept a copy of ${e.name}.`))}return(0,D.jsxs)(`div`,{className:`max-w-3xl space-y-6`,children:[(0,D.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`h1`,{className:`font-display text-2xl font-bold tracking-tight`,children:`Backups`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Each launch backs up your stars and Lists before the app can change anything. A restore only adds back what is missing: it never unstars a repo or deletes a List.`}),e&&(0,D.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Saved in `,(0,D.jsx)(`code`,{children:e.directory})]})]}),(0,D.jsx)(u,{onClick:m,disabled:a,children:`Back up now`})]}),r&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm`,children:r}),(0,D.jsxs)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:[e?.backups.length===0&&(0,D.jsx)(`li`,{className:`p-4 text-sm text-muted-foreground`,children:`No backups yet.`}),e?.backups.map(e=>(0,D.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 p-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium`,children:Y.format(new Date(e.createdAt))}),(0,D.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[ce[e.reason],` · `,Z(e.stars,`star`),` · `,Z(e.lists,`List`)]})]}),(0,D.jsxs)(u,{variant:`ghost`,size:`sm`,disabled:a,onClick:()=>void p(`Preparing the file...`,async()=>(await q(e),`Downloaded.`)),children:[(0,D.jsx)(d,{className:`mr-1.5 size-4`}),`Download`]}),(0,D.jsxs)(u,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>c(e),children:[(0,D.jsx)(ee,{className:`mr-1.5 size-4`}),`Restore...`]})]},e.id))]}),(0,D.jsxs)(`section`,{className:`space-y-2`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Restore from a file`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A backup you downloaded, from this computer or another. You see what it would change before anything does.`}),(0,D.jsx)(`input`,{ref:l,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{h(e.target.files?.[0]),e.target.value=``}}),(0,D.jsxs)(u,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>l.current?.click(),children:[(0,D.jsx)(T,{className:`mr-1.5 size-4`}),`Choose a file`]})]}),s&&(0,D.jsx)(de,{backup:s,onClose:()=>c(null),onRestored:()=>void f()})]})}var Q=5;function $({names:e}){let t=e.length-Q;return(0,D.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e.slice(0,Q).join(`, `),t>0&&`, and ${t} more`]})}function de({backup:e,onClose:n,onRestored:r}){let[i,a]=(0,E.useState)({step:`planning`});(0,E.useEffect)(()=>{Promise.all([t.planRestore({backupId:e.id}),t.readBackup(e.id)]).then(([e,t])=>a({step:`review`,plan:e,hasLocal:t.local!==void 0})).catch(e=>a({step:`failed`,message:X(e)}))},[e.id]);async function o(){a({step:`applying`});try{a({step:`done`,result:await se(e)}),r()}catch(e){a({step:`failed`,message:X(e)})}}return(0,D.jsx)(ie,{open:!0,onOpenChange:e=>{!e&&i.step!==`applying`&&n()},children:(0,D.jsxs)(k,{children:[(0,D.jsxs)(A,{children:[(0,D.jsxs)(M,{children:[`Restore the backup from `,Y.format(new Date(e.createdAt))]}),(0,D.jsx)(N,{children:`Only adds what GitHub is missing. Nothing you starred or made since is touched.`})]}),(0,D.jsx)(fe,{state:i}),(0,D.jsxs)(j,{children:[i.step===`review`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(u,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,D.jsx)(u,{onClick:()=>void o(),disabled:H(i.plan)===0&&!i.hasLocal,children:`Restore`})]}),(i.step===`done`||i.step===`failed`)&&(0,D.jsx)(u,{onClick:n,children:`Close`})]})]})})}function fe({state:e}){switch(e.step){case`planning`:return(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Comparing the backup with GitHub...`});case`applying`:return(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Restoring. Leave this open until it finishes.`});case`failed`:return(0,D.jsx)(`p`,{className:`text-sm text-destructive`,children:e.message});case`review`:return(0,D.jsx)(pe,{plan:e.plan,hasLocal:e.hasLocal});case`done`:return(0,D.jsx)(he,{result:e.result})}}function pe({plan:e,hasLocal:t}){let n=new Set(e.addToLists.map(e=>e.repo.fullName));return H(e)===0?(0,D.jsxs)(`p`,{className:`text-sm`,children:[`GitHub already has every star and List in this backup.`,t&&` Restoring fills in any tags, ratings and notes this browser is missing.`]}):(0,D.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[e.restar.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Star `,Z(e.restar.length,`repo`),` again. GitHub dates them today, so they move to the top.`]}),(0,D.jsx)($,{names:e.restar.map(e=>e.fullName)})]}),e.recreateLists.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Recreate `,Z(e.recreateLists.length,`List`),`.`]}),(0,D.jsx)($,{names:e.recreateLists.map(e=>e.isPrivate?`${e.name} (private)`:e.name)})]}),n.size>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Put `,Z(n.size,`repo`),` back in their Lists.`]}),(0,D.jsx)($,{names:[...n]})]}),t&&(0,D.jsx)(`p`,{children:`Fill in tags, ratings and notes this browser is missing. Nothing you have is overwritten.`}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A backup of how things are now is taken first, so you can go back.`})]})}function me(e){let t=[e.notesAndRatings>0&&`notes or ratings on ${Z(e.notesAndRatings,`repo`)}`,e.tagLinks>0&&Z(e.tagLinks,`tag`)].filter(e=>e!==!1);return t.length===0?`This browser already had every tag, rating and note.`:`Filled in ${t.join(` and `)}.`}function he({result:e}){return(0,D.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,D.jsxs)(`p`,{children:[`Starred `,Z(e.restarred,`repo`),` again, recreated `,Z(e.recreatedLists,`List`),`, and re-added`,` `,Z(e.addedToLists,`List entry`,`List entries`),`.`,e.local&&` ${me(e.local)}`]}),e.failed.length>0&&(0,D.jsxs)(`div`,{className:`rounded-md border border-destructive/40 p-2`,children:[(0,D.jsxs)(`p`,{className:`font-medium text-destructive`,children:[`GitHub refused `,Z(e.failed.length,`change`),`:`]}),(0,D.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:e.failed.map(e=>(0,D.jsxs)(`li`,{children:[e.what,`: `,e.reason]},e.what))})]})]})}export{le as component};
@@ -0,0 +1 @@
1
+ import{R as e,a as t,m as n,n as r,r as i}from"./button-ZbiqMfUE.js";var a=e(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]);function o(e){return t(e.defaultTagName??`div`,e,e)}var s=i(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function c({className:e,variant:t=`default`,render:i,...a}){return o({defaultTagName:`span`,props:n({className:r(s({variant:t}),e)},a),render:i,state:{slot:`badge`,variant:t}})}export{a as n,c as t};