From dc40aece6319554288f48a101382e05ec097b249 Mon Sep 17 00:00:00 2001 From: jascha Date: Sat, 18 Jul 2020 04:19:40 +0200 Subject: [PATCH] docs: update --- docs/404.html | 2 +- docs/index.html | 6 +++--- docs/magic.css | 2 +- docs/magic.js | 2 +- docs/sitemap.xml | 4 ++-- docs/sri-hashes.json | 10 +++++----- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/404.html b/docs/404.html index e887729..1900ff8 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1 +1 @@ -404 - not found

@magic-libraries/json

404 - not found.
made with a few bits of magic
\ No newline at end of file +404 - not found

@magic-libraries/json

404 - not found.
made with a few bits of magic
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 802caae..dc15cfa 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,10 +1,10 @@ -@magic-libraries/json

@magic-libraries/json

@magic-libraries/json

this is the +@magic-libraries/json

@magic-libraries/json

@magic-libraries/json

this is the @magic-libraries json library. it returns errors instead of throwing them and catches (some) malformed objects when stringifying.

installation

npm install @magic-libraries/json

usage

in a page/component, just use the lib.json functions

lib.json.stringify({ some: { object: ['with', 'values'] } })

renders

{ "some": { "object": ["with", "values"] } }

caveat

this library is intended to handle incoming web traffic. we can never be sure that this incoming packets will not include faulty json.

to use this library without checking it's return value your input json MUST be wellformed.

in all (other) cases the following pattern should be employed -(and enhanced with custom error messages).

