@sysce/stomp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # SystemYA's TOMP implementation (STomp)
2
+
3
+ This repository implements the proxy model found [here](https://github.com/tomphttp/specifications/blob/master/ProxyModel.md).
4
+
5
+ - [Demo](https://tomp.sys32.dev/)
6
+ - [Frontend](https://github.com/sysce/tomp-demo)
7
+
8
+ ## Usage
9
+
10
+ We provide a command-line interface for compiling the code.
11
+
12
+ For more features, specify the `--help` option when running the CLI.
13
+
14
+ ## Wiki
15
+
16
+ Documentation for components such as the Bootstrapper can be found in [the wiki](https://github.com/sysce/tomp/wiki).
17
+
18
+ ### Quickstart
19
+
20
+ 1. Clone the repository locally
21
+
22
+ ```sh
23
+ $ git clone https://github.com/sysce/stomp.git
24
+ > Cloning into stomp...
25
+ $ cd stomp
26
+ ```
27
+
28
+ 2. Install dependencies
29
+
30
+ ```sh
31
+ $ npm install
32
+ ```
33
+
34
+ 3. Build
35
+
36
+ ```sh
37
+ $ npm build
38
+ ```
@@ -0,0 +1,2 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StompBoot=e():t.StompBoot=e()}(self,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>s});const r=/\s/,o=/^https?:\/\//;class s{static SearchBuilder=class{constructor(t){this.template=String(t)}query(t){return(t=String(t)).match(o)?t:t.includes(".")&&!t.match(r)?`http://${t}`:this.template.replace("%s",encodeURIComponent(t))}};static CODEC_XOR=1;static CODEC_PLAIN=0;static LOG_TRACE=0;static LOG_DEBUG=1;static LOG_INFO=2;static LOG_WARN=3;static LOG_ERROR=4;static LOG_SILENT=5;constructor(t){if("string"!=typeof t.directory)throw new TypeError("Directory must be a string");this.config=t,this.ready=this.register()}async register(){if(!("serviceWorker"in navigator))throw new Error("Your browser does not support service workers.");const t=`${this.config.directory}worker.js?config=${encodeURIComponent(JSON.stringify(this.config))}`;this.worker=await navigator.serviceWorker.register(t,{scope:this.config.directory,updateViaCache:"none"}),await this.worker.update(),this.config.loglevel<=1&&console.debug("Registered the service worker.")}#t(t,e){return`${this.config.directory}process:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}html(t){return this.#t("html",t)}css(t){return this.#t("css",t)}js(t){return this.#t("js",t)}binary(t){return this.#t("binary",t)}}return e.default})()));
2
+ //# sourceMappingURL=bootstrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrapper.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAmB,UAAID,IAEvBD,EAAgB,UAAIC,GACrB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,4BCAlF,MAAMI,EAAa,KACbC,EAAkB,eCUT,MAAMC,EACpBC,qBDTc,MACdC,YAAYC,GACXC,KAAKD,SAAWE,OAAOF,EACxB,CACAG,MAAMC,GAGL,OAFAA,EAAQF,OAAOE,IAELC,MAAMT,GACRQ,EACGA,EAAME,SAAS,OAASF,EAAMC,MAAMV,GACvC,UAAUS,IAEVH,KAAKD,SAASO,QAAQ,KAAMC,mBAAmBJ,GAExD,GCHAN,iBCbwB,EDcxBA,mBCf0B,EDgB1BA,iBEhBwB,EFiBxBA,iBEhBwB,EFiBxBA,gBEhBuB,EFiBvBA,gBEhBuB,EFiBvBA,iBEhBwB,EFiBxBA,kBEhByB,EFiBzBC,YAAYU,GACX,GAAgC,iBAArBA,EAAOC,UACjB,MAAM,IAAIC,UAAU,8BAGrBV,KAAKQ,OAASA,EAEdR,KAAKW,MAAQX,KAAKY,UACnB,CACAC,iBACC,KAAM,kBAAmBC,WACxB,MAAM,IAAIC,MAAM,kDAMjB,MAAMC,EAAM,GAAGhB,KAAKQ,OAAOC,6BAA6BF,mBACvDU,KAAKC,UAAUlB,KAAKQ,WAGrBR,KAAKmB,aAAeL,UAAUM,cAAcR,SAASI,EAAK,CACzDK,MAAOrB,KAAKQ,OAAOC,UACnBa,eAAgB,eAGXtB,KAAKmB,OAAOI,SAEdvB,KAAKQ,OAAOgB,UEjDO,GFkDtBC,QAAQC,MAAM,iCAEhB,CACA,GAAMC,EAASX,GACd,MAAO,GAAGhB,KAAKQ,OAAOC,oBAAoBF,mBACzCoB,MACIpB,mBAAmBS,IACzB,CACAY,KAAKZ,GACJ,OAAOhB,MAAK,EAAM,OAAQgB,EAC3B,CACAa,IAAIb,GACH,OAAOhB,MAAK,EAAM,MAAOgB,EAC1B,CACAc,GAAGd,GACF,OAAOhB,MAAK,EAAM,KAAMgB,EACzB,CACAe,OAAOf,GACN,OAAOhB,MAAK,EAAM,SAAUgB,EAC7B,E","sources":["webpack://StompBoot/webpack/universalModuleDefinition","webpack://StompBoot/webpack/bootstrap","webpack://StompBoot/webpack/runtime/define property getters","webpack://StompBoot/webpack/runtime/hasOwnProperty shorthand","webpack://StompBoot/./src/Bootstrapper/SearchBuilder.js","webpack://StompBoot/./src/Bootstrapper/Bootstrapper.js","webpack://StompBoot/./src/TOMPConstants.js","webpack://StompBoot/./src/LoggerConstants.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 if(typeof exports === 'object')\n\t\texports[\"StompBoot\"] = factory();\n\telse\n\t\troot[\"StompBoot\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","const whitespace = /\\s/;\nconst http_s_protocol = /^https?:\\/\\//;\n\nexport default class SearchBuilder {\n\tconstructor(template) {\n\t\tthis.template = String(template);\n\t}\n\tquery(input) {\n\t\tinput = String(input);\n\n\t\tif (input.match(http_s_protocol)) {\n\t\t\treturn input;\n\t\t} else if (input.includes('.') && !input.match(whitespace)) {\n\t\t\treturn `http://${input}`;\n\t\t} else {\n\t\t\treturn this.template.replace('%s', encodeURIComponent(input));\n\t\t}\n\t}\n}\n","import SearchBuilder from './SearchBuilder.js';\nimport {\n\tLOG_TRACE,\n\tLOG_DEBUG,\n\tLOG_INFO,\n\tLOG_WARN,\n\tLOG_ERROR,\n\tLOG_SILENT,\n} from '../LoggerConstants.js';\nimport { CODEC_PLAIN, CODEC_XOR } from '../TOMPConstants.js';\n\nexport default class Bootstrapper {\n\tstatic SearchBuilder = SearchBuilder;\n\t// expose constants\n\tstatic CODEC_XOR = CODEC_XOR;\n\tstatic CODEC_PLAIN = CODEC_PLAIN;\n\tstatic LOG_TRACE = LOG_TRACE;\n\tstatic LOG_DEBUG = LOG_DEBUG;\n\tstatic LOG_INFO = LOG_INFO;\n\tstatic LOG_WARN = LOG_WARN;\n\tstatic LOG_ERROR = LOG_ERROR;\n\tstatic LOG_SILENT = LOG_SILENT;\n\tconstructor(config) {\n\t\tif (typeof config.directory !== 'string') {\n\t\t\tthrow new TypeError(`Directory must be a string`);\n\t\t}\n\n\t\tthis.config = config;\n\n\t\tthis.ready = this.register();\n\t}\n\tasync register() {\n\t\tif (!('serviceWorker' in navigator))\n\t\t\tthrow new Error('Your browser does not support service workers.');\n\n\t\t/*for(let worker of await navigator.serviceWorker.getRegistrations()){\n\t\t\tawait worker.unregister();\n\t\t}*/\n\n\t\tconst url = `${this.config.directory}worker.js?config=${encodeURIComponent(\n\t\t\tJSON.stringify(this.config)\n\t\t)}`;\n\n\t\tthis.worker = await navigator.serviceWorker.register(url, {\n\t\t\tscope: this.config.directory,\n\t\t\tupdateViaCache: 'none',\n\t\t});\n\n\t\tawait this.worker.update();\n\n\t\tif (this.config.loglevel <= LOG_DEBUG) {\n\t\t\tconsole.debug('Registered the service worker.');\n\t\t}\n\t}\n\t#send(service, url) {\n\t\treturn `${this.config.directory}process:${encodeURIComponent(\n\t\t\tservice\n\t\t)}:${encodeURIComponent(url)}`;\n\t}\n\thtml(url) {\n\t\treturn this.#send('html', url);\n\t}\n\tcss(url) {\n\t\treturn this.#send('css', url);\n\t}\n\tjs(url) {\n\t\treturn this.#send('js', url);\n\t}\n\tbinary(url) {\n\t\treturn this.#send('binary', url);\n\t}\n}\n","export const CODEC_PLAIN = 0;\nexport const CODEC_XOR = 1;\n","export const LOG_TRACE = 0;\nexport const LOG_DEBUG = 1;\nexport const LOG_INFO = 2;\nexport const LOG_WARN = 3;\nexport const LOG_ERROR = 4;\nexport const LOG_SILENT = 5;\n\n/**\n * @typedef {LOG_TRACE|LOG_DEBUG|LOG_INFO|LOG_WARN|LOG_ERROR|LOG_SILENT} LOG_LEVELS\n */\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","whitespace","http_s_protocol","Bootstrapper","static","constructor","template","this","String","query","input","match","includes","replace","encodeURIComponent","config","directory","TypeError","ready","register","async","navigator","Error","url","JSON","stringify","worker","serviceWorker","scope","updateViaCache","update","loglevel","console","debug","service","html","css","js","binary"],"sourceRoot":""}