@rozenite/storage-plugin 2.0.0 → 2.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.
- package/CHANGELOG.md +18 -0
- package/dist/devtools/assets/panel-BlDRXgVW.js +32 -0
- package/dist/devtools/assets/panel-DBweZnW5.css +1 -0
- package/dist/devtools/panel.html +2 -2
- package/dist/react-native/chunks/index.require.js +1 -3
- package/dist/react-native/chunks/secure-storage.require.js +2 -6
- package/dist/react-native/chunks/useRozeniteStoragePlugin.require.cjs +1 -1
- package/dist/react-native/chunks/useRozeniteStoragePlugin.require.js +266 -295
- package/dist/react-native/index.d.ts +14 -2
- package/dist/react-native/index.js +2 -10
- package/dist/rozenite.json +1 -1
- package/package.json +29 -29
- package/react-native.ts +11 -36
- package/rozenite.config.ts +2 -6
- package/sdk.ts +1 -5
- package/src/react-native/__tests__/entry-preview-pagination.test.ts +12 -40
- package/src/react-native/__tests__/export-snapshot.test.ts +2 -6
- package/src/react-native/__tests__/full-entry-request.test.ts +5 -17
- package/src/react-native/__tests__/import.test.ts +9 -8
- package/src/react-native/__tests__/storage-discovery.test.ts +7 -18
- package/src/react-native/__tests__/stress-verification.test.ts +5 -18
- package/src/react-native/__tests__/use-storage-agent-tools.test.ts +25 -35
- package/src/react-native/adapters/__tests__/mmkv.test.ts +20 -30
- package/src/react-native/adapters/async-storage.ts +2 -5
- package/src/react-native/adapters/index.ts +2 -8
- package/src/react-native/adapters/mmkv.ts +7 -24
- package/src/react-native/adapters/secure-storage.ts +2 -6
- package/src/react-native/entry-preview-pagination.ts +11 -27
- package/src/react-native/export-snapshot.ts +3 -9
- package/src/react-native/full-entry-request.ts +3 -8
- package/src/react-native/import.ts +10 -21
- package/src/react-native/storage-discovery.ts +2 -6
- package/src/react-native/storage-view.ts +2 -6
- package/src/react-native/useRozeniteStoragePlugin.ts +107 -119
- package/src/react-native/useStorageAgentTools.ts +8 -24
- package/src/shared/__tests__/entry-preview.test.ts +9 -27
- package/src/shared/__tests__/snapshot.test.ts +10 -32
- package/src/shared/agent-tools.ts +9 -30
- package/src/shared/entry-preview.ts +3 -8
- package/src/shared/messaging.ts +15 -11
- package/src/shared/snapshot.ts +4 -17
- package/src/shared/types.ts +2 -4
- package/src/ui/__tests__/binary-value-editor-state.test.ts +6 -16
- package/src/ui/__tests__/binary.test.ts +13 -33
- package/src/ui/__tests__/large-value-viewer.test.tsx +4 -13
- package/src/ui/__tests__/panel.test.tsx +41 -68
- package/src/ui/__tests__/storage-groups.test.ts +1 -4
- package/src/ui/__tests__/type-conversion.test.ts +8 -24
- package/src/ui/__tests__/use-storage-entries.test.tsx +18 -34
- package/src/ui/add-entry-dialog.tsx +4 -15
- package/src/ui/binary-value-editor-state.ts +6 -24
- package/src/ui/binary-value-editor.tsx +5 -17
- package/src/ui/binary.ts +6 -19
- package/src/ui/edit-entry-dialog.tsx +3 -11
- package/src/ui/editor-switcher.tsx +2 -11
- package/src/ui/entry-detail-dialog.tsx +5 -14
- package/src/ui/format-value.tsx +2 -9
- package/src/ui/import-dialog.tsx +7 -19
- package/src/ui/large-value-viewer-state.ts +2 -9
- package/src/ui/large-value-viewer.tsx +3 -9
- package/src/ui/panel.tsx +65 -153
- package/src/ui/query-client.tsx +4 -15
- package/src/ui/type-conversion.ts +2 -5
- package/src/ui/typed-value-editor.tsx +1 -5
- package/src/ui/use-storage-entries.ts +6 -21
- package/src/ui/utils.ts +1 -4
- package/dist/devtools/assets/panel-B6Wp0eie.css +0 -1
- package/dist/devtools/assets/panel-D7MFc4HG.js +0 -32
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-content:"";--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-medium:500;--font-weight-semibold:600;--leading-snug:1.375;--radius-lg:var(--radius);--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab,red,red)){*{outline-color:color-mix(in oklab,var(--ring) 50%,transparent)}}body{background-color:var(--background);color:var(--foreground);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif}::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background-color:var(--border);border-radius:var(--radius-lg);background-clip:padding-box;border:2px solid #0000}::-webkit-scrollbar-thumb:hover{background-color:var(--muted-foreground)}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.top-0{top:calc(var(--spacing) * 0)}.top-1\/2{top:50%}.top-4{top:calc(var(--spacing) * 4)}.right-1\.5{right:calc(var(--spacing) * 1.5)}.right-2{right:calc(var(--spacing) * 2)}.right-4{right:calc(var(--spacing) * 4)}.bottom-4{bottom:calc(var(--spacing) * 4)}.left-0\.5{left:calc(var(--spacing) * .5)}.left-2\.5{left:calc(var(--spacing) * 2.5)}.z-10{z-index:10}.z-50{z-index:50}.row-0{grid-row:0}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-1{margin-inline:calc(var(--spacing) * 1)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-auto{margin-top:auto}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3\.5{margin-left:calc(var(--spacing) * 3.5)}.ml-auto{margin-left:auto}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.list-item{display:list-item}.table{display:table}.size-1\.5{width:calc(var(--spacing) * 1.5);height:calc(var(--spacing) * 1.5)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-12{height:calc(var(--spacing) * 12)}.h-16{height:calc(var(--spacing) * 16)}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-20{max-height:calc(var(--spacing) * 20)}.max-h-24{max-height:calc(var(--spacing) * 24)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-96{max-height:calc(var(--spacing) * 96)}.max-h-\[70vh\]{max-height:70vh}.max-h-\[300px\]{max-height:300px}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-28{min-height:calc(var(--spacing) * 28)}.min-h-56{min-height:calc(var(--spacing) * 56)}.min-h-\[120px\]{min-height:120px}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-56{width:calc(var(--spacing) * 56)}.w-80{width:calc(var(--spacing) * 80)}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.max-w-2xl{max-width:var(--container-2xl)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-40{min-width:calc(var(--spacing) * 40)}.min-w-\[--anchor-width\]{min-width:--anchor-width}.min-w-full{min-width:100%}.flex-1{flex:1}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.origin-\(--transform-origin\){transform-origin:var(--transform-origin)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-90{rotate:90deg}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.resize-y{resize:vertical}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\[minmax\(7rem\,25\%\)_minmax\(3rem\,1fr\)\]{grid-template-columns:minmax(7rem,25%) minmax(3rem,1fr)}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) * .8)}.rounded-sm{border-radius:calc(var(--radius) * .6)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-0{border-right-style:var(--tw-border-style);border-right-width:0}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-border{border-color:var(--border)}.border-destructive\/40{border-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.border-destructive\/40{border-color:color-mix(in oklab,var(--destructive) 40%,transparent)}}.border-destructive\/50{border-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.border-destructive\/50{border-color:color-mix(in oklab,var(--destructive) 50%,transparent)}}.border-input{border-color:var(--input)}.border-ring{border-color:var(--ring)}.border-sidebar-border{border-color:var(--sidebar-border)}.bg-background,.bg-background\/70{background-color:var(--background)}@supports (color:color-mix(in lab,red,red)){.bg-background\/70{background-color:color-mix(in oklab,var(--background) 70%,transparent)}}.bg-border{background-color:var(--border)}.bg-card{background-color:var(--card)}.bg-destructive,.bg-destructive\/10{background-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.bg-destructive\/10{background-color:color-mix(in oklab,var(--destructive) 10%,transparent)}}.bg-foreground{background-color:var(--foreground)}.bg-muted{background-color:var(--muted)}.bg-popover{background-color:var(--popover)}.bg-primary{background-color:var(--primary)}.bg-secondary{background-color:var(--secondary)}.bg-sidebar{background-color:var(--sidebar)}.bg-transparent{background-color:#0000}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-0{padding-inline:calc(var(--spacing) * 0)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-10{padding-block:calc(var(--spacing) * 10)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pr-14{padding-right:calc(var(--spacing) * 14)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-8{padding-left:calc(var(--spacing) * 8)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.wrap-anywhere{overflow-wrap:anywhere}.break-all{word-break:break-all}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent{color:var(--accent)}.text-accent-foreground{color:var(--accent-foreground)}.text-background{color:var(--background)}.text-card-foreground{color:var(--card-foreground)}.text-destructive{color:var(--destructive)}.text-destructive-foreground{color:var(--destructive-foreground)}.text-foreground{color:var(--foreground)}.text-muted{color:var(--muted)}.text-muted-foreground,.text-muted-foreground\/60{color:var(--muted-foreground)}@supports (color:color-mix(in lab,red,red)){.text-muted-foreground\/60{color:color-mix(in oklab,var(--muted-foreground) 60%,transparent)}}.text-popover-foreground{color:var(--popover-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-sidebar-foreground,.text-sidebar-foreground\/60{color:var(--sidebar-foreground)}@supports (color:color-mix(in lab,red,red)){.text-sidebar-foreground\/60{color:color-mix(in oklab,var(--sidebar-foreground) 60%,transparent)}}.lowercase{text-transform:lowercase}.italic{font-style:italic}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[transform\,opacity\]{transition-property:transform,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[transform\,scale\,opacity\]{transition-property:transform,scale,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.running{animation-play-state:running}@media(hover:hover){.group-hover\:translate-x-0\.5:is(:where(.group):hover *){--tw-translate-x:calc(var(--spacing) * .5);translate:var(--tw-translate-x) var(--tw-translate-y)}.group-hover\:-translate-y-0\.5:is(:where(.group):hover *){--tw-translate-y:calc(var(--spacing) * -.5);translate:var(--tw-translate-x) var(--tw-translate-y)}}.group-aria-\[orientation\=horizontal\]\/split-handle\:h-3:is(:where(.group\/split-handle)[aria-orientation=horizontal] *){height:calc(var(--spacing) * 3)}.group-aria-\[orientation\=horizontal\]\/split-handle\:w-4:is(:where(.group\/split-handle)[aria-orientation=horizontal] *){width:calc(var(--spacing) * 4)}.group-aria-\[orientation\=horizontal\]\/split-handle\:rotate-90:is(:where(.group\/split-handle)[aria-orientation=horizontal] *){rotate:90deg}.group-aria-\[orientation\=vertical\]\/split-handle\:h-4:is(:where(.group\/split-handle)[aria-orientation=vertical] *){height:calc(var(--spacing) * 4)}.group-aria-\[orientation\=vertical\]\/split-handle\:w-3:is(:where(.group\/split-handle)[aria-orientation=vertical] *){width:calc(var(--spacing) * 3)}.placeholder\:text-muted-foreground::placeholder{color:var(--muted-foreground)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:inset-y-0:after{content:var(--tw-content);inset-block:calc(var(--spacing) * 0)}.after\:left-1\/2:after{content:var(--tw-content);left:50%}.after\:w-1:after{content:var(--tw-content);width:calc(var(--spacing) * 1)}.after\:-translate-x-1\/2:after{content:var(--tw-content);--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}@media(hover:hover){.hover\:bg-accent:hover,.hover\:bg-accent\/50:hover{background-color:var(--accent)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-accent\/50:hover{background-color:color-mix(in oklab,var(--accent) 50%,transparent)}}.hover\:bg-destructive\/90:hover{background-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-destructive\/90:hover{background-color:color-mix(in oklab,var(--destructive) 90%,transparent)}}.hover\:bg-muted-foreground:hover{background-color:var(--muted-foreground)}.hover\:bg-primary\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,var(--primary) 90%,transparent)}}.hover\:bg-secondary\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-secondary\/80:hover{background-color:color-mix(in oklab,var(--secondary) 80%,transparent)}}.hover\:bg-sidebar-accent:hover{background-color:var(--sidebar-accent)}.hover\:text-accent-foreground:hover{color:var(--accent-foreground)}.hover\:text-destructive:hover{color:var(--destructive)}.hover\:text-foreground:hover{color:var(--foreground)}.hover\:text-primary:hover{color:var(--primary)}.hover\:text-sidebar-accent-foreground:hover{color:var(--sidebar-accent-foreground)}.hover\:underline:hover{text-decoration-line:underline}}.focus-visible\:border-ring:focus-visible{border-color:var(--ring)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-ring:focus-visible,.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:var(--ring)}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:color-mix(in oklab, var(--ring) 50%, transparent)}}.focus-visible\:ring-sidebar-ring:focus-visible{--tw-ring-color:var(--sidebar-ring)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus-visible\:ring-offset-background:focus-visible{--tw-ring-offset-color:var(--background)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.aria-\[orientation\=horizontal\]\:h-px[aria-orientation=horizontal]{height:1px}.aria-\[orientation\=horizontal\]\:cursor-row-resize[aria-orientation=horizontal]{cursor:row-resize}.aria-\[orientation\=vertical\]\:w-px[aria-orientation=vertical]{width:1px}.aria-\[orientation\=vertical\]\:cursor-col-resize[aria-orientation=vertical]{cursor:col-resize}.data-\[checked\]\:translate-x-4[data-checked]{--tw-translate-x:calc(var(--spacing) * 4);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[checked\]\:border-primary[data-checked]{border-color:var(--primary)}.data-\[checked\]\:bg-primary[data-checked]{background-color:var(--primary)}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[ending-style\]\:scale-90[data-ending-style]{--tw-scale-x:90%;--tw-scale-y:90%;--tw-scale-z:90%;scale:var(--tw-scale-x) var(--tw-scale-y)}.data-\[ending-style\]\:scale-95[data-ending-style]{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.data-\[ending-style\]\:opacity-0[data-ending-style]{opacity:0}.data-\[highlighted\]\:bg-accent[data-highlighted]{background-color:var(--accent)}.data-\[highlighted\]\:text-accent-foreground[data-highlighted]{color:var(--accent-foreground)}.data-\[selected\]\:bg-background[data-selected]{background-color:var(--background)}.data-\[selected\]\:bg-sidebar-accent[data-selected]{background-color:var(--sidebar-accent)}.data-\[selected\]\:font-medium[data-selected]{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.data-\[selected\]\:text-foreground[data-selected]{color:var(--foreground)}.data-\[selected\]\:text-sidebar-accent-foreground[data-selected]{color:var(--sidebar-accent-foreground)}.data-\[selected\]\:shadow-xs[data-selected]{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[starting-style\]\:scale-90[data-starting-style]{--tw-scale-x:90%;--tw-scale-y:90%;--tw-scale-z:90%;scale:var(--tw-scale-x) var(--tw-scale-y)}.data-\[starting-style\]\:scale-95[data-starting-style]{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.data-\[starting-style\]\:opacity-0[data-starting-style]{opacity:0}@media(min-width:40rem){.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:size-3\.5 svg{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.\[\&_svg\]\:size-4 svg{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&_svg\]\:h-3\.5 svg{height:calc(var(--spacing) * 3.5)}.\[\&_svg\]\:w-3\.5 svg{width:calc(var(--spacing) * 3.5)}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&\:\:-webkit-search-cancel-button\]\:appearance-none::-webkit-search-cancel-button{appearance:none}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:none}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}:root{--radius:0;--background:#fff;--foreground:#201f24;--card:#fff;--card-foreground:#201f24;--popover:#fff;--popover-foreground:#201f24;--primary:#8232ff;--primary-foreground:#fff;--secondary:#f9f8fd;--secondary-foreground:#201f24;--muted:#f9f8fd;--muted-foreground:#838289;--accent:#8232ff29;--accent-foreground:#201f24;--destructive:#fa7171;--destructive-foreground:#201f24;--border:#cfced5;--input:#cfced5;--ring:#8232ff;--sidebar:#fff;--sidebar-foreground:#201f24;--sidebar-primary:#8232ff;--sidebar-primary-foreground:#fff;--sidebar-accent:#8232ff29;--sidebar-accent-foreground:#201f24;--sidebar-border:#cfced5;--sidebar-ring:#8232ff}.dark{--background:#201f24;--foreground:#fff;--card:#201f24;--card-foreground:#fff;--popover:#2b2a2f;--popover-foreground:#fff;--primary:#8232ff;--primary-foreground:#fff;--secondary:#2b2a2f;--secondary-foreground:#fff;--muted:#2b2a2f;--muted-foreground:#cfced5;--accent:#8232ff33;--accent-foreground:#fff;--destructive:#fa7171;--destructive-foreground:#201f24;--border:#424145;--input:#424145;--ring:#8232ff;--sidebar:#201f24;--sidebar-foreground:#fff;--sidebar-primary:#8232ff;--sidebar-primary-foreground:#fff;--sidebar-accent:#8232ff33;--sidebar-accent-foreground:#fff;--sidebar-border:#424145;--sidebar-ring:#8232ff}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}
|
package/dist/devtools/panel.html
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
<script>
|
|
23
23
|
var __ROZENITE_PANEL__ = true;
|
|
24
24
|
</script>
|
|
25
|
-
<script type="module" crossorigin src="../devtools/assets/panel-
|
|
26
|
-
<link rel="stylesheet" crossorigin href="../devtools/assets/panel-
|
|
25
|
+
<script type="module" crossorigin src="../devtools/assets/panel-BlDRXgVW.js"></script>
|
|
26
|
+
<link rel="stylesheet" crossorigin href="../devtools/assets/panel-DBweZnW5.css">
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<div id="root"></div>
|
|
@@ -7,9 +7,7 @@ const u = (e) => "remove" in e, c = (e) => {
|
|
|
7
7
|
throw new Error(
|
|
8
8
|
"[Rozenite] Storage Plugin: MMKV arrays are not supported for v4 storages. Pass a record of storage IDs and MMKV instances."
|
|
9
9
|
);
|
|
10
|
-
return Object.fromEntries(
|
|
11
|
-
e.map((t) => [t.id, t])
|
|
12
|
-
);
|
|
10
|
+
return Object.fromEntries(e.map((t) => [t.id, t]));
|
|
13
11
|
}
|
|
14
12
|
return e;
|
|
15
13
|
}, f = (e) => {
|
|
@@ -30,17 +30,13 @@ const s = async (t) => Array.isArray(t) ? t : t(), u = ({
|
|
|
30
30
|
},
|
|
31
31
|
set: async (e) => {
|
|
32
32
|
if (e.type !== "string")
|
|
33
|
-
throw new Error(
|
|
34
|
-
"Expo SecureStore adapter supports only string values."
|
|
35
|
-
);
|
|
33
|
+
throw new Error("Expo SecureStore adapter supports only string values.");
|
|
36
34
|
await t.setItemAsync(e.key, e.value);
|
|
37
35
|
},
|
|
38
36
|
delete: (e) => t.deleteItemAsync(e),
|
|
39
37
|
clear: async () => {
|
|
40
38
|
const e = await s(a);
|
|
41
|
-
await Promise.all(
|
|
42
|
-
e.map((r) => t.deleteItemAsync(r))
|
|
43
|
-
);
|
|
39
|
+
await Promise.all(e.map((r) => t.deleteItemAsync(r)));
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
}]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("@rozenite/plugin-bridge"),N=require("react"),w=require("./types.cjs"),I=require("@rozenite/agent-bridge"),y=require("@rozenite/agent-shared"),V="@rozenite/storage-plugin",R=1;class u extends Error{constructor(t,r){super(r),this.path=t}}const p=e=>e===null?"null":Array.isArray(e)?"array":typeof e,G=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),T=(e,t)=>{if(!G(e))throw new u(t,`Expected object, got ${p(e)}`);return e},f=(e,t)=>{if(typeof e!="string")throw new u(t,`Expected string, got ${p(e)}`);return e},C=(e,t)=>{if(!Array.isArray(e))throw new u(t,`Expected array, got ${p(e)}`);return e},M=(e,t)=>{if(typeof e!="string"||!w.DEFAULT_SUPPORTED_TYPES.includes(e))throw new u(t,`Expected one of ${w.DEFAULT_SUPPORTED_TYPES.join(", ")}, got ${p(e)}`);return e},B=(e,t)=>{const r=T(e,t);return{supportedTypes:C(r.supportedTypes,`${t}.supportedTypes`).map((a,i)=>M(a,`${t}.supportedTypes[${i}]`))}},Y=e=>{const t=T(e,"storage");return{adapterId:f(t.adapterId,"storage.adapterId"),storageId:f(t.storageId,"storage.storageId"),adapterName:f(t.adapterName,"storage.adapterName"),storageName:f(t.storageName,"storage.storageName"),capabilities:B(t.capabilities,"storage.capabilities")}},Q=(e,t)=>{const r=T(e,t),o=f(r.key,`${t}.key`),s=M(r.type,`${t}.type`),a=`${t}.value`;switch(s){case"string":{const i=r.value;if(typeof i!="string")throw new u(a,`Expected string for type "string", got ${p(i)}`);return{key:o,type:"string",value:i}}case"number":{const i=r.value;if(typeof i!="number"||!Number.isFinite(i))throw new u(a,`Expected finite number for type "number", got ${p(i)}`);return{key:o,type:"number",value:i}}case"boolean":{const i=r.value;if(typeof i!="boolean")throw new u(a,`Expected boolean for type "boolean", got ${p(i)}`);return{key:o,type:"boolean",value:i}}case"buffer":{const i=r.value;if(!Array.isArray(i))throw new u(a,`Expected number[] for type "buffer", got ${p(i)}`);const n=i.map((c,g)=>{if(typeof c!="number"||!Number.isInteger(c)||c<0||c>255)throw new u(`${a}[${g}]`,`Expected uint8 (integer 0-255), got ${p(c)}`);return c});return{key:o,type:"buffer",value:n}}}},J=e=>{try{const t=T(e,"$"),r=t.version;if(r!==R)throw new u("version",`Unsupported snapshot version: ${p(r)} (this build supports version ${R})`);const o=f(t.plugin,"plugin"),s=f(t.createdAt,"createdAt"),a=Y(t.storage),n=C(t.entries,"entries").map((c,g)=>Q(c,`entries[${g}]`));return{ok:!0,snapshot:{version:R,plugin:o,createdAt:s,storage:a,entries:n}}}catch(t){if(t instanceof u)return{ok:!1,error:{path:t.path,message:t.message}};throw t}},W=e=>({version:1,plugin:V,createdAt:new Date().toISOString(),storage:{adapterId:e.target.adapterId,storageId:e.target.storageId,adapterName:e.adapterName,storageName:e.storageName,capabilities:e.capabilities},entries:e.entries}),X=(e,t)=>{const r=[],o=[],s=[],a=[],i=[];for(const[c,g]of e.entries.entries()){if(!w.supportsType(t.capabilities,g.type)){a.push({key:g.key,type:g.type});continue}if(t.isBlacklisted(g.key)){s.push({key:g.key,reason:"blacklist"});continue}t.entryKeys.has(g.key)?o.push(g.key):r.push(g.key),i.push(c),t.entryKeys.add(g.key)}const n=e.storage.adapterId!==t.target.adapterId||e.storage.storageId!==t.target.storageId;return{newKeys:r,overwriteKeys:o,skippedKeys:s,unsupportedTypes:a,acceptedEntryIndexes:i,metadataMismatch:n}},H=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,$=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,O=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",Z=e=>{if(typeof e!="object"||e==null||Array.isArray(e))return!1;const t=e;return typeof t.key!="string"?!1:t.type==="string"?typeof t.value=="string":t.type==="number"?typeof t.value=="number":t.type==="boolean"?typeof t.value=="boolean":t.type==="buffer"&&Array.isArray(t.value)&&t.value.every(r=>typeof r=="number"&&Number.isInteger(r)&&r>=0&&r<=255)},U=(e,t)=>e.blacklist?(e.blacklist.lastIndex=0,e.blacklist.test(t)):!1,K=(e,t)=>e.find(r=>H(r.target,t)),ee=async(e,t)=>{const r=O(t),o=t,s=J(o.snapshot);if(typeof o!="object"||o==null||o.type!=="preview-import"||typeof o.requestId!="string"||o.requestId.trim().length===0||!$(o.target)||!s.ok)return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Import preview requests require a valid target, request ID, and snapshot."};const a=K(e,o.target);if(!a)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};try{const i=new Set(await a.getAllKeys());return{type:"import-preview",requestId:r,target:a.target,preview:X(s.snapshot,{target:a.target,capabilities:a.capabilities,entryKeys:i,isBlacklisted:n=>U(a,n)})}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to inspect the requested storage for import."}}},te=async(e,t,r)=>{const o=O(t),s=t;if(typeof s!="object"||s==null||s.type!=="import-entries"||typeof s.requestId!="string"||s.requestId.trim().length===0||!$(s.target)||!Array.isArray(s.entries)||!s.entries.every(Z)){r({type:"import-result",requestId:o,target:$(s.target)?s.target:{adapterId:"",storageId:""},ok:!1,written:0,total:0,error:"Import requests require a valid target, request ID, and entries."});return}const a=K(e,s.target);if(!a){r({type:"import-result",requestId:s.requestId,target:s.target,ok:!1,written:0,total:s.entries.length,error:"Target storage not found"});return}const i=s.entries.filter(n=>w.supportsType(a.capabilities,n.type)&&!U(a,n.key));for(let n=0;n<i.length;n++){const c=i[n];try{await a.set(c)}catch(g){n>0&&r({type:"storage-invalidated",target:s.target,operation:"import"}),r({type:"import-result",requestId:s.requestId,target:s.target,ok:!1,written:n,total:i.length,failedKey:c.key,error:g instanceof Error?g.message:String(g)});return}r({type:"import-progress",requestId:s.requestId,target:s.target,written:n+1,total:i.length})}i.length>0&&r({type:"storage-invalidated",target:s.target,operation:"import"}),r({type:"import-result",requestId:s.requestId,target:s.target,ok:!0,written:i.length,total:i.length})},re=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",se=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&e.type==="discover-storages"&&typeof e.requestId=="string"&&e.requestId.trim().length>0,ne=async e=>({target:e.target,adapterName:e.adapterName,storageName:e.storageName,entryCount:(await e.getAllKeys()).length,capabilities:e.capabilities,supportsSubscriptions:e.supportsSubscriptions}),oe=e=>{const t=new Set;return e.some(({target:r})=>{const o=`${r.adapterId}:${r.storageId}`;return t.has(o)?!0:(t.add(o),!1)})},ae=async(e,t)=>{const r=re(t);if(!se(t))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Storage discovery requires a non-empty request ID."};try{if(oe(e))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Configured storages must have unique targets."};const o=await Promise.all(e.map(ne));return{type:"storage-descriptors",requestId:r,storages:o}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to discover configured storages."}}},ie=256,k=16,ce=e=>e.toString(16).toUpperCase().padStart(2,"0"),ge=e=>{let t="",r=0;for(const o of e){if(r===ie)return{preview:t,isTruncated:!0};t+=o,r+=1}return{preview:t,isTruncated:!1}},de=e=>{if(e.type==="string")return{key:e.key,type:e.type,...ge(e.value),valueSize:e.value.length};if(e.type==="buffer"){const r=e.value.slice(0,k);return{key:e.key,type:e.type,preview:r.map(ce).join(" "),valueSize:e.value.length,isTruncated:e.value.length>k}}const t=String(e.value);return{key:e.key,type:e.type,preview:t,valueSize:t.length,isTruncated:!1}},ue=100,pe=4,le=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",L=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,ye=e=>(e??"").trim().toLowerCase(),fe=e=>{if(typeof e!="object"||e==null||Array.isArray(e)||e.type!=="list-entry-previews"||typeof e.requestId!="string"||e.requestId.trim().length===0||!L(e.target)||e.search!==void 0&&typeof e.search!="string"||e.cursor!==void 0&&typeof e.cursor!="string"||!Number.isFinite(e.limit)||!Number.isInteger(e.limit)||e.limit<1)return;const t=e.keySortDirection;if(t!==void 0&&t!=="ascending"&&t!=="descending")return;const r=e;return{...r,search:ye(r.search),keySortDirection:t??"ascending",limit:Math.min(r.limit,ue)}},D=e=>btoa(encodeURIComponent(JSON.stringify(e))),Ie=e=>{try{const t=JSON.parse(decodeURIComponent(atob(e)));return typeof t!="object"||t==null||Array.isArray(t)||t.version!==1||!L(t.target)||typeof t.search!="string"||t.keySortDirection!=="ascending"&&t.keySortDirection!=="descending"||typeof t.boundaryKey!="string"||t.direction!=="next"&&t.direction!=="previous"?void 0:t}catch{return}},P=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,me=(e,t)=>e<t?-1:e>t?1:0,he=async(e,t)=>{const r=new Array(t.length);let o=0;const s=async()=>{for(;o<t.length;){const a=o;o+=1;const i=await e.get(t[a]);i&&(r[a]=de(i))}};return await Promise.all(Array.from({length:Math.min(pe,t.length)},s)),r.filter(a=>a!=null)},be=async(e,t)=>{const r=le(t),o=fe(t);if(!o)return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Entry preview requests require a valid target, request ID, and positive integer limit."};const s=e.find(i=>P(i.target,o.target));if(!s)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};let a;if(o.cursor!==void 0&&(a=Ie(o.cursor),!a||!P(a.target,o.target)||a.search!==o.search||a.keySortDirection!==o.keySortDirection))return{type:"storage-request-error",requestId:r,code:"INVALID_CURSOR",message:"The entry preview cursor is invalid or belongs to a different query.",resetPagination:!0};try{const i=(await s.getAllKeys()).filter(E=>E.toLowerCase().includes(o.search)).sort(me);o.keySortDirection==="descending"&&i.reverse();let n=0;if(a){const E=i.indexOf(a.boundaryKey);if(E===-1)return{type:"storage-request-error",requestId:r,code:"INVALID_CURSOR",message:"The entry preview cursor is stale after storage changes.",resetPagination:!0};n=a.direction==="next"?E+1:Math.max(0,E-o.limit)}const c=i.slice(n,n+o.limit),g=await he(s,c),d=n+c.length,l={version:1,target:o.target,search:o.search,keySortDirection:o.keySortDirection};return{type:"entry-previews",requestId:r,target:o.target,items:g,...d<i.length&&c.length>0?{nextCursor:D({...l,boundaryKey:c.at(-1),direction:"next"})}:{},...n>0&&c.length>0?{previousCursor:D({...l,boundaryKey:c[0],direction:"previous"})}:{}}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to read entry previews from the requested storage."}}},we=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",Ee=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,Ae=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,qe=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&e.type==="get-entry"&&typeof e.requestId=="string"&&e.requestId.trim().length>0&&Ee(e.target)&&typeof e.key=="string",Se=async(e,t)=>{const r=we(t);if(!qe(t))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Full entry requests require a valid target, request ID, and string key."};const o=e.find(s=>Ae(s.target,t.target));if(!o)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};try{const s=await o.get(t.key);return s?{type:"entry",requestId:r,target:o.target,entry:s}:{type:"storage-request-error",requestId:r,code:"ENTRY_NOT_FOUND",message:"The requested storage entry was not found."}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to read the requested storage entry."}}},Te=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",ve=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,Re=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,$e=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&e.type==="export-snapshot"&&typeof e.requestId=="string"&&e.requestId.trim().length>0&&ve(e.target),Ne=async(e,t)=>{const r=Te(t);if(!$e(t))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Export requests require a valid target and request ID."};const o=e.find(s=>Re(s.target,t.target));if(!o)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};try{const s=await o.getAllEntries();return{type:"export-snapshot-result",requestId:r,target:o.target,snapshot:W({target:o.target,adapterName:o.adapterName,storageName:o.storageName,capabilities:o.capabilities,entries:s})}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to export the requested storage."}}},v=e=>e.kind==="async",S=(e,t)=>e.shouldFilterKey?.(t)?!0:e.blacklist?(e.blacklist.lastIndex=0,e.blacklist.test(t)):!1,ke=(e,t,r)=>{if(!w.supportsType(e,t))throw new Error(`Type "${t}" is not supported by storage "${r.storageId}" in adapter "${r.adapterId}".`)},_=async e=>(v(e),e.getAllKeys()),x=async(e,t)=>(v(e),e.get(t)),De=async(e,t)=>{if(v(e)){await e.set(t);return}e.set(t)},Pe=async(e,t)=>{if(v(e)){await e.delete(t);return}e.delete(t)},_e=async e=>{await e.clear()},xe=(e,t)=>{const r=t.storage,o=r.subscribe,s=new Set;let a=!1;const i={adapterId:e.id,storageId:t.id},n=async g=>{if(!S(t,g))return x(r,g)},c=async()=>{const g=await _(r);return(await Promise.all(g.filter(l=>!S(t,l)).map(l=>x(r,l)))).filter(l=>!!l)};return{id:w.getStorageViewId(i),target:i,adapterName:e.name,storageName:t.name,capabilities:t.capabilities,supportsSubscriptions:o!=null,blacklist:t.blacklist,get:n,set:async g=>{ke(t.capabilities,g.type,i),s.add(g.key);try{await De(r,g)}finally{s.delete(g.key)}},delete:async g=>{s.add(g);try{await Pe(r,g)}finally{s.delete(g)}},purge:async()=>{a=!0;try{await _e(r)}finally{a=!1}},getAllKeys:async()=>(await _(r)).filter(d=>!S(t,d)),getAllEntries:c,...o?{watch:async g=>o(d=>{!a&&!s.has(d)&&!S(t,d)&&g(d)})}:{}}},je=e=>e.flatMap(t=>t.storages.map(r=>xe(t,r))),A={adapterId:{type:"string",description:"Storage adapter ID. Required when multiple adapters are configured."},storageId:{type:"string",description:"Storage node ID within the adapter. Required when multiple storages are configured."}},m="@rozenite/storage-plugin",j=["string","number","boolean","buffer"],h={listStorages:y.defineAgentToolContract({name:"list-storages",description:"List all storage adapters and their storage nodes currently available on the device, including supported entry types. Entry counts are omitted to avoid enumerating every storage.",inputSchema:{type:"object",properties:{}}}),listEntries:y.definePaginatedAgentToolContract({name:"list-entries",description:"List keys in a storage. This call intentionally does not return entry values to keep responses token-efficient.",inputSchema:{type:"object",properties:{...A,limit:{type:"number",description:"Pagination size. Defaults to 20 and is capped at 100."},cursor:{type:"string",description:"Opaque pagination cursor from a previous list-entries call."},offset:{type:"number",description:"Deprecated initial pagination offset. Must be a non-negative integer and cannot be combined with cursor."}}},pagination:{kind:"cursor",fields:["key"],defaultFields:["key"]}}),readEntry:y.defineAgentToolContract({name:"read-entry",description:"Read a single storage entry value by key.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."}},required:["key"]}}),createEntry:y.defineAgentToolContract({name:"create-entry",description:"Create a new storage entry. Fails if the key already exists.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."},type:{type:"string",enum:[...j],description:"Entry value type. Must be one of the supported types for the target storage (see list-storages)."},value:{description:"Entry value matching the provided type."}},required:["key","type","value"]}}),editEntry:y.defineAgentToolContract({name:"edit-entry",description:"Edit an existing storage entry. Fails if the key does not exist.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."},type:{type:"string",enum:[...j],description:"Entry value type. Must be one of the supported types for the target storage (see list-storages)."},value:{description:"Entry value matching the provided type."}},required:["key","type","value"]}}),removeEntry:y.defineAgentToolContract({name:"remove-entry",description:"Remove a storage entry by key.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."}},required:["key"]}})},F=(e,t)=>{if(e==="string"){if(typeof t!="string")throw new Error("Expected string value for type=string");return t}if(e==="number"){if(typeof t!="number"||Number.isNaN(t))throw new Error("Expected number value for type=number");return t}if(e==="boolean"){if(typeof t!="boolean")throw new Error("Expected boolean value for type=boolean");return t}if(!Array.isArray(t)||!t.every(r=>Number.isInteger(r)))throw new Error("Expected number[] value for type=buffer");return t},b=e=>`${e.target.adapterId}/${e.target.storageId}`,Fe=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,Ce=e=>btoa(encodeURIComponent(JSON.stringify(e))),Me=e=>{try{const t=JSON.parse(decodeURIComponent(atob(e)));if(typeof t!="object"||t==null||Array.isArray(t)||t.version!==1||typeof t.target?.adapterId!="string"||typeof t.target?.storageId!="string"||!Number.isSafeInteger(t.offset)||t.offset<0)throw new Error("Invalid cursor");return t}catch{throw new Error("Invalid cursor. Run list-entries again without a cursor to restart pagination.")}},Oe=e=>typeof e!="number"||!Number.isFinite(e)||!Number.isInteger(e)||e<1?y.DEFAULT_PAGE_LIMIT:Math.min(e,y.MAX_PAGE_LIMIT),Ue=e=>typeof e!="number"||!Number.isFinite(e)||!Number.isSafeInteger(e)||e<0?0:e,q=(e,t,r)=>{if(e.length===0)throw new Error("No storages are registered.");if(t!==void 0||r!==void 0){const o=e.filter(a=>(t===void 0||a.target.adapterId===t)&&(r===void 0||a.target.storageId===r)),s=[t!==void 0&&`adapterId="${t}"`,r!==void 0&&`storageId="${r}"`].filter(Boolean).join(", ");if(o.length===0)throw new Error(`No storage matched ${s}. Available: ${e.map(b).join(", ")}`);if(o.length>1)throw new Error(`Multiple storages matched ${s}. Provide both adapterId and storageId. Available: ${o.map(b).join(", ")}`);return o[0]}if(e.length>1)throw new Error(`Multiple storages detected. Provide adapterId and/or storageId. Available: ${e.map(b).join(", ")}`);return e[0]},Ke=async(e,t)=>{const r=Oe(t.limit);if(t.cursor!==void 0&&t.offset!==void 0)throw new Error("Provide either cursor or offset, not both.");const o=t.cursor===void 0?void 0:Me(t.cursor);if(o&&!Fe(o.target,e.target))throw new Error("Cursor does not match the requested storage. Run list-entries again without a cursor to restart pagination.");const s=await e.getAllKeys(),a=o?.offset??Ue(t.offset),i=Math.min(a+r,s.length);return{adapterId:e.target.adapterId,storageId:e.target.storageId,total:s.length,items:s.slice(a,i).map(n=>({key:n})),page:{limit:r,hasMore:i<s.length,...i<s.length?{nextCursor:Ce({version:1,target:e.target,offset:i})}:{}}}},Le=e=>({listStorages:async()=>({storages:e.map(t=>({adapterId:t.target.adapterId,storageId:t.target.storageId,adapterName:t.adapterName,storageName:t.storageName,supportedTypes:t.capabilities.supportedTypes}))}),listEntries:async t=>{const r=q(e,t.adapterId,t.storageId);return Ke(r,t)},readEntry:async({adapterId:t,storageId:r,key:o})=>{const s=q(e,t,r),a=await s.get(o);if(!a)throw new Error(`Key "${o}" not found in storage "${b(s)}".`);return{adapterId:s.target.adapterId,storageId:s.target.storageId,entry:a}}}),ze=e=>{const t=Le(e);I.useRozenitePluginAgentTool({pluginId:m,tool:h.listStorages,handler:t.listStorages}),I.useRozenitePluginAgentTool({pluginId:m,tool:h.listEntries,handler:t.listEntries}),I.useRozenitePluginAgentTool({pluginId:m,tool:h.readEntry,handler:t.readEntry}),I.useRozenitePluginAgentTool({pluginId:m,tool:h.createEntry,handler:async({adapterId:r,storageId:o,key:s,type:a,value:i})=>{const n=q(e,r,o);if(await n.get(s))throw new Error(`Key "${s}" already exists in storage "${b(n)}". Use edit-entry instead.`);const g=F(a,i);return await n.set({key:s,type:a,value:g}),{adapterId:n.target.adapterId,storageId:n.target.storageId,created:!0,key:s}}}),I.useRozenitePluginAgentTool({pluginId:m,tool:h.editEntry,handler:async({adapterId:r,storageId:o,key:s,type:a,value:i})=>{const n=q(e,r,o);if(!await n.get(s))throw new Error(`Key "${s}" not found in storage "${b(n)}". Use create-entry instead.`);const g=F(a,i);return await n.set({key:s,type:a,value:g}),{adapterId:n.target.adapterId,storageId:n.target.storageId,edited:!0,key:s}}}),I.useRozenitePluginAgentTool({pluginId:m,tool:h.removeEntry,handler:async({adapterId:r,storageId:o,key:s})=>{const a=q(e,r,o),i=!!await a.get(s);return await a.delete(s),{adapterId:a.target.adapterId,storageId:a.target.storageId,removed:i,key:s}}})},Ve=({storages:e})=>{const t=N.useMemo(()=>je(e),[e]);ze(t);const r=z.useRozeniteDevToolsClient({pluginId:"@rozenite/storage-plugin"});return N.useEffect(()=>{if(!r)return;const o=[];let s=!1;const a=(n,c,g)=>{r.send("storage-invalidated",{type:"storage-invalidated",target:n,key:c,operation:g})};Promise.all(t.filter(n=>n.supportsSubscriptions&&n.watch).map(async n=>{try{const c=n.watch;if(!c)return;const g=await c(d=>{a(n.target,d)});if(s){g.remove();return}o.push(g)}catch(c){console.warn(`[Rozenite] Storage Plugin: Failed to attach watcher for ${n.target.adapterId}/${n.target.storageId}.`,c)}}));const i=[r.onMessage("set-entry",async({target:n,entry:c})=>{const g=t.find(d=>d.target.adapterId===n.adapterId&&d.target.storageId===n.storageId);if(!g){console.warn(`[Rozenite] Storage Plugin: Storage target not found for ${n.adapterId}/${n.storageId}`);return}try{await g.set(c),a(g.target,c.key,"set")}catch(d){console.warn(`[Rozenite] Storage Plugin: Failed to set entry in ${n.adapterId}/${n.storageId}.`,d)}}),r.onMessage("delete-entry",async({target:n,key:c})=>{const g=t.find(d=>d.target.adapterId===n.adapterId&&d.target.storageId===n.storageId);if(!g){console.warn(`[Rozenite] Storage Plugin: Storage target not found for ${n.adapterId}/${n.storageId}`);return}try{await g.delete(c),a(g.target,c,"delete")}catch(d){console.warn(`[Rozenite] Storage Plugin: Failed to delete entry in ${n.adapterId}/${n.storageId}.`,d)}}),r.onMessage("purge-storage",async({target:n})=>{const c=t.find(g=>g.target.adapterId===n.adapterId&&g.target.storageId===n.storageId);if(!c){console.warn(`[Rozenite] Storage Plugin: Storage target not found for ${n.adapterId}/${n.storageId}`);return}try{await c.purge(),a(c.target,void 0,"purge")}catch(g){console.warn(`[Rozenite] Storage Plugin: Failed to purge storage in ${n.adapterId}/${n.storageId}.`,g)}}),r.onMessage("discover-storages",async n=>{const c=await ae(t,n);r.send(c.type,c)}),r.onMessage("list-entry-previews",async n=>{const c=await be(t,n);r.send(c.type,c)}),r.onMessage("get-entry",async n=>{const c=await Se(t,n);r.send(c.type,c)}),r.onMessage("export-snapshot",async n=>{const c=await Ne(t,n);r.send(c.type,c)}),r.onMessage("preview-import",async n=>{const c=await ee(t,n);r.send(c.type,c)}),r.onMessage("import-entries",async n=>{await te(t,n,c=>{r.send(c.type,c)})})];return()=>{s=!0,o.forEach(n=>n.remove()),i.forEach(n=>n.remove())}},[r,t]),r};exports.useRozeniteStoragePlugin=Ve;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("@rozenite/plugin-bridge"),N=require("react"),E=require("./types.cjs"),h=require("@rozenite/agent-bridge"),f=require("@rozenite/agent-shared"),V="@rozenite/storage-plugin",R=1;class u extends Error{constructor(t,r){super(r),this.path=t}}const y=e=>e===null?"null":Array.isArray(e)?"array":typeof e,G=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),T=(e,t)=>{if(!G(e))throw new u(t,`Expected object, got ${y(e)}`);return e},I=(e,t)=>{if(typeof e!="string")throw new u(t,`Expected string, got ${y(e)}`);return e},F=(e,t)=>{if(!Array.isArray(e))throw new u(t,`Expected array, got ${y(e)}`);return e},K=(e,t)=>{if(typeof e!="string"||!E.DEFAULT_SUPPORTED_TYPES.includes(e))throw new u(t,`Expected one of ${E.DEFAULT_SUPPORTED_TYPES.join(", ")}, got ${y(e)}`);return e},B=(e,t)=>{const r=T(e,t);return{supportedTypes:F(r.supportedTypes,`${t}.supportedTypes`).map((a,i)=>K(a,`${t}.supportedTypes[${i}]`))}},Y=e=>{const t=T(e,"storage");return{adapterId:I(t.adapterId,"storage.adapterId"),storageId:I(t.storageId,"storage.storageId"),adapterName:I(t.adapterName,"storage.adapterName"),storageName:I(t.storageName,"storage.storageName"),capabilities:B(t.capabilities,"storage.capabilities")}},Q=(e,t)=>{const r=T(e,t),o=I(r.key,`${t}.key`),n=K(r.type,`${t}.type`),a=`${t}.value`;switch(n){case"string":{const i=r.value;if(typeof i!="string")throw new u(a,`Expected string for type "string", got ${y(i)}`);return{key:o,type:"string",value:i}}case"number":{const i=r.value;if(typeof i!="number"||!Number.isFinite(i))throw new u(a,`Expected finite number for type "number", got ${y(i)}`);return{key:o,type:"number",value:i}}case"boolean":{const i=r.value;if(typeof i!="boolean")throw new u(a,`Expected boolean for type "boolean", got ${y(i)}`);return{key:o,type:"boolean",value:i}}case"buffer":{const i=r.value;if(!Array.isArray(i))throw new u(a,`Expected number[] for type "buffer", got ${y(i)}`);const s=i.map((c,g)=>{if(typeof c!="number"||!Number.isInteger(c)||c<0||c>255)throw new u(`${a}[${g}]`,`Expected uint8 (integer 0-255), got ${y(c)}`);return c});return{key:o,type:"buffer",value:s}}}},J=e=>{try{const t=T(e,"$"),r=t.version;if(r!==R)throw new u("version",`Unsupported snapshot version: ${y(r)} (this build supports version ${R})`);const o=I(t.plugin,"plugin"),n=I(t.createdAt,"createdAt"),a=Y(t.storage),s=F(t.entries,"entries").map((c,g)=>Q(c,`entries[${g}]`));return{ok:!0,snapshot:{version:R,plugin:o,createdAt:n,storage:a,entries:s}}}catch(t){if(t instanceof u)return{ok:!1,error:{path:t.path,message:t.message}};throw t}},W=e=>({version:1,plugin:V,createdAt:new Date().toISOString(),storage:{adapterId:e.target.adapterId,storageId:e.target.storageId,adapterName:e.adapterName,storageName:e.storageName,capabilities:e.capabilities},entries:e.entries}),X=(e,t)=>{const r=[],o=[],n=[],a=[],i=[];for(const[c,g]of e.entries.entries()){if(!E.supportsType(t.capabilities,g.type)){a.push({key:g.key,type:g.type});continue}if(t.isBlacklisted(g.key)){n.push({key:g.key,reason:"blacklist"});continue}t.entryKeys.has(g.key)?o.push(g.key):r.push(g.key),i.push(c),t.entryKeys.add(g.key)}const s=e.storage.adapterId!==t.target.adapterId||e.storage.storageId!==t.target.storageId;return{newKeys:r,overwriteKeys:o,skippedKeys:n,unsupportedTypes:a,acceptedEntryIndexes:i,metadataMismatch:s}},H=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,$=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,M=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",Z=e=>{if(typeof e!="object"||e==null||Array.isArray(e))return!1;const t=e;return typeof t.key!="string"?!1:t.type==="string"?typeof t.value=="string":t.type==="number"?typeof t.value=="number":t.type==="boolean"?typeof t.value=="boolean":t.type==="buffer"&&Array.isArray(t.value)&&t.value.every(r=>typeof r=="number"&&Number.isInteger(r)&&r>=0&&r<=255)},O=(e,t)=>e.blacklist?(e.blacklist.lastIndex=0,e.blacklist.test(t)):!1,U=(e,t)=>e.find(r=>H(r.target,t)),ee=async(e,t)=>{const r=M(t),o=t,n=J(o.snapshot);if(typeof o!="object"||o==null||o.type!=="preview-import"||typeof o.requestId!="string"||o.requestId.trim().length===0||!$(o.target)||!n.ok)return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Import preview requests require a valid target, request ID, and snapshot."};const a=U(e,o.target);if(!a)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};try{const i=new Set(await a.getAllKeys());return{type:"import-preview",requestId:r,target:a.target,preview:X(n.snapshot,{target:a.target,capabilities:a.capabilities,entryKeys:i,isBlacklisted:s=>O(a,s)})}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to inspect the requested storage for import."}}},te=async(e,t,r)=>{const o=M(t),n=t;if(typeof n!="object"||n==null||n.type!=="import-entries"||typeof n.requestId!="string"||n.requestId.trim().length===0||!$(n.target)||!Array.isArray(n.entries)||!n.entries.every(Z)){r({type:"import-result",requestId:o,target:$(n.target)?n.target:{adapterId:"",storageId:""},ok:!1,written:0,total:0,error:"Import requests require a valid target, request ID, and entries."});return}const a=U(e,n.target);if(!a){r({type:"import-result",requestId:n.requestId,target:n.target,ok:!1,written:0,total:n.entries.length,error:"Target storage not found"});return}const i=n.entries.filter(s=>E.supportsType(a.capabilities,s.type)&&!O(a,s.key));for(let s=0;s<i.length;s++){const c=i[s];try{await a.set(c)}catch(g){if(s>0){const d=(await a.getAllKeys()).length;r({type:"storage-invalidated",target:n.target,operation:"import",entryCount:d})}r({type:"import-result",requestId:n.requestId,target:n.target,ok:!1,written:s,total:i.length,failedKey:c.key,error:g instanceof Error?g.message:String(g)});return}r({type:"import-progress",requestId:n.requestId,target:n.target,written:s+1,total:i.length})}if(i.length>0){const s=(await a.getAllKeys()).length;r({type:"storage-invalidated",target:n.target,operation:"import",entryCount:s})}r({type:"import-result",requestId:n.requestId,target:n.target,ok:!0,written:i.length,total:i.length})},re=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",se=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&e.type==="discover-storages"&&typeof e.requestId=="string"&&e.requestId.trim().length>0,ne=async e=>({target:e.target,adapterName:e.adapterName,storageName:e.storageName,entryCount:(await e.getAllKeys()).length,capabilities:e.capabilities,supportsSubscriptions:e.supportsSubscriptions}),oe=e=>{const t=new Set;return e.some(({target:r})=>{const o=`${r.adapterId}:${r.storageId}`;return t.has(o)?!0:(t.add(o),!1)})},ae=async(e,t)=>{const r=re(t);if(!se(t))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Storage discovery requires a non-empty request ID."};try{if(oe(e))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Configured storages must have unique targets."};const o=await Promise.all(e.map(ne));return{type:"storage-descriptors",requestId:r,storages:o}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to discover configured storages."}}},ie=256,k=16,ce=e=>e.toString(16).toUpperCase().padStart(2,"0"),ge=e=>{let t="",r=0;for(const o of e){if(r===ie)return{preview:t,isTruncated:!0};t+=o,r+=1}return{preview:t,isTruncated:!1}},de=e=>{if(e.type==="string")return{key:e.key,type:e.type,...ge(e.value),valueSize:e.value.length};if(e.type==="buffer"){const r=e.value.slice(0,k);return{key:e.key,type:e.type,preview:r.map(ce).join(" "),valueSize:e.value.length,isTruncated:e.value.length>k}}const t=String(e.value);return{key:e.key,type:e.type,preview:t,valueSize:t.length,isTruncated:!1}},ue=100,pe=4,ye=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",L=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,le=e=>(e??"").trim().toLowerCase(),fe=e=>{if(typeof e!="object"||e==null||Array.isArray(e)||e.type!=="list-entry-previews"||typeof e.requestId!="string"||e.requestId.trim().length===0||!L(e.target)||e.search!==void 0&&typeof e.search!="string"||e.cursor!==void 0&&typeof e.cursor!="string"||!Number.isFinite(e.limit)||!Number.isInteger(e.limit)||e.limit<1)return;const t=e.keySortDirection;if(t!==void 0&&t!=="ascending"&&t!=="descending")return;const r=e;return{...r,search:le(r.search),keySortDirection:t??"ascending",limit:Math.min(r.limit,ue)}},D=e=>btoa(encodeURIComponent(JSON.stringify(e))),Ie=e=>{try{const t=JSON.parse(decodeURIComponent(atob(e)));return typeof t!="object"||t==null||Array.isArray(t)||t.version!==1||!L(t.target)||typeof t.search!="string"||t.keySortDirection!=="ascending"&&t.keySortDirection!=="descending"||typeof t.boundaryKey!="string"||t.direction!=="next"&&t.direction!=="previous"?void 0:t}catch{return}},P=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,he=(e,t)=>e<t?-1:e>t?1:0,me=async(e,t)=>{const r=new Array(t.length);let o=0;const n=async()=>{for(;o<t.length;){const a=o;o+=1;const i=await e.get(t[a]);i&&(r[a]=de(i))}};return await Promise.all(Array.from({length:Math.min(pe,t.length)},n)),r.filter(a=>a!=null)},we=async(e,t)=>{const r=ye(t),o=fe(t);if(!o)return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Entry preview requests require a valid target, request ID, and positive integer limit."};const n=e.find(i=>P(i.target,o.target));if(!n)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};let a;if(o.cursor!==void 0&&(a=Ie(o.cursor),!a||!P(a.target,o.target)||a.search!==o.search||a.keySortDirection!==o.keySortDirection))return{type:"storage-request-error",requestId:r,code:"INVALID_CURSOR",message:"The entry preview cursor is invalid or belongs to a different query.",resetPagination:!0};try{const i=(await n.getAllKeys()).filter(l=>l.toLowerCase().includes(o.search)).sort(he);o.keySortDirection==="descending"&&i.reverse();let s=0;if(a){const l=i.indexOf(a.boundaryKey);if(l===-1)return{type:"storage-request-error",requestId:r,code:"INVALID_CURSOR",message:"The entry preview cursor is stale after storage changes.",resetPagination:!0};s=a.direction==="next"?l+1:Math.max(0,l-o.limit)}const c=i.slice(s,s+o.limit),g=await me(n,c),d=s+c.length,p={version:1,target:o.target,search:o.search,keySortDirection:o.keySortDirection};return{type:"entry-previews",requestId:r,target:o.target,items:g,...d<i.length&&c.length>0?{nextCursor:D({...p,boundaryKey:c.at(-1),direction:"next"})}:{},...s>0&&c.length>0?{previousCursor:D({...p,boundaryKey:c[0],direction:"previous"})}:{}}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to read entry previews from the requested storage."}}},be=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",Ee=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,Ae=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,qe=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&e.type==="get-entry"&&typeof e.requestId=="string"&&e.requestId.trim().length>0&&Ee(e.target)&&typeof e.key=="string",Se=async(e,t)=>{const r=be(t);if(!qe(t))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Full entry requests require a valid target, request ID, and string key."};const o=e.find(n=>Ae(n.target,t.target));if(!o)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};try{const n=await o.get(t.key);return n?{type:"entry",requestId:r,target:o.target,entry:n}:{type:"storage-request-error",requestId:r,code:"ENTRY_NOT_FOUND",message:"The requested storage entry was not found."}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to read the requested storage entry."}}},Te=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.requestId=="string"?e.requestId:"",ve=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&typeof e.adapterId=="string"&&e.adapterId.trim().length>0&&typeof e.storageId=="string"&&e.storageId.trim().length>0,Re=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,$e=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)&&e.type==="export-snapshot"&&typeof e.requestId=="string"&&e.requestId.trim().length>0&&ve(e.target),Ne=async(e,t)=>{const r=Te(t);if(!$e(t))return{type:"storage-request-error",requestId:r,code:"INVALID_REQUEST",message:"Export requests require a valid target and request ID."};const o=e.find(n=>Re(n.target,t.target));if(!o)return{type:"storage-request-error",requestId:r,code:"TARGET_NOT_FOUND",message:"The requested storage target was not found."};try{const n=await o.getAllEntries();return{type:"export-snapshot-result",requestId:r,target:o.target,snapshot:W({target:o.target,adapterName:o.adapterName,storageName:o.storageName,capabilities:o.capabilities,entries:n})}}catch{return{type:"storage-request-error",requestId:r,code:"READ_FAILED",message:"Failed to export the requested storage."}}},v=e=>e.kind==="async",S=(e,t)=>e.shouldFilterKey?.(t)?!0:e.blacklist?(e.blacklist.lastIndex=0,e.blacklist.test(t)):!1,ke=(e,t,r)=>{if(!E.supportsType(e,t))throw new Error(`Type "${t}" is not supported by storage "${r.storageId}" in adapter "${r.adapterId}".`)},_=async e=>(v(e),e.getAllKeys()),x=async(e,t)=>(v(e),e.get(t)),De=async(e,t)=>{if(v(e)){await e.set(t);return}e.set(t)},Pe=async(e,t)=>{if(v(e)){await e.delete(t);return}e.delete(t)},_e=async e=>{await e.clear()},xe=(e,t)=>{const r=t.storage,o=r.subscribe,n=new Set;let a=!1;const i={adapterId:e.id,storageId:t.id},s=async g=>{if(!S(t,g))return x(r,g)},c=async()=>{const g=await _(r);return(await Promise.all(g.filter(p=>!S(t,p)).map(p=>x(r,p)))).filter(p=>!!p)};return{id:E.getStorageViewId(i),target:i,adapterName:e.name,storageName:t.name,capabilities:t.capabilities,supportsSubscriptions:o!=null,blacklist:t.blacklist,get:s,set:async g=>{ke(t.capabilities,g.type,i),n.add(g.key);try{await De(r,g)}finally{n.delete(g.key)}},delete:async g=>{n.add(g);try{await Pe(r,g)}finally{n.delete(g)}},purge:async()=>{a=!0;try{await _e(r)}finally{a=!1}},getAllKeys:async()=>(await _(r)).filter(d=>!S(t,d)),getAllEntries:c,...o?{watch:async g=>o(d=>{!a&&!n.has(d)&&!S(t,d)&&g(d)})}:{}}},je=e=>e.flatMap(t=>t.storages.map(r=>xe(t,r))),A={adapterId:{type:"string",description:"Storage adapter ID. Required when multiple adapters are configured."},storageId:{type:"string",description:"Storage node ID within the adapter. Required when multiple storages are configured."}},m="@rozenite/storage-plugin",j=["string","number","boolean","buffer"],w={listStorages:f.defineAgentToolContract({name:"list-storages",description:"List all storage adapters and their storage nodes currently available on the device, including supported entry types. Entry counts are omitted to avoid enumerating every storage.",inputSchema:{type:"object",properties:{}}}),listEntries:f.definePaginatedAgentToolContract({name:"list-entries",description:"List keys in a storage. This call intentionally does not return entry values to keep responses token-efficient.",inputSchema:{type:"object",properties:{...A,limit:{type:"number",description:"Pagination size. Defaults to 20 and is capped at 100."},cursor:{type:"string",description:"Opaque pagination cursor from a previous list-entries call."},offset:{type:"number",description:"Deprecated initial pagination offset. Must be a non-negative integer and cannot be combined with cursor."}}},pagination:{kind:"cursor",fields:["key"],defaultFields:["key"]}}),readEntry:f.defineAgentToolContract({name:"read-entry",description:"Read a single storage entry value by key.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."}},required:["key"]}}),createEntry:f.defineAgentToolContract({name:"create-entry",description:"Create a new storage entry. Fails if the key already exists.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."},type:{type:"string",enum:[...j],description:"Entry value type. Must be one of the supported types for the target storage (see list-storages)."},value:{description:"Entry value matching the provided type."}},required:["key","type","value"]}}),editEntry:f.defineAgentToolContract({name:"edit-entry",description:"Edit an existing storage entry. Fails if the key does not exist.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."},type:{type:"string",enum:[...j],description:"Entry value type. Must be one of the supported types for the target storage (see list-storages)."},value:{description:"Entry value matching the provided type."}},required:["key","type","value"]}}),removeEntry:f.defineAgentToolContract({name:"remove-entry",description:"Remove a storage entry by key.",inputSchema:{type:"object",properties:{...A,key:{type:"string",description:"Entry key."}},required:["key"]}})},C=(e,t)=>{if(e==="string"){if(typeof t!="string")throw new Error("Expected string value for type=string");return t}if(e==="number"){if(typeof t!="number"||Number.isNaN(t))throw new Error("Expected number value for type=number");return t}if(e==="boolean"){if(typeof t!="boolean")throw new Error("Expected boolean value for type=boolean");return t}if(!Array.isArray(t)||!t.every(r=>Number.isInteger(r)))throw new Error("Expected number[] value for type=buffer");return t},b=e=>`${e.target.adapterId}/${e.target.storageId}`,Ce=(e,t)=>e.adapterId===t.adapterId&&e.storageId===t.storageId,Fe=e=>btoa(encodeURIComponent(JSON.stringify(e))),Ke=e=>{try{const t=JSON.parse(decodeURIComponent(atob(e)));if(typeof t!="object"||t==null||Array.isArray(t)||t.version!==1||typeof t.target?.adapterId!="string"||typeof t.target?.storageId!="string"||!Number.isSafeInteger(t.offset)||t.offset<0)throw new Error("Invalid cursor");return t}catch{throw new Error("Invalid cursor. Run list-entries again without a cursor to restart pagination.")}},Me=e=>typeof e!="number"||!Number.isFinite(e)||!Number.isInteger(e)||e<1?f.DEFAULT_PAGE_LIMIT:Math.min(e,f.MAX_PAGE_LIMIT),Oe=e=>typeof e!="number"||!Number.isFinite(e)||!Number.isSafeInteger(e)||e<0?0:e,q=(e,t,r)=>{if(e.length===0)throw new Error("No storages are registered.");if(t!==void 0||r!==void 0){const o=e.filter(a=>(t===void 0||a.target.adapterId===t)&&(r===void 0||a.target.storageId===r)),n=[t!==void 0&&`adapterId="${t}"`,r!==void 0&&`storageId="${r}"`].filter(Boolean).join(", ");if(o.length===0)throw new Error(`No storage matched ${n}. Available: ${e.map(b).join(", ")}`);if(o.length>1)throw new Error(`Multiple storages matched ${n}. Provide both adapterId and storageId. Available: ${o.map(b).join(", ")}`);return o[0]}if(e.length>1)throw new Error(`Multiple storages detected. Provide adapterId and/or storageId. Available: ${e.map(b).join(", ")}`);return e[0]},Ue=async(e,t)=>{const r=Me(t.limit);if(t.cursor!==void 0&&t.offset!==void 0)throw new Error("Provide either cursor or offset, not both.");const o=t.cursor===void 0?void 0:Ke(t.cursor);if(o&&!Ce(o.target,e.target))throw new Error("Cursor does not match the requested storage. Run list-entries again without a cursor to restart pagination.");const n=await e.getAllKeys(),a=o?.offset??Oe(t.offset),i=Math.min(a+r,n.length);return{adapterId:e.target.adapterId,storageId:e.target.storageId,total:n.length,items:n.slice(a,i).map(s=>({key:s})),page:{limit:r,hasMore:i<n.length,...i<n.length?{nextCursor:Fe({version:1,target:e.target,offset:i})}:{}}}},Le=e=>({listStorages:async()=>({storages:e.map(t=>({adapterId:t.target.adapterId,storageId:t.target.storageId,adapterName:t.adapterName,storageName:t.storageName,supportedTypes:t.capabilities.supportedTypes}))}),listEntries:async t=>{const r=q(e,t.adapterId,t.storageId);return Ue(r,t)},readEntry:async({adapterId:t,storageId:r,key:o})=>{const n=q(e,t,r),a=await n.get(o);if(!a)throw new Error(`Key "${o}" not found in storage "${b(n)}".`);return{adapterId:n.target.adapterId,storageId:n.target.storageId,entry:a}}}),ze=e=>{const t=Le(e);h.useRozenitePluginAgentTool({pluginId:m,tool:w.listStorages,handler:t.listStorages}),h.useRozenitePluginAgentTool({pluginId:m,tool:w.listEntries,handler:t.listEntries}),h.useRozenitePluginAgentTool({pluginId:m,tool:w.readEntry,handler:t.readEntry}),h.useRozenitePluginAgentTool({pluginId:m,tool:w.createEntry,handler:async({adapterId:r,storageId:o,key:n,type:a,value:i})=>{const s=q(e,r,o);if(await s.get(n))throw new Error(`Key "${n}" already exists in storage "${b(s)}". Use edit-entry instead.`);const g=C(a,i);return await s.set({key:n,type:a,value:g}),{adapterId:s.target.adapterId,storageId:s.target.storageId,created:!0,key:n}}}),h.useRozenitePluginAgentTool({pluginId:m,tool:w.editEntry,handler:async({adapterId:r,storageId:o,key:n,type:a,value:i})=>{const s=q(e,r,o);if(!await s.get(n))throw new Error(`Key "${n}" not found in storage "${b(s)}". Use create-entry instead.`);const g=C(a,i);return await s.set({key:n,type:a,value:g}),{adapterId:s.target.adapterId,storageId:s.target.storageId,edited:!0,key:n}}}),h.useRozenitePluginAgentTool({pluginId:m,tool:w.removeEntry,handler:async({adapterId:r,storageId:o,key:n})=>{const a=q(e,r,o),i=!!await a.get(n);return await a.delete(n),{adapterId:a.target.adapterId,storageId:a.target.storageId,removed:i,key:n}}})},Ve=({storages:e})=>{const t=N.useMemo(()=>je(e),[e]);ze(t);const r=z.useRozeniteDevToolsClient({pluginId:"@rozenite/storage-plugin"});return N.useEffect(()=>{if(!r)return;const o=[];let n=!1;const a=async(s,c,g)=>{const d=t.find(l=>l.target.adapterId===s.adapterId&&l.target.storageId===s.storageId),p=d?(await d.getAllKeys()).length:0;r.send("storage-invalidated",{type:"storage-invalidated",target:s,key:c,operation:g,entryCount:p})};Promise.all(t.filter(s=>s.supportsSubscriptions&&s.watch).map(async s=>{try{const c=s.watch;if(!c)return;const g=await c(d=>{a(s.target,d)});if(n){g.remove();return}o.push(g)}catch(c){console.warn(`[Rozenite] Storage Plugin: Failed to attach watcher for ${s.target.adapterId}/${s.target.storageId}.`,c)}}));const i=[r.onMessage("set-entry",async({target:s,entry:c})=>{const g=t.find(d=>d.target.adapterId===s.adapterId&&d.target.storageId===s.storageId);if(!g){console.warn(`[Rozenite] Storage Plugin: Storage target not found for ${s.adapterId}/${s.storageId}`);return}try{await g.set(c),await a(g.target,c.key,"set")}catch(d){console.warn(`[Rozenite] Storage Plugin: Failed to set entry in ${s.adapterId}/${s.storageId}.`,d)}}),r.onMessage("delete-entry",async({target:s,key:c})=>{const g=t.find(d=>d.target.adapterId===s.adapterId&&d.target.storageId===s.storageId);if(!g){console.warn(`[Rozenite] Storage Plugin: Storage target not found for ${s.adapterId}/${s.storageId}`);return}try{await g.delete(c),await a(g.target,c,"delete")}catch(d){console.warn(`[Rozenite] Storage Plugin: Failed to delete entry in ${s.adapterId}/${s.storageId}.`,d)}}),r.onMessage("purge-storage",async({target:s})=>{const c=t.find(g=>g.target.adapterId===s.adapterId&&g.target.storageId===s.storageId);if(!c){console.warn(`[Rozenite] Storage Plugin: Storage target not found for ${s.adapterId}/${s.storageId}`);return}try{await c.purge(),await a(c.target,void 0,"purge")}catch(g){console.warn(`[Rozenite] Storage Plugin: Failed to purge storage in ${s.adapterId}/${s.storageId}.`,g)}}),r.onMessage("discover-storages",async s=>{const c=await ae(t,s);r.send(c.type,c)}),r.onMessage("list-entry-previews",async s=>{const c=await we(t,s);r.send(c.type,c)}),r.onMessage("get-entry",async s=>{const c=await Se(t,s);r.send(c.type,c)}),r.onMessage("export-snapshot",async s=>{const c=await Ne(t,s);r.send(c.type,c)}),r.onMessage("preview-import",async s=>{const c=await ee(t,s);r.send(c.type,c)}),r.onMessage("import-entries",async s=>{await te(t,s,c=>{r.send(c.type,c)})})];return r.send("device-ready",{type:"device-ready"}),()=>{n=!0,o.forEach(s=>s.remove()),i.forEach(s=>s.remove())}},[r,t]),r};exports.useRozeniteStoragePlugin=Ve;
|