diff --git a/src/compiler/compile/utils/a11y.js b/src/compiler/compile/utils/a11y.js index c21d8af0ce..563d5bfb64 100644 --- a/src/compiler/compile/utils/a11y.js +++ b/src/compiler/compile/utils/a11y.js @@ -1,6 +1,7 @@ import { roles as roles_map, elementRoles } from 'aria-query'; import { AXObjects, AXObjectRoles, elementAXObjects } from 'axobject-query'; import { regex_whitespaces } from '../../utils/patterns.js'; + const aria_roles = roles_map.keys(); const abstract_roles = new Set(aria_roles.filter((role) => roles_map.get(role).abstract)); const non_abstract_roles = aria_roles.filter((name) => !abstract_roles.has(name)); @@ -33,21 +34,21 @@ const interactive_roles = new Set( ); /** - * @param {ARIARoleDefinitionKey} role + * @param {import('aria-query').ARIARoleDefinitionKey} role */ export function is_non_interactive_roles(role) { return non_interactive_roles.has(role); } /** - * @param {ARIARoleDefinitionKey} role + * @param {import('aria-query').ARIARoleDefinitionKey} role */ export function is_interactive_roles(role) { return interactive_roles.has(role); } /** - * @param {ARIARoleDefinitionKey} role + * @param {import('aria-query').ARIARoleDefinitionKey} role */ export function is_abstract_role(role) { return abstract_roles.has(role); @@ -55,7 +56,7 @@ export function is_abstract_role(role) { const presentation_roles = new Set(['presentation', 'none']); /** - * @param {ARIARoleDefinitionKey} role + * @param {import('aria-query').ARIARoleDefinitionKey} role */ export function is_presentation_role(role) { return presentation_roles.has(role); @@ -63,7 +64,7 @@ export function is_presentation_role(role) { /** * @param {string} tag_name - * @param {Map} attribute_map + * @param {Map} attribute_map */ export function is_hidden_from_screen_reader(tag_name, attribute_map) { if (tag_name === 'input') { @@ -80,7 +81,7 @@ export function is_hidden_from_screen_reader(tag_name, attribute_map) { } /** - * @param {Map} attribute_map + * @param {Map} attribute_map */ export function has_disabled_attribute(attribute_map) { const disabled_attr = attribute_map.get('disabled'); @@ -99,7 +100,7 @@ export function has_disabled_attribute(attribute_map) { } /** - * @type {ARIARoleRelationConcept[]} + * @type {import('aria-query').ARIARoleRelationConcept[]} */ const non_interactive_element_role_schemas = []; elementRoles.entries().forEach(([schema, roles]) => { @@ -109,7 +110,7 @@ elementRoles.entries().forEach(([schema, roles]) => { }); /** - * @type {ARIARoleRelationConcept[]} + * @type {import('aria-query').ARIARoleRelationConcept[]} */ const interactive_element_role_schemas = []; elementRoles.entries().forEach(([schema, roles]) => { @@ -127,7 +128,7 @@ const non_interactive_ax_objects = new Set( ); /** - * @type {ARIARoleRelationConcept[]} + * @type {import('aria-query').ARIARoleRelationConcept[]} */ const interactive_element_ax_object_schemas = []; elementAXObjects.entries().forEach(([schema, ax_object]) => { @@ -137,7 +138,7 @@ elementAXObjects.entries().forEach(([schema, ax_object]) => { }); /** - * @type {ARIARoleRelationConcept[]} + * @type {import('aria-query').ARIARoleRelationConcept[]} */ const non_interactive_element_ax_object_schemas = []; elementAXObjects.entries().forEach(([schema, ax_object]) => { @@ -147,9 +148,9 @@ elementAXObjects.entries().forEach(([schema, ax_object]) => { }); /** - * @param {ARIARoleRelationConcept} schema + * @param {import('aria-query').ARIARoleRelationConcept} schema * @param {string} tag_name - * @param {Map} attribute_map + * @param {Map} attribute_map */ function match_schema(schema, tag_name, attribute_map) { if (schema.name !== tag_name) return false; @@ -163,17 +164,17 @@ function match_schema(schema, tag_name, attribute_map) { return true; }); } -export var ElementInteractivity; -(function (ElementInteractivity) { - ElementInteractivity['Interactive'] = 'interactive'; - ElementInteractivity['NonInteractive'] = 'non-interactive'; - ElementInteractivity['Static'] = 'static'; -})(ElementInteractivity || (ElementInteractivity = {})); + +export const ElementInteractivity = /** @type {const} */ ({ + Interactive: 'interactive', + NonInteractive: 'non-interactive', + Static: 'static' +}); /** * @param {string} tag_name - * @param {Map} attribute_map - * @returns {import("C:/repos/svelte/svelte/a11y.ts-to-jsdoc").ElementInteractivity} + * @param {Map} attribute_map + * @returns {ElementInteractivity[keyof ElementInteractivity]} */ export function element_interactivity(tag_name, attribute_map) { if ( @@ -208,7 +209,7 @@ export function element_interactivity(tag_name, attribute_map) { /** * @param {string} tag_name - * @param {Map} attribute_map + * @param {Map} attribute_map * @returns {boolean} */ export function is_interactive_element(tag_name, attribute_map) { @@ -217,7 +218,7 @@ export function is_interactive_element(tag_name, attribute_map) { /** * @param {string} tag_name - * @param {Map} attribute_map + * @param {Map} attribute_map * @returns {boolean} */ export function is_non_interactive_element(tag_name, attribute_map) { @@ -226,7 +227,7 @@ export function is_non_interactive_element(tag_name, attribute_map) { /** * @param {string} tag_name - * @param {Map} attribute_map + * @param {Map} attribute_map * @returns {boolean} */ export function is_static_element(tag_name, attribute_map) { @@ -234,9 +235,9 @@ export function is_static_element(tag_name, attribute_map) { } /** - * @param {ARIARoleDefinitionKey} role + * @param {import('aria-query').ARIARoleDefinitionKey} role * @param {string} tag_name - * @param {Map} attribute_map + * @param {Map} attribute_map */ export function is_semantic_role_element(role, tag_name, attribute_map) { for (const [schema, ax_object] of elementAXObjects.entries()) { diff --git a/src/compiler/compile/utils/get_slot_data.js b/src/compiler/compile/utils/get_slot_data.js index 6d5593f654..73990c894c 100644 --- a/src/compiler/compile/utils/get_slot_data.js +++ b/src/compiler/compile/utils/get_slot_data.js @@ -2,8 +2,8 @@ import { p, x } from 'code-red'; import { string_literal } from './stringify.js'; /** - * @param {Map} values - * @param {Block} block + * @param {Map} values + * @param {import('../render_dom/Block.js').default} block */ export default function get_slot_data(values, block = null) { return { @@ -25,8 +25,8 @@ export default function get_slot_data(values, block = null) { } /** - * @param {Block} block - * @param {Attribute} attribute + * @param {import('../render_dom/Block.js').default} block + * @param {import('../nodes/Attribute.js').default} attribute */ function get_value(block, attribute) { if (attribute.is_true) return x`true`; @@ -47,8 +47,8 @@ function get_value(block, attribute) { } /** - * @param {Block} block - * @param {Attribute} attribute + * @param {import('../render_dom/Block.js').default} block + * @param {import('../nodes/Attribute.js').default} attribute */ function get_spread_value(block, attribute) { return block ? attribute.expression.manipulate(block) : attribute.expression.node; diff --git a/src/compiler/compile/utils/nodes_to_template_literal.ts b/src/compiler/compile/utils/nodes_to_template_literal.ts index a1eec22b0c..ebe1f685bf 100644 --- a/src/compiler/compile/utils/nodes_to_template_literal.ts +++ b/src/compiler/compile/utils/nodes_to_template_literal.ts @@ -1,37 +1,47 @@ -import { TemplateElement, TemplateLiteral } from 'estree'; -import { MustacheTag, Text } from '../../interfaces'; - /** * Transforms a list of Text and MustacheTags into a TemplateLiteral expression. * Start/End positions on the elements of the expression are not set. + * @param {Array} value + * @returns {import("C:/repos/svelte/svelte/node_modules/.pnpm/@types+estree@1.0.0/node_modules/@types/estree/index").TemplateLiteral} */ -export function nodes_to_template_literal(value: Array): TemplateLiteral { - const literal: TemplateLiteral = { - type: 'TemplateLiteral', - expressions: [], - quasis: [] - }; +export function nodes_to_template_literal(value) { - let quasi: TemplateElement = { - type: 'TemplateElement', - value: { raw: '', cooked: null }, - tail: false - }; + /** + * @type {TemplateLiteral} + */ + const literal = { + type: 'TemplateLiteral', + expressions: [], + quasis: [] + }; - value.forEach((node) => { - if (node.type === 'Text') { - quasi.value.raw += node.raw; - } else if (node.type === 'MustacheTag') { - literal.quasis.push(quasi); - literal.expressions.push(node.expression as any); - quasi = { - type: 'TemplateElement', - value: { raw: '', cooked: null }, - tail: false - }; - } - }); - quasi.tail = true; - literal.quasis.push(quasi); - return literal; + /** + * @type {TemplateElement} + */ + let quasi = { + type: 'TemplateElement', + value: { raw: '', cooked: null }, + tail: false + }; + value.forEach((node) => { + if (node.type === 'Text') { + quasi.value.raw += node.raw; + } + else if (node.type === 'MustacheTag') { + literal.quasis.push(quasi); + literal.expressions.push(node.expression); + quasi = { + type: 'TemplateElement', + value: { raw: '', cooked: null }, + tail: false + }; + } + }); + quasi.tail = true; + literal.quasis.push(quasi); + return literal; } + + + +