Coder Social home page Coder Social logo

Global types about gnome-shell HOT 4 CLOSED

gjsify avatar gjsify commented on August 25, 2024 1
Global types

from gnome-shell.

Comments (4)

schnz avatar schnz commented on August 25, 2024 1

Take this with a grain of salt, since I am also not very familiar with the build scripts. But from what I can tell, this should work:

Step 1

Create a file packages/gnome-shell/src/global.d.ts:

import Shell from "@girs/shell-13";

declare global {
  const global: Shell.Global;
}

interface Math {
  /**
   * Returns {@link x} clamped to the inclusive range of {@link min} and {@link max}.
   * @see https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/8a8539ee6766058b39d0a5c0961a08f76799f4da/js/ui/environment.js#L357
   *
   * @param x The value to be clamped.
   * @param min The lower bound of the result.
   * @param max The upper bound of the result.
   */
  clamp(x: number, min: number, max: number): number;
}

// [...] further declarations as you see fit

Step 2

In packages/gnome-shell/scripts/generate-exports.js, packages/gnome-shell/scripts/generate-files.js, and packages/gnome-shell/scripts/generate-index.js you can add global.d.ts to the IGNORE_FILENAMES array. This prevents the d.ts file from being exported as gnome resource module etc.

Run yarn run build. The global.d.ts file should be part of the dist folder now and can be imported/referenced from downstream projects.


I haven't gave this much thought. @JumpLink does know the architecture alot better than I do :)

from gnome-shell.

JumpLink avatar JumpLink commented on August 25, 2024

Thank you very much, I will look at this in detail as soon as possible

from gnome-shell.

swsnr avatar swsnr commented on August 25, 2024

@JumpLink @schnz I've opened #13 for this 🙂

from gnome-shell.

Freed-Wu avatar Freed-Wu commented on August 25, 2024

The global.d.ts file should be part of the dist folder now

However, the document still said import '@girs/gnome-shell/extensions/global'; not import '@girs/gnome-shell/dist/extensions/global';

from gnome-shell.

Related Issues (15)

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.