Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 authored Sep 25, 2024
1 parent 0687808 commit 062ebe3
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 29 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ jobs:

- name: Build package
working-directory: src/js
run: bun build pyodide.ts --outdir=dist --sourcemap=linked
run: |
mkdir -p generated
cp ../core/*.ts ./generated/
sed -i 's@../js/@../@g' ./generated/error_handling.ts
sed -i 's@from "types"@from "../types"@g' ./generated/pyproxy.ts
sed -i 's@from "pyodide-util"@from "../pyodide-util"@g' ./generated/pyproxy.ts
bun build pyodide.ts --outdir=dist --sourcemap=linked
- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand Down
10 changes: 5 additions & 5 deletions src/js/api.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { ffi } from "./ffi";
import { CanvasInterface, canvas } from "./canvas";
import { type CanvasInterface, canvas } from "./canvas";

import { PackageData, loadPackage, loadedPackages } from "./load-package";
import { type PyProxy, type PyDict } from "generated/pyproxy";
import { type PackageData, loadPackage, loadedPackages } from "./load-package";
import { type PyProxy, type PyDict } from "./generated/pyproxy";
import { loadBinaryFile } from "./compat";
import { version } from "./version";
import { setStdin, setStdout, setStderr } from "./streams";
import { scheduleCallback } from "./scheduler";
import { TypedArray } from "./types";
import type { TypedArray } from "./types";
import { detectEnvironment } from "./environments";
import "./literal-map.js";
import {
makeGlobalsProxy,
SnapshotConfig,
type SnapshotConfig,
syncUpSnapshotLoad1,
syncUpSnapshotLoad2,
} from "./snapshot";
Expand Down
2 changes: 1 addition & 1 deletion src/js/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
IN_BROWSER_MAIN_THREAD,
IN_BROWSER_WEB_WORKER,
} from "./environments";
import { Lockfile } from "./types";
import type { Lockfile } from "./types";

declare var globalThis: {
importScripts: (url: string) => void;
Expand Down
9 changes: 4 additions & 5 deletions src/js/dynload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ declare var DEBUG: boolean;

import { createLock } from "./lock";
import { memoize } from "./pyodide-util";
import { InternalPackageData } from "./load-package";
import { LoadDynlibFS, ReadFileType } from "./types";
import type { InternalPackageData } from "./load-package";
import type { LoadDynlibFS, ReadFileType } from "./types";

// File System-like type which can be passed to
// Module.loadDynamicLibrary or Module.loadWebAssemblyModule
Expand Down Expand Up @@ -153,9 +153,8 @@ export async function loadDynlibsFromPackage(
) {
// assume that shared libraries of a package are located in <package-name>.libs directory,
// following the convention of auditwheel.
const auditWheelLibDir = `${API.sitepackages}/${
pkg.file_name.split("-")[0]
}.libs`;
const auditWheelLibDir = `${API.sitepackages}/${pkg.file_name.split("-")[0]
}.libs`;

// This prevents from reading large libraries multiple times.
const readFileMemoized: ReadFileType = memoize(Module.FS.readFile);
Expand Down
4 changes: 2 additions & 2 deletions src/js/emscripten-settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @private */

import { ConfigType } from "./pyodide";
import type { ConfigType } from "./pyodide";
import { loadBinaryFile, getBinaryResponse } from "./compat";
import { API, PreRunFunc } from "./types";
import type { API, PreRunFunc } from "./types";

/**
* @private
Expand Down
8 changes: 4 additions & 4 deletions src/js/ffi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export type {
PyBufferView,
PySequence,
PyMutableSequence,
} from "generated/pyproxy";
export type { PythonError } from "generated/error_handling";
} from "./generated/pyproxy";
export type { PythonError } from "./generated/error_handling";
// These need to be imported for their side effects at startup
import "generated/js2python";
import "generated/python2js_buffer";
Expand All @@ -44,9 +44,9 @@ import {
PyBufferView,
PySequence,
PyMutableSequence,
} from "generated/pyproxy";
} from "./generated/pyproxy";

import { PythonError } from "../core/error_handling";
import { PythonError } from "./generated/error_handling";

/**
* See :ref:`js-api-pyodide-ffi`
Expand Down
4 changes: 2 additions & 2 deletions src/js/load-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
} from "./compat.js";
import { createLock } from "./lock";
import { loadDynlibsFromPackage } from "./dynload";
import { PyProxy } from "generated/pyproxy";
import { PyProxy } from "./generated/pyproxy";
import {
canonicalizePackageName,
uriToPackageData,
base16ToBase64,
} from "./packaging-utils";
import { Lockfile } from "./types";
import type { Lockfile } from "./types";

/**
* Initialize the packages index. This is called as early as possible in
Expand Down
16 changes: 10 additions & 6 deletions src/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"access": "public"
},
"version": "0.26.2",
"type": "module",
"description": "The Pyodide JavaScript package",
"keywords": [
"python",
Expand All @@ -22,18 +23,21 @@
".": {
"import": "./dist/pyodide.js",
"types": "./pyodide.ts"
},
"./version": {
"import": "./version.ts",
"types": "./version.ts"
}
},
"files": [
"package.json",
"dist",
"pyodide.ts",
"api.ts",
"types.ts",
"emscripten-settings.ts",
"snapshot.ts"
"generated",
"vendor",
"*.ts"
],
"types": "./pyodide.ts",
"engines": {
"node": ">=18.0.0"
}
}
}
2 changes: 1 addition & 1 deletion src/js/pyodide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { PyodideInterface } from "./api.js";
import type { TypedArray, Module } from "./types";
import type { EmscriptenSettings } from "./emscripten-settings";
import type { PackageData } from "./load-package";
import { SnapshotConfig } from "./snapshot";
import type { SnapshotConfig } from "./snapshot";
export type { PyodideInterface, TypedArray };

export { version, type PackageData };
Expand Down
4 changes: 2 additions & 2 deletions src/js/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { };
import type { PyProxy, PyAwaitable } from "generated/pyproxy";
import type { PyProxy, PyAwaitable } from "./generated/pyproxy";
import { type PyodideInterface } from "./api";
import { type ConfigType } from "./pyodide";
import { type InFuncType } from "./streams";
Expand All @@ -8,7 +8,7 @@ import {
type InternalPackageData,
type PackageLoadMetadata,
} from "./load-package";
import { SnapshotConfig } from "./snapshot";
import type { SnapshotConfig } from "./snapshot";

export type TypedArray =
| Int8Array
Expand Down

0 comments on commit 062ebe3

Please sign in to comment.