webuix 0.0.1

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 ADDED
@@ -0,0 +1,16 @@
1
+ Bun.build({
2
+ entrypoints: ["./src/index.ts", "./src/wrappers/index.ts"],
3
+ outdir: "./dist",
4
+ minify: false,
5
+ target: "browser",
6
+ format: "cjs",
7
+ splitting: true,
8
+ // naming: {
9
+ // entry: `[name].bundle.${ext}`,
10
+ // chunk: `[name]-[hash].${ext}`,
11
+ // asset: "[name]-[hash][ext]",
12
+ // },
13
+ }).catch((err) => {
14
+ console.error(err);
15
+ process.exit(1);
16
+ });
package/bun.lockb ADDED
Binary file
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // src/index.ts
2
+ console.log("This is a test for Bun's TypeScript support.");
@@ -0,0 +1,135 @@
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
+ }
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "webuix",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "A library to make your life easier when working with MMRL's WebUI",
6
+ "source": "src/index.ts",
7
+ "main": "dist/index.cjs.js",
8
+ "module": "dist/index.esm.js",
9
+ "types": "dist/index.d.ts",
10
+ "scripts": {
11
+ "build": "bun run build.ts",
12
+ "upload": "npm run build && npm publish"
13
+ },
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "GPL-3.0-only",
17
+ "devDependencies": {
18
+ "@types/bun": "latest"
19
+ },
20
+ "peerDependencies": {
21
+ "typescript": "^5.0.0"
22
+ }
23
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }