bruh 1.13.1 → 2.0.0-beta.1
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/browser/jsx-runtime.mjs +2 -0
- package/dist/browser/jsx-runtime.mjs.map +1 -0
- package/dist/browser.mjs +174 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/cli/node.mjs +16 -0
- package/dist/cli/node.mjs.map +1 -0
- package/dist/components/aside-toc.mjs +162 -0
- package/dist/components/aside-toc.mjs.map +1 -0
- package/dist/components/custom-elements.mjs +52 -0
- package/dist/components/custom-elements.mjs.map +1 -0
- package/dist/components/intl/date-time.mjs +219 -0
- package/dist/components/intl/date-time.mjs.map +1 -0
- package/dist/components/intl/display-name.mjs +71 -0
- package/dist/components/intl/display-name.mjs.map +1 -0
- package/dist/components/intl/language-picker.mjs +102 -0
- package/dist/components/intl/language-picker.mjs.map +1 -0
- package/dist/components/intl/list.mjs +80 -0
- package/dist/components/intl/list.mjs.map +1 -0
- package/dist/components/intl/number.mjs +118 -0
- package/dist/components/intl/number.mjs.map +1 -0
- package/dist/components/intl/plural.mjs +82 -0
- package/dist/components/intl/plural.mjs.map +1 -0
- package/dist/components/intl/utils.mjs +197 -0
- package/dist/components/intl/utils.mjs.map +1 -0
- package/dist/components/optimized-picture/hydrate.mjs +10 -0
- package/dist/components/optimized-picture/hydrate.mjs.map +1 -0
- package/dist/components/optimized-picture/server.mjs +28 -0
- package/dist/components/optimized-picture/server.mjs.map +1 -0
- package/dist/components/utils.mjs +4 -0
- package/dist/components/utils.mjs.map +1 -0
- package/dist/media/images/node.mjs +41 -0
- package/dist/media/images/node.mjs.map +1 -0
- package/dist/polyfills/weakref.mjs +16 -0
- package/dist/polyfills/weakref.mjs.map +1 -0
- package/dist/reactive/sync/transport/websocket/browser.mjs +52 -0
- package/dist/reactive/sync/transport/websocket/browser.mjs.map +1 -0
- package/dist/reactive.mjs +160 -0
- package/dist/reactive.mjs.map +1 -0
- package/dist/server/jsx-runtime.mjs +2 -0
- package/dist/server/jsx-runtime.mjs.map +1 -0
- package/dist/server.mjs +346 -0
- package/dist/server.mjs.map +1 -0
- package/dist/types/cli/index.d.mts +2 -0
- package/dist/types/components/aside-toc/index.d.ts +45 -0
- package/dist/types/components/custom-elements.d.mts +83 -0
- package/dist/types/components/intl/date-time.d.ts +138 -0
- package/dist/types/components/intl/display-name.d.ts +45 -0
- package/dist/types/components/intl/language-picker.d.ts +35 -0
- package/dist/types/components/intl/list.d.ts +41 -0
- package/dist/types/components/intl/number.d.ts +81 -0
- package/dist/types/components/intl/plural.d.ts +60 -0
- package/dist/types/components/intl/utils.d.mts +30 -0
- package/dist/types/components/optimized-picture/hydrate.d.mts +2 -0
- package/dist/types/components/optimized-picture/server.d.ts +8 -0
- package/dist/types/components/utils.d.mts +5 -0
- package/dist/types/dom/browser/jsx-runtime.d.mts +3 -0
- package/dist/types/dom/index.browser.d.mts +127 -0
- package/dist/types/dom/index.server.d.mts +174 -0
- package/dist/types/dom/server/jsx-runtime.d.mts +3 -0
- package/dist/types/dom/types.d.mts +9 -0
- package/dist/types/media/images.node.d.mts +1 -0
- package/dist/types/polyfills/weakref.d.mts +4 -0
- package/dist/types/reactive/index.d.mts +91 -0
- package/dist/types/reactive/sync/transport/websocket/browser.d.mts +11 -0
- package/dist/types/utils/browser.d.mts +2 -0
- package/dist/types/utils/index.d.mts +122 -0
- package/dist/utils/browser.mjs +27 -0
- package/dist/utils/browser.mjs.map +1 -0
- package/dist/utils.mjs +287 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +122 -19
- package/dist/bruh.es.js +0 -226
- package/dist/bruh.es.js.map +0 -1
- package/dist/bruh.umd.js +0 -2
- package/dist/bruh.umd.js.map +0 -1
- package/src/cli/index.mjs +0 -19
- package/src/components/optimized-picture/hydrate.mjs +0 -10
- package/src/components/optimized-picture/render.mjs +0 -26
- package/src/dom/index.browser.mjs +0 -270
- package/src/dom/index.server.mjs +0 -280
- package/src/index.browser.mjs +0 -3
- package/src/media/images.node.mjs +0 -70
- package/src/reactive/index.mjs +0 -160
- package/src/util/index.mjs +0 -42
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":["../src/dom/index.server.mts"],"sourcesContent":["import type {\n PropertyWiseOr,\n MaybePromise,\n LikelyAsString,\n LikelyAsAbsent,\n LikelyAsBoolean\n} from \"./types.mts\"\nimport type { PropertiesHyphen as Styles } from \"csstype\"\nimport type {\n HTMLTag,\n SVGTag,\n MathMLTag,\n\n Namespace,\n HTMLNamespace,\n SVGNamespace,\n MathMLNamespace,\n\n ElementToEventMap,\n ElementToAttributes\n} from \"html-info\"\nimport { makePromiseQueue } from \"../utils/index.mts\"\n\nexport type TerminalBruhChild =\n | LikelyAsString\n | LikelyAsAbsent\n | MetaNode\n | MetaRawString\n\nexport type BruhChild =\n | MaybePromise<TerminalBruhChild>\n | Promise<BruhChild>\n | Iterable<BruhChild>\n | AsyncIterable<BruhChild>\n\nexport type StylesToApply = {\n [Property in keyof Styles]: MaybePromise<Styles[Property] | LikelyAsAbsent>\n}\n\nexport interface ClassesToApply {\n [className: string]: MaybePromise<LikelyAsBoolean>\n}\n\nexport type AttributesToApply<\n Name extends string,\n NS extends Namespace = HTMLNamespace\n> = {\n [Attribute in keyof ElementToAttributes<Name, NS>]?:\n MaybePromise<ElementToAttributes<Name, NS>[Attribute] | LikelyAsBoolean>\n}\n\ntype EventMapToListenerProps<EventMap> = {\n [E in ((keyof EventMap) & string) as `on${E}`]:\n string\n}\n\ntype AttributeMapToProps<AttributeMap> = {\n [Attribute in keyof AttributeMap]:\n MaybePromise<AttributeMap[Attribute] | LikelyAsBoolean>\n | ( Attribute extends \"style\"\n ? StylesToApply\n : Attribute extends \"class\"\n ? ClassesToApply\n : never\n )\n}\n\nexport interface BruhOptions {\n namespace?: Namespace\n}\n\ninterface BaseBruhProps {\n bruh?: BruhOptions,\n children?: BruhChild\n}\n\nexport type BruhProps<\n Name extends string,\n NS extends string = HTMLNamespace\n>\n = BaseBruhProps\n & (\n NS extends HTMLNamespace\n ? { bruh?: { namespace?: HTMLNamespace } }\n : { bruh: { namespace: NS } }\n )\n & Partial<\n EventMapToListenerProps<ElementToEventMap<Name, NS>> &\n AttributeMapToProps<ElementToAttributes<Name, NS>>\n >\n\nexport type HTMLTagToBruhProps = { [Name in HTMLTag]: BruhProps<Name, HTMLNamespace> }\nexport type SVGTagToBruhProps = { [Name in SVGTag]: BruhProps<Name, SVGNamespace> }\nexport type MathMLTagToBruhProps = { [Name in MathMLTag]: BruhProps<Name, MathMLNamespace> }\n\nexport type TagToBruhProps =\n PropertyWiseOr<\n HTMLTagToBruhProps,\n PropertyWiseOr<\n SVGTagToBruhProps,\n MathMLTagToBruhProps\n >\n >\n\nexport namespace JSX {\n /** @see https://www.typescriptlang.org/docs/handbook/jsx.html#children-type-checking */\n export interface ElementChildrenAttribute { children: {} }\n\n /** @see https://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking */\n export interface IntrinsicElements extends TagToBruhProps {}\n\n export type Element = any\n\n export type ElementType = HTMLTag | SVGTag | MathMLTag | ((props: any) => Element)\n}\n\nconst isMetaNode = Symbol.for(\"bruh meta node\")\nconst isMetaTextNode = Symbol.for(\"bruh meta text node\")\nconst isMetaElement = Symbol.for(\"bruh meta element\")\nconst isMetaRawString = Symbol.for(\"bruh meta raw string\")\n\n//#region HTML syntax functions\n\n// https://html.spec.whatwg.org/multipage/syntax.html#void-elements\nconst voidElements = new Set([\n \"base\",\n \"link\",\n \"meta\",\n\n \"hr\",\n \"br\",\n \"wbr\",\n\n \"area\",\n \"img\",\n \"track\",\n\n \"embed\",\n \"param\",\n \"source\",\n\n \"col\",\n\n \"input\"\n] as const)\n\nconst isVoidElement = (element: string) =>\n voidElements.has(element as any)\n\n// https://html.spec.whatwg.org/multipage/syntax.html#elements-2\n// https://html.spec.whatwg.org/multipage/syntax.html#escapable-raw-text-elements (textarea and title)\n// https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions\nconst escapeForElementReplacer = (match: string) => match === \"&\" ? \"&\" : \"<\"\nconst escapeForElement = (x: LikelyAsString) =>\n (x + \"\").replace(/[&<]/g, escapeForElementReplacer)\n\n// https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements (script and style)\n// https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements\nconst escapeForScript = (x: LikelyAsString) =>\n (x + \"\")\n .replace(/<!--/g, \"\\\\x3C!--\")\n .replace(/<script/g, \"\\\\x3Cscript\")\n .replace(/<\\/script/g, \"\\\\x3C/script\")\n\nconst escapeForStyle = (x: LikelyAsString) =>\n (x + \"\")\n .replace(/<!--/g, \"\\\\x3C!--\")\n .replace(/<style/g, \"\\\\x3Cstyle\")\n .replace(/<\\/style/g, \"\\\\x3C/style\")\n\n// https://html.spec.whatwg.org/multipage/syntax.html#syntax-attribute-value\nconst escapeForDoubleQuotedAttributeReplacer = (match: string) => match === \"&\" ? \"&\" : \""\"\nconst escapeForDoubleQuotedAttribute = (x: LikelyAsString) =>\n (x + \"\").replace(/[&\"]/g, escapeForDoubleQuotedAttributeReplacer)\n\ntype Attributes = Partial<Record<string, MaybePromise<LikelyAsString | LikelyAsBoolean>>>\n\n// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2\nfunction * attributesToIterator(attributes: Attributes): IterableIterator<string> {\n for (const name in attributes) {\n const value = attributes[name]\n\n if (\n value == null\n || value === false\n || value instanceof Promise\n )\n continue\n\n yield ` ${name}`\n\n if (value === true || value === \"\")\n continue\n\n yield `=\"${escapeForDoubleQuotedAttribute(value)}\"`\n }\n}\n\n// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2\nasync function * attributesToAsyncIterator(attributes: Attributes): AsyncIterableIterator<string> {\n for (const name in attributes) {\n try {\n const value = await attributes[name]\n\n if (value == null || value === false)\n continue\n\n yield ` ${name}`\n\n if (value === true || value === \"\")\n continue\n\n yield `=\"${escapeForDoubleQuotedAttribute(value)}\"`\n }\n catch (e) {\n console.error(e)\n continue\n }\n }\n}\n\n//#endregion\n\n//#region Meta Nodes that act like lightweight rendering-oriented DOM nodes\n\ntype MetaNode =\n | MetaTextNode\n | MetaElement<string, Namespace>\n\n// Text nodes have no individual HTML representation\n// We emulate this with a custom element <bruh-text> with an inline style reset\n// These elements can be hydrated very quickly and even be marked with a tag\nexport class MetaTextNode {\n [isMetaNode] = true;\n [isMetaTextNode] = true\n\n textContent: MaybePromise<LikelyAsString>\n tag?: string\n\n constructor(textContent: MaybePromise<LikelyAsString>) {\n this.textContent = textContent\n }\n\n * [Symbol.iterator](): IterableIterator<string> {\n yield `<bruh-text style=\"all:unset;display:inline\"`\n if (this.tag)\n yield* attributesToIterator({ tag: this.tag })\n yield \">\"\n\n if (this.textContent instanceof Promise)\n yield \"<!--Promise-->\"\n else\n yield escapeForElement(this.textContent)\n\n yield \"</bruh-text>\"\n }\n\n async * [Symbol.asyncIterator](): AsyncIterableIterator<string> {\n yield `<bruh-text style=\"all:unset;display:inline\"`\n if (this.tag)\n yield* attributesToAsyncIterator({ tag: this.tag })\n yield \">\"\n\n try {\n yield escapeForElement(await this.textContent)\n }\n catch (e) {\n console.error(e)\n }\n\n yield \"</bruh-text>\"\n }\n\n toString(): string {\n let result = \"\"\n for (const chunk of this)\n result += chunk\n return result\n }\n\n async toStringPromise(): Promise<string> {\n let result = \"\"\n for await (const chunk of this)\n result += chunk\n return result\n }\n\n setTag(tag: string) {\n this.tag = tag\n\n return this\n }\n}\n\n// A light model of an element\nexport class MetaElement<\n Name extends string,\n NS extends Namespace = HTMLNamespace\n> {\n [isMetaNode] = true;\n [isMetaElement] = true\n\n name: Name\n attributes: AttributesToApply<Name, NS> = {}\n children: Array<BruhChild> = []\n\n #isRawTextOnly\n #escape\n\n constructor(name: Name) {\n this.name = name\n this.#isRawTextOnly = name === \"script\" || name === \"style\"\n this.#escape\n = name === \"script\" ? escapeForScript\n : name === \"style\" ? escapeForStyle\n : escapeForElement\n }\n\n * #childChunks(children: Iterable<BruhChild>): IterableIterator<string> {\n const partiallyFlattened =\n Array.isArray(children)\n ? children.flat<BruhChild, number>(Infinity)\n : children\n\n for (const child of partiallyFlattened) {\n if (child == null || typeof child === \"boolean\") {\n if (this.#isRawTextOnly)\n continue\n else\n yield `<!--${child}-->`\n }\n else if (typeof child === \"object\") {\n if (!this.#isRawTextOnly && isMetaNode in child)\n yield* child\n else if (!this.#isRawTextOnly && child instanceof Promise)\n yield \"<!--Promise-->\"\n else if (!this.#isRawTextOnly && Symbol.asyncIterator in child)\n yield \"<!--asyncIterator-->\"\n else if (isMetaRawString in child)\n yield child as any as string\n else if (Symbol.iterator in child)\n yield* this.#childChunks(child)\n }\n else\n yield this.#escape(child)\n }\n }\n\n async * #asyncChildChunks(children: Iterable<BruhChild> | AsyncIterable<BruhChild>): AsyncIterableIterator<string> {\n const partiallyFlattened =\n Array.isArray(children)\n ? children.flat<BruhChild, number>(Infinity)\n : children\n\n for await (const child of (partiallyFlattened as AsyncIterable<BruhChild>)) {\n if (child == null || typeof child === \"boolean\") {\n if (this.#isRawTextOnly)\n continue\n else\n yield `<!--${child}-->`\n }\n else if (typeof child === \"object\") {\n if (!this.#isRawTextOnly && isMetaNode in child)\n yield* child\n else if (isMetaRawString in child)\n yield child as any as string\n else if (Symbol.iterator in child || Symbol.asyncIterator in child)\n yield* this.#asyncChildChunks(child)\n }\n else\n yield this.#escape(child)\n }\n }\n\n * [Symbol.iterator](): IterableIterator<string> {\n // https://html.spec.whatwg.org/multipage/syntax.html#syntax-start-tag\n yield `<${this.name}`\n yield* attributesToIterator(this.attributes as Attributes)\n yield \">\"\n if (isVoidElement(this.name))\n return\n\n yield* this.#childChunks(this.children)\n\n // https://html.spec.whatwg.org/multipage/syntax.html#end-tags\n yield `</${this.name}>`\n }\n\n async * [Symbol.asyncIterator](): AsyncIterableIterator<string> {\n // https://html.spec.whatwg.org/multipage/syntax.html#syntax-start-tag\n yield `<${this.name}`\n yield* attributesToAsyncIterator(this.attributes as Attributes)\n yield \">\"\n if (isVoidElement(this.name))\n return\n\n yield* this.#asyncChildChunks(this.children)\n\n // https://html.spec.whatwg.org/multipage/syntax.html#end-tags\n yield `</${this.name}>`\n }\n\n toString(): string {\n let result = \"\"\n for (const chunk of this)\n result += chunk\n return result\n }\n\n async toStringPromise(): Promise<string> {\n let result = \"\"\n for await (const chunk of this)\n result += chunk\n return result\n }\n}\n\n// Raw strings can be meta element children, where they bypass string escaping\n// This should be avoided in general, but is needed for unsupported HTML features\nexport class MetaRawString extends String {\n [isMetaRawString] = true\n\n constructor(string: LikelyAsString) {\n super(string)\n }\n}\n\n//#endregion\n\n//#region Meta element helper functions e.g. applyAttributes()\n\ntype ElementWithStyle = MetaElement<string, HTMLNamespace | SVGNamespace | MathMLNamespace>\n\n// Merge style rules with an object\nexport const applyStyles = (\n element: ElementWithStyle,\n styles: StylesToApply\n) => {\n // TODO handle promises\n\n // Doesn't support proper escaping\n // https://www.w3.org/TR/css-syntax-3/#ref-for-parse-a-list-of-declarations%E2%91%A0\n // https://www.w3.org/TR/css-syntax-3/#typedef-ident-token\n const currentStyles =\n typeof element.attributes.style === \"string\"\n ? Object.fromEntries(\n element.attributes.style\n .split(\";\").filter(s => s.length)\n .map(declaration => declaration.split(\":\").map(s => s.trim()))\n )\n : {}\n\n Object.entries(styles)\n .forEach(([property, value]) => {\n if (value != null && typeof value !== \"boolean\")\n currentStyles[property] = value\n else\n delete currentStyles[property]\n })\n\n element.attributes.style =\n Object.entries(currentStyles)\n .map(([property, value]) => `${property}:${value}`)\n .join(\";\")\n}\n\n// Merge classes with an object mapping from class names to booleans\nexport const applyClasses = (\n element: MetaElement<string, Namespace>,\n classes: ClassesToApply\n) => {\n // TODO handle promises\n\n // Doesn't support proper escaping\n // https://html.spec.whatwg.org/multipage/dom.html#global-attributes:classes-2\n const currentClasses = new Set(\n typeof element.attributes.class === \"string\"\n ? element.attributes.class\n .split(/\\s+/).filter(s => s.length)\n : undefined\n )\n\n Object.entries(classes)\n .forEach(([name, value]) => {\n if (value)\n currentClasses.add(name)\n else\n currentClasses.delete(name)\n })\n\n element.attributes.class = [...currentClasses].join(\" \")\n}\n\n// Merge attributes with an object\nexport const applyAttributes = <\n Name extends string,\n NS extends Namespace = HTMLNamespace\n>(\n element: MetaElement<Name, NS>,\n attributes: AttributesToApply<Name, NS>\n) => {\n Object.assign(element.attributes, attributes)\n}\n\n//#endregion\n\n//#region rawString() and t()\n\nexport const rawString = (string: LikelyAsString) =>\n new MetaRawString(string)\n\nexport const t = (textContent: MaybePromise<LikelyAsString>) =>\n new MetaTextNode(textContent)\n\n//#endregion\n\n//#region JSX integration\n\nexport const jsx: {\n /**\n * Create an HTML element\n */\n <\n Name extends HTMLTag\n >(\n name: Name,\n props: HTMLTagToBruhProps[Name],\n key?: string\n ):\n MetaElement<Name, HTMLNamespace>\n\n /**\n * Create an SVG element\n */\n <\n Name extends SVGTag\n >(\n name: Name,\n props: SVGTagToBruhProps[Name],\n key?: string\n ):\n MetaElement<Name, SVGNamespace>\n\n /**\n * Create a MathML element\n */\n <\n Name extends MathMLTag\n >(\n name: Name,\n props: MathMLTagToBruhProps[Name],\n key?: string\n ):\n MetaElement<Name, MathMLNamespace>\n\n /**\n * Create an element\n */\n <\n Name extends string,\n NS extends Namespace = HTMLNamespace\n >(\n name: Name,\n props: BruhProps<Name, NS>,\n key?: string\n ):\n MetaElement<Name, NS>\n\n /**\n * Call a function as a JSX component\n */\n <\n Props extends Record<any, unknown>,\n Result\n >(\n component: (props: Props) => Result,\n props: Props,\n key?: string\n ): Result\n} =\n<\n Name extends string,\n NS extends Namespace = HTMLNamespace\n>\n(\n nameOrComponent: Name | Function,\n props_: Record<any, unknown>,\n key?: string\n) => {\n if (key !== undefined)\n props_.key = key\n\n // It must be a component, as bruh components are just functions\n // Due to JSX, this would mean a function with only one parameter - props\n // This object includes all of the normal props and a \"children\" key\n if (typeof nameOrComponent !== \"string\") {\n const component = nameOrComponent\n const props = props_ as Record<any, unknown>\n\n return component(props)\n }\n\n const name = nameOrComponent\n const props = props_ as BruhProps<Name, NS>\n\n // Extract explicit options from the bruh prop\n let options: BruhOptions = {}\n if (typeof props.bruh === \"object\" && !(props.bruh instanceof Promise)) {\n options = props.bruh\n delete props.bruh\n }\n // const { namespace } = options\n\n const element = new MetaElement<Name, NS>(name)\n\n if (\"children\" in props) {\n if (Array.isArray(props.children))\n element.children.push(...props.children)\n else\n element.children.push(props.children)\n\n delete props.children\n }\n\n // Apply overloaded props, if possible\n\n // Inline style object\n if (\n \"style\" in props &&\n props.style != null &&\n typeof props.style === \"object\" &&\n !(props.style instanceof Promise)\n ) {\n applyStyles(element, props.style)\n delete props.style\n }\n\n // Classes object\n if (\n \"class\" in props &&\n props.class != null &&\n typeof props.class === \"object\" &&\n !(props.class instanceof Promise)\n ) {\n applyClasses(element, props.class)\n delete props.class\n }\n\n // The rest of the props are attributes\n applyAttributes(element, props as AttributesToApply<Name, NS>)\n\n return element\n}\n\nexport const Fragment =\n <Children extends BruhChild>\n (props: { children: Children }) => props.children\n\n//#endregion\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bruh-deferred\": HTMLElement\n }\n}\ndeclare module \"html-info\" {\n interface HTMLTagToAttributes {\n \"bruh-deferred\": {\n \"data-replace\": `bruh-deferred-${number}`\n }\n }\n}\n\nexport const replaceDeferredScriptContent\n = `\"use strict\";`\n + `customElements.define(\"bruh-deferred\",class extends HTMLElement{`\n + \"connectedCallback(){\"\n + \"const t=this.previousElementSibling;\"\n + \"document.getElementById(this.dataset.replace).replaceWith(t.content);\"\n + \"t.remove();\"\n + \"this.remove()\"\n + \"}\"\n + \"})\"\n\n/**\n * \"Content-Security-Policy\": `script-src '${replaceDeferredHash}'`\n */\nexport const replaceDeferredHash =\n \"sha512-+xpsela6B2jMNhk2cPpAgB4Z89EeB6yltQ208+kvcbUKlkg11dBjAlj2FbNFxeE0kqOuZhdVVldl3hz1yZD38Q==\"\n\ntype MetaDocumentDeferFunction =\n<P extends BruhChild>\n(\n context: {\n placeholder: (id: `bruh-deferred-${number}`) => P\n content: Promise<BruhChild>\n }\n) => P\n\ntype MetaDocumentDisabledDeferFunction =\n(\n context: {\n content: Promise<BruhChild>\n }\n) => Promise<BruhChild>\n\ntype MetaDocumentFunction = (\n context: {\n defer: MetaDocumentDeferFunction,\n deferred: AsyncIterableIterator<MetaElement<\"template\" | \"bruh-deferred\">>,\n replaceDeferredScript: MetaElement<\"script\">\n } | {\n defer: MetaDocumentDisabledDeferFunction,\n deferred?: undefined\n replaceDeferredScript?: undefined\n }\n) => MetaElement<string>\n\nexport class MetaDocument {\n #metaElementOrFunction: MetaElement<string> | MetaDocumentFunction\n\n constructor(metaElementOrFunction: MetaElement<string> | MetaDocumentFunction) {\n this.#metaElementOrFunction = metaElementOrFunction\n }\n\n * [Symbol.iterator](): IterableIterator<string> {\n if (!(isMetaElement in this.#metaElementOrFunction))\n throw new Error(\"Not a meta element\")\n\n const metaElement = this.#metaElementOrFunction\n\n // https://html.spec.whatwg.org/#the-doctype\n yield \"<!doctype html>\"\n yield* metaElement\n }\n\n async * [Symbol.asyncIterator]({ deferred: allowDefer = true } = {}): AsyncIterableIterator<string> {\n // https://html.spec.whatwg.org/#the-doctype\n yield \"<!doctype html>\"\n if (isMetaElement in this.#metaElementOrFunction) {\n const metaElement = this.#metaElementOrFunction\n yield* metaElement\n return\n }\n\n const documentFunction = this.#metaElementOrFunction\n\n if (!allowDefer) {\n const defer: MetaDocumentDisabledDeferFunction = ({ content }) => content\n yield* documentFunction({ defer })\n return\n }\n\n const deferQueue = makePromiseQueue<{ id: `bruh-deferred-${number}`, content: BruhChild }, unknown>()\n let deferCount = 0\n const defer: MetaDocumentDeferFunction = ({ placeholder, content }) => {\n const id = `bruh-deferred-${deferCount++}` as const\n deferQueue.enqueue(content.then(content => ({ id, content })))\n return placeholder(id)\n }\n\n // https://html.spec.whatwg.org/#parsing-main-afterbody:parse-errors-3\n // https://html.spec.whatwg.org/#the-after-after-body-insertion-mode:parse-errors\n // Should place deferred content before the closing </body> tag.\n // Placing after is defined to parse as if it was before the </body> anyways,\n // but it's technically a parse error and browsers are allowed to drop the content.\n const deferred = (async function * () {\n for await (const settled of deferQueue) {\n if (settled.status === \"rejected\") {\n console.error(settled.reason)\n continue\n }\n const { id, content } = settled.value\n yield jsx(\"template\", { children: content })\n yield jsx(\"bruh-deferred\", { \"data-replace\": id })\n }\n })()\n\n const replaceDeferredScript = jsx(\"script\", { children: replaceDeferredScriptContent })\n\n yield* documentFunction({ defer, deferred, replaceDeferredScript })\n }\n\n toStream({ deferred = true } = {}): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder()\n\n const asyncIterator = this[Symbol.asyncIterator]({ deferred })\n\n return new ReadableStream({\n async pull(controller) {\n const { value, done } = await asyncIterator.next()\n if (done) {\n controller.close()\n return\n }\n\n controller.enqueue(\n encoder.encode(value)\n )\n }\n })\n }\n\n toResponse({ deferred = true } = {}): Response {\n return new Response(this.toStream({ deferred }), {\n headers: {\n \"Content-Type\": \"text/html; charset=utf-8\"\n }\n })\n }\n\n toString(): string {\n let result = \"\"\n for (const chunk of this)\n result += chunk\n return result\n }\n\n async toStringPromise({ deferred = false } = {}): Promise<string> {\n let result = \"\"\n for await (const chunk of this[Symbol.asyncIterator]({ deferred }))\n result += chunk\n return result\n }\n}\n"],"names":["props","defer","content"],"mappings":";;AAoHA,MAAM,UAAA,mBAAyB,MAAA,CAAA,GAAA,CAAI,gBAAgB,CAAA;AACnD,MAAM,cAAA,mBAAyB,MAAA,CAAA,GAAA,CAAI,qBAAqB,CAAA;AACxD,MAAM,aAAA,mBAAyB,MAAA,CAAA,GAAA,CAAI,mBAAmB,CAAA;AACtD,MAAM,eAAA,mBAAyB,MAAA,CAAA,GAAA,CAAI,sBAAsB,CAAA;AAKzD,MAAM,YAAA,uBAAmB,GAAI,CAAA;AAAA,EAC3B,MAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EAEA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,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AAA;AAE7D,IAAA,OAAO,IAAI,cAAe,CAAA;AAAA,MACxB,MAAM,KAAK,UAAY,EAAA;AACrB,QAAA,MAAM,EAAE,KAAO,EAAA,IAAA,EAAS,GAAA,MAAM,cAAc,IAAK,EAAA;AACjD,QAAA,IAAI,IAAM,EAAA;AACR,UAAA,UAAA,CAAW,KAAM,EAAA;AACjB,UAAA;AAAA;AAGF,QAAW,UAAA,CAAA,OAAA;AAAA,UACT,OAAA,CAAQ,OAAO,KAAK;AAAA,SACtB;AAAA;AACF,KACD,CAAA;AAAA;AACH,EAEA,WAAW,EAAE,QAAA,GAAW,IAAK,EAAA,GAAI,EAAc,EAAA;AAC7C,IAAA,OAAO,IAAI,QAAS,CAAA,IAAA,CAAK,SAAS,EAAE,QAAA,EAAU,CAAG,EAAA;AAAA,MAC/C,OAAS,EAAA;AAAA,QACP,cAAgB,EAAA;AAAA;AAClB,KACD,CAAA;AAAA;AACH,EAEA,QAAmB,GAAA;AACjB,IAAA,IAAI,MAAS,GAAA,EAAA;AACb,IAAA,KAAA,MAAW,KAAS,IAAA,IAAA;AAClB,MAAU,MAAA,IAAA,KAAA;AACZ,IAAO,OAAA,MAAA;AAAA;AACT,EAEA,MAAM,eAAgB,CAAA,EAAE,WAAW,KAAM,EAAA,GAAI,EAAqB,EAAA;AAChE,IAAA,IAAI,MAAS,GAAA,EAAA;AACb,IAAA,WAAA,MAAiB,SAAS,IAAK,CAAA,MAAA,CAAO,aAAa,CAAE,CAAA,EAAE,UAAU,CAAA;AAC/D,MAAU,MAAA,IAAA,KAAA;AACZ,IAAO,OAAA,MAAA;AAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BruhCustomElementBase } from '../custom-elements.mts';
|
|
2
|
+
type BruhAsideTOCAttributes = {
|
|
3
|
+
"headings"?: ReadonlyArray<string>;
|
|
4
|
+
"container"?: string;
|
|
5
|
+
"max-level": 2 | 3 | 4 | 5 | 6;
|
|
6
|
+
"probabilistic-influence"?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class BruhAsideTOC extends BruhCustomElementBase<BruhAsideTOCAttributes> {
|
|
9
|
+
#private;
|
|
10
|
+
static observedAttributes: readonly ["headings", "container", "max-level", "probabilistic-influence"];
|
|
11
|
+
static bruh: {
|
|
12
|
+
parseAttributes: {
|
|
13
|
+
headings: (s: string | null) => string[];
|
|
14
|
+
container: (s: string | null) => string | undefined;
|
|
15
|
+
"max-level": (s: string | null) => number;
|
|
16
|
+
"probabilistic-influence": (s: string | null) => number | undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
constructor();
|
|
20
|
+
mountedCallback(): void;
|
|
21
|
+
}
|
|
22
|
+
declare global {
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
"bruh-aside-toc": BruhAsideTOC;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
declare module "html-info" {
|
|
28
|
+
interface HTMLTagToAttributes {
|
|
29
|
+
"bruh-aside-toc": {
|
|
30
|
+
/**
|
|
31
|
+
* Space separated list of heading ids
|
|
32
|
+
*/
|
|
33
|
+
"headings"?: ReadonlyArray<string>;
|
|
34
|
+
/** Content container id */
|
|
35
|
+
"container"?: string;
|
|
36
|
+
"max-level"?: `${2 | 3 | 4 | 5 | 6}`;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
declare module "csstype" {
|
|
41
|
+
interface PropertiesHyphen {
|
|
42
|
+
"--prominence"?: number;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { SourceNode } from '../reactive/index.mts';
|
|
2
|
+
export declare class CustomElement extends HTMLElement {
|
|
3
|
+
/**
|
|
4
|
+
* Which attributes to observe for `attributeChangedCallback()`
|
|
5
|
+
*/
|
|
6
|
+
static observedAttributes?: ReadonlyArray<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Disable `attachInternals()` and/or `attachShadow()`
|
|
9
|
+
*/
|
|
10
|
+
static disabledFeatures?: ReadonlyArray<"internals" | "shadow">;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the element is form-associated
|
|
13
|
+
*/
|
|
14
|
+
static formAssociated?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Called whenever the element is connected to a document
|
|
17
|
+
* @see https://html.spec.whatwg.org/multipage/infrastructure.html#becomes-connected
|
|
18
|
+
*/
|
|
19
|
+
connectedCallback?(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Called whenever the element is disconnected from a document
|
|
22
|
+
* @see https://html.spec.whatwg.org/multipage/infrastructure.html#becomes-disconnected
|
|
23
|
+
*/
|
|
24
|
+
disconnectedCallback?(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Called whenever the element is moved to a new document
|
|
27
|
+
* @see https://dom.spec.whatwg.org/#concept-node-move-ext
|
|
28
|
+
*/
|
|
29
|
+
connectedMoveCallback?(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Called whenever the element is adopted by a new document
|
|
32
|
+
* @see https://dom.spec.whatwg.org/#concept-node-adopt
|
|
33
|
+
*/
|
|
34
|
+
adoptedCallback?(oldDocument: Document, newDocument: Document): void;
|
|
35
|
+
/**
|
|
36
|
+
* Called whenever an attribute is changed, appended, removed, or replaced
|
|
37
|
+
* @see https://dom.spec.whatwg.org/#concept-element-attributes-change-ext
|
|
38
|
+
*/
|
|
39
|
+
attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null, namespace: string | null): void;
|
|
40
|
+
/**
|
|
41
|
+
* Called (if the element is form-associated) whenever the form "owner" of the element is reset and doing so changes the form that owns the element
|
|
42
|
+
* @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#reset-the-form-owner
|
|
43
|
+
*/
|
|
44
|
+
formAssociatedCallback?(formOwner: HTMLFormElement | null): void;
|
|
45
|
+
/**
|
|
46
|
+
* Called (if the element is form-associated) whenever the form "owner" of the element is reset
|
|
47
|
+
* @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-reset
|
|
48
|
+
*/
|
|
49
|
+
formResetCallback?(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Called (if the element is form-associated) whenever the element is disabled or enabled
|
|
52
|
+
* @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-disabled
|
|
53
|
+
*/
|
|
54
|
+
formDisabledCallback?(isDisabled: boolean): void;
|
|
55
|
+
/**
|
|
56
|
+
* Called (if the element is form-associated) whenever the element's value is restored
|
|
57
|
+
* @see https://html.spec.whatwg.org/multipage/browsing-the-web.html#restore-persisted-state
|
|
58
|
+
*/
|
|
59
|
+
formStateRestoreCallback?(state: FormDataEntryValue | FormDataIterator<[string, FormDataEntryValue]> | null, reason: "autocomplete" | "restore"): void;
|
|
60
|
+
}
|
|
61
|
+
export declare class BruhCustomElementBase<Attributes extends {
|
|
62
|
+
[attribute: string]: any;
|
|
63
|
+
} = {}> extends CustomElement {
|
|
64
|
+
#private;
|
|
65
|
+
static bruh?: {
|
|
66
|
+
parseAttributes?: Partial<{
|
|
67
|
+
[attribute: string]: (raw: string | null) => any;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
70
|
+
bruh: {
|
|
71
|
+
attributes: { [A in (keyof Attributes & string)]: SourceNode<Attributes[A] | undefined>; };
|
|
72
|
+
};
|
|
73
|
+
constructor();
|
|
74
|
+
attributeChangedCallback<A extends keyof Attributes & string>(name: A, oldValue: string | null, newValue: string | null, namespace: string | null): void;
|
|
75
|
+
/**
|
|
76
|
+
* Overrides must call `super.connectedCallback()`
|
|
77
|
+
*/
|
|
78
|
+
connectedCallback(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Called when the element is first connected to a document
|
|
81
|
+
*/
|
|
82
|
+
mountedCallback?(): void;
|
|
83
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { BruhCustomElementBase } from '../custom-elements.mts';
|
|
2
|
+
/**
|
|
3
|
+
* In minutes from UTC/GMT, same as `new Date().getTimezoneOffset()`, but for any time zone
|
|
4
|
+
*
|
|
5
|
+
* `undefined` if unknown
|
|
6
|
+
*/
|
|
7
|
+
export declare const getTimeZoneOffset: (timeZone?: string) => number | undefined;
|
|
8
|
+
export declare const currentTimeZone: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* Makes a date that has a UTC time set to the input date's local time in the given time zone
|
|
11
|
+
*/
|
|
12
|
+
export declare const localDateInUTC: (date: Date | number, timeZone: string) => Date | undefined;
|
|
13
|
+
export declare const hideRedundantOptions: (originalFormatter: Intl.DateTimeFormat, { date, endDate, now }: {
|
|
14
|
+
date: Date;
|
|
15
|
+
endDate?: Date;
|
|
16
|
+
now?: Date;
|
|
17
|
+
}) => Intl.DateTimeFormat;
|
|
18
|
+
export declare const parseDate: (unparsed?: string | null) => {
|
|
19
|
+
readonly type: "now";
|
|
20
|
+
readonly date?: undefined;
|
|
21
|
+
readonly unparsed?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: "date";
|
|
24
|
+
readonly date: Date;
|
|
25
|
+
readonly unparsed?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "unparsed";
|
|
28
|
+
readonly unparsed: string;
|
|
29
|
+
readonly date?: undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
export type ParsedDate = ReturnType<typeof parseDate>;
|
|
32
|
+
type BruhDateTimeAttributes = {
|
|
33
|
+
"date"?: ParsedDate;
|
|
34
|
+
"end-date"?: ParsedDate;
|
|
35
|
+
"locales"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>;
|
|
36
|
+
"hide-redundant-options"?: boolean;
|
|
37
|
+
"locale-matcher"?: Intl.DateTimeFormatOptions["localeMatcher"];
|
|
38
|
+
"calendar"?: Intl.DateTimeFormatOptions["calendar"];
|
|
39
|
+
"numbering-system"?: Intl.DateTimeFormatOptions["numberingSystem"];
|
|
40
|
+
"hour12"?: Intl.DateTimeFormatOptions["hour12"];
|
|
41
|
+
"hour-cycle"?: Intl.DateTimeFormatOptions["hourCycle"];
|
|
42
|
+
"time-zone"?: Intl.DateTimeFormatOptions["timeZone"];
|
|
43
|
+
"weekday"?: Intl.DateTimeFormatOptions["weekday"];
|
|
44
|
+
"era"?: Intl.DateTimeFormatOptions["era"];
|
|
45
|
+
"year"?: Intl.DateTimeFormatOptions["year"];
|
|
46
|
+
"month"?: Intl.DateTimeFormatOptions["month"];
|
|
47
|
+
"day"?: Intl.DateTimeFormatOptions["day"];
|
|
48
|
+
"day-period"?: Intl.DateTimeFormatOptions["dayPeriod"];
|
|
49
|
+
"hour"?: Intl.DateTimeFormatOptions["hour"];
|
|
50
|
+
"minute"?: Intl.DateTimeFormatOptions["minute"];
|
|
51
|
+
"second"?: Intl.DateTimeFormatOptions["second"];
|
|
52
|
+
"fractional-second-digits"?: Intl.DateTimeFormatOptions["fractionalSecondDigits"];
|
|
53
|
+
"time-zone-name"?: Intl.DateTimeFormatOptions["timeZoneName"];
|
|
54
|
+
"format-matcher"?: Intl.DateTimeFormatOptions["formatMatcher"];
|
|
55
|
+
"date-style"?: Intl.DateTimeFormatOptions["dateStyle"];
|
|
56
|
+
"time-style"?: Intl.DateTimeFormatOptions["timeStyle"];
|
|
57
|
+
};
|
|
58
|
+
export declare class BruhDateTime extends BruhCustomElementBase<BruhDateTimeAttributes> {
|
|
59
|
+
#private;
|
|
60
|
+
static observedAttributes: string[];
|
|
61
|
+
static bruh: {
|
|
62
|
+
parseAttributes: {
|
|
63
|
+
date: (unparsed?: string | null) => {
|
|
64
|
+
readonly type: "now";
|
|
65
|
+
readonly date?: undefined;
|
|
66
|
+
readonly unparsed?: undefined;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "date";
|
|
69
|
+
readonly date: Date;
|
|
70
|
+
readonly unparsed?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
readonly type: "unparsed";
|
|
73
|
+
readonly unparsed: string;
|
|
74
|
+
readonly date?: undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
"end-date": (unparsed?: string | null) => {
|
|
77
|
+
readonly type: "now";
|
|
78
|
+
readonly date?: undefined;
|
|
79
|
+
readonly unparsed?: undefined;
|
|
80
|
+
} | {
|
|
81
|
+
readonly type: "date";
|
|
82
|
+
readonly date: Date;
|
|
83
|
+
readonly unparsed?: undefined;
|
|
84
|
+
} | {
|
|
85
|
+
readonly type: "unparsed";
|
|
86
|
+
readonly unparsed: string;
|
|
87
|
+
readonly date?: undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
locales: {
|
|
90
|
+
(s: string): string[];
|
|
91
|
+
(s?: null): undefined;
|
|
92
|
+
(s?: string | null): string[] | undefined;
|
|
93
|
+
};
|
|
94
|
+
"hide-redundant-options": (v?: string | null) => v is string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
constructor();
|
|
98
|
+
mountedCallback(): void;
|
|
99
|
+
}
|
|
100
|
+
declare global {
|
|
101
|
+
interface HTMLElementTagNameMap {
|
|
102
|
+
"bruh-date-time": BruhDateTime;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
declare module "html-info" {
|
|
106
|
+
interface HTMLTagToAttributes {
|
|
107
|
+
"bruh-date-time": {
|
|
108
|
+
"date"?: string;
|
|
109
|
+
"end-date"?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Space separated list of locales
|
|
112
|
+
*/
|
|
113
|
+
"locales"?: string;
|
|
114
|
+
"hide-redundant-options"?: boolean;
|
|
115
|
+
"locale-matcher"?: Intl.DateTimeFormatOptions["localeMatcher"];
|
|
116
|
+
"calendar"?: Intl.DateTimeFormatOptions["calendar"];
|
|
117
|
+
"numbering-system"?: Intl.DateTimeFormatOptions["numberingSystem"];
|
|
118
|
+
"hour12"?: Intl.DateTimeFormatOptions["hour12"];
|
|
119
|
+
"hour-cycle"?: Intl.DateTimeFormatOptions["hourCycle"];
|
|
120
|
+
"time-zone"?: Intl.DateTimeFormatOptions["timeZone"];
|
|
121
|
+
"weekday"?: Intl.DateTimeFormatOptions["weekday"];
|
|
122
|
+
"era"?: Intl.DateTimeFormatOptions["era"];
|
|
123
|
+
"year"?: Intl.DateTimeFormatOptions["year"];
|
|
124
|
+
"month"?: Intl.DateTimeFormatOptions["month"];
|
|
125
|
+
"day"?: Intl.DateTimeFormatOptions["day"];
|
|
126
|
+
"day-period"?: Intl.DateTimeFormatOptions["dayPeriod"];
|
|
127
|
+
"hour"?: Intl.DateTimeFormatOptions["hour"];
|
|
128
|
+
"minute"?: Intl.DateTimeFormatOptions["minute"];
|
|
129
|
+
"second"?: Intl.DateTimeFormatOptions["second"];
|
|
130
|
+
"fractional-second-digits"?: Intl.DateTimeFormatOptions["fractionalSecondDigits"] | `${Intl.DateTimeFormatOptions["fractionalSecondDigits"]}`;
|
|
131
|
+
"time-zone-name"?: Intl.DateTimeFormatOptions["timeZoneName"];
|
|
132
|
+
"format-matcher"?: Intl.DateTimeFormatOptions["formatMatcher"];
|
|
133
|
+
"date-style"?: Intl.DateTimeFormatOptions["dateStyle"];
|
|
134
|
+
"time-style"?: Intl.DateTimeFormatOptions["timeStyle"];
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BruhCustomElementBase } from '../custom-elements.mts';
|
|
2
|
+
type BruhDisplayNameAttributes = {
|
|
3
|
+
"code"?: string;
|
|
4
|
+
"locales"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>;
|
|
5
|
+
"locale-matcher"?: Intl.DisplayNamesOptions["localeMatcher"];
|
|
6
|
+
"format-style"?: Intl.DisplayNamesOptions["style"];
|
|
7
|
+
"type"?: Intl.DisplayNamesOptions["type"];
|
|
8
|
+
"language-display"?: Intl.DisplayNamesOptions["languageDisplay"];
|
|
9
|
+
};
|
|
10
|
+
export declare class BruhDisplayName extends BruhCustomElementBase<BruhDisplayNameAttributes> {
|
|
11
|
+
#private;
|
|
12
|
+
static observedAttributes: readonly ["code", "locales", ...("type" | "locale-matcher" | "format-style" | "language-display")[]];
|
|
13
|
+
static bruh: {
|
|
14
|
+
parseAttributes: {
|
|
15
|
+
locales: {
|
|
16
|
+
(s: string): string[];
|
|
17
|
+
(s?: null): undefined;
|
|
18
|
+
(s?: string | null): string[] | undefined;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
constructor();
|
|
23
|
+
mountedCallback(): void;
|
|
24
|
+
}
|
|
25
|
+
declare global {
|
|
26
|
+
interface HTMLElementTagNameMap {
|
|
27
|
+
"bruh-display-name": BruhDisplayName;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
declare module "html-info" {
|
|
31
|
+
interface HTMLTagToAttributes {
|
|
32
|
+
"bruh-display-name": {
|
|
33
|
+
"code": string;
|
|
34
|
+
/**
|
|
35
|
+
* Space separated list of locales
|
|
36
|
+
*/
|
|
37
|
+
"locales"?: string;
|
|
38
|
+
"locale-matcher"?: Intl.DisplayNamesOptions["localeMatcher"];
|
|
39
|
+
"format-style"?: Intl.DisplayNamesOptions["style"];
|
|
40
|
+
"type": Intl.DisplayNamesOptions["type"];
|
|
41
|
+
"language-display"?: Intl.DisplayNamesOptions["languageDisplay"];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BruhCustomElementBase } from '../custom-elements.mts';
|
|
2
|
+
type BruhLanguagePickerAttributes = {
|
|
3
|
+
"languages": ReadonlyArray<Intl.Locale>;
|
|
4
|
+
};
|
|
5
|
+
export declare class BruhLanguagePicker extends BruhCustomElementBase<BruhLanguagePickerAttributes> {
|
|
6
|
+
#private;
|
|
7
|
+
static observedAttributes: string[];
|
|
8
|
+
static bruh: {
|
|
9
|
+
parseAttributes: {
|
|
10
|
+
languages: {
|
|
11
|
+
(s: string): string[];
|
|
12
|
+
(s?: null): undefined;
|
|
13
|
+
(s?: string | null): string[] | undefined;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
constructor();
|
|
18
|
+
mountedCallback(): void;
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
"bruh-language-picker": BruhLanguagePicker;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare module "html-info" {
|
|
26
|
+
interface HTMLTagToAttributes {
|
|
27
|
+
"bruh-language-picker": {
|
|
28
|
+
/**
|
|
29
|
+
* Space separated list of locales
|
|
30
|
+
*/
|
|
31
|
+
"languages": string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BruhCustomElementBase } from '../custom-elements.mts';
|
|
2
|
+
type BruhListAttributes = {
|
|
3
|
+
"locales"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>;
|
|
4
|
+
"locale-matcher"?: Intl.ListFormatOptions["localeMatcher"];
|
|
5
|
+
"type"?: Intl.ListFormatOptions["type"];
|
|
6
|
+
"format-style"?: Intl.ListFormatOptions["style"];
|
|
7
|
+
};
|
|
8
|
+
export declare class BruhList extends BruhCustomElementBase<BruhListAttributes> {
|
|
9
|
+
#private;
|
|
10
|
+
static observedAttributes: string[];
|
|
11
|
+
static bruh: {
|
|
12
|
+
parseAttributes: {
|
|
13
|
+
locales: {
|
|
14
|
+
(s: string): string[];
|
|
15
|
+
(s?: null): undefined;
|
|
16
|
+
(s?: string | null): string[] | undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
constructor();
|
|
21
|
+
mountedCallback(): void;
|
|
22
|
+
}
|
|
23
|
+
declare global {
|
|
24
|
+
interface HTMLElementTagNameMap {
|
|
25
|
+
"bruh-list": BruhList;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
declare module "html-info" {
|
|
29
|
+
interface HTMLTagToAttributes {
|
|
30
|
+
"bruh-list": {
|
|
31
|
+
/**
|
|
32
|
+
* Space separated list of locales
|
|
33
|
+
*/
|
|
34
|
+
"locales"?: string;
|
|
35
|
+
"locale-matcher"?: Intl.ListFormatOptions["localeMatcher"];
|
|
36
|
+
"type"?: Intl.ListFormatOptions["type"];
|
|
37
|
+
"format-style"?: Intl.ListFormatOptions["style"];
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { BruhCustomElementBase } from '../custom-elements.mts';
|
|
2
|
+
type BruhNumberAttributes = {
|
|
3
|
+
"number"?: Intl.StringNumericLiteral | string;
|
|
4
|
+
"end-number"?: Intl.StringNumericLiteral | string;
|
|
5
|
+
"locales"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>;
|
|
6
|
+
"locale-matcher"?: Intl.NumberFormatOptions["localeMatcher"];
|
|
7
|
+
"numbering-system"?: Intl.NumberFormatOptions["numberingSystem"];
|
|
8
|
+
"format-style"?: Intl.NumberFormatOptions["style"];
|
|
9
|
+
"currency"?: Intl.NumberFormatOptions["currency"];
|
|
10
|
+
"currency-display"?: Intl.NumberFormatOptions["currencyDisplay"];
|
|
11
|
+
"currency-sign"?: Intl.NumberFormatOptions["currencySign"];
|
|
12
|
+
"unit"?: Intl.NumberFormatOptions["unit"];
|
|
13
|
+
"unit-display"?: Intl.NumberFormatOptions["unitDisplay"];
|
|
14
|
+
"minimum-integer-digits"?: Intl.NumberFormatOptions["minimumIntegerDigits"];
|
|
15
|
+
"minimum-fraction-digits"?: Intl.NumberFormatOptions["minimumFractionDigits"];
|
|
16
|
+
"maximum-fraction-digits"?: Intl.NumberFormatOptions["maximumFractionDigits"];
|
|
17
|
+
"minimum-significant-digits"?: Intl.NumberFormatOptions["minimumSignificantDigits"];
|
|
18
|
+
"maximum-significant-digits"?: Intl.NumberFormatOptions["maximumSignificantDigits"];
|
|
19
|
+
"rounding-priority"?: Intl.NumberFormatOptions["roundingPriority"];
|
|
20
|
+
"rounding-increment"?: Intl.NumberFormatOptions["roundingIncrement"];
|
|
21
|
+
"rounding-mode"?: Intl.NumberFormatOptions["roundingMode"];
|
|
22
|
+
"trailing-zero-display"?: Intl.NumberFormatOptions["trailingZeroDisplay"];
|
|
23
|
+
"notation"?: Intl.NumberFormatOptions["notation"];
|
|
24
|
+
"compact-display"?: Intl.NumberFormatOptions["compactDisplay"];
|
|
25
|
+
"use-grouping"?: Intl.NumberFormatOptions["useGrouping"];
|
|
26
|
+
"sign-display"?: Intl.NumberFormatOptions["signDisplay"];
|
|
27
|
+
};
|
|
28
|
+
export declare class BruhNumber extends BruhCustomElementBase<BruhNumberAttributes> {
|
|
29
|
+
#private;
|
|
30
|
+
static observedAttributes: string[];
|
|
31
|
+
static bruh: {
|
|
32
|
+
parseAttributes: {
|
|
33
|
+
locales: {
|
|
34
|
+
(s: string): string[];
|
|
35
|
+
(s?: null): undefined;
|
|
36
|
+
(s?: string | null): string[] | undefined;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
constructor();
|
|
41
|
+
mountedCallback(): void;
|
|
42
|
+
}
|
|
43
|
+
declare global {
|
|
44
|
+
interface HTMLElementTagNameMap {
|
|
45
|
+
"bruh-number": BruhNumber;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
declare module "html-info" {
|
|
49
|
+
interface HTMLTagToAttributes {
|
|
50
|
+
"bruh-number": {
|
|
51
|
+
"number": Intl.StringNumericLiteral | string;
|
|
52
|
+
"end-number"?: Intl.StringNumericLiteral | string;
|
|
53
|
+
/**
|
|
54
|
+
* Space separated list of locales
|
|
55
|
+
*/
|
|
56
|
+
"locales"?: string;
|
|
57
|
+
"locale-matcher"?: Intl.NumberFormatOptions["localeMatcher"];
|
|
58
|
+
"numbering-system"?: Intl.NumberFormatOptions["numberingSystem"];
|
|
59
|
+
"format-style"?: Intl.NumberFormatOptions["style"];
|
|
60
|
+
"currency"?: Intl.NumberFormatOptions["currency"];
|
|
61
|
+
"currency-display"?: Intl.NumberFormatOptions["currencyDisplay"];
|
|
62
|
+
"currency-sign"?: Intl.NumberFormatOptions["currencySign"];
|
|
63
|
+
"unit"?: Intl.NumberFormatOptions["unit"];
|
|
64
|
+
"unit-display"?: Intl.NumberFormatOptions["unitDisplay"];
|
|
65
|
+
"minimum-integer-digits"?: Intl.NumberFormatOptions["minimumIntegerDigits"] | `${number}`;
|
|
66
|
+
"minimum-fraction-digits"?: Intl.NumberFormatOptions["minimumFractionDigits"] | `${number}`;
|
|
67
|
+
"maximum-fraction-digits"?: Intl.NumberFormatOptions["maximumFractionDigits"] | `${number}`;
|
|
68
|
+
"minimum-significant-digits"?: Intl.NumberFormatOptions["minimumSignificantDigits"] | `${number}`;
|
|
69
|
+
"maximum-significant-digits"?: Intl.NumberFormatOptions["maximumSignificantDigits"] | `${number}`;
|
|
70
|
+
"rounding-priority"?: Intl.NumberFormatOptions["roundingPriority"];
|
|
71
|
+
"rounding-increment"?: Intl.NumberFormatOptions["roundingIncrement"] | `${Intl.NumberFormatOptions["roundingIncrement"]}`;
|
|
72
|
+
"rounding-mode"?: Intl.NumberFormatOptions["roundingMode"];
|
|
73
|
+
"trailing-zero-display"?: Intl.NumberFormatOptions["trailingZeroDisplay"];
|
|
74
|
+
"notation"?: Intl.NumberFormatOptions["notation"];
|
|
75
|
+
"compact-display"?: Intl.NumberFormatOptions["compactDisplay"];
|
|
76
|
+
"use-grouping"?: Intl.NumberFormatOptions["useGrouping"];
|
|
77
|
+
"sign-display"?: Intl.NumberFormatOptions["signDisplay"];
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BruhCustomElementBase } from '../custom-elements.mts';
|
|
2
|
+
type BruhPluralAttributes = {
|
|
3
|
+
"number"?: Intl.StringNumericLiteral | string;
|
|
4
|
+
"end-number"?: Intl.StringNumericLiteral | string;
|
|
5
|
+
"locales"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>;
|
|
6
|
+
"locale-matcher"?: Intl.PluralRulesOptions["localeMatcher"];
|
|
7
|
+
"type"?: Intl.PluralRulesOptions["type"];
|
|
8
|
+
"minimum-integer-digits"?: Intl.PluralRulesOptions["minimumIntegerDigits"];
|
|
9
|
+
"minimum-fraction-digits"?: Intl.PluralRulesOptions["minimumFractionDigits"];
|
|
10
|
+
"maximum-fraction-digits"?: Intl.PluralRulesOptions["maximumFractionDigits"];
|
|
11
|
+
"minimum-significant-digits"?: Intl.PluralRulesOptions["minimumSignificantDigits"];
|
|
12
|
+
"maximum-significant-digits"?: Intl.PluralRulesOptions["maximumSignificantDigits"];
|
|
13
|
+
"rounding-priority"?: Intl.PluralRulesOptions["roundingPriority"];
|
|
14
|
+
"rounding-increment"?: Intl.PluralRulesOptions["roundingIncrement"];
|
|
15
|
+
"rounding-mode"?: Intl.PluralRulesOptions["roundingMode"];
|
|
16
|
+
"trailing-zero-display"?: Intl.PluralRulesOptions["trailingZeroDisplay"];
|
|
17
|
+
};
|
|
18
|
+
export declare class BruhPlural extends BruhCustomElementBase<BruhPluralAttributes> {
|
|
19
|
+
#private;
|
|
20
|
+
static observedAttributes: string[];
|
|
21
|
+
static bruh: {
|
|
22
|
+
parseAttributes: {
|
|
23
|
+
locales: {
|
|
24
|
+
(s: string): string[];
|
|
25
|
+
(s?: null): undefined;
|
|
26
|
+
(s?: string | null): string[] | undefined;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
constructor();
|
|
31
|
+
}
|
|
32
|
+
declare global {
|
|
33
|
+
interface HTMLElementTagNameMap {
|
|
34
|
+
"bruh-plural": BruhPlural;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
declare module "html-info" {
|
|
38
|
+
interface HTMLTagToAttributes {
|
|
39
|
+
"bruh-plural": {
|
|
40
|
+
"number": Intl.StringNumericLiteral | string;
|
|
41
|
+
"end-number"?: Intl.StringNumericLiteral | string;
|
|
42
|
+
/**
|
|
43
|
+
* Space separated list of locales
|
|
44
|
+
*/
|
|
45
|
+
"locales"?: string;
|
|
46
|
+
"locale-matcher"?: Intl.PluralRulesOptions["localeMatcher"];
|
|
47
|
+
"type"?: Intl.PluralRulesOptions["type"];
|
|
48
|
+
"minimum-integer-digits"?: Intl.NumberFormatOptions["minimumIntegerDigits"] | `${number}`;
|
|
49
|
+
"minimum-fraction-digits"?: Intl.NumberFormatOptions["minimumFractionDigits"] | `${number}`;
|
|
50
|
+
"maximum-fraction-digits"?: Intl.NumberFormatOptions["maximumFractionDigits"] | `${number}`;
|
|
51
|
+
"minimum-significant-digits"?: Intl.NumberFormatOptions["minimumSignificantDigits"] | `${number}`;
|
|
52
|
+
"maximum-significant-digits"?: Intl.NumberFormatOptions["maximumSignificantDigits"] | `${number}`;
|
|
53
|
+
"rounding-priority"?: Intl.PluralRulesOptions["roundingPriority"];
|
|
54
|
+
"rounding-increment"?: Intl.PluralRulesOptions["roundingIncrement"] | `${Intl.PluralRulesOptions["roundingIncrement"]}`;
|
|
55
|
+
"rounding-mode"?: Intl.PluralRulesOptions["roundingMode"];
|
|
56
|
+
"trailing-zero-display"?: Intl.PluralRulesOptions["trailingZeroDisplay"];
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SourceNode } from '../../reactive/index.mts';
|
|
2
|
+
export type InputLocale = Intl.UnicodeBCP47LocaleIdentifier | Intl.Locale | null | undefined;
|
|
3
|
+
export declare const parseLocale: (locale: InputLocale) => Intl.Locale | undefined;
|
|
4
|
+
export declare const parseLocales: (locales: ReadonlyArray<InputLocale> | InputLocale) => Intl.Locale[];
|
|
5
|
+
export declare const parseRegion: (region?: string | null) => string | undefined;
|
|
6
|
+
export declare const inferRegion: (locale: InputLocale) => string | undefined;
|
|
7
|
+
export declare const inferDirection: (locale: InputLocale) => "ltr" | "rtl" | undefined;
|
|
8
|
+
export declare const languageDisplayName: (displayNames: Intl.DisplayNames, language: InputLocale) => string;
|
|
9
|
+
export declare const generalizedLocales: (locale: InputLocale) => Intl.Locale[];
|
|
10
|
+
export declare const bestAvailableLocales: (available: ReadonlyArray<InputLocale>, preferred: ReadonlyArray<InputLocale>) => {
|
|
11
|
+
matches: Intl.Locale[];
|
|
12
|
+
alsoAvailable: Intl.Locale[];
|
|
13
|
+
};
|
|
14
|
+
export declare const browserLanguages: SourceNode<ReadonlyArray<Intl.Locale>>;
|
|
15
|
+
export declare const languagePickerLanguages: SourceNode<ReadonlyArray<Intl.Locale>>;
|
|
16
|
+
export declare const userLanguages: import('../../reactive/index.mts').DerivativeNode<readonly Intl.Locale[]>;
|
|
17
|
+
export declare const userRegions: import('../../reactive/index.mts').DerivativeNode<readonly string[]>;
|
|
18
|
+
export declare const segmentTree: (locales: Intl.LocalesArgument, content: string) => {
|
|
19
|
+
readonly type: "sentence";
|
|
20
|
+
readonly content: ({
|
|
21
|
+
readonly type: "grapheme";
|
|
22
|
+
readonly content: string;
|
|
23
|
+
}[] | {
|
|
24
|
+
readonly type: "word";
|
|
25
|
+
readonly content: {
|
|
26
|
+
readonly type: "grapheme";
|
|
27
|
+
readonly content: string;
|
|
28
|
+
}[];
|
|
29
|
+
})[];
|
|
30
|
+
}[];
|