brumate 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/check.d.ts +49 -0
- package/dist/{boot-D-IdPy7B.d.ts → boot-DLlRmD9z.d.ts} +11 -10
- package/dist/cli.js +275 -15
- package/dist/cli.js.map +1 -1
- package/dist/client-BvDsC6Qr.js +3463 -0
- package/dist/client-BvDsC6Qr.js.map +1 -0
- package/dist/client-DBwL2wKQ.d.ts +669 -0
- package/dist/{client-routes-JTbGtukf.js → client-routes-BtGpYCef.js} +60 -30
- package/dist/client-routes-BtGpYCef.js.map +1 -0
- package/dist/{cookies-Av5WFmcf.js → cookies-Cnbf4w-S.js} +15 -7
- package/dist/cookies-Cnbf4w-S.js.map +1 -0
- package/dist/{defer-D0bo1Gqx.js → defer-CKWZLv2K.js} +8 -4
- package/dist/defer-CKWZLv2K.js.map +1 -0
- package/dist/devtools-4uTPwR_v.js +597 -0
- package/dist/devtools-4uTPwR_v.js.map +1 -0
- package/dist/devtools-panel-Be9pxYgv.js +1994 -0
- package/dist/devtools-panel-Be9pxYgv.js.map +1 -0
- package/dist/events-LgLdp1R7.js +114 -0
- package/dist/events-LgLdp1R7.js.map +1 -0
- package/dist/features-CHY5Ekku.js +30 -0
- package/dist/features-CHY5Ekku.js.map +1 -0
- package/dist/files-WW4RlajL.js +506 -0
- package/dist/files-WW4RlajL.js.map +1 -0
- package/dist/forms-j1xPAR14.d.ts +281 -0
- package/dist/forms-nXK7-Lv_.js +440 -0
- package/dist/forms-nXK7-Lv_.js.map +1 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.js +278 -0
- package/dist/highlight.js.map +1 -0
- package/dist/html-BtKRyi7g.js +305 -0
- package/dist/html-BtKRyi7g.js.map +1 -0
- package/dist/html-Bw9Qwu6F.d.ts +107 -0
- package/dist/index.d.ts +142 -11
- package/dist/index.js +641 -106
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BJtACnQp.js → inspect-Y6y4uNZp.js} +4333 -681
- package/dist/inspect-Y6y4uNZp.js.map +1 -0
- package/dist/{loader-B18i3_-T.js → loader-BjKGJzLN.js} +21 -14
- package/dist/loader-BjKGJzLN.js.map +1 -0
- package/dist/logo-DQ_OYhBi.js +10 -0
- package/dist/logo-DQ_OYhBi.js.map +1 -0
- package/dist/{navigate-BwuZveDF.js → navigate-CfOr-TRF.js} +130 -24
- package/dist/navigate-CfOr-TRF.js.map +1 -0
- package/dist/nesting-DA5vJw9X.js +265 -0
- package/dist/nesting-DA5vJw9X.js.map +1 -0
- package/dist/produce-B7X9ori9.js +402 -0
- package/dist/produce-B7X9ori9.js.map +1 -0
- package/dist/produce-DIgHBVwL.d.ts +148 -0
- package/dist/{rpc-B-Zkn6Ch.js → rpc-Q-XkLwFh.js} +28 -13
- package/dist/rpc-Q-XkLwFh.js.map +1 -0
- package/dist/runtime/batch.js +9 -7
- package/dist/runtime/batch.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/devtools.d.ts +172 -5
- package/dist/runtime/devtools.js +3 -1
- package/dist/runtime/env.js +14 -2
- package/dist/runtime/env.js.map +1 -1
- package/dist/runtime/events.d.ts +38 -1
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/forms.d.ts +2 -0
- package/dist/runtime/forms.js +1 -0
- package/dist/runtime/gather.d.ts +25 -0
- package/dist/runtime/gather.js +33 -0
- package/dist/runtime/gather.js.map +1 -0
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/hot.js +5 -2
- package/dist/runtime/hot.js.map +1 -1
- package/dist/runtime/html.d.ts +2 -2
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/routes.js +4 -1
- package/dist/runtime/routes.js.map +1 -1
- package/dist/runtime/server.d.ts +5 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +75 -2
- package/dist/runtime/signals.js +44 -2
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +18 -3
- package/dist/runtime/testing.js +150 -33
- package/dist/runtime/testing.js.map +1 -1
- package/dist/runtime/values.d.ts +2 -0
- package/dist/runtime/values.js +24 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/{server-BA9SJ2Vm.d.ts → server-BvPIg9pT.d.ts} +363 -32
- package/dist/{server-BqfM95r1.js → server-DjyOVJtJ.js} +1309 -220
- package/dist/server-DjyOVJtJ.js.map +1 -0
- package/dist/{static-loader-BzE9SRaj.d.ts → static-loader-BGgdp_Y5.d.ts} +2 -2
- package/dist/static-loader-BZR17hSw.js +312 -0
- package/dist/static-loader-BZR17hSw.js.map +1 -0
- package/dist/{stream-JaMHMdBD.js → stream-BP5AVmg5.js} +182 -17
- package/dist/stream-BP5AVmg5.js.map +1 -0
- package/dist/values-B8C7CLvG.d.ts +63 -0
- package/dist/vite.d.ts +20 -20
- package/dist/vite.js +2031 -539
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +951 -0
- package/forms/forms.brm.ts +141 -0
- package/package.json +41 -3
- package/skills/brumate/SKILL.md +58 -0
- package/skills/brumate/references/errors.md +2078 -0
- package/skills/brumate/references/events.md +117 -0
- package/skills/brumate/references/signals.md +61 -0
- package/skills/brumate/references/state.md +235 -0
- package/skills/brumate/references/syntax.md +250 -0
- package/types.d.ts +4 -4
- package/dist/client-C0UCNL3J.js +0 -1643
- package/dist/client-C0UCNL3J.js.map +0 -1
- package/dist/client-MD0ZmcFR.d.ts +0 -354
- package/dist/client-routes-JTbGtukf.js.map +0 -1
- package/dist/cookies-Av5WFmcf.js.map +0 -1
- package/dist/defer-D0bo1Gqx.js.map +0 -1
- package/dist/devtools-C50VH8gZ.js +0 -113
- package/dist/devtools-C50VH8gZ.js.map +0 -1
- package/dist/devtools-panel-AYjfwPhj.js +0 -435
- package/dist/devtools-panel-AYjfwPhj.js.map +0 -1
- package/dist/events-BKWRqtMg.js +0 -52
- package/dist/events-BKWRqtMg.js.map +0 -1
- package/dist/files-Bnn1JqHx.js +0 -192
- package/dist/files-Bnn1JqHx.js.map +0 -1
- package/dist/html-bHZbkK-h.js +0 -170
- package/dist/html-bHZbkK-h.js.map +0 -1
- package/dist/html-y1q7-t7D.d.ts +0 -60
- package/dist/inspect-BJtACnQp.js.map +0 -1
- package/dist/loader-B18i3_-T.js.map +0 -1
- package/dist/navigate-BwuZveDF.js.map +0 -1
- package/dist/produce-CWfJ4byV.js +0 -167
- package/dist/produce-CWfJ4byV.js.map +0 -1
- package/dist/produce-D4K7qpaL.d.ts +0 -72
- package/dist/rpc-B-Zkn6Ch.js.map +0 -1
- package/dist/server-BqfM95r1.js.map +0 -1
- package/dist/static-loader-DOygOFj5.js +0 -216
- package/dist/static-loader-DOygOFj5.js.map +0 -1
- package/dist/stream-JaMHMdBD.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-BtKRyi7g.js","names":[],"sources":["../src/runtime/html.ts"],"sourcesContent":["// HTML string helpers that the server and the client both use.\n\nconst RAW: unique symbol = Symbol.for('brumate.raw');\n\n/** HTML that is inserted as it is, such as the output of a template. */\nexport interface Raw {\n [RAW]: string;\n}\n\n// A class, not an object literal, so serializers can skip their test for raw HTML on plain objects.\nclass RawHTML implements Raw {\n readonly [RAW]: string;\n\n constructor(html: string) {\n this[RAW] = html;\n }\n}\n\nexport function raw(html: string): Raw {\n return new RawHTML(html);\n}\n\nexport function isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && RAW in value;\n}\n\nexport function rawHTML(value: Raw): string {\n return value[RAW];\n}\n\nconst ESCAPES: Record<string, string> = { '&': '&', '<': '<', '>': '>', '\"': '"' };\n\nfunction toEscape(char: string): string {\n return ESCAPES[char]!;\n}\n\n// Most text has nothing to escape, so a test without the global flag skips the replace.\nexport function escape(value: string): string {\n return /[&<>]/.test(value) ? value.replace(/[&<>]/g, toEscape) : value;\n}\n\nexport function escapeAttribute(value: string): string {\n return /[&<\"]/.test(value) ? value.replace(/[&<\"]/g, toEscape) : value;\n}\n\n/** True for a promise, or any object with a `then` function, as the server awaits it. */\nfunction isThenable(value: unknown): boolean {\n return (\n value !== null &&\n (typeof value === 'object' || typeof value === 'function') &&\n typeof (value as PromiseLike<unknown>).then === 'function'\n );\n}\n\n/** Renders a value inserted in markup. A promise is not awaited: it renders empty. */\nexport function insertValue(value: unknown): string {\n if (isRaw(value)) {\n return value[RAW];\n }\n // A memo of a promise that is still loading: empty until its value lands.\n if (value === null || value === undefined || typeof value === 'boolean' || isThenable(value)) {\n return '';\n }\n if (Array.isArray(value)) {\n let result = '';\n for (const item of value) {\n result += insertValue(item);\n }\n return result;\n }\n return escape(String(value));\n}\n\n/**\n * Renders a value as the text of an element whose content is text, such as\n * a `<textarea>`, as `insertValue` does but without escaping.\n */\nexport function textValue(value: unknown): string {\n if (isRaw(value)) {\n return value[RAW];\n }\n if (value === null || value === undefined || typeof value === 'boolean' || isThenable(value)) {\n return '';\n }\n if (Array.isArray(value)) {\n let result = '';\n for (const item of value) {\n result += textValue(item);\n }\n return result;\n }\n return String(value);\n}\n\nfunction toKebabCase(name: string): string {\n return name.startsWith('--') ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\nexport function classValue(value: unknown): string {\n if (typeof value !== 'object' || value === null) {\n return value ? String(value) : '';\n }\n let text = '';\n if (Array.isArray(value)) {\n for (const item of value) {\n const part = classValue(item);\n if (part !== '') {\n text = text === '' ? part : `${text} ${part}`;\n }\n }\n return text;\n }\n // An empty name still adds a space between its neighbours, as in a join.\n let first = true;\n for (const name in value) {\n if (Object.hasOwn(value, name) && (value as Record<string, unknown>)[name]) {\n text = first ? name : `${text} ${name}`;\n first = false;\n }\n }\n return text;\n}\n\n/**\n * Renders a `class` attribute from classes that each have a space before\n * them, which the compiler builds from a literal class value. The classes\n * are escaped already. No class renders nothing.\n */\nexport function classAttribute(classes: string): string {\n return classes === '' ? '' : ` class=\"${classes.slice(1)}\"`;\n}\n\nfunction styleValue(value: unknown): string {\n if (typeof value === 'object' && value !== null) {\n const declarations: string[] = [];\n for (const [name, item] of Object.entries(value)) {\n if (item !== null && item !== undefined && item !== false) {\n declarations.push(`${toKebabCase(name)}:${String(item)}`);\n }\n }\n return declarations.join(';');\n }\n return String(value);\n}\n\n/** The brand of a binding of `$bind`, under the key of the registry. See `Binding`. */\nconst BOUND = Symbol.for('brumate.binding');\n\n/** The words of an attribute that says `true` or `false` in its value. */\nconst TRUE_FALSE = ['true', 'false'] as const;\n\n/**\n * Attributes whose two states are words in the value, not whether the\n * attribute is there, by their words for `true` and `false`. A missing\n * attribute means a third state, such as the default of the element, so\n * `false` must not remove it. `aria-*` and `data-*` are such attributes too.\n */\nconst SWITCHES = new Map<string, readonly [string, string]>([\n ['contenteditable', TRUE_FALSE],\n ['draggable', TRUE_FALSE],\n ['spellcheck', TRUE_FALSE],\n ['writingsuggestions', TRUE_FALSE],\n // SVG.\n ['focusable', TRUE_FALSE],\n ['translate', ['yes', 'no']],\n ['autocomplete', ['on', 'off']],\n ['autocorrect', ['on', 'off']],\n]);\n\n/** The words of `true` and `false` for an attribute that says them in its value, or undefined. */\nfunction switchWords(name: string): readonly [string, string] | undefined {\n const lower = name.toLowerCase();\n if (lower.startsWith('aria-') || lower.startsWith('data-')) {\n return TRUE_FALSE;\n }\n return SWITCHES.get(lower);\n}\n\n/**\n * Returns the text of an attribute, or undefined if the attribute is not\n * rendered.\n *\n * - `null` and `undefined` leave the attribute out.\n * - For an attribute whose value says its state, such as `aria-expanded`,\n * `draggable` or `translate`, `true` and `false` render as its words:\n * `\"true\"` and `\"false\"`, or `\"yes\"` and `\"no\"`, or `\"on\"` and `\"off\"`.\n * - For other attributes, such as `disabled`, `true` renders the attribute\n * without a value, and `false` leaves it out.\n */\nexport function attributeText(name: string, value: unknown): string | undefined {\n // `value=$bind(name)` on an element renders the value of the name.\n if (typeof value === 'object' && value !== null && BOUND in value) {\n // A `ref` is no attribute: the element goes to its signal.\n if (name === 'ref') {\n return undefined;\n }\n value = (value as unknown as { value: unknown }).value;\n }\n // A promise is a memo that is still loading: the attribute is absent until its value lands.\n if (value === null || value === undefined || typeof value === 'function' || isThenable(value)) {\n return undefined;\n }\n if (typeof value === 'boolean') {\n const words = switchWords(name);\n if (words) {\n return value ? words[0] : words[1];\n }\n return value ? '' : undefined;\n }\n if (name === 'class') {\n const text = classValue(value);\n return text === '' ? undefined : text;\n }\n return name === 'style' ? styleValue(value) : String(value);\n}\n\n/**\n * A name that HTML reads as one attribute. A spread takes its names from\n * data, so a name with a space, a quote, `>`, `/` or `=` could write other\n * attributes or markup.\n */\n// oxlint-disable-next-line no-control-regex -- HTML reads no control character in a name.\nconst ATTRIBUTE_NAME = /^[^\\s\"'>/=\\x00-\\x1f\\x7f]+$/;\n\n/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */\nexport function attribute(name: string, value: unknown): string {\n const text = attributeText(name, value);\n if (text === undefined || !ATTRIBUTE_NAME.test(name)) {\n return '';\n }\n return value === true && text === '' ? ` ${name}` : ` ${name}=\"${escapeAttribute(text)}\"`;\n}\n\n/**\n * Returns the value of a style variable with text around it, such as `12px`\n * for `${size}px`. A value that sets no variable stays as it is.\n */\nexport function affix(prefix: string, value: unknown, suffix: string): unknown {\n return value === null || value === undefined || value === false\n ? value\n : `${prefix}${String(value)}${suffix}`;\n}\n\n/** Returns a style with custom properties before an element's own style. */\nexport function vars(variables: Record<string, unknown>, own: unknown): string {\n const parts: string[] = [];\n for (const [name, value] of Object.entries(variables)) {\n if (value !== null && value !== undefined && value !== false) {\n parts.push(`${name}:${String(value)}`);\n }\n }\n const rest = own === null || own === undefined || own === false ? '' : styleValue(own);\n if (rest) {\n parts.push(rest);\n }\n return parts.join(';');\n}\n\n/** Returns a `<style>` element for a component's stylesheet. */\nexport function styleElement(id: string, css: string): string {\n return `<style b-style=\"${escapeAttribute(id)}\">${css.replace(/<\\/style/gi, '<\\\\/style')}</style>`;\n}\n\n/**\n * Merges the attributes of an element that has spreads, in their order: a\n * later value wins, except `class`, whose values all apply.\n */\n/**\n * A value of an attribute that brumate writes, such as the `b-on` of a dynamic tag, which the\n * compiler wraps. An object of attributes, such as a spread, writes a `b-` attribute only with\n * one, so data from outside the app cannot name handlers or scopes.\n */\nexport class Internal {\n readonly value: unknown;\n\n constructor(value: unknown) {\n this.value = value;\n }\n}\n\n/** Wraps the value of an attribute that brumate writes. See `Internal`. */\nexport function internal(value: unknown): Internal {\n return new Internal(value);\n}\n\n/** The value of an attribute of an object, or undefined for a `b-` attribute from outside. */\nexport function ownValue(name: string, value: unknown): unknown {\n if (value instanceof Internal) {\n return value.value;\n }\n return name.startsWith('b-') ? undefined : value;\n}\n\nexport function mergeAttributes(\n parts: Record<string, unknown>[],\n variables?: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const part of parts) {\n for (const [name, value] of Object.entries(part ?? {})) {\n // A `b-` attribute from outside the app does not take the place of brumate's own.\n if (name.startsWith('b-') && !(value instanceof Internal)) {\n continue;\n }\n result[name] =\n name === 'class' && result.class !== undefined && value !== undefined\n ? [result.class, value]\n : value;\n }\n }\n // The style variables of the component come before the style that won, whoever gave it.\n if (variables) {\n result.style = vars(variables, result.style);\n }\n return result;\n}\n\n/**\n * The `b-on` entry of a handler that a spread passes on, such as\n * `click:prevent=Parent#h1@3`: its event, the modifiers of its wrappers, its\n * client function and the scope it runs in. A handler that `$handler` made\n * has its arguments after another `@`, encoded so that they hold no space.\n */\nexport function handlerEntry(\n name: string,\n ref: string,\n scope: number | string,\n modifiers: readonly string[] = [],\n args?: unknown[],\n): string {\n const bound = args === undefined ? '' : `@${encodeURIComponent(JSON.stringify(args))}`;\n return `${[name.slice(2).toLowerCase(), ...modifiers].join(':')}=${ref}@${scope}${bound}`;\n}\n\n/**\n * The `b-on` entry of a binding that a spread puts on `value` or `checked`\n * of an element. It names the scope of the slot, or of the setter of\n * `$bind(name, fn)`, after `@`. A box writes on `change`.\n */\nexport function bindEntry(\n name: string,\n ref: { scope: number | string; slot: number },\n setter?: { ref: string; scope: number | string },\n): string {\n const event = name === 'checked' ? 'change' : 'input';\n return setter\n ? `${event}=$set:${setter.ref}@${setter.scope}`\n : `${event}=$bind#0.${ref.slot}@${ref.scope}`;\n}\n\n/**\n * The `b-on` attribute of an element with spreads: the bindings of its\n * spreads, so its handlers read the new value, then its own handlers, then\n * those of its spreads.\n */\nexport function onAttribute(on: string[], own: string): string {\n const value = onValue(on, own);\n return value ? ` b-on=\"${escapeAttribute(value)}\"` : '';\n}\n\n/** The value of `b-on`, in the order of `onAttribute`. */\nexport function onValue(on: string[], own: string): string {\n const bindings: string[] = [];\n const rest: string[] = [];\n for (const entry of on) {\n if (/=\\$(bind#|set:)/.test(entry)) {\n bindings.push(entry);\n } else {\n rest.push(entry);\n }\n }\n const parts: string[] = [];\n for (const part of [...bindings, own, ...rest]) {\n if (part) {\n parts.push(part);\n }\n }\n return parts.join(' ');\n}\n\n/** Renders an object of attributes. */\nexport function spread(attributes: Record<string, unknown>, names = false): string {\n let result = '';\n const written: string[] = [];\n for (const [name, value] of Object.entries(attributes)) {\n if (name !== 'children' && !/^on[A-Z]/.test(name)) {\n const text = attribute(name, ownValue(name, value));\n if (text) {\n result += text;\n written.push(name);\n }\n }\n }\n // `b-s` names the attributes of a spread that changes in the browser. Its first update there\n // removes only those, so a spread that wrote none still writes it, empty.\n return names ? `${result} b-s=\"${written.join(' ')}\"` : result;\n}\n\nexport const VOID_ELEMENTS: Set<string> = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Renders the attributes of a form that posts to a server function, such as\n * ` action=\"/_brumate/App_1abc%23save\" method=\"post\"`. `method` is the name of\n * the method attribute to add, if the element has none. `build` is the ID\n * of the build of the page, which the URL carries as `__build`, so the\n * server can tell a post from before a deploy without scripts.\n */\nexport function actionAttributes(\n prefix: string,\n name: string,\n id: string,\n method?: string,\n result?: string,\n build?: string,\n key?: string,\n): string {\n const methodText = method ? ` ${method}=\"post\"` : '';\n // The key of a form of a function that `idempotent` made, so a second post gets the first result.\n const params: string[] = [];\n if (build !== undefined) {\n params.push(`__build=${encodeURIComponent(build)}`);\n }\n if (key !== undefined) {\n params.push(`__key=${key}`);\n }\n const query = params.join('&');\n if (result !== undefined) {\n // The form posts to its page, which renders with the result. With the\n // loader, the result is written into the `$action` at `result` instead.\n const url = `?__action=${encodeURIComponent(id)}${query ? `&${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText} b-action=\"${escapeAttribute(id)}\" b-result=\"${escapeAttribute(result)}\"`;\n }\n const url = `${prefix}/${encodeURIComponent(id)}${query ? `?${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText}`;\n}\n"],"mappings":";AAEA,MAAM,MAAqB,OAAO,IAAI,aAAa;AAQnD,IAAM,UAAN,MAA6B;CAC3B,CAAU;CAEV,YAAY,MAAc;EACxB,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,IAAI,MAAmB;CACrC,OAAO,IAAI,QAAQ,IAAI;AACzB;AAEA,SAAgB,MAAM,OAA8B;CAClD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO;AAC/D;AAEA,SAAgB,QAAQ,OAAoB;CAC1C,OAAO,MAAM;AACf;AAEA,MAAM,UAAkC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;AAAS;AAEhG,SAAS,SAAS,MAAsB;CACtC,OAAO,QAAQ;AACjB;AAGA,SAAgB,OAAO,OAAuB;CAC5C,OAAO,QAAQ,KAAK,KAAK,IAAI,MAAM,QAAQ,UAAU,QAAQ,IAAI;AACnE;AAEA,SAAgB,gBAAgB,OAAuB;CACrD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AW,mBAAmB,KAAK,GAAG;CAEpD,IAAI,QAAQ,KAAA,GACV,OAAO,KAAK,SAAS,KAAK;CAE5B,MAAM,QAAQ,OAAO,KAAK,GAAG;CAC7B,IAAI,WAAW,KAAA,GAIb,OAAO,IAAI,KAAK,IAAI,gBAAgB,aADX,mBAAmB,EAAE,IAAI,QAAQ,IAAI,UAAU,IACjC,EAAE,GAAG,WAAW,aAAa,gBAAgB,EAAE,EAAE,cAAc,gBAAgB,MAAM,EAAE;CAGhI,OAAO,IAAI,KAAK,IAAI,gBAAgB,GADrB,OAAO,GAAG,mBAAmB,EAAE,IAAI,QAAQ,IAAI,UAAU,IACjC,EAAE,GAAG;AAC9C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//#region src/runtime/html.d.ts
|
|
2
|
+
declare const RAW: unique symbol;
|
|
3
|
+
/** HTML that is inserted as it is, such as the output of a template. */
|
|
4
|
+
interface Raw {
|
|
5
|
+
[RAW]: string;
|
|
6
|
+
}
|
|
7
|
+
declare function raw(html: string): Raw;
|
|
8
|
+
declare function isRaw(value: unknown): value is Raw;
|
|
9
|
+
declare function rawHTML(value: Raw): string;
|
|
10
|
+
declare function escape(value: string): string;
|
|
11
|
+
declare function escapeAttribute(value: string): string;
|
|
12
|
+
/** Renders a value inserted in markup. A promise is not awaited: it renders empty. */
|
|
13
|
+
declare function insertValue(value: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* Renders a value as the text of an element whose content is text, such as
|
|
16
|
+
* a `<textarea>`, as `insertValue` does but without escaping.
|
|
17
|
+
*/
|
|
18
|
+
declare function textValue(value: unknown): string;
|
|
19
|
+
declare function classValue(value: unknown): string;
|
|
20
|
+
/**
|
|
21
|
+
* Renders a `class` attribute from classes that each have a space before
|
|
22
|
+
* them, which the compiler builds from a literal class value. The classes
|
|
23
|
+
* are escaped already. No class renders nothing.
|
|
24
|
+
*/
|
|
25
|
+
declare function classAttribute(classes: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the text of an attribute, or undefined if the attribute is not
|
|
28
|
+
* rendered.
|
|
29
|
+
*
|
|
30
|
+
* - `null` and `undefined` leave the attribute out.
|
|
31
|
+
* - For an attribute whose value says its state, such as `aria-expanded`,
|
|
32
|
+
* `draggable` or `translate`, `true` and `false` render as its words:
|
|
33
|
+
* `"true"` and `"false"`, or `"yes"` and `"no"`, or `"on"` and `"off"`.
|
|
34
|
+
* - For other attributes, such as `disabled`, `true` renders the attribute
|
|
35
|
+
* without a value, and `false` leaves it out.
|
|
36
|
+
*/
|
|
37
|
+
declare function attributeText(name: string, value: unknown): string | undefined;
|
|
38
|
+
/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */
|
|
39
|
+
declare function attribute(name: string, value: unknown): string;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the value of a style variable with text around it, such as `12px`
|
|
42
|
+
* for `${size}px`. A value that sets no variable stays as it is.
|
|
43
|
+
*/
|
|
44
|
+
declare function affix(prefix: string, value: unknown, suffix: string): unknown;
|
|
45
|
+
/** Returns a style with custom properties before an element's own style. */
|
|
46
|
+
declare function vars(variables: Record<string, unknown>, own: unknown): string;
|
|
47
|
+
/** Returns a `<style>` element for a component's stylesheet. */
|
|
48
|
+
declare function styleElement(id: string, css: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Merges the attributes of an element that has spreads, in their order: a
|
|
51
|
+
* later value wins, except `class`, whose values all apply.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* A value of an attribute that brumate writes, such as the `b-on` of a dynamic tag, which the
|
|
55
|
+
* compiler wraps. An object of attributes, such as a spread, writes a `b-` attribute only with
|
|
56
|
+
* one, so data from outside the app cannot name handlers or scopes.
|
|
57
|
+
*/
|
|
58
|
+
declare class Internal {
|
|
59
|
+
readonly value: unknown;
|
|
60
|
+
constructor(value: unknown);
|
|
61
|
+
}
|
|
62
|
+
/** Wraps the value of an attribute that brumate writes. See `Internal`. */
|
|
63
|
+
declare function internal(value: unknown): Internal;
|
|
64
|
+
/** The value of an attribute of an object, or undefined for a `b-` attribute from outside. */
|
|
65
|
+
declare function ownValue(name: string, value: unknown): unknown;
|
|
66
|
+
declare function mergeAttributes(parts: Record<string, unknown>[], variables?: Record<string, unknown>): Record<string, unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* The `b-on` entry of a handler that a spread passes on, such as
|
|
69
|
+
* `click:prevent=Parent#h1@3`: its event, the modifiers of its wrappers, its
|
|
70
|
+
* client function and the scope it runs in. A handler that `$handler` made
|
|
71
|
+
* has its arguments after another `@`, encoded so that they hold no space.
|
|
72
|
+
*/
|
|
73
|
+
declare function handlerEntry(name: string, ref: string, scope: number | string, modifiers?: readonly string[], args?: unknown[]): string;
|
|
74
|
+
/**
|
|
75
|
+
* The `b-on` entry of a binding that a spread puts on `value` or `checked`
|
|
76
|
+
* of an element. It names the scope of the slot, or of the setter of
|
|
77
|
+
* `$bind(name, fn)`, after `@`. A box writes on `change`.
|
|
78
|
+
*/
|
|
79
|
+
declare function bindEntry(name: string, ref: {
|
|
80
|
+
scope: number | string;
|
|
81
|
+
slot: number;
|
|
82
|
+
}, setter?: {
|
|
83
|
+
ref: string;
|
|
84
|
+
scope: number | string;
|
|
85
|
+
}): string;
|
|
86
|
+
/**
|
|
87
|
+
* The `b-on` attribute of an element with spreads: the bindings of its
|
|
88
|
+
* spreads, so its handlers read the new value, then its own handlers, then
|
|
89
|
+
* those of its spreads.
|
|
90
|
+
*/
|
|
91
|
+
declare function onAttribute(on: string[], own: string): string;
|
|
92
|
+
/** The value of `b-on`, in the order of `onAttribute`. */
|
|
93
|
+
declare function onValue(on: string[], own: string): string;
|
|
94
|
+
/** Renders an object of attributes. */
|
|
95
|
+
declare function spread(attributes: Record<string, unknown>, names?: boolean): string;
|
|
96
|
+
declare const VOID_ELEMENTS: Set<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Renders the attributes of a form that posts to a server function, such as
|
|
99
|
+
* ` action="/_brumate/App_1abc%23save" method="post"`. `method` is the name of
|
|
100
|
+
* the method attribute to add, if the element has none. `build` is the ID
|
|
101
|
+
* of the build of the page, which the URL carries as `__build`, so the
|
|
102
|
+
* server can tell a post from before a deploy without scripts.
|
|
103
|
+
*/
|
|
104
|
+
declare function actionAttributes(prefix: string, name: string, id: string, method?: string, result?: string, build?: string, key?: string): string;
|
|
105
|
+
//#endregion
|
|
106
|
+
export { spread as C, vars as E, rawHTML as S, textValue as T, mergeAttributes as _, affix as a, ownValue as b, bindEntry as c, escape as d, escapeAttribute as f, isRaw as g, internal as h, actionAttributes as i, classAttribute as l, insertValue as m, Raw as n, attribute as o, handlerEntry as p, VOID_ELEMENTS as r, attributeText as s, Internal as t, classValue as u, onAttribute as v, styleElement as w, raw as x, onValue as y };
|
|
107
|
+
//# sourceMappingURL=html-Bw9Qwu6F.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1372,6 +1372,18 @@ interface DynamicTagNode extends Range {
|
|
|
1372
1372
|
interface FragmentNode extends Range {
|
|
1373
1373
|
kind: "fragment";
|
|
1374
1374
|
children: Markup[];
|
|
1375
|
+
/**
|
|
1376
|
+
* For `#reveal`: the order in which the server shows the `#loading` bodies
|
|
1377
|
+
* inside, and whether only the next fallback shows. Elsewhere the children
|
|
1378
|
+
* render as they are.
|
|
1379
|
+
*/
|
|
1380
|
+
reveal?: Reveal;
|
|
1381
|
+
}
|
|
1382
|
+
/** The order of `#reveal`, as its header writes it. */
|
|
1383
|
+
type RevealOrder = "sequential" | "backwards" | "together" | "natural";
|
|
1384
|
+
interface Reveal {
|
|
1385
|
+
order: RevealOrder;
|
|
1386
|
+
collapsed: boolean;
|
|
1375
1387
|
}
|
|
1376
1388
|
interface GlobalListenerNode extends Range {
|
|
1377
1389
|
kind: "listener";
|
|
@@ -1387,7 +1399,6 @@ interface InsertNode extends Range {
|
|
|
1387
1399
|
expression: Expression;
|
|
1388
1400
|
}
|
|
1389
1401
|
type Modifier = "prevent" | "stop" | "passive" | "once" | "capture";
|
|
1390
|
-
type PrefetchStrategy = "hover" | "visible" | "idle" | "none";
|
|
1391
1402
|
interface StaticAttribute extends Range {
|
|
1392
1403
|
kind: "static";
|
|
1393
1404
|
name: string;
|
|
@@ -1409,15 +1420,11 @@ interface EventAttribute extends Range {
|
|
|
1409
1420
|
}
|
|
1410
1421
|
interface RefAttribute extends Range {
|
|
1411
1422
|
kind: "ref";
|
|
1412
|
-
/** The name
|
|
1423
|
+
/** The name in `ref=$bind(name)`: a signal, or a prop that the component writes. */
|
|
1413
1424
|
target: string;
|
|
1414
1425
|
/** The range of the name. */
|
|
1415
1426
|
targetRange: Range;
|
|
1416
1427
|
}
|
|
1417
|
-
interface PrefetchAttribute extends Range {
|
|
1418
|
-
kind: "prefetch";
|
|
1419
|
-
strategy: PrefetchStrategy;
|
|
1420
|
-
}
|
|
1421
1428
|
interface SpreadAttribute extends Range {
|
|
1422
1429
|
kind: "spread";
|
|
1423
1430
|
value: Expression;
|
|
@@ -1427,7 +1434,7 @@ interface ComputedAttribute extends Range {
|
|
|
1427
1434
|
name: Expression;
|
|
1428
1435
|
value: Expression | true;
|
|
1429
1436
|
}
|
|
1430
|
-
type Attribute = StaticAttribute | ValueAttribute | EventAttribute | RefAttribute |
|
|
1437
|
+
type Attribute = StaticAttribute | ValueAttribute | EventAttribute | RefAttribute | SpreadAttribute | ComputedAttribute;
|
|
1431
1438
|
interface Body extends Range {
|
|
1432
1439
|
script?: Script;
|
|
1433
1440
|
templates: TemplateDecl[];
|
|
@@ -1449,6 +1456,14 @@ interface ForBlock extends Range {
|
|
|
1449
1456
|
list: Expression;
|
|
1450
1457
|
/** `'index'` keys items by position. */
|
|
1451
1458
|
key?: Expression | "index";
|
|
1459
|
+
/**
|
|
1460
|
+
* `window(height, count)`: the browser renders only the items in view, which are about
|
|
1461
|
+
* `height` pixels tall, and the server renders the first `count`.
|
|
1462
|
+
*/
|
|
1463
|
+
window?: {
|
|
1464
|
+
height: Expression;
|
|
1465
|
+
count?: Expression;
|
|
1466
|
+
};
|
|
1452
1467
|
body: Body;
|
|
1453
1468
|
fallback?: Body;
|
|
1454
1469
|
}
|
|
@@ -1561,6 +1576,10 @@ interface Declaration {
|
|
|
1561
1576
|
* `const { user: { name } } = $props()`. Undefined for the props object.
|
|
1562
1577
|
*/
|
|
1563
1578
|
propKey?: string;
|
|
1579
|
+
/** True for a prop whose `$props<T>` type is written as `Promise<...>`, or a union with one. */
|
|
1580
|
+
promise?: boolean;
|
|
1581
|
+
/** True for the props object (`const props = $props()`) and the rest of `$props()`. */
|
|
1582
|
+
whole?: boolean;
|
|
1564
1583
|
/** For `const result = $action(fn)`, the name of the server function. */
|
|
1565
1584
|
action?: string;
|
|
1566
1585
|
/** True for a server function that a server function refreshes with `refresh(fn)`. */
|
|
@@ -1587,16 +1606,28 @@ interface Declaration {
|
|
|
1587
1606
|
};
|
|
1588
1607
|
/** For `let name = $signal(value)`, the value. */
|
|
1589
1608
|
init?: Node;
|
|
1590
|
-
/**
|
|
1609
|
+
/**
|
|
1610
|
+
* True for a memo declared with `$optimistic`, before its source is known,
|
|
1611
|
+
* and for a prop that the component destructures with `let`.
|
|
1612
|
+
*/
|
|
1591
1613
|
writable?: boolean;
|
|
1614
|
+
/** True for a signal or a writable prop that `$bind` passes to a child, which needs a slot. */
|
|
1615
|
+
bound?: boolean;
|
|
1616
|
+
/**
|
|
1617
|
+
* The props of components that the binding passes the declaration to, and `value` or `checked`
|
|
1618
|
+
* of an input. A signal that only `ref` binds holds an element that the browser fills.
|
|
1619
|
+
*/
|
|
1620
|
+
boundAs?: Set<string>;
|
|
1592
1621
|
/** True for `const name = await $memo(value)`: the render waits for the memo where it is declared. */
|
|
1593
1622
|
awaited?: boolean;
|
|
1594
1623
|
/** For `const name = $id()`, the position of the call among the `$id` calls of its scope. */
|
|
1595
1624
|
idIndex?: number;
|
|
1625
|
+
/** For `const name = $isPassed(prop)`, the key of the prop. */
|
|
1626
|
+
passedKey?: string;
|
|
1596
1627
|
/** Elements whose `ref` targets this declaration. */
|
|
1597
1628
|
refs: {
|
|
1598
1629
|
attribute: RefAttribute;
|
|
1599
|
-
element: ElementNode;
|
|
1630
|
+
element: ElementNode | DynamicTagNode;
|
|
1600
1631
|
scope: Scope;
|
|
1601
1632
|
}[];
|
|
1602
1633
|
}
|
|
@@ -1644,6 +1675,8 @@ interface Site {
|
|
|
1644
1675
|
* the modifiers that `b-on` holds, such as `prevent(Enter)`.
|
|
1645
1676
|
*/
|
|
1646
1677
|
modifiers?: string[];
|
|
1678
|
+
/** True for the handler prop of a component, such as `onPick=(…)`, which the child calls. */
|
|
1679
|
+
handlerProp?: boolean;
|
|
1647
1680
|
/** The block whose header this site is. */
|
|
1648
1681
|
block?: Block;
|
|
1649
1682
|
/** The trigger of a `$client` site. */
|
|
@@ -1652,6 +1685,13 @@ interface Site {
|
|
|
1652
1685
|
awaits: boolean;
|
|
1653
1686
|
/** More code of the site, such as the context of `$setContext(context, value)`. */
|
|
1654
1687
|
extra?: Node[];
|
|
1688
|
+
/**
|
|
1689
|
+
* For the function of `$handler(fn, ...args)`, the call, which the server
|
|
1690
|
+
* turns into a reference that a spread can pass on, with its arguments.
|
|
1691
|
+
*/
|
|
1692
|
+
handler?: CallExpression;
|
|
1693
|
+
/** For the function of `$bind(name, fn)`, the call, which passes it as the setter of the binding. */
|
|
1694
|
+
setter?: CallExpression;
|
|
1655
1695
|
}
|
|
1656
1696
|
type Severity = "error" | "warning";
|
|
1657
1697
|
interface Diagnostic {
|
|
@@ -1665,7 +1705,19 @@ interface SemanticModel {
|
|
|
1665
1705
|
scopes: Scope[];
|
|
1666
1706
|
declarations: Declaration[];
|
|
1667
1707
|
sites: Site[];
|
|
1708
|
+
/** The `$bind(name)` calls, with the declaration of their name. */
|
|
1709
|
+
/** The `$bind` calls, with the declaration of their name and the site of their setter. */
|
|
1710
|
+
bindings: {
|
|
1711
|
+
call: CallExpression;
|
|
1712
|
+
declaration: Declaration;
|
|
1713
|
+
setter?: Site;
|
|
1714
|
+
}[];
|
|
1668
1715
|
diagnostics: Diagnostic[];
|
|
1716
|
+
/** The `$isPending(memo)` and `$resolve(memo)` calls, with the read of their memo. */
|
|
1717
|
+
pendingCalls: {
|
|
1718
|
+
reference: Reference;
|
|
1719
|
+
at: Range;
|
|
1720
|
+
}[];
|
|
1669
1721
|
}
|
|
1670
1722
|
/** Returns true if `scope` is `ancestor` or inside it. */
|
|
1671
1723
|
export declare function isWithin(scope: Scope, ancestor: Scope): boolean;
|
|
@@ -1681,6 +1733,28 @@ export declare function lookup(scope: Scope, name: string): Declaration | undefi
|
|
|
1681
1733
|
//#region src/analyze.d.ts
|
|
1682
1734
|
export declare function analyze(file: SFCFile): SemanticModel;
|
|
1683
1735
|
//#endregion
|
|
1736
|
+
//#region src/error-catalog.d.ts
|
|
1737
|
+
/** One compile error of a `.brm` file. */
|
|
1738
|
+
interface ErrorEntry {
|
|
1739
|
+
/** The message the compiler reports, with `{name}` for the parts that vary. */
|
|
1740
|
+
message: string;
|
|
1741
|
+
/** What causes it, in one sentence. */
|
|
1742
|
+
cause: string;
|
|
1743
|
+
/** The form to write instead, as a short `brm` example. */
|
|
1744
|
+
fix: string;
|
|
1745
|
+
/** A code such as BRM012. It never changes and is never reused. */
|
|
1746
|
+
code?: string;
|
|
1747
|
+
/** The docs page that explains the code. */
|
|
1748
|
+
link?: string;
|
|
1749
|
+
}
|
|
1750
|
+
/** The link to the explanation of a code. */
|
|
1751
|
+
export declare function errorLink(code: string): string;
|
|
1752
|
+
/**
|
|
1753
|
+
* The entry for a message that the compiler reported. The place of the
|
|
1754
|
+
* error, as in `(File.brm:3:7)`, can follow the message.
|
|
1755
|
+
*/
|
|
1756
|
+
export declare function findError(message: string): ErrorEntry | undefined;
|
|
1757
|
+
//#endregion
|
|
1684
1758
|
//#region src/graph.d.ts
|
|
1685
1759
|
type GraphNode = {
|
|
1686
1760
|
kind: "source";
|
|
@@ -1732,6 +1806,18 @@ interface ComponentUsage {
|
|
|
1732
1806
|
source: string;
|
|
1733
1807
|
/** The props whose values can change on the client. `*` means every prop. */
|
|
1734
1808
|
liveProps: Set<string>;
|
|
1809
|
+
/** True for a dynamic tag, which can name the component. Only a component that declares the prop takes it. */
|
|
1810
|
+
dynamic?: boolean;
|
|
1811
|
+
/**
|
|
1812
|
+
* The props whose value names `.brm` imports, such as `as=Target` or `as=(flag ? A : B)`: the
|
|
1813
|
+
* prop name and the import specifiers.
|
|
1814
|
+
*/
|
|
1815
|
+
components?: Map<string, string[]>;
|
|
1816
|
+
/**
|
|
1817
|
+
* The props whose value is a prop of this file, such as `{as}`: the prop name and the names of
|
|
1818
|
+
* this file's props. `*` means the whole props object.
|
|
1819
|
+
*/
|
|
1820
|
+
passed?: Map<string, string[]>;
|
|
1735
1821
|
}
|
|
1736
1822
|
/** Lists the components that a file renders, and the props it passes that can change. */
|
|
1737
1823
|
export declare function summarize(file: SFCFile, graph: Graph): ComponentUsage[];
|
|
@@ -1771,7 +1857,7 @@ export declare function printGraph(source: string, graph: Graph): string;
|
|
|
1771
1857
|
interface StyleOutput {
|
|
1772
1858
|
/** The scoped CSS of every `<style>` block, or an empty string. */
|
|
1773
1859
|
css: string;
|
|
1774
|
-
/** The attribute that marks the component's elements, such as `
|
|
1860
|
+
/** The attribute that marks the component's elements, such as `b-c-1abc`. */
|
|
1775
1861
|
attribute: string;
|
|
1776
1862
|
/**
|
|
1777
1863
|
* The custom property for each `${…}` interpolation, in source order. Text
|
|
@@ -1825,6 +1911,8 @@ interface Plan {
|
|
|
1825
1911
|
bodyScopes: Map<Body, Scope>;
|
|
1826
1912
|
/** The anchor index of a node within its scope. */
|
|
1827
1913
|
anchors: Map<AnchorTarget, number>;
|
|
1914
|
+
/** The scope of each anchor, for the devtools, which find an element by its scope and anchor. */
|
|
1915
|
+
anchorScopes: Map<AnchorTarget, Scope>;
|
|
1828
1916
|
/**
|
|
1829
1917
|
* Inserts that are the only content of their element. They share the
|
|
1830
1918
|
* element's anchor and update its children, so they have no markers.
|
|
@@ -1842,6 +1930,22 @@ interface Plan {
|
|
|
1842
1930
|
elementItems: Set<Block>;
|
|
1843
1931
|
/** The export name of each client root, such as `h3`. */
|
|
1844
1932
|
symbols: Map<Site, string>;
|
|
1933
|
+
/**
|
|
1934
|
+
* The children of each component and dynamic tag, which the browser renders each time the
|
|
1935
|
+
* component inserts them: the export of their render, such as `n0`, and their scope.
|
|
1936
|
+
*/
|
|
1937
|
+
childrenRenders: Map<ComponentNode | DynamicTagNode, {
|
|
1938
|
+
symbol: string;
|
|
1939
|
+
scope: Scope;
|
|
1940
|
+
}>;
|
|
1941
|
+
/**
|
|
1942
|
+
* The component whose children hold a block, for the blocks in children. The browser renders
|
|
1943
|
+
* the new bodies of such a block with the contexts of that component, as the server does.
|
|
1944
|
+
*/
|
|
1945
|
+
blockHolders: Map<Block, {
|
|
1946
|
+
node: ComponentNode;
|
|
1947
|
+
scope: Scope;
|
|
1948
|
+
}>;
|
|
1845
1949
|
/** Sites whose code runs on the client, including update code for live nodes. */
|
|
1846
1950
|
clientSites: Set<Site>;
|
|
1847
1951
|
/** The compiled `<style>` blocks. */
|
|
@@ -1916,6 +2020,13 @@ interface CompileOptions {
|
|
|
1916
2020
|
* server function calls `refresh` with it. The Vite plugin passes it.
|
|
1917
2021
|
*/
|
|
1918
2022
|
serverImport?: (specifier: string, name: string) => string | undefined;
|
|
2023
|
+
/**
|
|
2024
|
+
* The names of the server functions that the project passes to
|
|
2025
|
+
* `refresh`, from `refreshedNames`. A memo that calls an imported server
|
|
2026
|
+
* function outside it renders on the server only. Without it, any imported
|
|
2027
|
+
* server function can be refreshed.
|
|
2028
|
+
*/
|
|
2029
|
+
refreshed?: ReadonlySet<string>;
|
|
1919
2030
|
/**
|
|
1920
2031
|
* The names of the server environment variables that an import gives,
|
|
1921
2032
|
* such as `import env from './env.ts'`, or undefined for other imports.
|
|
@@ -1923,6 +2034,11 @@ interface CompileOptions {
|
|
|
1923
2034
|
* it for the imports that resolve to the env file.
|
|
1924
2035
|
*/
|
|
1925
2036
|
envImport?: EnvImport;
|
|
2037
|
+
/**
|
|
2038
|
+
* Classes that the plugins of the serial entry send, such as `Money`, so a
|
|
2039
|
+
* signal can hold an instance. The Vite plugin reads them from the entry.
|
|
2040
|
+
*/
|
|
2041
|
+
sendableClasses?: readonly string[];
|
|
1926
2042
|
/**
|
|
1927
2043
|
* Server function IDs use a hash of each function's name instead of the
|
|
1928
2044
|
* name, so the browser does not see it. The Vite plugin sets it in builds.
|
|
@@ -1992,6 +2108,16 @@ export declare class CompileError extends Error {
|
|
|
1992
2108
|
}
|
|
1993
2109
|
export declare function compile(source: string, options?: CompileOptions): CompileResult;
|
|
1994
2110
|
//#endregion
|
|
2111
|
+
//#region src/codegen/markup.d.ts
|
|
2112
|
+
/** The render functions that fill a nested block of a clone. */
|
|
2113
|
+
type Fill = {
|
|
2114
|
+
kind: "if";
|
|
2115
|
+
renders: string[];
|
|
2116
|
+
} | {
|
|
2117
|
+
kind: "for";
|
|
2118
|
+
render: string;
|
|
2119
|
+
};
|
|
2120
|
+
//#endregion
|
|
1995
2121
|
//#region src/shared-module.d.ts
|
|
1996
2122
|
/** The query of the shared module of a module of reactive logic. */
|
|
1997
2123
|
export declare const SHARED_QUERY = "?brumate-shared";
|
|
@@ -2048,6 +2174,11 @@ interface ClientOutput {
|
|
|
2048
2174
|
loaders: Record<string, string[]>;
|
|
2049
2175
|
/** False when nothing of the component runs in the browser. */
|
|
2050
2176
|
clientCode: boolean;
|
|
2177
|
+
/**
|
|
2178
|
+
* The render functions of the client entry that fill a nested `#if` or `#for` of a clone,
|
|
2179
|
+
* for the render module, which imports them.
|
|
2180
|
+
*/
|
|
2181
|
+
fillOf: (block: Block) => Fill | undefined;
|
|
2051
2182
|
diagnostics: Diagnostic[];
|
|
2052
2183
|
}
|
|
2053
2184
|
/**
|
|
@@ -2134,5 +2265,5 @@ export declare function inspect(source: string, options?: InspectOptions): {
|
|
|
2134
2265
|
text: string;
|
|
2135
2266
|
};
|
|
2136
2267
|
//#endregion
|
|
2137
|
-
export type { AnchorTarget, Attribute, Block, Body, Branch, CheckMapping, CheckOutput, ClientBlock, ClientTrigger, CompileOptions, CompileResult, ComponentNode, ComponentUsage, ComputedAttribute, Declaration, DeclarationKind, DeferBlock, Diagnostic, DynamicTagNode, Edge, ElementNode, EventAttribute, Expression, ForBlock, FragmentNode, GlobalListenerNode, Graph, GraphNode, GraphOptions, HeadBlock, IfBlock, InsertNode, InspectEntry, InspectOptions, InspectReport, KeyBlock, LoadingBlock, Location, Markup, Modifier, OffscreenBlock, ParseOptions, Plan, PortalBlock,
|
|
2268
|
+
export type { AnchorTarget, Attribute, Block, Body, Branch, CheckMapping, CheckOutput, ClientBlock, ClientTrigger, CompileOptions, CompileResult, ComponentNode, ComponentUsage, ComputedAttribute, Declaration, DeclarationKind, DeferBlock, Diagnostic, DynamicTagNode, Edge, ElementNode, ErrorEntry, EventAttribute, Expression, ForBlock, FragmentNode, GlobalListenerNode, Graph, GraphNode, GraphOptions, HeadBlock, IfBlock, InsertNode, InspectEntry, InspectOptions, InspectReport, KeyBlock, LoadingBlock, Location, Markup, Modifier, OffscreenBlock, ParseOptions, Plan, PortalBlock, ProjectProps, Range, ReactiveModule, RefAttribute, Reference, RepeatBlock, Resolve, ResolveModule, Reveal, RevealOrder, SFCFile, Scope, ScopeKind, ScopePlan, Script, SemanticModel, Severity, SharedSite, Site, SiteKind, SourceMap, SpreadAttribute, StaticAttribute, Style, SwitchBlock, TemplateDecl, TextNode, TryBlock, ValueAttribute, upstreamMemos };
|
|
2138
2269
|
//# sourceMappingURL=index.d.ts.map
|