@mercuryworkshop/epoxy-transport 2.1.14 → 2.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  // import { dtsPlugin } from "esbuild-plugin-d.ts";
2
2
  import { build } from "esbuild";
3
3
  import path from 'node:path'
4
- import fs from 'node:fs'
4
+ import fs, { readFileSync } from 'node:fs'
5
5
  import { umdWrapper } from "esbuild-plugin-umd-wrapper";
6
6
 
7
7
  const umdWrapperOptions = {
@@ -10,6 +10,24 @@ const umdWrapperOptions = {
10
10
  amdLoaderName: "define" // <= default
11
11
  }
12
12
 
13
+ //for the CJS build: we take the import url and translate it into it's corresponding functions and annd that back to the file.
14
+ const dataUrl = {
15
+ name: 'data-url-to-functions',
16
+ setup(build) {
17
+ build.onLoad({ filter: /\.js$/ }, (args) => {
18
+ const source = readFileSync(args.path, 'utf-8');
19
+ const transformedSource = source.replace(/import\s+(?:{[^}]*}\s+from\s+)?['"]data:application\/javascript;base64,([^'"]+)['"];\s*/g, (_, b64) => {
20
+ const code = Buffer.from(b64, 'base64').toString('utf-8');
21
+ return code;
22
+ })
23
+ return {
24
+ contents: transformedSource,
25
+ loader: 'js'
26
+ }
27
+ });
28
+ }
29
+ }
30
+
13
31
  let wasmPlugin = {
14
32
  name: 'wasm',
15
33
  setup(build) {
@@ -86,7 +104,7 @@ build({
86
104
  entryPoints: [`./src/main.ts`],
87
105
  outfile: `./dist/index.js`,
88
106
  external: ["fs", "ws", "path"],
89
- plugins: [wasmPlugin, umdWrapper(umdWrapperOptions)]
107
+ plugins: [wasmPlugin, dataUrl, umdWrapper(umdWrapperOptions)]
90
108
  // plugins: [dtsPlugin({
91
109
  // outDir: `./dist/`,
92
110
  // tsconfig: "tsconfig.json"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercuryworkshop/epoxy-transport",
3
- "version": "2.1.14",
3
+ "version": "2.1.16",
4
4
  "description": "a bare transport that implements end-to-end encryption with epoxy-tls and wisp",
5
5
  "main": "./dist/index.mjs",
6
6
  "keywords": [],
@@ -12,10 +12,10 @@
12
12
  "prepare": "npm run build"
13
13
  },
14
14
  "dependencies": {
15
- "@mercuryworkshop/epoxy-tls": "2.1.7-1"
15
+ "@mercuryworkshop/epoxy-tls": "2.1.8-1"
16
16
  },
17
17
  "devDependencies": {
18
- "@mercuryworkshop/bare-mux": "^2.0.9",
18
+ "@mercuryworkshop/bare-mux": "^2.1.2",
19
19
  "esbuild": "^0.24.0",
20
20
  "esbuild-plugin-d.ts": "^1.3.0",
21
21
  "esbuild-plugin-umd-wrapper": "^3.0.0"