mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
190 lines
8.2 KiB
Go
190 lines
8.2 KiB
Go
// Code generated by templ - DO NOT EDIT.
|
|
|
|
// templ: version: v0.2.793
|
|
package storage
|
|
|
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
|
|
import "github.com/a-h/templ"
|
|
import templruntime "github.com/a-h/templ/runtime"
|
|
|
|
var storageHandle = templ.NewOnceHandle()
|
|
|
|
// Internal script templates for storage operations
|
|
func setLocalStorage(key string, value string) templ.ComponentScript {
|
|
return templ.ComponentScript{
|
|
Name: `__templ_setLocalStorage_13ae`,
|
|
Function: `function __templ_setLocalStorage_13ae(key, value){localStorage.setItem(key, value)
|
|
}`,
|
|
Call: templ.SafeScript(`__templ_setLocalStorage_13ae`, key, value),
|
|
CallInline: templ.SafeScriptInline(`__templ_setLocalStorage_13ae`, key, value),
|
|
}
|
|
}
|
|
|
|
func getLocalStorage(key string) templ.ComponentScript {
|
|
return templ.ComponentScript{
|
|
Name: `__templ_getLocalStorage_3450`,
|
|
Function: `function __templ_getLocalStorage_3450(key){return localStorage.getItem(key)
|
|
}`,
|
|
Call: templ.SafeScript(`__templ_getLocalStorage_3450`, key),
|
|
CallInline: templ.SafeScriptInline(`__templ_getLocalStorage_3450`, key),
|
|
}
|
|
}
|
|
|
|
func removeLocalStorage(key string) templ.ComponentScript {
|
|
return templ.ComponentScript{
|
|
Name: `__templ_removeLocalStorage_64b1`,
|
|
Function: `function __templ_removeLocalStorage_64b1(key){localStorage.removeItem(key)
|
|
}`,
|
|
Call: templ.SafeScript(`__templ_removeLocalStorage_64b1`, key),
|
|
CallInline: templ.SafeScriptInline(`__templ_removeLocalStorage_64b1`, key),
|
|
}
|
|
}
|
|
|
|
func setSessionStorage(key string, value string) templ.ComponentScript {
|
|
return templ.ComponentScript{
|
|
Name: `__templ_setSessionStorage_0b44`,
|
|
Function: `function __templ_setSessionStorage_0b44(key, value){sessionStorage.setItem(key, value)
|
|
}`,
|
|
Call: templ.SafeScript(`__templ_setSessionStorage_0b44`, key, value),
|
|
CallInline: templ.SafeScriptInline(`__templ_setSessionStorage_0b44`, key, value),
|
|
}
|
|
}
|
|
|
|
func getSessionStorage(key string) templ.ComponentScript {
|
|
return templ.ComponentScript{
|
|
Name: `__templ_getSessionStorage_66b8`,
|
|
Function: `function __templ_getSessionStorage_66b8(key){return sessionStorage.getItem(key)
|
|
}`,
|
|
Call: templ.SafeScript(`__templ_getSessionStorage_66b8`, key),
|
|
CallInline: templ.SafeScriptInline(`__templ_getSessionStorage_66b8`, key),
|
|
}
|
|
}
|
|
|
|
func removeSessionStorage(key string) templ.ComponentScript {
|
|
return templ.ComponentScript{
|
|
Name: `__templ_removeSessionStorage_a2e3`,
|
|
Function: `function __templ_removeSessionStorage_a2e3(key){sessionStorage.removeItem(key)
|
|
}`,
|
|
Call: templ.SafeScript(`__templ_removeSessionStorage_a2e3`, key),
|
|
CallInline: templ.SafeScriptInline(`__templ_removeSessionStorage_a2e3`, key),
|
|
}
|
|
}
|
|
|
|
// Storage component that includes all storage-related scripts
|
|
func StorageScripts() templ.Component {
|
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
return templ_7745c5c3_CtxErr
|
|
}
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
if templ_7745c5c3_Var1 == nil {
|
|
templ_7745c5c3_Var1 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script type=\"text/javascript\">\n // Storage helper functions\n function setLocalStorageItem(key, value) {\n localStorage.setItem(key, value);\n }\n\n function getLocalStorageItem(key) {\n return localStorage.getItem(key);\n }\n\n function removeLocalStorageItem(key) {\n localStorage.removeItem(key);\n }\n\n function setSessionStorageItem(key, value) {\n sessionStorage.setItem(key, value);\n }\n\n function getSessionStorageItem(key) {\n return sessionStorage.getItem(key);\n }\n\n function removeSessionStorageItem(key) {\n sessionStorage.removeItem(key);\n }\n </script>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return templ_7745c5c3_Err
|
|
})
|
|
templ_7745c5c3_Err = storageHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return templ_7745c5c3_Err
|
|
})
|
|
}
|
|
|
|
// Public components for storage operations
|
|
func SetLocalStorageItem(key string, value any) templ.Component {
|
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
return templ_7745c5c3_CtxErr
|
|
}
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
|
if templ_7745c5c3_Var3 == nil {
|
|
templ_7745c5c3_Var3 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
templ_7745c5c3_Err = StorageScripts().Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script>\n (() => {\n const value = { templ.JSONString(value) };\n setLocalStorageItem({ key }, JSON.stringify(value));\n })();\n </script>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return templ_7745c5c3_Err
|
|
})
|
|
}
|
|
|
|
func SetSessionStorageItem(key string, value any) templ.Component {
|
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
return templ_7745c5c3_CtxErr
|
|
}
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
|
if templ_7745c5c3_Var4 == nil {
|
|
templ_7745c5c3_Var4 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
templ_7745c5c3_Err = StorageScripts().Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script>\n (() => {\n const value = { templ.JSONString(value) };\n setSessionStorageItem({ key }, JSON.stringify(value));\n })();\n </script>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return templ_7745c5c3_Err
|
|
})
|
|
}
|
|
|
|
var _ = templruntime.GeneratedTemplate
|