@abide/abide 0.41.1 → 0.42.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.
Files changed (32) hide show
  1. package/AGENTS.md +19 -13
  2. package/CHANGELOG.md +48 -0
  3. package/README.md +13 -14
  4. package/package.json +1 -1
  5. package/src/abideLsp.ts +46 -8
  6. package/src/abideResolverPlugin.ts +3 -5
  7. package/src/lib/server/runtime/devClientFingerprint.ts +2 -1
  8. package/src/lib/shared/escapeRegex.ts +9 -0
  9. package/src/lib/shared/fileName.ts +9 -0
  10. package/src/lib/shared/fileStem.ts +3 -1
  11. package/src/lib/shared/programNameForPackage.ts +3 -1
  12. package/src/lib/shared/stripImport.ts +3 -1
  13. package/src/lib/ui/compile/ABIDE_SEMANTIC_TOKENS_LEGEND.ts +45 -0
  14. package/src/lib/ui/compile/abideUiPlugin.ts +2 -1
  15. package/src/lib/ui/compile/compileShadow.ts +42 -10
  16. package/src/lib/ui/compile/createShadowLanguageService.ts +48 -0
  17. package/src/lib/ui/compile/encodeSemanticTokens.ts +37 -0
  18. package/src/lib/ui/compile/generateBuild.ts +2 -2
  19. package/src/lib/ui/compile/generateSSR.ts +6 -6
  20. package/src/lib/ui/compile/makeVarNamer.ts +10 -0
  21. package/src/lib/ui/compile/offsetToPosition.ts +9 -0
  22. package/src/lib/ui/compile/parseTemplate.ts +524 -104
  23. package/src/lib/ui/compile/structuralBlockTokens.ts +101 -0
  24. package/src/lib/ui/compile/types/SemanticToken.ts +11 -0
  25. package/src/lib/ui/compile/types/TemplateNode.ts +9 -0
  26. package/src/lib/ui/dom/appendText.ts +1 -5
  27. package/src/lib/ui/dom/applyResolved.ts +1 -5
  28. package/src/lib/ui/dom/isComment.ts +6 -0
  29. package/src/lib/ui/runtime/createDoc.ts +3 -3
  30. package/src/lib/ui/runtime/pathSegments.ts +10 -0
  31. package/template/.zed/settings.json +4 -0
  32. package/template/src/ui/pages/page.abide +4 -4
@@ -10,6 +10,7 @@ import { groupBindParts } from './groupBindParts.ts'
10
10
  import { isControlFlow } from './isControlFlow.ts'
11
11
  import { isWhitespaceText } from './isWhitespaceText.ts'
12
12
  import { lowerContext } from './lowerContext.ts'
13
+ import { makeVarNamer } from './makeVarNamer.ts'
13
14
  import { resolveBranches } from './resolveBranches.ts'
14
15
  import { scopeAttr } from './scopeAttr.ts'
15
16
  import { skeletonContext } from './skeletonContext.ts'
@@ -61,8 +62,7 @@ export function generateBuild(
61
62
  computedNames: ReadonlySet<string>,
62
63
  isLayout = false,
63
64
  ): string {
64
- let counter = 0
65
- const nextVar = (prefix: string): string => `${prefix}${counter++}`
65
+ const nextVar = makeVarNamer()
66
66
 
67
67
  /* In a layout, `<slot/>` outlets are rewritten to `OUTLET_TAG` elements up front
68
68
  (`asOutlet`) so the static-clone path carries them as ordinary structure. `asOutlet`
@@ -1,4 +1,5 @@
1
1
  import { assertExhaustive } from '../../shared/assertExhaustive.ts'
2
+ import { escapeRegex } from '../../shared/escapeRegex.ts'
2
3
  import { OUTLET_CLOSE, OUTLET_OPEN } from '../runtime/OUTLET_MARKER.ts'
3
4
  import { OUTLET_TAG } from '../runtime/OUTLET_TAG.ts'
4
5
  import {
@@ -11,6 +12,7 @@ import { composeProps } from './composeProps.ts'
11
12
  import { groupBindParts } from './groupBindParts.ts'
12
13
  import { isAnchorPositioned } from './isAnchorPositioned.ts'
13
14
  import { lowerContext } from './lowerContext.ts'
15
+ import { makeVarNamer } from './makeVarNamer.ts'
14
16
  import { resolveBranches } from './resolveBranches.ts'
15
17
  import { scopeAttr } from './scopeAttr.ts'
16
18
  import { skeletonContext } from './skeletonContext.ts'
@@ -55,10 +57,9 @@ export function generateSSR(
55
57
  computedNames: ReadonlySet<string>,
56
58
  isLayout = false,
57
59
  ): string {
58
- /* Compile-time counter for unique temp var names (runtime block ids, child render
59
- results) block ids themselves are allocated at runtime via `$ctx.next++`. */
60
- let varCounter = 0
61
- const nextVar = (prefix: string): string => `${prefix}${varCounter++}`
60
+ /* Unique temp var names (child render results); runtime block ids are
61
+ allocated separately at runtime via `$ctx.next++`. */
62
+ const nextVar = makeVarNamer()
62
63
 
63
64
  /* The shared signal→`model` lowering + branch-scoped nested-script deref scope. */
64
65
  const {
@@ -90,13 +91,12 @@ export function generateSSR(
90
91
  regex metacharacters escaped, or e.g. a trailing `$` would read as an end-anchor and the
91
92
  call site would never match — leaving an un-awaited Promise stringified as `[object
92
93
  Promise]`. */
93
- const escapeRegExp = (text: string): string => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
94
94
  /* A leading boundary that, unlike `\b`, also fires before a `$`-leading name: `\b$row`
95
95
  never matches (`$` is a non-word char, so there is no word boundary before it), which
96
96
  would silently miss every `$row(...)` call. A negative lookbehind for word-or-`$`
97
97
  matches the same call sites as `\b` for word-leading names while also catching them. */
98
98
  const callPattern = (name: string): RegExp =>
99
- new RegExp(`(?<![$\\w])${escapeRegExp(name)}\\s*\\(`)
99
+ new RegExp(`(?<![$\\w])${escapeRegex(name)}\\s*\\(`)
100
100
  /* A subtree call to any of `names` from a TEXT interpolation (`name()` / `name(args)`). */
101
101
  const subtreeCalls = (children: TemplateNode[], names: ReadonlySet<string>): boolean =>
102
102
  children.some((child) => {
@@ -0,0 +1,10 @@
1
+ /*
2
+ Compile-time generator of unique temp var names: each call appends a fresh
3
+ incrementing suffix to `prefix` (`row` → `row0`, `row1`, …). Shared by the
4
+ generateSSR / generateBuild codegen passes so the two hand-mirrored traversals
5
+ allocate names one way. Runtime block ids stay separate (`$ctx.next++`).
6
+ */
7
+ export function makeVarNamer(): (prefix: string) => string {
8
+ let counter = 0
9
+ return (prefix: string): string => `${prefix}${counter++}`
10
+ }
@@ -0,0 +1,9 @@
1
+ /* An absolute offset → LSP `{ line, character }` (0-based, UTF-16 code units). */
2
+ export function offsetToPosition(
3
+ text: string,
4
+ offset: number,
5
+ ): { line: number; character: number } {
6
+ const before = text.slice(0, offset)
7
+ const line = before.split('\n').length - 1
8
+ return { line, character: offset - (before.lastIndexOf('\n') + 1) }
9
+ }