@blinkk/root 2.5.14-alpha.0 → 3.0.1-alpha.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/dist/{chunk-BUAFCL5F.js → chunk-3OVMCKPA.js} +37 -2
- package/dist/chunk-3OVMCKPA.js.map +1 -0
- package/dist/{chunk-3KGEENDW.js → chunk-6P3B7ZXL.js} +16 -17
- package/dist/chunk-6P3B7ZXL.js.map +1 -0
- package/dist/{chunk-ISNB54FM.js → chunk-EBE4O463.js} +30 -19
- package/dist/chunk-EBE4O463.js.map +1 -0
- package/dist/{chunk-SBYWZOQ6.js → chunk-G7OKXRD3.js} +28 -26
- package/dist/chunk-G7OKXRD3.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/functions.js +3 -3
- package/dist/jsx.js +1 -1
- package/dist/node.js +1 -1
- package/dist/render.js +2 -2
- package/package.json +3 -5
- package/dist/chunk-3KGEENDW.js.map +0 -1
- package/dist/chunk-BUAFCL5F.js.map +0 -1
- package/dist/chunk-ISNB54FM.js.map +0 -1
- package/dist/chunk-SBYWZOQ6.js.map +0 -1
|
@@ -114,7 +114,42 @@ var PROP_TO_ATTR = {
|
|
|
114
114
|
srcLang: "srclang",
|
|
115
115
|
srcSet: "srcset",
|
|
116
116
|
tabIndex: "tabindex",
|
|
117
|
-
useMap: "usemap"
|
|
117
|
+
useMap: "usemap",
|
|
118
|
+
// SVG presentation attributes (camelCase -> kebab-case).
|
|
119
|
+
clipPath: "clip-path",
|
|
120
|
+
clipRule: "clip-rule",
|
|
121
|
+
colorInterpolation: "color-interpolation",
|
|
122
|
+
colorInterpolationFilters: "color-interpolation-filters",
|
|
123
|
+
dominantBaseline: "dominant-baseline",
|
|
124
|
+
fillOpacity: "fill-opacity",
|
|
125
|
+
fillRule: "fill-rule",
|
|
126
|
+
floodColor: "flood-color",
|
|
127
|
+
floodOpacity: "flood-opacity",
|
|
128
|
+
imageRendering: "image-rendering",
|
|
129
|
+
letterSpacing: "letter-spacing",
|
|
130
|
+
lightingColor: "lighting-color",
|
|
131
|
+
markerEnd: "marker-end",
|
|
132
|
+
markerMid: "marker-mid",
|
|
133
|
+
markerStart: "marker-start",
|
|
134
|
+
paintOrder: "paint-order",
|
|
135
|
+
pointerEvents: "pointer-events",
|
|
136
|
+
shapeRendering: "shape-rendering",
|
|
137
|
+
stopColor: "stop-color",
|
|
138
|
+
stopOpacity: "stop-opacity",
|
|
139
|
+
strokeDasharray: "stroke-dasharray",
|
|
140
|
+
strokeDashoffset: "stroke-dashoffset",
|
|
141
|
+
strokeLinecap: "stroke-linecap",
|
|
142
|
+
strokeLinejoin: "stroke-linejoin",
|
|
143
|
+
strokeMiterlimit: "stroke-miterlimit",
|
|
144
|
+
strokeOpacity: "stroke-opacity",
|
|
145
|
+
strokeWidth: "stroke-width",
|
|
146
|
+
textAnchor: "text-anchor",
|
|
147
|
+
textDecoration: "text-decoration",
|
|
148
|
+
textRendering: "text-rendering",
|
|
149
|
+
transformOrigin: "transform-origin",
|
|
150
|
+
vectorEffect: "vector-effect",
|
|
151
|
+
wordSpacing: "word-spacing",
|
|
152
|
+
writingMode: "writing-mode"
|
|
118
153
|
};
|
|
119
154
|
var AMP = "&";
|
|
120
155
|
var LT = "<";
|
|
@@ -378,4 +413,4 @@ function noop() {
|
|
|
378
413
|
export {
|
|
379
414
|
renderJsxToString
|
|
380
415
|
};
|
|
381
|
-
//# sourceMappingURL=chunk-
|
|
416
|
+
//# sourceMappingURL=chunk-3OVMCKPA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jsx/jsx-render.ts"],"sourcesContent":["import {options as preactOptions} from 'preact';\nimport {VNode, Fragment} from './jsx-runtime.js';\n\n/** HTML void elements (self-closing, no end tag). */\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/** Tags whose text content may contain literal newlines that should not be treated as block-child indicators. */\nconst RAW_CONTENT_ELEMENTS = new Set(['pre', 'textarea', 'script', 'style']);\n\n/** Standard HTML block-level elements. */\nconst DEFAULT_BLOCK_ELEMENTS = new Set([\n 'address',\n 'article',\n 'aside',\n 'blockquote',\n 'body',\n 'dd',\n 'details',\n 'dialog',\n 'div',\n 'dl',\n 'dt',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'li',\n 'link',\n 'main',\n 'meta',\n 'nav',\n 'noscript',\n 'ol',\n 'p',\n 'pre',\n 'script',\n 'search',\n 'section',\n 'style',\n 'summary',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'title',\n 'tr',\n 'ul',\n]);\n\n/** JSX prop name -> HTML attribute name. */\nconst PROP_TO_ATTR: Record<string, string> = {\n acceptCharset: 'accept-charset',\n autoCapitalize: 'autocapitalize',\n autoComplete: 'autocomplete',\n autoFocus: 'autofocus',\n autoPlay: 'autoplay',\n charSet: 'charset',\n className: 'class',\n colSpan: 'colspan',\n contentEditable: 'contenteditable',\n crossOrigin: 'crossorigin',\n dateTime: 'datetime',\n encType: 'enctype',\n formAction: 'formaction',\n formEncType: 'formenctype',\n formMethod: 'formmethod',\n formNoValidate: 'formnovalidate',\n formTarget: 'formtarget',\n frameBorder: 'frameborder',\n hrefLang: 'hreflang',\n htmlFor: 'for',\n httpEquiv: 'http-equiv',\n inputMode: 'inputmode',\n itemProp: 'itemprop',\n itemRef: 'itemref',\n itemScope: 'itemscope',\n itemType: 'itemtype',\n maxLength: 'maxlength',\n mediaGroup: 'mediagroup',\n minLength: 'minlength',\n noModule: 'nomodule',\n noValidate: 'novalidate',\n playsInline: 'playsinline',\n readOnly: 'readonly',\n referrerPolicy: 'referrerpolicy',\n rowSpan: 'rowspan',\n spellCheck: 'spellcheck',\n srcDoc: 'srcdoc',\n srcLang: 'srclang',\n srcSet: 'srcset',\n tabIndex: 'tabindex',\n useMap: 'usemap',\n\n // SVG presentation attributes (camelCase -> kebab-case).\n clipPath: 'clip-path',\n clipRule: 'clip-rule',\n colorInterpolation: 'color-interpolation',\n colorInterpolationFilters: 'color-interpolation-filters',\n dominantBaseline: 'dominant-baseline',\n fillOpacity: 'fill-opacity',\n fillRule: 'fill-rule',\n floodColor: 'flood-color',\n floodOpacity: 'flood-opacity',\n imageRendering: 'image-rendering',\n letterSpacing: 'letter-spacing',\n lightingColor: 'lighting-color',\n markerEnd: 'marker-end',\n markerMid: 'marker-mid',\n markerStart: 'marker-start',\n paintOrder: 'paint-order',\n pointerEvents: 'pointer-events',\n shapeRendering: 'shape-rendering',\n stopColor: 'stop-color',\n stopOpacity: 'stop-opacity',\n strokeDasharray: 'stroke-dasharray',\n strokeDashoffset: 'stroke-dashoffset',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeMiterlimit: 'stroke-miterlimit',\n strokeOpacity: 'stroke-opacity',\n strokeWidth: 'stroke-width',\n textAnchor: 'text-anchor',\n textDecoration: 'text-decoration',\n textRendering: 'text-rendering',\n transformOrigin: 'transform-origin',\n vectorEffect: 'vector-effect',\n wordSpacing: 'word-spacing',\n writingMode: 'writing-mode',\n};\n\nconst AMP = '&';\nconst LT = '<';\nconst GT = '>';\nconst QUOT = '"';\n\n/** Returns `true` when `value` is neither `null` nor `undefined`. */\nfunction isDef<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined;\n}\n\nfunction escapeHtml(str: string): string {\n let result = '';\n let last = 0;\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n let escaped: string | undefined;\n if (ch === 38) escaped = AMP;\n else if (ch === 60) escaped = LT;\n else if (ch === 62) escaped = GT;\n if (escaped) {\n result += str.slice(last, i) + escaped;\n last = i + 1;\n }\n }\n if (last === 0) return str;\n return result + str.slice(last);\n}\n\nfunction escapeAttr(str: string): string {\n let result = '';\n let last = 0;\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n let escaped: string | undefined;\n if (ch === 38) escaped = AMP;\n else if (ch === 34) escaped = QUOT;\n else if (ch === 60) escaped = LT;\n else if (ch === 62) escaped = GT;\n if (escaped) {\n result += str.slice(last, i) + escaped;\n last = i + 1;\n }\n }\n if (last === 0) return str;\n return result + str.slice(last);\n}\n\nfunction styleToString(style: Record<string, any>): string {\n const parts: string[] = [];\n for (const key in style) {\n const value = style[key];\n if (!isDef(value) || value === '') continue;\n // Convert camelCase to kebab-case.\n const cssKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n parts.push(`${cssKey}:${value}`);\n }\n return parts.join(';');\n}\n\nexport interface JsxRenderOptions {\n /** Render mode. `'pretty'` adds newlines around block elements; `'minimal'` outputs compact HTML. Default: `'pretty'`. */\n mode?: 'pretty' | 'minimal';\n /** Additional tag names to treat as block-level elements in pretty mode. */\n blockElements?: string[];\n}\n\n/**\n * Renders a Preact VNode tree to an HTML string.\n */\nexport function renderJsxToString(\n vnode: VNode,\n options?: JsxRenderOptions\n): string {\n const mode = options?.mode ?? 'pretty';\n const isPretty = mode === 'pretty';\n const blockSet = new Set(DEFAULT_BLOCK_ELEMENTS);\n if (options?.blockElements) {\n for (const el of options.blockElements) {\n blockSet.add(el);\n }\n }\n\n // Context stacks: context.__c (id) -> value[]\n const contextStacks = new Map<string, any[]>();\n\n function pushCtx(contextId: string, value: any) {\n let stack = contextStacks.get(contextId);\n if (!stack) {\n stack = [];\n contextStacks.set(contextId, stack);\n }\n stack.push(value);\n }\n\n function popCtx(contextId: string) {\n contextStacks.get(contextId)?.pop();\n }\n\n /** Builds the __n (global context) map for hooks. */\n function buildGlobalContext(): Record<string, any> {\n const globalCtx: Record<string, any> = {};\n for (const [contextId, stack] of contextStacks) {\n if (stack.length > 0) {\n // useContext expects provider.props.value and provider.sub().\n globalCtx[contextId] = {\n props: {value: stack[stack.length - 1]},\n sub: noop,\n };\n }\n }\n return globalCtx;\n }\n\n function render(node: any, inline?: boolean): string {\n if (!isDef(node) || typeof node === 'boolean') return '';\n if (typeof node === 'string') return escapeHtml(node);\n if (typeof node === 'number' || typeof node === 'bigint')\n return String(node);\n if (Array.isArray(node)) return node.map((n) => render(n, inline)).join('');\n\n // Must be a VNode-like object.\n if (typeof node !== 'object' || !('type' in node)) return '';\n\n const {type, props} = node;\n\n // Fragment.\n if (type === Fragment) {\n return renderChildren(props?.children);\n }\n\n // Component (function or class).\n if (typeof type === 'function') {\n return renderComponent(node);\n }\n\n // HTML element.\n if (typeof type === 'string') {\n return renderElement(type, props, inline);\n }\n\n return '';\n }\n\n function renderComponent(vnode: VNode): string {\n const {type, props} = vnode;\n const fn = type as Function;\n\n // Detect context Provider.\n // Root.js local JSX runtime: Provider._isProvider === true, Provider._context\n // is the Context object with a _stack array.\n // Preact >=10.27: Provider === Context (same function). `fn.__c` is the\n // context id string (e.g. \"__cC0\").\n // Preact <10.27: Provider._contextRef (mangled `fn.__`) points to the\n // context object which has `__c` (id) and `__` (default value).\n const fnAny = fn as any;\n if (fnAny._isProvider && fnAny._context) {\n const ctx = fnAny._context;\n ctx._stack.push((props as any).value);\n const result = renderChildren(props.children);\n ctx._stack.pop();\n return result;\n }\n let contextId: string | undefined;\n if (typeof fnAny.__c === 'string' && fnAny.__c.startsWith('__cC')) {\n contextId = fnAny.__c;\n } else if (fnAny.__ && typeof fnAny.__ === 'object' && fnAny.__.__c) {\n contextId = fnAny.__.__c;\n }\n if (contextId) {\n pushCtx(contextId, (props as any).value);\n const result = renderChildren(props.children);\n popCtx(contextId);\n return result;\n }\n\n // Detect context Consumer.\n if ((fn as any).contextType) {\n const ctx = (fn as any).contextType;\n const ctxId: string = ctx.__c;\n const stack = contextStacks.get(ctxId);\n const value =\n stack && stack.length > 0 ? stack[stack.length - 1] : ctx.__;\n if (typeof props.children === 'function') {\n return render(props.children(value));\n }\n return renderChildren(props.children);\n }\n\n // Regular component — set up a fake component instance so Preact hooks\n // (useContext, useState, useMemo, etc.) work during SSR.\n // Preact's useContext reads from `component.context[context.__c]`.\n const component: any = {\n props,\n context: buildGlobalContext(),\n state: {},\n __v: vnode, // _vnode\n __d: false, // _dirty\n __h: [], // _renderCallbacks\n __s: {}, // _nextState\n __H: null, // _hooks (initialised by hooks addon)\n };\n (vnode as any).__c = component;\n\n // Trigger Preact option hooks so the hooks addon can set currentComponent.\n (preactOptions as any).__b?.(vnode);\n (preactOptions as any).__r?.(vnode);\n\n try {\n // Class component.\n if (fn.prototype && fn.prototype.render) {\n const instance = new (fn as any)(props, component.context);\n instance.__n = component.__n;\n instance.__H = component.__H;\n (vnode as any).__c = instance;\n (preactOptions as any).__r?.(vnode);\n return render(instance.render(instance.props, instance.state));\n }\n\n // Functional component.\n const rendered = fn(props, component.context);\n return render(rendered);\n } finally {\n preactOptions.diffed?.(vnode as any);\n }\n }\n\n function renderElement(\n tag: string,\n props: Record<string, any>,\n inline?: boolean\n ): string {\n const isBlock = isPretty && !inline && blockSet.has(tag);\n const isVoid = VOID_ELEMENTS.has(tag);\n const attrs = renderAttrs(tag, props);\n let result = '<' + tag + attrs + '>';\n\n if (isVoid) {\n if (isBlock) result += '\\n';\n return result;\n }\n\n let inner = '';\n if (isDef(props?.dangerouslySetInnerHTML?.__html)) {\n inner = props.dangerouslySetInnerHTML.__html;\n } else if (isDef(props?.children)) {\n inner = renderChildren(props.children);\n } else if (tag === 'textarea' && props) {\n // For <textarea>, render value/defaultValue as text content since\n // browsers ignore the value attribute on textarea elements.\n const textVal = props.value ?? props.defaultValue;\n if (isDef(textVal)) {\n inner = escapeHtml(String(textVal));\n }\n }\n\n if (isBlock) {\n // When inner content contains block children (indicated by newlines),\n // add a newline after the opening tag so content starts on its own line.\n // Exempt raw-content elements (pre, textarea, script, style) where\n // newlines are literal text, not block-child indicators.\n const hasBlockChildren =\n !RAW_CONTENT_ELEMENTS.has(tag) && inner.includes('\\n');\n if (hasBlockChildren) {\n result += '\\n' + inner + '</' + tag + '>\\n';\n } else {\n result += inner + '</' + tag + '>\\n';\n }\n } else {\n result += inner + '</' + tag + '>';\n }\n\n return result;\n }\n\n function renderAttrs(tag: string, props: Record<string, any>): string {\n if (!props) return '';\n const parts: string[] = [];\n for (const key in props) {\n if (\n key === 'children' ||\n key === 'dangerouslySetInnerHTML' ||\n key === 'key' ||\n key === 'ref' ||\n key === '__self' ||\n key === '__source'\n ) {\n continue;\n }\n // Skip value/defaultValue on textarea — rendered as text content.\n if (tag === 'textarea' && (key === 'value' || key === 'defaultValue')) {\n continue;\n }\n // Skip event handlers.\n if (key.length > 2 && key[0] === 'o' && key[1] === 'n') continue;\n\n let value = props[key];\n if (!isDef(value)) continue;\n // For standard and boolean attributes, `false` removes the attribute.\n // For data-* attributes, `false` is rendered as the string \"false\".\n if (value === false && !key.startsWith('data-')) continue;\n\n const attrName = PROP_TO_ATTR[key] || key;\n\n // Boolean attributes.\n if (value === true) {\n parts.push(' ', attrName);\n continue;\n }\n\n // Style objects.\n if (key === 'style' && typeof value === 'object') {\n value = styleToString(value);\n if (!value) continue;\n }\n\n parts.push(' ', attrName, '=\"', escapeAttr(String(value)), '\"');\n }\n return parts.join('');\n }\n\n /**\n * Returns true if a child node is a text-like value (string, number).\n */\n function isTextNode(child: any): boolean {\n if (!isDef(child) || typeof child === 'boolean') return false;\n return (\n typeof child === 'string' ||\n typeof child === 'number' ||\n typeof child === 'bigint'\n );\n }\n\n /**\n * Checks if an array of children contains a mix of text nodes and elements.\n * When mixed, block elements should render inline to avoid breaking text flow.\n */\n function hasMixedContent(children: any[]): boolean {\n let hasText = false;\n let hasElement = false;\n for (const child of children) {\n if (isTextNode(child)) {\n hasText = true;\n } else if (isDef(child) && typeof child === 'object' && 'type' in child) {\n hasElement = true;\n }\n if (hasText && hasElement) return true;\n }\n return false;\n }\n\n function renderChildren(children: any): string {\n if (!isDef(children)) return '';\n if (Array.isArray(children)) {\n const inline = isPretty && hasMixedContent(children);\n return children.map((child) => render(child, inline)).join('');\n }\n return render(children);\n }\n\n return render(vnode);\n}\n\nfunction noop() {}\n"],"mappings":";;;;;AAAA,SAAQ,WAAW,qBAAoB;AAIvC,IAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,IAAM,uBAAuB,oBAAI,IAAI,CAAC,OAAO,YAAY,UAAU,OAAO,CAAC;AAG3E,IAAM,yBAAyB,oBAAI,IAAI;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,IAAM,eAAuC;AAAA,EAC3C,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,UAAU;AAAA,EACV,SAA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xD,WACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAAA,EAErB;AAMA,WAAS,gBAAgB,UAA0B;AACjD,QAAI,UAAU;AACd,QAAI,aAAa;AACjB,eAAW,SAAS,UAAU;AAC5B,UAAI,WAAW,KAAK,GAAG;AACrB,kBAAU;AAAA,MACZ,WAAW,MAAM,KAAK,KAAK,OAAO,UAAU,YAAY,UAAU,OAAO;AACvE,qBAAa;AAAA,MACf;AACA,UAAI,WAAW,WAAY,QAAO;AAAA,IACpC;AACA,WAAO;AAAA,EACT;AAEA,WAAS,eAAe,UAAuB;AAC7C,QAAI,CAAC,MAAM,QAAQ,EAAG,QAAO;AAC7B,QAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,YAAM,SAAS,YAAY,gBAAgB,QAAQ;AACnD,aAAO,SAAS,IAAI,CAAC,UAAU,OAAO,OAAO,MAAM,CAAC,EAAE,KAAK,EAAE;AAAA,IAC/D;AACA,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,SAAO,OAAO,KAAK;AACrB;AAEA,SAAS,OAAO;AAAC;","names":["vnode"]}
|
|
@@ -57,7 +57,7 @@ async function htmlPretty(html, options) {
|
|
|
57
57
|
|
|
58
58
|
// src/render/route-trie.ts
|
|
59
59
|
var RouteTrie = class _RouteTrie {
|
|
60
|
-
children =
|
|
60
|
+
children = /* @__PURE__ */ new Map();
|
|
61
61
|
paramNodes;
|
|
62
62
|
catchAllNodes;
|
|
63
63
|
optCatchAllNodes;
|
|
@@ -85,18 +85,18 @@ var RouteTrie = class _RouteTrie {
|
|
|
85
85
|
let nextNode;
|
|
86
86
|
if (head.startsWith("[") && head.endsWith("]")) {
|
|
87
87
|
if (!this.paramNodes) {
|
|
88
|
-
this.paramNodes =
|
|
88
|
+
this.paramNodes = /* @__PURE__ */ new Map();
|
|
89
89
|
}
|
|
90
90
|
const paramName = head.slice(1, -1);
|
|
91
|
-
if (!this.paramNodes
|
|
92
|
-
this.paramNodes
|
|
91
|
+
if (!this.paramNodes.has(paramName)) {
|
|
92
|
+
this.paramNodes.set(paramName, new ParamNode(paramName));
|
|
93
93
|
}
|
|
94
|
-
nextNode = this.paramNodes
|
|
94
|
+
nextNode = this.paramNodes.get(paramName).trie;
|
|
95
95
|
} else {
|
|
96
|
-
nextNode = this.children
|
|
96
|
+
nextNode = this.children.get(head);
|
|
97
97
|
if (!nextNode) {
|
|
98
98
|
nextNode = new _RouteTrie();
|
|
99
|
-
this.children
|
|
99
|
+
this.children.set(head, nextNode);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
nextNode.add(tail, route);
|
|
@@ -132,7 +132,7 @@ var RouteTrie = class _RouteTrie {
|
|
|
132
132
|
addPromise(cb("/", this.route));
|
|
133
133
|
}
|
|
134
134
|
if (this.paramNodes) {
|
|
135
|
-
|
|
135
|
+
this.paramNodes.forEach((paramChild) => {
|
|
136
136
|
const param = `[${paramChild.name}]`;
|
|
137
137
|
paramChild.trie.walk((childPath, route) => {
|
|
138
138
|
const paramUrlPath = `/${param}${childPath}`;
|
|
@@ -148,12 +148,11 @@ var RouteTrie = class _RouteTrie {
|
|
|
148
148
|
const wildcardUrlPath = `/[[...${this.optCatchAllNodes.name}]]`;
|
|
149
149
|
addPromise(cb(wildcardUrlPath, this.optCatchAllNodes.route));
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
const childTrie = this.children[subpath];
|
|
151
|
+
this.children.forEach((childTrie, subpath) => {
|
|
153
152
|
childTrie.walk((childPath, childRoute) => {
|
|
154
153
|
addPromise(cb(`/${subpath}${childPath}`, childRoute));
|
|
155
154
|
});
|
|
156
|
-
}
|
|
155
|
+
});
|
|
157
156
|
return Promise.all(promises).then(() => {
|
|
158
157
|
});
|
|
159
158
|
}
|
|
@@ -161,7 +160,7 @@ var RouteTrie = class _RouteTrie {
|
|
|
161
160
|
* Removes all routes from the trie.
|
|
162
161
|
*/
|
|
163
162
|
clear() {
|
|
164
|
-
this.children =
|
|
163
|
+
this.children = /* @__PURE__ */ new Map();
|
|
165
164
|
this.paramNodes = void 0;
|
|
166
165
|
this.catchAllNodes = void 0;
|
|
167
166
|
this.optCatchAllNodes = void 0;
|
|
@@ -182,7 +181,7 @@ var RouteTrie = class _RouteTrie {
|
|
|
182
181
|
return void 0;
|
|
183
182
|
}
|
|
184
183
|
const [head, tail] = this.splitPath(urlPath);
|
|
185
|
-
const child = this.children
|
|
184
|
+
const child = this.children.get(head);
|
|
186
185
|
if (child) {
|
|
187
186
|
const route = child.getRoute(tail, params);
|
|
188
187
|
if (route) {
|
|
@@ -190,7 +189,7 @@ var RouteTrie = class _RouteTrie {
|
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
if (this.paramNodes) {
|
|
193
|
-
for (const paramChild of
|
|
192
|
+
for (const paramChild of this.paramNodes.values()) {
|
|
194
193
|
const route = paramChild.trie.getRoute(tail, params);
|
|
195
194
|
if (route) {
|
|
196
195
|
params[paramChild.name] = head;
|
|
@@ -224,12 +223,12 @@ var RouteTrie = class _RouteTrie {
|
|
|
224
223
|
return;
|
|
225
224
|
}
|
|
226
225
|
const [head, tail] = this.splitPath(urlPath);
|
|
227
|
-
const child = this.children
|
|
226
|
+
const child = this.children.get(head);
|
|
228
227
|
if (child) {
|
|
229
228
|
child.collectRoutes(tail, { ...params }, results);
|
|
230
229
|
}
|
|
231
230
|
if (this.paramNodes) {
|
|
232
|
-
for (const paramChild of
|
|
231
|
+
for (const paramChild of this.paramNodes.values()) {
|
|
233
232
|
const paramParams = { ...params, [paramChild.name]: head };
|
|
234
233
|
paramChild.trie.collectRoutes(tail, paramParams, results);
|
|
235
234
|
}
|
|
@@ -288,4 +287,4 @@ export {
|
|
|
288
287
|
htmlPretty,
|
|
289
288
|
RouteTrie
|
|
290
289
|
};
|
|
291
|
-
//# sourceMappingURL=chunk-
|
|
290
|
+
//# sourceMappingURL=chunk-6P3B7ZXL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/elements.ts","../src/render/html-minify.ts","../src/render/html-pretty.ts","../src/render/route-trie.ts"],"sourcesContent":["export const ELEMENT_RE = /^[a-z][\\w-]*-[\\w-]*$/;\nexport const HTML_ELEMENTS_REGEX = /<([a-z][\\w-]*-[\\w-]*)/g;\n\n/**\n * Returns true if the tagName is a valid custom element tag.\n */\nexport function isValidTagName(tagName: string) {\n return ELEMENT_RE.test(tagName);\n}\n\n/**\n * Returns a list of custom elements used in a src string (e.g. HTML, jsx, lit).\n * NOTE: the impl uses a simple regex, so tagNames used in comments and attr\n * values may be included.\n */\nexport function parseTagNames(src: string): string[] {\n if (!src) {\n return [];\n }\n const tagNames = new Set<string>();\n const matches = Array.from(String(src).matchAll(HTML_ELEMENTS_REGEX));\n for (const match of matches) {\n const tagName = match[1];\n tagNames.add(tagName);\n }\n return Array.from(tagNames);\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {Options} from 'html-minifier-terser';\n\nconst {minify} = require('html-minifier-terser');\n\nexport type HtmlMinifyOptions = Options;\n\nexport async function htmlMinify(\n html: string,\n options?: HtmlMinifyOptions\n): Promise<string> {\n const minifyOptions = options || {\n collapseWhitespace: true,\n removeComments: true,\n preserveLineBreaks: true,\n };\n try {\n const min = await minify(html, minifyOptions);\n return min.trimStart();\n } catch (e) {\n console.error('failed to minify html:', e);\n return html;\n }\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {HTMLBeautifyOptions} from 'js-beautify';\n\nconst beautify = require('js-beautify');\n\nexport type HtmlPrettyOptions = HTMLBeautifyOptions;\n\nexport async function htmlPretty(\n html: string,\n options?: HtmlPrettyOptions\n): Promise<string> {\n const prettyOptions = options || {\n indent_size: 0,\n end_with_newline: true,\n extra_liners: [],\n };\n try {\n const output = beautify.html(html, prettyOptions);\n return output.trimStart();\n } catch (e) {\n console.error('failed to pretty html:', e);\n return html;\n }\n}\n","/**\n * A trie data structure that stores routes. Supports Next-style routing using\n * [param], [...catchall], and [[...optcatchall]] placeholders.\n */\nexport class RouteTrie<T> {\n private children: Map<string, RouteTrie<T>> = new Map();\n private paramNodes?: Map<string, ParamNode<T>>;\n private catchAllNodes?: CatchAllNode<T>;\n private optCatchAllNodes?: CatchAllNode<T>;\n private route?: T;\n\n /**\n * Adds a route to the trie.\n */\n add(path: string, route: T) {\n path = this.normalizePath(path);\n\n // If the end was reached, save the value to the node.\n if (path === '') {\n this.route = route;\n return;\n }\n\n const [head, tail] = this.splitPath(path);\n\n if (head.startsWith('[[...') && head.endsWith(']]')) {\n const paramName = head.slice(5, -2);\n this.optCatchAllNodes = new CatchAllNode(paramName, route);\n return;\n }\n if (head.startsWith('[...') && head.endsWith(']')) {\n const paramName = head.slice(4, -1);\n this.catchAllNodes = new CatchAllNode(paramName, route);\n return;\n }\n\n let nextNode: RouteTrie<T>;\n if (head.startsWith('[') && head.endsWith(']')) {\n if (!this.paramNodes) {\n this.paramNodes = new Map();\n }\n const paramName = head.slice(1, -1);\n if (!this.paramNodes.has(paramName)) {\n this.paramNodes.set(paramName, new ParamNode(paramName));\n }\n nextNode = this.paramNodes.get(paramName)!.trie;\n } else {\n nextNode = this.children.get(head)!;\n if (!nextNode) {\n nextNode = new RouteTrie();\n this.children.set(head, nextNode);\n }\n }\n nextNode.add(tail, route);\n }\n\n /**\n * Returns a route mapped to the given path and any parameter values from the\n * URL.\n */\n get(path: string): [T | undefined, Record<string, string>] {\n const params = {};\n const route = this.getRoute(path, params);\n return [route, params];\n }\n\n /**\n * Returns all routes that match the given path and their parameter values.\n */\n matchAll(path: string): Array<[T, Record<string, string>]> {\n const matches: Array<[T, Record<string, string>]> = [];\n this.collectRoutes(path, {}, matches);\n return matches;\n }\n\n /**\n * Walks the route trie and calls a callback function for each route.\n */\n walk(cb: (urlPath: string, route: T) => Promise<void> | void): Promise<void> {\n const promises: Array<Promise<void>> = [];\n const addPromise = (promise: Promise<void> | void) => {\n if (promise) {\n promises.push(promise);\n }\n };\n if (this.route) {\n addPromise(cb('/', this.route));\n }\n if (this.paramNodes) {\n this.paramNodes.forEach((paramChild) => {\n const param = `[${paramChild.name}]`;\n paramChild.trie.walk((childPath: string, route: T) => {\n const paramUrlPath = `/${param}${childPath}`;\n addPromise(cb(paramUrlPath, route));\n });\n });\n }\n if (this.catchAllNodes) {\n const wildcardUrlPath = `/[...${this.catchAllNodes.name}]`;\n addPromise(cb(wildcardUrlPath, this.catchAllNodes.route));\n }\n if (this.optCatchAllNodes) {\n const wildcardUrlPath = `/[[...${this.optCatchAllNodes.name}]]`;\n addPromise(cb(wildcardUrlPath, this.optCatchAllNodes.route));\n }\n this.children.forEach((childTrie, subpath) => {\n childTrie.walk((childPath: string, childRoute: T) => {\n addPromise(cb(`/${subpath}${childPath}`, childRoute));\n });\n });\n return Promise.all(promises).then(() => {});\n }\n\n /**\n * Removes all routes from the trie.\n */\n clear() {\n this.children = new Map();\n this.paramNodes = undefined;\n this.catchAllNodes = undefined;\n this.optCatchAllNodes = undefined;\n this.route = undefined;\n }\n\n private getRoute(\n urlPath: string,\n params: Record<string, string>\n ): T | undefined {\n urlPath = this.normalizePath(urlPath);\n if (urlPath === '') {\n if (this.route) {\n return this.route;\n }\n if (this.optCatchAllNodes) {\n if (urlPath) {\n params[this.optCatchAllNodes.name] = urlPath;\n }\n return this.optCatchAllNodes.route;\n }\n return undefined;\n }\n\n const [head, tail] = this.splitPath(urlPath);\n\n const child = this.children.get(head);\n if (child) {\n const route = child.getRoute(tail, params);\n if (route) {\n return route;\n }\n }\n\n if (this.paramNodes) {\n for (const paramChild of this.paramNodes.values()) {\n const route = paramChild.trie.getRoute(tail, params);\n if (route) {\n params[paramChild.name] = head;\n return route;\n }\n }\n }\n\n if (this.catchAllNodes) {\n params[this.catchAllNodes.name] = urlPath;\n return this.catchAllNodes.route;\n }\n\n if (this.optCatchAllNodes) {\n params[this.optCatchAllNodes.name] = urlPath;\n return this.optCatchAllNodes.route;\n }\n\n return undefined;\n }\n\n private collectRoutes(\n urlPath: string,\n params: Record<string, string>,\n results: Array<[T, Record<string, string>]>\n ) {\n urlPath = this.normalizePath(urlPath);\n if (urlPath === '') {\n if (this.route) {\n results.push([this.route, {...params}]);\n }\n if (this.optCatchAllNodes) {\n const optParams = {...params};\n if (urlPath) {\n optParams[this.optCatchAllNodes.name] = urlPath;\n }\n results.push([this.optCatchAllNodes.route, optParams]);\n }\n return;\n }\n\n const [head, tail] = this.splitPath(urlPath);\n\n const child = this.children.get(head);\n if (child) {\n child.collectRoutes(tail, {...params}, results);\n }\n\n if (this.paramNodes) {\n for (const paramChild of this.paramNodes.values()) {\n const paramParams = {...params, [paramChild.name]: head};\n paramChild.trie.collectRoutes(tail, paramParams, results);\n }\n }\n\n if (this.catchAllNodes) {\n const caParams = {...params, [this.catchAllNodes.name]: urlPath};\n results.push([this.catchAllNodes.route, caParams]);\n }\n\n if (this.optCatchAllNodes) {\n const ocParams = {...params};\n if (urlPath) {\n ocParams[this.optCatchAllNodes.name] = urlPath;\n }\n results.push([this.optCatchAllNodes.route, ocParams]);\n }\n }\n\n /**\n * Normalizes a path for inclusion into the route trie.\n */\n private normalizePath(path: string) {\n // Remove leading/trailing slashes.\n return path.replace(/^\\/+/g, '').replace(/\\/+$/g, '');\n }\n\n /**\n * Splits the parent directory from its children, e.g.:\n *\n * splitPath(\"foo/bar/baz\") -> [\"foo\", \"bar/baz\"]\n */\n private splitPath(path: string): [string, string] {\n const i = path.indexOf('/');\n if (i === -1) {\n return [path, ''];\n }\n return [path.slice(0, i), path.slice(i + 1)];\n }\n}\n\n/**\n * A node in the RouteTrie for a :param child.\n */\nclass ParamNode<T> {\n readonly name: string;\n readonly trie: RouteTrie<T> = new RouteTrie();\n\n constructor(name: string) {\n this.name = name;\n }\n}\n\n/**\n * A node in the RouteTrie for a *wildcard child.\n */\nclass CatchAllNode<T> {\n readonly name: string;\n readonly route: T;\n\n constructor(name: string, route: T) {\n this.name = name;\n this.route = route;\n }\n}\n"],"mappings":";AAAO,IAAM,aAAa;AACnB,IAAM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,QAAQ,GAAG;AAC1B,QAAI,MAAM,IAAI;AACZ,aAAO,CAAC,MAAM,EAAE;AAAA,IAClB;AACA,WAAO,CAAC,KAAK,MAAM,GAAG,CAAC,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;AAAA,EAC7C;AACF;AAKA,IAAM,YAAN,MAAmB;AAAA,EACR;AAAA,EACA,OAAqB,IAAI,UAAU;AAAA,EAE5C,YAAY,MAAc;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAKA,IAAM,eAAN,MAAsB;AAAA,EACX;AAAA,EACA;AAAA,EAET,YAAY,MAAc,OAAU;AAClC,SAAK,OAAO;AACZ,SAAK,QAAQ;AAAA,EACf;AACF;","names":["require","createRequire","require"]}
|
|
@@ -275,6 +275,33 @@ function esbuildExternalsPlugin(options) {
|
|
|
275
275
|
|
|
276
276
|
// src/node/vite.ts
|
|
277
277
|
import { createServer } from "vite";
|
|
278
|
+
|
|
279
|
+
// src/node/vite-plugin-preact-alias.ts
|
|
280
|
+
function preactToRootJsxPlugin() {
|
|
281
|
+
return {
|
|
282
|
+
name: "root:preact-to-jsx",
|
|
283
|
+
config() {
|
|
284
|
+
return {
|
|
285
|
+
resolve: {
|
|
286
|
+
alias: [
|
|
287
|
+
{ find: /^preact\/hooks$/, replacement: "@blinkk/root/jsx" },
|
|
288
|
+
{
|
|
289
|
+
find: /^preact\/jsx-runtime$/,
|
|
290
|
+
replacement: "@blinkk/root/jsx/jsx-runtime"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
find: /^preact\/jsx-dev-runtime$/,
|
|
294
|
+
replacement: "@blinkk/root/jsx/jsx-dev-runtime"
|
|
295
|
+
},
|
|
296
|
+
{ find: /^preact$/, replacement: "@blinkk/root/jsx" }
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/node/vite.ts
|
|
278
305
|
async function createViteServer(rootConfig, options) {
|
|
279
306
|
const rootDir = rootConfig.rootDir;
|
|
280
307
|
const viteConfig = rootConfig.vite || {};
|
|
@@ -299,19 +326,6 @@ async function createViteServer(rootConfig, options) {
|
|
|
299
326
|
},
|
|
300
327
|
appType: "custom",
|
|
301
328
|
optimizeDeps: {
|
|
302
|
-
// As of vite v5 / esbuild v19, experimentalDecorators need to be
|
|
303
|
-
// explicitly set, and for some reason this option isn't read from the
|
|
304
|
-
// project's tsconfig.json file by default.
|
|
305
|
-
// See: https://vitejs.dev/blog/announcing-vite5
|
|
306
|
-
esbuildOptions: {
|
|
307
|
-
tsconfigRaw: {
|
|
308
|
-
compilerOptions: {
|
|
309
|
-
target: "esnext",
|
|
310
|
-
experimentalDecorators: true,
|
|
311
|
-
useDefineForClassFields: false
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
329
|
...viteConfig.optimizeDeps || {},
|
|
316
330
|
include: [
|
|
317
331
|
...options?.optimizeDeps || [],
|
|
@@ -323,13 +337,9 @@ async function createViteServer(rootConfig, options) {
|
|
|
323
337
|
...viteConfig.ssr || {},
|
|
324
338
|
noExternal: ["@blinkk/root", "@blinkk/root-cms/richtext"]
|
|
325
339
|
},
|
|
326
|
-
esbuild: {
|
|
327
|
-
...viteConfig.esbuild || {},
|
|
328
|
-
jsx: "automatic",
|
|
329
|
-
jsxImportSource: "preact"
|
|
330
|
-
},
|
|
331
340
|
plugins: [
|
|
332
341
|
hmrSSRReload(),
|
|
342
|
+
...rootConfig.jsxRenderer?.mode ? [preactToRootJsxPlugin()] : [],
|
|
333
343
|
...viteConfig.plugins || [],
|
|
334
344
|
...getVitePlugins(rootConfig.plugins || [])
|
|
335
345
|
]
|
|
@@ -400,7 +410,8 @@ export {
|
|
|
400
410
|
loadRootConfigWithDeps,
|
|
401
411
|
bundleRootConfig,
|
|
402
412
|
loadBundledConfig,
|
|
413
|
+
preactToRootJsxPlugin,
|
|
403
414
|
createViteServer,
|
|
404
415
|
viteSsrLoadModule
|
|
405
416
|
};
|
|
406
|
-
//# sourceMappingURL=chunk-
|
|
417
|
+
//# sourceMappingURL=chunk-EBE4O463.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/monorepo.ts","../src/utils/fsutils.ts","../src/node/load-config.ts","../src/node/vite.ts","../src/node/vite-plugin-preact-alias.ts"],"sourcesContent":["import path from 'node:path';\nimport {getWorkspaces, getWorkspaceRoot, PackageInfo} from 'workspace-tools';\nimport {fileExistsSync, loadJsonSync} from '../utils/fsutils.js';\n\ninterface WorkspacePackage {\n name: string;\n path: string;\n packageJson: PackageInfo;\n}\n\nexport function loadPackageJson(filepath: string): PackageInfo | null {\n if (!fileExistsSync(filepath)) {\n return null;\n }\n return loadJsonSync(filepath);\n}\n\n/**\n * Returns a map of all packages in the monorepo and the corresponding\n * package.json path.\n */\nfunction getMonorepoPackages(\n rootDir: string\n): Record<string, WorkspacePackage> {\n const monorepoRoot = getWorkspaceRoot(rootDir);\n if (!monorepoRoot) {\n return {};\n }\n\n const workspaces = getWorkspaces(monorepoRoot);\n const packages: Record<string, WorkspacePackage> = {};\n workspaces.forEach((workspaceInfo) => {\n packages[workspaceInfo.name] = workspaceInfo;\n });\n return packages;\n}\n\n/**\n * Returns the top-level monorepo package's deps, if any.\n */\nexport function getMonorepoPackageDeps(\n rootDir: string\n): Record<string, string> {\n const monorepoRoot = getWorkspaceRoot(rootDir);\n if (!monorepoRoot) {\n return {};\n }\n\n const packageJsonPath = path.join(monorepoRoot, 'package.json');\n const packageJson = loadPackageJson(packageJsonPath);\n return packageJson?.dependencies || {};\n}\n\n/**\n * Flattens package.json deps from the root project dir, taking into account any\n * deps from the monorepo root as well as any `workspace:` deps from within the\n * monorepo.\n */\nexport function flattenPackageDepsFromMonorepo(\n rootDir: string,\n options?: {ignore?: Set<string>}\n): Record<string, string> {\n const packageJsonPath = path.resolve(rootDir, 'package.json');\n const packageJson = loadPackageJson(packageJsonPath);\n const monorepoDeps = getMonorepoPackageDeps(rootDir);\n\n // Flatten `peerDependencies` and `dependencies`.\n const projectDeps = {\n ...packageJson?.peerDependencies,\n ...packageJson?.dependencies,\n };\n\n const allDeps: Record<string, string> = {};\n const workspacePackages = getMonorepoPackages(rootDir);\n const ignore = options?.ignore || new Set();\n Object.entries(projectDeps).forEach(([depName, depVersion]) => {\n if (\n depName.startsWith('@blinkk/root') &&\n depVersion.startsWith('workspace:')\n ) {\n const packageInfo = workspacePackages[depName];\n if (packageInfo) {\n allDeps[depName] = packageInfo.packageJson.version;\n }\n } else if (depVersion.startsWith('workspace:')) {\n // For internal packages within the workspace, recursively collect the\n // deps from those packages.\n if (ignore.has(depName)) {\n return;\n }\n ignore.add(depName);\n const packageInfo = workspacePackages[depName];\n if (packageInfo) {\n const workspacePackageDir = packageInfo.path;\n const deps = flattenPackageDepsFromMonorepo(workspacePackageDir, {\n ignore: ignore,\n });\n for (const key in deps) {\n const currentValue = allDeps[key];\n if (\n deps[key] &&\n deps[key] !== '*' &&\n (!currentValue || currentValue === '*')\n ) {\n allDeps[key] = deps[key];\n }\n }\n }\n } else if (depVersion === '*' && monorepoDeps[depName]) {\n // For any dependencies using a wildcard version `*`, if the top-level\n // package.json has the depdenency defined, overwrite the version.\n allDeps[depName] = monorepoDeps[depName];\n } else {\n allDeps[depName] = depVersion;\n }\n });\n return sortDeps(allDeps);\n}\n\nfunction sortDeps(deps: Record<string, string>): Record<string, string> {\n const keys = Object.keys(deps).sort();\n const sortedDeps: Record<string, string> = {};\n for (const key of keys) {\n sortedDeps[key] = deps[key];\n }\n return sortedDeps;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport fsExtra from 'fs-extra';\nimport glob from 'tiny-glob';\n\nexport function isJsFile(filename: string) {\n return !!filename.match(/\\.(j|t)sx?$/);\n}\n\nexport async function writeFile(filepath: string, content: string) {\n const dirPath = path.dirname(filepath);\n await makeDir(dirPath);\n await fs.promises.writeFile(filepath, content);\n}\n\nexport async function makeDir(dirpath: string) {\n try {\n await fs.promises.access(dirpath);\n } catch (e) {\n await fs.promises.mkdir(dirpath, {recursive: true});\n }\n}\n\nexport async function copyDir(srcdir: string, dstdir: string) {\n if (!fsExtra.existsSync(srcdir)) {\n return;\n }\n fsExtra.copySync(srcdir, dstdir, {overwrite: true});\n}\n\n/**\n * Copies a glob of files from one directory to another.\n *\n * Example:\n *\n * ```\n * await copyGlob('*.css', 'src/styles', 'dist/html/styles');\n * ```\n */\nexport async function copyGlob(\n pattern: string,\n srcdir: string,\n dstdir: string\n) {\n const files = await glob(pattern, {cwd: srcdir});\n if (files.length > 0) {\n await makeDir(dstdir);\n }\n files.forEach((file) => {\n fsExtra.copySync(path.resolve(srcdir, file), path.resolve(dstdir, file));\n });\n}\n\nexport async function rmDir(dirpath: string) {\n await fs.promises.rm(dirpath, {recursive: true, force: true});\n}\n\nexport async function loadJson<T = unknown>(filepath: string): Promise<T> {\n const content = await fs.promises.readFile(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport function loadJsonSync<T = unknown>(filepath: string): T {\n const content = fs.readFileSync(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport async function writeJson(filepath: string, data: any) {\n const content = JSON.stringify(data, null, 2);\n await writeFile(filepath, content);\n}\n\nexport async function isDirectory(dirpath: string) {\n return fs.promises\n .stat(dirpath)\n .then((fsStat) => {\n return fsStat.isDirectory();\n })\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return false;\n }\n throw err;\n });\n}\n\nexport function fileExists(filepath: string): Promise<boolean> {\n return fs.promises\n .access(filepath)\n .then(() => true)\n .catch(() => false);\n}\n\nexport function fileExistsSync(filepath: string): boolean {\n try {\n fs.accessSync(filepath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function dirExists(dirpath: string): Promise<boolean> {\n try {\n const stat = await fs.promises.stat(dirpath);\n return stat.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n return false;\n }\n throw error;\n }\n}\n\nexport async function directoryContains(\n dirpath: string,\n subpath: string\n): Promise<boolean> {\n const outer = await fs.promises.realpath(dirpath);\n const inner = await fs.promises.realpath(subpath);\n const rel = path.relative(outer, inner);\n return !rel.startsWith('..');\n}\n\nexport async function listFilesRecursive(dirPath: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await fs.promises.readdir(dirPath, {withFileTypes: true});\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n if (entry.isDirectory()) {\n const subFiles = await listFilesRecursive(fullPath);\n files.push(...subFiles);\n } else {\n files.push(fullPath);\n }\n }\n return files;\n}\n","import path from 'node:path';\nimport {bundleRequire} from 'bundle-require';\nimport {build, Plugin as EsbuildPlugin} from 'esbuild';\nimport {RootConfig} from '../core/config.js';\nimport {fileExists} from '../utils/fsutils.js';\nimport {flattenPackageDepsFromMonorepo} from './monorepo.js';\n\nexport interface ConfigOptions {\n command: string;\n}\n\nexport async function loadRootConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const {rootConfig} = await loadRootConfigWithDeps(rootDir, options);\n return rootConfig;\n}\n\nexport async function loadRootConfigWithDeps(\n rootDir: string,\n options: ConfigOptions\n): Promise<{rootConfig: RootConfig; dependencies: string[]}> {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const configBundle = await bundleRequire({\n filepath: configPath,\n esbuildOptions: {plugins: [esbuildExternalsPlugin({rootDir})]},\n });\n let config = configBundle.mod.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n const rootConfig = Object.assign({}, config, {rootDir});\n validateRootconfig(rootConfig);\n return {rootConfig, dependencies: configBundle.dependencies};\n}\n\nfunction validateRootconfig(rootConfig: RootConfig) {\n // Update vite legacy config options.\n const scss: any = rootConfig.vite?.css?.preprocessorOptions?.scss;\n if (scss?.includePaths) {\n console.warn(\n '[deprecation warning] root.config.ts: vite.css.preprocessorOptions.scss.includePaths is deprecated. rename \"includePaths\" -> \"loadPaths\"'\n );\n scss.loadPaths = scss.includePaths;\n }\n}\n\n/**\n * Compiles a root.config.ts file to root.config.js.\n */\nexport async function bundleRootConfig(rootDir: string, outPath: string) {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const configExists = await fileExists(configPath);\n if (!configExists) {\n throw new Error(`${configPath} does not exist`);\n }\n await build({\n entryPoints: [configPath],\n bundle: true,\n minify: true,\n platform: 'node',\n outfile: outPath,\n sourcemap: 'inline',\n metafile: true,\n format: 'esm',\n plugins: [esbuildExternalsPlugin({rootDir})],\n });\n}\n\n/**\n * Loads a pre-bundled config file from dist/root.config.js.\n */\nexport async function loadBundledConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const configPath = path.resolve(rootDir, 'dist/root.config.js');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const module = await import(configPath);\n let config = module.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n return Object.assign({}, config, {rootDir});\n}\n\n/**\n * Externalizes node_modules deps from the package and any dependent packages\n * from the monorepo.\n */\nfunction esbuildExternalsPlugin(options: {rootDir: string}): EsbuildPlugin {\n const rootDir = options.rootDir;\n const allDeps = flattenPackageDepsFromMonorepo(rootDir);\n\n function getPackageName(id: string): string {\n const segments = id.split('/');\n if (segments.length > 1) {\n // Check if package is an org path like `@blinkk/root`.\n if (segments[0].startsWith('@') && segments[0].length > 1) {\n return `${segments[0]}/${segments[1]}`;\n }\n // For imports like `my-package/subpackage`, return `my-package`.\n return segments[0];\n }\n return id;\n }\n\n return {\n name: 'root-externals-plugin',\n setup(build) {\n build.onResolve({filter: /.*/}, (args) => {\n const id = args.path;\n if (id[0] !== '.' && !id.startsWith('@/')) {\n const packageName = getPackageName(id);\n if (packageName in allDeps) {\n return {\n external: true,\n };\n }\n }\n return null;\n });\n },\n };\n}\n","import {createServer, ViteDevServer} from 'vite';\nimport type {Plugin, EnvironmentModuleNode} from 'vite';\nimport {RootConfig} from '../core/config.js';\nimport {getVitePlugins} from '../core/plugin.js';\nimport {preactToRootJsxPlugin} from './vite-plugin-preact-alias.js';\n\nexport interface CreateViteServerOptions {\n /** Override HMR settings. */\n hmr?: boolean;\n /** The port the server will run on. */\n port?: number;\n /** List of files to include in the optimizeDeps.include config. */\n optimizeDeps?: string[];\n}\n\n/**\n * Returns a vite dev server.\n */\nexport async function createViteServer(\n rootConfig: RootConfig,\n options?: CreateViteServerOptions\n): Promise<ViteDevServer> {\n const rootDir = rootConfig.rootDir;\n const viteConfig = rootConfig.vite || {};\n\n let hmrOptions = viteConfig.server?.hmr;\n if (options?.hmr === false) {\n hmrOptions = false;\n } else if (typeof hmrOptions === 'undefined' && options?.port) {\n // Automatically set the HMR port to `port + 10`. This allows multiple\n // root.js dev servers to run without conflicts.\n hmrOptions = {port: options.port + 10};\n }\n\n const viteServer = await createServer({\n ...viteConfig,\n mode: 'development',\n root: rootDir,\n // publicDir is disabled from the vite dev server since it's handled by the\n // root dev server directly, which allows user middlewares to override\n // files in the public dir.\n publicDir: false,\n server: {\n ...(viteConfig.server || {}),\n middlewareMode: true,\n hmr: hmrOptions,\n },\n appType: 'custom',\n optimizeDeps: {\n ...(viteConfig.optimizeDeps || {}),\n include: [\n ...(options?.optimizeDeps || []),\n ...(viteConfig.optimizeDeps?.include || []),\n ],\n extensions: [...(viteConfig.optimizeDeps?.extensions || []), '.tsx'],\n },\n ssr: {\n ...(viteConfig.ssr || {}),\n noExternal: ['@blinkk/root', '@blinkk/root-cms/richtext'],\n },\n plugins: [\n hmrSSRReload(),\n ...(rootConfig.jsxRenderer?.mode ? [preactToRootJsxPlugin()] : []),\n ...(viteConfig.plugins || []),\n ...getVitePlugins(rootConfig.plugins || []),\n ],\n });\n return viteServer;\n}\n\n/**\n * Shortcut `viteServer.ssrLoadModule()` without starting an actual dev server.\n */\nexport async function viteSsrLoadModule<T = Record<string, any>>(\n rootConfig: RootConfig,\n file: string\n): Promise<T> {\n const viteServer = await createViteServer(rootConfig, {hmr: false});\n const module = await viteServer.ssrLoadModule(file);\n await viteServer.close();\n return module as T;\n}\n\n/**\n * Vite plugin to reload the page when SSR modules change.\n * https://github.com/vitejs/vite/issues/19114\n */\nfunction hmrSSRReload(): Plugin {\n return {\n name: 'hmr-ssr-reload',\n enforce: 'post',\n hotUpdate: {\n order: 'post',\n handler({modules, server, timestamp}) {\n if (this.environment.name !== 'ssr') {\n return;\n }\n\n let hasSsrOnlyModules = false;\n const invalidatedModules = new Set<EnvironmentModuleNode>();\n for (const mod of modules) {\n if (mod.id === null) {\n continue;\n }\n const clientModule =\n server.environments.client.moduleGraph.getModuleById(mod.id);\n if (clientModule) {\n continue;\n }\n\n hasSsrOnlyModules = true;\n this.environment.moduleGraph.invalidateModule(\n mod,\n invalidatedModules,\n timestamp,\n true\n );\n }\n\n if (hasSsrOnlyModules) {\n server.ws.send({type: 'full-reload'});\n return [];\n }\n\n return;\n },\n },\n };\n}\n","import type {Plugin} from 'vite';\n\n/**\n * Vite plugin that aliases `preact` imports to `@blinkk/root/jsx`.\n *\n * When `jsxRenderer.mode` is configured, the project uses Root's built-in JSX\n * runtime instead of Preact. This plugin redirects all `preact` imports\n * (including `preact/hooks`, `preact/jsx-runtime`, etc.) so that Root's\n * built-in hooks and components use Root's context API rather than Preact's.\n */\nexport function preactToRootJsxPlugin(): Plugin {\n return {\n name: 'root:preact-to-jsx',\n config() {\n return {\n resolve: {\n alias: [\n {find: /^preact\\/hooks$/, replacement: '@blinkk/root/jsx'},\n {\n find: /^preact\\/jsx-runtime$/,\n replacement: '@blinkk/root/jsx/jsx-runtime',\n },\n {\n find: /^preact\\/jsx-dev-runtime$/,\n replacement: '@blinkk/root/jsx/jsx-dev-runtime',\n },\n {find: /^preact$/, replacement: '@blinkk/root/jsx'},\n ],\n },\n };\n },\n };\n}\n"],"mappings":";;;;;AAAA,OAAOA,WAAU;AACjB,SAAQ,eAAe,wBAAoC;;;ACD3D,OAAO,QAAQ;AACf,OAAO,UAAU;AAE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QAAQ,EAAC,SAAS,QAAQ,UAAS,GAAG;AACpC,YAAI,KAAK,YAAY,SAAS,OAAO;AACnC;AAAA,QACF;AAEA,YAAI,oBAAoB;AACxB,cAAM,qBAAqB,oBAAI,IAA2B;AAC1D,mBAAW,OAAO,SAAS;AACzB,cAAI,IAAI,OAAO,MAAM;AACnB;AAAA,UACF;AACA,gBAAM,eACJ,OAAO,aAAa,OAAO,YAAY,cAAc,IAAI,EAAE;AAC7D,cAAI,cAAc;AAChB;AAAA,UACF;AAEA,8BAAoB;AACpB,eAAK,YAAY,YAAY;AAAA,YAC3B;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAEA,YAAI,mBAAmB;AACrB,iBAAO,GAAG,KAAK,EAAC,MAAM,cAAa,CAAC;AACpC,iBAAO,CAAC;AAAA,QACV;AAEA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["path","path","path","path","build"]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
htmlPretty,
|
|
5
5
|
isValidTagName,
|
|
6
6
|
parseTagNames
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6P3B7ZXL.js";
|
|
8
8
|
import {
|
|
9
9
|
headersMiddleware,
|
|
10
10
|
rootProjectMiddleware,
|
|
@@ -27,10 +27,11 @@ import {
|
|
|
27
27
|
loadRootConfig,
|
|
28
28
|
loadRootConfigWithDeps,
|
|
29
29
|
makeDir,
|
|
30
|
+
preactToRootJsxPlugin,
|
|
30
31
|
rmDir,
|
|
31
32
|
writeFile,
|
|
32
33
|
writeJson
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-EBE4O463.js";
|
|
34
35
|
import {
|
|
35
36
|
configureServerPlugins,
|
|
36
37
|
getVitePlugins
|
|
@@ -319,14 +320,20 @@ var BuildAsset = class {
|
|
|
319
320
|
};
|
|
320
321
|
|
|
321
322
|
// src/utils/batch.ts
|
|
322
|
-
async function batchAsyncCalls(data,
|
|
323
|
-
const result =
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
323
|
+
async function batchAsyncCalls(data, concurrency, asyncFunction) {
|
|
324
|
+
const result = new Array(data.length);
|
|
325
|
+
let nextIndex = 0;
|
|
326
|
+
async function worker() {
|
|
327
|
+
while (nextIndex < data.length) {
|
|
328
|
+
const index = nextIndex++;
|
|
329
|
+
result[index] = await asyncFunction(data[index]);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const workers = Array.from(
|
|
333
|
+
{ length: Math.min(concurrency, data.length) },
|
|
334
|
+
() => worker()
|
|
335
|
+
);
|
|
336
|
+
await Promise.all(workers);
|
|
330
337
|
return result;
|
|
331
338
|
}
|
|
332
339
|
|
|
@@ -378,6 +385,7 @@ async function build(rootProjectDir, options) {
|
|
|
378
385
|
}
|
|
379
386
|
}
|
|
380
387
|
const vitePlugins = [
|
|
388
|
+
...rootConfig.jsxRenderer?.mode ? [preactToRootJsxPlugin()] : [],
|
|
381
389
|
...viteConfig.plugins || [],
|
|
382
390
|
...getVitePlugins(rootPlugins)
|
|
383
391
|
];
|
|
@@ -385,12 +393,6 @@ async function build(rootProjectDir, options) {
|
|
|
385
393
|
...viteConfig,
|
|
386
394
|
root: rootDir,
|
|
387
395
|
mode,
|
|
388
|
-
esbuild: {
|
|
389
|
-
...viteConfig.esbuild,
|
|
390
|
-
jsx: "automatic",
|
|
391
|
-
jsxImportSource: "preact",
|
|
392
|
-
treeShaking: true
|
|
393
|
-
},
|
|
394
396
|
plugins: vitePlugins
|
|
395
397
|
};
|
|
396
398
|
const ssrInput = {
|
|
@@ -415,8 +417,8 @@ async function build(rootProjectDir, options) {
|
|
|
415
417
|
publicDir: false,
|
|
416
418
|
build: {
|
|
417
419
|
...viteConfig?.build,
|
|
418
|
-
|
|
419
|
-
...viteConfig?.build?.
|
|
420
|
+
rolldownOptions: {
|
|
421
|
+
...viteConfig?.build?.rolldownOptions,
|
|
420
422
|
input: ssrInput,
|
|
421
423
|
output: {
|
|
422
424
|
format: "esm",
|
|
@@ -438,7 +440,7 @@ async function build(rootProjectDir, options) {
|
|
|
438
440
|
ssr: {
|
|
439
441
|
...viteConfig.ssr,
|
|
440
442
|
target: "node",
|
|
441
|
-
noExternal: ["@blinkk/root",
|
|
443
|
+
noExternal: ["@blinkk/root", ...noExternal]
|
|
442
444
|
}
|
|
443
445
|
});
|
|
444
446
|
await viteBuild({
|
|
@@ -446,8 +448,8 @@ async function build(rootProjectDir, options) {
|
|
|
446
448
|
publicDir: false,
|
|
447
449
|
build: {
|
|
448
450
|
...viteConfig?.build,
|
|
449
|
-
|
|
450
|
-
...viteConfig?.build?.
|
|
451
|
+
rolldownOptions: {
|
|
452
|
+
...viteConfig?.build?.rolldownOptions,
|
|
451
453
|
input: [...routeFiles],
|
|
452
454
|
output: {
|
|
453
455
|
format: "esm",
|
|
@@ -455,7 +457,7 @@ async function build(rootProjectDir, options) {
|
|
|
455
457
|
assetFileNames: "assets/[hash][extname]",
|
|
456
458
|
chunkFileNames: "chunks/[hash].min.js",
|
|
457
459
|
sanitizeFileName,
|
|
458
|
-
...viteConfig?.build?.
|
|
460
|
+
...viteConfig?.build?.rolldownOptions?.output
|
|
459
461
|
}
|
|
460
462
|
},
|
|
461
463
|
outDir: path3.join(distDir, ".build/routes"),
|
|
@@ -477,8 +479,8 @@ async function build(rootProjectDir, options) {
|
|
|
477
479
|
publicDir: false,
|
|
478
480
|
build: {
|
|
479
481
|
...viteConfig?.build,
|
|
480
|
-
|
|
481
|
-
...viteConfig?.build?.
|
|
482
|
+
rolldownOptions: {
|
|
483
|
+
...viteConfig?.build?.rolldownOptions,
|
|
482
484
|
input: [...elements, ...bundleScripts],
|
|
483
485
|
output: {
|
|
484
486
|
format: "esm",
|
|
@@ -486,7 +488,7 @@ async function build(rootProjectDir, options) {
|
|
|
486
488
|
assetFileNames: "assets/[hash][extname]",
|
|
487
489
|
chunkFileNames: "chunks/[hash].min.js",
|
|
488
490
|
sanitizeFileName,
|
|
489
|
-
...viteConfig?.build?.
|
|
491
|
+
...viteConfig?.build?.rolldownOptions?.output
|
|
490
492
|
}
|
|
491
493
|
},
|
|
492
494
|
outDir: path3.join(distDir, ".build/client"),
|
|
@@ -2103,4 +2105,4 @@ export {
|
|
|
2103
2105
|
createProdServer,
|
|
2104
2106
|
CliRunner
|
|
2105
2107
|
};
|
|
2106
|
-
//# sourceMappingURL=chunk-
|
|
2108
|
+
//# sourceMappingURL=chunk-G7OKXRD3.js.map
|