From 24c7d1d161051a735be633e97cfc65a196bf996e Mon Sep 17 00:00:00 2001 From: Benedikt Strehle Date: Sun, 6 Jul 2025 23:42:21 +0200 Subject: [PATCH 1/6] update wasm js file --- scripts/build-wasm.ts | 34 +++++++++++++++++++-------------- src/datex-core/datex_core_js.js | 34 +++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/scripts/build-wasm.ts b/scripts/build-wasm.ts index a2d3a21..f266ee6 100644 --- a/scripts/build-wasm.ts +++ b/scripts/build-wasm.ts @@ -51,20 +51,26 @@ if (!flags.inline) { const jsFile = dedent` import * as imports from "./${NAME}.internal.js"; // for deno-to-node builds, fetch does not support streaming webassembly instantiation - let isDntBuild = !!globalThis[Symbol.for("import-meta-ponyfill-commonjs")]; - const wasm = (isDntBuild - ? await WebAssembly.instantiate( - await Deno.readFile(new URL("${NAME}.wasm", import.meta.url)), - { - "./${NAME}.internal.js": imports, - }, - ) - : await WebAssembly.instantiateStreaming( - fetch(new URL("${NAME}.wasm", import.meta.url)), - { - "./${NAME}.internal.js": imports, - }, - )).instance; + const isDntBuild = !!globalThis[Symbol.for("import-meta-ponyfill-commonjs")]; + const isBrowser = !globalThis.navigator.userAgent.startsWith("Deno") && + !globalThis.navigator.userAgent.startsWith("Node.js") && + !globalThis.navigator.userAgent.startsWith("Bun"); + const wasm = ( + isBrowser // TODO: Deno should also do instantiateStreaming (globalThis.Deno && !isDntBuild) + ? await WebAssembly.instantiateStreaming( + // dnt-shim-ignore + fetch(new URL("${NAME}.wasm", import.meta.url)), + { + "./${NAME}.internal.js": imports, + }, + ) + : await WebAssembly.instantiate( + await Deno.readFile(new URL("${NAME}.wasm", import.meta.url)), + { + "./${NAME}.internal.js": imports, + }, + ) + ).instance; export * from "./${NAME}.internal.js"; import { __wbg_set_wasm } from "./${NAME}.internal.js"; __wbg_set_wasm(wasm.exports); diff --git a/src/datex-core/datex_core_js.js b/src/datex-core/datex_core_js.js index 0c3571f..148f21c 100644 --- a/src/datex-core/datex_core_js.js +++ b/src/datex-core/datex_core_js.js @@ -1,19 +1,25 @@ import * as imports from "./datex_core_js.internal.js"; // for deno-to-node builds, fetch does not support streaming webassembly instantiation -let isDntBuild = !!globalThis[Symbol.for("import-meta-ponyfill-commonjs")]; -const wasm = (isDntBuild - ? await WebAssembly.instantiate( - await Deno.readFile(new URL("datex_core_js.wasm", import.meta.url)), - { - "./datex_core_js.internal.js": imports, - }, - ) - : await WebAssembly.instantiateStreaming( - fetch(new URL("datex_core_js.wasm", import.meta.url)), - { - "./datex_core_js.internal.js": imports, - }, - )).instance; +const isDntBuild = !!globalThis[Symbol.for("import-meta-ponyfill-commonjs")]; +const isBrowser = !globalThis.navigator.userAgent.startsWith("Deno") && + !globalThis.navigator.userAgent.startsWith("Node.js") && + !globalThis.navigator.userAgent.startsWith("Bun"); +const wasm = ( + isBrowser // TODO: Deno should also do instantiateStreaming (globalThis.Deno && !isDntBuild) + ? await WebAssembly.instantiateStreaming( + // dnt-shim-ignore + fetch(new URL("datex_core_js.wasm", import.meta.url)), + { + "./datex_core_js.internal.js": imports, + }, + ) + : await WebAssembly.instantiate( + await Deno.readFile(new URL("datex_core_js.wasm", import.meta.url)), + { + "./datex_core_js.internal.js": imports, + }, + ) +).instance; export * from "./datex_core_js.internal.js"; import { __wbg_set_wasm } from "./datex_core_js.internal.js"; __wbg_set_wasm(wasm.exports); From 6be97be3238f1e00f84f9ed9fa78a970e55ddcf3 Mon Sep 17 00:00:00 2001 From: Benedikt Strehle Date: Sun, 6 Jul 2025 23:54:48 +0200 Subject: [PATCH 2/6] update npm build --- scripts/build-npm.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/build-npm.ts b/scripts/build-npm.ts index b5929fc..5293e87 100644 --- a/scripts/build-npm.ts +++ b/scripts/build-npm.ts @@ -35,8 +35,18 @@ await build({ url: "https://github.com/unyt-org/datex-core-js/issues", }, }, + // steps to run after building and before running the tests postBuild() { - // steps to run after building and before running the tests + // replace import.meta because dnt-shim-ignore does not work here + const datexCoreJSInternalPath = new URL("../npm/esm/src/datex-core/datex_core_js.js", import.meta.url); + const fileContent = Deno.readTextFileSync(datexCoreJSInternalPath); + const updatedContent = fileContent.replace( + `globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url`, + `import.meta.url`, + ); + Deno.writeTextFileSync(datexCoreJSInternalPath, updatedContent); + + Deno.copyFileSync("README.md", "npm/README.md"); Deno.copyFileSync( "src/datex-core/datex_core_js.wasm", @@ -51,4 +61,4 @@ await build({ "npm/esm/rs-lib/datex-core/Cargo.toml", ); }, -}); +}); \ No newline at end of file From d0b30cd12771a8998d0206d63b035ab0293c0717 Mon Sep 17 00:00:00 2001 From: Benedikt Strehle Date: Sun, 6 Jul 2025 23:55:36 +0200 Subject: [PATCH 3/6] deno fmt --- scripts/build-npm.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/build-npm.ts b/scripts/build-npm.ts index 5293e87..d5b0911 100644 --- a/scripts/build-npm.ts +++ b/scripts/build-npm.ts @@ -38,7 +38,10 @@ await build({ // steps to run after building and before running the tests postBuild() { // replace import.meta because dnt-shim-ignore does not work here - const datexCoreJSInternalPath = new URL("../npm/esm/src/datex-core/datex_core_js.js", import.meta.url); + const datexCoreJSInternalPath = new URL( + "../npm/esm/src/datex-core/datex_core_js.js", + import.meta.url, + ); const fileContent = Deno.readTextFileSync(datexCoreJSInternalPath); const updatedContent = fileContent.replace( `globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url`, @@ -46,7 +49,6 @@ await build({ ); Deno.writeTextFileSync(datexCoreJSInternalPath, updatedContent); - Deno.copyFileSync("README.md", "npm/README.md"); Deno.copyFileSync( "src/datex-core/datex_core_js.wasm", @@ -61,4 +63,4 @@ await build({ "npm/esm/rs-lib/datex-core/Cargo.toml", ); }, -}); \ No newline at end of file +}); From 176b6fdeae0ea478eb6eae8ce9f1a19d717f7f74 Mon Sep 17 00:00:00 2001 From: benStre Date: Sun, 6 Jul 2025 21:56:25 +0000 Subject: [PATCH 4/6] Bump version to 0.0.4 --- Cargo.lock | 2 +- deno.json | 2 +- rs-lib/Cargo.toml | 2 +- src/runtime/runtime.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b20ee8..6245c10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1228,7 +1228,7 @@ dependencies = [ [[package]] name = "datex-core-js" -version = "0.0.3" +version = "0.0.4" dependencies = [ "async-trait", "datex-core", diff --git a/deno.json b/deno.json index 3802f28..aa33206 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@unyt/datex", - "version": "0.0.3", + "version": "0.0.4", "license": "MIT", "exports": "./src/mod.ts", "compilerOptions": { diff --git a/rs-lib/Cargo.toml b/rs-lib/Cargo.toml index 701a318..e7d9840 100644 --- a/rs-lib/Cargo.toml +++ b/rs-lib/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "datex-core-js" -version = "0.0.3" +version = "0.0.4" authors = [ "Benedikt Strehle ", "Jonas Strehle ", diff --git a/src/runtime/runtime.ts b/src/runtime/runtime.ts index 1f2f941..7357b49 100644 --- a/src/runtime/runtime.ts +++ b/src/runtime/runtime.ts @@ -2,7 +2,7 @@ import type { JSComHub, JSMemory, JSRuntime } from "../datex-core.ts"; import { execute, execute_internal, init_runtime } from "../datex-core.ts"; // auto-generated version - do not edit: -const VERSION: string = "0.0.3"; +const VERSION: string = "0.0.4"; interface DebugFlags { allow_unsigned_blocks?: boolean; From 2f35f578ce72d4e42d366d1d6ead9a8e172a9017 Mon Sep 17 00:00:00 2001 From: Benedikt Strehle Date: Mon, 7 Jul 2025 00:03:07 +0200 Subject: [PATCH 5/6] fix navigator, update node version --- .github/workflows/publish.yml | 2 +- scripts/build-wasm.ts | 6 +++--- src/datex-core/datex_core_js.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9bb5fe3..9b418a5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -64,7 +64,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: "20.x" + node-version: "24.x" registry-url: "https://registry.npmjs.org" - name: Build for NPM diff --git a/scripts/build-wasm.ts b/scripts/build-wasm.ts index f266ee6..45b5f76 100644 --- a/scripts/build-wasm.ts +++ b/scripts/build-wasm.ts @@ -52,9 +52,9 @@ if (!flags.inline) { import * as imports from "./${NAME}.internal.js"; // for deno-to-node builds, fetch does not support streaming webassembly instantiation const isDntBuild = !!globalThis[Symbol.for("import-meta-ponyfill-commonjs")]; - const isBrowser = !globalThis.navigator.userAgent.startsWith("Deno") && - !globalThis.navigator.userAgent.startsWith("Node.js") && - !globalThis.navigator.userAgent.startsWith("Bun"); + const isBrowser = !globalThis.navigator?.userAgent.startsWith("Deno") && + !globalThis.navigator?.userAgent.startsWith("Node.js") && + !globalThis.navigator?.userAgent.startsWith("Bun"); const wasm = ( isBrowser // TODO: Deno should also do instantiateStreaming (globalThis.Deno && !isDntBuild) ? await WebAssembly.instantiateStreaming( diff --git a/src/datex-core/datex_core_js.js b/src/datex-core/datex_core_js.js index 148f21c..8f19ac9 100644 --- a/src/datex-core/datex_core_js.js +++ b/src/datex-core/datex_core_js.js @@ -1,9 +1,9 @@ import * as imports from "./datex_core_js.internal.js"; // for deno-to-node builds, fetch does not support streaming webassembly instantiation const isDntBuild = !!globalThis[Symbol.for("import-meta-ponyfill-commonjs")]; -const isBrowser = !globalThis.navigator.userAgent.startsWith("Deno") && - !globalThis.navigator.userAgent.startsWith("Node.js") && - !globalThis.navigator.userAgent.startsWith("Bun"); +const isBrowser = !globalThis.navigator?.userAgent.startsWith("Deno") && + !globalThis.navigator?.userAgent.startsWith("Node.js") && + !globalThis.navigator?.userAgent.startsWith("Bun"); const wasm = ( isBrowser // TODO: Deno should also do instantiateStreaming (globalThis.Deno && !isDntBuild) ? await WebAssembly.instantiateStreaming( From c7fc786a35ead0077fabf8b63c1e6432f95a8dfe Mon Sep 17 00:00:00 2001 From: Benedikt Strehle Date: Mon, 7 Jul 2025 00:08:59 +0200 Subject: [PATCH 6/6] capitalize rust --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 613b113..a97e1e0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The DATEX logo The DATEX Core Library for JavaScript (DATEX Core JS) is based on the -[DATEX Core](https://github.com/unyt-org/datex-core) rust library and provides a +[DATEX Core](https://github.com/unyt-org/datex-core) Rust library and provides a high-level API for working with DATEX in JavaScript and TypeScript. DATEX is developed and maintained by the [unyt.org](https://unyt.org) organization and community.