@tamagui/language-service 3.0.0-beta.924.1 → 3.0.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 +25 -134
- package/dist/cjs/check.cjs +85 -10
- package/dist/cjs/check.native.cjs +138 -22
- package/dist/cjs/check.native.js +138 -22
- package/dist/cjs/check.native.js.map +1 -1
- package/dist/cjs/core.cjs +8 -4
- package/dist/cjs/core.native.cjs +10 -9
- package/dist/cjs/core.native.js +10 -9
- package/dist/cjs/core.native.js.map +1 -1
- package/dist/cjs/document.cjs +4 -3
- package/dist/cjs/document.native.cjs +5 -3
- package/dist/cjs/document.native.js +5 -3
- package/dist/cjs/document.native.js.map +1 -1
- package/dist/cjs/extract-estree.native.cjs +2 -6
- package/dist/cjs/extract-estree.native.js +2 -6
- package/dist/cjs/extract-estree.native.js.map +1 -1
- package/dist/cjs/index.cjs +5 -284
- package/dist/cjs/index.native.cjs +5 -395
- package/dist/cjs/index.native.js +5 -395
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/check.mjs +87 -12
- package/dist/esm/check.mjs.map +1 -1
- package/dist/esm/check.native.js +140 -24
- package/dist/esm/check.native.js.map +1 -1
- package/dist/esm/core.mjs +8 -4
- package/dist/esm/core.mjs.map +1 -1
- package/dist/esm/core.native.js +10 -9
- package/dist/esm/core.native.js.map +1 -1
- package/dist/esm/document.mjs +4 -3
- package/dist/esm/document.mjs.map +1 -1
- package/dist/esm/document.native.js +5 -3
- package/dist/esm/document.native.js.map +1 -1
- package/dist/esm/extract-estree.native.js +2 -6
- package/dist/esm/extract-estree.native.js.map +1 -1
- package/dist/esm/index.mjs +5 -279
- package/dist/esm/index.native.js +5 -390
- package/package.json +8 -17
- package/src/check.ts +118 -13
- package/src/core.ts +25 -6
- package/src/document.ts +21 -4
- package/src/index.ts +4 -452
- package/types/check.d.ts +4 -0
- package/types/check.d.ts.map +2 -2
- package/types/core.d.ts +7 -2
- package/types/core.d.ts.map +2 -2
- package/types/document.d.ts +8 -2
- package/types/document.d.ts.map +2 -2
- package/types/index.d.ts +4 -7
- package/types/index.d.ts.map +2 -2
- package/dist/cjs/host.cjs +0 -37
- package/dist/cjs/host.native.cjs +0 -60
- package/dist/cjs/host.native.js +0 -62
- package/dist/cjs/host.native.js.map +0 -1
- package/dist/esm/host.mjs +0 -17
- package/dist/esm/host.mjs.map +0 -1
- package/dist/esm/host.native.js +0 -38
- package/dist/esm/host.native.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/index.cjs +0 -1
- package/src/host.ts +0 -32
- package/types/host.d.ts +0 -10
- package/types/host.d.ts.map +0 -11
package/types/core.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAaA,cAUO,gCACA,mBACA,oCACA,2BACA,2BACA,kCACA,4BACA;AAEP,cACE,sBACA,sBACA,6BACA;;AAIF,iBAAiB,qBAAqB;CACpC,gBAAgB;CAChB;;AAGF,iBAAiB,UAAU;CACzB;CACA;CACA;CACA;;AAGF,iBAAiB,gBAAgB;;CAE/B;CACA;CACA;CACA,OAAO;;CAEP;;AAGF,iBAAiB,gBAAgB;;CAE/B;CACA;CACA;;CAEA;;CAEA,QAAQ;;;;;;;;AA+BV,OAAO,iBAAS,mBACd,YAAY,sBACZ,cAAc;AA6BhB,iBAAiB,aAAa;;CAE5B,YAAY;;CAEZ,QAAQ;CACR,YAAY;;CAEZ,eAAe;;;;;CAKf,YACE,kBACA,eACA,iBACC;;CAEH,
|
|
2
|
+
"mappings": "AAaA,cAUO,gCACA,mBACA,oCACA,2BACA,2BACA,kCACA,4BACA;AAEP,cACE,sBACA,sBACA,6BACA;;AAIF,iBAAiB,qBAAqB;CACpC,gBAAgB;CAChB;;AAGF,iBAAiB,UAAU;CACzB;CACA;CACA;CACA;;AAGF,iBAAiB,gBAAgB;;CAE/B;CACA;CACA;CACA,OAAO;;CAEP;;AAGF,iBAAiB,gBAAgB;;CAE/B;CACA;CACA;;CAEA;;CAEA,QAAQ;;;;;;;;AA+BV,OAAO,iBAAS,mBACd,YAAY,sBACZ,cAAc;AA6BhB,iBAAiB,aAAa;;CAE5B,YAAY;;CAEZ,QAAQ;CACR,YAAY;;CAEZ,eAAe;;;;;CAKf,YACE,kBACA,eACA,iBACC;;CAEH,YACE,kBACA,eACA,UAAU;EAAE;cACF;;CAEZ,YAAY,kBAAkB,yBAAyB;;CAEvD,MAAM,kBAAkB,eAAe,iBAAiB;;CAExD,OAAO,kBAAkB,yBAAyB;;CAElD,aAAa,eAAe;;CAE5B;;AAGF,iBAAiB,oBAAoB;CACnC;;AAGF,OAAO,iBAAS,mBACd,MAAM,sBACN,iBAAiB,sBAChB",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/core.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"// The standalone Tamagui style tooling core.\n//\n// Browser-safe by contract: no node imports, no typescript imports. Everything\n// here works from the serialized config JSON the Tamagui compiler emits\n// (`.tamagui/tamagui.config.json`), so the same engine powers the tsserver\n// plugin, the VS Code extension, the CLI checker, and in-browser IDEs.\n//\n// The @tamagui/style-grammar engine owns candidate meaning; this module adds\n// the two things the engine's config view deliberately drops — token and theme\n// VALUES — and projects everything into editor-shaped results: completions,\n// diagnostics, hover, and color swatches.\n\nimport { normalizeCSSColor, rgba } from '@tamagui/normalize-css-color'\nimport {\n annotateStyleValue,\n completeStyleValueAtCursor,\n createCandidatePropertyVocabulary,\n createGrammarConfigViewFromSerializedConfig,\n createModifierRegistry,\n createStylePropSet,\n diagnoseStyleValueProgram,\n programEligibility,\n stateModifierNames,\n type DiagnoseStyleValueOptions,\n type ModifierKind,\n type SerializedGrammarSourceConfig,\n type StyleValueAnnotation,\n type StyleValueCompletion,\n type StyleValueCursorCompletions,\n type StyleValueDiagnostic,\n} from '@tamagui/style-grammar/tooling'\n\nexport type {\n StyleValueAnnotation,\n StyleValueCompletion,\n StyleValueCursorCompletions,\n StyleValueDiagnostic,\n}\n\n/** the shape of the JSON artifact the Tamagui compiler writes */\nexport interface SerializedConfigFile {\n tamaguiConfig?: SerializedGrammarSourceConfig\n tamaguiConfigMetadata?: unknown\n}\n\nexport interface RgbaColor {\n r: number\n g: number\n b: number\n a: number\n}\n\nexport interface StyleValueColor {\n /** character span within the authored value */\n start: number\n end: number\n text: string\n color: RgbaColor\n /** the theme the preview value came from, when theme-resolved */\n theme?: string\n}\n\nexport interface StyleValueHover {\n /** character span within the authored value */\n start: number\n end: number\n text: string\n /** markdown suitable for an editor hover */\n markdown: string\n /** a representative color for colorish targets */\n color?: RgbaColor\n}\n\nconst modifierKindLabel: Readonly<Record<ModifierKind, string>> = {\n state: 'state modifier',\n media: 'media modifier',\n theme: 'theme modifier',\n platform: 'platform modifier',\n group: 'group modifier',\n container: 'container modifier',\n}\n\nconst modifierKindSort: Readonly<Record<ModifierKind, string>> = {\n state: '00',\n group: '01',\n media: '02',\n container: '03',\n theme: '04',\n platform: '05',\n}\n\nconst stateModifierSort = new Map(\n stateModifierNames.map((name, index) => [name, index] as const)\n)\n\n/**\n * The one sort key every host uses for completion entries, so ordering does\n * not drift between tsserver, LSP, and in-browser consumers: states first in\n * interaction order, then groups, media, containers, themes, platforms, then\n * configured values, then keywords.\n */\nexport function completionSortText(\n completion: StyleValueCompletion,\n modifierKind: ModifierKind | undefined\n): string {\n if (modifierKind) {\n const stateOrder =\n modifierKind === 'state'\n ? `${String(stateModifierSort.get(completion.value) ?? 999).padStart(3, '0')}:`\n : ''\n return `${modifierKindSort[modifierKind]}:${stateOrder}${completion.value}`\n }\n return `${completion.kind === 'configured' ? '10' : '11'}:${completion.value}`\n}\n\n/** unwraps a compiler-serialized token variable to its raw value */\nfunction tokenValue(entry: unknown): unknown {\n if (entry && typeof entry === 'object' && 'val' in entry) {\n return (entry as { val: unknown }).val\n }\n return entry\n}\n\nfunction parseColor(value: unknown, opacity?: number): RgbaColor | null {\n if (typeof value !== 'string') return null\n const normalized = normalizeCSSColor(value)\n if (normalized === null) return null\n const color = rgba(normalized)\n if (opacity !== undefined) color.a = color.a * (opacity / 100)\n return color\n}\n\nexport interface StyleTooling {\n /** every prop name treated as a flat style value site */\n styleProps: ReadonlySet<string>\n /** engine options, for hosts that call @tamagui/style-grammar directly */\n engine: DiagnoseStyleValueOptions\n isStyleProp(name: string): boolean\n /** the longhand a prop resolves to through the configured shorthands */\n targetProperty(name: string): string\n /**\n * cursor completions for one value slot, or null when the property takes no\n * flat program (unknown props, legacy part props)\n */\n completions(\n property: string,\n value: string,\n cursor: number\n ): StyleValueCursorCompletions | null\n /** the complete static verdict for one authored value */\n diagnostics(property: string, value: string): readonly StyleValueDiagnostic[]\n /** classified spans: modifiers, tokens, keywords, literals */\n annotations(property: string, value: string): readonly StyleValueAnnotation[]\n /** hover content for the annotation under `offset`, or null */\n hover(property: string, value: string, offset: number): StyleValueHover | null\n /** every span that resolves to a presentable color */\n colors(property: string, value: string): readonly StyleValueColor[]\n /** the modifier kind of a registered modifier name */\n modifierKind(name: string): ModifierKind | undefined\n /** root theme names, preview themes first */\n previewThemes: readonly string[]\n}\n\nexport function createStyleTooling(file: SerializedConfigFile): StyleTooling | null {\n const serialized = file.tamaguiConfig\n if (!serialized) return null\n\n const config = createGrammarConfigViewFromSerializedConfig(\n serialized,\n file.tamaguiConfigMetadata\n )\n const registry = createModifierRegistry(config).registry\n const candidates = createCandidatePropertyVocabulary(config)\n const engine: DiagnoseStyleValueOptions = { config, registry, candidates }\n const styleProps = createStylePropSet(config)\n\n // themes and tokens keep their VALUES here; the grammar view keeps names only\n const themes = (serialized.themes || {}) as Readonly<\n Record<string, Readonly<Record<string, unknown>> | undefined>\n >\n const rootThemes = Object.keys(themes).filter((name) => !name.includes('_'))\n const previewThemes = [\n ...['light', 'dark'].filter((name) => rootThemes.includes(name)),\n ...rootThemes.filter((name) => name !== 'light' && name !== 'dark'),\n ]\n const tokens = (serialized.tokens || {}) as Readonly<\n Record<string, Readonly<Record<string, unknown>> | undefined>\n >\n const media = (serialized.media || {}) as Readonly<Record<string, unknown>>\n\n const targetProperty = (name: string): string => config.shorthands?.[name] || name\n\n const themeValue = (name: string): { theme: string; value: unknown } | null => {\n for (const theme of previewThemes) {\n const value = themes[theme]?.[name]\n if (value !== undefined) return { theme, value }\n }\n return null\n }\n\n const annotationColor = (\n annotation: StyleValueAnnotation\n ): { color: RgbaColor; theme?: string } | null => {\n if (annotation.kind === 'token' || annotation.kind === 'identifier') {\n const name =\n annotation.opacity !== undefined\n ? annotation.text.slice(0, annotation.text.lastIndexOf('/'))\n : annotation.text\n if (annotation.tokenCategory === 'color') {\n const themed = themeValue(name)\n if (themed) {\n const color = parseColor(themed.value, annotation.opacity)\n return color ? { color, theme: themed.theme } : null\n }\n const color = parseColor(tokenValue(tokens.color?.[name]), annotation.opacity)\n return color ? { color } : null\n }\n if (annotation.kind === 'identifier') {\n // literal CSS colors: hex, rgb()/hsl() never annotate (functions are\n // skipped), but hex runs and named colors do\n const color = parseColor(name)\n return color ? { color } : null\n }\n return null\n }\n if (annotation.kind === 'keyword' && annotation.text === 'transparent') {\n return { color: { r: 0, g: 0, b: 0, a: 0 } }\n }\n return null\n }\n\n const annotations = (property: string, value: string) =>\n annotateStyleValue(property, value, engine)\n\n const formatRgba = (color: RgbaColor): string =>\n color.a === 1\n ? `rgb(${color.r}, ${color.g}, ${color.b})`\n : `rgba(${color.r}, ${color.g}, ${color.b}, ${Number(color.a.toFixed(3))})`\n\n return {\n styleProps,\n engine,\n previewThemes,\n isStyleProp: (name) => styleProps.has(name),\n targetProperty,\n modifierKind: (name) => registry.get(name),\n\n completions(property, value, cursor) {\n const target = targetProperty(property)\n if (programEligibility(target) === 'legacy-part') return null\n if (!styleProps.has(property)) return null\n return completeStyleValueAtCursor(property, value, cursor, engine)\n },\n\n diagnostics(property, value) {\n if (!styleProps.has(property)) return []\n return diagnoseStyleValueProgram(property, value, engine)\n },\n\n annotations,\n\n colors(property, value) {\n if (!styleProps.has(property)) return []\n const results: StyleValueColor[] = []\n for (const annotation of annotations(property, value)) {\n const resolved = annotationColor(annotation)\n if (!resolved) continue\n results.push({\n start: annotation.start,\n end: annotation.end,\n text: annotation.text,\n color: resolved.color,\n ...(resolved.theme !== undefined && { theme: resolved.theme }),\n })\n }\n return results\n },\n\n hover(property, value, offset) {\n if (!styleProps.has(property)) return null\n const annotation = annotations(property, value).find(\n (entry) => offset >= entry.start && offset <= entry.end\n )\n if (!annotation) return null\n\n const lines: string[] = []\n let color: RgbaColor | undefined\n\n if (annotation.kind === 'modifier' && annotation.modifierKind) {\n lines.push(\n `**${annotation.text}** · Tamagui ${modifierKindLabel[annotation.modifierKind]}`\n )\n if (annotation.modifierKind === 'media') {\n const query = media[annotation.text]\n if (query !== undefined) {\n lines.push('```json\\n' + JSON.stringify(query) + '\\n```')\n }\n }\n } else if (annotation.kind === 'token') {\n const name =\n annotation.opacity !== undefined\n ? annotation.text.slice(0, annotation.text.lastIndexOf('/'))\n : annotation.text\n if (annotation.tokenCategory === 'color') {\n lines.push(`**${name}** · Tamagui color`)\n let shown = 0\n for (const theme of previewThemes) {\n const value = themes[theme]?.[name]\n if (value === undefined || shown >= 4) continue\n shown++\n lines.push(`- ${theme}: \\`${String(value)}\\``)\n }\n if (shown === 0) {\n const value = tokenValue(tokens.color?.[name])\n if (value !== undefined) lines.push(`- \\`${String(value)}\\``)\n }\n if (annotation.opacity !== undefined) {\n lines.push(`- opacity: ${annotation.opacity}%`)\n }\n } else {\n const value = tokenValue(tokens[annotation.tokenCategory || '']?.[name])\n lines.push(\n `**${name}** · Tamagui ${annotation.tokenCategory} token` +\n (value !== undefined ? ` = \\`${String(value)}\\`` : '')\n )\n }\n const resolved = annotationColor(annotation)\n if (resolved) {\n color = resolved.color\n lines.push(`- resolves: \\`${formatRgba(resolved.color)}\\``)\n }\n } else if (annotation.kind === 'keyword') {\n lines.push(\n `**${annotation.text}** · CSS keyword` +\n (annotation.property ? ` for \\`${annotation.property}\\`` : '')\n )\n } else {\n const resolved = annotationColor(annotation)\n if (!resolved) return null\n color = resolved.color\n lines.push(\n `**${annotation.text}** · CSS color = \\`${formatRgba(resolved.color)}\\``\n )\n }\n\n return {\n start: annotation.start,\n end: annotation.end,\n text: annotation.text,\n markdown: lines.join('\\n\\n'),\n ...(color !== undefined && { color }),\n }\n },\n }\n}\n"
|
|
9
|
+
"// The standalone Tamagui style tooling core.\n//\n// Browser-safe by contract: no node imports, no typescript imports. Everything\n// here works from the serialized config JSON the Tamagui compiler emits\n// (`.tamagui/tamagui.config.json`), so the same engine powers the language server\n// plugin, the VS Code extension, the CLI checker, and in-browser IDEs.\n//\n// The @tamagui/style-grammar engine owns candidate meaning; this module adds\n// the two things the engine's config view deliberately drops — token and theme\n// VALUES — and projects everything into editor-shaped results: completions,\n// diagnostics, hover, and color swatches.\n\nimport { normalizeCSSColor, rgba } from '@tamagui/normalize-css-color'\nimport {\n annotateStyleValue,\n completeStyleValueAtCursor,\n createCandidatePropertyVocabulary,\n createGrammarConfigViewFromSerializedConfig,\n createModifierRegistry,\n createStylePropSet,\n diagnoseStyleValueProgram,\n programEligibility,\n stateModifierNames,\n type DiagnoseStyleValueOptions,\n type ModifierKind,\n type SerializedGrammarSourceConfig,\n type StyleValueAnnotation,\n type StyleValueCompletion,\n type StyleValueCursorCompletions,\n type StyleValueDiagnostic,\n} from '@tamagui/style-grammar/tooling'\n\nexport type {\n StyleValueAnnotation,\n StyleValueCompletion,\n StyleValueCursorCompletions,\n StyleValueDiagnostic,\n}\n\n/** the shape of the JSON artifact the Tamagui compiler writes */\nexport interface SerializedConfigFile {\n tamaguiConfig?: SerializedGrammarSourceConfig\n tamaguiConfigMetadata?: unknown\n}\n\nexport interface RgbaColor {\n r: number\n g: number\n b: number\n a: number\n}\n\nexport interface StyleValueColor {\n /** character span within the authored value */\n start: number\n end: number\n text: string\n color: RgbaColor\n /** the theme the preview value came from, when theme-resolved */\n theme?: string\n}\n\nexport interface StyleValueHover {\n /** character span within the authored value */\n start: number\n end: number\n text: string\n /** markdown suitable for an editor hover */\n markdown: string\n /** a representative color for colorish targets */\n color?: RgbaColor\n}\n\nconst modifierKindLabel: Readonly<Record<ModifierKind, string>> = {\n state: 'state modifier',\n media: 'media modifier',\n theme: 'theme modifier',\n platform: 'platform modifier',\n group: 'group modifier',\n container: 'container modifier',\n}\n\nconst modifierKindSort: Readonly<Record<ModifierKind, string>> = {\n state: '00',\n group: '01',\n media: '02',\n container: '03',\n theme: '04',\n platform: '05',\n}\n\nconst stateModifierSort = new Map(\n stateModifierNames.map((name, index) => [name, index] as const)\n)\n\n/**\n * The one sort key every host uses for completion entries, so ordering does\n * not drift between tsserver, LSP, and in-browser consumers: states first in\n * interaction order, then groups, media, containers, themes, platforms, then\n * configured values, then keywords.\n */\nexport function completionSortText(\n completion: StyleValueCompletion,\n modifierKind: ModifierKind | undefined\n): string {\n if (modifierKind) {\n const stateOrder =\n modifierKind === 'state'\n ? `${String(stateModifierSort.get(completion.value) ?? 999).padStart(3, '0')}:`\n : ''\n return `${modifierKindSort[modifierKind]}:${stateOrder}${completion.value}`\n }\n return `${completion.kind === 'configured' ? '10' : '11'}:${completion.value}`\n}\n\n/** unwraps a compiler-serialized token variable to its raw value */\nfunction tokenValue(entry: unknown): unknown {\n if (entry && typeof entry === 'object' && 'val' in entry) {\n return (entry as { val: unknown }).val\n }\n return entry\n}\n\nfunction parseColor(value: unknown, opacity?: number): RgbaColor | null {\n if (typeof value !== 'string') return null\n const normalized = normalizeCSSColor(value)\n if (normalized === null) return null\n const color = rgba(normalized)\n if (opacity !== undefined) color.a = color.a * (opacity / 100)\n return color\n}\n\nexport interface StyleTooling {\n /** every prop name treated as a flat style value site */\n styleProps: ReadonlySet<string>\n /** engine options, for hosts that call @tamagui/style-grammar directly */\n engine: DiagnoseStyleValueOptions\n isStyleProp(name: string): boolean\n /** the longhand a prop resolves to through the configured shorthands */\n targetProperty(name: string): string\n /**\n * cursor completions for one value slot, or null when the property takes no\n * flat program (unknown props, legacy part props)\n */\n completions(\n property: string,\n value: string,\n cursor: number\n ): StyleValueCursorCompletions | null\n /** the complete static verdict for one authored value */\n diagnostics(\n property: string,\n value: string,\n options?: { strictPayloads?: boolean }\n ): readonly StyleValueDiagnostic[]\n /** classified spans: modifiers, tokens, keywords, literals */\n annotations(property: string, value: string): readonly StyleValueAnnotation[]\n /** hover content for the annotation under `offset`, or null */\n hover(property: string, value: string, offset: number): StyleValueHover | null\n /** every span that resolves to a presentable color */\n colors(property: string, value: string): readonly StyleValueColor[]\n /** the modifier kind of a registered modifier name */\n modifierKind(name: string): ModifierKind | undefined\n /** root theme names, preview themes first */\n previewThemes: readonly string[]\n}\n\nexport interface StyleToolingOptions {\n strictPayloads?: boolean\n}\n\nexport function createStyleTooling(\n file: SerializedConfigFile,\n toolingOptions?: StyleToolingOptions\n): StyleTooling | null {\n const serialized = file.tamaguiConfig\n if (!serialized) return null\n\n const config = createGrammarConfigViewFromSerializedConfig(\n serialized,\n file.tamaguiConfigMetadata\n )\n const registry = createModifierRegistry(config).registry\n const candidates = createCandidatePropertyVocabulary(config)\n const engine: DiagnoseStyleValueOptions = {\n config,\n registry,\n candidates,\n strictPayloads: toolingOptions?.strictPayloads,\n }\n const styleProps = createStylePropSet(config)\n\n // themes and tokens keep their VALUES here; the grammar view keeps names only\n const themes = (serialized.themes || {}) as Readonly<\n Record<string, Readonly<Record<string, unknown>> | undefined>\n >\n const rootThemes = Object.keys(themes).filter((name) => !name.includes('_'))\n const previewThemes = [\n ...['light', 'dark'].filter((name) => rootThemes.includes(name)),\n ...rootThemes.filter((name) => name !== 'light' && name !== 'dark'),\n ]\n const tokens = (serialized.tokens || {}) as Readonly<\n Record<string, Readonly<Record<string, unknown>> | undefined>\n >\n const media = (serialized.media || {}) as Readonly<Record<string, unknown>>\n\n const targetProperty = (name: string): string => config.shorthands?.[name] || name\n\n const themeValue = (name: string): { theme: string; value: unknown } | null => {\n for (const theme of previewThemes) {\n const value = themes[theme]?.[name]\n if (value !== undefined) return { theme, value }\n }\n return null\n }\n\n const annotationColor = (\n annotation: StyleValueAnnotation\n ): { color: RgbaColor; theme?: string } | null => {\n if (annotation.kind === 'token' || annotation.kind === 'identifier') {\n const name =\n annotation.opacity !== undefined\n ? annotation.text.slice(0, annotation.text.lastIndexOf('/'))\n : annotation.text\n if (annotation.tokenCategory === 'color') {\n const themed = themeValue(name)\n if (themed) {\n const color = parseColor(themed.value, annotation.opacity)\n return color ? { color, theme: themed.theme } : null\n }\n const color = parseColor(tokenValue(tokens.color?.[name]), annotation.opacity)\n return color ? { color } : null\n }\n if (annotation.kind === 'identifier') {\n // literal CSS colors: hex, rgb()/hsl() never annotate (functions are\n // skipped), but hex runs and named colors do\n const color = parseColor(name)\n return color ? { color } : null\n }\n return null\n }\n if (annotation.kind === 'keyword' && annotation.text === 'transparent') {\n return { color: { r: 0, g: 0, b: 0, a: 0 } }\n }\n return null\n }\n\n const annotations = (property: string, value: string) =>\n annotateStyleValue(property, value, engine)\n\n const formatRgba = (color: RgbaColor): string =>\n color.a === 1\n ? `rgb(${color.r}, ${color.g}, ${color.b})`\n : `rgba(${color.r}, ${color.g}, ${color.b}, ${Number(color.a.toFixed(3))})`\n\n return {\n styleProps,\n engine,\n previewThemes,\n isStyleProp: (name) => styleProps.has(name),\n targetProperty,\n modifierKind: (name) => registry.get(name),\n\n completions(property, value, cursor) {\n const target = targetProperty(property)\n if (programEligibility(target) === 'legacy-part') return null\n if (!styleProps.has(property)) return null\n return completeStyleValueAtCursor(property, value, cursor, engine)\n },\n\n diagnostics(property, value, diagnosticOptions) {\n if (!styleProps.has(property)) return []\n return diagnoseStyleValueProgram(property, value, {\n ...engine,\n strictPayloads: diagnosticOptions?.strictPayloads ?? engine.strictPayloads,\n })\n },\n\n annotations,\n\n colors(property, value) {\n if (!styleProps.has(property)) return []\n const results: StyleValueColor[] = []\n for (const annotation of annotations(property, value)) {\n const resolved = annotationColor(annotation)\n if (!resolved) continue\n results.push({\n start: annotation.start,\n end: annotation.end,\n text: annotation.text,\n color: resolved.color,\n ...(resolved.theme !== undefined && { theme: resolved.theme }),\n })\n }\n return results\n },\n\n hover(property, value, offset) {\n if (!styleProps.has(property)) return null\n const annotation = annotations(property, value).find(\n (entry) => offset >= entry.start && offset <= entry.end\n )\n if (!annotation) return null\n\n const lines: string[] = []\n let color: RgbaColor | undefined\n\n if (annotation.kind === 'modifier' && annotation.modifierKind) {\n lines.push(\n `**${annotation.text}** · Tamagui ${modifierKindLabel[annotation.modifierKind]}`\n )\n if (annotation.modifierKind === 'media') {\n const query = media[annotation.text]\n if (query !== undefined) {\n lines.push('```json\\n' + JSON.stringify(query) + '\\n```')\n }\n }\n } else if (annotation.kind === 'token') {\n const name =\n annotation.opacity !== undefined\n ? annotation.text.slice(0, annotation.text.lastIndexOf('/'))\n : annotation.text\n if (annotation.tokenCategory === 'color') {\n lines.push(`**${name}** · Tamagui color`)\n let shown = 0\n for (const theme of previewThemes) {\n const value = themes[theme]?.[name]\n if (value === undefined || shown >= 4) continue\n shown++\n lines.push(`- ${theme}: \\`${String(value)}\\``)\n }\n if (shown === 0) {\n const value = tokenValue(tokens.color?.[name])\n if (value !== undefined) lines.push(`- \\`${String(value)}\\``)\n }\n if (annotation.opacity !== undefined) {\n lines.push(`- opacity: ${annotation.opacity}%`)\n }\n } else {\n const value = tokenValue(tokens[annotation.tokenCategory || '']?.[name])\n lines.push(\n `**${name}** · Tamagui ${annotation.tokenCategory} token` +\n (value !== undefined ? ` = \\`${String(value)}\\`` : '')\n )\n }\n const resolved = annotationColor(annotation)\n if (resolved) {\n color = resolved.color\n lines.push(`- resolves: \\`${formatRgba(resolved.color)}\\``)\n }\n } else if (annotation.kind === 'keyword') {\n lines.push(\n `**${annotation.text}** · CSS keyword` +\n (annotation.property ? ` for \\`${annotation.property}\\`` : '')\n )\n } else {\n const resolved = annotationColor(annotation)\n if (!resolved) return null\n color = resolved.color\n lines.push(\n `**${annotation.text}** · CSS color = \\`${formatRgba(resolved.color)}\\``\n )\n }\n\n return {\n start: annotation.start,\n end: annotation.end,\n text: annotation.text,\n markdown: lines.join('\\n\\n'),\n ...(color !== undefined && { color }),\n }\n },\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
package/types/document.d.ts
CHANGED
|
@@ -26,17 +26,23 @@ export interface DocumentHover extends StyleValueHover {
|
|
|
26
26
|
export interface DocumentCompletions extends StyleValueCursorCompletions {
|
|
27
27
|
site: StyleSite;
|
|
28
28
|
}
|
|
29
|
+
export interface DocumentDiagnosticOptions {
|
|
30
|
+
strictPayloads?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface DocumentStyleToolingOptions {
|
|
33
|
+
strictPayloads?: boolean;
|
|
34
|
+
}
|
|
29
35
|
export interface DocumentStyleTooling {
|
|
30
36
|
sites(source: string, fileName?: string): readonly StyleSite[];
|
|
31
37
|
/** completions at a file offset, spans mapped to file offsets */
|
|
32
38
|
completionsAt(source: string, offset: number, fileName?: string): DocumentCompletions | null;
|
|
33
39
|
/** every diagnostic in the file, spans mapped to file offsets */
|
|
34
|
-
diagnostics(source: string, fileName?: string): readonly DocumentDiagnostic[];
|
|
40
|
+
diagnostics(source: string, fileName?: string, options?: DocumentDiagnosticOptions): readonly DocumentDiagnostic[];
|
|
35
41
|
/** hover at a file offset, span mapped to file offsets */
|
|
36
42
|
hoverAt(source: string, offset: number, fileName?: string): DocumentHover | null;
|
|
37
43
|
/** every color swatch in the file, spans mapped to file offsets */
|
|
38
44
|
colors(source: string, fileName?: string): readonly DocumentColor[];
|
|
39
45
|
}
|
|
40
|
-
export declare function createDocumentStyleTooling(tooling: StyleTooling, extract: ExtractStyleSites): DocumentStyleTooling;
|
|
46
|
+
export declare function createDocumentStyleTooling(tooling: StyleTooling, extract: ExtractStyleSites, toolingOptions?: DocumentStyleToolingOptions): DocumentStyleTooling;
|
|
41
47
|
|
|
42
48
|
//# sourceMappingURL=document.d.ts.map
|
package/types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5
|
"src/document.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"// Document-level orchestration: an extractor locates the style value sites in\n// one source file, the core answers inside each site, and this module joins\n// the two so every host (browser IDE, LSP wrapper, CLI checker) gets\n// file-offset results from one code path.\n//\n// Extractors are pluggable because hosts already own a parse: the tsserver\n// plugin walks TypeScript's AST, the eslint rule walks ESTree, soot's bundler\n// holds sucrase tokens. Each adapter reduces its tree to the same StyleSite\n// contract; nothing downstream re-parses.\n\nimport type {\n StyleTooling,\n StyleValueColor,\n StyleValueDiagnostic,\n StyleValueHover,\n} from './core'\nimport type { StyleValueCursorCompletions } from './core'\n\n/** one static string style value in a source file */\nexport interface StyleSite {\n /** the authored prop name (`bg`, `padding`) */\n property: string\n /** the cooked string value */\n value: string\n /** file offset of the value's first character (inside the quotes) */\n start: number\n /** file offset just past the value's last character */\n end: number\n /** how the site was authored, for hosts that filter */\n kind: 'jsx-attribute' | 'styled-property'\n}\n\nexport type ExtractStyleSites = (\n source: string,\n fileName?: string\n) => readonly StyleSite[]\n\nexport interface DocumentDiagnostic extends StyleValueDiagnostic {\n site: StyleSite\n}\n\nexport interface DocumentColor extends StyleValueColor {\n site: StyleSite\n}\n\nexport interface DocumentHover extends StyleValueHover {\n site: StyleSite\n}\n\nexport interface DocumentCompletions extends StyleValueCursorCompletions {\n site: StyleSite\n}\n\nexport interface DocumentStyleTooling {\n sites(source: string, fileName?: string): readonly StyleSite[]\n /** completions at a file offset, spans mapped to file offsets */\n completionsAt(\n source: string,\n offset: number,\n fileName?: string\n ): DocumentCompletions | null\n /** every diagnostic in the file, spans mapped to file offsets */\n diagnostics(source: string
|
|
9
|
+
"// Document-level orchestration: an extractor locates the style value sites in\n// one source file, the core answers inside each site, and this module joins\n// the two so every host (browser IDE, LSP wrapper, CLI checker) gets\n// file-offset results from one code path.\n//\n// Extractors are pluggable because hosts already own a parse: the tsserver\n// plugin walks TypeScript's AST, the eslint rule walks ESTree, soot's bundler\n// holds sucrase tokens. Each adapter reduces its tree to the same StyleSite\n// contract; nothing downstream re-parses.\n\nimport type {\n StyleTooling,\n StyleValueColor,\n StyleValueDiagnostic,\n StyleValueHover,\n} from './core'\nimport type { StyleValueCursorCompletions } from './core'\n\n/** one static string style value in a source file */\nexport interface StyleSite {\n /** the authored prop name (`bg`, `padding`) */\n property: string\n /** the cooked string value */\n value: string\n /** file offset of the value's first character (inside the quotes) */\n start: number\n /** file offset just past the value's last character */\n end: number\n /** how the site was authored, for hosts that filter */\n kind: 'jsx-attribute' | 'styled-property'\n}\n\nexport type ExtractStyleSites = (\n source: string,\n fileName?: string\n) => readonly StyleSite[]\n\nexport interface DocumentDiagnostic extends StyleValueDiagnostic {\n site: StyleSite\n}\n\nexport interface DocumentColor extends StyleValueColor {\n site: StyleSite\n}\n\nexport interface DocumentHover extends StyleValueHover {\n site: StyleSite\n}\n\nexport interface DocumentCompletions extends StyleValueCursorCompletions {\n site: StyleSite\n}\n\nexport interface DocumentDiagnosticOptions {\n strictPayloads?: boolean\n}\n\nexport interface DocumentStyleToolingOptions {\n strictPayloads?: boolean\n}\n\nexport interface DocumentStyleTooling {\n sites(source: string, fileName?: string): readonly StyleSite[]\n /** completions at a file offset, spans mapped to file offsets */\n completionsAt(\n source: string,\n offset: number,\n fileName?: string\n ): DocumentCompletions | null\n /** every diagnostic in the file, spans mapped to file offsets */\n diagnostics(\n source: string,\n fileName?: string,\n options?: DocumentDiagnosticOptions\n ): readonly DocumentDiagnostic[]\n /** hover at a file offset, span mapped to file offsets */\n hoverAt(source: string, offset: number, fileName?: string): DocumentHover | null\n /** every color swatch in the file, spans mapped to file offsets */\n colors(source: string, fileName?: string): readonly DocumentColor[]\n}\n\nexport function createDocumentStyleTooling(\n tooling: StyleTooling,\n extract: ExtractStyleSites,\n toolingOptions?: DocumentStyleToolingOptions\n): DocumentStyleTooling {\n const siteAt = (sites: readonly StyleSite[], offset: number): StyleSite | undefined =>\n sites.find((site) => offset >= site.start && offset <= site.end)\n\n return {\n sites: (source, fileName) => extract(source, fileName),\n\n completionsAt(source, offset, fileName) {\n const site = siteAt(extract(source, fileName), offset)\n if (!site) return null\n const completions = tooling.completions(\n site.property,\n site.value,\n offset - site.start\n )\n if (!completions) return null\n return {\n ...completions,\n replaceStart: site.start + completions.replaceStart,\n site,\n }\n },\n\n diagnostics(source, fileName, diagnosticOptions) {\n const results: DocumentDiagnostic[] = []\n const strictPayloads =\n diagnosticOptions?.strictPayloads ?? toolingOptions?.strictPayloads\n for (const site of extract(source, fileName)) {\n for (const diagnostic of tooling.diagnostics(site.property, site.value, {\n strictPayloads,\n })) {\n results.push({\n ...diagnostic,\n index: site.start + diagnostic.index,\n start: site.start + diagnostic.start,\n end: site.start + diagnostic.end,\n site,\n })\n }\n }\n return results\n },\n\n hoverAt(source, offset, fileName) {\n const site = siteAt(extract(source, fileName), offset)\n if (!site) return null\n const hover = tooling.hover(site.property, site.value, offset - site.start)\n if (!hover) return null\n return {\n ...hover,\n start: site.start + hover.start,\n end: site.start + hover.end,\n site,\n }\n },\n\n colors(source, fileName) {\n const results: DocumentColor[] = []\n for (const site of extract(source, fileName)) {\n for (const color of tooling.colors(site.property, site.value)) {\n results.push({\n ...color,\n start: site.start + color.start,\n end: site.start + color.end,\n site,\n })\n }\n }\n return results\n },\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const init: ts.server.PluginModuleFactory;
|
|
7
|
-
export default init;
|
|
1
|
+
export * from "./core";
|
|
2
|
+
export * from "./document";
|
|
3
|
+
export * from "./extract-estree";
|
|
4
|
+
export * from "./extract-sucrase";
|
|
8
5
|
|
|
9
6
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import { isAbsolute, resolve } from 'node:path'\n\nimport type ts from 'typescript'\nimport {\n completionSortText,\n createStyleTooling,\n type SerializedConfigFile,\n type StyleTooling,\n} from './core'\nimport { resolveTamaguiHost } from './host'\n\nconst completionSource = '@tamagui/language-service'\nconst diagnosticCode = 78711\nconst defaultConfigPath = '.tamagui/tamagui.config.json'\nconst flatStyledModules: ReadonlySet<string> = new Set([\n 'tamagui',\n 'tamagui/unstyled',\n '@tamagui/core',\n '@tamagui/ui',\n '@tamagui/web',\n])\n\nexport interface TamaguiLanguageServicePluginConfig {\n /** Path to the config JSON emitted by the Tamagui compiler. */\n configPath?: string\n}\n\ntype ImportedBindings = {\n styled: ReadonlySet<string>\n}\n\ntype LiteralSite = {\n property: string\n /** cooked value, identical to its authored source text */\n value: string\n /** file offset of the value's first character */\n contentStart: number\n literal: ts.StringLiteralLike\n}\n\nfunction loadTooling(\n info: ts.server.PluginCreateInfo,\n configPath: string\n): StyleTooling | null {\n const contents = info.serverHost.readFile(configPath)\n if (contents === undefined) return null\n try {\n return createStyleTooling(JSON.parse(contents) as SerializedConfigFile)\n } catch {\n return null\n }\n}\n\nfunction findStringLiteralAtPosition(\n typescript: typeof ts,\n sourceFile: ts.SourceFile,\n position: number\n): ts.StringLiteralLike | null {\n let found: ts.StringLiteralLike | null = null\n const visit = (node: ts.Node): void => {\n if (position < node.getFullStart() || position > node.getEnd()) return\n if (\n typescript.isStringLiteralLike(node) &&\n position >= node.getStart(sourceFile) + 1 &&\n position <= node.getEnd() - 1\n ) {\n found = node\n return\n }\n typescript.forEachChild(node, visit)\n }\n visit(sourceFile)\n return found\n}\n\nfunction importedBindings(\n typescript: typeof ts,\n sourceFile: ts.SourceFile\n): ImportedBindings {\n const styled = new Set<string>()\n\n for (const statement of sourceFile.statements) {\n if (\n !typescript.isImportDeclaration(statement) ||\n !typescript.isStringLiteral(statement.moduleSpecifier)\n ) {\n continue\n }\n const source = statement.moduleSpecifier.text\n if (!flatStyledModules.has(source)) continue\n const bindings = statement.importClause?.namedBindings\n if (!bindings) continue\n if (typescript.isNamespaceImport(bindings)) continue\n for (const element of bindings.elements) {\n const imported = element.propertyName?.text || element.name.text\n if (imported === 'styled') styled.add(element.name.text)\n }\n }\n\n return { styled }\n}\n\nfunction propertyName(typescript: typeof ts, name: ts.PropertyName): string | null {\n if (typescript.isIdentifier(name) || typescript.isStringLiteral(name)) {\n return name.text\n }\n return null\n}\n\nfunction completionProperty(\n typescript: typeof ts,\n literal: ts.StringLiteralLike,\n tooling: StyleTooling,\n checker: ts.TypeChecker,\n bindings: ImportedBindings\n): { property: string } | null {\n let parent = literal.parent\n\n if (typescript.isJsxExpression(parent)) parent = parent.parent\n if (typescript.isJsxAttribute(parent)) {\n if (!typescript.isIdentifier(parent.name)) return null\n const property = parent.name.text\n if (!tooling.styleProps.has(property)) return null\n const opening = parent.parent.parent\n if (!typescript.isJsxOpeningLikeElement(opening)) return null\n const host = resolveTamaguiHost(checker, opening.tagName)\n if (!host?.accepts(property)) return null\n return { property }\n }\n\n if (!typescript.isPropertyAssignment(parent)) return null\n const property = propertyName(typescript, parent.name)\n if (!property || !tooling.styleProps.has(property)) return null\n\n let current: ts.Node = parent\n while (current.parent && !typescript.isCallExpression(current.parent)) {\n current = current.parent\n }\n if (!current.parent || !typescript.isCallExpression(current.parent)) return null\n const call = current.parent\n if (\n call.arguments[1] !== current ||\n !typescript.isIdentifier(call.expression) ||\n !bindings.styled.has(call.expression.text)\n ) {\n return null\n }\n const component = call.arguments[0]\n const host = component && resolveTamaguiHost(checker, component)\n if (!host?.accepts(property)) return null\n return { property }\n}\n\n/**\n * The literal as a style value site, or null when it is not one: wrong parent\n * shape, not a style prop, not a tamagui host, or authored with escapes that\n * cook differently than they read (TypeScript exposes cooked values but no\n * cooked-to-source offset map, so exact-raw literals only).\n */\nfunction siteForLiteral(\n typescript: typeof ts,\n sourceFile: ts.SourceFile,\n literal: ts.StringLiteralLike,\n tooling: StyleTooling,\n checker: ts.TypeChecker,\n bindings: ImportedBindings\n): LiteralSite | null {\n const site = completionProperty(typescript, literal, tooling, checker, bindings)\n if (!site) return null\n const contentStart = literal.getStart(sourceFile) + 1\n const contentEnd = literal.getEnd() - 1\n const sourceInput = sourceFile.text.slice(contentStart, contentEnd)\n if (literal.text !== sourceInput) return null\n return { property: site.property, value: literal.text, contentStart, literal }\n}\n\nfunction collectLiteralSites(\n typescript: typeof ts,\n sourceFile: ts.SourceFile,\n tooling: StyleTooling,\n checker: ts.TypeChecker,\n bindings: ImportedBindings\n): LiteralSite[] {\n const sites: LiteralSite[] = []\n const visit = (node: ts.Node): void => {\n if (typescript.isStringLiteralLike(node)) {\n const site = siteForLiteral(\n typescript,\n sourceFile,\n node,\n tooling,\n checker,\n bindings\n )\n if (site) sites.push(site)\n return\n }\n typescript.forEachChild(node, visit)\n }\n visit(sourceFile)\n return sites\n}\n\nfunction copyLanguageService(service: ts.LanguageService): ts.LanguageService {\n const proxy = Object.create(null) as ts.LanguageService\n for (const key of Object.keys(service) as Array<keyof ts.LanguageService>) {\n const value = service[key]\n ;(proxy as unknown as Record<string, unknown>)[key] =\n typeof value === 'function' ? value.bind(service) : value\n }\n return proxy\n}\n\nconst init: ts.server.PluginModuleFactory = ({ typescript }) => ({\n create(info) {\n const pluginConfig = info.config as TamaguiLanguageServicePluginConfig | undefined\n const configuredPath = pluginConfig?.configPath || defaultConfigPath\n const configPath = isAbsolute(configuredPath)\n ? configuredPath\n : resolve(info.project.getCurrentDirectory(), configuredPath)\n let tooling = loadTooling(info, configPath)\n const watcher = info.serverHost.watchFile(configPath, () => {\n tooling = loadTooling(info, configPath)\n })\n\n const proxy = copyLanguageService(info.languageService)\n const baseCompletions = info.languageService.getCompletionsAtPosition.bind(\n info.languageService\n )\n const baseDetails = info.languageService.getCompletionEntryDetails.bind(\n info.languageService\n )\n const baseSemanticDiagnostics = info.languageService.getSemanticDiagnostics.bind(\n info.languageService\n )\n const baseQuickInfo = info.languageService.getQuickInfoAtPosition.bind(\n info.languageService\n )\n const baseDispose = info.languageService.dispose.bind(info.languageService)\n const bindingsBySourceFile = new WeakMap<ts.SourceFile, ImportedBindings>()\n\n const fileContext = (\n fileName: string\n ): {\n sourceFile: ts.SourceFile\n checker: ts.TypeChecker\n bindings: ImportedBindings\n } | null => {\n const program = info.languageService.getProgram()\n const sourceFile = program?.getSourceFile(fileName)\n if (!program || !sourceFile) return null\n let bindings = bindingsBySourceFile.get(sourceFile)\n if (!bindings) {\n bindings = importedBindings(typescript, sourceFile)\n bindingsBySourceFile.set(sourceFile, bindings)\n }\n return { sourceFile, checker: program.getTypeChecker(), bindings }\n }\n\n proxy.getCompletionsAtPosition = (\n fileName,\n position,\n options,\n formattingSettings\n ) => {\n const getBaseCompletions = () =>\n baseCompletions(fileName, position, options, formattingSettings)\n if (!tooling) return getBaseCompletions()\n const context = fileContext(fileName)\n if (!context) return getBaseCompletions()\n const { sourceFile, checker, bindings } = context\n const literal = findStringLiteralAtPosition(typescript, sourceFile, position)\n if (!literal) return getBaseCompletions()\n const site = siteForLiteral(\n typescript,\n sourceFile,\n literal,\n tooling,\n checker,\n bindings\n )\n if (!site) return getBaseCompletions()\n\n const cursorCompletions = tooling.completions(\n site.property,\n site.value,\n position - site.contentStart\n )\n if (!cursorCompletions) return getBaseCompletions()\n const replacementSpan = {\n start: site.contentStart + cursorCompletions.replaceStart,\n length: cursorCompletions.replaceLength,\n }\n const entries: ts.CompletionEntry[] = []\n let contextualType: ts.Type | undefined\n for (const completion of cursorCompletions.completions) {\n const insertText = completion.insertText || completion.value\n const modifierKind =\n completion.kind === 'modifier'\n ? tooling.modifierKind(completion.value)\n : undefined\n if (completion.kind === 'keyword') {\n contextualType ||= checker.getContextualType(literal)\n if (\n !contextualType ||\n !checker.isTypeAssignableTo(\n checker.getStringLiteralType(insertText),\n contextualType\n )\n ) {\n continue\n }\n }\n entries.push({\n name: completion.value,\n kind: typescript.ScriptElementKind.string,\n kindModifiers: '',\n sortText: completionSortText(completion, modifierKind),\n insertText,\n replacementSpan,\n source: completionSource,\n labelDetails: {\n description: modifierKind\n ? `Tamagui ${modifierKind} modifier`\n : completion.kind === 'configured'\n ? 'Tamagui configured value'\n : 'Tamagui style keyword',\n },\n })\n }\n if (entries.length === 0) return getBaseCompletions()\n return {\n isGlobalCompletion: false,\n isMemberCompletion: false,\n isNewIdentifierLocation: true,\n // A completion requested immediately after whitespace has an empty\n // replacement span. Ask the editor to request again as the modifier\n // prefix grows instead of dismissing suggestions when the cursor\n // moves beyond that initial span.\n isIncomplete: true,\n entries,\n }\n }\n\n proxy.getCompletionEntryDetails = (\n fileName,\n position,\n entryName,\n formatOptions,\n source,\n preferences,\n data\n ) => {\n if (source === completionSource) {\n return {\n name: entryName,\n kind: typescript.ScriptElementKind.string,\n kindModifiers: '',\n displayParts: [\n {\n text: entryName,\n kind: 'stringLiteral',\n },\n ],\n documentation: [\n {\n text: 'Resolved from the active Tamagui config.',\n kind: 'text',\n },\n ],\n tags: [],\n }\n }\n return baseDetails(\n fileName,\n position,\n entryName,\n formatOptions,\n source,\n preferences,\n data\n )\n }\n\n proxy.getSemanticDiagnostics = (fileName) => {\n const diagnostics = [...baseSemanticDiagnostics(fileName)]\n if (!tooling) return diagnostics\n const context = fileContext(fileName)\n if (!context) return diagnostics\n const { sourceFile, checker, bindings } = context\n for (const site of collectLiteralSites(\n typescript,\n sourceFile,\n tooling,\n checker,\n bindings\n )) {\n for (const diagnostic of tooling.diagnostics(site.property, site.value)) {\n diagnostics.push({\n file: sourceFile,\n start: site.contentStart + diagnostic.start,\n length: Math.max(1, diagnostic.end - diagnostic.start),\n messageText: diagnostic.message,\n category: typescript.DiagnosticCategory.Error,\n code: diagnosticCode,\n source: completionSource,\n })\n }\n }\n return diagnostics\n }\n\n proxy.getQuickInfoAtPosition = (fileName, position) => {\n const getBaseQuickInfo = () => baseQuickInfo(fileName, position)\n if (!tooling) return getBaseQuickInfo()\n const context = fileContext(fileName)\n if (!context) return getBaseQuickInfo()\n const { sourceFile, checker, bindings } = context\n const literal = findStringLiteralAtPosition(typescript, sourceFile, position)\n if (!literal) return getBaseQuickInfo()\n const site = siteForLiteral(\n typescript,\n sourceFile,\n literal,\n tooling,\n checker,\n bindings\n )\n if (!site) return getBaseQuickInfo()\n const hover = tooling.hover(site.property, site.value, position - site.contentStart)\n if (!hover) return getBaseQuickInfo()\n return {\n kind: typescript.ScriptElementKind.string,\n kindModifiers: '',\n textSpan: {\n start: site.contentStart + hover.start,\n length: hover.end - hover.start,\n },\n displayParts: [{ text: hover.text, kind: 'stringLiteral' }],\n documentation: [{ text: hover.markdown, kind: 'text' }],\n }\n }\n\n proxy.dispose = () => {\n watcher.close()\n baseDispose()\n }\n return proxy\n },\n})\n\nexport default init\n"
|
|
9
|
+
"export * from './core'\nexport * from './document'\nexport * from './extract-estree'\nexport * from './extract-sucrase'\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
package/dist/cjs/host.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
var host_exports = {};
|
|
22
|
-
__export(host_exports, { resolveTamaguiHost: () => resolveTamaguiHost });
|
|
23
|
-
module.exports = __toCommonJS(host_exports);
|
|
24
|
-
function resolveTamaguiHost(checker, component) {
|
|
25
|
-
const componentType = checker.getTypeAtLocation(component);
|
|
26
|
-
if (!checker.getPropertyOfType(componentType, "staticConfig")) return void 0;
|
|
27
|
-
const propsTypes = [];
|
|
28
|
-
for (const signature of componentType.getCallSignatures()) {
|
|
29
|
-
const props = signature.getParameters()[0];
|
|
30
|
-
if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));
|
|
31
|
-
}
|
|
32
|
-
if (propsTypes.length === 0) return void 0;
|
|
33
|
-
return {
|
|
34
|
-
displayName: component.getText(),
|
|
35
|
-
accepts: (property) => propsTypes.some((propsType) => checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0)
|
|
36
|
-
};
|
|
37
|
-
}
|
package/dist/cjs/host.native.cjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var host_exports = {};
|
|
24
|
-
__export(host_exports, { resolveTamaguiHost: () => resolveTamaguiHost });
|
|
25
|
-
module.exports = __toCommonJS(host_exports);
|
|
26
|
-
function resolveTamaguiHost(checker, component) {
|
|
27
|
-
var componentType = checker.getTypeAtLocation(component);
|
|
28
|
-
if (!checker.getPropertyOfType(componentType, "staticConfig")) return void 0;
|
|
29
|
-
var propsTypes = [];
|
|
30
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
31
|
-
try {
|
|
32
|
-
for (var _iterator = componentType.getCallSignatures()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
33
|
-
var signature = _step.value;
|
|
34
|
-
var props = signature.getParameters()[0];
|
|
35
|
-
if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));
|
|
36
|
-
}
|
|
37
|
-
} catch (err) {
|
|
38
|
-
_didIteratorError = true;
|
|
39
|
-
_iteratorError = err;
|
|
40
|
-
} finally {
|
|
41
|
-
try {
|
|
42
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
43
|
-
_iterator.return();
|
|
44
|
-
}
|
|
45
|
-
} finally {
|
|
46
|
-
if (_didIteratorError) {
|
|
47
|
-
throw _iteratorError;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (propsTypes.length === 0) return void 0;
|
|
52
|
-
return {
|
|
53
|
-
displayName: component.getText(),
|
|
54
|
-
accepts: function(property) {
|
|
55
|
-
return propsTypes.some(function(propsType) {
|
|
56
|
-
return checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
package/dist/cjs/host.native.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var host_exports = {};
|
|
24
|
-
__export(host_exports, { resolveTamaguiHost: () => resolveTamaguiHost });
|
|
25
|
-
module.exports = __toCommonJS(host_exports);
|
|
26
|
-
function resolveTamaguiHost(checker, component) {
|
|
27
|
-
var componentType = checker.getTypeAtLocation(component);
|
|
28
|
-
if (!checker.getPropertyOfType(componentType, "staticConfig")) return void 0;
|
|
29
|
-
var propsTypes = [];
|
|
30
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
31
|
-
try {
|
|
32
|
-
for (var _iterator = componentType.getCallSignatures()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
33
|
-
var signature = _step.value;
|
|
34
|
-
var props = signature.getParameters()[0];
|
|
35
|
-
if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));
|
|
36
|
-
}
|
|
37
|
-
} catch (err) {
|
|
38
|
-
_didIteratorError = true;
|
|
39
|
-
_iteratorError = err;
|
|
40
|
-
} finally {
|
|
41
|
-
try {
|
|
42
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
43
|
-
_iterator.return();
|
|
44
|
-
}
|
|
45
|
-
} finally {
|
|
46
|
-
if (_didIteratorError) {
|
|
47
|
-
throw _iteratorError;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (propsTypes.length === 0) return void 0;
|
|
52
|
-
return {
|
|
53
|
-
displayName: component.getText(),
|
|
54
|
-
accepts: function(property) {
|
|
55
|
-
return propsTypes.some(function(propsType) {
|
|
56
|
-
return checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//# sourceMappingURL=host.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host.native.js","names":[],"sources":["cjs/host.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar host_exports = {};\n__export(host_exports, {\n resolveTamaguiHost: () => resolveTamaguiHost\n});\nmodule.exports = __toCommonJS(host_exports);\nfunction resolveTamaguiHost(checker, component) {\n var componentType = checker.getTypeAtLocation(component);\n if (!checker.getPropertyOfType(componentType, \"staticConfig\")) return void 0;\n var propsTypes = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = componentType.getCallSignatures()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var signature = _step.value;\n var props = signature.getParameters()[0];\n if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (propsTypes.length === 0) return void 0;\n return {\n displayName: component.getText(),\n accepts: function(property) {\n return propsTypes.some(function(propsType) {\n return checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0;\n });\n }\n };\n}\n//# sourceMappingURL=host.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK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,WAAW,KAAK,SAAS,WAAW;IACzC,OAAO,QAAQ,kBAAkB,QAAQ,gBAAgB,SAAS,GAAG,QAAQ,MAAM,KAAK;GAC1F,CAAC;EACH;CACF;AACF"}
|
package/dist/esm/host.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
function resolveTamaguiHost(checker, component) {
|
|
2
|
-
const componentType = checker.getTypeAtLocation(component);
|
|
3
|
-
if (!checker.getPropertyOfType(componentType, "staticConfig")) return void 0;
|
|
4
|
-
const propsTypes = [];
|
|
5
|
-
for (const signature of componentType.getCallSignatures()) {
|
|
6
|
-
const props = signature.getParameters()[0];
|
|
7
|
-
if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));
|
|
8
|
-
}
|
|
9
|
-
if (propsTypes.length === 0) return void 0;
|
|
10
|
-
return {
|
|
11
|
-
displayName: component.getText(),
|
|
12
|
-
accepts: (property) => propsTypes.some((propsType) => checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0)
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { resolveTamaguiHost };
|
|
17
|
-
//# sourceMappingURL=host.mjs.map
|
package/dist/esm/host.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","names":[],"sources":["esm/host.js"],"sourcesContent":["function resolveTamaguiHost(checker, component) {\n const componentType = checker.getTypeAtLocation(component);\n if (!checker.getPropertyOfType(componentType, \"staticConfig\")) return void 0;\n const propsTypes = [];\n for (const signature of componentType.getCallSignatures()) {\n const props = signature.getParameters()[0];\n if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));\n }\n if (propsTypes.length === 0) return void 0;\n return {\n displayName: component.getText(),\n accepts: (property) => propsTypes.some(\n (propsType) => checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0\n )\n };\n}\nexport {\n resolveTamaguiHost\n};\n//# sourceMappingURL=host.js.map\n"],"mappings":";AAAA,SAAS,mBAAmB,SAAS,WAAW;CAC9C,MAAM,gBAAgB,QAAQ,kBAAkB,SAAS;CACzD,IAAI,CAAC,QAAQ,kBAAkB,eAAe,cAAc,GAAG,OAAO,KAAK;CAC3E,MAAM,aAAa,CAAC;CACpB,KAAK,MAAM,aAAa,cAAc,kBAAkB,GAAG;EACzD,MAAM,QAAQ,UAAU,cAAc,CAAC,CAAC;EACxC,IAAI,OAAO,WAAW,KAAK,QAAQ,0BAA0B,OAAO,SAAS,CAAC;CAChF;CACA,IAAI,WAAW,WAAW,GAAG,OAAO,KAAK;CACzC,OAAO;EACL,aAAa,UAAU,QAAQ;EAC/B,UAAU,aAAa,WAAW,MAC/B,cAAc,QAAQ,kBAAkB,QAAQ,gBAAgB,SAAS,GAAG,QAAQ,MAAM,KAAK,CAClG;CACF;AACF"}
|
package/dist/esm/host.native.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
function resolveTamaguiHost(checker, component) {
|
|
2
|
-
var componentType = checker.getTypeAtLocation(component);
|
|
3
|
-
if (!checker.getPropertyOfType(componentType, "staticConfig")) return void 0;
|
|
4
|
-
var propsTypes = [];
|
|
5
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
6
|
-
try {
|
|
7
|
-
for (var _iterator = componentType.getCallSignatures()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
8
|
-
var signature = _step.value;
|
|
9
|
-
var props = signature.getParameters()[0];
|
|
10
|
-
if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));
|
|
11
|
-
}
|
|
12
|
-
} catch (err) {
|
|
13
|
-
_didIteratorError = true;
|
|
14
|
-
_iteratorError = err;
|
|
15
|
-
} finally {
|
|
16
|
-
try {
|
|
17
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
18
|
-
_iterator.return();
|
|
19
|
-
}
|
|
20
|
-
} finally {
|
|
21
|
-
if (_didIteratorError) {
|
|
22
|
-
throw _iteratorError;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (propsTypes.length === 0) return void 0;
|
|
27
|
-
return {
|
|
28
|
-
displayName: component.getText(),
|
|
29
|
-
accepts: function(property) {
|
|
30
|
-
return propsTypes.some(function(propsType) {
|
|
31
|
-
return checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { resolveTamaguiHost };
|
|
38
|
-
//# sourceMappingURL=host.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host.native.js","names":[],"sources":["esm/host.native.js"],"sourcesContent":["function resolveTamaguiHost(checker, component) {\n var componentType = checker.getTypeAtLocation(component);\n if (!checker.getPropertyOfType(componentType, \"staticConfig\")) return void 0;\n var propsTypes = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = componentType.getCallSignatures()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var signature = _step.value;\n var props = signature.getParameters()[0];\n if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (propsTypes.length === 0) return void 0;\n return {\n displayName: component.getText(),\n accepts: function(property) {\n return propsTypes.some(function(propsType) {\n return checker.getPropertyOfType(checker.getApparentType(propsType), property) !== void 0;\n });\n }\n };\n}\nexport {\n resolveTamaguiHost\n};\n//# sourceMappingURL=host.js.map\n"],"mappings":";AAAA,SAAS,mBAAmB,SAAS,WAAW;CAC9C,IAAI,gBAAgB,QAAQ,kBAAkB,SAAS;CACvD,IAAI,CAAC,QAAQ,kBAAkB,eAAe,cAAc,GAAG,OAAO,KAAK;CAC3E,IAAI,aAAa,CAAC;CAClB,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;CACvF,IAAI;EACF,KAAK,IAAI,YAAY,cAAc,kBAAkB,CAAC,CAAC,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;GAClL,IAAI,YAAY,MAAM;GACtB,IAAI,QAAQ,UAAU,cAAc,CAAC,CAAC;GACtC,IAAI,OAAO,WAAW,KAAK,QAAQ,0BAA0B,OAAO,SAAS,CAAC;EAChF;CACF,SAAS,KAAK;EACZ,oBAAoB;EACpB,iBAAiB;CACnB,UAAU;EACR,IAAI;GACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;IAC1D,UAAU,OAAO;GACnB;EACF,UAAU;GACR,IAAI,mBAAmB;IACrB,MAAM;GACR;EACF;CACF;CACA,IAAI,WAAW,WAAW,GAAG,OAAO,KAAK;CACzC,OAAO;EACL,aAAa,UAAU,QAAQ;EAC/B,SAAS,SAAS,UAAU;GAC1B,OAAO,WAAW,KAAK,SAAS,WAAW;IACzC,OAAO,QAAQ,kBAAkB,QAAQ,gBAAgB,SAAS,GAAG,QAAQ,MAAM,KAAK;GAC1F,CAAC;EACH;CACF;AACF"}
|
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isAbsolute, resolve } from \"node:path\";\nimport {\n completionSortText,\n createStyleTooling\n} from \"./core\";\nimport { resolveTamaguiHost } from \"./host\";\nconst completionSource = \"@tamagui/language-service\";\nconst diagnosticCode = 78711;\nconst defaultConfigPath = \".tamagui/tamagui.config.json\";\nconst flatStyledModules = /* @__PURE__ */ new Set([\n \"tamagui\",\n \"tamagui/unstyled\",\n \"@tamagui/core\",\n \"@tamagui/ui\",\n \"@tamagui/web\"\n]);\nfunction loadTooling(info, configPath) {\n const contents = info.serverHost.readFile(configPath);\n if (contents === void 0) return null;\n try {\n return createStyleTooling(JSON.parse(contents));\n } catch {\n return null;\n }\n}\nfunction findStringLiteralAtPosition(typescript, sourceFile, position) {\n let found = null;\n const visit = (node) => {\n if (position < node.getFullStart() || position > node.getEnd()) return;\n if (typescript.isStringLiteralLike(node) && position >= node.getStart(sourceFile) + 1 && position <= node.getEnd() - 1) {\n found = node;\n return;\n }\n typescript.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n}\nfunction importedBindings(typescript, sourceFile) {\n const styled = /* @__PURE__ */ new Set();\n for (const statement of sourceFile.statements) {\n if (!typescript.isImportDeclaration(statement) || !typescript.isStringLiteral(statement.moduleSpecifier)) {\n continue;\n }\n const source = statement.moduleSpecifier.text;\n if (!flatStyledModules.has(source)) continue;\n const bindings = statement.importClause?.namedBindings;\n if (!bindings) continue;\n if (typescript.isNamespaceImport(bindings)) continue;\n for (const element of bindings.elements) {\n const imported = element.propertyName?.text || element.name.text;\n if (imported === \"styled\") styled.add(element.name.text);\n }\n }\n return { styled };\n}\nfunction propertyName(typescript, name) {\n if (typescript.isIdentifier(name) || typescript.isStringLiteral(name)) {\n return name.text;\n }\n return null;\n}\nfunction completionProperty(typescript, literal, tooling, checker, bindings) {\n let parent = literal.parent;\n if (typescript.isJsxExpression(parent)) parent = parent.parent;\n if (typescript.isJsxAttribute(parent)) {\n if (!typescript.isIdentifier(parent.name)) return null;\n const property2 = parent.name.text;\n if (!tooling.styleProps.has(property2)) return null;\n const opening = parent.parent.parent;\n if (!typescript.isJsxOpeningLikeElement(opening)) return null;\n const host2 = resolveTamaguiHost(checker, opening.tagName);\n if (!host2?.accepts(property2)) return null;\n return { property: property2 };\n }\n if (!typescript.isPropertyAssignment(parent)) return null;\n const property = propertyName(typescript, parent.name);\n if (!property || !tooling.styleProps.has(property)) return null;\n let current = parent;\n while (current.parent && !typescript.isCallExpression(current.parent)) {\n current = current.parent;\n }\n if (!current.parent || !typescript.isCallExpression(current.parent)) return null;\n const call = current.parent;\n if (call.arguments[1] !== current || !typescript.isIdentifier(call.expression) || !bindings.styled.has(call.expression.text)) {\n return null;\n }\n const component = call.arguments[0];\n const host = component && resolveTamaguiHost(checker, component);\n if (!host?.accepts(property)) return null;\n return { property };\n}\nfunction siteForLiteral(typescript, sourceFile, literal, tooling, checker, bindings) {\n const site = completionProperty(typescript, literal, tooling, checker, bindings);\n if (!site) return null;\n const contentStart = literal.getStart(sourceFile) + 1;\n const contentEnd = literal.getEnd() - 1;\n const sourceInput = sourceFile.text.slice(contentStart, contentEnd);\n if (literal.text !== sourceInput) return null;\n return { property: site.property, value: literal.text, contentStart, literal };\n}\nfunction collectLiteralSites(typescript, sourceFile, tooling, checker, bindings) {\n const sites = [];\n const visit = (node) => {\n if (typescript.isStringLiteralLike(node)) {\n const site = siteForLiteral(\n typescript,\n sourceFile,\n node,\n tooling,\n checker,\n bindings\n );\n if (site) sites.push(site);\n return;\n }\n typescript.forEachChild(node, visit);\n };\n visit(sourceFile);\n return sites;\n}\nfunction copyLanguageService(service) {\n const proxy = /* @__PURE__ */ Object.create(null);\n for (const key of Object.keys(service)) {\n const value = service[key];\n proxy[key] = typeof value === \"function\" ? value.bind(service) : value;\n }\n return proxy;\n}\nconst init = ({ typescript }) => ({\n create(info) {\n const pluginConfig = info.config;\n const configuredPath = pluginConfig?.configPath || defaultConfigPath;\n const configPath = isAbsolute(configuredPath) ? configuredPath : resolve(info.project.getCurrentDirectory(), configuredPath);\n let tooling = loadTooling(info, configPath);\n const watcher = info.serverHost.watchFile(configPath, () => {\n tooling = loadTooling(info, configPath);\n });\n const proxy = copyLanguageService(info.languageService);\n const baseCompletions = info.languageService.getCompletionsAtPosition.bind(\n info.languageService\n );\n const baseDetails = info.languageService.getCompletionEntryDetails.bind(\n info.languageService\n );\n const baseSemanticDiagnostics = info.languageService.getSemanticDiagnostics.bind(\n info.languageService\n );\n const baseQuickInfo = info.languageService.getQuickInfoAtPosition.bind(\n info.languageService\n );\n const baseDispose = info.languageService.dispose.bind(info.languageService);\n const bindingsBySourceFile = /* @__PURE__ */ new WeakMap();\n const fileContext = (fileName) => {\n const program = info.languageService.getProgram();\n const sourceFile = program?.getSourceFile(fileName);\n if (!program || !sourceFile) return null;\n let bindings = bindingsBySourceFile.get(sourceFile);\n if (!bindings) {\n bindings = importedBindings(typescript, sourceFile);\n bindingsBySourceFile.set(sourceFile, bindings);\n }\n return { sourceFile, checker: program.getTypeChecker(), bindings };\n };\n proxy.getCompletionsAtPosition = (fileName, position, options, formattingSettings) => {\n const getBaseCompletions = () => baseCompletions(fileName, position, options, formattingSettings);\n if (!tooling) return getBaseCompletions();\n const context = fileContext(fileName);\n if (!context) return getBaseCompletions();\n const { sourceFile, checker, bindings } = context;\n const literal = findStringLiteralAtPosition(typescript, sourceFile, position);\n if (!literal) return getBaseCompletions();\n const site = siteForLiteral(\n typescript,\n sourceFile,\n literal,\n tooling,\n checker,\n bindings\n );\n if (!site) return getBaseCompletions();\n const cursorCompletions = tooling.completions(\n site.property,\n site.value,\n position - site.contentStart\n );\n if (!cursorCompletions) return getBaseCompletions();\n const replacementSpan = {\n start: site.contentStart + cursorCompletions.replaceStart,\n length: cursorCompletions.replaceLength\n };\n const entries = [];\n let contextualType;\n for (const completion of cursorCompletions.completions) {\n const insertText = completion.insertText || completion.value;\n const modifierKind = completion.kind === \"modifier\" ? tooling.modifierKind(completion.value) : void 0;\n if (completion.kind === \"keyword\") {\n contextualType ||= checker.getContextualType(literal);\n if (!contextualType || !checker.isTypeAssignableTo(\n checker.getStringLiteralType(insertText),\n contextualType\n )) {\n continue;\n }\n }\n entries.push({\n name: completion.value,\n kind: typescript.ScriptElementKind.string,\n kindModifiers: \"\",\n sortText: completionSortText(completion, modifierKind),\n insertText,\n replacementSpan,\n source: completionSource,\n labelDetails: {\n description: modifierKind ? `Tamagui ${modifierKind} modifier` : completion.kind === \"configured\" ? \"Tamagui configured value\" : \"Tamagui style keyword\"\n }\n });\n }\n if (entries.length === 0) return getBaseCompletions();\n return {\n isGlobalCompletion: false,\n isMemberCompletion: false,\n isNewIdentifierLocation: true,\n // A completion requested immediately after whitespace has an empty\n // replacement span. Ask the editor to request again as the modifier\n // prefix grows instead of dismissing suggestions when the cursor\n // moves beyond that initial span.\n isIncomplete: true,\n entries\n };\n };\n proxy.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, data) => {\n if (source === completionSource) {\n return {\n name: entryName,\n kind: typescript.ScriptElementKind.string,\n kindModifiers: \"\",\n displayParts: [\n {\n text: entryName,\n kind: \"stringLiteral\"\n }\n ],\n documentation: [\n {\n text: \"Resolved from the active Tamagui config.\",\n kind: \"text\"\n }\n ],\n tags: []\n };\n }\n return baseDetails(\n fileName,\n position,\n entryName,\n formatOptions,\n source,\n preferences,\n data\n );\n };\n proxy.getSemanticDiagnostics = (fileName) => {\n const diagnostics = [...baseSemanticDiagnostics(fileName)];\n if (!tooling) return diagnostics;\n const context = fileContext(fileName);\n if (!context) return diagnostics;\n const { sourceFile, checker, bindings } = context;\n for (const site of collectLiteralSites(\n typescript,\n sourceFile,\n tooling,\n checker,\n bindings\n )) {\n for (const diagnostic of tooling.diagnostics(site.property, site.value)) {\n diagnostics.push({\n file: sourceFile,\n start: site.contentStart + diagnostic.start,\n length: Math.max(1, diagnostic.end - diagnostic.start),\n messageText: diagnostic.message,\n category: typescript.DiagnosticCategory.Error,\n code: diagnosticCode,\n source: completionSource\n });\n }\n }\n return diagnostics;\n };\n proxy.getQuickInfoAtPosition = (fileName, position) => {\n const getBaseQuickInfo = () => baseQuickInfo(fileName, position);\n if (!tooling) return getBaseQuickInfo();\n const context = fileContext(fileName);\n if (!context) return getBaseQuickInfo();\n const { sourceFile, checker, bindings } = context;\n const literal = findStringLiteralAtPosition(typescript, sourceFile, position);\n if (!literal) return getBaseQuickInfo();\n const site = siteForLiteral(\n typescript,\n sourceFile,\n literal,\n tooling,\n checker,\n bindings\n );\n if (!site) return getBaseQuickInfo();\n const hover = tooling.hover(site.property, site.value, position - site.contentStart);\n if (!hover) return getBaseQuickInfo();\n return {\n kind: typescript.ScriptElementKind.string,\n kindModifiers: \"\",\n textSpan: {\n start: site.contentStart + hover.start,\n length: hover.end - hover.start\n },\n displayParts: [{ text: hover.text, kind: \"stringLiteral\" }],\n documentation: [{ text: hover.markdown, kind: \"text\" }]\n };\n };\n proxy.dispose = () => {\n watcher.close();\n baseDispose();\n };\n return proxy;\n }\n});\nvar index_default = init;\nexport {\n index_default as default\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;AAMA,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,oCAAoC,IAAI,IAAI;CAChD;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,SAAS,YAAY,MAAM,YAAY;CACrC,MAAM,WAAW,KAAK,WAAW,SAAS,UAAU;CACpD,IAAI,aAAa,KAAK,GAAG,OAAO;CAChC,IAAI;EACF,OAAO,mBAAmB,KAAK,MAAM,QAAQ,CAAC;CAChD,QAAQ;EACN,OAAO;CACT;AACF;AACA,SAAS,4BAA4B,YAAY,YAAY,UAAU;CACrE,IAAI,QAAQ;CACZ,MAAM,SAAS,SAAS;EACtB,IAAI,WAAW,KAAK,aAAa,KAAK,WAAW,KAAK,OAAO,GAAG;EAChE,IAAI,WAAW,oBAAoB,IAAI,KAAK,YAAY,KAAK,SAAS,UAAU,IAAI,KAAK,YAAY,KAAK,OAAO,IAAI,GAAG;GACtH,QAAQ;GACR;EACF;EACA,WAAW,aAAa,MAAM,KAAK;CACrC;CACA,MAAM,UAAU;CAChB,OAAO;AACT;AACA,SAAS,iBAAiB,YAAY,YAAY;CAChD,MAAM,yBAAyB,IAAI,IAAI;CACvC,KAAK,MAAM,aAAa,WAAW,YAAY;EAC7C,IAAI,CAAC,WAAW,oBAAoB,SAAS,KAAK,CAAC,WAAW,gBAAgB,UAAU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ACA,SACA,QACF;EACA,IAAI,CAAC,MAAM,OAAO,iBAAiB;EACnC,MAAM,QAAQ,QAAQ,MAAM,KAAK,UAAU,KAAK,OAAO,WAAW,KAAK,YAAY;EACnF,IAAI,CAAC,OAAO,OAAO,iBAAiB;EACpC,OAAO;GACL,MAAM,WAAW,kBAAkB;GACnC,eAAe;GACf,UAAU;IACR,OAAO,KAAK,eAAe,MAAM;IACjC,QAAQ,MAAM,MAAM,MAAM;GAC5B;GACA,cAAc,CAAC;IAAE,MAAM,MAAM;IAAM,MAAM;GAAgB,CAAC;GAC1D,eAAe,CAAC;IAAE,MAAM,MAAM;IAAU,MAAM;GAAO,CAAC;EACxD;CACF;CACA,MAAM,gBAAgB;EACpB,QAAQ,MAAM;EACd,YAAY;CACd;CACA,OAAO;AACT,EACF;AACA,IAAI,gBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { isAbsolute, resolve } from \"path\";\nimport { completionSortText, createStyleTooling } from \"./core\";\nimport { resolveTamaguiHost } from \"./host\";\nvar completionSource = \"@tamagui/language-service\";\nvar diagnosticCode = 78711;\nvar defaultConfigPath = \".tamagui/tamagui.config.json\";\nvar flatStyledModules = /* @__PURE__ */ new Set([\n \"tamagui\",\n \"tamagui/unstyled\",\n \"@tamagui/core\",\n \"@tamagui/ui\",\n \"@tamagui/web\"\n]);\nfunction loadTooling(info, configPath) {\n var contents = info.serverHost.readFile(configPath);\n if (contents === void 0) return null;\n try {\n return createStyleTooling(JSON.parse(contents));\n } catch (e) {\n return null;\n }\n}\nfunction findStringLiteralAtPosition(typescript, sourceFile, position) {\n var found = null;\n var visit = function(node) {\n if (position < node.getFullStart() || position > node.getEnd()) return;\n if (typescript.isStringLiteralLike(node) && position >= node.getStart(sourceFile) + 1 && position <= node.getEnd() - 1) {\n found = node;\n return;\n }\n typescript.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n}\nfunction importedBindings(typescript, sourceFile) {\n var styled = /* @__PURE__ */ new Set();\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = sourceFile.statements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var statement = _step.value;\n var _statement_importClause;\n if (!typescript.isImportDeclaration(statement) || !typescript.isStringLiteral(statement.moduleSpecifier)) {\n continue;\n }\n var source = statement.moduleSpecifier.text;\n if (!flatStyledModules.has(source)) continue;\n var bindings = (_statement_importClause = statement.importClause) === null || _statement_importClause === void 0 ? void 0 : _statement_importClause.namedBindings;\n if (!bindings) continue;\n if (typescript.isNamespaceImport(bindings)) continue;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = bindings.elements[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var element = _step1.value;\n var _element_propertyName;\n var imported = ((_element_propertyName = element.propertyName) === null || _element_propertyName === void 0 ? void 0 : _element_propertyName.text) || element.name.text;\n if (imported === \"styled\") styled.add(element.name.text);\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return {\n styled\n };\n}\nfunction propertyName(typescript, name) {\n if (typescript.isIdentifier(name) || typescript.isStringLiteral(name)) {\n return name.text;\n }\n return null;\n}\nfunction completionProperty(typescript, literal, tooling, checker, bindings) {\n var parent = literal.parent;\n if (typescript.isJsxExpression(parent)) parent = parent.parent;\n if (typescript.isJsxAttribute(parent)) {\n if (!typescript.isIdentifier(parent.name)) return null;\n var property = parent.name.text;\n if (!tooling.styleProps.has(property)) return null;\n var opening = parent.parent.parent;\n if (!typescript.isJsxOpeningLikeElement(opening)) return null;\n var host = resolveTamaguiHost(checker, opening.tagName);\n if (!(host === null || host === void 0 ? void 0 : host.accepts(property))) return null;\n return {\n property\n };\n }\n if (!typescript.isPropertyAssignment(parent)) return null;\n var property1 = propertyName(typescript, parent.name);\n if (!property1 || !tooling.styleProps.has(property1)) return null;\n var current = parent;\n while (current.parent && !typescript.isCallExpression(current.parent)) {\n current = current.parent;\n }\n if (!current.parent || !typescript.isCallExpression(current.parent)) return null;\n var call = current.parent;\n if (call.arguments[1] !== current || !typescript.isIdentifier(call.expression) || !bindings.styled.has(call.expression.text)) {\n return null;\n }\n var component = call.arguments[0];\n var host1 = component && resolveTamaguiHost(checker, component);\n if (!(host1 === null || host1 === void 0 ? void 0 : host1.accepts(property1))) return null;\n return {\n property: property1\n };\n}\nfunction siteForLiteral(typescript, sourceFile, literal, tooling, checker, bindings) {\n var site = completionProperty(typescript, literal, tooling, checker, bindings);\n if (!site) return null;\n var contentStart = literal.getStart(sourceFile) + 1;\n var contentEnd = literal.getEnd() - 1;\n var sourceInput = sourceFile.text.slice(contentStart, contentEnd);\n if (literal.text !== sourceInput) return null;\n return {\n property: site.property,\n value: literal.text,\n contentStart,\n literal\n };\n}\nfunction collectLiteralSites(typescript, sourceFile, tooling, checker, bindings) {\n var sites = [];\n var visit = function(node) {\n if (typescript.isStringLiteralLike(node)) {\n var site = siteForLiteral(typescript, sourceFile, node, tooling, checker, bindings);\n if (site) sites.push(site);\n return;\n }\n typescript.forEachChild(node, visit);\n };\n visit(sourceFile);\n return sites;\n}\nfunction copyLanguageService(service) {\n var proxy = /* @__PURE__ */ Object.create(null);\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.keys(service)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n var value = service[key];\n proxy[key] = typeof value === \"function\" ? value.bind(service) : value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return proxy;\n}\nvar init = function(param) {\n var { typescript } = param;\n return {\n create(info) {\n var pluginConfig = info.config;\n var configuredPath = (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.configPath) || defaultConfigPath;\n var configPath = isAbsolute(configuredPath) ? configuredPath : resolve(info.project.getCurrentDirectory(), configuredPath);\n var tooling = loadTooling(info, configPath);\n var watcher = info.serverHost.watchFile(configPath, function() {\n tooling = loadTooling(info, configPath);\n });\n var proxy = copyLanguageService(info.languageService);\n var baseCompletions = info.languageService.getCompletionsAtPosition.bind(info.languageService);\n var baseDetails = info.languageService.getCompletionEntryDetails.bind(info.languageService);\n var baseSemanticDiagnostics = info.languageService.getSemanticDiagnostics.bind(info.languageService);\n var baseQuickInfo = info.languageService.getQuickInfoAtPosition.bind(info.languageService);\n var baseDispose = info.languageService.dispose.bind(info.languageService);\n var bindingsBySourceFile = /* @__PURE__ */ new WeakMap();\n var fileContext = function(fileName) {\n var program = info.languageService.getProgram();\n var sourceFile = program === null || program === void 0 ? void 0 : program.getSourceFile(fileName);\n if (!program || !sourceFile) return null;\n var bindings = bindingsBySourceFile.get(sourceFile);\n if (!bindings) {\n bindings = importedBindings(typescript, sourceFile);\n bindingsBySourceFile.set(sourceFile, bindings);\n }\n return {\n sourceFile,\n checker: program.getTypeChecker(),\n bindings\n };\n };\n proxy.getCompletionsAtPosition = function(fileName, position, options, formattingSettings) {\n var getBaseCompletions = function() {\n return baseCompletions(fileName, position, options, formattingSettings);\n };\n if (!tooling) return getBaseCompletions();\n var context = fileContext(fileName);\n if (!context) return getBaseCompletions();\n var { sourceFile, checker, bindings } = context;\n var literal = findStringLiteralAtPosition(typescript, sourceFile, position);\n if (!literal) return getBaseCompletions();\n var site = siteForLiteral(typescript, sourceFile, literal, tooling, checker, bindings);\n if (!site) return getBaseCompletions();\n var cursorCompletions = tooling.completions(site.property, site.value, position - site.contentStart);\n if (!cursorCompletions) return getBaseCompletions();\n var replacementSpan = {\n start: site.contentStart + cursorCompletions.replaceStart,\n length: cursorCompletions.replaceLength\n };\n var entries = [];\n var contextualType;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = cursorCompletions.completions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var completion = _step.value;\n var insertText = completion.insertText || completion.value;\n var modifierKind = completion.kind === \"modifier\" ? tooling.modifierKind(completion.value) : void 0;\n if (completion.kind === \"keyword\") {\n contextualType || (contextualType = checker.getContextualType(literal));\n if (!contextualType || !checker.isTypeAssignableTo(checker.getStringLiteralType(insertText), contextualType)) {\n continue;\n }\n }\n entries.push({\n name: completion.value,\n kind: typescript.ScriptElementKind.string,\n kindModifiers: \"\",\n sortText: completionSortText(completion, modifierKind),\n insertText,\n replacementSpan,\n source: completionSource,\n labelDetails: {\n description: modifierKind ? `Tamagui ${modifierKind} modifier` : completion.kind === \"configured\" ? \"Tamagui configured value\" : \"Tamagui style keyword\"\n }\n });\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (entries.length === 0) return getBaseCompletions();\n return {\n isGlobalCompletion: false,\n isMemberCompletion: false,\n isNewIdentifierLocation: true,\n // A completion requested immediately after whitespace has an empty\n // replacement span. Ask the editor to request again as the modifier\n // prefix grows instead of dismissing suggestions when the cursor\n // moves beyond that initial span.\n isIncomplete: true,\n entries\n };\n };\n proxy.getCompletionEntryDetails = function(fileName, position, entryName, formatOptions, source, preferences, data) {\n if (source === completionSource) {\n return {\n name: entryName,\n kind: typescript.ScriptElementKind.string,\n kindModifiers: \"\",\n displayParts: [\n {\n text: entryName,\n kind: \"stringLiteral\"\n }\n ],\n documentation: [\n {\n text: \"Resolved from the active Tamagui config.\",\n kind: \"text\"\n }\n ],\n tags: []\n };\n }\n return baseDetails(fileName, position, entryName, formatOptions, source, preferences, data);\n };\n proxy.getSemanticDiagnostics = function(fileName) {\n var diagnostics = [\n ...baseSemanticDiagnostics(fileName)\n ];\n if (!tooling) return diagnostics;\n var context = fileContext(fileName);\n if (!context) return diagnostics;\n var { sourceFile, checker, bindings } = context;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = collectLiteralSites(typescript, sourceFile, tooling, checker, bindings)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var site = _step.value;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = tooling.diagnostics(site.property, site.value)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var diagnostic = _step1.value;\n diagnostics.push({\n file: sourceFile,\n start: site.contentStart + diagnostic.start,\n length: Math.max(1, diagnostic.end - diagnostic.start),\n messageText: diagnostic.message,\n category: typescript.DiagnosticCategory.Error,\n code: diagnosticCode,\n source: completionSource\n });\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return diagnostics;\n };\n proxy.getQuickInfoAtPosition = function(fileName, position) {\n var getBaseQuickInfo = function() {\n return baseQuickInfo(fileName, position);\n };\n if (!tooling) return getBaseQuickInfo();\n var context = fileContext(fileName);\n if (!context) return getBaseQuickInfo();\n var { sourceFile, checker, bindings } = context;\n var literal = findStringLiteralAtPosition(typescript, sourceFile, position);\n if (!literal) return getBaseQuickInfo();\n var site = siteForLiteral(typescript, sourceFile, literal, tooling, checker, bindings);\n if (!site) return getBaseQuickInfo();\n var hover = tooling.hover(site.property, site.value, position - site.contentStart);\n if (!hover) return getBaseQuickInfo();\n return {\n kind: typescript.ScriptElementKind.string,\n kindModifiers: \"\",\n textSpan: {\n start: site.contentStart + hover.start,\n length: hover.end - hover.start\n },\n displayParts: [\n {\n text: hover.text,\n kind: \"stringLiteral\"\n }\n ],\n documentation: [\n {\n text: hover.markdown,\n kind: \"text\"\n }\n ]\n };\n };\n proxy.dispose = function() {\n watcher.close();\n baseDispose();\n };\n return proxy;\n }\n };\n};\nvar index_default = init;\nexport {\n index_default as default\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;AAGA,IAAI,mBAAmB;AACvB,IAAI,iBAAiB;AACrB,IAAI,oBAAoB;AACxB,IAAI,oCAAoC,IAAI,IAAI;CAC9C;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,SAAS,YAAY,MAAM,YAAY;CACrC,IAAI,WAAW,KAAK,WAAW,SAAS,UAAU;CAClD,IAAI,aAAa,KAAK,GAAG,OAAO;CAChC,IAAI;EACF,OAAO,mBAAmB,KAAK,MAAM,QAAQ,CAAC;CAChD,SAAS,GAAG;EACV,OAAO;CACT;AACF;AACA,SAAS,4BAA4B,YAAY,YAAY,UAAU;CACrE,IAAI,QAAQ;CACZ,IAAI,QAAQ,SAAS,MAAM;EACzB,IAAI,WAAW,KAAK,aAAa,KAAK,WAAW,KAAK,OAAO,GAAG;EAChE,I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@@
|
|
|
1
|
-
module.exports = require('./dist/cjs/index.cjs').default
|
package/src/host.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { HostView } from '@tamagui/style-grammar/tooling'
|
|
2
|
-
import type ts from 'typescript'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* resolves the style-prop surface TypeScript assigns to a Tamagui component.
|
|
6
|
-
* the staticConfig marker distinguishes Tamagui hosts from unrelated React
|
|
7
|
-
* components, while the call signatures retain styled component prop types.
|
|
8
|
-
*/
|
|
9
|
-
export function resolveTamaguiHost(
|
|
10
|
-
checker: ts.TypeChecker,
|
|
11
|
-
component: ts.Node
|
|
12
|
-
): HostView | undefined {
|
|
13
|
-
const componentType = checker.getTypeAtLocation(component)
|
|
14
|
-
if (!checker.getPropertyOfType(componentType, 'staticConfig')) return undefined
|
|
15
|
-
|
|
16
|
-
const propsTypes: ts.Type[] = []
|
|
17
|
-
for (const signature of componentType.getCallSignatures()) {
|
|
18
|
-
const props = signature.getParameters()[0]
|
|
19
|
-
if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component))
|
|
20
|
-
}
|
|
21
|
-
if (propsTypes.length === 0) return undefined
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
displayName: component.getText(),
|
|
25
|
-
accepts: (property) =>
|
|
26
|
-
propsTypes.some(
|
|
27
|
-
(propsType) =>
|
|
28
|
-
checker.getPropertyOfType(checker.getApparentType(propsType), property) !==
|
|
29
|
-
undefined
|
|
30
|
-
),
|
|
31
|
-
}
|
|
32
|
-
}
|
package/types/host.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { HostView } from "@tamagui/style-grammar/tooling";
|
|
2
|
-
import type ts from "typescript";
|
|
3
|
-
/**
|
|
4
|
-
* resolves the style-prop surface TypeScript assigns to a Tamagui component.
|
|
5
|
-
* the staticConfig marker distinguishes Tamagui hosts from unrelated React
|
|
6
|
-
* components, while the call signatures retain styled component prop types.
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveTamaguiHost(checker: ts.TypeChecker, component: ts.Node): HostView | undefined;
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=host.d.ts.map
|
package/types/host.d.ts.map
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAAA,cAAc,gBAAgB;AAC9B,YAAY,QAAQ;;;;;;AAOpB,OAAO,iBAAS,mBACd,SAAS,GAAG,aACZ,WAAW,GAAG,OACb",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/host.ts"
|
|
6
|
-
],
|
|
7
|
-
"version": 3,
|
|
8
|
-
"sourcesContent": [
|
|
9
|
-
"import type { HostView } from '@tamagui/style-grammar/tooling'\nimport type ts from 'typescript'\n\n/**\n * resolves the style-prop surface TypeScript assigns to a Tamagui component.\n * the staticConfig marker distinguishes Tamagui hosts from unrelated React\n * components, while the call signatures retain styled component prop types.\n */\nexport function resolveTamaguiHost(\n checker: ts.TypeChecker,\n component: ts.Node\n): HostView | undefined {\n const componentType = checker.getTypeAtLocation(component)\n if (!checker.getPropertyOfType(componentType, 'staticConfig')) return undefined\n\n const propsTypes: ts.Type[] = []\n for (const signature of componentType.getCallSignatures()) {\n const props = signature.getParameters()[0]\n if (props) propsTypes.push(checker.getTypeOfSymbolAtLocation(props, component))\n }\n if (propsTypes.length === 0) return undefined\n\n return {\n displayName: component.getText(),\n accepts: (property) =>\n propsTypes.some(\n (propsType) =>\n checker.getPropertyOfType(checker.getApparentType(propsType), property) !==\n undefined\n ),\n }\n}\n"
|
|
10
|
-
]
|
|
11
|
-
}
|