Skip to content

Commit

Permalink
chore: ...
Browse files Browse the repository at this point in the history
Signed-off-by: Okiki <[email protected]>
  • Loading branch information
okikio committed Dec 3, 2024
1 parent ee090b7 commit 6f1ce6e
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 44 deletions.
112 changes: 69 additions & 43 deletions packages/core/repl.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,69 @@
import { build, compress, getFile, setFile, PLATFORM_AUTO, TheFileSystem } from "./src/index.ts";

const fs = await TheFileSystem;

console.log("\n");
await setFile(fs, "/index.tsx", `\
export * as Other from "/new.tsx";
export * from "spring-easing";`);
await setFile(fs, "/new.tsx", "export * from \"@okikio/native\";");
await setFile(fs, "/other.tsx", `\
export * as Other from "/index.tsx";
export * from "@okikio/emitter";`);

console.log(await getFile(fs, "/index.tsx", "string") )
console.log(fs)

const result = await build({
entryPoints: ["/index.tsx", "/new.tsx"],
esbuild: {
treeShaking: true,
splitting: true,
format: "esm"
},
});

console.log(
await compress(
result.contents.map((x: any) => x?.contents),
{ type: "gzip" }
)
);


if (PLATFORM_AUTO === "deno") {
globalThis?.Deno?.exit?.();
} else {
// @ts-ignore Only for Node
globalThis?.process?.exit?.();
}


// import { resolveVersion } from "./src/utils/npm-search";
// console.log(await resolveVersion("@okikio/animate@>=1 <2"))
import type { TarStreamEntry } from "@std/tar/untar-stream";
import { UntarStream } from "@std/tar/untar-stream";
import { normalize, join } from "@std/path/posix";

const response = await fetch("https://pkg.pr.new/@tanstack/react-query@7988");
const content = await response.arrayBuffer();

const contentType = response.headers.get("content-type");


if (contentType?.trim()?.toLowerCase() === "application/tar+gzip") {
// const blob = new Blob([content]);
const stream = new Blob([content]).stream()
.pipeThrough<Uint8Array>(new DecompressionStream("gzip"))
.pipeThrough(new UntarStream());

// Create a reader from the stream
const reader = stream.getReader();

console.log({
stream,
reader
})

// Get the stream as an async iterable
const iterableStream = {
async *[Symbol.asyncIterator]() {
try {

console.log({
result: "result"
})

while (true) {
const result = await reader.read();
if (result.done) break;
yield result.value;
}

console.log({
result_POLL: "result"
})
} finally {
reader.releaseLock();
}
}
};

for await (const entry of iterableStream) {
// console.log({
// entry
// })
const path = normalize(entry.path);
// await Deno.mkdir(dirname(path));

// Convert the stream into a Blob
const blob = await new Response(entry.readable).blob();

// Convert the Blob to an ArrayBuffer and then into a Uint8Array
const arrayBuffer = await blob.arrayBuffer();

const uint8arr = new Uint8Array(arrayBuffer);
console.log({
path: join("./", path)
})
// setFile(args.namespace + ":" + join("./", path), uint8arr);
}

}
10 changes: 9 additions & 1 deletion packages/edge/deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"imports": {
"@bundle/core/": "../core/",
"@bundle/core": "../core/src/index.ts",

"@okikio/emitter": "npm:@okikio/emitter",
"esbuild-wasm/esm/browser.d.ts": "npm:esbuild-wasm/esm/browser.d.ts",
"esbuild-wasm/package.json": "npm:esbuild-wasm/package.json",
Expand All @@ -22,5 +21,14 @@
"@std/path": "jsr:@std/path",
"@std/encoding": "jsr:@std/encoding",
"@std/media-types": "jsr:@std/media-types"
},
"deploy": {
"project": "66040930-9863-498e-b6f0-0657e47d6631",
"exclude": [
"node_modules",
"**/node_modules"
],
"include": [],
"entrypoint": "mod.ts"
}
}

0 comments on commit 6f1ce6e

Please sign in to comment.