export const ViewStringify = unsafe => {  const result = lib.json.stringify(unsafe)  return div([result.message ? result.message : result])}export const ViewParse = unsafe => {  const result = lib.json.parse(unsafe)  // in this case we can not check for .message,  // since unsafe might have a .message key after parsing  div([result instanceof Error ? result.message : result])}

example modules

the example/assets directory contains two modules that use the lib.json functions:

<JsonStringify state></JsonStringify>

renders

stringified JSON:{  "state": {    "title": "@magic-libraries/json",    "description": "json client lib for @magic. returns errors instead of throwing them.",    "logotext": "@magic-libraries/json",    "menu": [      {        "to": "/#installation",        "text": "installation"      },      {        "to": "/#usage",        "text": "usage"      },      {        "to": "/#caveat",        "text": "caveat"      },      {        "to": "/#source",        "text": "source"      }    ],    "theme": "dark",    "nospy": {      "show": false    },    "pageClass": {},    "url": "/json/",    "root": "/json/",    "pages": {      "/json/": {        "title": "@magic-libraries/json",        "description": "json client lib for @magic. returns errors instead of throwing them.",        "logotext": "@magic-libraries/json",        "menu": [          {            "to": "/#installation",            "text": "installation"          },          {            "to": "/#usage",            "text": "usage"          },          {            "to": "/#caveat",            "text": "caveat"          },          {            "to": "/#source",            "text": "source"          }        ],        "url": "/json/",        "root": "/json/"      },      "/json/404/": {        "title": "404 - not found",        "description": "404 - not found."      }    }  }}
<JsonParse>{ "valid": true }</JsonParse>

renders

parsed (and then stringified) JSON:{  "valid": true}

source

the source for this page is in the +(and enhanced with custom error messages).

export const ViewStringify = unsafe => {  const result = lib.json.stringify(unsafe)  return div([result.message ? result.message : result])}export const ViewParse = unsafe => {  const result = lib.json.parse(unsafe)  // in this case we can not check for .message,  // since unsafe might have a .message key after parsing  div([result instanceof Error ? result.message : result])}

example modules

the example/assets directory contains two modules that use the lib.json functions:

<JsonStringify state></JsonStringify>

renders

stringified JSON:{  "state": {    "title": "@magic-libraries/json",    "description": "json client lib for @magic. returns errors instead of throwing them.",    "logotext": "@magic-libraries/json",    "menu": [      {        "to": "/#installation",        "text": "installation"      },      {        "to": "/#usage",        "text": "usage"      },      {        "to": "/#caveat",        "text": "caveat"      },      {        "to": "/#source",        "text": "source"      }    ],    "nospy": {      "show": false    },    "theme": "dark",    "pageClass": {},    "url": "/json/",    "root": "/json/",    "pages": {      "/json/": {        "title": "@magic-libraries/json",        "description": "json client lib for @magic. returns errors instead of throwing them.",        "logotext": "@magic-libraries/json",        "menu": [          {            "to": "/#installation",            "text": "installation"          },          {            "to": "/#usage",            "text": "usage"          },          {            "to": "/#caveat",            "text": "caveat"          },          {            "to": "/#source",            "text": "source"          }        ],        "url": "/json/",        "root": "/json/"      },      "/json/404/": {        "title": "404 - not found",        "description": "404 - not found."      }    }  }}
<JsonParse>{ "valid": true }</JsonParse>

renders

parsed (and then stringified) JSON:{  "valid": true}

source

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

made with a few bits of magic
\ No newline at end of file +@magic/core

made with a few bits of magic
\ No newline at end of file diff --git a/docs/magic.css b/docs/magic.css index f92c148..bca10e2 100644 --- a/docs/magic.css +++ b/docs/magic.css @@ -1 +1 @@ -html{scroll-behavior:smooth;overflow-y:scroll}h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,img,picture,source,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video,div,body{border:0;box-sizing:border-box;font:inherit;font-size:100%;margin:0;padding:0;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1.5;margin:0;max-width:100vw;overflow-x:hidden;padding:0;font-family:"Ubuntu Narrow",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,sans-serif}ul{display:inline-block;list-style:none}ol{display:inline-block;list-style:inside decimal}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}a{cursor:pointer;outline:none;white-space:nowrap;color:#eeeeee;text-decoration:underline;transition:color 500ms}b,strong{font-weight:700}i,em{font-style:italic}button,.button,input[type="reset"],input[type="button"],input[type="submit"],input[type="file"] > input[type="button"]{background-color:#9E9E9E;color:#212121;cursor:pointer;padding:0.5em}button:hover,.button:hover,input[type="reset"]:hover,input[type="button"]:hover,input[type="submit"]:hover,input[type="file"] > input[type="button"]:hover{background-color:#616161;color:#F5F5F5}button::-moz-focus-inner,.button::-moz-focus-inner,input[type="reset"]::-moz-focus-inner,input[type="button"]::-moz-focus-inner,input[type="submit"]::-moz-focus-inner,input[type="file"] > input[type="button"]::-moz-focus-inner{border:0 none;padding:0}#Magic{height:100%;min-height:100vh;width:100%;background-color:#232323;color:#cccccc;transition:color 300ms,background-color 300ms;font-weight:400}.Wrapper{margin:0 auto;max-width:1300px;width:90%}.Header{display:inline-block;width:100%;padding:.5em 0 0}.Header .Logo{display:inline-block}.Header .Logo img{float:left}.Header .Logo span{float:left;font-size:1.5em;margin:.7em .2em}.Page h1{padding:1em 0 .2em}.Footer{width:100%;padding:2em 0 .5em;position:relative}h1,h2,h3,h4,h5{padding:1em 0 .2em}h1{font-size:1.4em}h2{font-size:1.3em}h3{font-size:1.2em}.Credits{clear:both;display:block;margin:2em 0 1em}.Credits a{color:#cccccc;text-decoration:underline}.Credits a:hover{color:#c4c4c4}.Footer .Container{text-align:center}.GitBadges{display:inline-block;margin:15px 0}.GitBadges img{height:23px}.GitBadges li{margin:0 .5em 0 0;display:inline-block;float:left}.Header .Menu{display:inline-block;width:100%}.Header p{font-size:1.5em}.LightSwitch{background:none;border:none;color:inherit;cursor:pointer;fill:#9E9E9E;font:inherit;height:2em;outline:inherit;padding:0;width:2em;left:auto;position:fixed;right:0.5em;top:0.5em}.LightSwitch:hover{background:none;fill:#616161}.Logo{float:left;height:2.4em}.Logo .stroke{fill:none;stroke:#663695;stroke-width:15;stroke-linecap:round;stroke-linejoin:round}.Logo .stroke.white{stroke:#ffffff}.Logo svg{display:inline-block;width:3em;height:auto}.Menu{float:none;margin:1.5em 0 0;position:relative;display:block;clear:both}.Menu li{float:none;margin:0 .5em 0 0;display:block}.Menu li.active > a{text-decoration:underline;color:#fefefe}.Menu li a{display:block;text-decoration:none}.Menu ul ul{position:relative;left:0;border-left:1px dotted;display:block;margin:0 0 0 0.2em;padding:0 0 0 0.3em}.NoSpy{-webkit-animation:showNoSpy 1s 1s forwards;animation:showNoSpy 1s 1s forwards;bottom:0.5em;left:3%;max-width:94%;opacity:0;position:fixed;text-align:center}.NoSpy .Container{background-color:#212121;border:1px solid;border-radius:.5em;color:#F5F5F5;display:inline-block;padding:1em;position:relative;text-align:left}.light .NoSpy .Container{background-color:#F5F5F5;color:#212121}.NoSpy .ShowHide{position:fixed;left:1em;bottom:1em;width:2em;height:2em;cursor:pointer;color:#9E9E9E;stroke:#9E9E9E;fill:#9E9E9E}.NoSpy .ShowHide:hover{color:#616161;stroke:#616161;fill:#616161}.NoSpy h3{padding:0;margin:0}.NoSpy input[type=button]{display:inline-block;margin:0.5em 0;width:100%}@-webkit-keyframes showNoSpy{0%{opacity:0}100%{opacity:1}}@keyframes showNoSpy{0%{opacity:0}100%{opacity:1}}.Pre{background-color:#121212;border:1px solid #666;border-radius:5px;color:#eee;counter-reset:line;display:block;font-family:monospace;line-height:1.3;margin:1em 0;padding:1em .5em 0 .2em;position:relative;transition:color 300ms,background-color 300ms;white-space:pre}.Pre.lines pre > code{counter-increment:line;padding:0}.Pre.lines pre > code:last-child{padding:0 0 1em}.Pre.lines pre > code:before{content:counter(line);display:inline-block;padding:0 .5em 0 0;text-align:right;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:3ch}.Pre .actions{color:blueviolet}.Pre .boolean{color:#7979e4}.Pre .builtin{color:cadetblue}.Pre .colon{color:#8eef8e}.Pre .comment{opacity:0.7;font-style:italic}.Pre .html{color:#008800}.Pre .keyword{color:violet}.light .Pre{background-color:#ddd;color:#111}.light .Pre > code:before{color:#666}.light .Pre .html{color:#008800}.light .Pre .keyword{color:purple}.light .Pre .builtin{color:cadetblue}.light .Pre .string{color:#d15100}.light .Pre .colon{color:#016301}.light .Pre .boolean{color:blue}.light .Pre .actions{color:blueviolet}.light .Pre .state{color:cornflowerblue}.light .Pre .comment{color:#555;opacity:0.8;font-style:italic}.light .Pre .object{color:#016301}.light .Pre .property{color:#2a952a}.light .Pre a{color:#d15100}.light .Pre a:hover{color:turquoise}.Pre .menu{position:absolute;margin-top:-2em;right:0}.Pre .object{color:#00ff00}.Pre .property{color:#8eef8e}.Pre .state{color:cornflowerblue}.Pre .string{color:#dd8f00}.Pre > code:before{color:#666}.Pre a{color:turquoise}.Pre a:hover{color:#d15100}.Pre button{background-color:#666;border-radius:3px;color:#fefefe;margin:0 .2em;padding:1px 3px;border:0 none}.Pre pre{overflow-x:auto}.Pre pre > code{display:block;padding:0 1em 0}.Pre pre > code:last-child{padding:0 1em 1em}.SkipLink{height:1px;left:0;overflow:hidden;position:absolute;top:0;width:1px}#Magic.light{background-color:#eeeeee;color:#232323}h1:target,h2:target,h3:target,h4:target,h5:target{text-decoration:underline}:target > h1:first-child,:target > h2:first-child,:target > h3:first-child,:target > h4:first-child,:target > h5:first-child{text-decoration:underline}a:hover{color:#fefefe}.light a{color:#232323}.light a:hover{color:#232323}.Page{margin-bottom:3em}h4{font-size:1.1em}p{line-height:1.8}.light .Menu li.active > a{color:#232323}.Menu li.active li a{text-decoration:none}@media screen and (min-width:1024px){.Header{width:210px;position:fixed;float:left;max-height:100vh;height:100vh;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;box-sizing:border-box}.Header p{font-size:1em}.Header .Menu{max-width:210px;padding:0 0 2em}.Logo{float:none}.Menu{max-width:210px;padding:0 0 2em}.Page{float:right;width:calc(100% - 220px);min-height:83vh}.Footer{clear:both}}@media screen and (min-width:500px{.Header .Menu{width:auto;float:left}}@media screen and (min-width:900px){.NoSpy input[type=button]{margin:1em 3% 0 0;max-width:30%;width:auto}} \ No newline at end of file +html{scroll-behavior:smooth;overflow-y:scroll}h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,img,picture,source,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video,div,body{border:0;box-sizing:border-box;font:inherit;font-size:100%;margin:0;padding:0;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1.5;margin:0;max-width:100vw;overflow-x:hidden;padding:0;font-family:"Ubuntu Narrow",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,sans-serif}ul{display:inline-block;list-style:none}ol{display:inline-block;list-style:inside decimal}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}a{cursor:pointer;outline:none;white-space:nowrap;color:#eeeeee;text-decoration:underline;transition:color 500ms}b,strong{font-weight:700}i,em{font-style:italic}button,.button,input[type="reset"],input[type="button"],input[type="submit"],input[type="file"] > input[type="button"]{background-color:#9E9E9E;color:#212121;cursor:pointer;padding:0.5em}button:hover,.button:hover,input[type="reset"]:hover,input[type="button"]:hover,input[type="submit"]:hover,input[type="file"] > input[type="button"]:hover{background-color:#616161;color:#F5F5F5}button::-moz-focus-inner,.button::-moz-focus-inner,input[type="reset"]::-moz-focus-inner,input[type="button"]::-moz-focus-inner,input[type="submit"]::-moz-focus-inner,input[type="file"] > input[type="button"]::-moz-focus-inner{border:0 none;padding:0}#Magic{height:100%;min-height:100vh;width:100%;background-color:#232323;color:#cccccc;transition:color 300ms,background-color 300ms;font-weight:400}.Wrapper{margin:0 auto;max-width:1300px;width:90%}.Header{display:inline-block;width:100%;padding:.5em 0 0}.Header .Logo{display:inline-block}.Header .Logo img{float:left}.Header .Logo span{float:left;font-size:1.5em;margin:.7em .2em}.Page h1{padding:1em 0 .2em}.Footer{width:100%;padding:2em 0 .5em;position:relative}h1,h2,h3,h4,h5{padding:1em 0 .2em}h1{font-size:1.4em}h2{font-size:1.3em}h3{font-size:1.2em}.Credits{clear:both;display:block;margin:2em 0 1em}.Credits a{color:#cccccc;text-decoration:underline}.Credits a:hover{color:#c4c4c4}.Footer .Container{text-align:center}.GitBadges{display:inline-block;margin:15px 0}.GitBadges img{height:23px}.GitBadges li{margin:0 .5em 0 0;display:inline-block;float:left}.Header .Menu{display:inline-block;width:100%}.Header p{font-size:1.5em}.LightSwitch{background:none;border:none;color:inherit;cursor:pointer;fill:#9E9E9E;font:inherit;height:2em;outline:inherit;padding:0;width:2em;left:auto;position:fixed;right:0.5em;top:0.5em}.LightSwitch:hover{background:none;fill:#616161}.Logo{float:left;height:2.4em}.Logo .stroke{fill:none;stroke:#663695;stroke-width:15;stroke-linecap:round;stroke-linejoin:round}.Logo .stroke.white{stroke:#ffffff}.Logo svg{display:inline-block;width:3em;height:auto}.Menu{float:none;margin:1.5em 0 0;position:relative;display:block;clear:both}.Menu li{float:none;margin:0 .5em 0 0;display:block}.Menu li.active > a{text-decoration:underline;color:#fefefe}.Menu li a{display:block;text-decoration:none}.Menu ul ul{position:relative;left:0;border-left:1px dotted;display:block;margin:0 0 0 0.2em;padding:0 0 0 0.3em}.NoSpy{-webkit-animation:showNoSpy 1s 1s forwards;animation:showNoSpy 1s 1s forwards;bottom:0.5em;left:3%;max-width:94%;opacity:0;position:fixed;text-align:center}.NoSpy .Container{background-color:#212121;border:1px solid;border-radius:.5em;color:#F5F5F5;display:inline-block;padding:1em;position:relative;text-align:left}.light .NoSpy .Container{background-color:#F5F5F5;color:#212121}.NoSpy .ShowHide{position:fixed;left:1em;bottom:1em;width:2em;height:2em;cursor:pointer;color:#9E9E9E;stroke:#9E9E9E;fill:#9E9E9E}.NoSpy .ShowHide:hover{color:#616161;stroke:#616161;fill:#616161}.NoSpy h3{padding:0;margin:0}.NoSpy input[type=button]{display:inline-block;margin:0.5em 0;width:100%}@-webkit-keyframes showNoSpy{0%{opacity:0}100%{opacity:1}}@keyframes showNoSpy{0%{opacity:0}100%{opacity:1}}.Pre{background-color:#121212;border:1px solid #666;border-radius:5px;color:#eee;counter-reset:line;display:block;font-family:monospace;line-height:1.3;margin:1em 0;padding:1em .5em 0 .2em;position:relative;text-align:left;transition:color 300ms,background-color 300ms;white-space:pre}.Pre.lines pre > code{counter-increment:line;padding:0}.Pre.lines pre > code:last-child{padding:0 0 1em}.Pre.lines pre > code:before{content:counter(line);display:inline-block;padding:0 .5em 0 0;text-align:right;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:3ch}.Pre .actions{color:blueviolet}.Pre .boolean{color:#7979e4}.Pre .builtin{color:cadetblue}.Pre .colon{color:#8eef8e}.Pre .comment{opacity:0.7;font-style:italic}.Pre .html{color:#008800}.Pre .keyword{color:violet}.light .Pre{background-color:#ddd;color:#111}.light .Pre > code:before{color:#666}.light .Pre .html{color:#008800}.light .Pre .keyword{color:purple}.light .Pre .builtin{color:cadetblue}.light .Pre .string{color:#d15100}.light .Pre .colon{color:#016301}.light .Pre .boolean{color:blue}.light .Pre .actions{color:blueviolet}.light .Pre .state{color:cornflowerblue}.light .Pre .comment{color:#555;opacity:0.8;font-style:italic}.light .Pre .object{color:#016301}.light .Pre .property{color:#2a952a}.light .Pre a{color:#d15100}.light .Pre a:hover{color:turquoise}.Pre .menu{position:absolute;margin-top:-2em;right:0}.Pre .object{color:#00ff00}.Pre .property{color:#8eef8e}.Pre .state{color:cornflowerblue}.Pre .string{color:#dd8f00}.Pre > code:before{color:#666}.Pre a{color:turquoise}.Pre a:hover{color:#d15100}.Pre button{background-color:#666;border-radius:3px;color:#fefefe;margin:0 .2em;padding:1px 3px;border:0 none}.Pre pre{overflow-x:auto}.Pre pre > code{display:block;padding:0 1em 0}.Pre pre > code:last-child{padding:0 1em 1em}.SkipLink{height:1px;left:0;overflow:hidden;position:absolute;top:0;width:1px}#Magic.light{background-color:#eeeeee;color:#232323}h1:target,h2:target,h3:target,h4:target,h5:target{text-decoration:underline}:target > h1:first-child,:target > h2:first-child,:target > h3:first-child,:target > h4:first-child,:target > h5:first-child{text-decoration:underline}a:hover{color:#fefefe}.light a{color:#232323}.light a:hover{color:#232323}.Page{margin-bottom:3em}h4{font-size:1.1em}p{line-height:1.8}.light .Menu li.active > a{color:#232323}.Menu li.active li a{text-decoration:none}@media screen and (min-width:1024px){.Header{width:210px;position:fixed;float:left;max-height:100vh;height:100vh;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;box-sizing:border-box}.Header p{font-size:1em}.Header .Menu{max-width:210px;padding:0 0 2em}.Logo{float:none}.Menu{max-width:210px;padding:0 0 2em}.Page{float:right;width:calc(100% - 220px);min-height:83vh}.Footer{clear:both}}@media screen and (min-width:500px{.Header .Menu{width:auto;float:left}}@media screen and (min-width:900px){.NoSpy input[type=button]{margin:1em 3% 0 0;max-width:30%;width:auto}} \ No newline at end of file diff --git a/docs/magic.js b/docs/magic.js index 2c8ecb8..d52a88c 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&&Symbol.iterator in Object(a))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}}}},na={changeTheme:function changeTheme(a){return j(j({},a),{},{pageClass:j(j({},a.pageClass),{},{light:"dark"===a.theme}),theme:"dark"===a.theme?"light":"dark"})},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=window,k=i.scrollY,m=a.pages&&a.pages[f]&&a.pages[f].title;if(m&&(document.title=a.title=m),f===a.url)window.location.hash=h;else if(!h){var n=document.getElementsByTagName("html"),o=l(n,1),p=o[0],q=p.style.scrollBehavior;p.style.scrollBehavior="auto",window.scrollTo({top:0,behavior:"smooth"}),p.style.scrollBehavior=q}return window.history.pushState({url:f,hash:h,scrollY:k},a.title,c),j(j({},a),{},{url:f,hash:h,prev:a.url})},nospy:{close:function close(a){return j(j({},a),{},{nospy:j(j({},a.nospy),{},{show:!1})})},show:function(a,b){var c=b.show;return"boolean"==typeof c?j(j({},a),{},{nospy:j(j({},a.nospy),{},{show:c})}):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,behavior:"smooth"}),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}}},oa={"/json/":function json(a){return[g({id:"magic-librariesjson"},"@magic-libraries/json"),M(["this is the\n",ea({to:"https://github.com/magic-libraries",text:"@magic-libraries"}),"\njson library. it returns errors instead of throwing them\nand catches (some) malformed objects when stringifying."]),_("@magic-libraries/json"),C({id:"installation"},"installation"),la({lines:"false"},"npm install @magic-libraries/json"),C({id:"usage"},"usage"),M("in a page/component, just use the lib.json functions"),la({lines:"false"},"lib.json.stringify({ some: { object: ['with', 'values'] } })"),M("renders"),la({lines:"false"},"{ \"some\": { \"object\": [\"with\", \"values\"] } }"),C({id:"caveat"},"caveat"),M("this library is intended to handle incoming web traffic.\nwe can never be sure that this incoming packets will not include faulty json."),M(["to use this library without checking it's return value\nyour input json ",ea({to:"https://tools.ietf.org/html/rfc2119#section-1",text:"MUST"})," be wellformed."]),M("in all (other) cases the following pattern should be employed\n(and enhanced with custom error messages)."),la("export const ViewStringify = unsafe => {\n const result = lib.json.stringify(unsafe)\n return div([result.message ? result.message : result])\n}\n\nexport const ViewParse = unsafe => {\n const result = lib.json.parse(unsafe)\n // in this case we can not check for .message,\n // since unsafe might have a .message key after parsing\n div([result instanceof Error ? result.message : result])\n}"),C({id:"example-modules"},"example modules"),M("the example/assets directory contains two modules that use the lib.json functions:"),la({lines:"false"},""),M("renders"),da({state:a}),la({lines:"false"},"{ \"valid\": true }"),M("renders"),ca("{ \"valid\": true }"),C({id:"source"},"source"),M(["the source for this page is in the\n",ea({to:"https://github.com/magic-libraries/json/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"})])]},"/json/404/":function json404(){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,na.pop]]},view:function(a){var b=oa[a.url]?a.url:"/404/",c=oa[b],d=a.pages&&a.pages[b];return d&&Object.keys(d).forEach(function(b){a[b]=d[b]}),a.url=b,ka({page:c,state:a},ja(a))},node:document.getElementById("Magic")}); \ No newline at end of file +"use strict";function b(a){return s(a)||c(a)||n(a)||m()}function c(a){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a))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}}}},na={changeTheme:function changeTheme(a){return j(j({},a),{},{pageClass:j(j({},a.pageClass),{},{light:"dark"===a.theme}),theme:"dark"===a.theme?"light":"dark"})},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=window,k=i.scrollY,m=a.pages&&a.pages[f]&&a.pages[f].title;if(m&&(document.title=a.title=m),f===a.url)window.location.hash=h;else if(!h){var n=document.getElementsByTagName("html"),o=l(n,1),p=o[0],q=p.style.scrollBehavior;p.style.scrollBehavior="auto",window.scrollTo({top:0,behavior:"smooth"}),p.style.scrollBehavior=q}return window.history.pushState({url:f,hash:h,scrollY:k},a.title,c),j(j({},a),{},{url:f,hash:h,prev:a.url})},nospy:{close:function close(a){return j(j({},a),{},{nospy:j(j({},a.nospy),{},{show:!1})})},show:function(a,b){var c=b.show;return"boolean"==typeof c?j(j({},a),{},{nospy:j(j({},a.nospy),{},{show:c})}):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,behavior:"smooth"}),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}}},oa={"/json/":function json(a){return[g({id:"magic-librariesjson"},"@magic-libraries/json"),M(["this is the\n",ea({to:"https://github.com/magic-libraries",text:"@magic-libraries"}),"\njson library. it returns errors instead of throwing them\nand catches (some) malformed objects when stringifying."]),_("@magic-libraries/json"),C({id:"installation"},"installation"),la({lines:"false"},"npm install @magic-libraries/json"),C({id:"usage"},"usage"),M("in a page/component, just use the lib.json functions"),la({lines:"false"},"lib.json.stringify({ some: { object: ['with', 'values'] } })"),M("renders"),la({lines:"false"},"{ \"some\": { \"object\": [\"with\", \"values\"] } }"),C({id:"caveat"},"caveat"),M("this library is intended to handle incoming web traffic.\nwe can never be sure that this incoming packets will not include faulty json."),M(["to use this library without checking it's return value\nyour input json ",ea({to:"https://tools.ietf.org/html/rfc2119#section-1",text:"MUST"})," be wellformed."]),M("in all (other) cases the following pattern should be employed\n(and enhanced with custom error messages)."),la("export const ViewStringify = unsafe => {\n const result = lib.json.stringify(unsafe)\n return div([result.message ? result.message : result])\n}\n\nexport const ViewParse = unsafe => {\n const result = lib.json.parse(unsafe)\n // in this case we can not check for .message,\n // since unsafe might have a .message key after parsing\n div([result instanceof Error ? result.message : result])\n}"),C({id:"example-modules"},"example modules"),M("the example/assets directory contains two modules that use the lib.json functions:"),la({lines:"false"},""),M("renders"),da({state:a}),la({lines:"false"},"{ \"valid\": true }"),M("renders"),ca("{ \"valid\": true }"),C({id:"source"},"source"),M(["the source for this page is in the\n",ea({to:"https://github.com/magic-libraries/json/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"})])]},"/json/404/":function json404(){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,na.pop]]},view:function(a){var b=oa[a.url]?a.url:"/404/",c=oa[b],d=a.pages&&a.pages[b];return d&&Object.keys(d).forEach(function(b){a[b]=d[b]}),a.url=b,ka({page:c,state:a},ja(a))},node:document.getElementById("Magic")}); \ No newline at end of file diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 59bb45f..06ba68d 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -7,14 +7,14 @@ https://magic-libraries.github.io/json/ - 2020-07-17 + 2020-07-18 weekly 0.5 https://magic-libraries.github.io/json/404/ - 2020-07-17 + 2020-07-18 weekly 0.5 diff --git a/docs/sri-hashes.json b/docs/sri-hashes.json index 4ac8c14..87ffbfe 100644 --- a/docs/sri-hashes.json +++ b/docs/sri-hashes.json @@ -1,8 +1,8 @@ { - "/magic.css": "sha384-m0rgTTR+NsZCatxTILqr/RPlnxFUoZCNn4QReZM3/rWmDWIkdbxVJyOsaKE82Pm/", - "/magic.js": "sha384-dj+bUG2sJDl0BstpXbzZKzAyCBaV3fshwVNY9JIAiIZCdSKPAMzA9NWWVCsyykZL", - "/json/": "sha384-4FfL3W72wtwgWwGLhP7Wn4toKdhAl3/hFwMS/zApWnFL3L2LMPrdu2/XaBdOk1Ul", - "/json/404/": "sha384-48+WlTDqP53Z0tp/a2nm3w40PZDnt+darKI3o/Tiwr9cEl4XFis5OtowrqbujAH3", + "/magic.css": "sha384-IaHIeqgKAXPVltBUYtWuOgSOMY7fbiwUvGRCvcfPxynVAxho7i9ZJjKQFT9myZ2v", + "/magic.js": "sha384-91N8LuRxU+FViKl/gac8KBrqp5TNvirG+mBA4seeHgM3bECUVlkQCWzqlCGHbD2l", + "/json/": "sha384-elYwVGTBh1bZ/LWpWbVHEesRDEjLqQO3PjG6M92eYNyPceYafeR7R2VGGInnBBSJ", + "/json/404/": "sha384-0+lDf7QbiuyO9HqVq2pbx2Ege22cyWCyOyKzRTZOBmK88ho/1LIHlejK5DElRnI/", "/robots.txt": "sha384-BezcsYYh2jQK8v9dbMv1mqHr9efGOsKGiwvoFUqIyZ+t+aedW6lctl/bW644Rmah", - "/sitemap.xml": "sha384-Vt49tI/EvkeVIdIvmA+lXJLBfO3MoLjzRZZU1WGDgc/Zdi2jW3nMGdwRDp7gj/jT" + "/sitemap.xml": "sha384-e43/J9g9cAOeEZJUJ0sD4x9SqUsQvkucB/ixbx5s02pjUX2s2CvrSmdMre74Ihqm" } \ No newline at end of file