webuix 0.0.2 → 0.0.3

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.
package/build.ts CHANGED
@@ -1,8 +1,13 @@
1
+ import dts from "bun-plugin-dts";
1
2
  import { writeFileSync, readFileSync } from "fs";
2
3
  import { execSync } from "child_process";
4
+ import type { BuildConfig } from "bun";
3
5
 
4
6
  // Get Git commit count
5
- const count = parseInt(execSync("git rev-list --count HEAD").toString().trim(), 10);
7
+ const count = parseInt(
8
+ execSync("git rev-list --count HEAD").toString().trim(),
9
+ 10
10
+ );
6
11
 
7
12
  // Compute MAJOR.MINOR.PATCH
8
13
  const MAJOR = Math.floor(count / 10000);
@@ -16,15 +21,25 @@ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
16
21
  pkg.version = version;
17
22
  writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
18
23
 
19
- // Run Bun build
20
- Bun.build({
21
- entrypoints: ["./src/index.ts", "./src/wrappers/index.ts"],
22
- outdir: "./dist",
23
- minify: false,
24
- target: "browser",
25
- format: "cjs",
26
- splitting: true,
27
- }).catch((err) => {
28
- console.error(err);
29
- process.exit(1);
30
- });
24
+ const minify = true;
25
+ const formats: Array<BuildConfig["format"]> = ["cjs", "esm"];
26
+
27
+ for (const format of formats) {
28
+ Bun.build({
29
+ entrypoints: ["./src/index.ts"],
30
+ outdir: `./dist/`,
31
+ minify: minify,
32
+ target: "browser",
33
+ format: format,
34
+ plugins: [dts()],
35
+ splitting: true,
36
+ naming: {
37
+ entry: `[name].${format}.js`,
38
+ chunk: "[name]-[hash].js",
39
+ asset: "[name]-[hash][ext]",
40
+ },
41
+ }).catch((err) => {
42
+ console.error(err);
43
+ process.exit(1);
44
+ });
45
+ }
package/bun.lockb CHANGED
Binary file
@@ -0,0 +1 @@
1
+ var{defineProperty:p,getOwnPropertyNames:S,getOwnPropertyDescriptor:b}=Object,y=Object.prototype.hasOwnProperty;var d=new WeakMap,w=(t)=>{var r=d.get(t),e;if(r)return r;if(r=p({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")S(t).map((a)=>!y.call(r,a)&&p(r,a,{get:()=>t[a],enumerable:!(e=b(t,a))||e.enumerable}));return d.set(t,r),r};var h=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0,configurable:!0,set:(a)=>r[e]=()=>a})};var g={};h(g,{wrapToReadableStream:()=>c,wrapInputStream:()=>f});module.exports=w(g);var s={chunkSize:1048576,headers:{"Content-Type":"application/octet-stream"}};async function c(t,r={}){let e={...s,...r};return new Promise((a,l)=>{let o;try{if(o=t,!o)throw new Error("Failed to open file input stream")}catch(n){l(n);return}let u=()=>{try{o?.close()}catch(n){console.error("Error during abort cleanup:",n)}l(new DOMException("The operation was aborted.","AbortError"))};if(e.signal){if(e.signal.aborted){u();return}e.signal.addEventListener("abort",u)}let I=new ReadableStream({async pull(n){try{let i=R(o,e.chunkSize);if(!i){n.close(),m();return}n.enqueue(i)}catch(i){m(),n.error(i),l(new Error(`Error reading file chunk: ${i}`))}},cancel(n){console.warn("Stream canceled:",n),m()}});function m(){try{if(e.signal)e.signal.removeEventListener("abort",u);o?.close()}catch(n){console.error(`Error during cleanup: ${n}`)}}a(I)})}function R(t,r){try{let e=r?t.readChunk(r):t.read();if(typeof e==="number")return new Uint8Array([e]);else if(typeof e==="string"){let a=JSON.parse(e);return a&&Array.isArray(a)&&a.length>0?new Uint8Array(a):null}return null}catch(e){throw new Error("Error reading chunk data: "+e)}}async function f(t,r={}){let e={...s,...r};try{let a=await c(t,e);return new Response(a,e)}catch(a){throw new Error(`wrapInputStream failed: ${a}`)}}
@@ -0,0 +1,24 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /**
4
+ * This is a private interface which is not accessible in the window object.
5
+ * It is used to define the structure of a file input stream.
6
+ */
7
+ export interface FileInputInterfaceStream {
8
+ read(): number;
9
+ /**
10
+ * This method needs to be parsed with `JSON.parse(...)`
11
+ * @param chinkSize The size of the chunk to read
12
+ * @returns The chunk data as a string
13
+ */
14
+ readChunk(chinkSize: number): string;
15
+ close(): void;
16
+ skip(n: number): number;
17
+ }
18
+ export interface ReadableStreamInit extends RequestInit {
19
+ chunkSize?: number;
20
+ }
21
+ export declare function wrapToReadableStream(inputStream: FileInputInterfaceStream, init?: ReadableStreamInit): Promise<ReadableStream<Uint8Array>>;
22
+ export declare function wrapInputStream(inputStream: FileInputInterfaceStream, init?: ReadableStreamInit): Promise<Response>;
23
+
24
+ export {};
@@ -0,0 +1 @@
1
+ var m={chunkSize:1048576,headers:{"Content-Type":"application/octet-stream"}};async function p(a,n={}){let e={...m,...n};return new Promise((t,c)=>{let o;try{if(o=a,!o)throw new Error("Failed to open file input stream")}catch(r){c(r);return}let l=()=>{try{o?.close()}catch(r){console.error("Error during abort cleanup:",r)}c(new DOMException("The operation was aborted.","AbortError"))};if(e.signal){if(e.signal.aborted){l();return}e.signal.addEventListener("abort",l)}let s=new ReadableStream({async pull(r){try{let i=d(o,e.chunkSize);if(!i){r.close(),u();return}r.enqueue(i)}catch(i){u(),r.error(i),c(new Error(`Error reading file chunk: ${i}`))}},cancel(r){console.warn("Stream canceled:",r),u()}});function u(){try{if(e.signal)e.signal.removeEventListener("abort",l);o?.close()}catch(r){console.error(`Error during cleanup: ${r}`)}}t(s)})}function d(a,n){try{let e=n?a.readChunk(n):a.read();if(typeof e==="number")return new Uint8Array([e]);else if(typeof e==="string"){let t=JSON.parse(e);return t&&Array.isArray(t)&&t.length>0?new Uint8Array(t):null}return null}catch(e){throw new Error("Error reading chunk data: "+e)}}async function f(a,n={}){let e={...m,...n};try{let t=await p(a,e);return new Response(t,e)}catch(t){throw new Error(`wrapInputStream failed: ${t}`)}}export{p as wrapToReadableStream,f as wrapInputStream};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webuix",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "A library to make your life easier when working with MMRL's WebUI",
6
6
  "source": "src/index.ts",
@@ -15,7 +15,9 @@
15
15
  "author": "",
16
16
  "license": "GPL-3.0-only",
17
17
  "devDependencies": {
18
- "@types/bun": "latest"
18
+ "@types/bun": "latest",
19
+ "bun-plugin-dts": "^0.3.0",
20
+ "tsc": "^2.0.4"
19
21
  },
20
22
  "peerDependencies": {
21
23
  "typescript": "^5.0.0"
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- // src/index.ts
2
- console.log("This is a test for Bun's TypeScript support.");
@@ -1,135 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
6
- var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
8
- if (entry)
9
- return entry;
10
- entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
16
- __moduleCache.set(from, entry);
17
- return entry;
18
- };
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
-
29
- // src/wrappers/index.ts
30
- var exports_wrappers = {};
31
- __export(exports_wrappers, {
32
- wrapToReadableStream: () => wrapToReadableStream,
33
- wrapInputStream: () => wrapInputStream
34
- });
35
- module.exports = __toCommonJS(exports_wrappers);
36
-
37
- // src/wrappers/wrapToReadableStream.ts
38
- var readableStreamInit = {
39
- chunkSize: 1024 * 1024,
40
- headers: {
41
- "Content-Type": "application/octet-stream"
42
- }
43
- };
44
- async function wrapToReadableStream(inputStream, init = {}) {
45
- const mergedInit = {
46
- ...readableStreamInit,
47
- ...init
48
- };
49
- return new Promise((resolve, reject) => {
50
- let input;
51
- try {
52
- input = inputStream;
53
- if (!input) {
54
- throw new Error("Failed to open file input stream");
55
- }
56
- } catch (error) {
57
- reject(error);
58
- return;
59
- }
60
- const abortHandler = () => {
61
- try {
62
- input?.close();
63
- } catch (error) {
64
- console.error("Error during abort cleanup:", error);
65
- }
66
- reject(new DOMException("The operation was aborted.", "AbortError"));
67
- };
68
- if (mergedInit.signal) {
69
- if (mergedInit.signal.aborted) {
70
- abortHandler();
71
- return;
72
- }
73
- mergedInit.signal.addEventListener("abort", abortHandler);
74
- }
75
- const stream = new ReadableStream({
76
- async pull(controller) {
77
- try {
78
- const chunkData = getChunkData(input, mergedInit.chunkSize);
79
- if (!chunkData) {
80
- controller.close();
81
- cleanup();
82
- return;
83
- }
84
- controller.enqueue(chunkData);
85
- } catch (error) {
86
- cleanup();
87
- controller.error(error);
88
- reject(new Error(`Error reading file chunk: ${error}`));
89
- }
90
- },
91
- cancel(reason) {
92
- console.warn("Stream canceled:", reason);
93
- cleanup();
94
- }
95
- });
96
- function cleanup() {
97
- try {
98
- if (mergedInit.signal) {
99
- mergedInit.signal.removeEventListener("abort", abortHandler);
100
- }
101
- input?.close();
102
- } catch (error) {
103
- console.error(`Error during cleanup: ${error}`);
104
- }
105
- }
106
- resolve(stream);
107
- });
108
- }
109
- function getChunkData(input, chunkSize) {
110
- try {
111
- const chunkData = chunkSize ? input.readChunk(chunkSize) : input.read();
112
- if (typeof chunkData === "number") {
113
- return new Uint8Array([chunkData]);
114
- } else if (typeof chunkData === "string") {
115
- const chunk = JSON.parse(chunkData);
116
- return chunk && Array.isArray(chunk) && chunk.length > 0 ? new Uint8Array(chunk) : null;
117
- }
118
- return null;
119
- } catch (error) {
120
- throw new Error("Error reading chunk data: " + error);
121
- }
122
- }
123
- // src/wrappers/wrapInputStream.ts
124
- async function wrapInputStream(inputStream, init = {}) {
125
- const mergedInit = {
126
- ...readableStreamInit,
127
- ...init
128
- };
129
- try {
130
- const stream = await wrapToReadableStream(inputStream, mergedInit);
131
- return new Response(stream, mergedInit);
132
- } catch (error) {
133
- throw new Error(`wrapInputStream failed: ${error}`);
134
- }
135
- }