LoadingSpinner Tapestry

Hello dear community,

I am in the process of adding a LoadingSpinner with Tapestry5. However, I can’t get the LoadingSpinner to run on the click event. I can show/hide the LoadingSpinner via the browser console, but my browser does not respond to the Javascript onClick command when I click on the event link. I have also tried to switch to JQuery but unfortunately in vain. When executing the method manually, everything works perfectly. Hiding via the callback works perfectly.

Does anyone know what the problem could be? How can I execute the method loadSpinner(1) when executing the event link?

<a t:type="eventlink" t:zone="appMaintenanceZone" name="reindexArticle" event="reindexArticle" onclick="showSpinner(0)">Update</a>

<t:zone t:id="appMaintenanceZone" id="appMaintenanceZone" t:update="show">

@OnEvent("reindexArticle")
    void reindexAricle()
    {
        if (request.isXHR()) {

            //TODO: execute $('#loadSpinnerDiv1').show(); on appMaintenanceZone

            articleService.reindex();
            
            ajaxResponseRenderer.addRender("appMaintenanceZone", appMaintenanceZone)
                .addCallback((JavaScriptCallback) javascriptSupport -> {
                    javascriptSupport.addScript("$('#loadSpinnerDiv1').hide();");
                });
        }
    }
</t:zone>

Getting The HTML Source Code from Javascript Function , [closed]

below code embeds google trends results to test.php html page, but when you check the source code of test.php page, it will shows the javscript code below.

Instead of this I want to get the html code from the function trends.embed.renderExploreWidget and display it on test.php page. So that I don’t have to deal with CORS errors when I try to modify it.

How is this possible ?

<script type="text/javascript" src="https://ssl.gstatic.com/trends_nrtr/3700_RC01/embed_loader.js"></script>
<script type="text/javascript">
trends.embed.renderExploreWidget
("RELATED_QUERIES",
{"comparisonItem":[{"keyword":"cars","geo":"TR","time":"now 7-d"}],"category":0,"property":""},
{"exploreQuery":"date=now%207-d&geo=TR&q=ti%C5%9F%C3%B6rt",
"guestPath":"https://trends.google.com:443/trends/embed/"});
 </script>

generate dynamic metadata in nextjs and sanity.io

I have used the following approach to generate metadata but its not working. not throwing any error
Its returning the default meta data that i have set in layout.tsx
I am using nextjs and sanity.io

get data function


async function getData(slug: string) {
    const query =
        `*[_type=='post' && slug.current=="${slug}"]{
        title,
        "currentSlug": slug.current,
        shortdescription,
        body,
        author,
        mainImage,
        "categories":categories[]->title,
        "tags":tags[]->title,
        metaTitle,
        metaDescription,
        publishedAt
    }[0]`;
    const result: Post = await client.fetch(query, { revalidate: 60 });
    return result;
}

metadata function

export async function generateMetaData({ params }: { params: { slug: string } }, parent: ResolvingMetadata): Promise<Metadata> {

    const metadata = await getData(params.slug);
    const previousImages = (await parent).openGraph?.images || [];

    console.log(metadata.metaTitle);
    return {
        title: metadata.metaTitle,
        description: metadata.metaDescription,
        openGraph: {
            images: [urlFor(metadata.mainImage).url(), ...previousImages]
        }
    }
}

How can i solve the issue. Thanks

i have tried the below code

export async function generateMetaData({ params }: { params: { slug: string } }, parent: ResolvingMetadata): Promise<Metadata> {

    const metadata = await getData(params.slug);
    const previousImages = (await parent).openGraph?.images || [];

    console.log(metadata.metaTitle);
    return {
        title: metadata.metaTitle,
        description: metadata.metaDescription,
        openGraph: {
            images: [urlFor(metadata.mainImage).url(), ...previousImages]
        }
    }
}

i am expecting the result in browser in form of meta title, description and opengraph image

React-Native Event Listener not being unregistered when you navigate to another screen

I am a React developer and this is my first time dealing with react-native, I have this annoying problem I’ve been stuck for 2 days.

I have this component:

imports

const OrderDetails = ({route}) => {
  const {OrderNumber} = route.params;
  const [items, setItems] = useState(null);
  const navigation = useNavigation();

   useEffect(() => {
    const fetchItemDetails = async () => {
      try {
        const response = await axios.get(
          `http://192.168.1.85:5000/orders/${OrderNumber}`,
        );
        setItems(response.data);
        const handleScannerStatus = data => {
          onBarcodeScan(data.data, response.data.items);
        };

        RegisterScanner(handleScannerStatus);
      } catch (error) {
        console.log('error fetching order');
      }
    };
    fetchItemDetails();

    return () => {
      console.log('component unmounted');
      UnregisterScanner();
    };
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [OrderNumber]);
  const onBarcodeScan = async (barcode, items) => {
    console.log("Scanning barcode from OrderDetails");
    const matchedProduct = items.find(item => barcode === item.tag);
    if (matchedProduct.Type === 'kit') {
      navigation.navigate('KitDetails', {
        OrderNumber,
        kit: matchedProduct,
      });
    } 
  };

  return (my jsx)
};

const styles = {...mystyles}
export default OrderDetails;

this component basically fetches the order and registers an event that listens for an emit my native module sends and whenever it finds an item in the order that is a kit, we get navigated to the kitDetails component, which looks like this:

improts


const KitDetailsScreen = ({route}) => {
  const {OrderNumber, kit} = route.params;

  useEffect(() => {
    let handleScannerStatus = data => {
      console.log('Logging Barcode From KitDetails');
    };

    RegisterScanner(handleScannerStatus);

    return () => {
      console.log('unregister here');
      UnregisterScanner();
    };
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  const tableHead = ['SKU', 'Fulfilled'];
  const tableData = kit.items.map(orderItem => [
    orderItem.sku,
    `${orderItem.Fulfilled}`,
  ]);

  return (jsx);
};

const styles = {...}
export default KitDetailsScreen;

Also I don’t think it will matter, but here is the Event Listener as well:

import {NativeEventEmitter, NativeModules} from 'react-native';

const {BarcodeScannerModule} = NativeModules;
const eventEmitter = new NativeEventEmitter(BarcodeScannerModule);

export const RegisterScanner = handleScannerStatus => {
  eventEmitter.addListener('onBarcodeScanned', handleScannerStatus);

  BarcodeScannerModule.registerScannerStatusListener();
};

export const UnregisterScanner = () =>
  BarcodeScannerModule.unregisterScannerStatusListener();

The two Screens look very similar, but that is besides the point. The problem here is, whenever I navigate to the kitDetails, I still see the console.logs from the OrderDetails, I want whenever I navigate to kitDetails the event to Unregister and for it to only be available in the kitDetails, but navigation works in a weird way that it doesn’t do that.

When I start scanning inside my kitDetails component, this is the output:

 LOG  Logging Barcode From OrderDetails
 LOG  Logging Barcode From KitDetails
 LOG  Logging Barcode From OrderDetails
 LOG  Logging Barcode From KitDetails
 LOG  Logging Barcode From OrderDetails
 LOG  Logging Barcode From KitDetails

instead it should only show the KitDetails log.
Maybe due to the fact I am new to react-native and I am missing something or don’t exactly understand how the flow works, if you can give me some pointers that would be nice.
I can provide my native module code as well if needed.

The things I tried and didn’t work are:

  1. switching views inside the same component but that doesnt really work for my case.
  2. Unregistering right before the navigation switch.
  3. Knowing the fact that unmount is asynchronous, I tried adding a setTimeout to the registering inside kitDetails, but still was able to see the console log of both components.
    Thanks for your attention.

AlphaNumeric Sorting Typescript

Input -> const s = [‘2.1.1.a’, ‘2.1.a’, ‘2.1.1.d’, ‘A2.2’, ‘A2.1′, 2.1.1.c’, ‘2.1.b’, ‘2.1.1.b’]

Expected out put after sort -> const s = [‘2.1.a’, ‘2.1.b’, ‘2.1.1.a’, ‘2.1.1.b’, ‘2.1.1.c’, ‘2.1.1.d’, ‘A2.1’, ‘A2.2’]

out put after sort using below methods -> const s = [‘2.1.b’, ‘2.1.a’, ‘2.1.1.d’, ‘2.1.1.c’, ‘2.1.1.b’ , ‘2.1.1.a’, , ‘A2.1’, ‘A2.2’]

below are my angular methods I tried to sortto get the output , can some one tell me what is the wrong with this code

private REGEXP_SPECIAL_CHAR = /^[A-Za-z]d$/;

bubbleSort(collection: any[], property: string = 'code'): any[] {
        let memo = null;

        if (!collection.length) { return collection; }

        for (let outer = 0; outer < collection.length; outer++) {
            for (let inner = 0; inner < collection.length; inner++) {
                if (this.compare(collection[outer][property], collection[inner][property]) === -1) {
                    memo = collection[outer];
                    collection[outer] = collection[inner];
                    collection[inner] = memo;
                }
            }
        }

        return collection;
    }
    private compare(v: any, w: any): number {
        const vCollection = v.split('.');
        const wCollection = w.split('.');
        const depth = Math.min(vCollection.length, wCollection.length);
        let res = 0;

        for (let i = 0; i < depth; i++) {
            const vElement = vCollection[i];
            const wElement = wCollection[i];
            const shouldCompareNumbers = !isNaN(Number(vElement)) && !isNaN(Number(wElement));
            const shouldCompareChars = this.isSpecialSymbol(vElement, wElement) || (!isNaN(Number(vElement)) && !isNaN(Number(wElement)));

            if (shouldCompareNumbers) {
                if (Number(vElement) < Number(wElement)) {
                    res = -1;
                    break;
                } else if (Number(vElement) > Number(wElement)) {
                    res = 1;
                    break;
                }
            } else if (shouldCompareChars) {
                if (vElement < wElement) {
                    res = -1;
                    break;
                } else if (vElement > wElement) {
                    res = 1;
                    break;
                }
            } else {
                if (vElement < wElement) {
                    res = 1;
                    break;
                } else if (vElement > wElement) {
                    res = -1;
                    break;
                }
            }
        }

        if (res === 0) {
            // check depth
            if (vCollection.length > wCollection.length) {
                res = 1;
            } else if (vCollection.length < wCollection.length) {
                res = -1;
            } else {
                res = 0;
            }
        }
        return res;
    }

    private isSpecialSymbol(v: string, w: string): boolean {
        return this.REGEXP_SPECIAL_CHAR.test(v) || this.REGEXP_SPECIAL_CHAR.test(w);
    }

Loading scripts dynamically fails but loading directly works

I am trying to load js scripts when needed. I wrote a function that returns a promise when it resolves and called the function with the script URLs. The scripts load sequentially. Why am I getting these errors:

VM4599 monacoManipulate.js:1 Uncaught ReferenceError: monaco is not defined at

loader.js:657 GET https://example.com/vs/language/typescript/tsMode.js net::ERR_ABORTED 404

Refused to execute script from 'https://example.com/vs/language/typescript/tsMode.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

When I load the same scripts in the same order directly on head the code works fine. Where did i go wrong when dynamically loading the scripts?

WORKS:

<head>
  <link rel="stylesheet" data-name="vs/editor/editor.main" href="/monaco-editor/min/vs/editor/editor.main.css" />

  <script defer>
    var require = {
      paths: {
        vs: '/monaco-editor/min/vs'
      }
    };
  </script>

  <script src="/monaco-editor/min/vs/loader.js"></script>
  <script src="/monaco-editor/min/vs/editor/editor.main.nls.js"></script>
  <script src="/monaco-editor/min/vs/editor/editor.main.js"></script>
</head>

DOESN”T WORK:

function loadResource(url, callback) {
  return new Promise(function(resolve, reject) {
      var element;
      if (url.endsWith('.js')) {
        element = document.createElement("script");
        element.type = "text/javascript";
        element.src = url;
      } else if (url.endsWith('.css')) {
        element = document.createElement("link");
        element.rel = "stylesheet";
        element.href = url;
        element.type = "text/css";
        if (url === '/monaco-editor/min/vs/editor/editor.main.css') {
          element.dataset.name = "vs/editor/editor.main";
        }
      } else {
        reject(new Error('Unsupported file type ' + url));
        return;
      }

      element.onload = () => {
        if (typeof callback === 'function') {
          resolve(callback());
        } else {
          resolve();
        }
      };
      element.onerror = reject;

      document.getElementsByTagName("head")[0].appendChild(element);
    })
    .catch(function(error) {
      console.error("The resource failed to load:", error);
    });
}

const monaco_css = "/monaco-editor/min/vs/editor/editor.main.css";
const monaco_script = "/monaco-editor/min/vs/loader.js";
const monaco_i18n_script = "/monaco-editor/min/vs/editor/editor.main.nls.js";
const monaco_main_script = "/monaco-editor/min/vs/editor/editor.main.js";
const monaco_manipulate = "/js/users/monacoManipulate.js"

loadResource(monaco_css)
  .then(() => loadResource(monaco_script))
  .then(() => loadResource(monaco_i18n_script))
  .then(() => loadResource(monaco_main_script))
  .then(() => loadResource(monaco_manipulate))
  .then(() => {
    require.config({
      paths: {
        'vs': '/monaco-editor/min/vs'
      }
    });
    require(['vs/editor/editor.main'], function() {
      console.log("Monaco loaded")
    });
  })
  .catch((error) => {
    console.error("Some resources failed to load:", error);
  });

NextJS API to export data array as CSV

I have a simple array of data I would like to export as CSV using a NextJS api route. So I tried this:

import { captureException } from '@sentry/nextjs';
import { NextResponse } from 'next/server';
import { parse } from 'json2csv';

export const fetchCache = 'force-no-store';
export const revalidate = 0;
export const dynamic = 'force-dynamic';

export async function GET(req: Request) {
  const { emailEventId, token } = await req.json();

  try {
    // Fetch or generate your data here. Example:
    const data = [
      { id: 1, name: 'Alice', email: '[email protected]' },
      { id: 2, name: 'Bob', email: '[email protected]' }
    ];

    const csv = parse(data, { fields: ['id', 'name', 'email'] });

    return new Response(csv, {
      status: 200,
      headers: {
        'Content-Type': `text/csv`,
        'Content-Disposition': `attachment; filename="export.csv"`,
      },
    })
  } catch (error) {
    captureException(error);
    return NextResponse.json({});
  }
}

But it results in this: SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>)

Any ideas how to export a csv from a nextjs 13 api route?

angular build not successful

I am getting this error on running ng build

./node_modules/webpack-dev-server/client/index.js?protocol=auto%3A&username=&password=&hostname=0.0.0.0&port=0&pathname=%2Fng-cli-ws&logging=info&overlay=%7B%22errors%22%3Atrue%2C%22warnings%22%3Afalse%2C%22runtimeErrors%22%3Afalse%7D&reconnect=10&hot=false&live-reload=true – Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/tools/babel/webpack-loader.js):
Error: EACCES: permission denied, open ‘/app/.angular/cache/16.2.14/babel-webpack/8c4089325a41d7e6a0109ed788ace5297542e2aebbb21b82dfcf62b3aea46039.json’

There are 2 errors – build failed and unable to access file. I dont understand are they related or not? The file does not even exist they why is angular trying to access it 8c4089325a41d7e6a0109ed788ace5297542e2aebbb21b82dfcf62b3aea46039.json ? How can I fix the other error as well related to webpack-loader.js?

following is the environment info.
node v20.12.2
npm v10.5.0
ng v16.2.12

Java Script not working on Livewire component

I am creating a user register page using laravel livewire. But the js that I use to validate the password field (Show requirement for correct password)is not working

what I did was by default and if requirements notmet password requirements shows in red text, if password meets each requirement it shows in green

Password field + popup hint view

<div x-data="{ showPasswordTip: false }">
                        <div x-show="showPasswordTip"
                            class="absolute top-72 z-50 bg-gray-200 text-gray-700 px-4 py-2 rounded-lg text-sm mt-1 shadow-md">
                            <div id="simpleCheck" class="flex font-semibold">
                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"
                                    class="w-5 h-5 mr-1">
                                    <path fill-rule="evenodd"
                                        d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z"
                                        clip-rule="evenodd" />
                                </svg>
                                1 small letter minimum
                            </div>
                            <div id="capitalCheck" class="flex font-semibold">
                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"
                                    class="w-5 h-5 mr-1">
                                    <path fill-rule="evenodd"
                                        d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z"
                                        clip-rule="evenodd" />
                                </svg>
                                1 capital letter minimum
                            </div>
                            <div id="numberCheck" class="flex font-semibold">
                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"
                                    class="w-5 h-5 mr-1">
                                    <path fill-rule="evenodd"
                                        d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z"
                                        clip-rule="evenodd" />
                                </svg>
                                1 number minimum
                            </div>
                            <div id="specialCheck" class="flex font-semibold">
                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"
                                    class="w-5 h-5 mr-1">
                                    <path fill-rule="evenodd"
                                        d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z"
                                        clip-rule="evenodd" />
                                </svg>
                                1 special character minimum
                            </div>
                            <div id="countCheck" class="flex font-semibold">
                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"
                                    class="w-5 h-5 mr-1">
                                    <path fill-rule="evenodd"
                                        d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z"
                                        clip-rule="evenodd" />
                                </svg>
                                6 character password
                            </div>
                        </div>
                        <label for="password"
                            class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ __('Password') }}</label>
                        <input @click="showPasswordTip = true" @blur="showPasswordTip = false" type="password"
                            name="password" id="password" wire:model="password"
                            class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white"
                            placeholder="*******" required="">
                        @error('password')
                            <p id="standard_error_help" class="px-2 mt-2 text-xs text-red-600 dark:text-red-400">
                                {{ $message }}</p>
                        @enderror
                    </div>

**Java Script
**

@script
                    <script>
                        const password = document.getElementById('password');
                        const confirm_password = document.getElementById('confirm_password');
                        const message = document.getElementById('message');
                        const container = document.getElementById('container');

                        const checks = {
                            simpleCheck: hasLowercaseLetter,
                            capitalCheck: hasUppercaseLetter,
                            numberCheck: hasNumber,
                            specialCheck: hasSpecialCharacter,
                            countCheck: hasMinimumLength
                        };

                        function hasMinimumLength(password) {
                            return password.length >= 6;
                        }

                        function hasUppercaseLetter(password) {
                            return /[A-Z]/.test(password);
                        }

                        function hasNumber(password) {
                            return /[0-9]/.test(password);
                        }

                        function hasSpecialCharacter(password) {
                            return /[!@#$%^&*]/.test(password);
                        }

                        function hasLowercaseLetter(password) {
                            return /[a-z]/.test(password);
                        }

                        function updateCheck(check, isValid) {
                            const element = document.getElementById(check);
                            element.classList.remove('text-red-500', 'text-green-500');
                            element.classList.add(isValid ? 'text-green-500' : 'text-red-500');
                        }

                        function secure_password() {
                            for (const [check, validator] of Object.entries(checks)) {
                                updateCheck(check, validator(password.value));
                            }
                            validatePassword();
                        }

                        function validatePassword() {
                            const passwordsMatch = password.value === confirm_password.value;
                            message.textContent = passwordsMatch ? 'Passwords match' : 'Passwords do not match';
                            container.classList.toggle('text-green-500', passwordsMatch);
                            container.classList.toggle('text-red-500', !passwordsMatch);
                            container.classList.toggle('line-through', !passwordsMatch);
                        }

                        password.addEventListener('input', secure_password);
                        confirm_password.addEventListener('input', validatePassword);

                        function focusNextInput(el, prevId, nextId) {
                            if (el.value.length === 0) {
                                document.getElementById(prevId).focus();
                            } else {
                                document.getElementById(nextId).focus();
                            }
                        }
                    </script>
                @endscript

All this contents are inside a kivewire component. But java script is not working

P.S – Java script also not visible when page inspect

what I want to done is to show password hint popup. It want to show by default and if requirements notmet password requirements shows in red text, if password meets each requirement it shows in green

Settin up a macro with ImageJ

I am trying to set up a macro in imagej but I am unfamiliar with the language

This is my script :

String directory = "dts/";
String[] list = getFileList(directory);

ArrayList<String> meanValuesList = new ArrayList<String>();

for (int i = 0; i < list.length; i++) {
open(directory + list[i]);
  run("Find Maxima...", "noise=0 output=[Point Selection]");
  run("Measure");
  meanValue = getResult("Mean", 0);
  meanValuesList.add(list[i] + ": " + meanValue);
    close();
}

for (j = 0; j < meanValuesList.size(); j++) {
    print(meanValuesList.get(j));
}

This is the error : ‘.’ expected in line 1:

Thank you for your help

I need my script to work, so I need to solve the problem

React 18 new way of state update or not?

I encountered a peculiar issue with state updates in React, not a bug my code was working fine but I feel a bit weird. Initially, I have a product state that contains all the products fetched from the API:

const [products, setProducts] = useState<Product[]>([]);

I created a function to change a product’s information. Even though I didn’t update the previous products’ state, the description still changes to the new one:

const handleChangeProduct = async ({ productId }: Product) => {
  const exitsProduct = products.find(({ id }) => id === productId);
  exitsProduct.description = "example desc";
  const response = await fetch(
    `${process.env.VITE_APP_API_URL}/products/add`,
    {
      method: 'POST',
      body: JSON.stringify(exitsProduct),
    }
  );
  const responseObj = await response.json();
  // Update the products state, I don't know why the products state is update the description to `example desc`.
  if (responseObj?.success) {
    setProducts(products);
  }
} 

Since I began working with React, this is the method I have considered correct for updating state.

const updatedProducts = products.map((product) => {
  if (product.id === productId) {
    return {
     ...product,
     description: product.description,
    }
  }
  return product;
});
setProducts(updatedProducts);

If this is due to my lack of understanding about ReactJS, please let me know. Can we actually update the new product state even if we copy the state to a new constant?

How to use codrops / tympanus Effects in my wordpress website?

I am trying to replicate this effect on my website
3d-particle-explorations
the code on github here it says (Html/Css/Javascript) but it has package.json file with Dependencies.

i am beginner and I don’t understand what framework this project built with (React , angular …etc)
can someone guide me please

I tried to download the code and inspecting it someone told me to use only the files inside (DIST) folder but when i tried to change the page content to my content everything crashed!

Draw most smooth and pen like sketch on canvas using javascript

Trying to make this project work correctly:

https://github.com/dulnan/lazy-brush?tab=readme-ov-file

I get the coordinates of the brush and the pointer and I want to get these values in my mousemove handler, and then draw.

But it doesn’t work and only shows the pointer!

How can we make this work?

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>lazy-brush Basic Example</title>
    <style>
      body {
        margin: 0;
      }
      canvas {
        display: block;
        cursor: crosshair;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <canvas id="canvas" width="1024" height="768"></canvas>
    </div>

    <script type="module">
      import { LazyBrush } from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/lazy-brush.js'

      // The lazy radius.
      const LAZY_RADIUS = 60
      const BRUSH_RADIUS = 30

      // Create new LazyBrush instance.
      const lazy = new LazyBrush({
        enabled: true,
        radius: LAZY_RADIUS
      })
      const canvas = document.getElementById('canvas')

      canvas.width = window.innerWidth
      canvas.height = window.innerHeight

      // While not always reccommended, we can directly draw in your event
      // handler here. Generally it is better to do that in an animation loop.
      // See the "friction.html" example on how to do that.
      canvas.addEventListener('mousemove', function (e) {
        const x = e.clientX
        const y = e.clientY
        lazy.update({ x, y })

        const brushHasMoved = lazy.brushHasMoved()

        // We only need to update the canvas if the brush has moved.
        if (brushHasMoved) {
          // Get the updated brush coordinates.
          const brush = lazy.getBrushCoordinates()

          // Draw the canvas.
          const H = canvas.getContext('2d')





          // Clear entire canvaas.
          H.clearRect(0, 0, canvas.width, canvas.height)

          // Draw brush point
          H.beginPath()
          H.fillStyle = 'red'
          H.arc(brush.x, brush.y, BRUSH_RADIUS, 0, Math.PI * 2, true)
          H.fill()

          // Draw the lazy radius.
          H.beginPath()
          H.strokeStyle = '#ccc'
          H.arc(brush.x, brush.y, LAZY_RADIUS, 0, Math.PI * 2, true)
          H.stroke()



          const u = [] 

     


          if (H.lineJoin = "round", H.lineCap = "round", H.strokeStyle = 'red',( u.push(lazy.getBrushCoordinates())), 0) {
            H.clearRect(0, 0, H.canvas.width, H.canvas.height), H.lineWidth = 10 * 2, u.push(lazy.getBrushCoordinates());
            let ie = u[0],
              Se = u[1];
            H.moveTo(Se.x, Se.y), H.beginPath();
            for (let Ie = 1, be = u.length; Ie < be; Ie++) {
              const lt = z(ie, Se);
              H.quadraticCurveTo(ie.x, ie.y, lt.x, lt.y), ie = u[Ie], Se = u[Ie + 1]
            }
            H.lineTo(ie.x, ie.y), H.stroke()
          }

          function z(M, H) {
            return {
              x: M.x + (H.x - M.x) / 2,
              y: M.y + (H.y - M.y) / 2
            }
          }



        }
      })
    </script>
  </body>
</html>