Giter Site home page Giter Site logo

Comments (14)

simonw avatar simonw commented on September 28, 2024

https://stackoverflow.com/a/60845153 suggests that preload.js now needs to be included in extraResources or one of the other similar keys.

from datasette-app.

simonw avatar simonw commented on September 28, 2024

https://www.electronjs.org/docs/latest/tutorial/tutorial-preload

Relevant code:

datasette-app/main.js

Lines 469 to 477 in 6de9080

function windowOpts(extraOpts) {
extraOpts = extraOpts || {};
let opts = {
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, extraOpts.preload || "preload.js"),
},
};

from datasette-app.

simonw avatar simonw commented on September 28, 2024

https://www.electron.build/configuration/contents#files - maybe adding it to "files" could help, e.g. this app does that: https://github.com/tencentyun/TRTCSDK/blob/7b1578a21cad7d16fcb57664e1ee7a34b0fa1b1d/Electron/TRTC-API-Example/package.json#L47

from datasette-app.

simonw avatar simonw commented on September 28, 2024

I grabbed the app.asar file from the latest build and extracted it:

npx asar extract app.asar .

Got this:

drwxr-xr-x   3 simon  wheel    96B Feb 16 20:14 .github
-rw-r--r--   1 simon  wheel   3.5K Feb 16 20:14 README.md
-rw-r--r--@  1 simon  wheel   3.1M Feb 16 20:13 app.asar
-rw-r--r--   1 simon  wheel   397B Feb 16 20:14 did-fail-load.html
-rwxr-xr-x   1 simon  wheel   521B Feb 16 20:14 download-python.sh
-rw-r--r--   1 simon  wheel   4.3K Feb 16 20:14 loading.html
-rw-r--r--   1 simon  wheel    32K Feb 16 20:14 main.js
drwxr-xr-x  13 simon  wheel   416B Feb 16 20:14 node_modules
-rw-r--r--   1 simon  wheel   432B Feb 16 20:14 package.json
-rw-r--r--   1 simon  wheel   3.9K Feb 16 20:14 progress.html
-rw-r--r--   1 simon  wheel    10B Feb 16 20:14 requirements.txt
drwxr-xr-x   3 simon  wheel    96B Feb 16 20:14 scripts
-rw-r--r--   1 simon  wheel   169B Feb 16 20:14 server-log-preload.js
-rw-r--r--   1 simon  wheel   649B Feb 16 20:14 server-log.html
drwxr-xr-x   3 simon  wheel    96B Feb 16 20:14 test
drwxr-xr-x   3 simon  wheel    96B Feb 16 20:14 test-videos

Not sure why all of that stuff is in there but preload.js is not.

Also don't want the test-videos folder in there! That's the video generated during CI runs.

from datasette-app.

simonw avatar simonw commented on September 28, 2024

It would be useful if I could run a build on my laptop instead of just in CI.

Adding this to "build" in package.json almost but didn't quite fix that:

    "mac": {
      "target": {
        "target": "default",
        "arch": [
          "x64"
        ]
      },

from datasette-app.

simonw avatar simonw commented on September 28, 2024

New theory:

image

I think it's down to this line in preload.js:

const path = require("path");

https://www.reddit.com/r/electronjs/comments/wydus6/unable_to_require_path_and_fs_modules_in_preload/ has a tip:

Electron v20 changes the default setting for sandboxing renderers with preload scripts to true. This means you need to set the sandbox: false option on your BrowserWindow to access Node APIs in your preload.

https://www.electronjs.org/blog/electron-20-0

from datasette-app.

simonw avatar simonw commented on September 28, 2024

The built package still doesn't have preload.js in its app.asar file for some reason.

from datasette-app.

simonw avatar simonw commented on September 28, 2024

Possibly relevant: https://stackoverflow.com/questions/70175316/electron-unable-to-load-preload-script-resources-app-asar-src-preload-js

from datasette-app.

simonw avatar simonw commented on September 28, 2024
npx asar extract app.asar app

That confirms that the preload.js script is NOT in that archive - which is weird, because other files like server-log-preload.js ARE included in that archive.

from datasette-app.

simonw avatar simonw commented on September 28, 2024

After much mucking around locally it looks like adding preload.js to that list did at least convince it to be included in the app.asar file.

from datasette-app.

simonw avatar simonw commented on September 28, 2024

That fixed it! The build generated by https://github.com/simonw/datasette-app/actions/runs/4277650268 worked correctly.

from datasette-app.

simonw avatar simonw commented on September 28, 2024

I grabbed a copy of that build and saved it here - once a few more people have tested I'll ship it as a new release. https://static.simonwillison.net/static/2023/feb-26-datasette-desktop/Datasette.app.zip

from datasette-app.

simonw avatar simonw commented on September 28, 2024

Asked for help testing this in https://discord.com/channels/823971286308356157/823971286941302908/1079616010069495829

from datasette-app.

simonw avatar simonw commented on September 28, 2024

OK, I'm going to ship it.

from datasette-app.

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.