React app based on Vite is not able to serve build files – Failed to load module script

When serving a new Vite + React project like so

  • Create new React + Vite project via npm create vite
  • Select React => TypeScript
  • Install dependencies via npm install
  • Build via npm run build
  • CD into dist dir
  • Run app locally via npx http-serve
  • Open url in browser

everything works as expected.

But when I delete the public directory and simplify the main.tsx file to

import React from 'react'
import ReactDOM from 'react-dom/client'

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <div>Foo</div>
  </React.StrictMode>,
)

the application build looks fine but when serving it I get a blank page with the error message

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “application/octet-stream”. Strict MIME type checking is enforced for module scripts per HTML spec.

Does someone know what’s wrong or missing?

Todolist: Remove dynamically added divs

I have a kind of todolist, in which I add elements when clicking on the ‘add’ button. There are two default lines. The add function works great, here’s the code

<html><head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(function() {
  $(".container").on('input', 'input[type=text]', function(event) {
    var i = $(this).closest(".flex-row").index();
    var v = (i == 0) ? $(this).val() : "|" + $(this).val();
    $("#custom_wrapper .output").eq(i).html(v);
  });

  $('.add').click(function() {
    var count = $("input").length;
    count++;
    var row = $("<div>", {
      class: "flex-row"
    }).insertBefore(this);
    $("<label>").appendTo(row);
    $("<input>", {
      type: "text",
      class: "input",
      placeholder: "custom text " + count,
      tabindex: count
    }).appendTo($("label", row));
    $("<button>", {
      class: "remove"
    }).html("-").appendTo(row);
    $("<span>", {
      class: "output"
    }).insertAfter($("#custom_wrapper .output:last"));
  });
});

</script>
 </head>

    <body>
 <div class="container">
  <div class="wrapper">
    <article>
      <section>
        <div class="flex-row">
          <label><input class="input" type="text" name="" placeholder="custom text" tabindex="1" /></label><button class="remove">-</button>
        </div>
        <div class="flex-row">
          <label><input class="input" type="text" name="" placeholder="custom text 2" tabindex="2"></label><button class="remove">-</button>
        </div>
        <button class="add">+</button>
        <div class="flex-row">
          <div>customText{{[<span id="custom_wrapper"><span class="output"></span><span class="output"></span></span>]}}</div>
        </div>
      </section>
    </article>
  </div>
</div>


</body>

Now, I’ve added a button to delete the lines. This is where it gets stuck.

For example: I add two rows to have 4 in total. For example, each line has one letter on it. (a,b,c,d) I delete “b,c,d” and I leave “a”; When I add more, the added text will be inserted before the “a” when it should come after. If I keep adding more, a text will replace an existing text, instead of being added.

Moreover I would like that in my span.output, there is never a pipe before the first text.

Does anyone have any idea where the problem comes from?

Here is my code:

<html><head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(function() {
  $(".container").on('input', 'input[type=text]', function(event) {
    var i = $(this).closest(".flex-row").index();
    var v = (i == 0) ? $(this).val() : "|" + $(this).val();
    $("#custom_wrapper .output").eq(i).html(v);
  });

  $('.add').click(function() {
    var count = $("input").length;
    count++;
    var row = $("<div>", {
      class: "flex-row"
    }).insertBefore(this);
    $("<label>").appendTo(row);
    $("<input>", {
      type: "text",
      class: "input",
      id:"custom-text-" + count,
      placeholder: "custom text " + count,
      tabindex: count
    }).appendTo($("label", row));
    $("<button>", {
      class: "remove"
    }).html("-").appendTo(row);
    $("<span>", {
      class: "output",
      dataid:"custom-text-" + count
    }).insertAfter($("#custom_wrapper .output:last"));
  });

$('body').on('click','.remove', function(){
  $(this).parent('.flex-row').remove();  
  var j =$(this).parent().find('.input').attr("id");
  $('#custom_wrapper .output[dataid="'+ j +'"').empty();    
}) 

}) 
</script>
 </head>

    <body>
 <div class="container">
  <div class="wrapper">
    <article>
      <section>
        <div class="flex-row">
          <label><input class="input" type="text" name="" id="custom-text-1" placeholder="custom text" tabindex="1" /></label><button class="remove">-</button>
        </div>
        <div class="flex-row">
          <label><input class="input" type="text" name="" id="custom-text-2" placeholder="custom text 2" tabindex="2"></label><button class="remove">-</button>
        </div>
        <button class="add">+</button>
        <div class="flex-row">
        <div class="token">{{customText[<span id="custom_wrapper"><span class="output" dataid="custom-text-1"></span><span class="output" dataid="custom-text-2"></span></span>]}}</div>
        </div>
      </section>
    </article>
  </div>
