how to use the AudioWorkletNode in Safari iOS 18.2

When I try to use the AudioWorkletNode in Safari on iOS 18.2 I get

ReferenceError: Can’t find variable: AudioWorkletNode

Did Safari remove this API? Is there some new way to use it?

async function main() {

  const s = `
// random-noise-processor.js
class RandomNoiseProcessor extends AudioWorkletProcessor {
  count = 0;
  process(inputs, outputs, parameters) {
    const output = outputs[0];
    output.forEach((channel) => {
      for (let i = 0; i < channel.length; i++) {
        channel[i] = Math.sin(this.count++ * 0.1);
      }
    });
    return true;
  }
}

registerProcessor("random-noise-processor", RandomNoiseProcessor);
  `;

  const workerURL = URL.createObjectURL(new Blob([s], {type: 'application/javascript'}));
  console.log('made url');

  const audioContext = new AudioContext();
  console.log('made context');
  await audioContext.audioWorklet.addModule(workerURL);
  console.log('made worklet');

const randomNoiseNode = new AudioWorkletNode(
    audioContext,
    "random-noise-processor",
  );
  console.log('made node');

  randomNoiseNode.connect(audioContext.destination);
  console.log('connected');
}
 document.querySelector('button').addEventListener('click', main, { once: true });
<button type="button">start</button>

Connect Metamask App from Android to an Android app created project using Javascript only and CDNs

I have the following code, it is not working

// Handle connect button click
connectButton.addEventListener('click', async () => {
    try {
        // Initialize WalletConnect
        const walletConnectProvider = new WalletConnect.default({
            bridge: "https://bridge.walletconnect.org",  // Optional: WalletConnect bridge URL
        });

        // Enable the provider to establish the connection
        await walletConnectProvider.enable();

        // Initialize Web3 with WalletConnect provider
        provider = new Web3(walletConnectProvider);

        // Get the accounts
        accounts = await provider.eth.getAccounts();
        const address = accounts[0];

        walletAddressElement.innerText = "Connected: " + address;

        // Toggle button visibility
        connectButton.style.display = 'none';
        disconnectButton.style.display = 'inline-block';
    } catch (error) {
        console.error("Error during connection:", error);
        alert("Connection failed. Please try again.");
    }
});

I tried using the https://metamask.app.link also, but this only opens the metamask application on android, it doesn’t request for sign in the request, and approve the connection to the app, the idea is the user connect their metamask wallet, with a button, when clicking the button it redirects to the metamask application (if installed), then approve the request, and go back to the android project application and see their wallet address, also there will be a disconnection button. I have this other code with the metamask.app.link but only opens the application, not receiving the sign request to approve the android app.

document.addEventListener('deviceready', function () {
    console.log("Device is ready!");

    const connectButton = document.getElementById('connectButton');
    const walletAddressElement = document.getElementById('walletAddress');

    function openMetaMask() {
        const metamaskUrl = "https://metamask.app.link/wc"; // Opens MetaMask Mobile
        console.log("Opening MetaMask:", metamaskUrl);
        window.open(metamaskUrl, '_system'); // Opens MetaMask app
    }

    async function connectWallet() {
        try {
            if (!window.ethereum) {
                alert("MetaMask is not installed. Please install it first.");
                return;
            }

            const accounts = await ethereum.request({ method: 'eth_requestAccounts' });
            const account = accounts[0];

            console.log("Connected account:", account);
            walletAddressElement.innerText = "Wallet: " + account;

            // Now, request a signature
            const message = "Sign this message to authenticate with My Cordova App";
            const signature = await ethereum.request({
                method: 'personal_sign',
                params: [message, account]
            });

            console.log("Signature:", signature);
            alert("Signed successfully! Returning to app...");
        } catch (error) {
            console.error("Error:", error);
            alert("Connection or signing failed.");
        }
    }

    connectButton.addEventListener('click', function () {
        openMetaMask();
        setTimeout(connectWallet, 5000); // Wait for MetaMask to open before requesting connection
    });

Do you have any other approach, I am only using cdns and want to be in that way, is there any alternative without using Infura API or reown project id? The only thing I need is to connect, no anything else, no transactions, nothing only sign the approval and then go back to the application.

How to make next and back buttons with div array?

I’m coding a website and for the life of me i cannot find a way to get a functioning

way to get all four buttons to work.

var divs = ["Page1", "Page2", "Page3"];
var visibleDivId = null;
var i, divID, div;

function divVisibility(divID) {
  if (visibleDivId == divID) {
    visibleDivId = null;
  } else {
    visibleDivId = divID;
  }
  hideNonVisibleDivId();
}

function hideNonVisibleDivId() {
  for (i = 0; i < divs.length; i++) {
    divID = divs[i];
    div = document.getElementById(divID);
    if (visibleDivId === divID) {
      div.style.display = "block";
    } else {
      div.style.display = "none";
    }
  }
}

}
<HTML>

<Head>

</Head>

<Body>
  <Center>

    <table style="border-radius:15px 15px 15px 15px;">

      <tr>
        <td>
          <center>
            <div style="width:850px; border:3px black solid; margin-top:30px; margin-bottom:-10px; border-radius:8px 8px 8px 8px; background-image: url('https://basilthesheep.neocities.org/SiteImages/color2.png')">

              <!-- toolbar -->
              <table style="border-top: none; height:0px;">

                <tr>
                  <td>
                    <center>
                      <div class="toolbar" style="border-radius:15px 15px 15px 15px;">

                        <font size="3"><b>~&nbsp;&nbsp;/ 
<a href="#" onClick="divVisibility('Page1')">&nbsp;&nbsp;&nbsp;First&nbsp;&nbsp;&nbsp;</a> /
<a href="#" onClick="backward(?????);">&nbsp;&nbsp;&nbsp;Back&nbsp;&nbsp;&nbsp;</a> /
<a href="#" onClick="forward(??????);">&nbsp;&nbsp;&nbsp;Next&nbsp;&nbsp;&nbsp;</a> /
<a href="#" onClick="divVisibility('Page3');">&nbsp;&nbsp;&nbsp;Latest&nbsp;&nbsp;&nbsp;</a> / &nbsp;&nbsp;~</b></font>

                      </div>
                    </center>
                  </td>
                </tr>

              </table>
              <!-- diary -->

              <table style="border-radius:15px 15px 15px 15px;">

                <tr>
                  <td>
                    <center>
                      <div id="diary">

                        <div id="Page1">

                          egg

                        </div>

                        <div id="Page2" style="display: none;">

                          egg bacon

                        </div>

                        <div id="Page3" style="display: none;">

                          egg bacon cheese

                        </div>

                      </div>
                    </center>
                  </td>
                </tr>
              </table>
            </div>
          </center>
        </td>
      </tr>
    </table>
  </center>
</body>

</html>

I’ve tried to make it so:
First always goes to the first div (page1)
Next will go to page 2 3 4 etc.
Back will go back to page 3 2 1 etc.
and Latest will go to the last div (currently page3)

only First and Latest will work

Axios won’t wait for bcrypt to finish hashing

I’m trying to pass user credentials to an authorization table using axios handle the post request and I’m trying to use bcrypt to hash the password before posting to the db, but I’m getting a null error because as I’m assuming bcrypt is not done handling the request before axios starts passing the data. I’ve tried a couple solutions, but none seem to work. Here’s my current set up:

bcrypt.hash(password, 13)
  .then(res => {
    axios.post('http://localhost:8081/register', { email, res })
      .then(res => console.log(res))
      .catch(err => console.log(err))
  })
  .catch(err => console.log(err))

Despite the .then block, axios submits the request before the hashing is done.

Another thing I tried was running it in an async function. This is that code:

const handleRegistration = async (e) => {
    e.preventDefault();

    if (password !== confPassword) {
      console.log("Passwords must match.");
      alert("Passwords must match!");
      return;
    }

    const hashedPassword = await bcrypt.hash(password, 13)

    //Call POST api here
    await axios.post('http://localhost:8081/register', { email, hashedPassword })
      .then(res => console.log(res))
      .catch(err => console.log(err))
  };

This also doesn’t seem to work.

Why is DOMParser.parseFromString is stripping HTML tags?

Could someone tell me why parseFromString is stripping HTML tags?

let html = document.querySelector('template').innerHTML
let parser = new DOMParser()
objects.forEach(object => { // objects is a array of objects retirando from a API
    let string = Object.entries(object).reduce((str, key) => {
        return str.replace(`#[${key[0]}]`, key[1]);
    }, html)
    let node = parser.parseFromString(string, 'text/html').body.firstChild
    // HTMLElement.appendChild(node)
    // HTMLElement.append(string)
    HTMLElement.innerHTML += string
})

This returns me a text without the HTML tags, which I cannot insert into the DOM with

HTMLElement.appendChild(node)

It doesn`t Works if do:

HTMLElement.append(string)

But yes with:

HTMLElement.innerHTML += string

Which is not the way I wanted, since This is not the way I planned it.

Try This Fiddle

SearchBar for an iframe

Lets say this: i have 6 elements: a back and foward button (id backbtn and frwdbtn), an input element (id searchbar) a search button for duckduckgo (id searchduck) a search url button (id searchurl) and an iframe (id iframe_main). i couldnt find a way anywhere on the internet for all of those buttons and that searchbox to “navigate the internet” inside the iframe but i genuenly dont know how.

heres all the work that didnt get deleted because it didnt work

<button id="backbtn">back</button><button id="frwdbtn">frwd</button> <label for="searchbar">search:</label> <input type="text" id="searchbar" name="searchbar"> <button id="searchduck">DuckDuckGo</button><button id="searchurl">Enter URL</button>
        <iframe src="sidebar.html" name="iframe_side" style="width:7.5%; height:85%; overflow:auto; position:absolute; top:100px; left:12.5px;"></iframe>

i gave up here when i realized that i may need js and then i went to bed crying because i didnt finish this

Uncaught TypeError: items.filter is not a function [closed]

I’m using context API to build a small travel list app where users can add items to their list by writing in the input and clicking the add items button to add the specific item they want. I want anytime user input what they want and click on the add item button, the item should be added to the user list, but unfortunately anytime user click the add item button the whole UI disappear and have in my console “Uncaught TypeError: items.filter is not a function at Counter Component”. Below are the code from the ItemContext to the Counter component:

[Itemcontext][1]
[App.jsx][2]
[parent component to the counter][3]
[the counter component][4]

Someone should please guide me and ably solve it. Thanks.




 [1]: https://i.sstatic.net/nuuuL6rP.png
  [2]: https://i.sstatic.net/cWcqnk3g.png
  [3]: https://i.sstatic.net/jt79MgoF.png
  [4]: https://i.sstatic.net/rUFvEKIk.png

Setting up a local dev environment for HTML Javascript

I am trying to set up a dev env for my kid who is just starting out with HTML/JS.

Till a few months ago, I was able to just load the files using file:/// in a browser and debug. However, now none of the browsers support it anymore. I get the following errors —

Origin null is not allowed by Access-Control-Allow-Origin. Status code: 0
Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. Status code: 0

I understand that this is because of CORS settings changes. That’s fine, but it forces me to set up an actual environment for my kid. It’s no longer easy. I am looking for options to not make her jump through hoops.

Ideally I want debugging to be just calling http://localhost/Code/Project1/project1.html

Where Code is the dev directory in her home directory on the Mac and each project is organized in its own sub directory.

How do I achieve it?

I know Macs come with apache. I tried adding the Code directory in the DocumentRoot of apache2 (/Library/WebServer/Documents) as a symlink

However, apache does not follow it – gives me permission errors.

I tried modifying the configuration to AllowSymLinks allow all. That did not help either.

I am not tied to this particular option. Any other option will do.

The editor we use is VSCode.

We can move to any editor if it makes this easier.

Easier to set up dev environment but am running into as described above and would like to ask for options

Refresh token coming from Nest.js as cookie does not get persisted after refresh

My backend sends a refresh token as a cookie after the login happens.

Although this cookie does not get persisted after closing or refreshing my Next.js page.

I am sending the refresh token cookie after loginIn as a server side cookie so its secure.

This is the login logic:

  @Post('/login')
  @UsePipes(new ZodValidationPipe(authenticateBodySchema))
  async login(
    @Body() body: AuthenticateBodySchema,
    @Res({ passthrough: true }) response: Response,
  ) {
    const { email, password } = body

    const user = await this.authService.validateUser(email, password)

    const { senha, ...userWithoutPassword } = user

    const token = this.authService.generateAccessToken(user.id)

    const refreshToken = this.authService.generateRefreshToken(user.id)

    response.cookie('refreshToken', refreshToken, {
      path: '/',
      httpOnly: true,
      secure: this.configService.getOrThrow('ENVIRONMENT') === 'PRODUCTION',
      sameSite: true,
      maxAge: 7 * 24 * 60 * 60 * 1000,
    })

    return { token, user: userWithoutPassword }
  }

@Post('/refresh')
  async refresh(
    @Req() request: Request,
    @Res({ passthrough: true }) response: Response,
  ) {
    const refreshToken = request.cookies.refreshToken

    const { sub, user } =
      await this.authService.validateRefreshToken(refreshToken)

    const generatedAccessToken = this.authService.generateAccessToken(sub)

    const generatedRefreshToken = this.authService.generateRefreshToken(sub)

    const { senha, ...userWithoutPassword } = user

    response.cookie('refreshToken', generatedRefreshToken, {
      path: '/',
      httpOnly: true,
      secure: this.configService.getOrThrow('ENVIRONMENT') === 'PRODUCTION',
      sameSite: false,
      maxAge: 7 * 24 * 60 * 60 * 1000,
    })

    return { token: generatedAccessToken, user: userWithoutPassword }
  }

Main.js of Nest.js:

import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { ConfigService } from '@nestjs/config'
import { Env } from './env'
import * as cookieParser from 'cookie-parser'

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    cors: {
      origin: ['http://localhost:3001', 'https://mywebsite.vercel.app'],
      credentials: true,
    },
  })

  app.use(cookieParser())

  const configService: ConfigService<Env, true> = app.get(ConfigService)

  const port = configService.get('PORT', { infer: true })

  await app.listen(port)
}
bootstrap()

After login in I get:

enter image description here

The login logic in Next.js is:

 const signIn = async (email: string, password: string) => {
    const response = await AuthService.login(email, password)

    const decodedToken = jwtDecode(response.token)

    if (!decodedToken.exp) {
      toast('Erro ao fazer login')
      return
    }

    destroyCookie(undefined, 'mywebsite-token')

    const tokenExpiration = (decodedToken?.exp * 1000 - Date.now()) / 1000

    setCookie(undefined, 'mywebsite-token', response.token, {
      maxAge: tokenExpiration,
    })

    http.defaults.headers.Authorization = `Bearer ${response.token}`

    setUser(response.user)

    router.replace('/receitas')
  }

Add class when intersection observer passes the element scrolling down, and remove when up?

I’m trying to toggle the class when Intersection Observer passes a certain element.
When it passes from the top, I’d like to add class and then to remove it when scroll direction is up.

It works, but unfortunately not each time and not in correct place. How to add / remove the class when the element is just barely visible at the bottom of the screen?

const options = {
        root: null,
     //   rootMargin: '50px',
       threshold: 0.1
    }


    const observer = new IntersectionObserver(
        ([entry]) => {

            if (entry.isIntersecting) {
                
                     // up
                if (entry.boundingClientRect.top < 0) {
                    document.querySelector('button').classList.remove('hidden');
                } else {
                      //down 
                    document.querySelector('button').classList.add('hidden')
                }
            }
        },
        options
    );


const arr = document.querySelectorAll('h2')
arr.forEach(i => {
  observer.observe(i)
})
h2 {
  margin-top: 700px;
  margin-bottom: 700px;
}

button {
  position: fixed;
  top: 0;
  left:0;
}

button.hidden {
  background: red !important;
}
<h2>
ELEMENT
</h2>

<button>
  FIXED BUTTON
</button>

Example of a JavaScript binding that is part of the language standard

The online book Eloquent JavaScript has the following phrase in Chapter 2 while talking about the environment:

When a program starts up, this environment is not empty. It always contains bindings that are part of the language standard, and most of the time, it also has bindings that provide ways to interact with the surrounding system.

I’m don’t understand what it means by “bindings that are part of the language standard.” I’ve been looking for examples on the Internet, but I can’t find any, even though I’ve seen similar statements to what Eloquent JavaScript says.

Can anybody name some specific examples of these language standard bindings?

How do I set Auth State Persistance using firebase/compat/auth?

I am using Expo for my React native project. Every time I close the app the user is signed off and I tried every possible answer on stack overflow to persist the user state. Obviously I am doing something wrong, but the documents on firebase state persistance use firebase/auth while in my config file I am using firebase/compat/auth. Here is my config file:

import firebase from "firebase/compat/app";
import 'firebase/compat/firestore'
import 'firebase/compat/auth'

import { getReactNativePersistence, setPersistence } from 'firebase/auth';
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';

const localPersistence = getReactNativePersistence(ReactNativeAsyncStorage);

const firebaseConfig = {
  apiKey: "key",
  authDomain: "domain",
  databaseURL: "url",
  projectId: "id",
  storageBucket: "bucket",
  messagingSenderId: "id",
  appId: "id",
  measurementId: "id"
};

if (firebase.apps.length === 0) {
  firebase.initializeApp(firebaseConfig);
}

export const auth = firebase.auth();
export const firestore = firebase.firestore();

And then in my SignIn.js component I am importing auth from the above file:

import { auth } from '../../firebase.js'

export default function SignIn({ navigation }) {

  const [email, setEmail] = useState(null);
  const [password, setPassword] = useState(null);



  const onLogin = async () => {
    if(!email || !password){
      return;
    }
    auth.signInWithEmailAndPassword(email, password)
      .then((userCredential) => {
        const user = userCredential.user;
      })
      .catch((error) => {
        const errorCode = error.code;
        const errorMessage = error.message;
        console.log("error while user logs in: ", error);
        if(errorCode === "auth/invalid-credential"){
          setError("The supplied auth credential is incorrect, malformed or has expired.")
        }else{
          setError("An error occured and we can not log you in.")
        }
      });
  };

  return (
     <MyComponent />
  );
}

I tried calling

const authState = firebase.auth();
authState.setPersistence(localPersistence);
export const auth = authState;

from my firebase config file, it did not make any difference – the user was always logged out.

I also tried calling setPersistence from my SignIn.js file but then I could not log in (I think the problem was that I was mixing firebase/compat/auth with firebase/auth)

As I said the documentation is using firebase/auth while I am using firebase/compat/auth. Can someone please advice? Keeping user logged in the app is very important for me.

InsertAdjacentHTML is not a function [duplicate]

Going through the Javascript for Web Warriors book, Chapter 3 Project 5. It’s an assignment to debug the code so that it displays cell phone sales in a barchart. The error: “Uncaught TypeError TypeError: .insertAdjacentHTML is not a function.

// Array of phone models sold by the company
/* Changed parenthesis to braces to define an array - Debugged */
let phones = ["Photon 6E", "Photon 6X", "Photon 7E", "Photon 7X", "Photon 8P"];

// Units sold in the previous quarter
/* Changed parenthesis to braces to define an array - Debugged */
let sales = [10281, 12255, 25718, 21403, 16142];

// Variable to calculate total sales
let totalSales = 0;

// Use the forEach() method to sum the sales for each phone model and add it to the totalSales variable
/* addtoTotal needed to be capitalized to addToTotal - Debugged */
sales.forEach(addToTotal);

// For loop to generate bar chart of phone sales
/* Changed the i value from 1 to 0 - AA */
for (let i = 0; i <= phones.length; i++) {
   
   let barChart = "";   // Variable to store HTML code for table cells used to create bar chart
   
   // Calculate the percent of total sales for a particular phone model
   let barPercent = 100*sales/totalSales;
   
   
   let cellTag;   // Variable that will define the class of td elements used in creating the bar chart cells.
   
   // Determine the table cell based on the value of the phone model
   /* The switch case did not include a colon after each switch statement - Debugged */
   switch (phones[i]) {
      case "Photon 6E":
        cellTag = "<td class='group1'>";
        break;
      case "Photon 6X":
        cellTag = "<td class='group2'>";
        break;
      case "Photon 7E":
        cellTag = "<td class='group3'>";
        break;
      case "Photon 7X":
        cellTag = "<td class='group4'>";
          break;
      case "Photon 8P":
        cellTag = "<td class='group5'>";
        break;         
   }
   
   // Table cell containing information on phone and total sales (formatted using a thousands-separator)
   barChart += "<tr><th>" + phones[i] + " (" + formatNumber(sales[i]) + ")</th>";
   
   // For loop to create a table cell, 1 for each percentage value in the barPercent variable
   for (let j = 0; j <= barPercent; j++) {
      barChart += cellTag + "</td>";
   }
   barChart += "</tr>";

   // Insert the bChart HTML code into first tbody element in the web document
   /* beforeEnd was capitalized, changed to beforeend. - Debugged */
   document.getElementsByTagName("tbody").insertAdjacentHTML("afterbegin", barChart);
}


// Callback function that adds the value of each array element to the totalSales variable
function addToTotal(arrValue) {
   totalSales += arrValue;
}


// Function that takes a number value and returns it as a text string with a thousands separator
function formatNumber(value) {
   return value.toLocaleString();
}

I tried analyzing the HTML and CSS files to see if there was any kind of clue as to where I could potentially be messing up. I understand that I need to insert the code inbetween the <tbody></tbody> section of the HTML file.
So I tried rewriting the code as shown below to see if it would do anything different.

   let TableCell = document.getElementsByTagName("tbody");
   TableCell.insertAdjacentHTML("beforeend", barChart)

I still get the exact same error: “insertAdjacentHTML is not a function”.

Why this is so frustrating and confusing for me is that in a previous assignment, we used EXACTLY what I just tried rewriting the code to and it worked perfectly fine. I’m at an absolute dead end as to what to even try now, and the professor takes weeks to respond where I’m stuck between a rock and a hard place.

What is window.AICreateMonitor?

window.AICreateMonitor seems to be only available in Google Chrome and I assume it has something to do with its new window.ai-API, but it doesn’t need to be activated through any flags. I’ve literally looked everywhere and there is absolutely no information about it anywhere, not even in the Google Chrome docs (https://developer.chrome.com/docs).

I tried invoking it by both doing

new window.AICreateMonitor();

and

window.AICreateMonitor();

and with all sorts of dummy arguments, but it always throws the error: Uncaught TypeError: Illegal constructor. Maybe it’s not production ready yet and it was accidentally shipped, no idea what its purpose is or should have been.

It would be really nice if anyone could tell me something about it.

Error: Model not found when calling createModelReference from the vscode monaco editor

i’m building an electron app. On the renderer site im additionally using SolidJS with vite.

When trying to create a model reference with an registered memory file the Error “Model not found” occurs. I’m pretty much stuck as debugging shows that the file is registered correctly.

Code Snippet:

onMount(async () => {
    await initialize();

    const fileSystemProvider = new RegisteredFileSystemProvider(false);
    const fileURL = '/test-files/test.cpp'; //reference from vite public folder
    const fileName = '/test.cpp';           
    const response = await fetch(fileURL);
    const fileContent = await response.text();

    console.log("Fetched file content:", fileContent);

    const memoryFileUri = vscode.Uri.file(fileName);

    let memoryFile
    fileSystemProvider.registerFile(
      memoryFile = new RegisteredMemoryFile(memoryFileUri, fileContent)
    );

    console.log("Registered memory file:", memoryFile);

    const overlay = registerFileSystemOverlay(1, fileSystemProvider);

    console.log("Calling model reference with:", memoryFileUri.toString());
    // error is thrown here
    const modelRef = await createModelReference(memoryFileUri);

    modelRef.object.setLanguageId('cpp');
    console.log("Model:", modelRef.object.textEditorModel);

    const editor = createConfiguredEditor(container, {
      model: modelRef.object.textEditorModel,
      theme: 'vs-dark',
      automaticLayout: true,
    });

    createWebSocket('ws://localhost:30003/clangd');

    onCleanup(() => {
      editor.dispose();
      modelRef.dispose();
    });
  });

Logs:

Fetched file content: #include <stdio.h>

int main() {
  int b= a();
  return 0;
}

int a() {
  return 0;
}

MonacoEditor.jsx:87 Registered memory file: 
RegisteredMemoryFile {uri: Uri, readonly: false, type: 1, _onDidChange: Emitter, onDidChange: ƒ, …}

MonacoEditor.jsx:91 Calling model reference with: file:///test.cpp

chunk-BD6NCM2E.js?v=8d2335a4:70820 Uncaught (in promise) Error: Model not found
    at async MonacoEditor.jsx:93:22

Tried to create a model reference for the vscode monaco editor.

Thrown the error: Model not found

Model gets created and added to the editor instance.