@aliens-syndicate/cli 0.0.0-stage → 0.1.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 (81) hide show
  1. package/README.md +215 -2
  2. package/package.json +29 -4
  3. package/tools/build.mjs +607 -0
  4. package/tools/cli.mjs +39 -0
  5. package/tools/create.mjs +102 -0
  6. package/tools/project-layout.mjs +41 -0
  7. package/tools/runtime.mjs +294 -0
  8. package/tools/starter/app/animations/hero-enter.animation +8 -0
  9. package/tools/starter/app/apis/hero.api +9 -0
  10. package/tools/starter/app/directives/hero-highlight.directive +8 -0
  11. package/tools/starter/app/elements/atoms/kit-nav-link/kit-nav-link.markup +2 -0
  12. package/tools/starter/app/elements/molecules/hero-card/hero-card.logic +15 -0
  13. package/tools/starter/app/elements/molecules/hero-card/hero-card.markup +8 -0
  14. package/tools/starter/app/elements/molecules/hero-card/hero-card.style +12 -0
  15. package/tools/starter/app/elements/molecules/hero-card/hero-card.test +8 -0
  16. package/tools/starter/app/elements/molecules/kit-button-demo/kit-button-demo.logic +14 -0
  17. package/tools/starter/app/elements/molecules/kit-button-demo/kit-button-demo.markup +8 -0
  18. package/tools/starter/app/elements/molecules/kit-card-link/kit-card-link.markup +6 -0
  19. package/tools/starter/app/elements/organisms/kit-navigation/kit-navigation.markup +19 -0
  20. package/tools/starter/app/enums/hero-status.enum +7 -0
  21. package/tools/starter/app/errors/hero-not-found.error +7 -0
  22. package/tools/starter/app/guards/hero-editor.guard +8 -0
  23. package/tools/starter/app/interceptors/hero-request.interceptor +8 -0
  24. package/tools/starter/app/interfaces/hero.interface +8 -0
  25. package/tools/starter/app/mocks/hero.mock +8 -0
  26. package/tools/starter/app/models/hero.model +8 -0
  27. package/tools/starter/app/pages/kit-border/kit-border.markup +38 -0
  28. package/tools/starter/app/pages/kit-color/kit-color.markup +58 -0
  29. package/tools/starter/app/pages/kit-components/kit-components.markup +95 -0
  30. package/tools/starter/app/pages/kit-overview/kit-overview.markup +25 -0
  31. package/tools/starter/app/pages/kit-radius/kit-radius.markup +34 -0
  32. package/tools/starter/app/pages/kit-space/kit-space.markup +61 -0
  33. package/tools/starter/app/pages/kit-type/kit-type.markup +48 -0
  34. package/tools/starter/app/pages/style-guide/style-guide.markup +10 -0
  35. package/tools/starter/app/pages/style-guide/style-guide.style +252 -0
  36. package/tools/starter/app/pipes/hero-label.pipe +6 -0
  37. package/tools/starter/app/routes/hero-archive.route +8 -0
  38. package/tools/starter/app/routes/hero-detail.route +11 -0
  39. package/tools/starter/app/routes/hero-edit.route +14 -0
  40. package/tools/starter/app/routes/hero-filter.route +14 -0
  41. package/tools/starter/app/routes/hero-list.route +9 -0
  42. package/tools/starter/app/routes/hero-not-found.route +7 -0
  43. package/tools/starter/app/routes/hero-preview.route +11 -0
  44. package/tools/starter/app/routes/hero-redirect.route +8 -0
  45. package/tools/starter/app/routes/hero-search.route +15 -0
  46. package/tools/starter/app/routes/hero-tabs.route +17 -0
  47. package/tools/starter/app/routes/hero-team.route +11 -0
  48. package/tools/starter/app/services/hero-roster.service +8 -0
  49. package/tools/starter/app/storage/hero-favorite.storage +8 -0
  50. package/tools/starter/app/validators/hero-energy.validator +8 -0
  51. package/tools/starter/language/.en-US +73 -0
  52. package/tools/starter/language/.es-ES +73 -0
  53. package/tools/starter/language/.pt-BR +73 -0
  54. package/tools/starter/language/.zh-CN +73 -0
  55. package/tools/starter/styles/components/alerts.style +16 -0
  56. package/tools/starter/styles/components/badges.style +18 -0
  57. package/tools/starter/styles/components/borders.style +11 -0
  58. package/tools/starter/styles/components/buttons.style +34 -0
  59. package/tools/starter/styles/components/cards.style +9 -0
  60. package/tools/starter/styles/components/feedback.style +21 -0
  61. package/tools/starter/styles/components/forms.style +38 -0
  62. package/tools/starter/styles/components/spacing.style +13 -0
  63. package/tools/starter/styles/components/tables.style +17 -0
  64. package/tools/starter/styles/components/typography.style +51 -0
  65. package/tools/starter/styles/generic/ui-base.style +12 -0
  66. package/tools/starter/styles/objects/ui-layout.style +13 -0
  67. package/tools/starter/styles/settings/border-tokens.style +9 -0
  68. package/tools/starter/styles/settings/color-tokens.style +40 -0
  69. package/tools/starter/styles/settings/elevation-tokens.style +8 -0
  70. package/tools/starter/styles/settings/radius-tokens.style +8 -0
  71. package/tools/starter/styles/settings/space-tokens.style +11 -0
  72. package/tools/starter/styles/settings/theme.style +52 -0
  73. package/tools/starter/styles/settings/type-tokens.style +18 -0
  74. package/tools/vscode-space/extension.cjs +56 -0
  75. package/tools/vscode-space/language-configuration.json +9 -0
  76. package/tools/vscode-space/package.json +129 -0
  77. package/tools/vscode-space/space.tmLanguage.json +32 -0
  78. package/tools/vscode-space/style-colors.cjs +69 -0
  79. package/tools/vscode-space/syntax.cjs +122 -0
  80. package/tools/vscode-space/vendor/color-name.LICENSE +8 -0
  81. package/tools/vscode-space/vendor/color-name.cjs +152 -0
@@ -0,0 +1,51 @@
1
+ Style Typography
2
+ space-h1, space-h2, space-h3, space-h4, space-h5, space-h6
3
+ margin: 0
4
+ font-family: var(--font-sans)
5
+ font-weight: var(--weight-bold)
6
+ line-height: var(--line-heading)
7
+ letter-spacing: -.035em
8
+ overflow-wrap: anywhere
9
+ space-h1
10
+ font-size: var(--text-h1)
11
+ space-h2
12
+ font-size: var(--text-h2)
13
+ space-h3
14
+ font-size: var(--text-h3)
15
+ space-h4
16
+ font-size: var(--text-h4)
17
+ space-h5
18
+ font-size: var(--text-h5)
19
+ space-h6
20
+ font-size: var(--text-h6)
21
+ space-body
22
+ margin: 0
23
+ font-size: var(--text-body)
24
+ line-height: var(--line-body)
25
+ space-small
26
+ font-size: var(--text-small)
27
+ space-caption
28
+ font-size: var(--text-caption)
29
+ color: var(--color-muted)
30
+ space-link
31
+ color: var(--color-focus)
32
+ text-decoration: underline
33
+ text-underline-offset: .16em
34
+ space-code-inline, space-key
35
+ padding: .12em .35em
36
+ border-radius: var(--radius-sm)
37
+ background: var(--color-surface)
38
+ font: .88em var(--font-mono)
39
+ overflow-wrap: anywhere
40
+ space-key
41
+ border: var(--border-subtle)
42
+ space-quote
43
+ margin: 0
44
+ padding-inline-start: var(--space-4)
45
+ border-inline-start: var(--border-strong)
46
+ color: var(--color-muted)
47
+ space-list
48
+ margin: 0
49
+ padding-inline-start: var(--space-5)
50
+ space-list li + li
51
+ margin-block-start: var(--space-1)
@@ -0,0 +1,12 @@
1
+ Style UiBase
2
+ body:has(> style-guide)
3
+ margin: 0
4
+ background: var(--color-canvas)
5
+ :where(style-guide, style-guide *)
6
+ box-sizing: border-box
7
+ style-guide
8
+ font-family: var(--font-sans)
9
+ line-height: var(--line-body)
10
+ color: var(--color-text)
11
+ style-guide [hidden]
12
+ display: none !important
@@ -0,0 +1,13 @@
1
+ Style UiLayout
2
+ space-stack
3
+ display: grid
4
+ gap: var(--space-4)
5
+ space-cluster
6
+ display: flex
7
+ flex-wrap: wrap
8
+ align-items: center
9
+ gap: var(--space-2)
10
+ space-grid
11
+ display: grid
12
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr))
13
+ gap: var(--space-4)
@@ -0,0 +1,9 @@
1
+ Style BorderTokens
2
+ :root
3
+ --border-width-sm: 1px
4
+ --border-width-md: 2px
5
+ --border-width-lg: 4px
6
+ --border-subtle: var(--border-width-sm) solid var(--color-outline)
7
+ --border-strong: var(--border-width-md) solid var(--color-outline-strong)
8
+ --border-dashed: var(--border-width-sm) dashed var(--color-outline-strong)
9
+ --border-focus: var(--border-width-md) solid var(--color-focus)
@@ -0,0 +1,40 @@
1
+ Style ColorTokens
2
+ :root
3
+ --palette-white: #ffffff
4
+ --palette-black: #000000
5
+ --palette-neutral-50: #f6f8f3
6
+ --palette-neutral-100: #f2f7ef
7
+ --palette-neutral-200: #d5ddd1
8
+ --palette-neutral-300: #b8c4b3
9
+ --palette-neutral-450: #8c9b84
10
+ --palette-neutral-500: #71816a
11
+ --palette-neutral-650: #52604e
12
+ --palette-neutral-750: #394434
13
+ --palette-neutral-900: #182015
14
+ --palette-neutral-950: #141a12
15
+ --palette-green-100: #e7f4d3
16
+ --palette-green-150: #e0ffba
17
+ --palette-green-200: #dcff9c
18
+ --palette-green-250: #c5fa78
19
+ --palette-green-600: #3e6b23
20
+ --palette-green-700: #315724
21
+ --palette-green-800: #26461b
22
+ --palette-green-850: #25411c
23
+ --palette-green-900: #23341b
24
+ --palette-green-950: #17210d
25
+ --palette-mint-50: #e5f6ed
26
+ --palette-mint-250: #8ae4ae
27
+ --palette-mint-750: #17643d
28
+ --palette-mint-950: #10271c
29
+ --palette-amber-50: #fff3d2
30
+ --palette-amber-250: #ffd484
31
+ --palette-amber-750: #795000
32
+ --palette-amber-950: #33260f
33
+ --palette-rose-50: #fcebef
34
+ --palette-rose-250: #ff9aaa
35
+ --palette-rose-750: #a5243a
36
+ --palette-rose-950: #361820
37
+ --palette-blue-50: #eaf2fc
38
+ --palette-blue-250: #9ccfff
39
+ --palette-blue-750: #1d5686
40
+ --palette-blue-950: #14283b
@@ -0,0 +1,8 @@
1
+ Style ElevationTokens
2
+ :root
3
+ --shadow-light-sm: 0 1px 2px #16341314
4
+ --shadow-light-md: 0 7px 24px #16341321
5
+ --shadow-light-lg: 0 18px 46px #16341330
6
+ --shadow-dark-sm: 0 1px 2px #0008
7
+ --shadow-dark-md: 0 7px 24px #000a
8
+ --shadow-dark-lg: 0 18px 46px #000c
@@ -0,0 +1,8 @@
1
+ Style RadiusTokens
2
+ :root
3
+ --radius-none: 0
4
+ --radius-sm: .25rem
5
+ --radius-md: .5rem
6
+ --radius-lg: .75rem
7
+ --radius-xl: 1rem
8
+ --radius-pill: 9999px
@@ -0,0 +1,11 @@
1
+ Style SpaceTokens
2
+ :root
3
+ --space-0: 0
4
+ --space-1: .25rem
5
+ --space-2: .5rem
6
+ --space-3: .75rem
7
+ --space-4: 1rem
8
+ --space-5: 1.5rem
9
+ --space-6: 2rem
10
+ --space-7: 3rem
11
+ --space-8: 4rem
@@ -0,0 +1,52 @@
1
+ Style Theme
2
+ # Add a :root[data-theme="your-theme"] block to offer another theme in the selector.
3
+ :root, :root[data-theme="light"]
4
+ color-scheme: light
5
+ --color-canvas: var(--palette-white)
6
+ --color-surface: var(--palette-neutral-50)
7
+ --color-text: var(--palette-neutral-900)
8
+ --color-muted: var(--palette-neutral-650)
9
+ --color-outline: var(--palette-neutral-200)
10
+ --color-outline-strong: var(--palette-neutral-500)
11
+ --color-brand: var(--palette-green-700)
12
+ --color-brand-hover: var(--palette-green-800)
13
+ --color-on-brand: var(--palette-white)
14
+ --color-focus: var(--palette-green-600)
15
+ --color-accent: var(--palette-green-100)
16
+ --color-on-accent: var(--palette-green-850)
17
+ --color-success: var(--palette-mint-750)
18
+ --color-success-bg: var(--palette-mint-50)
19
+ --color-warning: var(--palette-amber-750)
20
+ --color-warning-bg: var(--palette-amber-50)
21
+ --color-danger: var(--palette-rose-750)
22
+ --color-danger-bg: var(--palette-rose-50)
23
+ --color-info: var(--palette-blue-750)
24
+ --color-info-bg: var(--palette-blue-50)
25
+ --shadow-sm: var(--shadow-light-sm)
26
+ --shadow-md: var(--shadow-light-md)
27
+ --shadow-lg: var(--shadow-light-lg)
28
+ :root[data-theme="dark"]
29
+ color-scheme: dark
30
+ --color-canvas: var(--palette-black)
31
+ --color-surface: var(--palette-neutral-950)
32
+ --color-text: var(--palette-neutral-100)
33
+ --color-muted: var(--palette-neutral-300)
34
+ --color-outline: var(--palette-neutral-750)
35
+ --color-outline-strong: var(--palette-neutral-450)
36
+ --color-brand: var(--palette-green-250)
37
+ --color-brand-hover: var(--palette-green-200)
38
+ --color-on-brand: var(--palette-green-950)
39
+ --color-focus: var(--palette-green-250)
40
+ --color-accent: var(--palette-green-900)
41
+ --color-on-accent: var(--palette-green-150)
42
+ --color-success: var(--palette-mint-250)
43
+ --color-success-bg: var(--palette-mint-950)
44
+ --color-warning: var(--palette-amber-250)
45
+ --color-warning-bg: var(--palette-amber-950)
46
+ --color-danger: var(--palette-rose-250)
47
+ --color-danger-bg: var(--palette-rose-950)
48
+ --color-info: var(--palette-blue-250)
49
+ --color-info-bg: var(--palette-blue-950)
50
+ --shadow-sm: var(--shadow-dark-sm)
51
+ --shadow-md: var(--shadow-dark-md)
52
+ --shadow-lg: var(--shadow-dark-lg)
@@ -0,0 +1,18 @@
1
+ Style TypeTokens
2
+ :root
3
+ --font-sans: "Geist", "Inter", system-ui, sans-serif
4
+ --font-mono: "IBM Plex Mono", ui-monospace, monospace
5
+ --text-h1: clamp(2.4rem, 6vw, 4rem)
6
+ --text-h2: clamp(2rem, 4vw, 2.85rem)
7
+ --text-h3: 1.65rem
8
+ --text-h4: 1.35rem
9
+ --text-h5: 1.15rem
10
+ --text-h6: 1rem
11
+ --text-body: 1rem
12
+ --text-small: .875rem
13
+ --text-caption: .75rem
14
+ --line-heading: 1.12
15
+ --line-body: 1.55
16
+ --weight-regular: 400
17
+ --weight-medium: 550
18
+ --weight-bold: 700
@@ -0,0 +1,56 @@
1
+ const { extname } = require('node:path').posix;
2
+ const vscode = require('vscode');
3
+ const { analyzeSpace, tokenTypes } = require('./syntax.cjs');
4
+
5
+ function colorRange(color) {
6
+ return new vscode.Range(color.line, color.start, color.line, color.start + color.length);
7
+ }
8
+
9
+ function colorText(color) {
10
+ const channels = [color.red, color.green, color.blue];
11
+ if (color.alpha !== 1) channels.push(color.alpha);
12
+ return '#' + channels.map(channel => Math.round(channel * 255).toString(16).padStart(2, '0')).join('');
13
+ }
14
+
15
+ function activate(context) {
16
+ const selector = { language: 'space' };
17
+ const legend = new vscode.SemanticTokensLegend(tokenTypes, ['declaration']);
18
+ const cache = new WeakMap();
19
+ function analyze(document) {
20
+ const existing = cache.get(document);
21
+ if (existing?.version === document.version) return existing.result;
22
+ const result = analyzeSpace(document.getText(), extname(document.uri.path).toLowerCase());
23
+ cache.set(document, { version: document.version, result });
24
+ return result;
25
+ }
26
+
27
+ context.subscriptions.push(
28
+ vscode.languages.registerDocumentSemanticTokensProvider(selector, {
29
+ provideDocumentSemanticTokens(document, cancellation) {
30
+ if (cancellation.isCancellationRequested) return;
31
+ const builder = new vscode.SemanticTokensBuilder(legend);
32
+ for (const token of analyze(document).tokens) {
33
+ const range = new vscode.Range(token.line, token.start, token.line, token.start + token.length);
34
+ builder.push(range, token.type, token.declaration ? ['declaration'] : []);
35
+ }
36
+ return builder.build();
37
+ }
38
+ }, legend),
39
+ vscode.languages.registerColorProvider({ ...selector, pattern: '**/*.style' }, {
40
+ provideDocumentColors(document, cancellation) {
41
+ if (cancellation.isCancellationRequested) return [];
42
+ return analyze(document).colors.map(color =>
43
+ new vscode.ColorInformation(colorRange(color), new vscode.Color(...color.rgba))
44
+ );
45
+ },
46
+ provideColorPresentations(color, context) {
47
+ const label = colorText(color);
48
+ const presentation = new vscode.ColorPresentation(label);
49
+ presentation.textEdit = vscode.TextEdit.replace(context.range, label);
50
+ return [presentation];
51
+ }
52
+ })
53
+ );
54
+ }
55
+
56
+ module.exports = { activate };
@@ -0,0 +1,9 @@
1
+ {
2
+ "comments": { "lineComment": "#" },
3
+ "brackets": [["(", ")"], ["[", "]"], ["{", "}"]],
4
+ "autoClosingPairs": [["(", ")"], ["[", "]"], ["{", "}"], ["\"", "\""], ["'", "'"]],
5
+ "surroundingPairs": [["(", ")"], ["[", "]"], ["{", "}"], ["\"", "\""], ["'", "'"]],
6
+ "indentationRules": {
7
+ "increaseIndentPattern": "^(?:[A-Z][a-z]+ +[A-Z]\\w*|\\s*[\\w-]+: *(?:\\|)?)\\s*$"
8
+ }
9
+ }
@@ -0,0 +1,129 @@
1
+ {
2
+ "name": "space-language-preview",
3
+ "displayName": "Space Language",
4
+ "description": "Native semantic highlighting and inline stylesheet colors for Space.",
5
+ "version": "0.2.1",
6
+ "publisher": "aliens-local",
7
+ "private": true,
8
+ "engines": {"vscode": "^1.90.0"},
9
+ "main": "./extension.cjs",
10
+ "activationEvents": ["onLanguage:space"],
11
+ "categories": ["Programming Languages"],
12
+ "contributes": {
13
+ "languages": [
14
+ {
15
+ "id": "space",
16
+ "aliases": ["Space"],
17
+ "extensions": [
18
+ ".agent",
19
+ ".animation",
20
+ ".api",
21
+ ".directive",
22
+ ".enum",
23
+ ".error",
24
+ ".guard",
25
+ ".interceptor",
26
+ ".interface",
27
+ ".logic",
28
+ ".markup",
29
+ ".mock",
30
+ ".model",
31
+ ".pipe",
32
+ ".route",
33
+ ".rule",
34
+ ".service",
35
+ ".skill",
36
+ ".storage",
37
+ ".style",
38
+ ".test",
39
+ ".validator"
40
+ ],
41
+ "filenames": [".config", ".env", ".map"],
42
+ "filenamePatterns": [".[a-z][a-z]-[A-Z][A-Z]"],
43
+ "configuration": "./language-configuration.json"
44
+ }
45
+ ],
46
+ "grammars": [{"language": "space", "scopeName": "source.space", "path": "./space.tmLanguage.json"}],
47
+ "semanticTokenTypes": [
48
+ {"id": "spaceReactive", "superType": "keyword", "description": "Space reactive constructs."},
49
+ {
50
+ "id": "spaceReturn",
51
+ "superType": "keyword",
52
+ "description": "Space return declarations and statements."
53
+ },
54
+ {"id": "spaceTranslation", "superType": "string", "description": "Space translation reference."},
55
+ {"id": "spaceSelector", "superType": "class", "description": "Space stylesheet selector."},
56
+ {"id": "spaceElement", "superType": "class", "description": "Space markup element."},
57
+ {"id": "spaceColor", "superType": "number", "description": "Space stylesheet color literal."},
58
+ {"id": "spaceActions", "superType": "keyword", "description": "Space action declaration block."},
59
+ {"id": "spaceLiteral", "superType": "keyword", "description": "Space boolean or null literal."}
60
+ ],
61
+ "semanticTokenScopes": [
62
+ {
63
+ "language": "space",
64
+ "scopes": {
65
+ "spaceReactive": ["storage.modifier"],
66
+ "spaceReturn": ["keyword.control.flow"],
67
+ "spaceTranslation": ["string.unquoted"],
68
+ "spaceSelector": ["entity.name.tag.css"],
69
+ "spaceElement": ["entity.name.tag"],
70
+ "spaceColor": ["constant.other.color.rgb-value.hex.css"],
71
+ "spaceActions": ["entity.name.function"],
72
+ "spaceLiteral": ["constant.language"]
73
+ }
74
+ }
75
+ ],
76
+ "configurationDefaults": {
77
+ "[space]": {
78
+ "editor.tabSize": 3,
79
+ "editor.indentSize": 3,
80
+ "editor.insertSpaces": true,
81
+ "editor.detectIndentation": false,
82
+ "editor.semanticHighlighting.enabled": true,
83
+ "editor.colorDecorators": true
84
+ },
85
+ "editor.semanticTokenColorCustomizations": {
86
+ "rules": {
87
+ "keyword:space": "#f5d46c",
88
+ "class:space": "#75dbd3",
89
+ "type:space": "#75dbd3",
90
+ "function:space": "#81c7ff",
91
+ "spaceActions:space": "#81c7ff",
92
+ "spaceSelector:space": "#81c7ff",
93
+ "spaceElement:space": "#81c7ff",
94
+ "variable:space": "#ff9098",
95
+ "property:space": "#ff9098",
96
+ "number:space": "#81e0a1",
97
+ "string:space": "#81e0a1",
98
+ "spaceReturn:space": "#81e0a1",
99
+ "spaceLiteral:space": "#81e0a1",
100
+ "spaceTranslation:space": "#81e0a1",
101
+ "spaceColor:space": "#81e0a1",
102
+ "spaceReactive:space": "#d5a9ff",
103
+ "comment:space": "#b0b0b0"
104
+ },
105
+ "[*Light*][*light*]": {
106
+ "rules": {
107
+ "keyword:space": "#755600",
108
+ "class:space": "#006864",
109
+ "type:space": "#006864",
110
+ "function:space": "#145c9e",
111
+ "spaceActions:space": "#145c9e",
112
+ "spaceSelector:space": "#145c9e",
113
+ "spaceElement:space": "#145c9e",
114
+ "variable:space": "#a22c37",
115
+ "property:space": "#a22c37",
116
+ "number:space": "#17683b",
117
+ "string:space": "#17683b",
118
+ "spaceReturn:space": "#17683b",
119
+ "spaceLiteral:space": "#17683b",
120
+ "spaceTranslation:space": "#17683b",
121
+ "spaceColor:space": "#17683b",
122
+ "spaceReactive:space": "#6d349e",
123
+ "comment:space": "#595959"
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "scopeName": "source.space",
3
+ "name": "Space",
4
+ "patterns": [
5
+ { "name": "comment.line.number-sign.space", "match": "^\\s*#(?:\\s.*|(?:AI|TODO|FIXME|NOTE|WARN|DEPRECATED)\\b.*)?$" },
6
+ {
7
+ "match": "^([A-Z][a-z]+)( +)([A-Z]\\w*)\\s*$",
8
+ "captures": {
9
+ "1": { "name": "storage.type.space" },
10
+ "3": { "name": "entity.name.type.space" }
11
+ }
12
+ },
13
+ {
14
+ "name": "string.quoted.double.space",
15
+ "begin": "\"",
16
+ "end": "\"|$",
17
+ "patterns": [{ "match": "\\\\.", "name": "constant.character.escape.space" }]
18
+ },
19
+ {
20
+ "name": "string.quoted.single.space",
21
+ "begin": "'",
22
+ "end": "'|$",
23
+ "patterns": [{ "match": "\\\\.", "name": "constant.character.escape.space" }]
24
+ },
25
+ { "name": "constant.other.color.rgb-value.hex.space", "match": "#(?:[A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{3})(?![\\w-])" },
26
+ { "name": "storage.type.space", "match": "\\b(?:number|integer|string|boolean|void)\\b" },
27
+ { "name": "keyword.control.space", "match": "\\b(?:import|signal|computed|effect|actions|returns|body|function|return|if|else)\\b" },
28
+ { "name": "variable.other.space", "match": "\\$[A-Za-z_][\\w.-]*" },
29
+ { "name": "string.unquoted.translation.space", "match": "@[A-Za-z_][\\w.-]*" },
30
+ { "name": "constant.numeric.space", "match": "\\b\\d+(?:\\.\\d+)?\\b" }
31
+ ]
32
+ }
@@ -0,0 +1,69 @@
1
+ const namedColors = require('./vendor/color-name.cjs');
2
+
3
+ const numeric = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(%|deg|grad|rad|turn)?$/i;
4
+ const clamp = value => Math.max(0, Math.min(1, value));
5
+
6
+ function number(text) {
7
+ const match = numeric.exec(text);
8
+ if (!match || !Number.isFinite(Number(match[1]))) return null;
9
+ return { value: Number(match[1]), unit: (match[2] ?? '').toLowerCase() };
10
+ }
11
+
12
+ function functionColor(name, raw) {
13
+ const parts = raw.trim().split(/\s*\/\s*/);
14
+ if (parts.length > 2 || (parts.length === 2 && raw.includes(','))) return null;
15
+ const channels = parts[0].includes(',') ? parts[0].split(/\s*,\s*/) : parts[0].split(/\s+/);
16
+ const alpha = channels.length === 4 && raw.includes(',') ? channels.pop() : parts[1] ?? '1';
17
+ if (channels.length !== 3) return null;
18
+
19
+ const parsed = [...channels, alpha].map(number);
20
+ if (parsed.some(value => value === null)) return null;
21
+ const [first, second, third, opacity] = parsed;
22
+ if (!['', '%'].includes(opacity.unit)) return null;
23
+ const a = clamp(opacity.value / (opacity.unit === '%' ? 100 : 1));
24
+
25
+ if (name.startsWith('rgb')) {
26
+ if (parsed.slice(0, 3).some(channel => !['', '%'].includes(channel.unit))) return null;
27
+ return [first, second, third].map(channel => clamp(channel.value / (channel.unit === '%' ? 100 : 255))).concat(a);
28
+ }
29
+
30
+ const angles = { '': 1, deg: 1, grad: .9, rad: 180 / Math.PI, turn: 360 };
31
+ if (!Object.hasOwn(angles, first.unit) || second.unit !== '%' || third.unit !== '%') return null;
32
+ const degrees = (first.value % (360 / angles[first.unit])) * angles[first.unit];
33
+ const hue = (degrees + 360) % 360 / 30;
34
+ const saturation = clamp(second.value / 100);
35
+ const lightness = clamp(third.value / 100);
36
+ const chroma = saturation * Math.min(lightness, 1 - lightness);
37
+ const channel = offset => {
38
+ const angle = (offset + hue) % 12;
39
+ return clamp(lightness - chroma * Math.max(-1, Math.min(angle - 3, 9 - angle, 1)));
40
+ };
41
+ return [channel(0), channel(8), channel(4), a];
42
+ }
43
+
44
+ function hexColor(text) {
45
+ if (![4, 5, 7, 9].includes(text.length)) return null;
46
+ let hex = text.slice(1);
47
+ if (hex.length <= 4) hex = [...hex].map(digit => digit.repeat(2)).join('');
48
+ if (hex.length === 6) hex += 'ff';
49
+ return hex.match(/../g).map(channel => Number.parseInt(channel, 16) / 255);
50
+ }
51
+
52
+ function findColors(value, property) {
53
+ const named = /^(?:--|.*(?:color|background|border|outline|shadow|decoration))|^(?:fill|stroke|filter|stop-|flood-|lighting-)/i.test(property);
54
+ const tokens = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\*[^]*?\*\/|\burl\(\s*(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^)]*)\s*\)|\b(?:rgba?|hsla?)\([^()]*\)|#[a-f\d]+(?![\w-])|--[\w-]+|[\w-]+\(?/gi;
55
+ const result = [];
56
+ for (const match of value.matchAll(tokens)) {
57
+ const literal = match[0].toLowerCase();
58
+ const fn = /^(rgba?|hsla?)\((.*)\)$/.exec(literal);
59
+ let rgba = null;
60
+ if (fn) rgba = functionColor(fn[1], fn[2]);
61
+ else if (literal.startsWith('#')) rgba = hexColor(literal);
62
+ else if (named && literal === 'transparent') rgba = [0, 0, 0, 0];
63
+ else if (named && Object.hasOwn(namedColors, literal)) rgba = namedColors[literal].map(channel => channel / 255).concat(1);
64
+ if (rgba) result.push({ start: match.index, length: literal.length, rgba });
65
+ }
66
+ return result;
67
+ }
68
+
69
+ module.exports = { findColors };
@@ -0,0 +1,122 @@
1
+ const { findColors } = require('./style-colors.cjs');
2
+
3
+ const reserved = new Map([
4
+ ['signal', ['spaceReactive', 'reactive']], ['computed', ['spaceReactive', 'reactive']],
5
+ ['effect', ['spaceReactive', 'reactive']], ['actions', ['spaceActions', 'action']],
6
+ ['returns', ['spaceReturn', 'return']], ['return', ['spaceReturn', 'return']],
7
+ ['import', ['keyword', 'control']], ['body', ['keyword', 'control']],
8
+ ['onInit', ['keyword', 'control']], ['onMount', ['keyword', 'control']],
9
+ ['onDestroy', ['keyword', 'control']], ['function', ['keyword', 'control']],
10
+ ['if', ['keyword', 'control']], ['else', ['keyword', 'control']],
11
+ ['number', ['type', 'type']], ['integer', ['type', 'type']], ['string', ['type', 'type']],
12
+ ['boolean', ['type', 'type']], ['void', ['type', 'type']],
13
+ ['true', ['spaceLiteral', 'return']], ['false', ['spaceLiteral', 'return']], ['null', ['spaceLiteral', 'return']]
14
+ ]);
15
+
16
+ const tokenTypes = [
17
+ 'keyword', 'class', 'type', 'function', 'property', 'variable', 'number', 'string', 'comment',
18
+ 'spaceReactive', 'spaceReturn', 'spaceTranslation', 'spaceSelector', 'spaceElement',
19
+ 'spaceColor', 'spaceActions', 'spaceLiteral'
20
+ ];
21
+
22
+ function isSpaceComment(value, style) {
23
+ return value.startsWith('#') && (!style || /^#(?:\s|$|(?:AI|TODO|FIXME|NOTE|WARN|DEPRECATED)\b)/.test(value));
24
+ }
25
+
26
+ function lexicalType(value) {
27
+ if (reserved.has(value)) return reserved.get(value);
28
+ if (value.startsWith('/*')) return ['comment', 'comment'];
29
+ if (value.startsWith('@')) return ['spaceTranslation', 'return'];
30
+ if (value.startsWith('$')) return ['variable', 'value'];
31
+ if (/^["']/.test(value)) return ['string', 'return'];
32
+ if (/^\d/.test(value)) return ['number', 'return'];
33
+ return null;
34
+ }
35
+
36
+ function styleValueType(token, rest) {
37
+ if (token.startsWith('/*')) return ['comment', 'comment'];
38
+ if (token.startsWith('--')) return ['variable', 'value'];
39
+ if (/^\d/.test(token)) return ['number', 'return'];
40
+ if (rest.startsWith('(')) return ['function', 'action'];
41
+ return ['string', 'return'];
42
+ }
43
+
44
+ function analyzeSpace(source, extension) {
45
+ const tokens = [];
46
+ const colors = [];
47
+ const parents = [];
48
+ const style = extension === '.style';
49
+ const markup = extension === '.markup';
50
+
51
+ for (const [line, text] of source.split(/\r\n|\n|\r/).entries()) {
52
+ const body = text.trim();
53
+ if (!body) continue;
54
+ const indent = text.length - text.trimStart().length;
55
+ const emit = (start, length, type, role, declaration = false) => {
56
+ tokens.push({ line, start, length, type, role, declaration });
57
+ };
58
+
59
+ if (isSpaceComment(body, style)) {
60
+ emit(indent, body.length, 'comment', 'comment');
61
+ continue;
62
+ }
63
+
64
+ while (parents.length && parents.at(-1).indent >= indent) parents.pop();
65
+ const parent = parents.at(-1)?.kind;
66
+ const header = indent === 0 && /^([A-Z][a-z]+)( +)([A-Z][\w]*)$/.exec(body);
67
+ if (header && '.' + header[1].toLowerCase() === extension) {
68
+ emit(0, header[1].length, 'keyword', 'control');
69
+ emit(header[1].length + header[2].length, header[3].length, 'class', 'type', true);
70
+ parents.push({ indent, kind: 'header' });
71
+ continue;
72
+ }
73
+
74
+ let valueStart = 0;
75
+ let lineColors = [];
76
+ if (style) {
77
+ const property = parent === 'selector' && /^([\w-]+):\s*/.exec(body);
78
+ if (property) {
79
+ emit(indent, property[1].length, 'property', 'value');
80
+ valueStart = indent + property[0].length;
81
+ lineColors = findColors(text.slice(valueStart), property[1]);
82
+ colors.push(...lineColors.map(color => ({ ...color, line, start: valueStart + color.start })));
83
+ } else {
84
+ const kind = body.startsWith('@') ? 'atRule' : /^(?:default|import):$/.test(body) ? 'manifest' : 'selector';
85
+ if (parent !== 'manifest') {
86
+ emit(indent, body.length, kind === 'selector' ? 'spaceSelector' : 'keyword', kind === 'selector' ? 'action' : 'control');
87
+ }
88
+ parents.push({ indent, kind });
89
+ continue;
90
+ }
91
+ }
92
+
93
+ const element = markup && /^[a-z][\w-]*/.exec(body)?.[0];
94
+ const signal = /^signal\s+(\w+):/.exec(body)?.[1];
95
+ const action = parent === 'actions' && /^(\w+):$/.exec(body)?.[1];
96
+ const callable = /^function\s+(\w+)\(/.exec(body)?.[1];
97
+ const field = parent && !style && !markup && /^(\w[\w-]*):/.exec(body)?.[1];
98
+ const value = text.slice(valueStart);
99
+ const lexemes = value.matchAll(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\*[^]*?\*\/|--[A-Za-z_][\w-]*|[@$][a-zA-Z_][\w.-]*|\b[A-Za-z_-][\w-]*\b|\b\d+(?:\.\d+)?\b/g);
100
+ for (const match of lexemes) {
101
+ const token = match[0];
102
+ const start = valueStart + match.index;
103
+ const rest = text.slice(start + token.length);
104
+ if (lineColors.some(color => start >= valueStart + color.start && start < valueStart + color.start + color.length)) continue;
105
+ let type = style ? styleValueType(token, rest) : lexicalType(token);
106
+ let declaration = false;
107
+ if (start === indent && token === element) type = ['spaceElement', 'action'];
108
+ else if (markup && /^\s*=/.test(rest) && /^[a-z][\w-]*$/.test(token)) type = ['property', 'value'];
109
+ else if (token === signal) { type = ['variable', 'value']; declaration = true; }
110
+ else if (token === action || token === callable) { type = ['function', 'action']; declaration = true; }
111
+ else if (!type && !markup && text.slice(0, start).endsWith('this.')) type = ['property', 'value'];
112
+ else if (!type && start === indent && token === field) type = ['property', 'value'];
113
+ if (type) emit(start, token.length, ...type, declaration);
114
+ }
115
+ for (const color of lineColors) emit(valueStart + color.start, color.length, 'spaceColor', 'return');
116
+ parents.push({ indent, kind: body === 'actions:' ? 'actions' : 'node' });
117
+ }
118
+
119
+ return { tokens: tokens.sort((left, right) => left.line - right.line || left.start - right.start), colors };
120
+ }
121
+
122
+ module.exports = { analyzeSpace, isSpaceComment, tokenTypes };