peryl 1.4.39 → 1.4.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +8 -7
  2. package/dist/cache.js +1 -0
  3. package/dist/cache.js.map +1 -1
  4. package/dist/debounce.js +1 -0
  5. package/dist/debounce.js.map +1 -1
  6. package/dist/dom.js +1 -0
  7. package/dist/dom.js.map +1 -1
  8. package/dist/encode.js +1 -0
  9. package/dist/encode.js.map +1 -1
  10. package/dist/events.js +1 -0
  11. package/dist/events.js.map +1 -1
  12. package/dist/form.js +1 -0
  13. package/dist/form.js.map +1 -1
  14. package/dist/google-analytics.js +1 -0
  15. package/dist/google-analytics.js.map +1 -1
  16. package/dist/hash.d.ts +3 -0
  17. package/dist/hash.js +16 -3
  18. package/dist/hash.js.map +1 -1
  19. package/dist/history.js +1 -0
  20. package/dist/history.js.map +1 -1
  21. package/dist/hsml-app.d.ts +2 -3
  22. package/dist/hsml-app.js +6 -6
  23. package/dist/hsml-app.js.map +1 -1
  24. package/dist/hsml-convert.js +1 -0
  25. package/dist/hsml-convert.js.map +1 -1
  26. package/dist/hsml-dom.js +1 -0
  27. package/dist/hsml-dom.js.map +1 -1
  28. package/dist/hsml-h.js +1 -0
  29. package/dist/hsml-h.js.map +1 -1
  30. package/dist/hsml-html.js +1 -0
  31. package/dist/hsml-html.js.map +1 -1
  32. package/dist/hsml-idom.js +2 -1
  33. package/dist/hsml-idom.js.map +1 -1
  34. package/dist/hsml-svac-ctrl.js +1 -0
  35. package/dist/hsml-svac-ctrl.js.map +1 -1
  36. package/dist/hsml-svac-html.js +1 -0
  37. package/dist/hsml-svac-html.js.map +1 -1
  38. package/dist/hsml-widget.js +1 -0
  39. package/dist/hsml-widget.js.map +1 -1
  40. package/dist/hsml.js +1 -0
  41. package/dist/hsml.js.map +1 -1
  42. package/dist/http.js +1 -0
  43. package/dist/http.js.map +1 -1
  44. package/dist/index.js +1 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/load.js +1 -0
  47. package/dist/load.js.map +1 -1
  48. package/dist/objpaths.js +1 -0
  49. package/dist/objpaths.js.map +1 -1
  50. package/dist/router.js +1 -0
  51. package/dist/router.js.map +1 -1
  52. package/dist/settings.js +1 -0
  53. package/dist/settings.js.map +1 -1
  54. package/dist/signal.js +1 -0
  55. package/dist/signal.js.map +1 -1
  56. package/dist/template.js +1 -0
  57. package/dist/template.js.map +1 -1
  58. package/dist/tmpl.js +1 -0
  59. package/dist/tmpl.js.map +1 -1
  60. package/dist/umd/cache.js +1 -1
  61. package/dist/umd/cache.js.map +1 -1
  62. package/dist/umd/debounce.js +1 -1
  63. package/dist/umd/debounce.js.map +1 -1
  64. package/dist/umd/dom.js +1 -1
  65. package/dist/umd/dom.js.map +1 -1
  66. package/dist/umd/encode.js +1 -1
  67. package/dist/umd/encode.js.map +1 -1
  68. package/dist/umd/events.js +1 -1
  69. package/dist/umd/events.js.map +1 -1
  70. package/dist/umd/form.js +1 -1
  71. package/dist/umd/form.js.map +1 -1
  72. package/dist/umd/google-analytics.js +1 -1
  73. package/dist/umd/google-analytics.js.map +1 -1
  74. package/dist/umd/hash.js +1 -1
  75. package/dist/umd/hash.js.map +1 -1
  76. package/dist/umd/history.js +1 -1
  77. package/dist/umd/history.js.map +1 -1
  78. package/dist/umd/hsml-app.js +1 -1
  79. package/dist/umd/hsml-app.js.map +1 -1
  80. package/dist/umd/hsml-convert.js +1 -1
  81. package/dist/umd/hsml-convert.js.map +1 -1
  82. package/dist/umd/hsml-dom.js +1 -1
  83. package/dist/umd/hsml-dom.js.map +1 -1
  84. package/dist/umd/hsml-h.js +1 -1
  85. package/dist/umd/hsml-h.js.map +1 -1
  86. package/dist/umd/hsml-html.js +1 -1
  87. package/dist/umd/hsml-html.js.map +1 -1
  88. package/dist/umd/hsml-idom.js +1 -1
  89. package/dist/umd/hsml-idom.js.map +1 -1
  90. package/dist/umd/hsml-svac-ctrl.js +1 -1
  91. package/dist/umd/hsml-svac-ctrl.js.map +1 -1
  92. package/dist/umd/hsml-svac-html.js +1 -1
  93. package/dist/umd/hsml-svac-html.js.map +1 -1
  94. package/dist/umd/hsml-widget.js +1 -1
  95. package/dist/umd/hsml-widget.js.map +1 -1
  96. package/dist/umd/hsml.js +1 -1
  97. package/dist/umd/hsml.js.map +1 -1
  98. package/dist/umd/http.js +1 -1
  99. package/dist/umd/http.js.map +1 -1
  100. package/dist/umd/index.js +1 -1
  101. package/dist/umd/index.js.map +1 -1
  102. package/dist/umd/load.js +1 -1
  103. package/dist/umd/load.js.map +1 -1
  104. package/dist/umd/objpaths.js +1 -1
  105. package/dist/umd/objpaths.js.map +1 -1
  106. package/dist/umd/router.js +1 -1
  107. package/dist/umd/router.js.map +1 -1
  108. package/dist/umd/settings.js +1 -1
  109. package/dist/umd/settings.js.map +1 -1
  110. package/dist/umd/signal.js +1 -1
  111. package/dist/umd/signal.js.map +1 -1
  112. package/dist/umd/template.js +1 -1
  113. package/dist/umd/template.js.map +1 -1
  114. package/dist/umd/tmpl.js +1 -1
  115. package/dist/umd/tmpl.js.map +1 -1
  116. package/dist/umd/validators-moment.js +1 -1
  117. package/dist/umd/validators-moment.js.map +1 -1
  118. package/dist/umd/validators-numeral.js +1 -1
  119. package/dist/umd/validators-numeral.js.map +1 -1
  120. package/dist/umd/validators-object.js +1 -1
  121. package/dist/umd/validators-object.js.map +1 -1
  122. package/dist/umd/validators.js +1 -1
  123. package/dist/umd/validators.js.map +1 -1
  124. package/dist/validators-moment.js +1 -0
  125. package/dist/validators-moment.js.map +1 -1
  126. package/dist/validators-numeral.js +1 -0
  127. package/dist/validators-numeral.js.map +1 -1
  128. package/dist/validators-object.js +1 -0
  129. package/dist/validators-object.js.map +1 -1
  130. package/dist/validators.js +1 -4
  131. package/dist/validators.js.map +1 -1
  132. package/package.json +1 -1
  133. package/src/hash.ts +20 -2
  134. package/src/hsml-app.ts +6 -8
  135. package/src/hsml-idom.ts +2 -2
  136. package/src/validators.ts +4 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/hsml.ts","webpack:///./src/hsml-svac-html.ts","webpack:///./src/hsml-html.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","hsml","hml","handler","ctx","constructor","Array","hmlTag","console","error","head","attrsObj","hasAttrs","hFnc","hObj","children","htc","Function","String","Boolean","Number","Date","refSplit","split","ref","dotSplit","hashSplit","tag","id","classes","slice","attrs","_id","length","_classes","_ref","_hObj","skip","open","fnc","forEach","jml","close","hsmlTag","text","toLocaleString","toString","ds","obj","hsmls","sep","reduce","push","splice","actionHtml","action","data","event","mountHtml","component","state","view","onHtml","pretty","hsmls2html","hsmls2htmls","join","HsmlHtmlHandler","indent","_depth","this","_onHtml","_pretty","_indent","props","attrClasses","concat","map","undefined","filter","attrData","JSON","stringify","attrStyles","style","replace","toLowerCase","unshift","type","args","escapeHtml","html","_mkIndent","_pairTags","indexOf","render","toHsml","pairTag","count","hsml2html","hsmlEl","htmls","escapeHtmlRegExp","str","exec","esc","escHtml","idx","lastIdx","index","charCodeAt","substring"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUT,QAGnC,IAAIC,EAASM,EAAiB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AAWf,EAAO0C,GAAQU,EAAMjD,KAAKuC,GAAO5B,GACrCsC,GAGX,MAAMC,EAAmB,UAYzB,SAASZ,EAAWC,GAChB,MAAMY,EAAM,GAAKZ,EACXtH,EAAIiI,EAAiBE,KAAKD,GAChC,IAAKlI,EACD,OAAOkI,EAEX,IAAIE,EACAC,EAAU,GACVC,EAAM,EACNC,EAAU,EACd,IAAKD,EAAMtI,EAAEwI,MAAOF,EAAMJ,EAAItE,OAAQ0E,IAAO,CACzC,OAAQJ,EAAIO,WAAWH,IACnB,KAAK,GACDF,EAAM,SACN,MACJ,KAAK,GACDA,EAAM,QACN,MACJ,KAAK,GACDA,EAAM,QACN,MACJ,KAAK,GACDA,EAAM,OACN,MACJ,KAAK,GACDA,EAAM,OACN,MACJ,QACI,SAEJG,IAAYD,IACZD,GAAWH,EAAIQ,UAAUH,EAASD,IAEtCC,EAAUD,EAAM,EAChBD,GAAWD,EAEf,OAAOG,IAAYD,EACbD,EAAUH,EAAIQ,UAAUH,EAASD,GACjCD","file":"hsml-svac-html.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 16);\n","\nexport type HHead = keyof HTMLElementTagNameMap | string; // \"tag#id.class1.class2~handler\"\n\nexport type HAttrClasses = Array<string | [string, boolean]>;\n\nexport type HAttrStyles = { [key: string]: string };\n\nexport type HAttrData = {\n [key: string]:\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object;\n};\n\nexport type HAttrOnAction = string;\n\nexport type HAttrOnDataFnc = (e: Event) => any;\n\nexport type HAttrOnData =\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object\n | HAttrOnDataFnc\n | null;\n\nexport type HAttrOnCb = [keyof HTMLElementEventMap, EventListener];\n\nexport type HAttrOnAct = [\n keyof HTMLElementEventMap,\n HAttrOnAction,\n HAttrOnData?\n];\n\nexport type HAttrOn = HAttrOnCb | HAttrOnAct | Array<HAttrOnCb | HAttrOnAct>;\n\nexport interface HAttrs {\n readonly _id?: string;\n readonly _classes?: string[];\n readonly _ref?: string;\n readonly _key?: string;\n readonly _skip?: boolean;\n readonly _hObj?: HObj;\n readonly classes?: HAttrClasses;\n readonly styles?: HAttrStyles;\n readonly data?: HAttrData;\n readonly on?: HAttrOn;\n readonly [key: string]:\n | string\n | String\n | string[]\n | String[]\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | HAttrClasses\n | HAttrStyles\n // | HsmlAttrData\n | HAttrOn\n | EventListener\n | HObj\n | undefined;\n}\n\nexport type HFnc = (e: Element) => boolean | void;\n\nexport interface HObj {\n toHsml?(): HElement;\n}\n\nexport interface HElements extends Array<HElement> {}\n\nexport type HChildren =\n | HElements\n | HFnc\n | HObj\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport type HTagNoAttr = [HHead, HChildren?];\nexport type HTagAttr = [HHead, HAttrs, HChildren?];\n\nexport type HTag = HTagNoAttr | HTagAttr;\n\nexport type HElement =\n | HFnc\n | HObj\n | HTag\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport interface HHandlerCtx extends HObj {\n refs: { [name: string]: Element };\n actionCb(action: HAttrOnAction, data: HAttrOnData, e: Event): void;\n}\n\nexport interface HHandler<C extends HHandlerCtx> {\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: C): boolean;\n close(tag: HHead, children: HElements, ctx?: C): void;\n text(text: string, ctx?: C): void;\n fnc(fnc: HFnc, ctx?: C): void;\n obj(obj: HObj, ctx?: C): void;\n}\n\nexport function hsml<C extends HHandlerCtx>(hml: HElement,\n handler: HHandler<C>,\n ctx?: C): void {\n // console.log(\"hsml\", hsml);\n if (hml === undefined || hml === null) {\n return;\n }\n switch (hml.constructor) {\n case Array:\n // const tag = hml as HTag;\n // if (\n // (\n // tag.length === 1 &&\n // tag[0].constructor === String\n // ) ||\n // (\n // tag.length === 2 &&\n // (\n // tag[0].constructor === String &&\n // (tag[1]!.constructor === Array || tag[1]!.constructor === Function)\n // ) ||\n // (\n // tag[0].constructor === String &&\n // tag[1]!.constructor === Object\n // )\n // ) ||\n // (\n // tag.length === 3 &&\n // tag[0].constructor === String &&\n // tag[1].constructor === Object &&\n // tag[2]!.constructor === Array\n // )\n // ) {\n // hsmlTag(hml as HTag, handler, ctx);\n // } else {\n // console.error(\"hsml parse error:\", hml);\n // // console.error(\"hsml parse error:\", JSON.stringify(hml, null, 4));\n // // throw Error(`hsml parse error: ${JSON.stringify(hml)}`);\n // }\n hsmlTag(hml as HTag, handler, ctx);\n break;\n case Function:\n handler.fnc(hml as HFnc, ctx);\n break;\n case String:\n handler.text(hml as string, ctx);\n break;\n case Boolean:\n handler.text(\"\" + hml, ctx);\n break;\n case Number:\n const n = hml as number;\n const ns = n.toLocaleString ? n.toLocaleString() : n.toString();\n handler.text(ns, ctx);\n break;\n case Date:\n const d = hml as Date;\n const ds = d.toLocaleString ? d.toLocaleString() : d.toString();\n handler.text(ds, ctx);\n break;\n default: // HObj\n handler.obj(hml as HObj, ctx);\n }\n\n function hsmlTag(hmlTag: HTag, handler: HHandler<C>, ctx?: C): void {\n // console.log(\"hsml tag\", hmlTag);\n\n if (typeof hmlTag[0] !== \"string\") {\n console.error(\"HSML tag head not string:\", hmlTag);\n return;\n }\n\n const head = hmlTag[0] as HHead;\n const attrsObj = hmlTag[1] as any;\n const hasAttrs = attrsObj && attrsObj.constructor === Object;\n const childIdx = hasAttrs ? 2 : 1;\n\n let children: HElements = [];\n let hFnc: HFnc | undefined;\n let hObj: HObj | undefined;\n\n const htc = hmlTag[childIdx];\n switch (htc && htc.constructor) {\n case Array:\n children = htc as HElements;\n break;\n case Function:\n hFnc = htc as HFnc;\n break;\n case String:\n case Boolean:\n case Number:\n case Date:\n children = [htc as string | boolean | number | Date];\n break;\n default: // HObj\n hObj = htc as HObj;\n break;\n }\n\n const refSplit = head.split(\"~\");\n const ref = refSplit[1];\n const dotSplit = refSplit[0].split(\".\");\n const hashSplit = dotSplit[0].split(\"#\");\n const tag = hashSplit[0] || \"div\";\n const id = hashSplit[1];\n const classes = dotSplit.slice(1);\n\n let attrs: HAttrs;\n if (hasAttrs) {\n attrs = attrsObj as HAttrs;\n } else {\n attrs = {} as HAttrs;\n }\n\n if (id) {\n (attrs as any)._id = id;\n }\n if (classes.length) {\n (attrs as any)._classes = classes;\n }\n if (ref) {\n (attrs as any)._ref = ref;\n }\n if (hObj) {\n (attrs as any)._hObj = hObj;\n }\n\n const skip = handler.open(tag, attrs, children, ctx);\n\n if (hFnc) {\n handler.fnc(hFnc, ctx);\n }\n\n if (!skip) {\n children.forEach(jml => hsml(jml, handler, ctx));\n }\n\n handler.close(tag, children, ctx);\n }\n}\n\nexport function hjoin(hsmls: HElements, sep: string | HElement): HElements {\n const r = hsmls.reduce<HElements>(\n (p, c) => (p.push(c, sep), p),\n [] as HElements\n );\n r.splice(-1);\n return r;\n}\n\n// Test\n\n// const hsmls: Hsmls = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\", { attr: \"attr\", classes: [\"class\"] }, [\n// \"text\",\n// 123,\n// true\n// ]]\n// ];\n\n// const hml: Hsml = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"t\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const hml1: Hsml = [\"div\", null, [\n// [\"span\", null, [\n// [\"a\",\n// {\n// href: \"https://gitlab.com/peter-rybar/diasheet\",\n// title: \"GitLab\",\n// target: \"_blank\"\n// },\n// [[\"i.fa.fa-gitlab\"]]\n// ]\n// ]],\n// [\"span\"]\n// ]];\n// console.log(hml1);\n\n// const hml2: Hsml = [\"div\", [\n// [\"h2\", [\"title\"]],\n// [\"div.w3-card-12\", [\n// [\"header.w3-container w3-light-grey\", [\n// [\"h3\", [\"Account: \", \"User\"]]\n// ]],\n// [\"div.w3-container.w3-light-grey\", [\n// [\"p\", [\"Balance: 4 DCT\"]],\n// [\"br\"]\n// ]],\n// [\"h4\", [\"Your account spending\"]],\n// [\"div#piechart\"],\n// [\"h4\", [\"Your account balance\"]],\n// [\"div#linechart\"],\n// [\"button.w3-button.w3-block.w3-dark-grey\", [\"Refresh\"]]\n// ]],\n// [\"br\"]\n// ]];\n// console.log(hml2);\n\n// TEST\n\n// import { hsmls2htmls } from \"./hsml-html\";\n// import { HDispatch } from \"./hsml-app\";\n\n// const dispatch: HDispatch = (type: string, data?: any, event?: Event): void => {\n// console.log(\"action:\", type, data, event);\n// };\n\n// const data = { attr: \"action-data\" };\n\n// const hmls: HElements = [\n// [\"button\", { on: [\"click\", \"action\", data] }, \"send\"],\n// [\"h1\", \"aaa\"],\n// [\"input\",\n// {\n// type: \"text\",\n// on: [\n// [\"mouseover\", \"hover-action\", data],\n// [\"change\", \"click-action\", e => (e.target as HTMLInputElement).value],\n// [\"click\", e => dispatch(\"action\", data, e)],\n// ],\n// click: e => dispatch(\"action\", data, e)\n// }\n// ],\n// [\"button\",\n// {\n// on: [\"click\", e => dispatch(\"action\", data, e)],\n// click: e => dispatch(\"action\", data, e)\n// },\n// [\"Send\"]\n// ]\n// ];\n\n// console.log(hsmls2htmls(hmls, true).join(\"\"));\n","import { HElements, HFnc } from \"./hsml\";\nimport { hsmls2htmls, hsmls2html } from \"./hsml-html\";\nimport { HAction, HMount, HComponent } from \"./hsml-svac\";\n\nconst actionHtml: HAction = (action: string | number, data: any, event?: Event) => { };\n\nconst mountHtml: HMount = <STATE>(component: HComponent<STATE>,\n state?: STATE): HFnc | HElements => {\n return component.view(state || component.state, actionHtml, mountHtml);\n};\n\nexport function html<STATE>(component: HComponent<STATE>,\n state: STATE,\n onHtml: (html: string) => void,\n pretty = false): void {\n hsmls2html(component.view(state, actionHtml, mountHtml), onHtml, pretty);\n}\n\nexport function htmls<STATE>(component: HComponent<STATE>,\n state: STATE,\n pretty = false): string {\n return hsmls2htmls(component.view(state, actionHtml, mountHtml), pretty).join(\"\");\n}\n","import {\n hsml,\n HElement,\n HElements,\n HHead,\n HAttrs,\n HAttrClasses,\n HAttrData,\n HAttrStyles,\n HFnc,\n HObj,\n HHandler,\n HHandlerCtx\n} from \"./hsml\";\n\nclass HsmlHtmlHandler implements HHandler<HHandlerCtx> {\n\n private static _pairTags = [\n \"script\", \"iframe\",\n \"html\", \"head\", \"body\", \"title\", \"div\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\",\n \"p\", \"a\", \"pre\", \"blockquote\", \"i\", \"b\", \"em\", \"strong\", \"tt\", \"cite\",\n \"ol\", \"ul\", \"li\", \"dl\", \"dt\", \"dd\", \"table\", \"tr\", \"td\",\n \"textarea\", \"select\", \"option\"];\n\n private _onHtml: (html: string) => void;\n private _pretty: boolean;\n private _indent: string;\n private _depth: number = 0;\n\n constructor(onHtml: (html: string) => void,\n pretty: boolean = false,\n indent: string = \" \") {\n this._onHtml = onHtml;\n this._pretty = pretty;\n this._indent = indent;\n }\n\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: HHandlerCtx): boolean {\n const props: any[] = [];\n let id = attrs._id;\n let classes: string[] = attrs._classes ? attrs._classes : [];\n let hObj: any = attrs._hObj;\n for (const a in attrs) {\n if (attrs.hasOwnProperty(a)) {\n switch (a) {\n case \"_id\":\n case \"_classes\":\n case \"_ref\":\n case \"_key\":\n case \"_skip\":\n case \"_hObj\":\n break;\n case \"id\":\n id = attrs[a] as string;\n break;\n case \"classes\":\n const attrClasses = attrs[a] as HAttrClasses;\n classes = classes.concat(attrClasses\n ? attrClasses\n .map(c =>\n c.constructor === String\n ? c as string\n : (c[1] ? c[0] as string : undefined))\n .filter((c): c is string => c !== undefined)\n : [] as string[]);\n break;\n case \"class\":\n classes = classes.concat((attrs[a] as string).split(\" \"));\n break;\n case \"data\":\n const attrData = attrs[a] as HAttrData;\n for (const d in attrData) {\n if (attrData.hasOwnProperty(d)) {\n if (attrData[d].constructor === String) {\n props.push([\"data-\" + d, attrData[d]]);\n } else {\n props.push([\"data-\" + d, JSON.stringify(attrData[d])]);\n }\n }\n }\n break;\n case \"styles\":\n const attrStyles = attrs[a] as HAttrStyles;\n let style = \"\";\n for (const d in attrStyles) {\n if (attrStyles.hasOwnProperty(d)) {\n const dd = d.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n style += dd + \":\" + attrStyles[d] + \";\";\n }\n }\n props.push([\"style\", style]);\n break;\n case \"styles\":\n break;\n case \"on\":\n break;\n default:\n if (typeof attrs[a] === \"function\") {\n // ignore\n } else if (typeof attrs[a] === \"boolean\") {\n attrs[a] && props.push([a, \"\"]);\n } else {\n props.push([a, attrs[a]]);\n }\n }\n }\n }\n if (classes.length) {\n props.unshift([\"class\", classes.join(\" \")]);\n }\n if (id) {\n props.unshift([\"id\", id]);\n }\n if (hObj && \"type\" in hObj) {\n props.unshift([\"hObj\", hObj.type]);\n }\n const args = props.map(p => `${p[0]}=\"${escapeHtml(p[1])}\"`).join(\" \");\n let html = \"\";\n if (this._pretty) {\n html += this._mkIndent(this._depth);\n this._depth++;\n }\n const pairTag = (children.length || HsmlHtmlHandler._pairTags.indexOf(tag) !== -1);\n html += \"<\" + tag + (args ? \" \" + args : \"\") + (pairTag ? \">\" : \"/>\");\n if (this._pretty) {\n html += \"\\n\";\n }\n this._onHtml(html);\n if (hObj && \"render\" in hObj && hObj.render.constructor === Function) {\n const hsmls = hObj.render() as HElements;\n for (const hml of hsmls) {\n if (hml === undefined || hml === null) {\n continue;\n }\n if (hml.constructor === String) {\n this._onHtml(hml + (this._pretty ? \"\\n\" : \"\"));\n } else if (\"toHsml\" in (hml as any)) {\n const obj = hml as HObj;\n obj.toHsml && hsml(obj.toHsml(), this);\n } else {\n hsml(hml as HElement, this);\n }\n }\n }\n return false;\n }\n\n close(tag: HHead, children: HElements, ctx?: HHandlerCtx): void {\n let html = \"\";\n const pairTag = (children.length || HsmlHtmlHandler._pairTags.indexOf(tag) !== -1);\n if (this._pretty) {\n this._depth--;\n if (pairTag) {\n html += this._mkIndent(this._depth);\n }\n }\n if (pairTag) {\n html += \"</\" + tag + \">\";\n if (this._pretty) {\n html += \"\\n\";\n }\n this._onHtml(html);\n }\n }\n\n text(text: string, ctx?: HHandlerCtx): void {\n let html = \"\";\n if (this._pretty) {\n html += this._mkIndent(this._depth);\n }\n html += (text as any) instanceof String\n ? text\n : escapeHtml(text);\n if (this._pretty) {\n html += \"\\n\";\n }\n this._onHtml(html);\n }\n\n fnc(fnc: HFnc, ctx?: HHandlerCtx): void {\n }\n\n obj(obj: HObj, ctx?: HHandlerCtx): void {\n if (\"toHsml\" in obj) {\n obj.toHsml && hsml(obj.toHsml(), this, obj as HHandlerCtx);\n } else {\n this.text(\"\" + obj, ctx);\n }\n }\n\n private _mkIndent(count: number): string {\n let indent = \"\";\n for (let i = 0; i < count; i++) {\n indent += this._indent;\n }\n return indent;\n }\n\n}\n\nexport function hsml2html(hsmlEl: HElement, onHtml: (html: string) => void, pretty = false): void {\n const handler = new HsmlHtmlHandler(onHtml, pretty);\n hsml(hsmlEl, handler);\n}\n\nexport function hsmls2html(hsmls: HElements, onHtml: (html: string) => void, pretty = false): void {\n for (const hml of hsmls) {\n if (hml === undefined || hml === null) {\n continue;\n }\n if (hml.constructor === String) {\n onHtml(hml + (pretty ? \"\\n\" : \"\"));\n } else if (\"toHsml\" in (hml as any)) {\n const obj = hml as HObj;\n obj.toHsml && hsml2html(obj.toHsml(), onHtml, pretty);\n } else {\n hsml2html(hml as HElement, onHtml, pretty);\n }\n }\n}\n\nexport function hsml2htmls(hsml: HElement, pretty = false): string[] {\n const htmls: string[] = [];\n hsml2html(hsml, html => htmls.push(html), pretty);\n return htmls;\n}\n\nexport function hsmls2htmls(hsmls: HElements, pretty = false): string[] {\n const htmls: string[] = [];\n hsmls2html(hsmls, html => htmls.push(html), pretty);\n return htmls;\n}\n\nconst escapeHtmlRegExp = /[\"'&<>]/;\n\n// TODO: check performance\n// const escapeHTML = (html: string) => html.replace(/[&<>'\"]/g,\n// tag => (({\n// '&': '&amp;',\n// '<': '&lt;',\n// '>': '&gt;',\n// \"'\": '&#39;',\n// '\"': '&quot;'\n// } as any)[tag]));\n\nfunction escapeHtml(html: string): string {\n const str = \"\" + html;\n const m = escapeHtmlRegExp.exec(str);\n if (!m) {\n return str;\n }\n let esc;\n let escHtml = \"\";\n let idx = 0;\n let lastIdx = 0;\n for (idx = m.index; idx < str.length; idx++) {\n switch (str.charCodeAt(idx)) {\n case 34: // \"\n esc = \"&quot;\";\n break;\n case 38: // &\n esc = \"&amp;\";\n break;\n case 39: // '\n esc = \"&#39;\";\n break;\n case 60: // <\n esc = \"&lt;\";\n break;\n case 62: // >\n esc = \"&gt;\";\n break;\n default:\n continue;\n }\n if (lastIdx !== idx) {\n escHtml += str.substring(lastIdx, idx);\n }\n lastIdx = idx + 1;\n escHtml += esc;\n }\n return lastIdx !== idx\n ? escHtml + str.substring(lastIdx, idx)\n : escHtml;\n}\n\n// Test\n\n// const hsmls: HElements = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\",\n// {\n// attr: \"escape html attr entities: \\\" ' & < >\",\n// classes: [\"class\"]\n// },\n// [\n// \"text\",\n// \"escape html entities: \\\" ' & < >\",\n// new String(\"escape html entities: \\\" ' & < >\"),\n// 123,\n// true\n// ]\n// ]\n// ];\n\n// const hml: HElement = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"a\", { href: \"url\", onclick: \"return confirm('Confirm please')\" }, \"link\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const html = hsml2htmls(hml, true);\n// console.log(html.join(\"\"));\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/hsml.ts","webpack:///./src/hsml-svac-html.ts","webpack:///./src/hsml-html.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","hsml","hml","handler","ctx","constructor","Array","hmlTag","console","error","head","attrsObj","hasAttrs","hFnc","hObj","children","htc","Function","String","Boolean","Number","Date","refSplit","split","ref","dotSplit","hashSplit","tag","id","classes","slice","attrs","_id","length","_classes","_ref","_hObj","skip","open","fnc","forEach","jml","close","hsmlTag","text","toLocaleString","toString","ds","obj","hsmls","sep","reduce","push","splice","actionHtml","action","data","event","mountHtml","component","state","view","onHtml","pretty","hsmls2html","hsmls2htmls","join","HsmlHtmlHandler","indent","_depth","this","_onHtml","_pretty","_indent","props","attrClasses","concat","map","undefined","filter","attrData","JSON","stringify","attrStyles","style","replace","toLowerCase","unshift","type","args","escapeHtml","html","_mkIndent","_pairTags","indexOf","render","toHsml","pairTag","count","hsml2html","hsmlEl","htmls","escapeHtmlRegExp","str","exec","esc","escHtml","idx","lastIdx","index","charCodeAt","substring"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUT,QAGnC,IAAIC,EAASM,EAAiBE,GAAY,CACzCJ,EAAGI,EACHC,GAAG,EACHV,QAAS,IAUV,OANAW,EAAQF,GAAUG,KAAKX,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOS,GAAI,EAGJT,EAAOD,QA0Df,OArDAQ,EAAoBK,EAAIF,EAGxBH,EAAoBM,EAAIP,EAGxBC,EAAoBO,EAAI,SAASf,EAASgB,EAAMC,GAC3CT,EAAoBU,EAAElB,EAASgB,IAClCG,OAAOC,eAAepB,EAASgB,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhET,EAAoBe,EAAI,SAASvB,GACX,oBAAXwB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAepB,EAASwB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAepB,EAAS,aAAc,CAAE0B,OAAO,KAQvDlB,EAAoBmB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQlB,EAAoBkB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFAvB,EAAoBe,EAAEO,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9CoC,EAAUjG,EAAiB4D,EAAQC,GAxM5B,EAAA8B,UAAY,CACvB,SAAU,SACV,OAAQ,OAAQ,OAAQ,QAAS,MACjC,KAAM,KAAM,KAAM,KAAM,KAAM,KAC9B,IAAK,IAAK,MAAO,aAAc,IAAK,IAAK,KAAM,SAAU,KAAM,OAC/D,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,QAAS,KAAM,KACnD,WAAY,SAAU,UAkL9B,cAKA,eAgBA,sBAA2B5F,EAAgB8D,GAAS,GAChD,MAAMsC,EAAkB,GAExB,OADAF,EAAUlG,EAAM0F,GAAQU,EAAMjD,KAAKuC,GAAO5B,GACnCsC,GAGX,uBAA4BpD,EAAkBc,GAAS,GACnD,MAAMsC,EAAkB,GAExB,OADArC,EAAWf,EAAO0C,GAAQU,EAAMjD,KAAKuC,GAAO5B,GACrCsC,GAGX,MAAMC,EAAmB,UAYzB,SAASZ,EAAWC,GAChB,MAAMY,EAAM,GAAKZ,EACXtH,EAAIiI,EAAiBE,KAAKD,GAChC,IAAKlI,EACD,OAAOkI,EAEX,IAAIE,EACAC,EAAU,GACVC,EAAM,EACNC,EAAU,EACd,IAAKD,EAAMtI,EAAEwI,MAAOF,EAAMJ,EAAItE,OAAQ0E,IAAO,CACzC,OAAQJ,EAAIO,WAAWH,IACnB,KAAK,GACDF,EAAM,SACN,MACJ,KAAK,GACDA,EAAM,QACN,MACJ,KAAK,GACDA,EAAM,QACN,MACJ,KAAK,GACDA,EAAM,OACN,MACJ,KAAK,GACDA,EAAM,OACN,MACJ,QACI,SAEJG,IAAYD,IACZD,GAAWH,EAAIQ,UAAUH,EAASD,IAEtCC,EAAUD,EAAM,EAChBD,GAAWD,EAEf,OAAOG,IAAYD,EACbD,EAAUH,EAAIQ,UAAUH,EAASD,GACjCD","file":"hsml-svac-html.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 16);\n","\nexport type HHead = keyof HTMLElementTagNameMap | string; // \"tag#id.class1.class2~handler\"\n\nexport type HAttrClasses = Array<string | [string, boolean]>;\n\nexport type HAttrStyles = { [key: string]: string };\n\nexport type HAttrData = {\n [key: string]:\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object;\n};\n\nexport type HAttrOnAction = string;\n\nexport type HAttrOnDataFnc = (e: Event) => any;\n\nexport type HAttrOnData =\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object\n | HAttrOnDataFnc\n | null;\n\nexport type HAttrOnCb = [keyof HTMLElementEventMap, EventListener];\n\nexport type HAttrOnAct = [\n keyof HTMLElementEventMap,\n HAttrOnAction,\n HAttrOnData?\n];\n\nexport type HAttrOn = HAttrOnCb | HAttrOnAct | Array<HAttrOnCb | HAttrOnAct>;\n\nexport interface HAttrs {\n readonly _id?: string;\n readonly _classes?: string[];\n readonly _ref?: string;\n readonly _key?: string;\n readonly _skip?: boolean;\n readonly _hObj?: HObj;\n readonly classes?: HAttrClasses;\n readonly styles?: HAttrStyles;\n readonly data?: HAttrData;\n readonly on?: HAttrOn;\n readonly [key: string]:\n | string\n | String\n | string[]\n | String[]\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | HAttrClasses\n | HAttrStyles\n // | HsmlAttrData\n | HAttrOn\n | EventListener\n | HObj\n | undefined;\n}\n\nexport type HFnc = (e: Element) => boolean | void;\n\nexport interface HObj {\n toHsml?(): HElement;\n}\n\nexport interface HElements extends Array<HElement> {}\n\nexport type HChildren =\n | HElements\n | HFnc\n | HObj\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport type HTagNoAttr = [HHead, HChildren?];\nexport type HTagAttr = [HHead, HAttrs, HChildren?];\n\nexport type HTag = HTagNoAttr | HTagAttr;\n\nexport type HElement =\n | HFnc\n | HObj\n | HTag\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport interface HHandlerCtx extends HObj {\n refs: { [name: string]: Element };\n actionCb(action: HAttrOnAction, data: HAttrOnData, e: Event): void;\n}\n\nexport interface HHandler<C extends HHandlerCtx> {\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: C): boolean;\n close(tag: HHead, children: HElements, ctx?: C): void;\n text(text: string, ctx?: C): void;\n fnc(fnc: HFnc, ctx?: C): void;\n obj(obj: HObj, ctx?: C): void;\n}\n\nexport function hsml<C extends HHandlerCtx>(hml: HElement,\n handler: HHandler<C>,\n ctx?: C): void {\n // console.log(\"hsml\", hsml);\n if (hml === undefined || hml === null) {\n return;\n }\n switch (hml.constructor) {\n case Array:\n // const tag = hml as HTag;\n // if (\n // (\n // tag.length === 1 &&\n // tag[0].constructor === String\n // ) ||\n // (\n // tag.length === 2 &&\n // (\n // tag[0].constructor === String &&\n // (tag[1]!.constructor === Array || tag[1]!.constructor === Function)\n // ) ||\n // (\n // tag[0].constructor === String &&\n // tag[1]!.constructor === Object\n // )\n // ) ||\n // (\n // tag.length === 3 &&\n // tag[0].constructor === String &&\n // tag[1].constructor === Object &&\n // tag[2]!.constructor === Array\n // )\n // ) {\n // hsmlTag(hml as HTag, handler, ctx);\n // } else {\n // console.error(\"hsml parse error:\", hml);\n // // console.error(\"hsml parse error:\", JSON.stringify(hml, null, 4));\n // // throw Error(`hsml parse error: ${JSON.stringify(hml)}`);\n // }\n hsmlTag(hml as HTag, handler, ctx);\n break;\n case Function:\n handler.fnc(hml as HFnc, ctx);\n break;\n case String:\n handler.text(hml as string, ctx);\n break;\n case Boolean:\n handler.text(\"\" + hml, ctx);\n break;\n case Number:\n const n = hml as number;\n const ns = n.toLocaleString ? n.toLocaleString() : n.toString();\n handler.text(ns, ctx);\n break;\n case Date:\n const d = hml as Date;\n const ds = d.toLocaleString ? d.toLocaleString() : d.toString();\n handler.text(ds, ctx);\n break;\n default: // HObj\n handler.obj(hml as HObj, ctx);\n }\n\n function hsmlTag(hmlTag: HTag, handler: HHandler<C>, ctx?: C): void {\n // console.log(\"hsml tag\", hmlTag);\n\n if (typeof hmlTag[0] !== \"string\") {\n console.error(\"HSML tag head not string:\", hmlTag);\n return;\n }\n\n const head = hmlTag[0] as HHead;\n const attrsObj = hmlTag[1] as any;\n const hasAttrs = attrsObj && attrsObj.constructor === Object;\n const childIdx = hasAttrs ? 2 : 1;\n\n let children: HElements = [];\n let hFnc: HFnc | undefined;\n let hObj: HObj | undefined;\n\n const htc = hmlTag[childIdx];\n switch (htc && htc.constructor) {\n case Array:\n children = htc as HElements;\n break;\n case Function:\n hFnc = htc as HFnc;\n break;\n case String:\n case Boolean:\n case Number:\n case Date:\n children = [htc as string | boolean | number | Date];\n break;\n default: // HObj\n hObj = htc as HObj;\n break;\n }\n\n const refSplit = head.split(\"~\");\n const ref = refSplit[1];\n const dotSplit = refSplit[0].split(\".\");\n const hashSplit = dotSplit[0].split(\"#\");\n const tag = hashSplit[0] || \"div\";\n const id = hashSplit[1];\n const classes = dotSplit.slice(1);\n\n let attrs: HAttrs;\n if (hasAttrs) {\n attrs = attrsObj as HAttrs;\n } else {\n attrs = {} as HAttrs;\n }\n\n if (id) {\n (attrs as any)._id = id;\n }\n if (classes.length) {\n (attrs as any)._classes = classes;\n }\n if (ref) {\n (attrs as any)._ref = ref;\n }\n if (hObj) {\n (attrs as any)._hObj = hObj;\n }\n\n const skip = handler.open(tag, attrs, children, ctx);\n\n if (hFnc) {\n handler.fnc(hFnc, ctx);\n }\n\n if (!skip) {\n children.forEach(jml => hsml(jml, handler, ctx));\n }\n\n handler.close(tag, children, ctx);\n }\n}\n\nexport function hjoin(hsmls: HElements, sep: string | HElement): HElements {\n const r = hsmls.reduce<HElements>(\n (p, c) => (p.push(c, sep), p),\n [] as HElements\n );\n r.splice(-1);\n return r;\n}\n\n// Test\n\n// const hsmls: Hsmls = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\", { attr: \"attr\", classes: [\"class\"] }, [\n// \"text\",\n// 123,\n// true\n// ]]\n// ];\n\n// const hml: Hsml = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"t\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const hml1: Hsml = [\"div\", null, [\n// [\"span\", null, [\n// [\"a\",\n// {\n// href: \"https://gitlab.com/peter-rybar/diasheet\",\n// title: \"GitLab\",\n// target: \"_blank\"\n// },\n// [[\"i.fa.fa-gitlab\"]]\n// ]\n// ]],\n// [\"span\"]\n// ]];\n// console.log(hml1);\n\n// const hml2: Hsml = [\"div\", [\n// [\"h2\", [\"title\"]],\n// [\"div.w3-card-12\", [\n// [\"header.w3-container w3-light-grey\", [\n// [\"h3\", [\"Account: \", \"User\"]]\n// ]],\n// [\"div.w3-container.w3-light-grey\", [\n// [\"p\", [\"Balance: 4 DCT\"]],\n// [\"br\"]\n// ]],\n// [\"h4\", [\"Your account spending\"]],\n// [\"div#piechart\"],\n// [\"h4\", [\"Your account balance\"]],\n// [\"div#linechart\"],\n// [\"button.w3-button.w3-block.w3-dark-grey\", [\"Refresh\"]]\n// ]],\n// [\"br\"]\n// ]];\n// console.log(hml2);\n\n// TEST\n\n// import { hsmls2htmls } from \"./hsml-html\";\n// import { HDispatch } from \"./hsml-app\";\n\n// const dispatch: HDispatch = (type: string, data?: any, event?: Event): void => {\n// console.log(\"action:\", type, data, event);\n// };\n\n// const data = { attr: \"action-data\" };\n\n// const hmls: HElements = [\n// [\"button\", { on: [\"click\", \"action\", data] }, \"send\"],\n// [\"h1\", \"aaa\"],\n// [\"input\",\n// {\n// type: \"text\",\n// on: [\n// [\"mouseover\", \"hover-action\", data],\n// [\"change\", \"click-action\", e => (e.target as HTMLInputElement).value],\n// [\"click\", e => dispatch(\"action\", data, e)],\n// ],\n// click: e => dispatch(\"action\", data, e)\n// }\n// ],\n// [\"button\",\n// {\n// on: [\"click\", e => dispatch(\"action\", data, e)],\n// click: e => dispatch(\"action\", data, e)\n// },\n// [\"Send\"]\n// ]\n// ];\n\n// console.log(hsmls2htmls(hmls, true).join(\"\"));\n","import { HElements, HFnc } from \"./hsml\";\nimport { hsmls2htmls, hsmls2html } from \"./hsml-html\";\nimport { HAction, HMount, HComponent } from \"./hsml-svac\";\n\nconst actionHtml: HAction = (action: string | number, data: any, event?: Event) => { };\n\nconst mountHtml: HMount = <STATE>(component: HComponent<STATE>,\n state?: STATE): HFnc | HElements => {\n return component.view(state || component.state, actionHtml, mountHtml);\n};\n\nexport function html<STATE>(component: HComponent<STATE>,\n state: STATE,\n onHtml: (html: string) => void,\n pretty = false): void {\n hsmls2html(component.view(state, actionHtml, mountHtml), onHtml, pretty);\n}\n\nexport function htmls<STATE>(component: HComponent<STATE>,\n state: STATE,\n pretty = false): string {\n return hsmls2htmls(component.view(state, actionHtml, mountHtml), pretty).join(\"\");\n}\n","import {\n hsml,\n HElement,\n HElements,\n HHead,\n HAttrs,\n HAttrClasses,\n HAttrData,\n HAttrStyles,\n HFnc,\n HObj,\n HHandler,\n HHandlerCtx\n} from \"./hsml\";\n\nclass HsmlHtmlHandler implements HHandler<HHandlerCtx> {\n\n private static _pairTags = [\n \"script\", \"iframe\",\n \"html\", \"head\", \"body\", \"title\", \"div\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\",\n \"p\", \"a\", \"pre\", \"blockquote\", \"i\", \"b\", \"em\", \"strong\", \"tt\", \"cite\",\n \"ol\", \"ul\", \"li\", \"dl\", \"dt\", \"dd\", \"table\", \"tr\", \"td\",\n \"textarea\", \"select\", \"option\"];\n\n private _onHtml: (html: string) => void;\n private _pretty: boolean;\n private _indent: string;\n private _depth: number = 0;\n\n constructor(onHtml: (html: string) => void,\n pretty: boolean = false,\n indent: string = \" \") {\n this._onHtml = onHtml;\n this._pretty = pretty;\n this._indent = indent;\n }\n\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: HHandlerCtx): boolean {\n const props: any[] = [];\n let id = attrs._id;\n let classes: string[] = attrs._classes ? attrs._classes : [];\n let hObj: any = attrs._hObj;\n for (const a in attrs) {\n if (attrs.hasOwnProperty(a)) {\n switch (a) {\n case \"_id\":\n case \"_classes\":\n case \"_ref\":\n case \"_key\":\n case \"_skip\":\n case \"_hObj\":\n break;\n case \"id\":\n id = attrs[a] as string;\n break;\n case \"classes\":\n const attrClasses = attrs[a] as HAttrClasses;\n classes = classes.concat(attrClasses\n ? attrClasses\n .map(c =>\n c.constructor === String\n ? c as string\n : (c[1] ? c[0] as string : undefined))\n .filter((c): c is string => c !== undefined)\n : [] as string[]);\n break;\n case \"class\":\n classes = classes.concat((attrs[a] as string).split(\" \"));\n break;\n case \"data\":\n const attrData = attrs[a] as HAttrData;\n for (const d in attrData) {\n if (attrData.hasOwnProperty(d)) {\n if (attrData[d].constructor === String) {\n props.push([\"data-\" + d, attrData[d]]);\n } else {\n props.push([\"data-\" + d, JSON.stringify(attrData[d])]);\n }\n }\n }\n break;\n case \"styles\":\n const attrStyles = attrs[a] as HAttrStyles;\n let style = \"\";\n for (const d in attrStyles) {\n if (attrStyles.hasOwnProperty(d)) {\n const dd = d.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n style += dd + \":\" + attrStyles[d] + \";\";\n }\n }\n props.push([\"style\", style]);\n break;\n case \"styles\":\n break;\n case \"on\":\n break;\n default:\n if (typeof attrs[a] === \"function\") {\n // ignore\n } else if (typeof attrs[a] === \"boolean\") {\n attrs[a] && props.push([a, \"\"]);\n } else {\n props.push([a, attrs[a]]);\n }\n }\n }\n }\n if (classes.length) {\n props.unshift([\"class\", classes.join(\" \")]);\n }\n if (id) {\n props.unshift([\"id\", id]);\n }\n if (hObj && \"type\" in hObj) {\n props.unshift([\"hObj\", hObj.type]);\n }\n const args = props.map(p => `${p[0]}=\"${escapeHtml(p[1])}\"`).join(\" \");\n let html = \"\";\n if (this._pretty) {\n html += this._mkIndent(this._depth);\n this._depth++;\n }\n const pairTag = (children.length || HsmlHtmlHandler._pairTags.indexOf(tag) !== -1);\n html += \"<\" + tag + (args ? \" \" + args : \"\") + (pairTag ? \">\" : \"/>\");\n if (this._pretty) {\n html += \"\\n\";\n }\n this._onHtml(html);\n if (hObj && \"render\" in hObj && hObj.render.constructor === Function) {\n const hsmls = hObj.render() as HElements;\n for (const hml of hsmls) {\n if (hml === undefined || hml === null) {\n continue;\n }\n if (hml.constructor === String) {\n this._onHtml(hml + (this._pretty ? \"\\n\" : \"\"));\n } else if (\"toHsml\" in (hml as any)) {\n const obj = hml as HObj;\n obj.toHsml && hsml(obj.toHsml(), this);\n } else {\n hsml(hml as HElement, this);\n }\n }\n }\n return false;\n }\n\n close(tag: HHead, children: HElements, ctx?: HHandlerCtx): void {\n let html = \"\";\n const pairTag = (children.length || HsmlHtmlHandler._pairTags.indexOf(tag) !== -1);\n if (this._pretty) {\n this._depth--;\n if (pairTag) {\n html += this._mkIndent(this._depth);\n }\n }\n if (pairTag) {\n html += \"</\" + tag + \">\";\n if (this._pretty) {\n html += \"\\n\";\n }\n this._onHtml(html);\n }\n }\n\n text(text: string, ctx?: HHandlerCtx): void {\n let html = \"\";\n if (this._pretty) {\n html += this._mkIndent(this._depth);\n }\n html += (text as any) instanceof String\n ? text\n : escapeHtml(text);\n if (this._pretty) {\n html += \"\\n\";\n }\n this._onHtml(html);\n }\n\n fnc(fnc: HFnc, ctx?: HHandlerCtx): void {\n }\n\n obj(obj: HObj, ctx?: HHandlerCtx): void {\n if (\"toHsml\" in obj) {\n obj.toHsml && hsml(obj.toHsml(), this, obj as HHandlerCtx);\n } else {\n this.text(\"\" + obj, ctx);\n }\n }\n\n private _mkIndent(count: number): string {\n let indent = \"\";\n for (let i = 0; i < count; i++) {\n indent += this._indent;\n }\n return indent;\n }\n\n}\n\nexport function hsml2html(hsmlEl: HElement, onHtml: (html: string) => void, pretty = false): void {\n const handler = new HsmlHtmlHandler(onHtml, pretty);\n hsml(hsmlEl, handler);\n}\n\nexport function hsmls2html(hsmls: HElements, onHtml: (html: string) => void, pretty = false): void {\n for (const hml of hsmls) {\n if (hml === undefined || hml === null) {\n continue;\n }\n if (hml.constructor === String) {\n onHtml(hml + (pretty ? \"\\n\" : \"\"));\n } else if (\"toHsml\" in (hml as any)) {\n const obj = hml as HObj;\n obj.toHsml && hsml2html(obj.toHsml(), onHtml, pretty);\n } else {\n hsml2html(hml as HElement, onHtml, pretty);\n }\n }\n}\n\nexport function hsml2htmls(hsml: HElement, pretty = false): string[] {\n const htmls: string[] = [];\n hsml2html(hsml, html => htmls.push(html), pretty);\n return htmls;\n}\n\nexport function hsmls2htmls(hsmls: HElements, pretty = false): string[] {\n const htmls: string[] = [];\n hsmls2html(hsmls, html => htmls.push(html), pretty);\n return htmls;\n}\n\nconst escapeHtmlRegExp = /[\"'&<>]/;\n\n// TODO: check performance\n// const escapeHTML = (html: string) => html.replace(/[&<>'\"]/g,\n// tag => (({\n// '&': '&amp;',\n// '<': '&lt;',\n// '>': '&gt;',\n// \"'\": '&#39;',\n// '\"': '&quot;'\n// } as any)[tag]));\n\nfunction escapeHtml(html: string): string {\n const str = \"\" + html;\n const m = escapeHtmlRegExp.exec(str);\n if (!m) {\n return str;\n }\n let esc;\n let escHtml = \"\";\n let idx = 0;\n let lastIdx = 0;\n for (idx = m.index; idx < str.length; idx++) {\n switch (str.charCodeAt(idx)) {\n case 34: // \"\n esc = \"&quot;\";\n break;\n case 38: // &\n esc = \"&amp;\";\n break;\n case 39: // '\n esc = \"&#39;\";\n break;\n case 60: // <\n esc = \"&lt;\";\n break;\n case 62: // >\n esc = \"&gt;\";\n break;\n default:\n continue;\n }\n if (lastIdx !== idx) {\n escHtml += str.substring(lastIdx, idx);\n }\n lastIdx = idx + 1;\n escHtml += esc;\n }\n return lastIdx !== idx\n ? escHtml + str.substring(lastIdx, idx)\n : escHtml;\n}\n\n// Test\n\n// const hsmls: HElements = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\",\n// {\n// attr: \"escape html attr entities: \\\" ' & < >\",\n// classes: [\"class\"]\n// },\n// [\n// \"text\",\n// \"escape html entities: \\\" ' & < >\",\n// new String(\"escape html entities: \\\" ' & < >\"),\n// 123,\n// true\n// ]\n// ]\n// ];\n\n// const hml: HElement = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"a\", { href: \"url\", onclick: \"return confirm('Confirm please')\" }, \"link\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const html = hsml2htmls(hml, true);\n// console.log(html.join(\"\"));\n"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("IncrementalDOM"));else if("function"==typeof define&&define.amd)define(["IncrementalDOM"],e);else{var o="object"==typeof exports?e(require("IncrementalDOM")):e(t.IncrementalDOM);for(var n in o)("object"==typeof exports?exports:t)[n]=o[n]}}(window,(function(t){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=18)}({0:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hsml=function t(e,o,n){if(null!=e)switch(e.constructor){case Array:!function(e,o,n){if("string"!=typeof e[0])return void console.error("HSML tag head not string:",e);const i=e[0],s=e[1],c=s&&s.constructor===Object;let r,u,a=[];const d=e[c?2:1];switch(d&&d.constructor){case Array:a=d;break;case Function:r=d;break;case String:case Boolean:case Number:case Date:a=[d];break;default:u=d}const l=i.split("~"),h=l[1],f=l[0].split("."),m=f[0].split("#"),p=m[0]||"div",b=m[1],y=f.slice(1);let g;g=c?s:{};b&&(g._id=b);y.length&&(g._classes=y);h&&(g._ref=h);u&&(g._hObj=u);const _=o.open(p,g,a,n);r&&o.fnc(r,n);_||a.forEach(e=>t(e,o,n));o.close(p,a,n)}(e,o,n);break;case Function:o.fnc(e,n);break;case String:o.text(e,n);break;case Boolean:o.text(""+e,n);break;case Number:const i=e,s=i.toLocaleString?i.toLocaleString():i.toString();o.text(s,n);break;case Date:const c=e,r=c.toLocaleString?c.toLocaleString():c.toString();o.text(r,n);break;default:o.obj(e,n)}},e.hjoin=function(t,e){const o=t.reduce((t,o)=>(t.push(o,e),t),[]);return o.splice(-1),o}},1:function(e,o){e.exports=t},18:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(2),i=o(1),s=window.requestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},c=window.cancelAnimationFrame||function(t){window.clearTimeout(t)};class r{constructor(t){this.type=this.constructor.name,this.id=this.type+"-"+r._count++,this.refs={},this.toHtml=()=>this.dom?this.dom.outerHTML:"",t&&(this.type=t)}onMount(){console.log("mount")}onUmount(){console.log("umount")}actions(t,e){console.log(t,e)}action(t,e){this.actions(t,e)}actionCb(t,e,o){e=e&&e.constructor===Function?e(o):void 0===e?o:e,this.action(t,e)}mount(t){const e="string"==typeof t?document.getElementById(t)||document.body:t||document.body;if("widget"in e){const t=e.widget;t&&t.umount()}if(!this.dom){r.mounted[this.id]=this,this.dom=e,e.widget=this;const t=this.render();n.hsmls2idomPatch(e,t,this),e.setAttribute("widget",this.type),this.onMount&&this.onMount()}return this}umount(){if(this.dom){delete r.mounted[this.id],this.onUmount&&this.onUmount(),this.dom.hasAttribute("widget")&&this.dom.removeAttribute("widget");const t=this.dom.querySelectorAll("[widget]");for(let e=0;e<t.length;e++){const o=t[e].widget;o&&o.umount()}for(;this.dom.firstChild;)this.dom.removeChild(this.dom.firstChild);delete this.dom.widget,this.dom=void 0}return this}update(){return this.dom&&!this._updateSched&&(this._updateSched=s(()=>{this.dom&&n.hsmls2idomPatch(this.dom,this.render(),this),this._updateSched=void 0})),this}toHsml(){if(this.dom){if(!this._updateSched)return["div",{_skip:!0,_id:this.id,_key:this.id,widget:this.type}];c(this._updateSched),this._updateSched=void 0}const t=this.render();return t.push(t=>{this.dom||(this.dom=t,t.widget=this,this.onMount&&this.onMount())}),["div",{_id:this.id,_key:this.id,widget:this.type},t]}}e.HWidget=r,r._count=0,r.mounted={},i.notifications.nodesDeleted=t=>{t.forEach(t=>{if(1===t.nodeType&&"widget"in t){const e=t.widget;e&&e.umount()}})}},2:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(0),i=o(1);class s{open(t,e,o,n){const s=[];let c=e._id,r=e._classes?e._classes:[],u=e._ref,a=e._hObj;for(const t in e)if(e.hasOwnProperty(t))switch(t){case"_id":case"_classes":case"_ref":case"_key":case"_skip":case"_hObj":break;case"id":c=e[t];break;case"classes":const o=e[t];r=r.concat(o?o.map(t=>t.constructor===String?t:t[1]?t[0]:void 0).filter(t=>void 0!==t):[]);break;case"class":r=r.concat(e[t].split(" "));break;case"data":const i=e[t];for(const t in i)i.hasOwnProperty(t)&&(i[t].constructor===String?s.push("data-"+t,i[t]):s.push("data-"+t,JSON.stringify(i[t])));break;case"styles":s.push("style",e[t]);break;case"on":const u=e[t];"string"==typeof u[0]?"function"==typeof u[1]?s.push("on"+u[0],u[1]):s.push("on"+u[0],t=>{n&&n.actionCb&&"function"==typeof n.actionCb&&n.actionCb(u[1],u[2],t)}):u.forEach(t=>{"function"==typeof t[1]?s.push("on"+t[0],t[1]):s.push("on"+t[0],e=>{n&&n.actionCb&&"function"==typeof n.actionCb&&n.actionCb(t[1],t[2],e)})});break;default:switch(typeof e[t]){case"function":s.push("on"+t,e[t]);break;case"object":s.push(t,e[t]);break;case"boolean":e[t]&&s.push(t,"");break;default:s.push(t,e[t])}}return r.length&&s.unshift("class",r.join(" ")),c&&s.unshift("id",c),i.elementOpen(t,e._key,void 0,...s),e._skip&&i.skip(),n&&u&&(n.refs[u]=i.currentElement()),a&&a.mount&&a.mount.constructor===Function&&(a.mount(i.currentElement()),i.skip()),!!e._skip}close(t,e,o){i.elementClose(t)}text(t,e){i.text(t)}fnc(t,e){t(i.currentElement())&&i.skip()}obj(t,e){"toHsml"in t?t.toHsml&&n.hsml(t.toHsml(),this,t):this.text(""+t,e)}}function c(t,e){n.hsml(t,new s,e)}e.hsml2idomPatch=function(t,e,o){i.patch(t,t=>t&&c(t,o),e)},e.hsmls2idomPatch=function(t,e,o){i.patch(t,t=>t&&function(t,e){for(const o of t)if(null!=o)if(o.constructor===String)i.text(o);else if("toHsml"in o){const t=o;t.toHsml&&c(t.toHsml(),t)}else c(o,e)}(t,o),e)}}})}));
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("IncrementalDOM"));else if("function"==typeof define&&define.amd)define(["IncrementalDOM"],e);else{var o="object"==typeof exports?e(require("IncrementalDOM")):e(t.IncrementalDOM);for(var n in o)("object"==typeof exports?exports:t)[n]=o[n]}}(window,(function(t){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=18)}({0:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hjoin=e.hsml=void 0,e.hsml=function t(e,o,n){if(null!=e)switch(e.constructor){case Array:!function(e,o,n){if("string"!=typeof e[0])return void console.error("HSML tag head not string:",e);const i=e[0],s=e[1],c=s&&s.constructor===Object;let r,u,a=[];const d=e[c?2:1];switch(d&&d.constructor){case Array:a=d;break;case Function:r=d;break;case String:case Boolean:case Number:case Date:a=[d];break;default:u=d}const l=i.split("~"),h=l[1],f=l[0].split("."),m=f[0].split("#"),p=m[0]||"div",b=m[1],y=f.slice(1);let g;g=c?s:{};b&&(g._id=b);y.length&&(g._classes=y);h&&(g._ref=h);u&&(g._hObj=u);const _=o.open(p,g,a,n);r&&o.fnc(r,n);_||a.forEach(e=>t(e,o,n));o.close(p,a,n)}(e,o,n);break;case Function:o.fnc(e,n);break;case String:o.text(e,n);break;case Boolean:o.text(""+e,n);break;case Number:const i=e,s=i.toLocaleString?i.toLocaleString():i.toString();o.text(s,n);break;case Date:const c=e,r=c.toLocaleString?c.toLocaleString():c.toString();o.text(r,n);break;default:o.obj(e,n)}},e.hjoin=function(t,e){const o=t.reduce((t,o)=>(t.push(o,e),t),[]);return o.splice(-1),o}},1:function(e,o){e.exports=t},18:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HWidget=void 0;const n=o(2),i=o(1),s=window.requestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},c=window.cancelAnimationFrame||function(t){window.clearTimeout(t)};class r{constructor(t){this.type=this.constructor.name,this.id=this.type+"-"+r._count++,this.refs={},this.toHtml=()=>this.dom?this.dom.outerHTML:"",t&&(this.type=t)}onMount(){console.log("mount")}onUmount(){console.log("umount")}actions(t,e){console.log(t,e)}action(t,e){this.actions(t,e)}actionCb(t,e,o){e=e&&e.constructor===Function?e(o):void 0===e?o:e,this.action(t,e)}mount(t){const e="string"==typeof t?document.getElementById(t)||document.body:t||document.body;if("widget"in e){const t=e.widget;t&&t.umount()}if(!this.dom){r.mounted[this.id]=this,this.dom=e,e.widget=this;const t=this.render();n.hsmls2idomPatch(e,t,this),e.setAttribute("widget",this.type),this.onMount&&this.onMount()}return this}umount(){if(this.dom){delete r.mounted[this.id],this.onUmount&&this.onUmount(),this.dom.hasAttribute("widget")&&this.dom.removeAttribute("widget");const t=this.dom.querySelectorAll("[widget]");for(let e=0;e<t.length;e++){const o=t[e].widget;o&&o.umount()}for(;this.dom.firstChild;)this.dom.removeChild(this.dom.firstChild);delete this.dom.widget,this.dom=void 0}return this}update(){return this.dom&&!this._updateSched&&(this._updateSched=s(()=>{this.dom&&n.hsmls2idomPatch(this.dom,this.render(),this),this._updateSched=void 0})),this}toHsml(){if(this.dom){if(!this._updateSched)return["div",{_skip:!0,_id:this.id,_key:this.id,widget:this.type}];c(this._updateSched),this._updateSched=void 0}const t=this.render();return t.push(t=>{this.dom||(this.dom=t,t.widget=this,this.onMount&&this.onMount())}),["div",{_id:this.id,_key:this.id,widget:this.type},t]}}e.HWidget=r,r._count=0,r.mounted={},i.notifications.nodesDeleted=t=>{t.forEach(t=>{if(1===t.nodeType&&"widget"in t){const e=t.widget;e&&e.umount()}})}},2:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hsmls2idomPatch=e.hsml2idomPatch=void 0;const n=o(0),i=o(1);class s{open(t,e,o,n){const s=[];let c=e._id,r=e._classes?e._classes:[],u=e._ref,a=e._hObj;for(const t in e)if(e.hasOwnProperty(t))switch(t){case"_id":case"_classes":case"_ref":case"_key":case"_skip":case"_hObj":break;case"id":c=e[t];break;case"classes":const o=e[t];r=r.concat(o?o.map(t=>t.constructor===String?t:t[1]?t[0]:void 0).filter(t=>void 0!==t):[]);break;case"class":r=r.concat(e[t].split(" "));break;case"data":const i=e[t];for(const t in i)i.hasOwnProperty(t)&&(i[t].constructor===String?s.push("data-"+t,i[t]):s.push("data-"+t,JSON.stringify(i[t])));break;case"styles":s.push("style",e[t]);break;case"on":const u=e[t];"string"==typeof u[0]?"function"==typeof u[1]?s.push("on"+u[0],u[1]):s.push("on"+u[0],t=>{n&&n.actionCb&&"function"==typeof n.actionCb&&n.actionCb(u[1],u[2],t)}):u.forEach(t=>{"function"==typeof t[1]?s.push("on"+t[0],t[1]):s.push("on"+t[0],e=>{n&&n.actionCb&&"function"==typeof n.actionCb&&n.actionCb(t[1],t[2],e)})});break;default:switch(typeof e[t]){case"function":s.push("on"+t,e[t]);break;case"object":s.push(t,e[t]);break;case"boolean":e[t]&&s.push(t,t);break;default:s.push(t,e[t])}}return r.length&&s.unshift("class",r.join(" ")),c&&s.unshift("id",c),i.elementOpen(t,e._key,void 0,...s),e._skip&&i.skip(),n&&u&&(n.refs[u]=i.currentElement()),a&&a.mount&&a.mount.constructor===Function&&(a.mount(i.currentElement()),i.skip()),!!e._skip}close(t,e,o){i.elementClose(t)}text(t,e){i.text(t)}fnc(t,e){t(i.currentElement())&&i.skip()}obj(t,e){"toHsml"in t?t.toHsml&&n.hsml(t.toHsml(),this,t):this.text(""+t,e)}}function c(t,e){n.hsml(t,new s,e)}e.hsml2idomPatch=function(t,e,o){i.patch(t,t=>t&&c(t,o),e)},e.hsmls2idomPatch=function(t,e,o){i.patch(t,t=>t&&function(t,e){for(const o of t)if(null!=o)if(o.constructor===String)i.text(o);else if("toHsml"in o){const t=o;t.toHsml&&c(t.toHsml(),t)}else c(o,e)}(t,o),e)}}})}));
2
2
  //# sourceMappingURL=hsml-widget.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/hsml.ts","webpack:///external \"IncrementalDOM\"","webpack:///./src/hsml-widget.ts","webpack:///./src/hsml-idom.ts"],"names":["root","factory","exports","module","require","define","amd","a","i","window","__WEBPACK_EXTERNAL_MODULE__1__","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","hsml","hml","handler","ctx","constructor","Array","hmlTag","console","error","head","attrsObj","hasAttrs","hFnc","hObj","children","htc","Function","String","Boolean","Number","Date","refSplit","split","ref","dotSplit","hashSplit","tag","id","classes","slice","attrs","_id","length","_classes","_ref","_hObj","skip","open","fnc","forEach","jml","close","hsmlTag","text","toLocaleString","toString","ds","obj","hsmls","sep","reduce","push","splice","schedule","requestAnimationFrame","callback","setTimeout","unschedule","cancelAnimationFrame","handle","clearTimeout","HWidget","type","this","_count","refs","toHtml","dom","outerHTML","log","action","data","actions","e","undefined","el","document","getElementById","body","w","widget","umount","mounted","render","hsmls2idomPatch","setAttribute","onMount","onUmount","hasAttribute","removeAttribute","wNodes","querySelectorAll","firstChild","removeChild","_updateSched","_skip","_key","idom","notifications","nodesDeleted","nodes","node","nodeType","HsmlIDomHandler","props","attrClasses","concat","map","filter","attrData","JSON","stringify","attrOn","actionCb","attr","unshift","join","elementOpen","currentElement","mount","elementClose","toHsml","hsml2idom","hsmlEl","patch","hsmlFr","hmls","hsmls2idom"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,wBAC7B,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,kBAAmBJ,OACvB,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,mBAAqBH,EAAQD,EAAqB,gBACxG,IAAI,IAAIQ,KAAKD,GAAuB,iBAAZL,QAAuBA,QAAUF,GAAMQ,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,SAASC,GACpB,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUX,QAGnC,IAAIC,EAASQ,EAAiBE,GAAY,CACzCL,EAAGK,EACHC,GAAG,EACHZ,QAAS,IAUV,OANAa,EAAQF,GAAUG,KAAKb,EAAOD,QAASC,EAAQA,EAAOD,QAASU,GAG/DT,EAAOW,GAAI,EAGJX,EAAOD,QA0Df,OArDAU,EAAoBK,EAAIF,EAGxBH,EAAoBM,EAAIP,EAGxBC,EAAoBO,EAAI,SAASjB,EAASkB,EAAMC,GAC3CT,EAAoBU,EAAEpB,EAASkB,IAClCG,OAAOC,eAAetB,EAASkB,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhET,EAAoBe,EAAI,SAASzB,GACX,oBAAX0B,QAA0BA,OAAOC,aAC1CN,OA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EAAK7D,OAGjB,IAAIW,EAAW5C,GACP,WAAY4C,EACZA,EAAI0E,QAAU,EAAAzH,KAAK+C,EAAI0E,SAAU1D,KAAMhB,GAEvCgB,KAAKpB,KAAK,GAAKI,EAAK5C,IAMhC,SAASuH,EAAUzH,EAAeE,GAC9B,EAAAH,KAAKC,EAAK,IAAIsG,EAAmBpG,GAmBrC,0BAA+BkG,EAAesB,EAAkBxH,GAC5D8F,EAAK2B,MAAMvB,EACN9B,GAAqBA,GAAQmD,EAAUnD,EAAMpE,GAAOwH,IAG7D,2BAAgCtB,EAAewB,EAAmB1H,GAC9D8F,EAAK2B,MAAMvB,EACN9B,GAAsBA,GAvB/B,SAAoBuD,EAAiB3H,GACjC,IAAK,MAAMF,KAAO6H,EACd,GAAI7H,QAGJ,GAAIA,EAAIG,cAAgBa,OACpBgF,EAAKtD,KAAK1C,QACP,GAAI,WAAaA,EAAa,CACjC,MAAM8C,EAAM9C,EACZ8C,EAAI0E,QAAUC,EAAU3E,EAAI0E,SAAU1E,QAEtC2E,EAAUzH,EAAiBE,GAYA4H,CAAWxD,EAAMpE,GAAO0H","file":"hsml-widget.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"IncrementalDOM\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"IncrementalDOM\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"IncrementalDOM\")) : factory(root[\"IncrementalDOM\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function(__WEBPACK_EXTERNAL_MODULE__1__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 18);\n","\nexport type HHead = keyof HTMLElementTagNameMap | string; // \"tag#id.class1.class2~handler\"\n\nexport type HAttrClasses = Array<string | [string, boolean]>;\n\nexport type HAttrStyles = { [key: string]: string };\n\nexport type HAttrData = {\n [key: string]:\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object;\n};\n\nexport type HAttrOnAction = string;\n\nexport type HAttrOnDataFnc = (e: Event) => any;\n\nexport type HAttrOnData =\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object\n | HAttrOnDataFnc\n | null;\n\nexport type HAttrOnCb = [keyof HTMLElementEventMap, EventListener];\n\nexport type HAttrOnAct = [\n keyof HTMLElementEventMap,\n HAttrOnAction,\n HAttrOnData?\n];\n\nexport type HAttrOn = HAttrOnCb | HAttrOnAct | Array<HAttrOnCb | HAttrOnAct>;\n\nexport interface HAttrs {\n readonly _id?: string;\n readonly _classes?: string[];\n readonly _ref?: string;\n readonly _key?: string;\n readonly _skip?: boolean;\n readonly _hObj?: HObj;\n readonly classes?: HAttrClasses;\n readonly styles?: HAttrStyles;\n readonly data?: HAttrData;\n readonly on?: HAttrOn;\n readonly [key: string]:\n | string\n | String\n | string[]\n | String[]\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | HAttrClasses\n | HAttrStyles\n // | HsmlAttrData\n | HAttrOn\n | EventListener\n | HObj\n | undefined;\n}\n\nexport type HFnc = (e: Element) => boolean | void;\n\nexport interface HObj {\n toHsml?(): HElement;\n}\n\nexport interface HElements extends Array<HElement> {}\n\nexport type HChildren =\n | HElements\n | HFnc\n | HObj\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport type HTagNoAttr = [HHead, HChildren?];\nexport type HTagAttr = [HHead, HAttrs, HChildren?];\n\nexport type HTag = HTagNoAttr | HTagAttr;\n\nexport type HElement =\n | HFnc\n | HObj\n | HTag\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport interface HHandlerCtx extends HObj {\n refs: { [name: string]: Element };\n actionCb(action: HAttrOnAction, data: HAttrOnData, e: Event): void;\n}\n\nexport interface HHandler<C extends HHandlerCtx> {\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: C): boolean;\n close(tag: HHead, children: HElements, ctx?: C): void;\n text(text: string, ctx?: C): void;\n fnc(fnc: HFnc, ctx?: C): void;\n obj(obj: HObj, ctx?: C): void;\n}\n\nexport function hsml<C extends HHandlerCtx>(hml: HElement,\n handler: HHandler<C>,\n ctx?: C): void {\n // console.log(\"hsml\", hsml);\n if (hml === undefined || hml === null) {\n return;\n }\n switch (hml.constructor) {\n case Array:\n // const tag = hml as HTag;\n // if (\n // (\n // tag.length === 1 &&\n // tag[0].constructor === String\n // ) ||\n // (\n // tag.length === 2 &&\n // (\n // tag[0].constructor === String &&\n // (tag[1]!.constructor === Array || tag[1]!.constructor === Function)\n // ) ||\n // (\n // tag[0].constructor === String &&\n // tag[1]!.constructor === Object\n // )\n // ) ||\n // (\n // tag.length === 3 &&\n // tag[0].constructor === String &&\n // tag[1].constructor === Object &&\n // tag[2]!.constructor === Array\n // )\n // ) {\n // hsmlTag(hml as HTag, handler, ctx);\n // } else {\n // console.error(\"hsml parse error:\", hml);\n // // console.error(\"hsml parse error:\", JSON.stringify(hml, null, 4));\n // // throw Error(`hsml parse error: ${JSON.stringify(hml)}`);\n // }\n hsmlTag(hml as HTag, handler, ctx);\n break;\n case Function:\n handler.fnc(hml as HFnc, ctx);\n break;\n case String:\n handler.text(hml as string, ctx);\n break;\n case Boolean:\n handler.text(\"\" + hml, ctx);\n break;\n case Number:\n const n = hml as number;\n const ns = n.toLocaleString ? n.toLocaleString() : n.toString();\n handler.text(ns, ctx);\n break;\n case Date:\n const d = hml as Date;\n const ds = d.toLocaleString ? d.toLocaleString() : d.toString();\n handler.text(ds, ctx);\n break;\n default: // HObj\n handler.obj(hml as HObj, ctx);\n }\n\n function hsmlTag(hmlTag: HTag, handler: HHandler<C>, ctx?: C): void {\n // console.log(\"hsml tag\", hmlTag);\n\n if (typeof hmlTag[0] !== \"string\") {\n console.error(\"HSML tag head not string:\", hmlTag);\n return;\n }\n\n const head = hmlTag[0] as HHead;\n const attrsObj = hmlTag[1] as any;\n const hasAttrs = attrsObj && attrsObj.constructor === Object;\n const childIdx = hasAttrs ? 2 : 1;\n\n let children: HElements = [];\n let hFnc: HFnc | undefined;\n let hObj: HObj | undefined;\n\n const htc = hmlTag[childIdx];\n switch (htc && htc.constructor) {\n case Array:\n children = htc as HElements;\n break;\n case Function:\n hFnc = htc as HFnc;\n break;\n case String:\n case Boolean:\n case Number:\n case Date:\n children = [htc as string | boolean | number | Date];\n break;\n default: // HObj\n hObj = htc as HObj;\n break;\n }\n\n const refSplit = head.split(\"~\");\n const ref = refSplit[1];\n const dotSplit = refSplit[0].split(\".\");\n const hashSplit = dotSplit[0].split(\"#\");\n const tag = hashSplit[0] || \"div\";\n const id = hashSplit[1];\n const classes = dotSplit.slice(1);\n\n let attrs: HAttrs;\n if (hasAttrs) {\n attrs = attrsObj as HAttrs;\n } else {\n attrs = {} as HAttrs;\n }\n\n if (id) {\n (attrs as any)._id = id;\n }\n if (classes.length) {\n (attrs as any)._classes = classes;\n }\n if (ref) {\n (attrs as any)._ref = ref;\n }\n if (hObj) {\n (attrs as any)._hObj = hObj;\n }\n\n const skip = handler.open(tag, attrs, children, ctx);\n\n if (hFnc) {\n handler.fnc(hFnc, ctx);\n }\n\n if (!skip) {\n children.forEach(jml => hsml(jml, handler, ctx));\n }\n\n handler.close(tag, children, ctx);\n }\n}\n\nexport function hjoin(hsmls: HElements, sep: string | HElement): HElements {\n const r = hsmls.reduce<HElements>(\n (p, c) => (p.push(c, sep), p),\n [] as HElements\n );\n r.splice(-1);\n return r;\n}\n\n// Test\n\n// const hsmls: Hsmls = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\", { attr: \"attr\", classes: [\"class\"] }, [\n// \"text\",\n// 123,\n// true\n// ]]\n// ];\n\n// const hml: Hsml = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"t\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const hml1: Hsml = [\"div\", null, [\n// [\"span\", null, [\n// [\"a\",\n// {\n// href: \"https://gitlab.com/peter-rybar/diasheet\",\n// title: \"GitLab\",\n// target: \"_blank\"\n// },\n// [[\"i.fa.fa-gitlab\"]]\n// ]\n// ]],\n// [\"span\"]\n// ]];\n// console.log(hml1);\n\n// const hml2: Hsml = [\"div\", [\n// [\"h2\", [\"title\"]],\n// [\"div.w3-card-12\", [\n// [\"header.w3-container w3-light-grey\", [\n// [\"h3\", [\"Account: \", \"User\"]]\n// ]],\n// [\"div.w3-container.w3-light-grey\", [\n// [\"p\", [\"Balance: 4 DCT\"]],\n// [\"br\"]\n// ]],\n// [\"h4\", [\"Your account spending\"]],\n// [\"div#piechart\"],\n// [\"h4\", [\"Your account balance\"]],\n// [\"div#linechart\"],\n// [\"button.w3-button.w3-block.w3-dark-grey\", [\"Refresh\"]]\n// ]],\n// [\"br\"]\n// ]];\n// console.log(hml2);\n\n// TEST\n\n// import { hsmls2htmls } from \"./hsml-html\";\n// import { HDispatch } from \"./hsml-app\";\n\n// const dispatch: HDispatch = (type: string, data?: any, event?: Event): void => {\n// console.log(\"action:\", type, data, event);\n// };\n\n// const data = { attr: \"action-data\" };\n\n// const hmls: HElements = [\n// [\"button\", { on: [\"click\", \"action\", data] }, \"send\"],\n// [\"h1\", \"aaa\"],\n// [\"input\",\n// {\n// type: \"text\",\n// on: [\n// [\"mouseover\", \"hover-action\", data],\n// [\"change\", \"click-action\", e => (e.target as HTMLInputElement).value],\n// [\"click\", e => dispatch(\"action\", data, e)],\n// ],\n// click: e => dispatch(\"action\", data, e)\n// }\n// ],\n// [\"button\",\n// {\n// on: [\"click\", e => dispatch(\"action\", data, e)],\n// click: e => dispatch(\"action\", data, e)\n// },\n// [\"Send\"]\n// ]\n// ];\n\n// console.log(hsmls2htmls(hmls, true).join(\"\"));\n","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","import { HElement, HElements, HAttrOnData, HHandlerCtx, HAttrOnDataFnc, HObj } from \"./hsml\";\nimport { hsmls2idomPatch } from \"./hsml-idom\";\nimport * as idom from \"incremental-dom\";\n\nexport interface IHWidget {\n render(): HElements;\n onMount(): void;\n onUmount(): void;\n actions(action: string, data?: HAttrOnData): void;\n}\n\nconst schedule = window.requestAnimationFrame ||\n // window.webkitRequestAnimationFrame ||\n // (window as any).mozRequestAnimationFrame ||\n // (window as any).oRequestAnimationFrame ||\n // (window as any).msRequestAnimationFrame ||\n function (callback: Function) { window.setTimeout(callback, 1000 / 60); };\n\nconst unschedule = window.cancelAnimationFrame ||\n // window.webkitCancelAnimationFrame ||\n // (window as any).mozCancelAnimationFrame ||\n // (window as any).oCancelAnimationFrame ||\n // (window as any).msCancelAnimationFrame ||\n function (handle: number) { window.clearTimeout(handle); };\n\nexport abstract class HWidget implements HObj, HHandlerCtx, IHWidget {\n\n private static _count = 0;\n\n static readonly mounted: { [wid: string]: HWidget } = {};\n\n readonly type: string = this.constructor.name; // \"Widget\"\n readonly id: string = this.type + \"-\" + HWidget._count++;\n readonly dom?: Element;\n readonly refs: { [key: string]: HTMLElement } = {};\n\n private _updateSched?: number;\n\n constructor(type?: string) {\n if (type) {\n this.type = type;\n }\n }\n\n abstract render(): HElements;\n\n onMount(): void {\n console.log(\"mount\");\n }\n\n onUmount(): void {\n console.log(\"umount\");\n }\n\n actions(action: string, data: any): void {\n console.log(action, data);\n }\n\n action(action: string, data?: any): void {\n this.actions(action, data);\n }\n\n actionCb(action: string, data: HAttrOnData, e: Event) {\n data = (data && data.constructor === Function)\n ? (data as HAttrOnDataFnc)(e)\n : data === undefined ? e : data;\n this.action(action, data);\n }\n\n mount(e?: string | Element | null): this {\n const el = typeof e === \"string\"\n ? document.getElementById(e) || document.body\n : e || document.body;\n if (\"widget\" in el) {\n const w = (el as any).widget as HWidget;\n w && w.umount();\n }\n if (!this.dom) {\n HWidget.mounted[this.id] = this;\n (this as any).dom = el;\n (el as any).widget = this;\n const hsmls = this.render();\n hsmls2idomPatch(el, hsmls, this);\n el.setAttribute(\"widget\", this.type);\n if ((this as any).onMount) {\n (this as any).onMount();\n }\n }\n return this;\n }\n\n umount(): this {\n if (this.dom) {\n delete HWidget.mounted[this.id];\n if ((this as any).onUmount) {\n (this as any).onUmount();\n }\n if (this.dom.hasAttribute(\"widget\")) {\n this.dom.removeAttribute(\"widget\");\n }\n const wNodes = this.dom.querySelectorAll(\"[widget]\");\n for (let i = 0; i < wNodes.length; i++) {\n const w = (wNodes[i] as any).widget as HWidget;\n w && w.umount();\n }\n while (this.dom.firstChild /*.hasChildNodes()*/) {\n this.dom.removeChild(this.dom.firstChild);\n }\n delete (this.dom as any).widget;\n (this as any).dom = undefined;\n }\n return this;\n }\n\n update(): this {\n if (this.dom && !this._updateSched) {\n this._updateSched = schedule(() => {\n if (this.dom) {\n hsmls2idomPatch(this.dom, this.render(), this);\n }\n this._updateSched = undefined;\n });\n }\n return this;\n }\n\n toHsml(): HElement {\n if (this.dom) {\n if (this._updateSched) {\n unschedule(this._updateSched);\n this._updateSched = undefined;\n } else {\n return (\n [\"div\",\n {\n _skip: true,\n _id: this.id,\n _key: this.id,\n widget: this.type\n }\n ]\n );\n }\n }\n const hsmls = (this as any).render() as HElements;\n hsmls.push(\n (e: Element) => {\n if (!this.dom) {\n (this as any).dom = e;\n (e as any).widget = this;\n if ((this as any).onMount) {\n (this as any).onMount();\n }\n }\n });\n return (\n [\"div\",\n {\n _id: this.id,\n _key: this.id,\n widget: this.type\n },\n hsmls\n ]\n );\n }\n\n toHtml = (): string => {\n return this.dom ? this.dom.outerHTML : \"\";\n }\n\n}\n\n(idom as any).notifications.nodesDeleted = (nodes: Node[]) => {\n nodes.forEach(node => {\n if (node.nodeType === 1 && \"widget\" in node) {\n const w = (node as any).widget as HWidget;\n w && w.umount();\n }\n });\n};\n","import {\n hsml,\n HElement,\n HElements,\n HHead,\n HAttrs,\n HAttrClasses,\n HAttrData,\n HAttrStyles,\n HAttrOn,\n HAttrOnCb,\n HAttrOnAct,\n HAttrOnAction,\n HAttrOnData,\n HFnc,\n HObj,\n HHandler,\n HHandlerCtx\n} from \"./hsml\";\nimport * as idom from \"incremental-dom\";\n\n// function setBoolAttrProp(el: any, attr: string, value: any) {\n// // console.log(\"idom.attributes\", attr, value, typeof value, el);\n// if (typeof value === \"string\") {\n// let b;\n// switch (value) {\n// case \"true\":\n// case \"1\":\n// case \"on\":\n// case \"yes\":\n// b = true;\n// break;\n// default:\n// b = false;\n// }\n// if (b) {\n// el.setAttribute(attr, value);\n// } else {\n// el.removeAttribute(attr);\n// }\n// el[attr] = b;\n// } else if (typeof value === \"boolean\") {\n// if (value) {\n// el.setAttribute(attr, \"\");\n// } else {\n// el.removeAttribute(attr);\n// }\n// el[attr] = value;\n// } else {\n// if (value) {\n// el.setAttribute(attr, value ? value : \"\");\n// } else {\n// el.removeAttribute(attr);\n// }\n// }\n// }\n\n// const boolAttrProps = [\n// \"readonly\",\n// \"disabled\",\n// \"checked\",\n// \"value\"\n// ];\n\n// boolAttrProps.forEach(a => idom.attributes[a] = setBoolAttrProp);\n\nclass HsmlIDomHandler implements HHandler<HHandlerCtx> {\n\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: HHandlerCtx): boolean {\n const props: any[] = [];\n let id = attrs._id;\n let classes: string[] = attrs._classes ? attrs._classes : [];\n let ref = attrs._ref;\n let hObj: any = attrs._hObj;\n for (const a in attrs) {\n if (attrs.hasOwnProperty(a)) {\n switch (a) {\n case \"_id\":\n case \"_classes\":\n case \"_ref\":\n case \"_key\":\n case \"_skip\":\n case \"_hObj\":\n break;\n case \"id\":\n id = attrs[a] as string;\n break;\n case \"classes\":\n const attrClasses = attrs[a] as HAttrClasses;\n classes = classes.concat(attrClasses\n ? attrClasses\n .map(c =>\n c.constructor === String\n ? c as string\n : (c[1] ? c[0] as string : undefined))\n .filter((c): c is string => c !== undefined)\n : [] as string[]);\n break;\n case \"class\":\n classes = classes.concat((attrs[a] as string).split(\" \"));\n break;\n case \"data\":\n const attrData = attrs[a] as HAttrData;\n for (const d in attrData) {\n if (attrData.hasOwnProperty(d)) {\n if (attrData[d].constructor === String) {\n props.push(\"data-\" + d, attrData[d]);\n } else {\n props.push(\"data-\" + d, JSON.stringify(attrData[d]));\n }\n }\n }\n break;\n case \"styles\":\n props.push(\"style\", attrs[a] as HAttrStyles);\n break;\n case \"on\":\n const attrOn = attrs[a] as HAttrOn;\n if (typeof attrOn[0] === \"string\") {\n if (typeof attrOn[1] === \"function\") {\n props.push(\"on\" + attrOn[0], attrOn[1]);\n } else {\n props.push(\"on\" + attrOn[0], (e: Event) => {\n ctx && ctx.actionCb &&\n typeof ctx.actionCb === \"function\" &&\n ctx.actionCb(attrOn[1] as HAttrOnAction,\n attrOn[2] as HAttrOnData,\n e);\n });\n }\n } else {\n (attrOn as Array<HAttrOnCb | HAttrOnAct>)\n .forEach(attr => {\n if (typeof attr[1] === \"function\") {\n props.push(\"on\" + attr[0], attr[1]);\n } else {\n props.push(\"on\" + attr[0], (e: Event) => {\n ctx && ctx.actionCb &&\n typeof ctx.actionCb === \"function\" &&\n ctx.actionCb(attr[1] as HAttrOnAction,\n attr[2] as HAttrOnData,\n e);\n });\n }\n });\n }\n break;\n default:\n // http://google.github.io/incremental-dom/#attributes-and-properties\n switch (typeof attrs[a]) {\n case \"function\":\n props.push(\"on\" + a, attrs[a]);\n break;\n case \"object\":\n // console.log(\"---\", a, typeof attrs[a], attrs[a]);\n // console.log(\"---String \", attrs[a] instanceof String);\n // console.log(\"---Boolean\", attrs[a] instanceof Boolean);\n // console.log(\"---Number \", attrs[a] instanceof Number);\n props.push(a, attrs[a]);\n break;\n // case \"boolean\":\n // if (boolAttrProps.includes(a)) {\n // props.push(a, attrs[a]);\n // } else {\n // attrs[a] && props.push(a, \"\");\n // }\n // break;\n case \"boolean\":\n attrs[a] && props.push(a, \"\");\n break;\n default:\n props.push(a, attrs[a]);\n break;\n }\n }\n }\n }\n if (classes.length) {\n props.unshift(\"class\", classes.join(\" \"));\n }\n if (id) {\n props.unshift(\"id\", id);\n }\n idom.elementOpen(tag, attrs._key, undefined, ...props);\n if (attrs._skip) {\n idom.skip();\n }\n if (ctx && ref) {\n ctx.refs[ref] = idom.currentElement();\n }\n if (hObj && hObj.mount && hObj.mount.constructor === Function) {\n hObj.mount(idom.currentElement());\n idom.skip();\n }\n return attrs._skip ? true : false;\n }\n\n close(tag: HHead, children: HElements, ctx?: HHandlerCtx): void {\n idom.elementClose(tag);\n }\n\n text(text: string, ctx?: HHandlerCtx): void {\n idom.text(text);\n }\n\n fnc(fnc: HFnc, ctx?: HHandlerCtx): void {\n const skip = fnc(idom.currentElement());\n skip && idom.skip();\n }\n\n obj(obj: HObj, ctx?: HHandlerCtx): void {\n if (\"toHsml\" in obj) {\n obj.toHsml && hsml(obj.toHsml(), this, obj as HHandlerCtx);\n } else {\n this.text(\"\" + obj, ctx);\n }\n }\n\n}\n\nfunction hsml2idom(hml: HElement, ctx?: HHandlerCtx): void {\n hsml(hml, new HsmlIDomHandler(), ctx);\n}\n\nfunction hsmls2idom(hmls: HElements, ctx?: HHandlerCtx): void {\n for (const hml of hmls) {\n if (hml === undefined || hml === null) {\n continue;\n }\n if (hml.constructor === String) {\n idom.text(hml as string);\n } else if (\"toHsml\" in (hml as any)) {\n const obj = hml as HHandlerCtx;\n obj.toHsml && hsml2idom(obj.toHsml(), obj);\n } else {\n hsml2idom(hml as HElement, ctx);\n }\n }\n}\n\nexport function hsml2idomPatch(node: Element, hsmlEl: HElement, ctx?: HHandlerCtx): void {\n idom.patch(node,\n (data?: HElement) => (data && hsml2idom(data, ctx)), hsmlEl);\n}\n\nexport function hsmls2idomPatch(node: Element, hsmlFr: HElements, ctx?: HHandlerCtx): void {\n idom.patch(node,\n (data?: HElements) => (data && hsmls2idom(data, ctx)), hsmlFr);\n}\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/hsml.ts","webpack:///external \"IncrementalDOM\"","webpack:///./src/hsml-widget.ts","webpack:///./src/hsml-idom.ts"],"names":["root","factory","exports","module","require","define","amd","a","i","window","__WEBPACK_EXTERNAL_MODULE__1__","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","hsml","hml","handler","ctx","constructor","Array","hmlTag","console","error","head","attrsObj","hasAttrs","hFnc","hObj","children","htc","Function","String","Boolean","Number","Date","refSplit","split","ref","dotSplit","hashSplit","tag","id","classes","slice","attrs","_id","length","_classes","_ref","_hObj","skip","open","fnc","forEach","jml","close","hsmlTag","text","toLocaleString","toString","ds","obj","hsmls","sep","reduce","push","splice","schedule","requestAnimationFrame","callback","setTimeout","unschedule","cancelAnimationFrame","handle","clearTimeout","HWidget","type","this","_count","refs","toHtml","dom","outerHTML","log","action","data","actions","e","undefined","el","document","getElementById","body","w","widget","umount","mounted","render","hsmls2idomPatch","setAttribute","onMount","onUmount","hasAttribute","removeAttribute","wNodes","querySelectorAll","firstChild","removeChild","_updateSched","_skip","_key","idom","notifications","nodesDeleted","nodes","node","nodeType","HsmlIDomHandler","props","attrClasses","concat","map","filter","attrData","JSON","stringify","attrOn","actionCb","attr","unshift","join","elementOpen","currentElement","mount","elementClose","toHsml","hsml2idom","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EACN9B,GAAqBA,GAAQmD,EAAUnD,EAAMpE,GAAOwH,IAG7D,2BAAgCtB,EAAewB,EAAmB1H,GAC9D8F,EAAK2B,MAAMvB,EACN9B,GAAsBA,GAvB/B,SAAoBuD,EAAiB3H,GACjC,IAAK,MAAMF,KAAO6H,EACd,GAAI7H,QAGJ,GAAIA,EAAIG,cAAgBa,OACpBgF,EAAKtD,KAAK1C,QACP,GAAI,WAAaA,EAAa,CACjC,MAAM8C,EAAM9C,EACZ8C,EAAI0E,QAAUC,EAAU3E,EAAI0E,SAAU1E,QAEtC2E,EAAUzH,EAAiBE,GAYA4H,CAAWxD,EAAMpE,GAAO0H","file":"hsml-widget.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"IncrementalDOM\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"IncrementalDOM\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"IncrementalDOM\")) : factory(root[\"IncrementalDOM\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function(__WEBPACK_EXTERNAL_MODULE__1__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 18);\n","\nexport type HHead = keyof HTMLElementTagNameMap | string; // \"tag#id.class1.class2~handler\"\n\nexport type HAttrClasses = Array<string | [string, boolean]>;\n\nexport type HAttrStyles = { [key: string]: string };\n\nexport type HAttrData = {\n [key: string]:\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object;\n};\n\nexport type HAttrOnAction = string;\n\nexport type HAttrOnDataFnc = (e: Event) => any;\n\nexport type HAttrOnData =\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object\n | HAttrOnDataFnc\n | null;\n\nexport type HAttrOnCb = [keyof HTMLElementEventMap, EventListener];\n\nexport type HAttrOnAct = [\n keyof HTMLElementEventMap,\n HAttrOnAction,\n HAttrOnData?\n];\n\nexport type HAttrOn = HAttrOnCb | HAttrOnAct | Array<HAttrOnCb | HAttrOnAct>;\n\nexport interface HAttrs {\n readonly _id?: string;\n readonly _classes?: string[];\n readonly _ref?: string;\n readonly _key?: string;\n readonly _skip?: boolean;\n readonly _hObj?: HObj;\n readonly classes?: HAttrClasses;\n readonly styles?: HAttrStyles;\n readonly data?: HAttrData;\n readonly on?: HAttrOn;\n readonly [key: string]:\n | string\n | String\n | string[]\n | String[]\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | HAttrClasses\n | HAttrStyles\n // | HsmlAttrData\n | HAttrOn\n | EventListener\n | HObj\n | undefined;\n}\n\nexport type HFnc = (e: Element) => boolean | void;\n\nexport interface HObj {\n toHsml?(): HElement;\n}\n\nexport interface HElements extends Array<HElement> {}\n\nexport type HChildren =\n | HElements\n | HFnc\n | HObj\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport type HTagNoAttr = [HHead, HChildren?];\nexport type HTagAttr = [HHead, HAttrs, HChildren?];\n\nexport type HTag = HTagNoAttr | HTagAttr;\n\nexport type HElement =\n | HFnc\n | HObj\n | HTag\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport interface HHandlerCtx extends HObj {\n refs: { [name: string]: Element };\n actionCb(action: HAttrOnAction, data: HAttrOnData, e: Event): void;\n}\n\nexport interface HHandler<C extends HHandlerCtx> {\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: C): boolean;\n close(tag: HHead, children: HElements, ctx?: C): void;\n text(text: string, ctx?: C): void;\n fnc(fnc: HFnc, ctx?: C): void;\n obj(obj: HObj, ctx?: C): void;\n}\n\nexport function hsml<C extends HHandlerCtx>(hml: HElement,\n handler: HHandler<C>,\n ctx?: C): void {\n // console.log(\"hsml\", hsml);\n if (hml === undefined || hml === null) {\n return;\n }\n switch (hml.constructor) {\n case Array:\n // const tag = hml as HTag;\n // if (\n // (\n // tag.length === 1 &&\n // tag[0].constructor === String\n // ) ||\n // (\n // tag.length === 2 &&\n // (\n // tag[0].constructor === String &&\n // (tag[1]!.constructor === Array || tag[1]!.constructor === Function)\n // ) ||\n // (\n // tag[0].constructor === String &&\n // tag[1]!.constructor === Object\n // )\n // ) ||\n // (\n // tag.length === 3 &&\n // tag[0].constructor === String &&\n // tag[1].constructor === Object &&\n // tag[2]!.constructor === Array\n // )\n // ) {\n // hsmlTag(hml as HTag, handler, ctx);\n // } else {\n // console.error(\"hsml parse error:\", hml);\n // // console.error(\"hsml parse error:\", JSON.stringify(hml, null, 4));\n // // throw Error(`hsml parse error: ${JSON.stringify(hml)}`);\n // }\n hsmlTag(hml as HTag, handler, ctx);\n break;\n case Function:\n handler.fnc(hml as HFnc, ctx);\n break;\n case String:\n handler.text(hml as string, ctx);\n break;\n case Boolean:\n handler.text(\"\" + hml, ctx);\n break;\n case Number:\n const n = hml as number;\n const ns = n.toLocaleString ? n.toLocaleString() : n.toString();\n handler.text(ns, ctx);\n break;\n case Date:\n const d = hml as Date;\n const ds = d.toLocaleString ? d.toLocaleString() : d.toString();\n handler.text(ds, ctx);\n break;\n default: // HObj\n handler.obj(hml as HObj, ctx);\n }\n\n function hsmlTag(hmlTag: HTag, handler: HHandler<C>, ctx?: C): void {\n // console.log(\"hsml tag\", hmlTag);\n\n if (typeof hmlTag[0] !== \"string\") {\n console.error(\"HSML tag head not string:\", hmlTag);\n return;\n }\n\n const head = hmlTag[0] as HHead;\n const attrsObj = hmlTag[1] as any;\n const hasAttrs = attrsObj && attrsObj.constructor === Object;\n const childIdx = hasAttrs ? 2 : 1;\n\n let children: HElements = [];\n let hFnc: HFnc | undefined;\n let hObj: HObj | undefined;\n\n const htc = hmlTag[childIdx];\n switch (htc && htc.constructor) {\n case Array:\n children = htc as HElements;\n break;\n case Function:\n hFnc = htc as HFnc;\n break;\n case String:\n case Boolean:\n case Number:\n case Date:\n children = [htc as string | boolean | number | Date];\n break;\n default: // HObj\n hObj = htc as HObj;\n break;\n }\n\n const refSplit = head.split(\"~\");\n const ref = refSplit[1];\n const dotSplit = refSplit[0].split(\".\");\n const hashSplit = dotSplit[0].split(\"#\");\n const tag = hashSplit[0] || \"div\";\n const id = hashSplit[1];\n const classes = dotSplit.slice(1);\n\n let attrs: HAttrs;\n if (hasAttrs) {\n attrs = attrsObj as HAttrs;\n } else {\n attrs = {} as HAttrs;\n }\n\n if (id) {\n (attrs as any)._id = id;\n }\n if (classes.length) {\n (attrs as any)._classes = classes;\n }\n if (ref) {\n (attrs as any)._ref = ref;\n }\n if (hObj) {\n (attrs as any)._hObj = hObj;\n }\n\n const skip = handler.open(tag, attrs, children, ctx);\n\n if (hFnc) {\n handler.fnc(hFnc, ctx);\n }\n\n if (!skip) {\n children.forEach(jml => hsml(jml, handler, ctx));\n }\n\n handler.close(tag, children, ctx);\n }\n}\n\nexport function hjoin(hsmls: HElements, sep: string | HElement): HElements {\n const r = hsmls.reduce<HElements>(\n (p, c) => (p.push(c, sep), p),\n [] as HElements\n );\n r.splice(-1);\n return r;\n}\n\n// Test\n\n// const hsmls: Hsmls = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\", { attr: \"attr\", classes: [\"class\"] }, [\n// \"text\",\n// 123,\n// true\n// ]]\n// ];\n\n// const hml: Hsml = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"t\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const hml1: Hsml = [\"div\", null, [\n// [\"span\", null, [\n// [\"a\",\n// {\n// href: \"https://gitlab.com/peter-rybar/diasheet\",\n// title: \"GitLab\",\n// target: \"_blank\"\n// },\n// [[\"i.fa.fa-gitlab\"]]\n// ]\n// ]],\n// [\"span\"]\n// ]];\n// console.log(hml1);\n\n// const hml2: Hsml = [\"div\", [\n// [\"h2\", [\"title\"]],\n// [\"div.w3-card-12\", [\n// [\"header.w3-container w3-light-grey\", [\n// [\"h3\", [\"Account: \", \"User\"]]\n// ]],\n// [\"div.w3-container.w3-light-grey\", [\n// [\"p\", [\"Balance: 4 DCT\"]],\n// [\"br\"]\n// ]],\n// [\"h4\", [\"Your account spending\"]],\n// [\"div#piechart\"],\n// [\"h4\", [\"Your account balance\"]],\n// [\"div#linechart\"],\n// [\"button.w3-button.w3-block.w3-dark-grey\", [\"Refresh\"]]\n// ]],\n// [\"br\"]\n// ]];\n// console.log(hml2);\n\n// TEST\n\n// import { hsmls2htmls } from \"./hsml-html\";\n// import { HDispatch } from \"./hsml-app\";\n\n// const dispatch: HDispatch = (type: string, data?: any, event?: Event): void => {\n// console.log(\"action:\", type, data, event);\n// };\n\n// const data = { attr: \"action-data\" };\n\n// const hmls: HElements = [\n// [\"button\", { on: [\"click\", \"action\", data] }, \"send\"],\n// [\"h1\", \"aaa\"],\n// [\"input\",\n// {\n// type: \"text\",\n// on: [\n// [\"mouseover\", \"hover-action\", data],\n// [\"change\", \"click-action\", e => (e.target as HTMLInputElement).value],\n// [\"click\", e => dispatch(\"action\", data, e)],\n// ],\n// click: e => dispatch(\"action\", data, e)\n// }\n// ],\n// [\"button\",\n// {\n// on: [\"click\", e => dispatch(\"action\", data, e)],\n// click: e => dispatch(\"action\", data, e)\n// },\n// [\"Send\"]\n// ]\n// ];\n\n// console.log(hsmls2htmls(hmls, true).join(\"\"));\n","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","import { HElement, HElements, HAttrOnData, HHandlerCtx, HAttrOnDataFnc, HObj } from \"./hsml\";\nimport { hsmls2idomPatch } from \"./hsml-idom\";\nimport * as idom from \"incremental-dom\";\n\nexport interface IHWidget {\n render(): HElements;\n onMount(): void;\n onUmount(): void;\n actions(action: string, data?: HAttrOnData): void;\n}\n\nconst schedule = window.requestAnimationFrame ||\n // window.webkitRequestAnimationFrame ||\n // (window as any).mozRequestAnimationFrame ||\n // (window as any).oRequestAnimationFrame ||\n // (window as any).msRequestAnimationFrame ||\n function (callback: Function) { window.setTimeout(callback, 1000 / 60); };\n\nconst unschedule = window.cancelAnimationFrame ||\n // window.webkitCancelAnimationFrame ||\n // (window as any).mozCancelAnimationFrame ||\n // (window as any).oCancelAnimationFrame ||\n // (window as any).msCancelAnimationFrame ||\n function (handle: number) { window.clearTimeout(handle); };\n\nexport abstract class HWidget implements HObj, HHandlerCtx, IHWidget {\n\n private static _count = 0;\n\n static readonly mounted: { [wid: string]: HWidget } = {};\n\n readonly type: string = this.constructor.name; // \"Widget\"\n readonly id: string = this.type + \"-\" + HWidget._count++;\n readonly dom?: Element;\n readonly refs: { [key: string]: HTMLElement } = {};\n\n private _updateSched?: number;\n\n constructor(type?: string) {\n if (type) {\n this.type = type;\n }\n }\n\n abstract render(): HElements;\n\n onMount(): void {\n console.log(\"mount\");\n }\n\n onUmount(): void {\n console.log(\"umount\");\n }\n\n actions(action: string, data: any): void {\n console.log(action, data);\n }\n\n action(action: string, data?: any): void {\n this.actions(action, data);\n }\n\n actionCb(action: string, data: HAttrOnData, e: Event) {\n data = (data && data.constructor === Function)\n ? (data as HAttrOnDataFnc)(e)\n : data === undefined ? e : data;\n this.action(action, data);\n }\n\n mount(e?: string | Element | null): this {\n const el = typeof e === \"string\"\n ? document.getElementById(e) || document.body\n : e || document.body;\n if (\"widget\" in el) {\n const w = (el as any).widget as HWidget;\n w && w.umount();\n }\n if (!this.dom) {\n HWidget.mounted[this.id] = this;\n (this as any).dom = el;\n (el as any).widget = this;\n const hsmls = this.render();\n hsmls2idomPatch(el, hsmls, this);\n el.setAttribute(\"widget\", this.type);\n if ((this as any).onMount) {\n (this as any).onMount();\n }\n }\n return this;\n }\n\n umount(): this {\n if (this.dom) {\n delete HWidget.mounted[this.id];\n if ((this as any).onUmount) {\n (this as any).onUmount();\n }\n if (this.dom.hasAttribute(\"widget\")) {\n this.dom.removeAttribute(\"widget\");\n }\n const wNodes = this.dom.querySelectorAll(\"[widget]\");\n for (let i = 0; i < wNodes.length; i++) {\n const w = (wNodes[i] as any).widget as HWidget;\n w && w.umount();\n }\n while (this.dom.firstChild /*.hasChildNodes()*/) {\n this.dom.removeChild(this.dom.firstChild);\n }\n delete (this.dom as any).widget;\n (this as any).dom = undefined;\n }\n return this;\n }\n\n update(): this {\n if (this.dom && !this._updateSched) {\n this._updateSched = schedule(() => {\n if (this.dom) {\n hsmls2idomPatch(this.dom, this.render(), this);\n }\n this._updateSched = undefined;\n });\n }\n return this;\n }\n\n toHsml(): HElement {\n if (this.dom) {\n if (this._updateSched) {\n unschedule(this._updateSched);\n this._updateSched = undefined;\n } else {\n return (\n [\"div\",\n {\n _skip: true,\n _id: this.id,\n _key: this.id,\n widget: this.type\n }\n ]\n );\n }\n }\n const hsmls = (this as any).render() as HElements;\n hsmls.push(\n (e: Element) => {\n if (!this.dom) {\n (this as any).dom = e;\n (e as any).widget = this;\n if ((this as any).onMount) {\n (this as any).onMount();\n }\n }\n });\n return (\n [\"div\",\n {\n _id: this.id,\n _key: this.id,\n widget: this.type\n },\n hsmls\n ]\n );\n }\n\n toHtml = (): string => {\n return this.dom ? this.dom.outerHTML : \"\";\n }\n\n}\n\n(idom as any).notifications.nodesDeleted = (nodes: Node[]) => {\n nodes.forEach(node => {\n if (node.nodeType === 1 && \"widget\" in node) {\n const w = (node as any).widget as HWidget;\n w && w.umount();\n }\n });\n};\n","import {\n hsml,\n HElement,\n HElements,\n HHead,\n HAttrs,\n HAttrClasses,\n HAttrData,\n HAttrStyles,\n HAttrOn,\n HAttrOnCb,\n HAttrOnAct,\n HAttrOnAction,\n HAttrOnData,\n HFnc,\n HObj,\n HHandler,\n HHandlerCtx\n} from \"./hsml\";\nimport * as idom from \"incremental-dom\";\n\n// function setBoolAttrProp(el: any, attr: string, value: any) {\n// // console.log(\"idom.attributes\", attr, value, typeof value, el);\n// if (typeof value === \"string\") {\n// let b;\n// switch (value) {\n// case \"true\":\n// case \"1\":\n// case \"on\":\n// case \"yes\":\n// b = true;\n// break;\n// default:\n// b = false;\n// }\n// if (b) {\n// el.setAttribute(attr, value);\n// } else {\n// el.removeAttribute(attr);\n// }\n// el[attr] = b;\n// } else if (typeof value === \"boolean\") {\n// if (value) {\n// el.setAttribute(attr, \"\");\n// } else {\n// el.removeAttribute(attr);\n// }\n// el[attr] = value;\n// } else {\n// if (value) {\n// el.setAttribute(attr, value ? value : \"\");\n// } else {\n// el.removeAttribute(attr);\n// }\n// }\n// }\n\n// const boolAttrProps = [\n// \"readonly\",\n// \"disabled\",\n// \"checked\",\n// \"value\"\n// ];\n\n// boolAttrProps.forEach(a => idom.attributes[a] = setBoolAttrProp);\n\nclass HsmlIDomHandler implements HHandler<HHandlerCtx> {\n\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: HHandlerCtx): boolean {\n const props: any[] = [];\n let id = attrs._id;\n let classes: string[] = attrs._classes ? attrs._classes : [];\n let ref = attrs._ref;\n let hObj: any = attrs._hObj;\n for (const a in attrs) {\n if (attrs.hasOwnProperty(a)) {\n switch (a) {\n case \"_id\":\n case \"_classes\":\n case \"_ref\":\n case \"_key\":\n case \"_skip\":\n case \"_hObj\":\n break;\n case \"id\":\n id = attrs[a] as string;\n break;\n case \"classes\":\n const attrClasses = attrs[a] as HAttrClasses;\n classes = classes.concat(attrClasses\n ? attrClasses\n .map(c =>\n c.constructor === String\n ? c as string\n : (c[1] ? c[0] as string : undefined))\n .filter((c): c is string => c !== undefined)\n : [] as string[]);\n break;\n case \"class\":\n classes = classes.concat((attrs[a] as string).split(\" \"));\n break;\n case \"data\":\n const attrData = attrs[a] as HAttrData;\n for (const d in attrData) {\n if (attrData.hasOwnProperty(d)) {\n if (attrData[d].constructor === String) {\n props.push(\"data-\" + d, attrData[d]);\n } else {\n props.push(\"data-\" + d, JSON.stringify(attrData[d]));\n }\n }\n }\n break;\n case \"styles\":\n props.push(\"style\", attrs[a] as HAttrStyles);\n break;\n case \"on\":\n const attrOn = attrs[a] as HAttrOn;\n if (typeof attrOn[0] === \"string\") {\n if (typeof attrOn[1] === \"function\") {\n props.push(\"on\" + attrOn[0], attrOn[1]);\n } else {\n props.push(\"on\" + attrOn[0], (e: Event) => {\n ctx && ctx.actionCb &&\n typeof ctx.actionCb === \"function\" &&\n ctx.actionCb(attrOn[1] as HAttrOnAction,\n attrOn[2] as HAttrOnData,\n e);\n });\n }\n } else {\n (attrOn as Array<HAttrOnCb | HAttrOnAct>)\n .forEach(attr => {\n if (typeof attr[1] === \"function\") {\n props.push(\"on\" + attr[0], attr[1]);\n } else {\n props.push(\"on\" + attr[0], (e: Event) => {\n ctx && ctx.actionCb &&\n typeof ctx.actionCb === \"function\" &&\n ctx.actionCb(attr[1] as HAttrOnAction,\n attr[2] as HAttrOnData,\n e);\n });\n }\n });\n }\n break;\n default:\n // http://google.github.io/incremental-dom/#attributes-and-properties\n switch (typeof attrs[a]) {\n case \"function\":\n props.push(\"on\" + a, attrs[a]);\n break;\n case \"object\":\n // console.log(\"---\", a, typeof attrs[a], attrs[a]);\n // console.log(\"---String \", attrs[a] instanceof String);\n // console.log(\"---Boolean\", attrs[a] instanceof Boolean);\n // console.log(\"---Number \", attrs[a] instanceof Number);\n props.push(a, attrs[a]);\n break;\n // case \"boolean\":\n // if (boolAttrProps.includes(a)) {\n // props.push(a, attrs[a]);\n // } else {\n // attrs[a] && props.push(a, a);\n // }\n // break;\n case \"boolean\":\n attrs[a] && props.push(a, a);\n break;\n default:\n props.push(a, attrs[a]);\n break;\n }\n }\n }\n }\n if (classes.length) {\n props.unshift(\"class\", classes.join(\" \"));\n }\n if (id) {\n props.unshift(\"id\", id);\n }\n idom.elementOpen(tag, attrs._key, undefined, ...props);\n if (attrs._skip) {\n idom.skip();\n }\n if (ctx && ref) {\n ctx.refs[ref] = idom.currentElement();\n }\n if (hObj && hObj.mount && hObj.mount.constructor === Function) {\n hObj.mount(idom.currentElement());\n idom.skip();\n }\n return attrs._skip ? true : false;\n }\n\n close(tag: HHead, children: HElements, ctx?: HHandlerCtx): void {\n idom.elementClose(tag);\n }\n\n text(text: string, ctx?: HHandlerCtx): void {\n idom.text(text);\n }\n\n fnc(fnc: HFnc, ctx?: HHandlerCtx): void {\n const skip = fnc(idom.currentElement());\n skip && idom.skip();\n }\n\n obj(obj: HObj, ctx?: HHandlerCtx): void {\n if (\"toHsml\" in obj) {\n obj.toHsml && hsml(obj.toHsml(), this, obj as HHandlerCtx);\n } else {\n this.text(\"\" + obj, ctx);\n }\n }\n\n}\n\nfunction hsml2idom(hml: HElement, ctx?: HHandlerCtx): void {\n hsml(hml, new HsmlIDomHandler(), ctx);\n}\n\nfunction hsmls2idom(hmls: HElements, ctx?: HHandlerCtx): void {\n for (const hml of hmls) {\n if (hml === undefined || hml === null) {\n continue;\n }\n if (hml.constructor === String) {\n idom.text(hml as string);\n } else if (\"toHsml\" in (hml as any)) {\n const obj = hml as HHandlerCtx;\n obj.toHsml && hsml2idom(obj.toHsml(), obj);\n } else {\n hsml2idom(hml as HElement, ctx);\n }\n }\n}\n\nexport function hsml2idomPatch(node: Element, hsmlEl: HElement, ctx?: HHandlerCtx): void {\n idom.patch(node,\n (data?: HElement) => (data && hsml2idom(data, ctx)), hsmlEl);\n}\n\nexport function hsmls2idomPatch(node: Element, hsmlFr: HElements, ctx?: HHandlerCtx): void {\n idom.patch(node,\n (data?: HElements) => (data && hsmls2idom(data, ctx)), hsmlFr);\n}\n"],"sourceRoot":""}
package/dist/umd/hsml.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hsml=function e(t,n,r){if(null!=t)switch(t.constructor){case Array:!function(t,n,r){if("string"!=typeof t[0])return void console.error("HSML tag head not string:",t);const o=t[0],c=t[1],i=c&&c.constructor===Object;let u,a,s=[];const f=t[i?2:1];switch(f&&f.constructor){case Array:s=f;break;case Function:u=f;break;case String:case Boolean:case Number:case Date:s=[f];break;default:a=f}const l=o.split("~"),d=l[1],p=l[0].split("."),b=p[0].split("#"),y=b[0]||"div",g=b[1],j=p.slice(1);let S;S=i?c:{};g&&(S._id=g);j.length&&(S._classes=j);d&&(S._ref=d);a&&(S._hObj=a);const v=n.open(y,S,s,r);u&&n.fnc(u,r);v||s.forEach(t=>e(t,n,r));n.close(y,s,r)}(t,n,r);break;case Function:n.fnc(t,r);break;case String:n.text(t,r);break;case Boolean:n.text(""+t,r);break;case Number:const o=t,c=o.toLocaleString?o.toLocaleString():o.toString();n.text(c,r);break;case Date:const i=t,u=i.toLocaleString?i.toLocaleString():i.toString();n.text(u,r);break;default:n.obj(t,r)}},t.hjoin=function(e,t){const n=e.reduce((e,n)=>(e.push(n,t),e),[]);return n.splice(-1),n}}])}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hjoin=t.hsml=void 0,t.hsml=function e(t,n,r){if(null!=t)switch(t.constructor){case Array:!function(t,n,r){if("string"!=typeof t[0])return void console.error("HSML tag head not string:",t);const o=t[0],c=t[1],i=c&&c.constructor===Object;let u,a,s=[];const l=t[i?2:1];switch(l&&l.constructor){case Array:s=l;break;case Function:u=l;break;case String:case Boolean:case Number:case Date:s=[l];break;default:a=l}const f=o.split("~"),d=f[1],p=f[0].split("."),b=p[0].split("#"),y=b[0]||"div",g=b[1],j=p.slice(1);let v;v=i?c:{};g&&(v._id=g);j.length&&(v._classes=j);d&&(v._ref=d);a&&(v._hObj=a);const S=n.open(y,v,s,r);u&&n.fnc(u,r);S||s.forEach(t=>e(t,n,r));n.close(y,s,r)}(t,n,r);break;case Function:n.fnc(t,r);break;case String:n.text(t,r);break;case Boolean:n.text(""+t,r);break;case Number:const o=t,c=o.toLocaleString?o.toLocaleString():o.toString();n.text(c,r);break;case Date:const i=t,u=i.toLocaleString?i.toLocaleString():i.toString();n.text(u,r);break;default:n.obj(t,r)}},t.hjoin=function(e,t){const n=e.reduce((e,n)=>(e.push(n,t),e),[]);return n.splice(-1),n}}])}));
2
2
  //# sourceMappingURL=hsml.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/hsml.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","hsml","hml","handler","ctx","constructor","Array","hmlTag","console","error","head","attrsObj","hasAttrs","hFnc","hObj","children","htc","Function","String","Boolean","Number","Date","refSplit","split","ref","dotSplit","hashSplit","tag","id","classes","slice","attrs","_id","length","_classes","_ref","_hObj","skip","open","fnc","forEach","jml","close","hsmlTag","text","toLocaleString","toString","ds","obj","hsmls","sep","reduce","push","splice"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,G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C,IAAI1B,EAAMT,GAGjBiC,GACDtB,EAASyB,QAAQC,GAAOxC,EAAKwC,EAAKtC,EAASC,IAG/CD,EAAQuC,MAAMf,EAAKZ,EAAUX,GAnGzBuC,CAAQzC,EAAaC,EAASC,GAC9B,MACJ,KAAKa,SACDd,EAAQoC,IAAIrC,EAAaE,GACzB,MACJ,KAAKc,OACDf,EAAQyC,KAAK1C,EAAeE,GAC5B,MACJ,KAAKe,QACDhB,EAAQyC,KAAK,GAAK1C,EAAKE,GACvB,MACJ,KAAKgB,OACD,MAAM1B,EAAIQ,EACJZ,EAAKI,EAAEmD,eAAiBnD,EAAEmD,iBAAmBnD,EAAEoD,WACrD3C,EAAQyC,KAAKtD,EAAIc,GACjB,MACJ,KAAKiB,KACD,MAAM9C,EAAI2B,EACJ6C,EAAKxE,EAAEsE,eAAiBtE,EAAEsE,iBAAmBtE,EAAEuE,WACrD3C,EAAQyC,KAAKG,EAAI3C,GACjB,MACJ,QACID,EAAQ6C,IAAI9C,EAAaE,KAiFrC,iBAAsB6C,EAAkBC,GACpC,MAAMnE,EAAIkE,EAAME,OACZ,CAACpD,EAAGzB,KAAOyB,EAAEqD,KAAK9E,EAAG4E,GAAMnD,GAC3B,IAGJ,OADAhB,EAAEsE,QAAQ,GACHtE","file":"hsml.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","\nexport type HHead = keyof HTMLElementTagNameMap | string; // \"tag#id.class1.class2~handler\"\n\nexport type HAttrClasses = Array<string | [string, boolean]>;\n\nexport type HAttrStyles = { [key: string]: string };\n\nexport type HAttrData = {\n [key: string]:\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object;\n};\n\nexport type HAttrOnAction = string;\n\nexport type HAttrOnDataFnc = (e: Event) => any;\n\nexport type HAttrOnData =\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object\n | HAttrOnDataFnc\n | null;\n\nexport type HAttrOnCb = [keyof HTMLElementEventMap, EventListener];\n\nexport type HAttrOnAct = [\n keyof HTMLElementEventMap,\n HAttrOnAction,\n HAttrOnData?\n];\n\nexport type HAttrOn = HAttrOnCb | HAttrOnAct | Array<HAttrOnCb | HAttrOnAct>;\n\nexport interface HAttrs {\n readonly _id?: string;\n readonly _classes?: string[];\n readonly _ref?: string;\n readonly _key?: string;\n readonly _skip?: boolean;\n readonly _hObj?: HObj;\n readonly classes?: HAttrClasses;\n readonly styles?: HAttrStyles;\n readonly data?: HAttrData;\n readonly on?: HAttrOn;\n readonly [key: string]:\n | string\n | String\n | string[]\n | String[]\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | HAttrClasses\n | HAttrStyles\n // | HsmlAttrData\n | HAttrOn\n | EventListener\n | HObj\n | undefined;\n}\n\nexport type HFnc = (e: Element) => boolean | void;\n\nexport interface HObj {\n toHsml?(): HElement;\n}\n\nexport interface HElements extends Array<HElement> {}\n\nexport type HChildren =\n | HElements\n | HFnc\n | HObj\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport type HTagNoAttr = [HHead, HChildren?];\nexport type HTagAttr = [HHead, HAttrs, HChildren?];\n\nexport type HTag = HTagNoAttr | HTagAttr;\n\nexport type HElement =\n | HFnc\n | HObj\n | HTag\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport interface HHandlerCtx extends HObj {\n refs: { [name: string]: Element };\n actionCb(action: HAttrOnAction, data: HAttrOnData, e: Event): void;\n}\n\nexport interface HHandler<C extends HHandlerCtx> {\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: C): boolean;\n close(tag: HHead, children: HElements, ctx?: C): void;\n text(text: string, ctx?: C): void;\n fnc(fnc: HFnc, ctx?: C): void;\n obj(obj: HObj, ctx?: C): void;\n}\n\nexport function hsml<C extends HHandlerCtx>(hml: HElement,\n handler: HHandler<C>,\n ctx?: C): void {\n // console.log(\"hsml\", hsml);\n if (hml === undefined || hml === null) {\n return;\n }\n switch (hml.constructor) {\n case Array:\n // const tag = hml as HTag;\n // if (\n // (\n // tag.length === 1 &&\n // tag[0].constructor === String\n // ) ||\n // (\n // tag.length === 2 &&\n // (\n // tag[0].constructor === String &&\n // (tag[1]!.constructor === Array || tag[1]!.constructor === Function)\n // ) ||\n // (\n // tag[0].constructor === String &&\n // tag[1]!.constructor === Object\n // )\n // ) ||\n // (\n // tag.length === 3 &&\n // tag[0].constructor === String &&\n // tag[1].constructor === Object &&\n // tag[2]!.constructor === Array\n // )\n // ) {\n // hsmlTag(hml as HTag, handler, ctx);\n // } else {\n // console.error(\"hsml parse error:\", hml);\n // // console.error(\"hsml parse error:\", JSON.stringify(hml, null, 4));\n // // throw Error(`hsml parse error: ${JSON.stringify(hml)}`);\n // }\n hsmlTag(hml as HTag, handler, ctx);\n break;\n case Function:\n handler.fnc(hml as HFnc, ctx);\n break;\n case String:\n handler.text(hml as string, ctx);\n break;\n case Boolean:\n handler.text(\"\" + hml, ctx);\n break;\n case Number:\n const n = hml as number;\n const ns = n.toLocaleString ? n.toLocaleString() : n.toString();\n handler.text(ns, ctx);\n break;\n case Date:\n const d = hml as Date;\n const ds = d.toLocaleString ? d.toLocaleString() : d.toString();\n handler.text(ds, ctx);\n break;\n default: // HObj\n handler.obj(hml as HObj, ctx);\n }\n\n function hsmlTag(hmlTag: HTag, handler: HHandler<C>, ctx?: C): void {\n // console.log(\"hsml tag\", hmlTag);\n\n if (typeof hmlTag[0] !== \"string\") {\n console.error(\"HSML tag head not string:\", hmlTag);\n return;\n }\n\n const head = hmlTag[0] as HHead;\n const attrsObj = hmlTag[1] as any;\n const hasAttrs = attrsObj && attrsObj.constructor === Object;\n const childIdx = hasAttrs ? 2 : 1;\n\n let children: HElements = [];\n let hFnc: HFnc | undefined;\n let hObj: HObj | undefined;\n\n const htc = hmlTag[childIdx];\n switch (htc && htc.constructor) {\n case Array:\n children = htc as HElements;\n break;\n case Function:\n hFnc = htc as HFnc;\n break;\n case String:\n case Boolean:\n case Number:\n case Date:\n children = [htc as string | boolean | number | Date];\n break;\n default: // HObj\n hObj = htc as HObj;\n break;\n }\n\n const refSplit = head.split(\"~\");\n const ref = refSplit[1];\n const dotSplit = refSplit[0].split(\".\");\n const hashSplit = dotSplit[0].split(\"#\");\n const tag = hashSplit[0] || \"div\";\n const id = hashSplit[1];\n const classes = dotSplit.slice(1);\n\n let attrs: HAttrs;\n if (hasAttrs) {\n attrs = attrsObj as HAttrs;\n } else {\n attrs = {} as HAttrs;\n }\n\n if (id) {\n (attrs as any)._id = id;\n }\n if (classes.length) {\n (attrs as any)._classes = classes;\n }\n if (ref) {\n (attrs as any)._ref = ref;\n }\n if (hObj) {\n (attrs as any)._hObj = hObj;\n }\n\n const skip = handler.open(tag, attrs, children, ctx);\n\n if (hFnc) {\n handler.fnc(hFnc, ctx);\n }\n\n if (!skip) {\n children.forEach(jml => hsml(jml, handler, ctx));\n }\n\n handler.close(tag, children, ctx);\n }\n}\n\nexport function hjoin(hsmls: HElements, sep: string | HElement): HElements {\n const r = hsmls.reduce<HElements>(\n (p, c) => (p.push(c, sep), p),\n [] as HElements\n );\n r.splice(-1);\n return r;\n}\n\n// Test\n\n// const hsmls: Hsmls = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\", { attr: \"attr\", classes: [\"class\"] }, [\n// \"text\",\n// 123,\n// true\n// ]]\n// ];\n\n// const hml: Hsml = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"t\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const hml1: Hsml = [\"div\", null, [\n// [\"span\", null, [\n// [\"a\",\n// {\n// href: \"https://gitlab.com/peter-rybar/diasheet\",\n// title: \"GitLab\",\n// target: \"_blank\"\n// },\n// [[\"i.fa.fa-gitlab\"]]\n// ]\n// ]],\n// [\"span\"]\n// ]];\n// console.log(hml1);\n\n// const hml2: Hsml = [\"div\", [\n// [\"h2\", [\"title\"]],\n// [\"div.w3-card-12\", [\n// [\"header.w3-container w3-light-grey\", [\n// [\"h3\", [\"Account: \", \"User\"]]\n// ]],\n// [\"div.w3-container.w3-light-grey\", [\n// [\"p\", [\"Balance: 4 DCT\"]],\n// [\"br\"]\n// ]],\n// [\"h4\", [\"Your account spending\"]],\n// [\"div#piechart\"],\n// [\"h4\", [\"Your account balance\"]],\n// [\"div#linechart\"],\n// [\"button.w3-button.w3-block.w3-dark-grey\", [\"Refresh\"]]\n// ]],\n// [\"br\"]\n// ]];\n// console.log(hml2);\n\n// TEST\n\n// import { hsmls2htmls } from \"./hsml-html\";\n// import { HDispatch } from \"./hsml-app\";\n\n// const dispatch: HDispatch = (type: string, data?: any, event?: Event): void => {\n// console.log(\"action:\", type, data, event);\n// };\n\n// const data = { attr: \"action-data\" };\n\n// const hmls: HElements = [\n// [\"button\", { on: [\"click\", \"action\", data] }, \"send\"],\n// [\"h1\", \"aaa\"],\n// [\"input\",\n// {\n// type: \"text\",\n// on: [\n// [\"mouseover\", \"hover-action\", data],\n// [\"change\", \"click-action\", e => (e.target as HTMLInputElement).value],\n// [\"click\", e => dispatch(\"action\", data, e)],\n// ],\n// click: e => dispatch(\"action\", data, e)\n// }\n// ],\n// [\"button\",\n// {\n// on: [\"click\", e => dispatch(\"action\", data, e)],\n// click: e => dispatch(\"action\", data, e)\n// },\n// [\"Send\"]\n// ]\n// ];\n\n// console.log(hsmls2htmls(hmls, true).join(\"\"));\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/hsml.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","hsml","hml","handler","ctx","constructor","Array","hmlTag","console","error","head","attrsObj","hasAttrs","hFnc","hObj","children","htc","Function","String","Boolean","Number","Date","refSplit","split","ref","dotSplit","hashSplit","tag","id","classes","slice","attrs","_id","length","_classes","_ref","_hObj","skip","open","fnc","forEach","jml","close","hsmlTag","text","toLocaleString","toString","ds","obj","hsmls","sep","reduce","push","splice"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUT,QAGnC,IAAIC,EAASM,EAAiBE,GAAY,CACzCJ,EAAGI,EACHC,GAAG,EACHV,QAAS,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eE,GAC5B,MACJ,KAAKe,QACDhB,EAAQyC,KAAK,GAAK1C,EAAKE,GACvB,MACJ,KAAKgB,OACD,MAAM1B,EAAIQ,EACJZ,EAAKI,EAAEmD,eAAiBnD,EAAEmD,iBAAmBnD,EAAEoD,WACrD3C,EAAQyC,KAAKtD,EAAIc,GACjB,MACJ,KAAKiB,KACD,MAAM9C,EAAI2B,EACJ6C,EAAKxE,EAAEsE,eAAiBtE,EAAEsE,iBAAmBtE,EAAEuE,WACrD3C,EAAQyC,KAAKG,EAAI3C,GACjB,MACJ,QACID,EAAQ6C,IAAI9C,EAAaE,KAiFrC,iBAAsB6C,EAAkBC,GACpC,MAAMnE,EAAIkE,EAAME,OACZ,CAACpD,EAAGzB,KAAOyB,EAAEqD,KAAK9E,EAAG4E,GAAMnD,GAC3B,IAGJ,OADAhB,EAAEsE,QAAQ,GACHtE","file":"hsml.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","\nexport type HHead = keyof HTMLElementTagNameMap | string; // \"tag#id.class1.class2~handler\"\n\nexport type HAttrClasses = Array<string | [string, boolean]>;\n\nexport type HAttrStyles = { [key: string]: string };\n\nexport type HAttrData = {\n [key: string]:\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object;\n};\n\nexport type HAttrOnAction = string;\n\nexport type HAttrOnDataFnc = (e: Event) => any;\n\nexport type HAttrOnData =\n | string\n | String\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | Array<any>\n | Object\n | HAttrOnDataFnc\n | null;\n\nexport type HAttrOnCb = [keyof HTMLElementEventMap, EventListener];\n\nexport type HAttrOnAct = [\n keyof HTMLElementEventMap,\n HAttrOnAction,\n HAttrOnData?\n];\n\nexport type HAttrOn = HAttrOnCb | HAttrOnAct | Array<HAttrOnCb | HAttrOnAct>;\n\nexport interface HAttrs {\n readonly _id?: string;\n readonly _classes?: string[];\n readonly _ref?: string;\n readonly _key?: string;\n readonly _skip?: boolean;\n readonly _hObj?: HObj;\n readonly classes?: HAttrClasses;\n readonly styles?: HAttrStyles;\n readonly data?: HAttrData;\n readonly on?: HAttrOn;\n readonly [key: string]:\n | string\n | String\n | string[]\n | String[]\n | number\n | Number\n | boolean\n | Boolean\n | Date\n | HAttrClasses\n | HAttrStyles\n // | HsmlAttrData\n | HAttrOn\n | EventListener\n | HObj\n | undefined;\n}\n\nexport type HFnc = (e: Element) => boolean | void;\n\nexport interface HObj {\n toHsml?(): HElement;\n}\n\nexport interface HElements extends Array<HElement> {}\n\nexport type HChildren =\n | HElements\n | HFnc\n | HObj\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport type HTagNoAttr = [HHead, HChildren?];\nexport type HTagAttr = [HHead, HAttrs, HChildren?];\n\nexport type HTag = HTagNoAttr | HTagAttr;\n\nexport type HElement =\n | HFnc\n | HObj\n | HTag\n | string\n | String\n | boolean\n | Boolean\n | number\n | Number\n | Date\n | undefined\n | null;\n\nexport interface HHandlerCtx extends HObj {\n refs: { [name: string]: Element };\n actionCb(action: HAttrOnAction, data: HAttrOnData, e: Event): void;\n}\n\nexport interface HHandler<C extends HHandlerCtx> {\n open(tag: HHead, attrs: HAttrs, children: HElements, ctx?: C): boolean;\n close(tag: HHead, children: HElements, ctx?: C): void;\n text(text: string, ctx?: C): void;\n fnc(fnc: HFnc, ctx?: C): void;\n obj(obj: HObj, ctx?: C): void;\n}\n\nexport function hsml<C extends HHandlerCtx>(hml: HElement,\n handler: HHandler<C>,\n ctx?: C): void {\n // console.log(\"hsml\", hsml);\n if (hml === undefined || hml === null) {\n return;\n }\n switch (hml.constructor) {\n case Array:\n // const tag = hml as HTag;\n // if (\n // (\n // tag.length === 1 &&\n // tag[0].constructor === String\n // ) ||\n // (\n // tag.length === 2 &&\n // (\n // tag[0].constructor === String &&\n // (tag[1]!.constructor === Array || tag[1]!.constructor === Function)\n // ) ||\n // (\n // tag[0].constructor === String &&\n // tag[1]!.constructor === Object\n // )\n // ) ||\n // (\n // tag.length === 3 &&\n // tag[0].constructor === String &&\n // tag[1].constructor === Object &&\n // tag[2]!.constructor === Array\n // )\n // ) {\n // hsmlTag(hml as HTag, handler, ctx);\n // } else {\n // console.error(\"hsml parse error:\", hml);\n // // console.error(\"hsml parse error:\", JSON.stringify(hml, null, 4));\n // // throw Error(`hsml parse error: ${JSON.stringify(hml)}`);\n // }\n hsmlTag(hml as HTag, handler, ctx);\n break;\n case Function:\n handler.fnc(hml as HFnc, ctx);\n break;\n case String:\n handler.text(hml as string, ctx);\n break;\n case Boolean:\n handler.text(\"\" + hml, ctx);\n break;\n case Number:\n const n = hml as number;\n const ns = n.toLocaleString ? n.toLocaleString() : n.toString();\n handler.text(ns, ctx);\n break;\n case Date:\n const d = hml as Date;\n const ds = d.toLocaleString ? d.toLocaleString() : d.toString();\n handler.text(ds, ctx);\n break;\n default: // HObj\n handler.obj(hml as HObj, ctx);\n }\n\n function hsmlTag(hmlTag: HTag, handler: HHandler<C>, ctx?: C): void {\n // console.log(\"hsml tag\", hmlTag);\n\n if (typeof hmlTag[0] !== \"string\") {\n console.error(\"HSML tag head not string:\", hmlTag);\n return;\n }\n\n const head = hmlTag[0] as HHead;\n const attrsObj = hmlTag[1] as any;\n const hasAttrs = attrsObj && attrsObj.constructor === Object;\n const childIdx = hasAttrs ? 2 : 1;\n\n let children: HElements = [];\n let hFnc: HFnc | undefined;\n let hObj: HObj | undefined;\n\n const htc = hmlTag[childIdx];\n switch (htc && htc.constructor) {\n case Array:\n children = htc as HElements;\n break;\n case Function:\n hFnc = htc as HFnc;\n break;\n case String:\n case Boolean:\n case Number:\n case Date:\n children = [htc as string | boolean | number | Date];\n break;\n default: // HObj\n hObj = htc as HObj;\n break;\n }\n\n const refSplit = head.split(\"~\");\n const ref = refSplit[1];\n const dotSplit = refSplit[0].split(\".\");\n const hashSplit = dotSplit[0].split(\"#\");\n const tag = hashSplit[0] || \"div\";\n const id = hashSplit[1];\n const classes = dotSplit.slice(1);\n\n let attrs: HAttrs;\n if (hasAttrs) {\n attrs = attrsObj as HAttrs;\n } else {\n attrs = {} as HAttrs;\n }\n\n if (id) {\n (attrs as any)._id = id;\n }\n if (classes.length) {\n (attrs as any)._classes = classes;\n }\n if (ref) {\n (attrs as any)._ref = ref;\n }\n if (hObj) {\n (attrs as any)._hObj = hObj;\n }\n\n const skip = handler.open(tag, attrs, children, ctx);\n\n if (hFnc) {\n handler.fnc(hFnc, ctx);\n }\n\n if (!skip) {\n children.forEach(jml => hsml(jml, handler, ctx));\n }\n\n handler.close(tag, children, ctx);\n }\n}\n\nexport function hjoin(hsmls: HElements, sep: string | HElement): HElements {\n const r = hsmls.reduce<HElements>(\n (p, c) => (p.push(c, sep), p),\n [] as HElements\n );\n r.splice(-1);\n return r;\n}\n\n// Test\n\n// const hsmls: Hsmls = [\n// \"text\",\n// [\"tag\", [\n// \"d\",\n// [\"\"]\n// ]],\n// [\"taga\", { attr: \"attr\", classes: [\"class\"] }, [\n// \"text\",\n// 123,\n// true\n// ]]\n// ];\n\n// const hml: Hsml = [\"xxx\", {}, [\n// \"types\", \" \", 1235.456, \" \", new Date(), \" \",\n// ...hsmls,\n// [\"t\", [\"t\", \"a\", \"\"]],\n// [\"t\", {}, [\"t\", \"a\", \"\"]],\n// [\"t\"]\n// ]];\n\n// console.log(hsmls, hml);\n\n// const hml1: Hsml = [\"div\", null, [\n// [\"span\", null, [\n// [\"a\",\n// {\n// href: \"https://gitlab.com/peter-rybar/diasheet\",\n// title: \"GitLab\",\n// target: \"_blank\"\n// },\n// [[\"i.fa.fa-gitlab\"]]\n// ]\n// ]],\n// [\"span\"]\n// ]];\n// console.log(hml1);\n\n// const hml2: Hsml = [\"div\", [\n// [\"h2\", [\"title\"]],\n// [\"div.w3-card-12\", [\n// [\"header.w3-container w3-light-grey\", [\n// [\"h3\", [\"Account: \", \"User\"]]\n// ]],\n// [\"div.w3-container.w3-light-grey\", [\n// [\"p\", [\"Balance: 4 DCT\"]],\n// [\"br\"]\n// ]],\n// [\"h4\", [\"Your account spending\"]],\n// [\"div#piechart\"],\n// [\"h4\", [\"Your account balance\"]],\n// [\"div#linechart\"],\n// [\"button.w3-button.w3-block.w3-dark-grey\", [\"Refresh\"]]\n// ]],\n// [\"br\"]\n// ]];\n// console.log(hml2);\n\n// TEST\n\n// import { hsmls2htmls } from \"./hsml-html\";\n// import { HDispatch } from \"./hsml-app\";\n\n// const dispatch: HDispatch = (type: string, data?: any, event?: Event): void => {\n// console.log(\"action:\", type, data, event);\n// };\n\n// const data = { attr: \"action-data\" };\n\n// const hmls: HElements = [\n// [\"button\", { on: [\"click\", \"action\", data] }, \"send\"],\n// [\"h1\", \"aaa\"],\n// [\"input\",\n// {\n// type: \"text\",\n// on: [\n// [\"mouseover\", \"hover-action\", data],\n// [\"change\", \"click-action\", e => (e.target as HTMLInputElement).value],\n// [\"click\", e => dispatch(\"action\", data, e)],\n// ],\n// click: e => dispatch(\"action\", data, e)\n// }\n// ],\n// [\"button\",\n// {\n// on: [\"click\", e => dispatch(\"action\", data, e)],\n// click: e => dispatch(\"action\", data, e)\n// },\n// [\"Send\"]\n// ]\n// ];\n\n// console.log(hsmls2htmls(hmls, true).join(\"\"));\n"],"sourceRoot":""}