@platformos/platformos-language-server-common 0.0.5 → 0.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformos/platformos-language-server-common",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "platformOS",
@@ -27,9 +27,9 @@
27
27
  "type-check": "tsc --noEmit -p ./tsconfig.json"
28
28
  },
29
29
  "dependencies": {
30
- "@platformos/liquid-html-parser": "^0.0.5",
31
- "@platformos/platformos-check-common": "0.0.5",
32
- "@platformos/platformos-graph": "0.0.5",
30
+ "@platformos/liquid-html-parser": "^0.0.6",
31
+ "@platformos/platformos-check-common": "0.0.6",
32
+ "@platformos/platformos-graph": "0.0.6",
33
33
  "@vscode/web-custom-data": "^0.4.6",
34
34
  "vscode-json-languageservice": "^5.3.10",
35
35
  "vscode-languageserver": "^8.0.2",
@@ -44,7 +44,7 @@ export class ClientCapabilities {
44
44
  }
45
45
 
46
46
  initializationOption<T>(key: string, defaultValue: T): T {
47
- // { 'themeCheck.checkOnSave': true }
47
+ // { 'platformosCheck.checkOnSave': true }
48
48
  const direct = this.initializationOptions?.[key];
49
49
  if (direct !== undefined) return direct;
50
50
 
@@ -29,10 +29,15 @@ export function makeRunChecks(
29
29
  getMetafieldDefinitions,
30
30
  cssLanguageService,
31
31
  themeGraphManager,
32
+ includeFilesFromDisk,
32
33
  }: Pick<
33
34
  Dependencies,
34
35
  'fs' | 'loadConfig' | 'themeDocset' | 'jsonValidationSet' | 'getMetafieldDefinitions'
35
- > & { cssLanguageService?: CSSLanguageService; themeGraphManager?: ThemeGraphManager },
36
+ > & {
37
+ cssLanguageService?: CSSLanguageService;
38
+ themeGraphManager?: ThemeGraphManager;
39
+ includeFilesFromDisk?: () => boolean;
40
+ },
36
41
  ) {
37
42
  return async function runChecks(triggerURIs: string[]): Promise<void> {
38
43
  // This function takes an array of triggerURIs so that we can correctly
@@ -53,7 +58,7 @@ export function makeRunChecks(
53
58
 
54
59
  async function runChecksForRoot(configFileRootUri: string) {
55
60
  const config = await loadConfig(configFileRootUri, fs);
56
- const theme = documentManager.theme(config.rootUri);
61
+ const theme = documentManager.theme(config.rootUri, includeFilesFromDisk?.());
57
62
 
58
63
  const cssOffenses = cssLanguageService
59
64
  ? await Promise.all(
@@ -2,6 +2,7 @@ import { afterEach, assert, beforeEach, describe, expect, it, vi } from 'vitest'
2
2
  import { DocumentOnTypeFormattingParams } from 'vscode-languageserver';
3
3
  import { DocumentManager } from '../../documents';
4
4
  import { OnTypeFormattingProvider } from '../OnTypeFormattingProvider';
5
+ import { SetCursorPosition } from '../types';
5
6
 
6
7
  const options: DocumentOnTypeFormattingParams['options'] = {
7
8
  insertSpaces: true,
@@ -11,11 +12,11 @@ const options: DocumentOnTypeFormattingParams['options'] = {
11
12
  describe('Module: HtmlElementAutoclosingOnTypeFormattingProvider', () => {
12
13
  let documentManager: DocumentManager;
13
14
  let onTypeFormattingProvider: OnTypeFormattingProvider;
14
- let setCursorPositionSpy: ReturnType<typeof vi.fn>;
15
+ let setCursorPositionSpy: SetCursorPosition;
15
16
  const uri = 'file:///path/to/document.liquid';
16
17
 
17
18
  beforeEach(() => {
18
- setCursorPositionSpy = vi.fn();
19
+ setCursorPositionSpy = vi.fn(async () => {}) as SetCursorPosition;
19
20
  documentManager = new DocumentManager();
20
21
  onTypeFormattingProvider = new OnTypeFormattingProvider(documentManager, setCursorPositionSpy);
21
22
  vi.useFakeTimers();
@@ -7,10 +7,11 @@ import {
7
7
  } from 'vscode-languageserver';
8
8
  import { ClientCapabilities } from '../ClientCapabilities';
9
9
 
10
- export const CHECK_ON_OPEN = 'themeCheck.checkOnOpen' as const;
11
- export const CHECK_ON_SAVE = 'themeCheck.checkOnSave' as const;
12
- export const CHECK_ON_CHANGE = 'themeCheck.checkOnChange' as const;
13
- export const PRELOAD_ON_BOOT = 'themeCheck.preloadOnBoot' as const;
10
+ export const CHECK_ON_OPEN = 'platformosCheck.checkOnOpen' as const;
11
+ export const CHECK_ON_SAVE = 'platformosCheck.checkOnSave' as const;
12
+ export const CHECK_ON_CHANGE = 'platformosCheck.checkOnChange' as const;
13
+ export const PRELOAD_ON_BOOT = 'platformosCheck.preloadOnBoot' as const;
14
+ export const INCLUDE_FILES_FROM_DISK = 'platformosCheck.includeFilesFromDisk' as const;
14
15
  export const ConfigurationKeys = [
15
16
  CHECK_ON_OPEN,
16
17
  CHECK_ON_SAVE,
@@ -23,6 +24,7 @@ export class Configuration {
23
24
  [CHECK_ON_SAVE]: boolean = true;
24
25
  [CHECK_ON_CHANGE]: boolean = true;
25
26
  [PRELOAD_ON_BOOT]: boolean = true;
27
+ [INCLUDE_FILES_FROM_DISK]: boolean = false;
26
28
 
27
29
  constructor(private connection: Connection, private capabilities: ClientCapabilities) {
28
30
  this.connection = connection;
@@ -34,6 +36,10 @@ export class Configuration {
34
36
  this[CHECK_ON_SAVE] = this.capabilities.initializationOption(CHECK_ON_SAVE, true);
35
37
  this[CHECK_ON_CHANGE] = this.capabilities.initializationOption(CHECK_ON_CHANGE, true);
36
38
  this[PRELOAD_ON_BOOT] = this.capabilities.initializationOption(PRELOAD_ON_BOOT, true);
39
+ this[INCLUDE_FILES_FROM_DISK] = this.capabilities.initializationOption(
40
+ INCLUDE_FILES_FROM_DISK,
41
+ false,
42
+ );
37
43
  }
38
44
 
39
45
  async shouldCheckOnOpen() {
@@ -117,9 +117,9 @@ describe('Module: server', () => {
117
117
  connection.setup(
118
118
  {},
119
119
  {
120
- 'themeCheck.checkOnOpen': false,
121
- 'themeCheck.checkOnChange': false,
122
- 'themeCheck.checkOnSave': false,
120
+ 'platformosCheck.checkOnOpen': false,
121
+ 'platformosCheck.checkOnChange': false,
122
+ 'platformosCheck.checkOnSave': false,
123
123
  },
124
124
  );
125
125
  await flushAsync();
@@ -154,9 +154,9 @@ describe('Module: server', () => {
154
154
  },
155
155
  },
156
156
  {
157
- 'themeCheck.checkOnOpen': false,
158
- 'themeCheck.checkOnChange': false,
159
- 'themeCheck.checkOnSave': false,
157
+ 'platformosCheck.checkOnOpen': false,
158
+ 'platformosCheck.checkOnChange': false,
159
+ 'platformosCheck.checkOnSave': false,
160
160
  },
161
161
  );
162
162
  await flushAsync();
@@ -54,7 +54,7 @@ import {
54
54
  import { debounce } from '../utils';
55
55
  import { VERSION } from '../version';
56
56
  import { CachedFileSystem } from './CachedFileSystem';
57
- import { Configuration } from './Configuration';
57
+ import { Configuration, INCLUDE_FILES_FROM_DISK } from './Configuration';
58
58
  import { safe } from './safe';
59
59
  import { ThemeGraphManager } from './ThemeGraphManager';
60
60
  import { DocumentsLocator } from '@platformos/platformos-common';
@@ -194,6 +194,7 @@ export function startServer(
194
194
  getMetafieldDefinitions,
195
195
  cssLanguageService,
196
196
  themeGraphManager,
197
+ includeFilesFromDisk: () => configuration[INCLUDE_FILES_FROM_DISK],
197
198
  }),
198
199
  100,
199
200
  );
@@ -202,7 +203,7 @@ export function startServer(
202
203
  const rootURI = await findThemeRootURI(uri);
203
204
  if (!rootURI) return {};
204
205
 
205
- const theme = documentManager.theme(rootURI);
206
+ const theme = documentManager.theme(rootURI, configuration[INCLUDE_FILES_FROM_DISK]);
206
207
  const getDefaultTranslations = makeGetDefaultTranslations(fs, theme, rootURI);
207
208
  const [defaultTranslations, shopifyTranslations] = await Promise.all([
208
209
  getDefaultTranslations(),
@@ -216,7 +217,7 @@ export function startServer(
216
217
  const rootURI = await findThemeRootURI(uri);
217
218
  if (!rootURI) return {};
218
219
 
219
- const theme = documentManager.theme(rootURI);
220
+ const theme = documentManager.theme(rootURI, configuration[INCLUDE_FILES_FROM_DISK]);
220
221
  const getDefaultSchemaTranslations = makeGetDefaultSchemaTranslations(fs, theme, rootURI);
221
222
  return getDefaultSchemaTranslations();
222
223
  };