@caartzee/theme-sdk 0.0.0-stage → 1.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 +34 -2
- package/dist/bin/caartzee-theme.js +7449 -0
- package/dist/lib/index.js +9838 -0
- package/dist/types/src/auth/credentials-store.d.ts +18 -0
- package/dist/types/src/auth/index.d.ts +2 -0
- package/dist/types/src/auth/oauth-client.d.ts +39 -0
- package/dist/types/src/blocks/block-contract.d.ts +242 -0
- package/dist/types/src/candy/compatibility-matrix.d.ts +10 -0
- package/dist/types/src/candy/context-builder.d.ts +31 -0
- package/dist/types/src/candy/engine.d.ts +69 -0
- package/dist/types/src/candy/filters.d.ts +32 -0
- package/dist/types/src/candy/ide-support.d.ts +20 -0
- package/dist/types/src/candy/index.d.ts +9 -0
- package/dist/types/src/candy/schema-parser.d.ts +13 -0
- package/dist/types/src/candy/security.d.ts +54 -0
- package/dist/types/src/candy/tags.d.ts +11 -0
- package/dist/types/src/candy/types.d.ts +185 -0
- package/dist/types/src/cli/caartzee-cli.d.ts +9 -0
- package/dist/types/src/cli/index.d.ts +1 -0
- package/dist/types/src/cli/sdk-client.d.ts +12 -0
- package/dist/types/src/contracts/category-selection.d.ts +15 -0
- package/dist/types/src/contracts/commerce.d.ts +282 -0
- package/dist/types/src/contracts/footer-builder.d.ts +125 -0
- package/dist/types/src/contracts/hooks.d.ts +37 -0
- package/dist/types/src/contracts/manifest.d.ts +3127 -0
- package/dist/types/src/contracts/navigation.d.ts +39 -0
- package/dist/types/src/contracts/order-tracking.d.ts +40 -0
- package/dist/types/src/contracts/page.d.ts +262 -0
- package/dist/types/src/contracts/storefront-content.d.ts +60 -0
- package/dist/types/src/contracts/style-document.d.ts +2 -0
- package/dist/types/src/contracts/styles.d.ts +2002 -0
- package/dist/types/src/contracts/theme.d.ts +35 -0
- package/dist/types/src/dev-server/catalog-preview.d.ts +25 -0
- package/dist/types/src/dev-server/dev-server.d.ts +22 -0
- package/dist/types/src/dev-server/index.d.ts +1 -0
- package/dist/types/src/dev-server/theme-preview.d.ts +4 -0
- package/dist/types/src/index.d.ts +27 -0
- package/dist/types/src/mock/index.d.ts +10 -0
- package/dist/types/src/mock/mock-categories.d.ts +2 -0
- package/dist/types/src/mock/mock-commerce.d.ts +55 -0
- package/dist/types/src/mock/mock-customer.d.ts +47 -0
- package/dist/types/src/mock/mock-hooks.d.ts +2 -0
- package/dist/types/src/mock/mock-products.d.ts +3 -0
- package/dist/types/src/rendering/commerce-pages.d.ts +16 -0
- package/dist/types/src/rendering/raw-html.d.ts +12 -0
- package/dist/types/src/rendering/section-wrapper.d.ts +30 -0
- package/dist/types/src/scaffold/candy-starter-assets.d.ts +2 -0
- package/dist/types/src/scaffold/commerce-generator.d.ts +3 -0
- package/dist/types/src/scaffold/index.d.ts +2 -0
- package/dist/types/src/scaffold/template-generator.d.ts +21 -0
- package/dist/types/src/sections/section-contract.d.ts +350 -0
- package/dist/types/src/settings/global-settings.d.ts +25 -0
- package/dist/types/src/templates/json-template.d.ts +991 -0
- package/dist/types/src/validation/package-validator.d.ts +53 -0
- package/dist/types/src/validation/rich-text.d.ts +24 -0
- package/package.json +28 -3
- package/templates/commerce/README.md +165 -0
- package/templates/commerce/assets/theme.css +1 -0
- package/templates/commerce/manifest.json +1 -0
- package/templates/commerce/src/blocks/index.ts +184 -0
- package/templates/commerce/src/config/settings-defaults.ts +25 -0
- package/templates/commerce/src/config/settings-schema.ts +102 -0
- package/templates/commerce/src/index.ts +90 -0
- package/templates/commerce/src/layouts/default.ts +275 -0
- package/templates/commerce/src/manifest.ts +976 -0
- package/templates/commerce/src/pages/account/components.ts +369 -0
- package/templates/commerce/src/pages/account/tabs.ts +792 -0
- package/templates/commerce/src/pages/account.ts +55 -0
- package/templates/commerce/src/pages/campaign.ts +423 -0
- package/templates/commerce/src/pages/cart.ts +261 -0
- package/templates/commerce/src/pages/category-detail.ts +124 -0
- package/templates/commerce/src/pages/category-list.ts +87 -0
- package/templates/commerce/src/pages/checkout.ts +712 -0
- package/templates/commerce/src/pages/commerce.ts +45 -0
- package/templates/commerce/src/pages/home.ts +160 -0
- package/templates/commerce/src/pages/index.ts +99 -0
- package/templates/commerce/src/pages/login.ts +204 -0
- package/templates/commerce/src/pages/order-success.ts +80 -0
- package/templates/commerce/src/pages/product-detail.ts +489 -0
- package/templates/commerce/src/pages/product-list.ts +125 -0
- package/templates/commerce/src/pages/search.ts +88 -0
- package/templates/commerce/src/pages/signup.ts +253 -0
- package/templates/commerce/src/pages/status.ts +7 -0
- package/templates/commerce/src/pages/theme-layout.ts +491 -0
- package/templates/commerce/src/pages/track-order.ts +196 -0
- package/templates/commerce/src/pages/wishlist.ts +83 -0
- package/templates/commerce/src/sections/about-story.ts +117 -0
- package/templates/commerce/src/sections/announcement-bar.ts +101 -0
- package/templates/commerce/src/sections/banner-grid.ts +319 -0
- package/templates/commerce/src/sections/campaign-banners.ts +158 -0
- package/templates/commerce/src/sections/category-slider.ts +144 -0
- package/templates/commerce/src/sections/content-builder.ts +123 -0
- package/templates/commerce/src/sections/content-controls.ts +45 -0
- package/templates/commerce/src/sections/custom-form.ts +59 -0
- package/templates/commerce/src/sections/faq-accordion.ts +123 -0
- package/templates/commerce/src/sections/footer.ts +728 -0
- package/templates/commerce/src/sections/header.ts +439 -0
- package/templates/commerce/src/sections/hero-slider.ts +492 -0
- package/templates/commerce/src/sections/hero.ts +137 -0
- package/templates/commerce/src/sections/index.ts +102 -0
- package/templates/commerce/src/sections/mobile-slider.ts +102 -0
- package/templates/commerce/src/sections/newsletter.ts +43 -0
- package/templates/commerce/src/sections/product-grid.ts +191 -0
- package/templates/commerce/src/sections/raw-html.ts +1 -0
- package/templates/commerce/src/sections/rich-text.ts +26 -0
- package/templates/commerce/src/sections/services-features.ts +211 -0
- package/templates/commerce/src/sections/testimonials.ts +194 -0
- package/templates/commerce/src/snippets/product-card.ts +178 -0
- package/templates/commerce/src/snippets/product-price.ts +46 -0
- package/templates/commerce/src/snippets/responsive-image.ts +29 -0
- package/templates/commerce/src/styles.ts +477 -0
- package/templates/commerce/src/templates/404.json +26 -0
- package/templates/commerce/src/templates/account.json +17 -0
- package/templates/commerce/src/templates/cart.json +17 -0
- package/templates/commerce/src/templates/category.json +16 -0
- package/templates/commerce/src/templates/checkout.json +15 -0
- package/templates/commerce/src/templates/collection.json +16 -0
- package/templates/commerce/src/templates/index.json +180 -0
- package/templates/commerce/src/templates/login.json +17 -0
- package/templates/commerce/src/templates/order-success.json +17 -0
- package/templates/commerce/src/templates/page.json +17 -0
- package/templates/commerce/src/templates/product.json +17 -0
- package/templates/commerce/src/templates/search.json +18 -0
- package/templates/commerce/src/templates/signup.json +17 -0
- package/templates/commerce/src/templates/track-order.json +17 -0
- package/templates/commerce/src/templates/wishlist.json +17 -0
- package/templates/commerce/src/templates.ts +510 -0
- package/templates/commerce/src/tokens.ts +22 -0
- package/templates/vscode-candy/README.md +22 -0
- package/templates/vscode-candy/extension.js +338 -0
- package/templates/vscode-candy/icons/candy-dark.svg +23 -0
- package/templates/vscode-candy/icons/candy-light.svg +23 -0
- package/templates/vscode-candy/icons/candy-logo.png +0 -0
- package/templates/vscode-candy/icons/candy-sweet-dark.svg +23 -0
- package/templates/vscode-candy/icons/candy-sweet-light.svg +23 -0
- package/templates/vscode-candy/language-configuration.json +47 -0
- package/templates/vscode-candy/package.json +103 -0
- package/templates/vscode-candy/schemas/candy-config.schema.json +56 -0
- package/templates/vscode-candy/schemas/candy-settings.schema.json +70 -0
- package/templates/vscode-candy/snippets/candy.code-snippets +179 -0
- package/templates/vscode-candy/syntaxes/candy.tmLanguage.json +296 -0
- package/templates/vscode-candy/vim/ftdetect/candy.vim +5 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vscode = require('vscode');
|
|
4
|
+
|
|
5
|
+
const CANDY_TAGS = [
|
|
6
|
+
{ name: 'if', snippet: 'if ${1:condition} %}\n\t$0\n{% endif', detail: 'Conditional block ({% if %} ... {% endif %})' },
|
|
7
|
+
{ name: 'elsif', snippet: 'elsif ${1:condition}', detail: 'Else-if branch inside {% if %}' },
|
|
8
|
+
{ name: 'else', snippet: 'else', detail: 'Fallback branch inside {% if %}, {% unless %}, {% case %}, or {% for %}' },
|
|
9
|
+
{ name: 'unless', snippet: 'unless ${1:condition} %}\n\t$0\n{% endunless', detail: 'Negated conditional block ({% unless %} ... {% endunless %})' },
|
|
10
|
+
{ name: 'case', snippet: 'case ${1:variable} %}\n\t{% when ${2:value} %}\n\t\t$0\n{% endcase', detail: 'Multi-branch switch block ({% case %} ... {% endcase %})' },
|
|
11
|
+
{ name: 'when', snippet: 'when ${1:value}', detail: 'Match clause inside {% case %}' },
|
|
12
|
+
{ name: 'for', snippet: 'for ${1:item} in ${2:collection} %}\n\t$0\n{% endfor', detail: 'Loop over an array or range ({% for %} ... {% endfor %})' },
|
|
13
|
+
{ name: 'break', snippet: 'break', detail: 'Exit the current {% for %} or {% tablerow %} loop' },
|
|
14
|
+
{ name: 'continue', snippet: 'continue', detail: 'Skip to the next iteration of {% for %}' },
|
|
15
|
+
{ name: 'cycle', snippet: "cycle '${1:odd}', '${2:even}'", detail: 'Cycle through a list of strings on each loop iteration' },
|
|
16
|
+
{ name: 'tablerow', snippet: 'tablerow ${1:item} in ${2:collection} cols:${3:3} %}\n\t$0\n{% endtablerow', detail: 'Render an HTML <tr>/<td> table row loop' },
|
|
17
|
+
{ name: 'assign', snippet: 'assign ${1:name} = ${2:value}', detail: 'Assign a variable in template scope' },
|
|
18
|
+
{ name: 'capture', snippet: 'capture ${1:name} %}\n\t$0\n{% endcapture', detail: 'Capture rendered block content into a variable' },
|
|
19
|
+
{ name: 'increment', snippet: 'increment ${1:counter}', detail: 'Output and increment an independent counter' },
|
|
20
|
+
{ name: 'decrement', snippet: 'decrement ${1:counter}', detail: 'Decrement and output an independent counter' },
|
|
21
|
+
{ name: 'echo', snippet: 'echo ${1:expression}', detail: 'Output an expression inside {% liquid %} or standalone' },
|
|
22
|
+
{ name: 'liquid', snippet: 'liquid\n\t$0', detail: 'Multi-line tag-less Candy block' },
|
|
23
|
+
{ name: 'render', snippet: "render '${1:snippet-name}'", detail: 'Render an isolated snippet from snippets/<name>.candy' },
|
|
24
|
+
{ name: 'include', snippet: "include '${1:snippet-name}'", detail: 'Include a snippet sharing parent scope' },
|
|
25
|
+
{ name: 'layout', snippet: "layout '${1:theme}'", detail: 'Wrap template output in layout/<name>.candy' },
|
|
26
|
+
{ name: 'section', snippet: "section '${1:section-name}'", detail: 'Render a section from sections/<name>.candy' },
|
|
27
|
+
{ name: 'sections', snippet: "sections '${1:header-group}'", detail: 'Render a section group' },
|
|
28
|
+
{ name: 'content_for', snippet: "content_for '${1|layout,header|}'", detail: 'Inject layout body or header scripts' },
|
|
29
|
+
{ name: 'paginate', snippet: 'paginate ${1:collection.products} by ${2:12} %}\n\t$0\n{% endpaginate', detail: 'Paginate a collection array' },
|
|
30
|
+
{ name: 'form', snippet: "form '${1|product,cart,search,contact,customer_login|}' %}\n\t$0\n{% endform", detail: 'Render a Caartzee storefront form' },
|
|
31
|
+
{ name: 'schema', snippet: 'schema %}\n{\n\t"name": "${1:Section Name}",\n\t"type": "${2:section-type}",\n\t"settings": []\n}\n{% endschema', detail: 'Define Theme Builder JSON schema for this section' },
|
|
32
|
+
{ name: 'style', snippet: 'style %}\n\t$0\n{% endstyle', detail: 'Emit an HTML <style data-candy-style> block' },
|
|
33
|
+
{ name: 'stylesheet', snippet: 'stylesheet %}\n\t$0\n{% endstylesheet', detail: 'Emit a section stylesheet block' },
|
|
34
|
+
{ name: 'javascript', snippet: 'javascript %}\n\t$0\n{% endjavascript', detail: 'Emit a <script data-candy-script> block' },
|
|
35
|
+
{ name: 'comment', snippet: 'comment %}\n\t$0\n{% endcomment', detail: 'Multi-line unrendered comment block' },
|
|
36
|
+
{ name: 'doc', snippet: 'doc %}\n\t$0\n{% enddoc', detail: 'Template documentation block (stripped from output)' },
|
|
37
|
+
{ name: 'raw', snippet: 'raw %}\n\t$0\n{% endraw', detail: 'Output raw text without evaluating Candy tags' }
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const CANDY_FILTERS = [
|
|
41
|
+
{ name: 'escape', snippet: 'escape', detail: 'HTML-escape special characters (&, <, >, ", \')' },
|
|
42
|
+
{ name: 'escape_once', snippet: 'escape_once', detail: 'HTML-escape without double-escaping existing entities' },
|
|
43
|
+
{ name: 'raw', snippet: 'raw', detail: 'Mark output as trusted HTML (bypass auto-escaping)' },
|
|
44
|
+
{ name: 'money', snippet: 'money', detail: 'Format numeric price using tenant currency settings (e.g. $29.99)' },
|
|
45
|
+
{ name: 'money_with_currency', snippet: 'money_with_currency', detail: 'Format price with currency code (e.g. $29.99 USD)' },
|
|
46
|
+
{ name: 'money_without_currency', snippet: 'money_without_currency', detail: 'Format numeric price without currency symbol (e.g. 29.99)' },
|
|
47
|
+
{ name: 'money_without_trailing_zeros', snippet: 'money_without_trailing_zeros', detail: 'Format price and strip .00 suffix' },
|
|
48
|
+
{ name: 'image_url', snippet: 'image_url: width: ${1:800}', detail: 'Generate responsive CDN image URL with width/height/crop/format' },
|
|
49
|
+
{ name: 'image_tag', snippet: "image_tag: alt: '${1:Image}'", detail: 'Render an HTML <img> tag with lazy loading' },
|
|
50
|
+
{ name: 'asset_url', snippet: 'asset_url', detail: 'Resolve theme static asset path to /_assets/<themeSlug>/<file>' },
|
|
51
|
+
{ name: 'stylesheet_tag', snippet: 'stylesheet_tag', detail: 'Wrap CSS URL in <link rel="stylesheet"> tag' },
|
|
52
|
+
{ name: 'script_tag', snippet: 'script_tag', detail: 'Wrap JS URL in <script defer> tag' },
|
|
53
|
+
{ name: 'default', snippet: "default: '${1:fallback}'", detail: 'Return fallback value when input is nil, false, or empty' },
|
|
54
|
+
{ name: 't', snippet: 't', detail: 'Translate locale key from locales/*.json' },
|
|
55
|
+
{ name: 'default_pagination', snippet: 'default_pagination', detail: 'Render accessible pagination HTML links for paginate object' },
|
|
56
|
+
{ name: 'json', snippet: 'json', detail: 'Serialize value as script-safe JSON' },
|
|
57
|
+
{ name: 'upcase', snippet: 'upcase', detail: 'Convert string to uppercase' },
|
|
58
|
+
{ name: 'downcase', snippet: 'downcase', detail: 'Convert string to lowercase' },
|
|
59
|
+
{ name: 'capitalize', snippet: 'capitalize', detail: 'Capitalize the first character of a string' },
|
|
60
|
+
{ name: 'strip', snippet: 'strip', detail: 'Trim leading and trailing whitespace' },
|
|
61
|
+
{ name: 'strip_html', snippet: 'strip_html', detail: 'Remove all HTML tags from string' },
|
|
62
|
+
{ name: 'newline_to_br', snippet: 'newline_to_br', detail: 'Convert newline characters to <br /> tags' },
|
|
63
|
+
{ name: 'truncate', snippet: 'truncate: ${1:50}', detail: 'Truncate string to N characters' },
|
|
64
|
+
{ name: 'truncatewords', snippet: 'truncatewords: ${1:15}', detail: 'Truncate string to N words' },
|
|
65
|
+
{ name: 'split', snippet: "split: '${1:,}'", detail: 'Split string into array by delimiter' },
|
|
66
|
+
{ name: 'join', snippet: "join: '${1:, }'", detail: 'Join array elements into a string' },
|
|
67
|
+
{ name: 'replace', snippet: "replace: '${1:search}', '${2:replace}'", detail: 'Replace all occurrences of a substring' },
|
|
68
|
+
{ name: 'append', snippet: "append: '${1:suffix}'", detail: 'Append string to the end' },
|
|
69
|
+
{ name: 'prepend', snippet: "prepend: '${1:prefix}'", detail: 'Prepend string to the beginning' },
|
|
70
|
+
{ name: 'handleize', snippet: 'handleize', detail: 'Convert string into URL-safe kebab-case handle' },
|
|
71
|
+
{ name: 'slugify', snippet: 'slugify', detail: 'Convert string into URL-safe slug' },
|
|
72
|
+
{ name: 'url_encode', snippet: 'url_encode', detail: 'Percent-encode URL component' },
|
|
73
|
+
{ name: 'plus', snippet: 'plus: ${1:1}', detail: 'Add number' },
|
|
74
|
+
{ name: 'minus', snippet: 'minus: ${1:1}', detail: 'Subtract number' },
|
|
75
|
+
{ name: 'times', snippet: 'times: ${1:2}', detail: 'Multiply number' },
|
|
76
|
+
{ name: 'divided_by', snippet: 'divided_by: ${1:2}', detail: 'Divide number' },
|
|
77
|
+
{ name: 'round', snippet: 'round: ${1:2}', detail: 'Round number to N decimal places' },
|
|
78
|
+
{ name: 'where', snippet: "where: '${1:property}', ${2:value}", detail: 'Filter array of objects by property value' },
|
|
79
|
+
{ name: 'where_exp', snippet: "where_exp: '${1:item}', '${1:item}.${2:available} == true'", detail: 'Filter array using a safe comparison expression' },
|
|
80
|
+
{ name: 'map', snippet: "map: '${1:property}'", detail: 'Extract property from each object in an array' },
|
|
81
|
+
{ name: 'sort', snippet: "sort: '${1:property}'", detail: 'Sort array of primitives or objects' },
|
|
82
|
+
{ name: 'size', snippet: 'size', detail: 'Return length of string or array' },
|
|
83
|
+
{ name: 'first', snippet: 'first', detail: 'Return first item of array' },
|
|
84
|
+
{ name: 'last', snippet: 'last', detail: 'Return last item of array' },
|
|
85
|
+
{ name: 'date', snippet: "date: '${1:%B %d, %Y}'", detail: 'Format date/timestamp with strftime format' },
|
|
86
|
+
{ name: 'pluralize', snippet: "pluralize: '${1:item}', '${2:items}'", detail: 'Return singular or plural label based on numeric count' }
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const GLOBAL_OBJECTS = {
|
|
90
|
+
shop: ['name', 'description', 'currency', 'currency_symbol', 'domain', 'url', 'logo', 'email'],
|
|
91
|
+
product: ['id', 'title', 'handle', 'slug', 'description', 'price', 'compare_at_price', 'available', 'in_stock', 'inventory_quantity', 'featured_image', 'images', 'variants', 'options', 'vendor', 'type', 'tags', 'url'],
|
|
92
|
+
collection: ['id', 'title', 'handle', 'slug', 'description', 'image', 'products', 'products_count', 'all_products_count', 'url'],
|
|
93
|
+
cart: ['item_count', 'total_price', 'subtotal_price', 'currency', 'items', 'empty'],
|
|
94
|
+
section: ['id', 'type', 'settings', 'blocks', 'block_order'],
|
|
95
|
+
block: ['id', 'type', 'settings', 'candy_attributes', 'shopify_attributes'],
|
|
96
|
+
forloop: ['index', 'index0', 'rindex', 'rindex0', 'first', 'last', 'length', 'parentloop'],
|
|
97
|
+
paginate: ['current_page', 'current_offset', 'items', 'page_size', 'pages', 'parts', 'previous', 'next'],
|
|
98
|
+
request: ['path', 'page_type', 'host', 'locale', 'design_mode'],
|
|
99
|
+
routes: ['root_url', 'all_products_collection_url', 'collections_url', 'cart_url', 'cart_add_url', 'search_url', 'account_login_url', 'account_register_url']
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Extracts `{% schema %}...{% endschema %}` JSON from the active document so we can provide
|
|
104
|
+
* dynamic `section.settings.<id>` and `block.settings.<id>` autocompletion & validation.
|
|
105
|
+
*/
|
|
106
|
+
function parseDocumentSchema(documentText) {
|
|
107
|
+
const match = /\{%-?\s*schema\s*-?%\}([\s\S]*?)\{%-?\s*endschema\s*-?%\}/.exec(documentText);
|
|
108
|
+
if (!match) {
|
|
109
|
+
return { found: false, schema: null, error: null, startOffset: 0 };
|
|
110
|
+
}
|
|
111
|
+
const jsonText = match[1];
|
|
112
|
+
const startOffset = match.index + match[0].indexOf(jsonText);
|
|
113
|
+
try {
|
|
114
|
+
const parsed = JSON.parse(jsonText);
|
|
115
|
+
return { found: true, schema: parsed, error: null, startOffset };
|
|
116
|
+
} catch (err) {
|
|
117
|
+
return { found: true, schema: null, error: err, startOffset };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function validateCandyDocument(document, diagnosticCollection) {
|
|
122
|
+
if (!document || !document.fileName.endsWith('.candy')) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const text = document.getText();
|
|
127
|
+
const diagnostics = [];
|
|
128
|
+
|
|
129
|
+
// 1. Validate {% schema %} JSON syntax if present
|
|
130
|
+
const schemaResult = parseDocumentSchema(text);
|
|
131
|
+
if (schemaResult.found && schemaResult.error) {
|
|
132
|
+
const pos = document.positionAt(schemaResult.startOffset);
|
|
133
|
+
const range = new vscode.Range(pos, pos.translate(0, 20));
|
|
134
|
+
diagnostics.push(
|
|
135
|
+
new vscode.Diagnostic(
|
|
136
|
+
range,
|
|
137
|
+
`Invalid Candy {% schema %} JSON: ${schemaResult.error.message}`,
|
|
138
|
+
vscode.DiagnosticSeverity.Error
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 2. Validate balanced block tags (ignoring comment/raw/schema interiors)
|
|
144
|
+
const stripped = text
|
|
145
|
+
.replace(/\{%-?\s*comment\s*-?%\}[\s\S]*?\{%-?\s*endcomment\s*-?%\}/g, (m) => ' '.repeat(m.length))
|
|
146
|
+
.replace(/\{%-?\s*raw\s*-?%\}[\s\S]*?\{%-?\s*endraw\s*-?%\}/g, (m) => ' '.repeat(m.length))
|
|
147
|
+
.replace(/\{%-?\s*doc\s*-?%\}[\s\S]*?\{%-?\s*enddoc\s*-?%\}/g, (m) => ' '.repeat(m.length))
|
|
148
|
+
.replace(/\{%-?\s*schema\s*-?%\}[\s\S]*?\{%-?\s*endschema\s*-?%\}/g, (m) => ' '.repeat(m.length));
|
|
149
|
+
|
|
150
|
+
const blockPairs = {
|
|
151
|
+
if: 'endif',
|
|
152
|
+
unless: 'endunless',
|
|
153
|
+
case: 'endcase',
|
|
154
|
+
for: 'endfor',
|
|
155
|
+
tablerow: 'endtablerow',
|
|
156
|
+
capture: 'endcapture',
|
|
157
|
+
paginate: 'endpaginate',
|
|
158
|
+
form: 'endform',
|
|
159
|
+
style: 'endstyle',
|
|
160
|
+
stylesheet: 'endstylesheet',
|
|
161
|
+
javascript: 'endjavascript'
|
|
162
|
+
};
|
|
163
|
+
const closeToOpen = {};
|
|
164
|
+
for (const [open, close] of Object.entries(blockPairs)) {
|
|
165
|
+
closeToOpen[close] = open;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const stack = [];
|
|
169
|
+
const tagRegex = /\{%-?\s*([a-zA-Z_][a-zA-Z0-9_]*)\b[\s\S]*?-?%\}/g;
|
|
170
|
+
let match;
|
|
171
|
+
while ((match = tagRegex.exec(stripped)) !== null) {
|
|
172
|
+
const tagName = match[1];
|
|
173
|
+
if (blockPairs[tagName]) {
|
|
174
|
+
stack.push({ tagName, index: match.index, length: match[0].length });
|
|
175
|
+
} else if (closeToOpen[tagName]) {
|
|
176
|
+
const expectedOpen = closeToOpen[tagName];
|
|
177
|
+
const top = stack[stack.length - 1];
|
|
178
|
+
if (!top || top.tagName !== expectedOpen) {
|
|
179
|
+
const startPos = document.positionAt(match.index);
|
|
180
|
+
const endPos = document.positionAt(match.index + match[0].length);
|
|
181
|
+
diagnostics.push(
|
|
182
|
+
new vscode.Diagnostic(
|
|
183
|
+
new vscode.Range(startPos, endPos),
|
|
184
|
+
`Unexpected {% ${tagName} %} without matching {% ${expectedOpen} %}.`,
|
|
185
|
+
vscode.DiagnosticSeverity.Error
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
} else {
|
|
189
|
+
stack.pop();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
for (const unclosed of stack) {
|
|
195
|
+
const startPos = document.positionAt(unclosed.index);
|
|
196
|
+
const endPos = document.positionAt(unclosed.index + unclosed.length);
|
|
197
|
+
diagnostics.push(
|
|
198
|
+
new vscode.Diagnostic(
|
|
199
|
+
new vscode.Range(startPos, endPos),
|
|
200
|
+
`Unclosed {% ${unclosed.tagName} %} block (expected {% ${blockPairs[unclosed.tagName]} %}).`,
|
|
201
|
+
vscode.DiagnosticSeverity.Error
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
diagnosticCollection.set(document.uri, diagnostics);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function activate(context) {
|
|
210
|
+
const diagnosticCollection = vscode.languages.createDiagnosticCollection('candy');
|
|
211
|
+
context.subscriptions.push(diagnosticCollection);
|
|
212
|
+
|
|
213
|
+
if (vscode.window.activeTextEditor) {
|
|
214
|
+
validateCandyDocument(vscode.window.activeTextEditor.document, diagnosticCollection);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
context.subscriptions.push(
|
|
218
|
+
vscode.workspace.onDidOpenTextDocument((doc) => validateCandyDocument(doc, diagnosticCollection)),
|
|
219
|
+
vscode.workspace.onDidChangeTextDocument((e) => validateCandyDocument(e.document, diagnosticCollection)),
|
|
220
|
+
vscode.workspace.onDidCloseTextDocument((doc) => diagnosticCollection.delete(doc.uri))
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// 1. Completion Provider for Candy tags, filters, objects, and dynamic {% schema %} settings
|
|
224
|
+
const completionProvider = vscode.languages.registerCompletionItemProvider(
|
|
225
|
+
'candy',
|
|
226
|
+
{
|
|
227
|
+
provideCompletionItems(document, position) {
|
|
228
|
+
const linePrefix = document.lineAt(position).text.slice(0, position.character);
|
|
229
|
+
|
|
230
|
+
// A. After `|` -> Suggest Candy Filters
|
|
231
|
+
if (/\|\s*[a-zA-Z_]*$/.test(linePrefix)) {
|
|
232
|
+
return CANDY_FILTERS.map((f) => {
|
|
233
|
+
const item = new vscode.CompletionItem(f.name, vscode.CompletionItemKind.Function);
|
|
234
|
+
item.insertText = new vscode.SnippetString(f.snippet);
|
|
235
|
+
item.detail = `(Candy Filter) ${f.detail}`;
|
|
236
|
+
item.documentation = new vscode.MarkdownString(`**\`| ${f.name}\`**\n\n${f.detail}`);
|
|
237
|
+
return item;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// B. After `{%` or `{%-` -> Suggest Candy Tags
|
|
242
|
+
if (/\{%-?\s*[a-zA-Z_]*$/.test(linePrefix)) {
|
|
243
|
+
return CANDY_TAGS.map((t) => {
|
|
244
|
+
const item = new vscode.CompletionItem(t.name, vscode.CompletionItemKind.Keyword);
|
|
245
|
+
item.insertText = new vscode.SnippetString(t.snippet);
|
|
246
|
+
item.detail = `(Candy Tag) ${t.detail}`;
|
|
247
|
+
item.documentation = new vscode.MarkdownString(`**\`{% ${t.name} %}\`**\n\n${t.detail}`);
|
|
248
|
+
return item;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// C. After `section.settings.` -> Suggest settings from current file's {% schema %}
|
|
253
|
+
if (/section\.settings\.[a-zA-Z0-9_-]*$/.test(linePrefix)) {
|
|
254
|
+
const { schema } = parseDocumentSchema(document.getText());
|
|
255
|
+
const settings = Array.isArray(schema?.settings) ? schema.settings : [];
|
|
256
|
+
return settings
|
|
257
|
+
.filter((s) => s && typeof s.id === 'string')
|
|
258
|
+
.map((s) => {
|
|
259
|
+
const item = new vscode.CompletionItem(s.id, vscode.CompletionItemKind.Property);
|
|
260
|
+
item.detail = `(${s.type || 'setting'}) ${s.label || s.id}`;
|
|
261
|
+
item.documentation = new vscode.MarkdownString(
|
|
262
|
+
`**Section Setting \`${s.id}\`**\n- **Type**: \`${s.type}\`\n- **Label**: ${s.label || s.id}\n- **Default**: \`${JSON.stringify(s.default ?? null)}\``
|
|
263
|
+
);
|
|
264
|
+
return item;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// D. After `<object>.` -> Suggest known properties
|
|
269
|
+
const objMatch = /\b(shop|product|collection|cart|section|block|forloop|paginate|request|routes)\.[a-zA-Z0-9_]*$/.exec(
|
|
270
|
+
linePrefix
|
|
271
|
+
);
|
|
272
|
+
if (objMatch) {
|
|
273
|
+
const objName = objMatch[1];
|
|
274
|
+
const props = GLOBAL_OBJECTS[objName] || [];
|
|
275
|
+
return props.map((prop) => {
|
|
276
|
+
const item = new vscode.CompletionItem(prop, vscode.CompletionItemKind.Field);
|
|
277
|
+
item.detail = `${objName}.${prop}`;
|
|
278
|
+
return item;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// E. Inside `{{ ...` or `{% ...` -> Suggest global objects
|
|
283
|
+
if (/(\{\{-?|\{%-?)[^}%]*$/.test(linePrefix)) {
|
|
284
|
+
return Object.keys(GLOBAL_OBJECTS).map((objName) => {
|
|
285
|
+
const item = new vscode.CompletionItem(objName, vscode.CompletionItemKind.Variable);
|
|
286
|
+
item.detail = `Caartzee Candy global object (${objName})`;
|
|
287
|
+
return item;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
'|',
|
|
295
|
+
'.',
|
|
296
|
+
'%',
|
|
297
|
+
' '
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
// 2. Hover Provider for Candy tags, filters, and objects
|
|
301
|
+
const hoverProvider = vscode.languages.registerHoverProvider('candy', {
|
|
302
|
+
provideHover(document, position) {
|
|
303
|
+
const range = document.getWordRangeAtPosition(position, /[a-zA-Z_][a-zA-Z0-9_-]*/);
|
|
304
|
+
if (!range) return null;
|
|
305
|
+
const word = document.getText(range);
|
|
306
|
+
|
|
307
|
+
const filter = CANDY_FILTERS.find((f) => f.name === word);
|
|
308
|
+
if (filter) {
|
|
309
|
+
return new vscode.Hover(
|
|
310
|
+
new vscode.MarkdownString(`### Candy Filter \`| ${filter.name}\`\n\n${filter.detail}`)
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const tag = CANDY_TAGS.find((t) => t.name === word);
|
|
315
|
+
if (tag) {
|
|
316
|
+
return new vscode.Hover(
|
|
317
|
+
new vscode.MarkdownString(`### Candy Tag \`{% ${tag.name} %}\`\n\n${tag.detail}`)
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (GLOBAL_OBJECTS[word]) {
|
|
322
|
+
return new vscode.Hover(
|
|
323
|
+
new vscode.MarkdownString(
|
|
324
|
+
`### Candy Object \`${word}\`\n\nAvailable properties: \`${GLOBAL_OBJECTS[word].join('`, `')}\``
|
|
325
|
+
)
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
context.subscriptions.push(completionProvider, hoverProvider);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function deactivate() {}
|
|
337
|
+
|
|
338
|
+
module.exports = { activate, deactivate };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none">
|
|
2
|
+
<!-- Top-Left Fluted Candy Wrapper Tail -->
|
|
3
|
+
<path d="M8.5 8.5 L2.2 1.8 L5.2 5.8 L1.8 5.2 L5.8 8.2 L1.8 9.2 L8.5 10.5 Z" fill="#F472B6"/>
|
|
4
|
+
<path d="M9.2 9.2 L2.8 2.2 L6.8 3.2 L8.2 1.5 L10.5 8.5 Z" fill="#FB7185"/>
|
|
5
|
+
|
|
6
|
+
<!-- Bottom-Right Fluted Candy Wrapper Tail -->
|
|
7
|
+
<path d="M15.5 15.5 L21.8 22.2 L18.8 18.2 L22.2 18.8 L18.2 15.8 L22.2 14.8 L15.5 13.5 Z" fill="#C084FC"/>
|
|
8
|
+
<path d="M14.8 14.8 L21.2 21.8 L17.2 20.8 L15.8 22.5 L13.5 15.5 Z" fill="#F472B6"/>
|
|
9
|
+
|
|
10
|
+
<!-- Wrapper Twist Knots -->
|
|
11
|
+
<ellipse cx="7.4" cy="7.4" rx="2.3" ry="1.3" transform="rotate(-45 7.4 7.4)" fill="#FBCFE8"/>
|
|
12
|
+
<ellipse cx="16.6" cy="16.6" rx="2.3" ry="1.3" transform="rotate(-45 16.6 16.6)" fill="#E9D5FF"/>
|
|
13
|
+
|
|
14
|
+
<!-- Main Round Candy Body -->
|
|
15
|
+
<circle cx="12" cy="12" r="6.6" fill="#EC4899" stroke="#FDF2F8" stroke-width="1.1"/>
|
|
16
|
+
|
|
17
|
+
<!-- Bold White Peppermint Candy Stripes -->
|
|
18
|
+
<path d="M7.6 10.2 C9.5 8.2, 12.8 8.2, 14.8 10.2" stroke="#FFFFFF" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
19
|
+
<path d="M9.2 13.8 C11.2 15.8, 14.5 15.8, 16.4 13.8" stroke="#FCE7F3" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
20
|
+
|
|
21
|
+
<!-- Candy Center Swirl / Shine -->
|
|
22
|
+
<circle cx="10.2" cy="9.8" r="1.1" fill="#FFFFFF"/>
|
|
23
|
+
</svg>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none">
|
|
2
|
+
<!-- Top-Left Fluted Candy Wrapper Tail -->
|
|
3
|
+
<path d="M8.5 8.5 L2.2 1.8 L5.2 5.8 L1.8 5.2 L5.8 8.2 L1.8 9.2 L8.5 10.5 Z" fill="#DB2777"/>
|
|
4
|
+
<path d="M9.2 9.2 L2.8 2.2 L6.8 3.2 L8.2 1.5 L10.5 8.5 Z" fill="#E11D48"/>
|
|
5
|
+
|
|
6
|
+
<!-- Bottom-Right Fluted Candy Wrapper Tail -->
|
|
7
|
+
<path d="M15.5 15.5 L21.8 22.2 L18.8 18.2 L22.2 18.8 L18.2 15.8 L22.2 14.8 L15.5 13.5 Z" fill="#9333EA"/>
|
|
8
|
+
<path d="M14.8 14.8 L21.2 21.8 L17.2 20.8 L15.8 22.5 L13.5 15.5 Z" fill="#DB2777"/>
|
|
9
|
+
|
|
10
|
+
<!-- Wrapper Twist Knots -->
|
|
11
|
+
<ellipse cx="7.4" cy="7.4" rx="2.3" ry="1.3" transform="rotate(-45 7.4 7.4)" fill="#F472B6"/>
|
|
12
|
+
<ellipse cx="16.6" cy="16.6" rx="2.3" ry="1.3" transform="rotate(-45 16.6 16.6)" fill="#C084FC"/>
|
|
13
|
+
|
|
14
|
+
<!-- Main Round Candy Body -->
|
|
15
|
+
<circle cx="12" cy="12" r="6.6" fill="#DB2777" stroke="#FFFFFF" stroke-width="1.1"/>
|
|
16
|
+
|
|
17
|
+
<!-- Bold White Peppermint Candy Stripes -->
|
|
18
|
+
<path d="M7.6 10.2 C9.5 8.2, 12.8 8.2, 14.8 10.2" stroke="#FFFFFF" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
19
|
+
<path d="M9.2 13.8 C11.2 15.8, 14.5 15.8, 16.4 13.8" stroke="#FCE7F3" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
20
|
+
|
|
21
|
+
<!-- Candy Center Swirl / Shine -->
|
|
22
|
+
<circle cx="10.2" cy="9.8" r="1.1" fill="#FFFFFF"/>
|
|
23
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none">
|
|
2
|
+
<!-- Top-Left Fluted Candy Wrapper Tail -->
|
|
3
|
+
<path d="M8.5 8.5 L2.2 1.8 L5.2 5.8 L1.8 5.2 L5.8 8.2 L1.8 9.2 L8.5 10.5 Z" fill="#F472B6"/>
|
|
4
|
+
<path d="M9.2 9.2 L2.8 2.2 L6.8 3.2 L8.2 1.5 L10.5 8.5 Z" fill="#FB7185"/>
|
|
5
|
+
|
|
6
|
+
<!-- Bottom-Right Fluted Candy Wrapper Tail -->
|
|
7
|
+
<path d="M15.5 15.5 L21.8 22.2 L18.8 18.2 L22.2 18.8 L18.2 15.8 L22.2 14.8 L15.5 13.5 Z" fill="#C084FC"/>
|
|
8
|
+
<path d="M14.8 14.8 L21.2 21.8 L17.2 20.8 L15.8 22.5 L13.5 15.5 Z" fill="#F472B6"/>
|
|
9
|
+
|
|
10
|
+
<!-- Wrapper Twist Knots -->
|
|
11
|
+
<ellipse cx="7.4" cy="7.4" rx="2.3" ry="1.3" transform="rotate(-45 7.4 7.4)" fill="#FBCFE8"/>
|
|
12
|
+
<ellipse cx="16.6" cy="16.6" rx="2.3" ry="1.3" transform="rotate(-45 16.6 16.6)" fill="#E9D5FF"/>
|
|
13
|
+
|
|
14
|
+
<!-- Main Round Candy Body -->
|
|
15
|
+
<circle cx="12" cy="12" r="6.6" fill="#EC4899" stroke="#FDF2F8" stroke-width="1.1"/>
|
|
16
|
+
|
|
17
|
+
<!-- Bold White Peppermint Candy Stripes -->
|
|
18
|
+
<path d="M7.6 10.2 C9.5 8.2, 12.8 8.2, 14.8 10.2" stroke="#FFFFFF" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
19
|
+
<path d="M9.2 13.8 C11.2 15.8, 14.5 15.8, 16.4 13.8" stroke="#FCE7F3" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
20
|
+
|
|
21
|
+
<!-- Candy Center Swirl / Shine -->
|
|
22
|
+
<circle cx="10.2" cy="9.8" r="1.1" fill="#FFFFFF"/>
|
|
23
|
+
</svg>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none">
|
|
2
|
+
<!-- Top-Left Fluted Candy Wrapper Tail -->
|
|
3
|
+
<path d="M8.5 8.5 L2.2 1.8 L5.2 5.8 L1.8 5.2 L5.8 8.2 L1.8 9.2 L8.5 10.5 Z" fill="#DB2777"/>
|
|
4
|
+
<path d="M9.2 9.2 L2.8 2.2 L6.8 3.2 L8.2 1.5 L10.5 8.5 Z" fill="#E11D48"/>
|
|
5
|
+
|
|
6
|
+
<!-- Bottom-Right Fluted Candy Wrapper Tail -->
|
|
7
|
+
<path d="M15.5 15.5 L21.8 22.2 L18.8 18.2 L22.2 18.8 L18.2 15.8 L22.2 14.8 L15.5 13.5 Z" fill="#9333EA"/>
|
|
8
|
+
<path d="M14.8 14.8 L21.2 21.8 L17.2 20.8 L15.8 22.5 L13.5 15.5 Z" fill="#DB2777"/>
|
|
9
|
+
|
|
10
|
+
<!-- Wrapper Twist Knots -->
|
|
11
|
+
<ellipse cx="7.4" cy="7.4" rx="2.3" ry="1.3" transform="rotate(-45 7.4 7.4)" fill="#F472B6"/>
|
|
12
|
+
<ellipse cx="16.6" cy="16.6" rx="2.3" ry="1.3" transform="rotate(-45 16.6 16.6)" fill="#C084FC"/>
|
|
13
|
+
|
|
14
|
+
<!-- Main Round Candy Body -->
|
|
15
|
+
<circle cx="12" cy="12" r="6.6" fill="#DB2777" stroke="#FFFFFF" stroke-width="1.1"/>
|
|
16
|
+
|
|
17
|
+
<!-- Bold White Peppermint Candy Stripes -->
|
|
18
|
+
<path d="M7.6 10.2 C9.5 8.2, 12.8 8.2, 14.8 10.2" stroke="#FFFFFF" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
19
|
+
<path d="M9.2 13.8 C11.2 15.8, 14.5 15.8, 16.4 13.8" stroke="#FCE7F3" stroke-width="1.9" stroke-linecap="round" fill="none"/>
|
|
20
|
+
|
|
21
|
+
<!-- Candy Center Swirl / Shine -->
|
|
22
|
+
<circle cx="10.2" cy="9.8" r="1.1" fill="#FFFFFF"/>
|
|
23
|
+
</svg>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"comments": {
|
|
3
|
+
"blockComment": ["{% comment %}", "{% endcomment %}"]
|
|
4
|
+
},
|
|
5
|
+
"brackets": [
|
|
6
|
+
["{%", "%}"],
|
|
7
|
+
["{%-", "-%}"],
|
|
8
|
+
["{{", "}}"],
|
|
9
|
+
["{{-", "-}}"],
|
|
10
|
+
["<!--", "-->"],
|
|
11
|
+
["<", ">"],
|
|
12
|
+
["{", "}"],
|
|
13
|
+
["[", "]"],
|
|
14
|
+
["(", ")"]
|
|
15
|
+
],
|
|
16
|
+
"autoClosingPairs": [
|
|
17
|
+
{ "open": "{{ ", "close": " }}" },
|
|
18
|
+
{ "open": "{{", "close": "}}" },
|
|
19
|
+
{ "open": "{% ", "close": " %}" },
|
|
20
|
+
{ "open": "{%", "close": "%}" },
|
|
21
|
+
{ "open": "{", "close": "}" },
|
|
22
|
+
{ "open": "[", "close": "]" },
|
|
23
|
+
{ "open": "(", "close": ")" },
|
|
24
|
+
{ "open": "\"", "close": "\"", "notIn": ["string"] },
|
|
25
|
+
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
|
|
26
|
+
{ "open": "<!--", "close": "-->", "notIn": ["comment", "string"] }
|
|
27
|
+
],
|
|
28
|
+
"surroundingPairs": [
|
|
29
|
+
["{", "}"],
|
|
30
|
+
["[", "]"],
|
|
31
|
+
["(", ")"],
|
|
32
|
+
["\"", "\""],
|
|
33
|
+
["'", "'"],
|
|
34
|
+
["<", ">"]
|
|
35
|
+
],
|
|
36
|
+
"folding": {
|
|
37
|
+
"markers": {
|
|
38
|
+
"start": "^\\s*\\{%-?\\s*(if|unless|case|for|tablerow|capture|paginate|form|schema|style|stylesheet|javascript|comment|doc|raw)\\b.*-?%\\}",
|
|
39
|
+
"end": "^\\s*\\{%-?\\s*end(if|unless|case|for|tablerow|capture|paginate|form|schema|style|stylesheet|javascript|comment|doc|raw)\\b.*-?%\\}"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"indentationRules": {
|
|
43
|
+
"increaseIndentPattern": "^\\s*\\{%-?\\s*(if|elsif|else|unless|case|when|for|tablerow|capture|paginate|form|schema|style|stylesheet|javascript)\\b(?!.*\\{%-?\\s*end\\1\\b).*-?%\\}\\s*$",
|
|
44
|
+
"decreaseIndentPattern": "^\\s*\\{%-?\\s*(elsif|else|when|end(?:if|unless|case|for|tablerow|capture|paginate|form|schema|style|stylesheet|javascript))\\b.*-?%\\}"
|
|
45
|
+
},
|
|
46
|
+
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\$\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\s]+)"
|
|
47
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "candy-language-support",
|
|
3
|
+
"displayName": "Candy Language Support (Caartzee Themes)",
|
|
4
|
+
"description": "Official syntax highlighting, embedded schema JSON/CSS/JS grammar, snippets, live diagnostics, and IntelliSense for Caartzee .candy storefront templates.",
|
|
5
|
+
"version": "1.2.0",
|
|
6
|
+
"publisher": "caartzee",
|
|
7
|
+
"icon": "icons/candy-logo.png",
|
|
8
|
+
"galleryBanner": {
|
|
9
|
+
"color": "#1c102e",
|
|
10
|
+
"theme": "dark"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"vscode": "^1.75.0"
|
|
14
|
+
},
|
|
15
|
+
"categories": [
|
|
16
|
+
"Programming Languages",
|
|
17
|
+
"Snippets",
|
|
18
|
+
"Linters"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"candy",
|
|
22
|
+
"caartzee",
|
|
23
|
+
"liquid",
|
|
24
|
+
"theme",
|
|
25
|
+
"template",
|
|
26
|
+
"storefront"
|
|
27
|
+
],
|
|
28
|
+
"activationEvents": [
|
|
29
|
+
"onLanguage:candy",
|
|
30
|
+
"workspaceContains:**/*.candy",
|
|
31
|
+
"workspaceContains:**/candy.config.json"
|
|
32
|
+
],
|
|
33
|
+
"main": "./extension.js",
|
|
34
|
+
"contributes": {
|
|
35
|
+
"languages": [
|
|
36
|
+
{
|
|
37
|
+
"id": "candy",
|
|
38
|
+
"aliases": [
|
|
39
|
+
"Candy",
|
|
40
|
+
"Candy Template",
|
|
41
|
+
"Caartzee Candy",
|
|
42
|
+
"candy"
|
|
43
|
+
],
|
|
44
|
+
"extensions": [
|
|
45
|
+
".candy"
|
|
46
|
+
],
|
|
47
|
+
"configuration": "./language-configuration.json",
|
|
48
|
+
"icon": {
|
|
49
|
+
"light": "./icons/candy-sweet-light.svg",
|
|
50
|
+
"dark": "./icons/candy-sweet-dark.svg"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"grammars": [
|
|
55
|
+
{
|
|
56
|
+
"language": "candy",
|
|
57
|
+
"scopeName": "text.html.candy",
|
|
58
|
+
"path": "./syntaxes/candy.tmLanguage.json",
|
|
59
|
+
"embeddedLanguages": {
|
|
60
|
+
"meta.embedded.block.json.candy": "json",
|
|
61
|
+
"meta.embedded.block.css.candy": "css",
|
|
62
|
+
"meta.embedded.block.javascript.candy": "javascript"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"snippets": [
|
|
67
|
+
{
|
|
68
|
+
"language": "candy",
|
|
69
|
+
"path": "./snippets/candy.code-snippets"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"language": "liquid",
|
|
73
|
+
"path": "./snippets/candy.code-snippets"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"language": "html",
|
|
77
|
+
"path": "./snippets/candy.code-snippets"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"jsonValidation": [
|
|
81
|
+
{
|
|
82
|
+
"fileMatch": "candy.config.json",
|
|
83
|
+
"url": "./schemas/candy-config.schema.json"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"fileMatch": "**/schemas/settings_schema.json",
|
|
87
|
+
"url": "./schemas/candy-settings.schema.json"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"configurationDefaults": {
|
|
91
|
+
"[candy]": {
|
|
92
|
+
"editor.tabSize": 2,
|
|
93
|
+
"editor.insertSpaces": true,
|
|
94
|
+
"editor.bracketPairColorization.enabled": true,
|
|
95
|
+
"editor.quickSuggestions": {
|
|
96
|
+
"other": true,
|
|
97
|
+
"comments": false,
|
|
98
|
+
"strings": true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Caartzee Candy Theme Configuration (candy.config.json)",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": ["engine", "slug", "name", "version"],
|
|
6
|
+
"properties": {
|
|
7
|
+
"engine": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"enum": ["candy"],
|
|
10
|
+
"description": "Theme template engine identifier (must be 'candy')."
|
|
11
|
+
},
|
|
12
|
+
"candyVersion": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"default": "1.0.0",
|
|
15
|
+
"description": "Candy language specification version."
|
|
16
|
+
},
|
|
17
|
+
"slug": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"pattern": "^[a-z0-9-]+$",
|
|
20
|
+
"description": "Unique kebab-case identifier for the theme."
|
|
21
|
+
},
|
|
22
|
+
"name": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Human-readable display name of the theme."
|
|
25
|
+
},
|
|
26
|
+
"version": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "Semantic version of the theme (e.g. 1.0.0)."
|
|
29
|
+
},
|
|
30
|
+
"description": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Short summary of the theme."
|
|
33
|
+
},
|
|
34
|
+
"author": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Theme author or studio name."
|
|
37
|
+
},
|
|
38
|
+
"defaultLayout": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"default": "theme",
|
|
41
|
+
"description": "Default layout template name inside layout/<name>.candy."
|
|
42
|
+
},
|
|
43
|
+
"directories": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {
|
|
46
|
+
"layout": { "type": "string", "default": "layout" },
|
|
47
|
+
"templates": { "type": "string", "default": "templates" },
|
|
48
|
+
"sections": { "type": "string", "default": "sections" },
|
|
49
|
+
"snippets": { "type": "string", "default": "snippets" },
|
|
50
|
+
"schemas": { "type": "string", "default": "schemas" },
|
|
51
|
+
"assets": { "type": "string", "default": "assets" },
|
|
52
|
+
"locales": { "type": "string", "default": "locales" }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|