From 8fa25352ca7da9143d1ace31c0da1b49545f0573 Mon Sep 17 00:00:00 2001 From: Matthew Dean Date: Wed, 2 Sep 2026 13:48:38 -0700 Subject: [PATCH 1/2] feat: gate compile options by Less version Render the Options panel from a per-version descriptor list and send only the options valid for the active version, under that version's name: - < 3.7.0: strictMath switch; >= 3.7.0: math select (less.js 76c10345, v3.7.0) - < 5.0.0: strictUnits switch, deprecated compress switch; >= 5.0.0: unitMode select, collapseNesting switch (5.0.0-alpha options.js) The store keeps every key (URL hash unchanged); renderOptions() filters. --- src/App.vue | 39 +++++++++++++++---------------- src/options.ts | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 src/options.ts diff --git a/src/App.vue b/src/App.vue index 10e7e38..4c58d52 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,19 +6,18 @@ import Editor from '@components/Editor.vue' import Layout from '@components/Layout.vue' import Select from '@components/Select.vue' import { Switch } from '@headlessui/vue' - -const mathOptions = ['always', 'parens-division', 'parens'].map(value => ({ value })) +import { defaultStore, supportedOptions, renderOptions, type OptionStore } from './options' let input = $ref(LESS_DATA) let output = $ref('') let errorMessage = $ref('') let hash = $ref('') -let store: Less.Options & { activeVersion: string } = reactive({ +let store: OptionStore & { activeVersion: string } = reactive({ activeVersion: '4.x', - math: 'parens-division', - strictUnits: false + ...defaultStore }) let loadingLessJS = $ref(false) +const options = $computed(() => supportedOptions(store.activeVersion)) const serialize = () => { const newHash = '#' + utoa(JSON.stringify({ @@ -29,8 +28,7 @@ const serialize = () => { } const updateVue = () => { - const { math, strictUnits } = store - window.less.render(input, { math, strictUnits }, (error, result) => { + window.less.render(input, renderOptions(store, store.activeVersion), (error, result) => { if (error) { errorMessage = error.message output = '' @@ -80,18 +78,21 @@ onMounted(() => {