</div>


</body>

How to make responsive signature pad?

How to make a signature pad canvas in signature-pad.js work responsively?

My challenge is the following:

  1. I either get the cursor positioning while drawing correctly but lose the input on resize

    // OR //

  2. I save the input while resizing but then the canvas is not calculated correctly and it does not track the cursor position anymore

Right now I am sure the issue comes from this line in my code:
signaturePad.fromData(signaturePad.toData());

Commenting this out or not decides the outcome of my two observed behaviors.

Does someone have an easy solution to this? I am getting crazy about it already. I also created a JS Fiddle for you to see what I have so far:
https://jsfiddle.net/xetrzi9/hort1ubj/3/

Additional info:
When scrolling on the phone it also resets the input for some reason which is really weird.

NodeJS OCI (Oracle Cloud Infrastructure) libraries. Pull logs with a query created in the Log Analytics Dashboards

In order to tailor some rules in the WAF, I’ve been asked to generate a spreadsheet that has the hits against the said rules, along with the associated metadata, so it can be reviewed and adjusted as needs be. My plan as been to automate this as a NodeJS script (my preferred method for handling & manipulating JSON data) and run it weekly from Jenkins.

I’m going through the documentation from Oracle for using their NPM libraries and cannot seem to work out where the log analytics works and if I can input a query I’ve created in the dashboard as a starting point.
Their examples are here

The query looks something like this:

'Log Source' = 'OCI WAF Logs' and 'Request Protection Rule IDs' != null and 'Request Protection Rules Matched Data' != null and 'Host Name (Server)' in (my.endpoint.com)  | rename URI as Requests, 'OCI Resource OCID' as 'WAF OCID', 'OCI Resource Name' as 'Enforcement Point' | search 'WAF OCID' = 'nothing to see here' | timestats count by 'WAF OCID'

My plan is to get the information and sanitise it so I can place it into a CSV file without the bloat.

How to force hardware acceleration on webkit-based browsers?

I recently started dabbling with the <animate> SVG element to indefinitely animate a background pattern (by animating the x attribute). It worked really well until I realized it’s extremely laggy on Safari for macOS and any iOS browser (Chrome, Safari etc.) despite the SVG file being just 2 KB.

I later realized I never transition height and position, since this triggers a repaint, and that it’s much better to use transform. Luckily there’s something like animateTransform specifically for SVG, which I implemented to animate translate along the x axis instead of using animate to animate x itself. To my surprise, the animations still were just as laggy on webkit-based browsers. Safari’s developer tool (Events Timeline) shows the following:

Safari developer tools events timeline showing rapid style recalculations and layout invalidations

This is after grouping by resource, and recorded without interacting with the page. Max CPU usage in this time was only 6%.

Here are the (silly) things I tried:

  • Set animateTransform { will-change: transform; }
  • Same but instead of selecting animateTransform selecting its parent element

…and a few more things I forgot about. Anyways, the extremely laggy animations also cause other CSS transform transitions to be laggy. Now, my theory is that on webkit-based browsers, all CSS and HTML animations (is that even a thing?) get calculated by the CPU (and not by the GPU). I don’t really know how to check this for sure. But the <animate> and <animateTransform> elements don’t show up in the ‘Graphics’ tab of the Safari developer tools, unlike other animations.

So my question is, how do I off-load these animations to the GPU? I was thinking of trying the Web Animations API (see this Webkit blogpost), but I’m not sure if it’s good practice to use Javascript for a super simple animation. If anyone has more info on when to use CSS transitions/keyframes or the Web Animation API, I’d love to know more.

Going from a StructRowProxy to a Table

I am selecting rows from a Table in Apache Arrow JS, and than trying to convert those rows into a Table.

I load the data as such:

  import { tableFromIPC } from "apache-arrow";
  import { fetchData } from "../../services/dataStreamer";
  import { readFileSync } from "fs";

  const arrow = readFileSync("./src/__tests__/services/example_data.ipc");
  const table = tableFromIPC(arrow);
  const row = table.get(0) as any;

The row looks like this {"annotation": ["1","2","3"], "id": 1234}, where annotation is of Vector type and id of int type.

Once I have the StructRowProxy I try convert it into a table.

I have this code to convert into a table,

import { makeTable, RecordBatch, StructRowProxy, Table, tableToIPC } from "apache-arrow";

export const fetchData = (data: { [key: number]: StructRowProxy }) => {
  const table = Object.values(data)
    .map((row) => {
      const rowData = Array.from(row)
        .map((rowData, _rowIndex) => {
          const fieldName = rowData[0];
          const fieldValue = rowData[1] as any;
          const a = {
            [fieldName]: new Array(fieldValue),
          } as any;
          const t = makeTable(a);
          console.log(t.data);
          return {
            [fieldName]: fieldValue,
          };
        })
        .reduce((acc, curr) => {
          return { ...acc, ...curr };
        });

      makeTable(rowData);

      let batch = new RecordBatch(rowData);
      const table = new Table([batch]);
      console.log(table);
      return table;
    })
    .reduce((acc, table) => acc.concat(table));
  console.log(table);
  const ipc = tableToIPC(table as any as Table);
  console.log(ipc);
  return new Blob([ipc]);
};

The issue appears that the int value gets converted into 1234n, which isn’t accepted.

Any other ideas how to go from StructRowProxy to Table?

Dropping root privileges in NodeJS doesn’t seem to have an effect

I want to have root privileges on startup and drop them later. Background is a server written with NodeJS on Ubuntu 24.04 that needs to read in a private key. I followed these instructions using process.setgid() and process.setuid() and after that elevating privileges back doesn’t work.
But I saw that process.env wasn’t updated. It still shows user as root, but the fields SUDO_USER, SUDO_UID and SUDO_GID where added with correct values.
Curious I tried to read a root-only file after dropping privileges and it still worked. I tried reading other root-only files and it worked.

So what am I doing wrong or am I forgetting, because what’s the point in dropping root privileges when I can still read root-only files.

Can’t complete the deployment of contract to the Polygon Testnet Amoy

I have been trying my best to deploy to the Polygon Amoy testnet, but with no vain. I’m using Hardhat ignition modules to deploy to the testnet. I have 0.4 POL on the amoy testnet wallet. I got the link to the network from Alchemy. The link with API key is working fine, tested using Postman. The following is the deploy.js file:

const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");

var erccontract = ""

module.exports = buildModule("erc721contract", (m) => {
  erccontract = m.contract("erc721");
  return { erccontract };
});

console.log("Contract Deployed at address: ",erccontract);

The following is the output of the future variable erccontract that deals with the contract to be deployed:

Contract Deployed at address:  <ref *1> NamedContractDeploymentFutureImplementation {
  id: 'erc721contract#erc721',
  type: 'NAMED_ARTIFACT_CONTRACT_DEPLOYMENT',
  module: IgnitionModuleImplementation {
    id: 'erc721contract',
    results: { erccontract: [Circular *1] },
    futures: Set(1) { [Circular *1] },
    submodules: Set(0) {}
  },
  dependencies: Set(0) {},
  contractName: 'erc721',
  constructorArgs: [],
  libraries: {},
  value: 0n,
  from: undefined
}

As you can see here, the contract is not fully deployed, because the from address is undefined. I’m also sharing my hardhat.config.js file:

/**
 * @type import('hardhat/config').HardhatUserConfig
 */

require("dotenv").config();

const { NEW_API_URL_KEY, PRIVATE_KEY } = process.env;

module.exports = {
  solidity: "0.8.20",
  defaultNetwork: "polygon_amoy",
  networks: {
    hardhat: {},
    polygon_amoy: {
      url: NEW_API_URL_KEY,
      accounts: [`0x${PRIVATE_KEY}`],
      gasLimit: 8000000, // Adjust this value as needed
    },
  },
};

I can’t understand what the issue is. Can anyone please help me with this?

Firebase Function CORS Issue: “Access-Control-Allow-Credentials” Header Issue Despite Correct Setup

I’m encountering a persistent CORS issue while working with a Firebase HTTPS function in my Vite.js React app, specifically when trying to integrate OAuth.

Problem:
The following error is thrown when I try to send a request from my frontend to a Firebase Cloud Function:callback:1 Access to fetch at 'http://127.0.0.1:5001/my-project-id/us-central1/youtube/youtubeaccesstoken' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'.

I have set credentials: ‘include’ on my fetch request, and it seems that Firebase is not returning the required Access-Control-Allow-Credentials: true header, even though I have tried setting CORS both implicitly and explicitly.

What I’ve Tried:

  • Firebase Function Setup: I’ve used Firebase’s onRequest with cors:
    true to allow CORS

       
           const {
             onRequest
           } = require('firebase-functions/v2/https');
       
           exports.youtube = onRequest({
             timeoutSeconds: 360,
             cors: true
           }, (req, res) => {
             // Handle the preflight OPTIONS request
             if (req.method === 'OPTIONS') {
               res.set('Access-Control-Allow-Origin', 'http://localhost:5173');
               res.set('Access-Control-Allow-Methods', 'GET, POST');
               res.set('Access-Control-Allow-Headers', 'Authorization, Content-Type');
               res.set('Access-Control-Allow-Credentials', 'true');
               res.status(204).send('');
               return;
             }
       
             // Handle the actual request
             res.set('Access-Control-Allow-Origin', 'http://localhost:5173');
             res.set('Access-Control-Allow-Credentials', 'true');
       
             youtubeService(req, res);
           });
       
       
  • Client-Side Fetch: The client-side fetch request is set to include credentials:
fetch('http://127.0.0.1:5001/my-project-id/us-central1/youtube/youtubeaccesstoken', {
  method: 'POST',
  credentials: 'include',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    code,
    state,
    userId
  }),
});
  • I have also tried a different approach for my firebase function as i am using express.
const youtubeService = express();
youtubeService.use(express.json());
youtubeService.use(cookieParser());

const corsOptions = {
  origin: "http://localhost:5173", // Use specific origin instead of true
  methods: "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS",
  credentials: true, // Allow credentials
  allowedHeaders: ["Content-Type", "Authorization"],
};

youtubeService.use(cors(corsOptions));

//and the rest of the REST endpoints





exports.youtube = onRequest({
    timeoutSeconds: 360,
    cors: true,
  },
  youtubeService
);

Expected Behavior:
The Firebase function should allow cross-origin requests, returning the necessary CORS headers, particularly Access-Control-Allow-Credentials: true, when using credentials: ‘include’ on the frontend.

Things to Consider:

  • Firebase is supposed to handle the preflight request implicitly, but
    I’ve explicitly set it just to be sure.
  • All other CORS headers seem to be working fine, except for
    Access-Control-Allow-Credentials

.

Counting instances of a key in a JSON tree

I have a JSON structure in the likes of

{
 "a": {"b": "value"},
 "c": {"b": "value"},
 "d": {"b": "value"}, 
 "a": {"e": {"b": ["value"]}}
}

The expected answer is 4. b could be anywhere in the tree structure.

I want to know (for testing) how many instances of b I have. Google tells me to use JSON.stringify and then work on the string. In XML, I could have used XPath to count the number of elements. Is there a JS/JSON-native way to do this other than iterating over each field’s keys?

Safe Assignment Operator in JavaScript, a myth or reality?

I’ve been going through Medium to get some updates about programming. A couple of articles confused me that were related to “Safe Assignment Operator”:

async function getData() {
    const [networkError, res] ?= await fetch('https://api.backend.com/resource/1')
    
    if(networkError) console.error(networkError)
    const [parseError, data] ?= await res.json()

    if(parseError) console.error(parseError)
    return data
            
}

I tried finding the official documentation on MDN, but nothing found. I also tried on console but no luck.

Is this a myth or isn’t the MDN site updated?

Dynamically Show/Hide Django Admin Inline Forms Based on Dropdown Selection

I’m trying to dynamically show and hide inline forms in the Django admin based on a dropdown selection. I have two inline forms: one for IndividualCustomer and another for CorporateCustomer. The goal is for the corresponding inline to appear when a specific customer type is selected from the dropdown.

Here’s what I’ve set up:

Models: I have defined IndividualCustomer, CorporateCustomer, and Customer models.

Admin: I’ve created inlines for both customer types and included them in the CustomerAdmin class.

Custom Template: I’m using a custom change_form.html to implement the JavaScript logic.

Models and Admin Code:

# models.py
from django.db import models

class Customer(models.Model):
    CUSTOMER_TYPE_CHOICES = [
        ('Individual', 'مشتری حقیقی'),
        ('Corporate', 'مشتری حقوقی'),
    ]
    customer_type = models.CharField(max_length=20, choices=CUSTOMER_TYPE_CHOICES)

class IndividualCustomer(models.Model):
    customer = models.OneToOneField(Customer, on_delete=models.CASCADE)
    # Other fields...

class CorporateCustomer(models.Model):
    customer = models.OneToOneField(Customer, on_delete=models.CASCADE)
    # Other fields...

# admin.py
from django.contrib import admin
from .models import Customer, IndividualCustomer, CorporateCustomer

class IndividualCustomerInline(admin.StackedInline):
    model = IndividualCustomer
    extra = 0

class CorporateCustomerInline(admin.StackedInline):
    model = CorporateCustomer
    extra = 0

@admin.register(Customer)
class CustomerAdmin(admin.ModelAdmin):
    inlines = [IndividualCustomerInline, CorporateCustomerInline]

Custom Template (change_form.html):

{% extends "admin/change_form.html" %}
{% load i18n static %}

{% block after_field_sets %}
{{ block.super }}

<style>
    .inline-group {
        margin-bottom: 20px;
    }
</style>

<script>
document.addEventListener('DOMContentLoaded', function () {
    function hideAllInlines() {
        const individualInline = document.querySelector('#individualcustomer_set-group');
        const corporateInline = document.querySelector('#corporatecustomer_set-group');

        if (individualInline) individualInline.style.display = 'none';
        if (corporateInline) corporateInline.style.display = 'none';
    }

    function toggleInlines() {
        const customerType = document.querySelector('#id_customer_type').value;
        const individualInline = document.querySelector('#individualcustomer_set-group');
        const corporateInline = document.querySelector('#corporatecustomer_set-group');

        if (customerType === 'Individual') {
            if (individualInline) individualInline.style.display = 'block';
            if (corporateInline) corporateInline.style.display = 'none';
        } else if (customerType === 'Corporate') {
            if (corporateInline) corporateInline.style.display = 'block';
            if (individualInline) individualInline.style.display = 'none';
        } else {
            hideAllInlines();
        }
    }

    hideAllInlines();
    toggleInlines();

    const customerTypeField = document.querySelector('#id_customer_type');
    if (customerTypeField) {
        customerTypeField.addEventListener('change', toggleInlines);
    }
});
</script>
{% endblock %}

Issue
Despite implementing the above, both inline forms are displayed initially, and the expected behavior of hiding one form based on the dropdown selection is not occurring. Here are the specific issues I’m encountering:

Both IndividualCustomer and CorporateCustomer inline forms are shown when the page loads.
The inlines do not toggle visibility when the dropdown selection changes.
I receive console errors indicating that some elements are not found, such as Individual Inline not found!.
What I’ve Tried
Verified the IDs of the inline groups.
Ensured the JavaScript is included correctly in the template.
Checked for any JavaScript errors in the console.

How can I dynamically show and hide the Django admin inline forms based on a dropdown selection? What changes do I need to make to my JavaScript or template to ensure the inlines behave as expected?

How do I call child component method() via slots

I am migrating project from Vue 2 to Vue 3 and can’t find a solution to a problem

Form.vue

<template>
    <form>
        <slot></slot>
    </form>
</template>

<script lang="ts">
import { Component, Setup, Vue } from 'vue-facing-decorator'
import { useSlots } from 'vue'

@Component({
    name: 'Form'
})
export default class Form extends Vue
{
    @Setup(() => useSlots())
    private slots!:any;

    public mounted():void
    {

    }

    public submit():void
    {
        for(let i in this.slots!.default!())
        {
            let child:any = this.slots!.default!()[i];

            if('FormSubmit' === child.type.name)
            {
                child.lock();
            }
        }
    }
}
</script>

FormSubmit.vue

<template>
    
</template>
<script lang="ts">

import { Component, Prop, Setup, Vue, Watch } from 'vue-facing-decorator'

@Component({
    name: 'FormSubmit',
    expose: ['lock']
})
export default class FormSubmit extends Vue
{
    public lock():void
    {
        console.log('lock the button');
    }
}
</script>

And the main view:

<template>
    <main>
        <Form>
            <FormSubmit />
        </Form>
    </main>
</template>

<script lang="ts">
import {Vue, Component } from 'vue-facing-decorator';

@Component
export default class FormView extends Vue
{
   
}
</script>

In Vue 2 I could loop through this.$children and access any child method but here it says that

child.lock is not a function

How can I then get the child from a slot and call that child’s method?

Unfortunatelly ChatGPT is not helping this time, asking me to change submit() function into this

public submit():void
    {
        const defaultSlot = this.slots!.default?.();

        if (!defaultSlot) return;

        defaultSlot.forEach((vnode: any) => {
            if (vnode.type.name === 'FormSubmit') {
                const componentInstance = vnode.component;
                console.log(componentInstance);
                if (componentInstance && typeof componentInstance.exposed.lock === 'function') {
                    componentInstance.exposed.lock(); // Call the lock method
                }
            }
        });
    }

but componentIntance is always null

Why `expandable` block in table definition of mary ui is broken?

In laravel 11 / livewire 3.5 I use mary-ui ^1.40.3 app
and I try to use table row-expansion functionality from manuals
https://mary-ui.com/docs/components/table#row-expansion

I currencies table I added expandable to table definition and @scope('expansion' block in the end of the table block:

<x-mary-table :headers="$headers" :rows="$currencies" striped expandable
              :sort-by="$sortBy" with-pagination  show-empty-text empty-text="No currencies found. Try to change filter criteria"
              :per-page-values="[10, 25, 50, 100]" >

    @scope('actions', $currency)
        <div class="flex w-32 max-h-8">
            <div class="w-16 px-2">
                <x-mary-button :icon="IconEnum::Edit->value" wire:click="edit({{ $currency->id }})" spinner
                              class="btn-sm btn-primary max-h-6"
                />
            </div>
            <div class="w-16 align-items-end justify-end align-top">
                <x-mary-button :icon="IconEnum::Delete->value" wire:click="delete({{ $currency->id }})" spinner
                           class="btn-sm btn-error max-h-6"
                           wire:confirm="Are you sure you want to delete this currency?"
                />
            </div>
        </div>
    @endscope

    @scope('cell_name', $currency)
    <span class="whitespace-nowrap">
            {{ $currency->name }}
        </span>
    @endscope

    @scope('header_id', $header)
    <h2 class="text-xl font-bold text-grey-100">
        {{ $header['label'] }}
        <x-mary-icon :name="IconEnum::KeyField->value"/>
    </h2>
    @endscope

    @scope('cell_active', $currency)
    @if($currency->active === CurrencyActiveEnum::ACTIVE)
        <span class="whitespace-nowrap">
            <x-mary-badge :value="CurrencyActiveEnum::getLabel($currency->active)" class="badge-primary"/>
        </span>
    @else
        <span class="whitespace-nowrap">
            {{ CurrencyActiveEnum::getLabel($currency->active) }}
        </span>
    @endif
    @endscope

    @scope('cell_description', $currency)
    <span class="whitespace-nowrap">
            <x-mary-popover>
                <x-slot:trigger>
                    <x-mary-badge :value="Str::limit(strip_tags($currency->description), 20)"/>
                </x-slot:trigger>
                <x-slot:content>
                    {{strip_tags($currency->description) }}
                </x-slot:content>
            </x-mary-popover>
        </span>
    @endscope

    @scope('cell_created_at', $currency)
        <span class="whitespace-nowrap">
            {{ DateConv::getFormattedDateTime($currency->created_at) }}
        </span>
    @endscope

    {{-- Special `expansion` slot --}}
    @scope('expansion', $currency)
    <div class="bg-base-200 p-8 font-bold">
        currency_histories_count::{{ $currency->currency_histories_count }}<hr>
        user_currency_subscriptions_count::{{ $currency->user_currency_subscriptions_count }}<hr>
    </div>
    @endscope
</x-mary-table>

But in console of my chrome browser I see errors(1 such error for one row of the table) :

livewire.js?id=ec3a716b:1120 Alpine Expression Error: this.selection.includes is not a function

Expression: "isExpanded(27) || '-rotate-90 !text-current'"


livewire.js?id=ec3a716b:1120 Alpine Expression Error: this.selection.includes is not a function

Expression: "isExpanded(27) || 'hidden'"


livewire.js?id=ec3a716b:1120 Alpine Expression Error: this.selection.includes is not a function

I see expanded switcher image – but it is opened and does not switch the block :

enter image description here

What can be wrong in my expansion code ?

Solving scope issue while using jQuery ready function

How can I solve this scope issue:
I am trying to update an old project.
HTML file includes JS file.
after some code from the JS is running, it calls back a function myFunc() from the HTML.

In the new code, I need to add jQuery ready function to the HTML file.
so I get error

  jQuery.Deferred exception: myFunc is not defined 
  

what is the minimum change I can make in the JS code (or in the HTML code?) to solve this scope issue?

my HTML file:

<html>
<head>
  ... html code ...
  <script src="/my.js"></script>
</head>
<body>
  ... html code ...
  <script>
  $( document ).ready(function() {   // <- this line was added to the new HTML file
    ...
    function myFunc() {              // was called from JS file. but now is considered undefined :(
    ...
  }
  });                                // <- this line was added to the new HTML file
  </script>

</body>
</html>

my JS file:

(function($){
  $(document).ready(function(){
    ...
    myFunc();
    ...
  });

})(this.jQuery);