| //#region node_modules/.pnpm/cookie-es@3.1.1/node_modules/cookie-es/dist/index.d.mts | ||
| /** | ||
| * Stringify options. | ||
| */ | ||
| interface CookieStringifyOptions { | ||
| /** | ||
| * Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). | ||
| * Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode | ||
| * a value into a string suited for a cookie's value, and should mirror `decode` when parsing. | ||
| * | ||
| * @default encodeURIComponent | ||
| */ | ||
| encode?: (str: string) => string; | ||
| /** | ||
| * Specifies a function that will be used to coerce non-string values to a string. | ||
| * | ||
| * @default JSON.stringify | ||
| */ | ||
| stringify?: (value: unknown) => string; | ||
| } | ||
| /** | ||
| * Set-Cookie object. | ||
| */ | ||
| interface SetCookie { | ||
| /** | ||
| * Specifies the name of the cookie. | ||
| */ | ||
| name: string; | ||
| /** | ||
| * Specifies the string to be the value for the cookie. | ||
| */ | ||
| value: string | undefined; | ||
| /** | ||
| * Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2). | ||
| * | ||
| * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and | ||
| * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this, | ||
| * so if both are set, they should point to the same date and time. | ||
| */ | ||
| maxAge?: number; | ||
| /** | ||
| * Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1). | ||
| * When no expiration is set, clients consider this a "non-persistent cookie" and delete it when the current session is over. | ||
| * | ||
| * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and | ||
| * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this, | ||
| * so if both are set, they should point to the same date and time. | ||
| */ | ||
| expires?: Date; | ||
| /** | ||
| * Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3). | ||
| * When no domain is set, clients consider the cookie to apply to the current domain only. | ||
| */ | ||
| domain?: string; | ||
| /** | ||
| * Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4). | ||
| * When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4). | ||
| */ | ||
| path?: string; | ||
| /** | ||
| * Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6). | ||
| * When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`. | ||
| */ | ||
| httpOnly?: boolean; | ||
| /** | ||
| * Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5). | ||
| * When enabled, clients will only send the cookie back if the browser has an HTTPS connection. | ||
| */ | ||
| secure?: boolean; | ||
| /** | ||
| * Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/). | ||
| * When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches. | ||
| * | ||
| * This is an attribute that has not yet been fully standardized, and may change in the future. | ||
| * This also means clients may ignore this attribute until they understand it. More information | ||
| * about can be found in [the proposal](https://github.com/privacycg/CHIPS). | ||
| */ | ||
| partitioned?: boolean; | ||
| /** | ||
| * Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1). | ||
| * | ||
| * - `'low'` will set the `Priority` attribute to `Low`. | ||
| * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set. | ||
| * - `'high'` will set the `Priority` attribute to `High`. | ||
| * | ||
| * More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1). | ||
| */ | ||
| priority?: "low" | "medium" | "high"; | ||
| /** | ||
| * Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7). | ||
| * | ||
| * - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement. | ||
| * - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement. | ||
| * - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie. | ||
| * - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement. | ||
| * | ||
| * More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7). | ||
| */ | ||
| sameSite?: boolean | "lax" | "strict" | "none"; | ||
| } | ||
| /** | ||
| * Backward compatibility serialize options. | ||
| */ | ||
| type CookieSerializeOptions = CookieStringifyOptions & Omit<SetCookie, "name" | "value">; | ||
| /** | ||
| * Parse a `Cookie` header string into an object. | ||
| * | ||
| * The object has cookie names as keys and decoded values as values. | ||
| * First occurrence wins for duplicate names unless `allowMultiple` is set. | ||
| * | ||
| * @param str - The `Cookie` header string to parse. | ||
| * @param options - Parsing options (`decode`, `filter`, `allowMultiple`). | ||
| * @returns A prototype-less object of cookie name-value pairs. | ||
| */ | ||
| //#endregion | ||
| export { CookieSerializeOptions as t }; |
| //#region node_modules/.pnpm/cookie-es@3.1.1/node_modules/cookie-es/dist/index.mjs | ||
| const COOKIE_MAX_AGE_LIMIT = 3456e4; | ||
| function endIndex(str, min, len) { | ||
| const index = str.indexOf(";", min); | ||
| return index === -1 ? len : index; | ||
| } | ||
| function eqIndex(str, min, max) { | ||
| const index = str.indexOf("=", min); | ||
| return index < max ? index : -1; | ||
| } | ||
| function valueSlice(str, min, max) { | ||
| if (min === max) return ""; | ||
| let start = min; | ||
| let end = max; | ||
| do { | ||
| const code = str.charCodeAt(start); | ||
| if (code !== 32 && code !== 9) break; | ||
| } while (++start < end); | ||
| while (end > start) { | ||
| const code = str.charCodeAt(end - 1); | ||
| if (code !== 32 && code !== 9) break; | ||
| end--; | ||
| } | ||
| return str.slice(start, end); | ||
| } | ||
| const NullObject = /* @__PURE__ */ (() => { | ||
| const C = function() {}; | ||
| C.prototype = Object.create(null); | ||
| return C; | ||
| })(); | ||
| function parse(str, options) { | ||
| const obj = new NullObject(); | ||
| const len = str.length; | ||
| if (len < 2) return obj; | ||
| const dec = options?.decode || decode; | ||
| const allowMultiple = options?.allowMultiple || false; | ||
| let index = 0; | ||
| do { | ||
| const eqIdx = eqIndex(str, index, len); | ||
| if (eqIdx === -1) break; | ||
| const endIdx = endIndex(str, index, len); | ||
| if (eqIdx > endIdx) { | ||
| index = str.lastIndexOf(";", eqIdx - 1) + 1; | ||
| continue; | ||
| } | ||
| const key = valueSlice(str, index, eqIdx); | ||
| if (options?.filter && !options.filter(key)) { | ||
| index = endIdx + 1; | ||
| continue; | ||
| } | ||
| const val = dec(valueSlice(str, eqIdx + 1, endIdx)); | ||
| if (allowMultiple) { | ||
| const existing = obj[key]; | ||
| if (existing === void 0) obj[key] = val; | ||
| else if (Array.isArray(existing)) existing.push(val); | ||
| else obj[key] = [existing, val]; | ||
| } else if (obj[key] === void 0) obj[key] = val; | ||
| index = endIdx + 1; | ||
| } while (index < len); | ||
| return obj; | ||
| } | ||
| function decode(str) { | ||
| if (!str.includes("%")) return str; | ||
| try { | ||
| return decodeURIComponent(str); | ||
| } catch { | ||
| return str; | ||
| } | ||
| } | ||
| const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/; | ||
| const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/; | ||
| const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i; | ||
| const pathValueRegExp = /^[\u0020-\u003A\u003C-\u007E]*$/; | ||
| const __toString = Object.prototype.toString; | ||
| function serialize(_a0, _a1, _a2) { | ||
| const isObj = typeof _a0 === "object" && _a0 !== null; | ||
| const options = isObj ? _a1 : _a2; | ||
| const stringify = options?.stringify || JSON.stringify; | ||
| const cookie = isObj ? _a0 : { | ||
| ..._a2, | ||
| name: _a0, | ||
| value: _a1 == void 0 ? "" : typeof _a1 === "string" ? _a1 : stringify(_a1) | ||
| }; | ||
| const enc = options?.encode || encodeURIComponent; | ||
| if (!cookieNameRegExp.test(cookie.name)) throw new TypeError(`argument name is invalid: ${cookie.name}`); | ||
| const value = cookie.value ? enc(cookie.value) : ""; | ||
| if (!cookieValueRegExp.test(value)) throw new TypeError(`argument val is invalid: ${cookie.value}`); | ||
| if (!cookie.secure) { | ||
| if (cookie.partitioned) throw new TypeError(`Partitioned cookies must have the Secure attribute`); | ||
| if (cookie.sameSite && String(cookie.sameSite).toLowerCase() === "none") throw new TypeError(`SameSite=None cookies must have the Secure attribute`); | ||
| if (cookie.name.length > 9 && cookie.name.charCodeAt(0) === 95 && cookie.name.charCodeAt(1) === 95) { | ||
| const nameLower = cookie.name.toLowerCase(); | ||
| if (nameLower.startsWith("__secure-") || nameLower.startsWith("__host-")) throw new TypeError(`${cookie.name} cookies must have the Secure attribute`); | ||
| } | ||
| } | ||
| if (cookie.name.length > 7 && cookie.name.charCodeAt(0) === 95 && cookie.name.charCodeAt(1) === 95 && cookie.name.toLowerCase().startsWith("__host-")) { | ||
| if (cookie.path !== "/") throw new TypeError(`__Host- cookies must have Path=/`); | ||
| if (cookie.domain) throw new TypeError(`__Host- cookies must not have a Domain attribute`); | ||
| } | ||
| let str = cookie.name + "=" + value; | ||
| if (cookie.maxAge !== void 0) { | ||
| if (!Number.isInteger(cookie.maxAge)) throw new TypeError(`option maxAge is invalid: ${cookie.maxAge}`); | ||
| str += "; Max-Age=" + Math.max(0, Math.min(cookie.maxAge, COOKIE_MAX_AGE_LIMIT)); | ||
| } | ||
| if (cookie.domain) { | ||
| if (!domainValueRegExp.test(cookie.domain)) throw new TypeError(`option domain is invalid: ${cookie.domain}`); | ||
| str += "; Domain=" + cookie.domain; | ||
| } | ||
| if (cookie.path) { | ||
| if (!pathValueRegExp.test(cookie.path)) throw new TypeError(`option path is invalid: ${cookie.path}`); | ||
| str += "; Path=" + cookie.path; | ||
| } | ||
| if (cookie.expires) { | ||
| if (!isDate(cookie.expires) || !Number.isFinite(cookie.expires.valueOf())) throw new TypeError(`option expires is invalid: ${cookie.expires}`); | ||
| str += "; Expires=" + cookie.expires.toUTCString(); | ||
| } | ||
| if (cookie.httpOnly) str += "; HttpOnly"; | ||
| if (cookie.secure) str += "; Secure"; | ||
| if (cookie.partitioned) str += "; Partitioned"; | ||
| if (cookie.priority) switch (typeof cookie.priority === "string" ? cookie.priority.toLowerCase() : void 0) { | ||
| case "low": | ||
| str += "; Priority=Low"; | ||
| break; | ||
| case "medium": | ||
| str += "; Priority=Medium"; | ||
| break; | ||
| case "high": | ||
| str += "; Priority=High"; | ||
| break; | ||
| default: throw new TypeError(`option priority is invalid: ${cookie.priority}`); | ||
| } | ||
| if (cookie.sameSite) switch (typeof cookie.sameSite === "string" ? cookie.sameSite.toLowerCase() : cookie.sameSite) { | ||
| case true: | ||
| case "strict": | ||
| str += "; SameSite=Strict"; | ||
| break; | ||
| case "lax": | ||
| str += "; SameSite=Lax"; | ||
| break; | ||
| case "none": | ||
| str += "; SameSite=None"; | ||
| break; | ||
| default: throw new TypeError(`option sameSite is invalid: ${cookie.sameSite}`); | ||
| } | ||
| return str; | ||
| } | ||
| function isDate(val) { | ||
| return __toString.call(val) === "[object Date]"; | ||
| } | ||
| //#endregion | ||
| export { serialize as n, parse as t }; |
| # Licenses of Bundled Dependencies | ||
| The published artifact additionally contains code with the following licenses: | ||
| MIT | ||
| # Bundled Dependencies | ||
| ## cookie-es | ||
| License: MIT | ||
| Repository: https://github.com/unjs/cookie-es | ||
| > MIT License | ||
| > | ||
| > Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io> | ||
| > | ||
| > Cookie parsing based on https://github.com/jshttp/cookie | ||
| > Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com> | ||
| > Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com> | ||
| > | ||
| > Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser | ||
| > Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/) | ||
| > | ||
| > Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| > of this software and associated documentation files (the "Software"), to deal | ||
| > in the Software without restriction, including without limitation the rights | ||
| > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| > copies of the Software, and to permit persons to whom the Software is | ||
| > furnished to do so, subject to the following conditions: | ||
| > | ||
| > The above copyright notice and this permission notice shall be included in all | ||
| > copies or substantial portions of the Software. | ||
| > | ||
| > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| > SOFTWARE. | ||
| ## cookie-es | ||
| License: MIT | ||
| Repository: https://github.com/unjs/cookie-es | ||
| > MIT License | ||
| > | ||
| > Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io> | ||
| > | ||
| > Cookie parsing based on https://github.com/jshttp/cookie | ||
| > Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com> | ||
| > Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com> | ||
| > | ||
| > Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser | ||
| > Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/) | ||
| > | ||
| > Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| > of this software and associated documentation files (the "Software"), to deal | ||
| > in the Software without restriction, including without limitation the rights | ||
| > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| > copies of the Software, and to permit persons to whom the Software is | ||
| > furnished to do so, subject to the following conditions: | ||
| > | ||
| > The above copyright notice and this permission notice shall be included in all | ||
| > copies or substantial portions of the Software. | ||
| > | ||
| > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| > SOFTWARE. |
+6
-113
| #! /usr/bin/env node | ||
| import { n as serialize, t as parse } from "./_chunks/libs/cookie-es.mjs"; | ||
| import { resolve } from "node:path"; | ||
@@ -6,3 +7,2 @@ import { log } from "srvx/log"; | ||
| import { serveStatic } from "srvx/static"; | ||
| //#region src/parser.ts | ||
@@ -12,5 +12,5 @@ function parseTemplate(template) { | ||
| template = template.replace(/<script\s+server\s*>([\s\S]*?)<\/script>/gi, (_m, code) => `<?js${code}?>`); | ||
| template = template.replace(/{{\s*(.+)\s*}}|{{{\s*(.+)\s*}}}/g, (_m, code) => { | ||
| if (code[0] === "{") return `<?=${code.slice(1, -1).trim()}?>`; | ||
| return `<?=htmlspecialchars(${code.trim()})?>`; | ||
| template = template.replace(/{{{\s*([\s\S]+?)\s*}}}|{{\s*([\s\S]+?)\s*}}/g, (_m, raw, escaped) => { | ||
| if (raw) return `<?=${raw.trim()}?>`; | ||
| return `<?=htmlspecialchars(${escaped.trim()})?>`; | ||
| }); | ||
@@ -51,3 +51,2 @@ const tokens = []; | ||
| } | ||
| //#endregion | ||
@@ -123,3 +122,2 @@ //#region src/_runtime.ts | ||
| } | ||
| //#endregion | ||
@@ -191,107 +189,3 @@ //#region src/compiler.ts | ||
| } | ||
| //#endregion | ||
| //#region node_modules/.pnpm/cookie-es@2.0.0/node_modules/cookie-es/dist/index.mjs | ||
| function parse(str, options) { | ||
| if (typeof str !== "string") throw new TypeError("argument str must be a string"); | ||
| const obj = {}; | ||
| const opt = options || {}; | ||
| const dec = opt.decode || decode; | ||
| let index = 0; | ||
| while (index < str.length) { | ||
| const eqIdx = str.indexOf("=", index); | ||
| if (eqIdx === -1) break; | ||
| let endIdx = str.indexOf(";", index); | ||
| if (endIdx === -1) endIdx = str.length; | ||
| else if (endIdx < eqIdx) { | ||
| index = str.lastIndexOf(";", eqIdx - 1) + 1; | ||
| continue; | ||
| } | ||
| const key = str.slice(index, eqIdx).trim(); | ||
| if (opt?.filter && !opt?.filter(key)) { | ||
| index = endIdx + 1; | ||
| continue; | ||
| } | ||
| if (void 0 === obj[key]) { | ||
| let val = str.slice(eqIdx + 1, endIdx).trim(); | ||
| if (val.codePointAt(0) === 34) val = val.slice(1, -1); | ||
| obj[key] = tryDecode(val, dec); | ||
| } | ||
| index = endIdx + 1; | ||
| } | ||
| return obj; | ||
| } | ||
| function decode(str) { | ||
| return str.includes("%") ? decodeURIComponent(str) : str; | ||
| } | ||
| function tryDecode(str, decode2) { | ||
| try { | ||
| return decode2(str); | ||
| } catch { | ||
| return str; | ||
| } | ||
| } | ||
| const fieldContentRegExp = /^[\u0009\u0020-\u007E\u0080-\u00FF]+$/; | ||
| function serialize(name, value, options) { | ||
| const opt = options || {}; | ||
| const enc = opt.encode || encodeURIComponent; | ||
| if (typeof enc !== "function") throw new TypeError("option encode is invalid"); | ||
| if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid"); | ||
| const encodedValue = enc(value); | ||
| if (encodedValue && !fieldContentRegExp.test(encodedValue)) throw new TypeError("argument val is invalid"); | ||
| let str = name + "=" + encodedValue; | ||
| if (void 0 !== opt.maxAge && opt.maxAge !== null) { | ||
| const maxAge = opt.maxAge - 0; | ||
| if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid"); | ||
| str += "; Max-Age=" + Math.floor(maxAge); | ||
| } | ||
| if (opt.domain) { | ||
| if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid"); | ||
| str += "; Domain=" + opt.domain; | ||
| } | ||
| if (opt.path) { | ||
| if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid"); | ||
| str += "; Path=" + opt.path; | ||
| } | ||
| if (opt.expires) { | ||
| if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) throw new TypeError("option expires is invalid"); | ||
| str += "; Expires=" + opt.expires.toUTCString(); | ||
| } | ||
| if (opt.httpOnly) str += "; HttpOnly"; | ||
| if (opt.secure) str += "; Secure"; | ||
| if (opt.priority) switch (typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority) { | ||
| case "low": | ||
| str += "; Priority=Low"; | ||
| break; | ||
| case "medium": | ||
| str += "; Priority=Medium"; | ||
| break; | ||
| case "high": | ||
| str += "; Priority=High"; | ||
| break; | ||
| default: throw new TypeError("option priority is invalid"); | ||
| } | ||
| if (opt.sameSite) switch (typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite) { | ||
| case true: | ||
| str += "; SameSite=Strict"; | ||
| break; | ||
| case "lax": | ||
| str += "; SameSite=Lax"; | ||
| break; | ||
| case "strict": | ||
| str += "; SameSite=Strict"; | ||
| break; | ||
| case "none": | ||
| str += "; SameSite=None"; | ||
| break; | ||
| default: throw new TypeError("option sameSite is invalid"); | ||
| } | ||
| if (opt.partitioned) str += "; Partitioned"; | ||
| return str; | ||
| } | ||
| function isDate(val) { | ||
| return Object.prototype.toString.call(val) === "[object Date]" || val instanceof Date; | ||
| } | ||
| //#endregion | ||
| //#region src/render.ts | ||
@@ -370,3 +264,2 @@ /** | ||
| } | ||
| //#endregion | ||
@@ -406,3 +299,3 @@ //#region src/cli.ts | ||
| }); | ||
| //#endregion | ||
| //#endregion | ||
| export {}; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import { CookieSerializeOptions } from "cookie-es"; | ||
| import { t as CookieSerializeOptions } from "./_chunks/libs/cookie-es.mjs"; | ||
@@ -3,0 +3,0 @@ //#region src/compiler.d.ts |
+5
-112
@@ -0,3 +1,3 @@ | ||
| import { n as serialize, t as parse } from "./_chunks/libs/cookie-es.mjs"; | ||
| import { FastResponse } from "srvx"; | ||
| //#region src/parser.ts | ||
@@ -7,5 +7,5 @@ function parseTemplate(template) { | ||
| template = template.replace(/<script\s+server\s*>([\s\S]*?)<\/script>/gi, (_m, code) => `<?js${code}?>`); | ||
| template = template.replace(/{{\s*(.+)\s*}}|{{{\s*(.+)\s*}}}/g, (_m, code) => { | ||
| if (code[0] === "{") return `<?=${code.slice(1, -1).trim()}?>`; | ||
| return `<?=htmlspecialchars(${code.trim()})?>`; | ||
| template = template.replace(/{{{\s*([\s\S]+?)\s*}}}|{{\s*([\s\S]+?)\s*}}/g, (_m, raw, escaped) => { | ||
| if (raw) return `<?=${raw.trim()}?>`; | ||
| return `<?=htmlspecialchars(${escaped.trim()})?>`; | ||
| }); | ||
@@ -52,3 +52,2 @@ const tokens = []; | ||
| } | ||
| //#endregion | ||
@@ -124,3 +123,2 @@ //#region src/_runtime.ts | ||
| } | ||
| //#endregion | ||
@@ -192,107 +190,3 @@ //#region src/compiler.ts | ||
| } | ||
| //#endregion | ||
| //#region node_modules/.pnpm/cookie-es@2.0.0/node_modules/cookie-es/dist/index.mjs | ||
| function parse(str, options) { | ||
| if (typeof str !== "string") throw new TypeError("argument str must be a string"); | ||
| const obj = {}; | ||
| const opt = options || {}; | ||
| const dec = opt.decode || decode; | ||
| let index = 0; | ||
| while (index < str.length) { | ||
| const eqIdx = str.indexOf("=", index); | ||
| if (eqIdx === -1) break; | ||
| let endIdx = str.indexOf(";", index); | ||
| if (endIdx === -1) endIdx = str.length; | ||
| else if (endIdx < eqIdx) { | ||
| index = str.lastIndexOf(";", eqIdx - 1) + 1; | ||
| continue; | ||
| } | ||
| const key = str.slice(index, eqIdx).trim(); | ||
| if (opt?.filter && !opt?.filter(key)) { | ||
| index = endIdx + 1; | ||
| continue; | ||
| } | ||
| if (void 0 === obj[key]) { | ||
| let val = str.slice(eqIdx + 1, endIdx).trim(); | ||
| if (val.codePointAt(0) === 34) val = val.slice(1, -1); | ||
| obj[key] = tryDecode(val, dec); | ||
| } | ||
| index = endIdx + 1; | ||
| } | ||
| return obj; | ||
| } | ||
| function decode(str) { | ||
| return str.includes("%") ? decodeURIComponent(str) : str; | ||
| } | ||
| function tryDecode(str, decode2) { | ||
| try { | ||
| return decode2(str); | ||
| } catch { | ||
| return str; | ||
| } | ||
| } | ||
| const fieldContentRegExp = /^[\u0009\u0020-\u007E\u0080-\u00FF]+$/; | ||
| function serialize(name, value, options) { | ||
| const opt = options || {}; | ||
| const enc = opt.encode || encodeURIComponent; | ||
| if (typeof enc !== "function") throw new TypeError("option encode is invalid"); | ||
| if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid"); | ||
| const encodedValue = enc(value); | ||
| if (encodedValue && !fieldContentRegExp.test(encodedValue)) throw new TypeError("argument val is invalid"); | ||
| let str = name + "=" + encodedValue; | ||
| if (void 0 !== opt.maxAge && opt.maxAge !== null) { | ||
| const maxAge = opt.maxAge - 0; | ||
| if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid"); | ||
| str += "; Max-Age=" + Math.floor(maxAge); | ||
| } | ||
| if (opt.domain) { | ||
| if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid"); | ||
| str += "; Domain=" + opt.domain; | ||
| } | ||
| if (opt.path) { | ||
| if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid"); | ||
| str += "; Path=" + opt.path; | ||
| } | ||
| if (opt.expires) { | ||
| if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) throw new TypeError("option expires is invalid"); | ||
| str += "; Expires=" + opt.expires.toUTCString(); | ||
| } | ||
| if (opt.httpOnly) str += "; HttpOnly"; | ||
| if (opt.secure) str += "; Secure"; | ||
| if (opt.priority) switch (typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority) { | ||
| case "low": | ||
| str += "; Priority=Low"; | ||
| break; | ||
| case "medium": | ||
| str += "; Priority=Medium"; | ||
| break; | ||
| case "high": | ||
| str += "; Priority=High"; | ||
| break; | ||
| default: throw new TypeError("option priority is invalid"); | ||
| } | ||
| if (opt.sameSite) switch (typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite) { | ||
| case true: | ||
| str += "; SameSite=Strict"; | ||
| break; | ||
| case "lax": | ||
| str += "; SameSite=Lax"; | ||
| break; | ||
| case "strict": | ||
| str += "; SameSite=Strict"; | ||
| break; | ||
| case "none": | ||
| str += "; SameSite=None"; | ||
| break; | ||
| default: throw new TypeError("option sameSite is invalid"); | ||
| } | ||
| if (opt.partitioned) str += "; Partitioned"; | ||
| return str; | ||
| } | ||
| function isDate(val) { | ||
| return Object.prototype.toString.call(val) === "[object Date]" || val instanceof Date; | ||
| } | ||
| //#endregion | ||
| //#region src/render.ts | ||
@@ -382,4 +276,3 @@ /** | ||
| } | ||
| //#endregion | ||
| export { RENDER_CONTEXT_KEYS, compileTemplate, compileTemplateToString, createRenderContext, hasTemplateSyntax, renderToResponse }; | ||
| export { RENDER_CONTEXT_KEYS, compileTemplate, compileTemplateToString, createRenderContext, hasTemplateSyntax, renderToResponse }; |
+25
-24
| { | ||
| "name": "rendu", | ||
| "version": "0.0.7", | ||
| "version": "0.1.0", | ||
| "description": "", | ||
| "license": "MIT", | ||
| "repository": "h3js/rendu", | ||
| "license": "MIT", | ||
| "bin": "./dist/cli.mjs", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "type": "module", | ||
| "sideEffects": false, | ||
| "type": "module", | ||
| "types": "./dist/index.d.mts", | ||
| "exports": { | ||
| ".": "./dist/index.mjs" | ||
| }, | ||
| "types": "./dist/index.d.mts", | ||
| "bin": "./dist/cli.mjs", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "obuild", | ||
| "dev": "vitest dev", | ||
| "lint": "eslint . && prettier -c .", | ||
| "lint:fix": "automd && eslint . --fix && prettier -w .", | ||
| "lint": "oxlint . && oxfmt --check .", | ||
| "fmt": "automd && oxlint . --fix && oxfmt .", | ||
| "prepack": "pnpm build", | ||
@@ -27,22 +27,23 @@ "play": "pnpm rendu playground", | ||
| "test": "pnpm lint && pnpm test:types && vitest run --coverage", | ||
| "test:types": "tsc --noEmit --skipLibCheck" | ||
| "test:types": "tsgo --noEmit --skipLibCheck" | ||
| }, | ||
| "dependencies": { | ||
| "srvx": "^0.9.1" | ||
| "srvx": ">=0.11" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^24.9.1", | ||
| "@vitest/coverage-v8": "^4.0.4", | ||
| "automd": "^0.4.2", | ||
| "@types/node": "^25.5.0", | ||
| "@typescript/native-preview": "7.0.0-dev.20260401.1", | ||
| "@vitest/coverage-v8": "^4.1.2", | ||
| "automd": "^0.4.3", | ||
| "changelogen": "^0.6.2", | ||
| "cookie-es": "^2.0.0", | ||
| "eslint": "^9.38.0", | ||
| "eslint-config-unjs": "^0.5.0", | ||
| "obuild": "^0.3.0", | ||
| "prettier": "^3.6.2", | ||
| "rendu": "^0.0.6", | ||
| "typescript": "^5.9.3", | ||
| "vitest": "^4.0.4" | ||
| "cookie-es": "^3.1.1", | ||
| "eslint-config-unjs": "^0.6.2", | ||
| "obuild": "^0.4.32", | ||
| "oxfmt": "^0.43.0", | ||
| "oxlint": "^1.58.0", | ||
| "rendu": "^0.0.7", | ||
| "typescript": "^6.0.2", | ||
| "vitest": "^4.1.2" | ||
| }, | ||
| "packageManager": "pnpm@10.19.0" | ||
| "packageManager": "pnpm@10.33.0" | ||
| } |
+0
-3
@@ -7,5 +7,2 @@ # rendu | ||
| > [!WARNING] | ||
| > This is an experimental PoC. | ||
| > [!NOTE] | ||
@@ -12,0 +9,0 @@ > See [playground](./playground/) ([online playground](https://stackblitz.com/github/h3js/rendu/tree/main/playground?file=index.html)) for demos and [syntax](#syntax) section for usage. |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
40989
24.08%10
42.86%13
8.33%1
Infinity%80
-20%718
-6.27%216
-1.37%+ Added
- Removed
Updated