Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for creating widget bundles #69

Merged
merged 3 commits into from
Nov 6, 2023
Merged

support for creating widget bundles #69

merged 3 commits into from
Nov 6, 2023

Conversation

paulfitz
Copy link
Member

@paulfitz paulfitz commented Sep 25, 2023

It can be useful to include custom widgets with Grist, so they can be used offline, or for simpler archiving, or for tighter integration with the rest of the app. This PR includes a script for collecting custom widget files in a structured bundle. It is parallel work to developments in grist-core, including gristlabs/grist-core#714

@netlify
Copy link

netlify bot commented Sep 25, 2023

Deploy Preview for boisterous-sunburst-a5c941 ready!

Name Link
🔨 Latest commit b0516fe
🔍 Latest deploy log https://app.netlify.com/sites/boisterous-sunburst-a5c941/deploys/6549083a4eced300088d9911
😎 Deploy Preview https://deploy-preview-69--boisterous-sunburst-a5c941.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

It can be useful to include custom widgets with Grist, so they
can be used offline, or for simpler archiving, or for tighter
integration with the rest of the app. This PR includes a script
for collecting custom widget files in a structured bundle. It will
need some parallel work in Grist itself to serve the bundle.
@paulfitz paulfitz marked this pull request as ready for review October 30, 2023 21:17
@paulfitz paulfitz changed the title preliminary support for bundling widgets preliminary support for creating widget bundles Oct 30, 2023
@paulfitz paulfitz changed the title preliminary support for creating widget bundles support for creating widget bundles Oct 30, 2023
@berhalak berhalak self-requested a review October 31, 2023 13:23
Copy link
Contributor

@berhalak berhalak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think dist can be added to .gitignore.

}

// Start a widget server.
start() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this, to make sure it works, (I have python 2.7 by default so it breaks for me):

  async start() {
    this.localServer = spawn('python', [
      '-u', '-m', 'http.server', this.port,
    ], {
      cwd: process.cwd(),
    });

    await new Promise((resolve, reject) => {
      this.localServer.stdout.on('data', (data) => {
        if (data.toString().includes('Serving HTTP on')) {
          resolve();
        }
      });
      this.localServer.stderr.on('data', (data) => {
        reject(data.toString());
      });
    });
  }
  

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to wait for the server to be up and responsive, instead of the wait() method? I think I'd still have a weak preference for waiting for a fetch() to succeed, since it seems easier to be confident of it. When checking a message on console, I find myself asking is this printed before or after the server is started. I'm a bit daunted about tracking down exact python source code, but it may be like this:
https://github.com/python/cpython/blob/20cfab903db70cf952128bc6b606e3ec4a216498/Lib/http/server.py#L1267-L1275
which at first glance looks like it prints the message first.

Separately, maybe I should write python3 instead of python?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, python3 will be enough :)

* included in the bundle. Material needed by any
* extra entry-point pages will be included as well.
*
* The bundle will also include grist-plugin-api.js.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work for me, should it be added to the domains?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, I had commented out a // domains.push('getgrist.com') line. I put it back in.

@paulfitz paulfitz requested a review from berhalak November 3, 2023 17:44
Copy link
Contributor

@berhalak berhalak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@paulfitz paulfitz merged commit d0b74a4 into master Nov 6, 2023
@paulfitz paulfitz deleted the paulfitz/bundling branch November 6, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants