@platformos/codemirror-language-client 0.0.6 → 0.0.8

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.
@@ -12,53 +12,48 @@ import { MarkedString, MarkupContent } from 'vscode-languageserver-protocol';
12
12
 
13
13
  const md = new MarkdownIt();
14
14
 
15
- const exampleTemplate = `{% # sections/title.liquid %}
15
+ const exampleTemplate = `{% # app/views/partials/header.liquid %}
16
16
  {% # mod-alt-v for vim mode %}
17
- <section>
18
- <h2>{{ section.settings.title }}</h2>
19
- {% echo 'hi' | upcase %}
20
- </section>
21
-
22
- {% schema %}
23
- {
24
- "name": "t:sections.title.name",
25
- "limit": 1,
26
- "settings": [
27
- {
28
- "type": "text",
29
- "id": "title",
30
- "label": "t:sections.title.settings.title.label"
31
- }
32
- ]
33
- }
34
- {% endschema %}
17
+ {% doc %}
18
+ @param {string} title - The page title
19
+ @param {boolean} [show_nav] - Whether to show the navigation
20
+ {% enddoc %}
21
+ <header>
22
+ <h1>{{ title }}</h1>
23
+ <p>{{ 'header.welcome' | t }}</p>
24
+ {% if context.current_user %}
25
+ <span>{{ 'header.greeting' | t: name: context.current_user.name }}</span>
26
+ <a href="/logout">{{ 'header.logout' | t }}</a>
27
+ {% endif %}
28
+ {% if show_nav %}
29
+ {% render 'nav' %}
30
+ {% endif %}
31
+ </header>
35
32
  `;
36
33
 
37
34
  const exampleTranslations = {
38
- product: {
39
- price_html: '<b>{{ price }}$</b>',
40
- size: 'Size',
41
- count: {
42
- one: '{{ count }} item',
43
- other: '{{ count }} items',
44
- },
35
+ header: {
36
+ welcome: 'Welcome to our platform',
37
+ greeting: 'Hello, {{ name }}!',
38
+ logout: 'Log out',
45
39
  },
46
- footer: {
47
- subscribe: 'Subscribe to our newsletter',
40
+ navigation: {
41
+ home: 'Home',
42
+ about: 'About',
48
43
  },
49
44
  };
50
45
 
51
- const exampleSchemaTranslations = {
52
- sections: {
53
- title: {
54
- name: 'Title section name',
55
- settings: { title: { label: 'Title section title setting' } },
56
- },
57
- other: {
58
- name: 'Other section name',
59
- },
60
- },
61
- };
46
+ const exampleNavPartial = `{% # app/views/partials/nav.liquid %}
47
+ <nav>
48
+ <ul>
49
+ <li><a href="/">{{ 'navigation.home' | t }}</a></li>
50
+ <li><a href="/about">{{ 'navigation.about' | t }}</a></li>
51
+ {% for item in context.models %}
52
+ <li><a href="{{ item.url }}">{{ item.title }}</a></li>
53
+ {% endfor %}
54
+ </ul>
55
+ </nav>
56
+ `;
62
57
 
63
58
  function asMarkdown(content: MarkupContent | MarkedString[] | MarkedString): string {
64
59
  if (Array.isArray(content)) {
@@ -123,16 +118,12 @@ async function main() {
123
118
 
124
119
  client.client.onRequest('fs/readFile' as any, ([uri]: string) => {
125
120
  switch (uri) {
126
- case 'browser:/sections/section.liquid':
121
+ case 'browser:/app/views/partials/header.liquid':
127
122
  return exampleTemplate;
128
- case 'browser:/locales/en.default.json':
123
+ case 'browser:/app/views/partials/nav.liquid':
124
+ return exampleNavPartial;
125
+ case 'browser:/app/translations/en.default.json':
129
126
  return JSON.stringify(exampleTranslations, null, 2);
130
- case 'browser:/locales/en.default.schema.json':
131
- return JSON.stringify(exampleSchemaTranslations, null, 2);
132
- case 'browser:/snippets/article-card.liquid':
133
- case 'browser:/snippets/product-card.liquid':
134
- case 'browser:/snippets/product.liquid':
135
- return '';
136
127
  default:
137
128
  throw new Error(`File does not exist ${uri}`);
138
129
  }
@@ -140,13 +131,10 @@ async function main() {
140
131
 
141
132
  client.client.onRequest('fs/stat' as any, ([uri]: string) => {
142
133
  switch (uri) {
143
- case 'browser:/.theme-check.yml':
144
- case 'browser:/locales/en.default.json':
145
- case 'browser:/locales/en.schema.default.json':
146
- case 'browser:/sections/section.liquid':
147
- case 'browser:/snippets/article-card.liquid':
148
- case 'browser:/snippets/product-card.liquid':
149
- case 'browser:/snippets/product.liquid':
134
+ case 'browser:/.platformos-check.yml':
135
+ case 'browser:/app/translations/en.default.json':
136
+ case 'browser:/app/views/partials/header.liquid':
137
+ case 'browser:/app/views/partials/nav.liquid':
150
138
  return { fileType: 1, size: 1 };
151
139
  default:
152
140
  throw new Error(`File does not exist: ${uri}`);
@@ -157,26 +145,26 @@ async function main() {
157
145
  switch (uri) {
158
146
  case 'browser:/': {
159
147
  return [
160
- ['browser:/sections', 2],
161
- ['browser:/snippets', 2],
162
- ['browser:/locales', 2],
163
- ['browser:/.theme-check.yml', 1],
148
+ ['browser:/app', 2],
149
+ ['browser:/.platformos-check.yml', 1],
164
150
  ];
165
151
  }
166
- case 'browser:/sections': {
167
- return [['browser:/sections/section.liquid', 1]];
168
- }
169
- case 'browser:/snippets': {
152
+ case 'browser:/app': {
170
153
  return [
171
- ['browser:/snippets/article-card.liquid', 1],
172
- ['browser:/snippets/product-card.liquid', 1],
173
- ['browser:/snippets/product.liquid', 1],
154
+ ['browser:/app/views', 2],
155
+ ['browser:/app/translations', 2],
174
156
  ];
175
157
  }
176
- case 'browser:/locales': {
158
+ case 'browser:/app/translations': {
159
+ return [['browser:/app/translations/en.default.json', 1]];
160
+ }
161
+ case 'browser:/app/views': {
162
+ return [['browser:/app/views/partials', 2]];
163
+ }
164
+ case 'browser:/app/views/partials': {
177
165
  return [
178
- ['browser:/locales/en.default.json', 1],
179
- ['browser:/locales/en.default.schema.json', 1],
166
+ ['browser:/app/views/partials/header.liquid', 1],
167
+ ['browser:/app/views/partials/nav.liquid', 1],
180
168
  ];
181
169
  }
182
170
  default: {
@@ -191,7 +179,7 @@ async function main() {
191
179
  {
192
180
  key: 'Mod-Alt-v',
193
181
  run: () => {
194
- [liquidEditor, themeTranslationsEditor, schemaTranslationEditor].forEach((view) => {
182
+ [liquidEditor, translationsEditor, navPartialEditor].forEach((view) => {
195
183
  view.dispatch({
196
184
  effects: vimCompartment.reconfigure([vimEnabled ? [] : vim({ status: true })]),
197
185
  });
@@ -212,13 +200,13 @@ async function main() {
212
200
  // liquid(),
213
201
  // liquidHighLightStyle,
214
202
  // oneDark,
215
- client.extension('browser:/sections/section.liquid'),
203
+ client.extension('browser:/app/views/partials/header.liquid'),
216
204
  ],
217
205
  }),
218
206
  parent: document.getElementById('liquid-editor')!,
219
207
  });
220
208
 
221
- const themeTranslationsEditor = new EditorView({
209
+ const translationsEditor = new EditorView({
222
210
  state: EditorState.create({
223
211
  doc: JSON.stringify(exampleTranslations, null, 2),
224
212
  extensions: [
@@ -226,25 +214,25 @@ async function main() {
226
214
  basicSetup,
227
215
  jsonc(),
228
216
  // oneDark,
229
- client.extension('browser:/locales/en.default.json'),
217
+ client.extension('browser:/app/translations/en.default.json'),
230
218
  ],
231
219
  }),
232
- parent: document.getElementById('theme-translations-editor')!,
220
+ parent: document.getElementById('translations-editor')!,
233
221
  });
234
222
 
235
- const schemaTranslationEditor = new EditorView({
223
+ const navPartialEditor = new EditorView({
236
224
  state: EditorState.create({
237
- doc: JSON.stringify(exampleSchemaTranslations, null, 2),
225
+ doc: exampleNavPartial,
238
226
  extensions: [
239
227
  vimConfig,
240
228
  basicSetup,
241
229
  jsonc(),
242
230
  // liquidHighLightStyle,
243
231
  // oneDark,
244
- client.extension('browser:/locales/en.default.schema.json'),
232
+ client.extension('browser:/app/views/partials/nav.liquid'),
245
233
  ],
246
234
  }),
247
- parent: document.getElementById('schema-translations-editor')!,
235
+ parent: document.getElementById('nav-partial-editor')!,
248
236
  });
249
237
  }
250
238
 
@@ -12,11 +12,10 @@ const { ThemeLiquidDocsManager } = require('@platformos/platformos-check-docs-up
12
12
  /** @type {() => Promise<WebpackConfig>} */
13
13
  const config = async () => {
14
14
  const docsManager = new ThemeLiquidDocsManager();
15
- const [tags, filters, objects, systemTranslations, schemas] = await Promise.all([
15
+ const [tags, filters, objects, schemas] = await Promise.all([
16
16
  docsManager.tags(),
17
17
  docsManager.filters(),
18
18
  docsManager.objects(),
19
- docsManager.systemTranslations(),
20
19
  docsManager.schemas('theme'),
21
20
  ]);
22
21
 
@@ -45,7 +44,6 @@ const config = async () => {
45
44
  WEBPACK_TAGS: JSON.stringify(tags),
46
45
  WEBPACK_FILTERS: JSON.stringify(filters),
47
46
  WEBPACK_OBJECTS: JSON.stringify(objects),
48
- WEBPACK_SYSTEM_TRANSLATIONS: JSON.stringify(systemTranslations),
49
47
  WEBPACK_SCHEMAS: JSON.stringify(schemas),
50
48
  }),
51
49
  new HtmlWebpackPlugin({
@@ -59,7 +59,10 @@ export class LanguageClient extends EventTarget implements AbstractLanguageClien
59
59
  private disposables: Disposable[];
60
60
  private log: Dependencies['log'];
61
61
 
62
- constructor(public readonly worker: Worker, dependencies: Dependencies) {
62
+ constructor(
63
+ public readonly worker: Worker,
64
+ dependencies: Dependencies,
65
+ ) {
63
66
  super();
64
67
  this.requests = new Map();
65
68
  this.requestId = 0;