-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Okiki <[email protected]>
- Loading branch information
Showing
2 changed files
with
78 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters