Code Monkey home page Code Monkey logo

Comments (9)

hassandraga avatar hassandraga commented on July 29, 2024

Hi, Can you please add the browser's DevTools logs or a screenshot?

from webui.

sensiblearts avatar sensiblearts commented on July 29, 2024

Thank you for the quick reply.

Index.html loads but is blank:

image

If I right-click and inspect the JS console, I see:

Screenshot JS console

And here is index.html:

(NOTE: I have to put the webui.js script below the SvelteKit starter script; otherwise, it gets into an infinite loop, crashing, Kit restarting, repeat.)

<!doctype html>
<html>
	<head>
		<meta charset="utf-8" />
		<link rel="icon" href="/favicon.png" />
		<link rel="modulepreload" href="/_app/immutable/entry/start.mFb7rvTb.js">
		<link rel="modulepreload" href="/_app/immutable/chunks/entry.Bd4ck04i.js">
		<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.Vg6e9bTg.js">
		<link rel="modulepreload" href="/_app/immutable/chunks/index.DtEDIqaG.js">
		<link rel="modulepreload" href="/_app/immutable/chunks/control.CYgJF_JY.js">
		<link rel="modulepreload" href="/_app/immutable/entry/app.iE8pe31a.js">
		<link rel="modulepreload" href="/_app/immutable/chunks/preload-helper.BQ24v_F8.js">
		<link rel="modulepreload" href="/_app/immutable/chunks/index.kVFNCZ3-.js">
	</head> 
	<body data-sveltekit-preload-data="hover"; class="overflow-hidden">
		<div style="display: contents;">
			<script>
				{
					__sveltekit_1pkutvc = {
						base: ""
					};

					const element = document.currentScript.parentElement;

					Promise.all([
						import("/_app/immutable/entry/start.mFb7rvTb.js"),
						import("/_app/immutable/entry/app.iE8pe31a.js")
					]).then(([kit, app]) => {
						// console.log("starting...")
						kit.start(app, element);
						// console.log("started")
					});
				}
			</script>
			<script src="webui.js"></script>
	</div>
</body>
</html>
    

from webui.

sensiblearts avatar sensiblearts commented on July 29, 2024

WAIT -- I think I found the problem -- not a webui thing, so don't waste any more of your time.

I switched to Windows dev (from WSL Ubuntu) for Zig, and my Windows CouchDb settings are I think the problem. I'm going down that route and will report back (and probably close this).

from webui.

hassandraga avatar hassandraga commented on July 29, 2024

Yes, that's what I was about to write, your server at 5984 should allow Access-Control-Allow-Origin from *.

from webui.

sensiblearts avatar sensiblearts commented on July 29, 2024

Yes, I had not copied all settings correctly, so the CORS issue is solved.

However, the infinite loop (crash / reload) described above is still happening, regardless of where I place the webui.js script (See "NOTE", above).

My app starts to load (screenshot):

Screenshot zig webui

...but then it seems to be looking for index.html again, cannot find it, crashes, and sveltekit reloads.

Here's the console (pink is crashing, all the white logs are successful API calls; this repeats in a loop):

Screenshot JS console

from webui.

hassandraga avatar hassandraga commented on July 29, 2024

If you want to use a custom web server with WebUI, you can then look at this C example on how to do that.
The example is using a Python web server, and using WebUI to show a window, and track the click events using webui.js.

https://github.com/webui-dev/webui/blob/main/examples/C/custom_web_server/main.c

from webui.

sensiblearts avatar sensiblearts commented on July 29, 2024

Thanks, but no I don't need to write a server, it's just a SvelteKit SPA, with only client-side code. (SvelteKit can do server side, and is probably used mostly for that, but it also does SPAs by turning off all server-side stuff.)

The SPA makes many fetch calls to APIs that are separate apps.

I have a suspicion about what's happening, and that the problem is due to SvelteKit's client-side router or other code that SvelteKit generates. (SvelteKit does a ton behind the scenes, which is why it's so easy to write apps. But this ton of stuff is all compiled and mostly impenetrable by me.)

Anyway, what I think is happening:

  1. Something is happening to cause an error, during the initial load
  2. SvelteKit handles errors by reloading or re-routing
  3. WebUI is also responding to this re-routing, and tries to load index.html again...
  4. which triggers the error; goto (1)

I'll figure it out and, if it's of interest to the WebUI community I'll post back.

Closing this for now.

from webui.

hassandraga avatar hassandraga commented on July 29, 2024

Yes, I'm interested in learning more about this issue. We can improve WebUI or add a new option to make it more flexible to handle this kind of situation. When you have free time. Thank you.

from webui.

sensiblearts avatar sensiblearts commented on July 29, 2024

It seems to be a fundamental conflict with how SvelteKit works. I created a test project that has the same problem. The project is linked to in the new issue I opened: #392

from webui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.