@hyperspan/framework
Advanced tools
Comparing version 0.0.2 to 0.0.3
var __create = Object.create; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __defProp = Object.defineProperty; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
@@ -21,3 +21,3 @@ var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var require_escape_html = __commonJS((exports, module) => { | ||
var escapeHtml = function(string) { | ||
function escapeHtml(string) { | ||
var str = "" + string; | ||
@@ -59,3 +59,3 @@ var match = matchHtmlRegExp.exec(str); | ||
return lastIndex !== index ? html + str.substring(lastIndex, index) : html; | ||
}; | ||
} | ||
/*! | ||
@@ -76,3 +76,3 @@ * escape-html | ||
// src/clientjs/md5.js | ||
var md5cycle = function(x, k) { | ||
function md5cycle(x, k) { | ||
var a = x[0], b = x[1], c = x[2], d = x[3]; | ||
@@ -147,20 +147,20 @@ a = ff(a, b, c, d, k[0], 7, -680876936); | ||
x[3] = add32(d, x[3]); | ||
}; | ||
var cmn = function(q, a, b, x, s, t) { | ||
} | ||
function cmn(q, a, b, x, s, t) { | ||
a = add32(add32(a, q), add32(x, t)); | ||
return add32(a << s | a >>> 32 - s, b); | ||
}; | ||
var ff = function(a, b, c, d, x, s, t) { | ||
} | ||
function ff(a, b, c, d, x, s, t) { | ||
return cmn(b & c | ~b & d, a, b, x, s, t); | ||
}; | ||
var gg = function(a, b, c, d, x, s, t) { | ||
} | ||
function gg(a, b, c, d, x, s, t) { | ||
return cmn(b & d | c & ~d, a, b, x, s, t); | ||
}; | ||
var hh = function(a, b, c, d, x, s, t) { | ||
} | ||
function hh(a, b, c, d, x, s, t) { | ||
return cmn(b ^ c ^ d, a, b, x, s, t); | ||
}; | ||
var ii = function(a, b, c, d, x, s, t) { | ||
} | ||
function ii(a, b, c, d, x, s, t) { | ||
return cmn(c ^ (b | ~d), a, b, x, s, t); | ||
}; | ||
var md51 = function(s) { | ||
} | ||
function md51(s) { | ||
var txt = ""; | ||
@@ -184,4 +184,4 @@ var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i; | ||
return state; | ||
}; | ||
var md5blk = function(s) { | ||
} | ||
function md5blk(s) { | ||
var md5blks = [], i; | ||
@@ -192,4 +192,4 @@ for (i = 0;i < 64; i += 4) { | ||
return md5blks; | ||
}; | ||
var rhex = function(n) { | ||
} | ||
function rhex(n) { | ||
var s = "", j = 0; | ||
@@ -199,11 +199,11 @@ for (;j < 4; j++) | ||
return s; | ||
}; | ||
var hex = function(x) { | ||
} | ||
function hex(x) { | ||
for (var i = 0;i < x.length; i++) | ||
x[i] = rhex(x[i]); | ||
return x.join(""); | ||
}; | ||
var add32 = function(a, b) { | ||
} | ||
function add32(a, b) { | ||
return a + b & 4294967295; | ||
}; | ||
} | ||
function md5(s) { | ||
@@ -242,3 +242,3 @@ return hex(md51(s)); | ||
} | ||
if (value instanceof HSTemplate) { | ||
if (value instanceof HSTemplate || value.__hsTemplate) { | ||
yield* renderToStream(value); | ||
@@ -280,2 +280,5 @@ } else if (typeof value.render !== "undefined") { | ||
break; | ||
case "number": | ||
yield String(value); | ||
break; | ||
case "object": | ||
@@ -334,5 +337,5 @@ if (typeof value.render === "function") { | ||
} | ||
var randomId = function() { | ||
function randomId() { | ||
return Math.random().toString(36).substring(2, 9); | ||
}; | ||
} | ||
function _typeOf(obj) { | ||
@@ -365,8 +368,8 @@ if (obj instanceof Promise) | ||
} | ||
var isGenerator = function(obj) { | ||
function isGenerator(obj) { | ||
return obj && typeof obj.next == "function" && typeof obj.throw == "function"; | ||
}; | ||
var isPlainObject = function(val) { | ||
} | ||
function isPlainObject(val) { | ||
return Object == val.constructor; | ||
}; | ||
} | ||
function clientComponent(id, wc) { | ||
@@ -428,3 +431,3 @@ const comp = { | ||
} | ||
var renderObjectToLiteralString = function(obj) { | ||
function renderObjectToLiteralString(obj) { | ||
const lines = []; | ||
@@ -459,3 +462,3 @@ let str = 'hyperspan.wc.set("' + obj.id + '", {\n'; | ||
return str; | ||
}; | ||
} | ||
var IS_CLIENT = typeof window !== "undefined"; | ||
@@ -462,0 +465,0 @@ |
var __create = Object.create; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __defProp = Object.defineProperty; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
@@ -21,3 +21,3 @@ var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var require_escape_html = __commonJS((exports, module) => { | ||
var escapeHtml = function(string) { | ||
function escapeHtml(string) { | ||
var str = "" + string; | ||
@@ -59,3 +59,3 @@ var match = matchHtmlRegExp.exec(str); | ||
return lastIndex !== index ? html + str.substring(lastIndex, index) : html; | ||
}; | ||
} | ||
/*! | ||
@@ -304,3 +304,3 @@ * escape-html | ||
var require_deepmerge = __commonJS((exports, module) => { | ||
var deepmergeConstructor = function(options) { | ||
function deepmergeConstructor(options) { | ||
function isNotPrototypeKey(value) { | ||
@@ -409,3 +409,3 @@ return value !== "constructor" && value !== "prototype" && value !== "__proto__"; | ||
return options && options.all ? _deepmergeAll : _deepmerge; | ||
}; | ||
} | ||
var JSON_PROTO = Object.getPrototypeOf({}); | ||
@@ -418,4 +418,4 @@ module.exports = deepmergeConstructor; | ||
// src/server.ts | ||
import {readdir} from "node:fs/promises"; | ||
import {basename, extname, join, resolve} from "node:path"; | ||
import { readdir } from "node:fs/promises"; | ||
import { basename, extname, join, resolve } from "node:path"; | ||
@@ -426,3 +426,3 @@ // src/html.ts | ||
// src/clientjs/md5.js | ||
var md5cycle = function(x, k) { | ||
function md5cycle(x, k) { | ||
var a = x[0], b = x[1], c = x[2], d = x[3]; | ||
@@ -497,20 +497,20 @@ a = ff(a, b, c, d, k[0], 7, -680876936); | ||
x[3] = add32(d, x[3]); | ||
}; | ||
var cmn = function(q, a, b, x, s, t) { | ||
} | ||
function cmn(q, a, b, x, s, t) { | ||
a = add32(add32(a, q), add32(x, t)); | ||
return add32(a << s | a >>> 32 - s, b); | ||
}; | ||
var ff = function(a, b, c, d, x, s, t) { | ||
} | ||
function ff(a, b, c, d, x, s, t) { | ||
return cmn(b & c | ~b & d, a, b, x, s, t); | ||
}; | ||
var gg = function(a, b, c, d, x, s, t) { | ||
} | ||
function gg(a, b, c, d, x, s, t) { | ||
return cmn(b & d | c & ~d, a, b, x, s, t); | ||
}; | ||
var hh = function(a, b, c, d, x, s, t) { | ||
} | ||
function hh(a, b, c, d, x, s, t) { | ||
return cmn(b ^ c ^ d, a, b, x, s, t); | ||
}; | ||
var ii = function(a, b, c, d, x, s, t) { | ||
} | ||
function ii(a, b, c, d, x, s, t) { | ||
return cmn(c ^ (b | ~d), a, b, x, s, t); | ||
}; | ||
var md51 = function(s) { | ||
} | ||
function md51(s) { | ||
var txt = ""; | ||
@@ -534,4 +534,4 @@ var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i; | ||
return state; | ||
}; | ||
var md5blk = function(s) { | ||
} | ||
function md5blk(s) { | ||
var md5blks = [], i; | ||
@@ -542,4 +542,4 @@ for (i = 0;i < 64; i += 4) { | ||
return md5blks; | ||
}; | ||
var rhex = function(n) { | ||
} | ||
function rhex(n) { | ||
var s = "", j = 0; | ||
@@ -549,11 +549,11 @@ for (;j < 4; j++) | ||
return s; | ||
}; | ||
var hex = function(x) { | ||
} | ||
function hex(x) { | ||
for (var i = 0;i < x.length; i++) | ||
x[i] = rhex(x[i]); | ||
return x.join(""); | ||
}; | ||
var add32 = function(a, b) { | ||
} | ||
function add32(a, b) { | ||
return a + b & 4294967295; | ||
}; | ||
} | ||
function md5(s) { | ||
@@ -592,3 +592,3 @@ return hex(md51(s)); | ||
} | ||
if (value instanceof HSTemplate) { | ||
if (value instanceof HSTemplate || value.__hsTemplate) { | ||
yield* renderToStream(value); | ||
@@ -630,2 +630,5 @@ } else if (typeof value.render !== "undefined") { | ||
break; | ||
case "number": | ||
yield String(value); | ||
break; | ||
case "object": | ||
@@ -681,5 +684,5 @@ if (typeof value.render === "function") { | ||
} | ||
var randomId = function() { | ||
function randomId() { | ||
return Math.random().toString(36).substring(2, 9); | ||
}; | ||
} | ||
function _typeOf(obj) { | ||
@@ -712,8 +715,8 @@ if (obj instanceof Promise) | ||
} | ||
var isGenerator = function(obj) { | ||
function isGenerator(obj) { | ||
return obj && typeof obj.next == "function" && typeof obj.throw == "function"; | ||
}; | ||
var isPlainObject = function(val) { | ||
} | ||
function isPlainObject(val) { | ||
return Object == val.constructor; | ||
}; | ||
} | ||
function renderFunctionToString(fn) { | ||
@@ -751,3 +754,3 @@ let fns = fn.toString(); | ||
// node_modules/isbot/index.mjs | ||
var getPattern = function() { | ||
function getPattern() { | ||
if (pattern instanceof RegExp) { | ||
@@ -762,6 +765,6 @@ return pattern; | ||
return pattern; | ||
}; | ||
var isbot = function(userAgent) { | ||
} | ||
function isbot(userAgent) { | ||
return Boolean(userAgent) && getPattern().test(userAgent); | ||
}; | ||
} | ||
var fullPattern = " daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|^<|^[\\w \\.\\-\\(?:\\):]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/5\\.0\\s[a-z\\.-]+$|^mozilla/\\d\\.\\d \\(compatible;?\\)$|^mozilla/\\d\\.\\d \\w*$|^navermailapp|^netsurf|^offline|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^valid|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|images|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|reputation|resolver|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|trace|transcoder|url|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab"; | ||
@@ -774,3 +777,3 @@ var naivePattern = /bot|crawl|http|lighthouse|scan|search|spider/i; | ||
var import_trek_middleware = __toESM(require_trek_middleware(), 1); | ||
var deepmerge = __toESM(require_deepmerge(), 1); | ||
var import_deepmerge = __toESM(require_deepmerge(), 1); | ||
@@ -1042,3 +1045,3 @@ // node_modules/@mjackson/headers/dist/lib/param-values.js | ||
// node_modules/@mjackson/headers/dist/lib/content-disposition.js | ||
var decodeFilenameSplat = function(value) { | ||
function decodeFilenameSplat(value) { | ||
let match = value.match(/^([\w-]+)'([^']*)'(.+)$/); | ||
@@ -1057,8 +1060,8 @@ if (!match) | ||
} | ||
}; | ||
var percentDecode = function(value) { | ||
} | ||
function percentDecode(value) { | ||
return value.replace(/\+/g, " ").replace(/%([0-9A-Fa-f]{2})/g, (_, hex2) => { | ||
return String.fromCharCode(parseInt(hex2, 16)); | ||
}); | ||
}; | ||
} | ||
@@ -1623,3 +1626,3 @@ class ContentDisposition { | ||
} | ||
var mergeAll = deepmerge.default({ all: true }); | ||
var mergeAll = import_deepmerge.default({ all: true }); | ||
@@ -1729,6 +1732,6 @@ class HSRequestContext { | ||
// src/server.ts | ||
var requestIsBot = function(req) { | ||
function requestIsBot(req) { | ||
const ua = req.headers.get("User-Agent"); | ||
return ua ? isbot(ua) : false; | ||
}; | ||
} | ||
async function runFileRoute(routeFile, context) { | ||
@@ -1831,3 +1834,3 @@ const req = context.req; | ||
routes.push({ | ||
file, | ||
file: join("./", routesDir, file), | ||
route: route || "/", | ||
@@ -1841,7 +1844,7 @@ params | ||
await Promise.all([buildClientJS(), buildClientCSS()]); | ||
const app2 = new HSApp; | ||
app2.defaultRoute(() => { | ||
const app = new HSApp; | ||
app.defaultRoute(() => { | ||
return new Response("Not... found?", { status: 404 }); | ||
}); | ||
config.beforeRoutesAdded && config.beforeRoutesAdded(app2); | ||
config.beforeRoutesAdded && config.beforeRoutesAdded(app); | ||
const fileRoutes = await buildRoutes(config); | ||
@@ -1851,6 +1854,6 @@ const routeMap = []; | ||
let route = fileRoutes[i]; | ||
const fullRouteFile = join("../../", config.appDir, "routes", route.file); | ||
const fullRouteFile = join(CWD, route.file); | ||
const routePattern = normalizePath(route.route); | ||
routeMap.push({ route: routePattern, file: config.appDir + "/routes/" + route.file }); | ||
app2.all(routePattern, async (context) => { | ||
routeMap.push({ route: routePattern, file: route.file }); | ||
app.all(routePattern, async (context) => { | ||
const matchedRoute = await runFileRoute(fullRouteFile, context); | ||
@@ -1860,3 +1863,3 @@ if (matchedRoute) { | ||
} | ||
return app2._defaultRoute(context); | ||
return app._defaultRoute(context); | ||
}); | ||
@@ -1868,4 +1871,4 @@ } | ||
} | ||
config.afterRoutesAdded && config.afterRoutesAdded(app2); | ||
app2.all("*", (context) => { | ||
config.afterRoutesAdded && config.afterRoutesAdded(app); | ||
app.all("*", (context) => { | ||
const req = context.req; | ||
@@ -1875,16 +1878,16 @@ if (STATIC_FILE_MATCHER.test(req.url)) { | ||
const file = Bun.file(filePath); | ||
let headers2 = {}; | ||
let headers = {}; | ||
if (IS_PROD) { | ||
headers2 = { | ||
headers = { | ||
"cache-control": "public, max-age=31557600" | ||
}; | ||
} | ||
return new Response(file, { headers: headers2 }); | ||
return new Response(file, { headers }); | ||
} | ||
return app2._defaultRoute(context); | ||
return app._defaultRoute(context); | ||
}); | ||
return app2; | ||
return app; | ||
} | ||
async function buildClientJS() { | ||
const sourceFile = resolve(CWD, "../", "./src/clientjs/hyperspan-client.ts"); | ||
const sourceFile = resolve(PWD, "../", "./src/clientjs/hyperspan-client.ts"); | ||
const output = await Bun.build({ | ||
@@ -1935,3 +1938,4 @@ entrypoints: [sourceFile], | ||
var IS_PROD = false; | ||
var CWD = import.meta.dir; | ||
var PWD = import.meta.dir; | ||
var CWD = process.cwd(); | ||
var STATIC_FILE_MATCHER = /[^/\\&\?]+\.([a-zA-Z]+)$/; | ||
@@ -1938,0 +1942,0 @@ var _routeCache = {}; |
{ | ||
"name": "@hyperspan/framework", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Hyperspan Web Framework", | ||
@@ -45,8 +45,8 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/bun": "^1.1.9", | ||
"@types/bun": "^1.1.11", | ||
"@types/escape-html": "^1.0.4", | ||
"@types/node": "^22.5.5", | ||
"bun-plugin-dts": "^0.2.3", | ||
"typescript": "^5.6.2" | ||
"@types/node": "^22.7.5", | ||
"bun-plugin-dts": "^0.3.0", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
@@ -5,6 +5,6 @@ # Hyperspan. Simple. Full-Stack. Streaming. | ||
Hyperspan is a full-stack framework built with [Bun](https://bun.sh) that is focused on simplicity and ease of use. | ||
No JSX. No Virtual DOM. No hydration time. No nonsense. Just blazing fast HTML strings with reactive templates. | ||
Hyperspan is a full-stack framework built with [Bun](https://bun.sh) that is focused on simplicity and perforamnce. | ||
## Who Is Hyperspan For? | ||
@@ -11,0 +11,0 @@ |
@@ -71,3 +71,3 @@ import escapeHTML from 'escape-html'; | ||
if (value instanceof HSTemplate) { | ||
if (value instanceof HSTemplate || value.__hsTemplate) { | ||
yield* renderToStream(value); | ||
@@ -112,2 +112,5 @@ } else if (typeof value.render !== 'undefined') { | ||
break; | ||
case 'number': | ||
yield String(value); | ||
break; | ||
case 'object': | ||
@@ -114,0 +117,0 @@ if (typeof value.render === 'function') { |
@@ -9,3 +9,4 @@ import { readdir } from 'node:fs/promises'; | ||
export const IS_PROD = process.env.NODE_ENV === 'production'; | ||
const CWD = import.meta.dir; | ||
const PWD = import.meta.dir; | ||
const CWD = process.cwd(); | ||
const STATIC_FILE_MATCHER = /[^/\\&\?]+\.([a-zA-Z]+)$/; | ||
@@ -193,3 +194,3 @@ | ||
routes.push({ | ||
file, | ||
file: join('./', routesDir, file), | ||
route: route || '/', | ||
@@ -225,6 +226,6 @@ params, | ||
let route = fileRoutes[i]; | ||
const fullRouteFile = join('../../', config.appDir, 'routes', route.file); | ||
const fullRouteFile = join(CWD, route.file); | ||
const routePattern = normalizePath(route.route); | ||
routeMap.push({ route: routePattern, file: config.appDir + '/routes/' + route.file }); | ||
routeMap.push({ route: routePattern, file: route.file }); | ||
@@ -280,3 +281,3 @@ app.all(routePattern, async (context) => { | ||
export async function buildClientJS() { | ||
const sourceFile = resolve(CWD, '../', './src/clientjs/hyperspan-client.ts'); | ||
const sourceFile = resolve(PWD, '../', './src/clientjs/hyperspan-client.ts'); | ||
const output = await Bun.build({ | ||
@@ -283,0 +284,0 @@ entrypoints: [sourceFile], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170237
4653
1