diff --git a/docs/404.html b/docs/404.html index adfdd5a..3124b7a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1 +1 @@ -404 - not found

@magic-libraries/db

404 - not found.
\ No newline at end of file +404 - not found

@magic-libraries/db

404 - not found.
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 703c72b..3a599bb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,4 +4,4 @@ for an actual usecase

export const View = ({ key, state }) =>  div([    div(["key:  key]),    div([      h4("controls"),      button({ onclick: [actions.examplestore.set, { key }] }, "write"),      button({ onclick: [actions.examplestore.get, { key }] }, "read"),      button({ onclick: [actions.examplestore.del, { key }] }, "delete"),    ]),    div("value in local storage:"),    state[key]      ? ["state is accessible via state["" + key + ""] div(state[key])]      : div("no value in db"),  ])export const actions = {  examplestore: {    get: (state, { key }) => [      state,      [        lib.db.get,        {          key,          action: actions.examplestore.refresh,        },      ],    ],    set: (state, { key }) => [      state,      [        lib.db.set,        {          key,          value: "testing " + Math.ceil(Math.random() * 100000),          action: actions.examplestore.refresh,        },      ],    ],    del: (state, { key }) => [      state,      [        lib.db.del,        {          key,          action: actions.examplestore.refresh,        },      ],    ],    refresh: (state, { key, value }) => {      console.log("refresh { key, value })      if (key) {        state[key] = value      }      return {        ...state,      }    },  },}

then use it in a page:

<ExampleStore state key="magic-examplestore"><ExampleStore>

renders:

key: magic-examplestore

controls

value in local storage:
no value in db

source

the source for this page is in the example directory and gets built and published to github using -@magic/core

\ No newline at end of file +@magic/core

\ No newline at end of file diff --git a/docs/magic.js b/docs/magic.js index 77b6aa9..617f40e 100644 --- a/docs/magic.js +++ b/docs/magic.js @@ -1 +1 @@ -"use strict";function b(a){return s(a)||c(a)||n(a)||m()}function c(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function d(a,b){if(null==a)return{};var c,d,f=e(a,b);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(a);for(d=0;da.length)&&(b=a.length);for(var c=0,d=Array(b);cy)for(;x<=z;)c.insertBefore(p(u[x]=v(u[x++]),f,g),(k=t[w])&&k.node);else if(x>z)for(;w<=y;)c.removeChild(t[w++].node);else{for(var A=w,B={},C={};A<=y;A++)null!=(l=t[A].key)&&(B[l]=t[A]);for(;x<=z;){if(l=q(k=t[w]),m=q(u[x]=v(u[x],k)),C[l]||null!=m&&m===q(t[w+1])){null==l&&c.removeChild(k.node),w++;continue}null==m||1===d.type?(null==l&&(r(c,k&&k.node,k,u[x],f,g),x++),w++):(l===m?(r(c,k.node,k,u[x],f,g),C[m]=!0,w++):null==(h=B[m])?r(c,k&&k.node,null,u[x],f,g):(r(c,c.insertBefore(h.node,k&&k.node),h,u[x],f,g),C[m]=!0),x++)}for(;w<=y;)null==q(k=t[w++])&&c.removeChild(k.node);for(var A in B)null==C[A]&&c.removeChild(B[A].node)}}return e.node=c},s=function(c,a){for(var b in c)if(c[b]!==a[b])return!0;for(var b in a)if(c[b]!==a[b])return!0},u=function(a){return"object"===t(a)?a:x(a)},v=function(b,c){return b.type===a?((!c||!c.lazy||s(c.lazy,b.lazy))&&((c=u(b.lazy.view(b.lazy))).lazy=b.lazy),c):b},w=function(a,b,c,d,e,f){return{name:a,props:b,children:c,node:d,type:f,key:e}},x=function(a,e){return w(a,c,d,e,void 0,b)},y=function(a){return a.nodeType===b?x(a.nodeValue,a):w(a.nodeName.toLowerCase(),c,e.call(a.childNodes,y),a,void 0,1)};return{h:function h(a,b){for(var d,e=[],g=[],h=arguments.length;2"],stringRegex:/("|')(.*?)\1/gim,wordRegex:/( )/gim},preventDefault:function preventDefault(a){return a.preventDefault(),a},tryCatch:function tryCatch(a){return function(){try{return a.apply(void 0,arguments)}catch(a){return a}}}},ma={changeTheme:function changeTheme(a){return j(j({},a),{},{pageClass:j(j({},a.pageClass),{},{light:"dark"===a.theme}),theme:"dark"===a.theme?"light":"dark"})},examplestore:{del:function del(a,b){var c=b.key;return[a,[la.db.del,{key:c,action:ma.examplestore.refresh}]]},get:function get(a,b){var c=b.key;return[a,[la.db.get,{key:c,action:ma.examplestore.refresh}]]},refresh:function refresh(a,b){var c=b.key,d=b.value;return c&&(a[c]=d),j({},a)},set:function set(a,b){var c=Math.ceil,d=b.key;return[a,[la.db.set,{key:d,value:"testing ".concat(c(1e5*Math.random())),action:ma.examplestore.refresh}]]}},go:function go(a,b){var c=b.currentTarget.href.replace(window.location.origin,""),d=c.split("#"),e=l(d,2),f=e[0],g=e[1],h=void 0===g?"":g;if(f===a.url&&h===a.hash)return h&&(window.location.hash=h),a;var i=a.pages&&a.pages[f]&&a.pages[f].title;i&&(document.title=a.title=i),f===a.url?window.location.hash=h:!h&&window.scrollTo({top:0});var k=window,m=k.scrollY;return window.history.pushState({url:f,hash:h,scrollY:m},a.title,c),j(j({},a),{},{url:f,hash:h,prev:a.url})},nospy:{toggle:function toggle(a){return a.nospy.show=!a.nospy.show,j({},a)}},pop:function pop(a,b){var c=window.location,d=c.pathname,e=c.hash;e=e.substring(1);var f=0;return b.state&&(d=b.state.url,e=b.state.hash,f=b.state.scrollY||0),e?window.location.hash=e:window.scroll({top:f}),j(j({},a),{},{url:d,hash:e})},pre:{clip:function clip(a,b){var c=b.content;if("undefined"!=typeof document&&"function"==typeof document.execCommand){var d=document.createElement("textarea");d.id="copy",d.innerHTML=c,document.body.appendChild(d);var e=document.getElementById("copy");e.select(),document.execCommand("copy"),document.body.removeChild(e)}return a}}},na={"/db/":function db(a){return[g({id:"magic-librariesdb"},"@magic-libraries/db"),M("localstorage backed browser key value database for @magic"),aa("@magic-libraries/db"),C({id:"installation"},"installation"),ka({lines:"false"},"npm install --save-exact magic-libraries/db"),C({id:"usage"},"usage"),M("in a page/component, just use the lib.db functions, either as action or effect."),M(["see ",ea({to:"https://github.com/magic-libraries/db/blob/master/example/assets/ExampleStore.mjs",text:"ExampleStore"}),"\nfor a reference implementation and\n",ea({to:"https://github.com/magic-modules/gdpr",text:"@magic-modules/gdpr"}),"\nfor an actual usecase"]),ka("export const View = ({ key, state }) =>\n div([\n div([\"key: key]),\n div([\n h4(\"controls\"),\n button({ onclick: [actions.examplestore.set, { key }] }, \"write\"),\n button({ onclick: [actions.examplestore.get, { key }] }, \"read\"),\n button({ onclick: [actions.examplestore.del, { key }] }, \"delete\"),\n ]),\n\n div(\"value in local storage:\"),\n state[key]\n ? [\"state is accessible via state[\"\" + key + \"\"] div(state[key])]\n : div(\"no value in db\"),\n ])\n\nexport const actions = {\n examplestore: {\n get: (state, { key }) => [\n state,\n [\n lib.db.get,\n {\n key,\n action: actions.examplestore.refresh,\n },\n ],\n ],\n\n set: (state, { key }) => [\n state,\n [\n lib.db.set,\n {\n key,\n value: \"testing \" + Math.ceil(Math.random() * 100000),\n action: actions.examplestore.refresh,\n },\n ],\n ],\n\n del: (state, { key }) => [\n state,\n [\n lib.db.del,\n {\n key,\n action: actions.examplestore.refresh,\n },\n ],\n ],\n\n refresh: (state, { key, value }) => {\n console.log(\"refresh { key, value })\n\n if (key) {\n state[key] = value\n }\n\n return {\n ...state,\n }\n },\n },\n}"),M("then use it in a page:"),ka({lines:"false"},""),M("renders:"),$({state:a,key:"magic-examplestore"}),C({id:"source"},"source"),M(["the source for this page is in the\n",ea({to:"https://github.com/magic-libraries/db/tree/master/example",text:"example directory"}),"\nand gets built and published to github using\n",ea({to:"https://github.com/magic/core",text:"@magic/core"})])]},"/db/404/":function db404(){return y("404 - not found.")}};h({init:j(j({},U),{},{url:window.location.pathname,hash:window.location.hash.substr(1)}),subscriptions:function subscriptions(){return[[V.listenPopState,ma.pop]]},view:function(a){var b=na[a.url]?a.url:"/404/",c=na[b],d=a.pages&&a.pages[b];return d&&Object.keys(d).forEach(function(b){a[b]=d[b]}),a.url=b,ja({page:c,state:a},[da(a),ia(a)])},node:document.getElementById("Magic")}); \ No newline at end of file +"use strict";var b=["to","action","text"],c=["href","nofollow","noreferrer"],d=["collapse","items","text","url"];function e(a){return r(a)||f(a)||o(a)||n()}function f(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function g(a,b){if(null==a)return{};var c,d,e=h(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;da.length)&&(b=a.length);for(var c=0,d=Array(b);cy)for(;x<=z;)c.insertBefore(p(u[x]=v(u[x++]),f,g),(k=t[w])&&k.node);else if(x>z)for(;w<=y;)c.removeChild(t[w++].node);else{for(var A=w,B={},C={};A<=y;A++)null!=(l=t[A].key)&&(B[l]=t[A]);for(;x<=z;){if(l=q(k=t[w]),m=q(u[x]=v(u[x],k)),C[l]||null!=m&&m===q(t[w+1])){null==l&&c.removeChild(k.node),w++;continue}null==m||1===d.type?(null==l&&(r(c,k&&k.node,k,u[x],f,g),x++),w++):(l===m?(r(c,k.node,k,u[x],f,g),C[m]=!0,w++):null==(h=B[m])?r(c,k&&k.node,null,u[x],f,g):(r(c,c.insertBefore(h.node,k&&k.node),h,u[x],f,g),C[m]=!0),x++)}for(;w<=y;)null==q(k=t[w++])&&c.removeChild(k.node);for(var A in B)null==C[A]&&c.removeChild(B[A].node)}}return e.node=c},t=function(c,a){for(var b in c)if(c[b]!==a[b])return!0;for(var b in a)if(c[b]!==a[b])return!0},u=function(a){return"object"===s(a)?a:x(a)},v=function(b,c){return b.type===a?((!c||!c.lazy||t(c.lazy,b.lazy))&&((c=u(b.lazy.view(b.lazy))).lazy=b.lazy),c):b},w=function(a,b,c,d,e,f){return{name:a,props:b,children:c,node:d,type:f,key:e}},x=function(a,e){return w(a,c,d,e,void 0,b)},y=function(a){return a.nodeType===b?x(a.nodeValue,a):w(a.nodeName.toLowerCase(),c,e.call(a.childNodes,y),a,void 0,1)};return{h:function h(a,b){for(var d,e=[],g=[],h=arguments.length;2"],stringRegex:/("|')(.*?)\1/gim,wordRegex:/( )/gim},preventDefault:function preventDefault(a){return a.preventDefault(),a},tryCatch:function tryCatch(a){return function(){try{return a.apply(void 0,arguments)}catch(a){return a}}}},ea={changeTheme:function changeTheme(a){return k(k({},a),{},{pageClass:k(k({},a.pageClass),{},{light:"dark"===a.theme}),theme:"dark"===a.theme?"light":"dark"})},examplestore:{del:function del(a,b){var c=b.key;return[a,[da.db.del,{key:c,action:ea.examplestore.refresh}]]},get:function get(a,b){var c=b.key;return[a,[da.db.get,{key:c,action:ea.examplestore.refresh}]]},refresh:function refresh(a,b){var c=b.key,d=b.value;return c&&(a[c]=d),k({},a)},set:function set(a,b){var c=Math.ceil,d=b.key;return[a,[da.db.set,{key:d,value:"testing ".concat(c(1e5*Math.random())),action:ea.examplestore.refresh}]]}},go:function go(a,b){var c=b.currentTarget.href.replace(window.location.origin,""),d=c.split("#"),e=m(d,2),f=e[0],g=e[1],h=void 0===g?"":g;if(f===a.url&&h===a.hash)return h&&(window.location.hash=h),a;var i=a.pages&&a.pages[f]&&a.pages[f].title;i&&(document.title=a.title=i),f===a.url?window.location.hash=h:!h&&window.scrollTo({top:0});var j=window,l=j.scrollY;return window.history.pushState({url:f,hash:h,scrollY:l},a.title,c),k(k({},a),{},{url:f,hash:h,prev:a.url})},nospy:{toggle:function toggle(a){return a.nospy.show=!a.nospy.show,k({},a)}},pop:function pop(a,b){var c=window.location,d=c.pathname,e=c.hash;e=e.substring(1);var f=0;return b.state&&(d=b.state.url,e=b.state.hash,f=b.state.scrollY||0),e?window.location.hash=e:window.scroll({top:f}),k(k({},a),{},{url:d,hash:e})},pre:{clip:function clip(a,b){var c=b.content;if("undefined"!=typeof document&&"function"==typeof document.execCommand){var d=document.createElement("textarea");d.id="copy",d.innerHTML=c,document.body.appendChild(d);var e=document.getElementById("copy");e.select(),document.execCommand("copy"),document.body.removeChild(e)}return a}}},fa={"/db/":function db(a){return[u({id:"magic-librariesdb"},"@magic-libraries/db"),G("localstorage backed browser key value database for @magic"),U("@magic-libraries/db"),w({id:"installation"},"installation"),ca({lines:"false"},"npm install --save-exact magic-libraries/db"),w({id:"usage"},"usage"),G("in a page/component, just use the lib.db functions, either as action or effect."),G(["see ",Y({to:"https://github.com/magic-libraries/db/blob/master/example/assets/ExampleStore.mjs",text:"ExampleStore"}),"\nfor a reference implementation and\n",Y({to:"https://github.com/magic-modules/gdpr",text:"@magic-modules/gdpr"}),"\nfor an actual usecase"]),ca("export const View = ({ key, state }) =>\n div([\n div([\"key: key]),\n div([\n h4(\"controls\"),\n button({ onclick: [actions.examplestore.set, { key }] }, \"write\"),\n button({ onclick: [actions.examplestore.get, { key }] }, \"read\"),\n button({ onclick: [actions.examplestore.del, { key }] }, \"delete\"),\n ]),\n\n div(\"value in local storage:\"),\n state[key]\n ? [\"state is accessible via state[\"\" + key + \"\"] div(state[key])]\n : div(\"no value in db\"),\n ])\n\nexport const actions = {\n examplestore: {\n get: (state, { key }) => [\n state,\n [\n lib.db.get,\n {\n key,\n action: actions.examplestore.refresh,\n },\n ],\n ],\n\n set: (state, { key }) => [\n state,\n [\n lib.db.set,\n {\n key,\n value: \"testing \" + Math.ceil(Math.random() * 100000),\n action: actions.examplestore.refresh,\n },\n ],\n ],\n\n del: (state, { key }) => [\n state,\n [\n lib.db.del,\n {\n key,\n action: actions.examplestore.refresh,\n },\n ],\n ],\n\n refresh: (state, { key, value }) => {\n console.log(\"refresh { key, value })\n\n if (key) {\n state[key] = value\n }\n\n return {\n ...state,\n }\n },\n },\n}"),G("then use it in a page:"),ca({lines:"false"},""),G("renders:"),S({state:a,key:"magic-examplestore"}),w({id:"source"},"source"),G(["the source for this page is in the\n",Y({to:"https://github.com/magic-libraries/db/tree/master/example",text:"example directory"}),"\nand gets built and published to github using\n",Y({to:"https://github.com/magic/core",text:"@magic/core"})])]},"/db/404/":function db404(){return q("404 - not found.")}};h({init:k(k({},{description:"localstorage backed browser key value database for @magic",logotext:"@magic-libraries/db",menu:[{text:"installation",to:"/db/#installation"},{text:"usage",to:"/db/#usage"},{text:"source",to:"/db/#source"}],nospy:{show:!1},pageClass:{},pages:{"/db/":{},"/db/404/":{description:"404 - not found.",title:"404 - not found"}},root:"/db/",theme:"dark",title:"@magic-libraries/db",url:"/db/"}),{},{url:window.location.pathname,hash:window.location.hash.substr(1)}),subscriptions:function subscriptions(){return[[O.listenPopState,ea.pop]]},view:function(a){var b=fa[a.url]?a.url:"/404/",c=fa[b],d=a.pages&&a.pages[b];return d&&Object.keys(d).forEach(function(b){a[b]=d[b]}),a.url=b,ba({page:c,state:a},[X(a),aa(a)])},node:document.getElementById("Magic")})})(); \ No newline at end of file diff --git a/docs/sitemap.xml b/docs/sitemap.xml index fe1746a..d04d177 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -7,14 +7,14 @@ https:/magic-libraries.github.io/db/ - 2021-05-06 + 2021-07-10 weekly 0.5 https:/magic-libraries.github.io/db/404/ - 2021-05-06 + 2021-07-10 weekly 0.5 diff --git a/docs/sri-hashes.json b/docs/sri-hashes.json index b10c0cd..85e3a69 100644 --- a/docs/sri-hashes.json +++ b/docs/sri-hashes.json @@ -1,8 +1,8 @@ { "/magic.css": "sha384-S6KqwlVvY/KJ8U/Hv0xDEJN7IFjxy4KYbn0Z4lYLGl3T9il5udDt9owgAgDlGkLb", - "/magic.js": "sha384-h3sLV3lrVaIlu2FiypCm7gbiA+1d0pX2/WiZ1NRhUxwIIgRBbOSYUDG4duxEv2j+", - "/db/": "sha384-TrgPJJPA2SITOuI7EvSwScZ5B9WJ4bnJpAtBSyhJ5iptEFmLO9VvW5R0En8BFHZf", - "/db/404/": "sha384-/fU6DHS9MkioGhNPgnPZWOVn3U97rmM2z9KULTQMBY2XEw/FtSO483YcHLxLqLEH", + "/magic.js": "sha384-jjciNpgHPsX8tB4cxlOnScTUP9JLj63EUWCMkyg/yJJH4jgKW/vh7FSpOK8d4P5J", + "/db/": "sha384-zmLxHH1P3s5YtUyIp1fU2z4+Ztx5NG56oqsQku0GH1Gpr42tGumn6Kt434+RS+wQ", + "/db/404/": "sha384-H7f56AgZLQAg4hpkovLGdeHpiPeNG6LGbzVlwPB/mw6lFiWXR4+pFXHruY+HnrSS", "/robots.txt": "sha384-NwKD0fwQx3V0vRnfNmJRdp769lhBiUYM06IyN26JqKxq9Tk9wUx/qHW0KrfPSUUL", - "/sitemap.xml": "sha384-ajC+oWd6Rr6MUCoZMN+yUn/A3Cr81fWxyqNbKZnc1jRKQy4yVhUn+GIfxHIHBm73" + "/sitemap.xml": "sha384-sVSFCcboiDl50a9RftLLtpUrfzJHSSyiCY2mhT20rYHTz9m1yDYis/M7VPanhnTG" } \ No newline at end of file