@qds.dev/tools 0.8.5 → 0.9.7

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,38 +0,0 @@
1
- import { QWIK_PKG_NAME } from "../repl-constants.qwik.mjs";
2
- import { version } from "@qwik.dev/core";
3
- import qWasmMjs from "@qwik.dev/core/bindings/qwik.wasm.mjs?raw-source";
4
- import qWasmBinUrl from "@qwik.dev/core/bindings/qwik_wasm_bg.wasm?raw-source";
5
- import qBuild from "@qwik.dev/core/dist/build/index.d.ts?raw-source";
6
- import qCoreMinMjs from "@qwik.dev/core/dist/core.min.mjs?raw-source";
7
- import qCoreMjs from "@qwik.dev/core/dist/core.mjs?raw-source";
8
- import qCoreDts from "@qwik.dev/core/dist/core-internal.d.ts?raw-source";
9
- import qOptimizerMjs from "@qwik.dev/core/dist/optimizer.mjs?raw-source";
10
- import qPreloaderMjs from "@qwik.dev/core/dist/preloader.mjs?raw-source";
11
- import qQwikLoaderJs from "@qwik.dev/core/dist/qwikloader.debug.js?raw-source";
12
- import qServerDts from "@qwik.dev/core/dist/server.d.ts?raw-source";
13
- import qServerMjs from "@qwik.dev/core/dist/server.mjs?raw-source";
14
- import qHandlersMjs from "@qwik.dev/core/handlers.mjs?raw-source";
15
-
16
- //#region repl/bundler/bundled.ts
17
- const qwikUrls = {
18
- version,
19
- "/dist/build/index.d.ts": qBuild,
20
- "/dist/core.d.ts": qCoreDts,
21
- "/dist/core.min.mjs": qCoreMinMjs,
22
- "/dist/core.mjs": qCoreMjs,
23
- "/dist/optimizer.mjs": qOptimizerMjs,
24
- "/dist/server.mjs": qServerMjs,
25
- "/dist/server.d.ts": qServerDts,
26
- "/dist/preloader.mjs": qPreloaderMjs,
27
- "/dist/qwikloader.js": qQwikLoaderJs,
28
- "/bindings/qwik.wasm.mjs": qWasmMjs,
29
- "/bindings/qwik_wasm_bg.wasm": qWasmBinUrl,
30
- "/handlers.mjs": qHandlersMjs
31
- };
32
- const bundled = { [QWIK_PKG_NAME]: qwikUrls };
33
- const getDeps = () => {
34
- return bundled;
35
- };
36
-
37
- //#endregion
38
- export { getDeps };
@@ -1,89 +0,0 @@
1
- import { getDeps } from "./bundled.qwik.mjs";
2
-
3
- //#region repl/bundler/index.ts
4
- var Bundler = class {
5
- worker = null;
6
- initP = null;
7
- ready = null;
8
- timer = null;
9
- buildPromises = /* @__PURE__ */ new Map();
10
- nextBuildId = 1;
11
- constructor() {
12
- this.initWorker();
13
- this.keepAlive();
14
- }
15
- initWorker() {
16
- this.initP = new Promise((res) => this.ready = res);
17
- this.worker = new Worker(new URL("./repl-bundler-worker.ts", import.meta.url), { type: "module" });
18
- this.worker.addEventListener("message", this.messageHandler);
19
- this.worker.addEventListener("error", (e) => {
20
- console.error(`Bundler worker failed`, e.message);
21
- this.terminateWorker();
22
- });
23
- }
24
- messageHandler = (e) => {
25
- const { type } = e.data;
26
- if (type === "ready") {
27
- const message = {
28
- type: "init",
29
- deps: getDeps()
30
- };
31
- this.worker.postMessage.bind(this.worker)(message);
32
- this.ready();
33
- } else if (type === "result" || type === "error") {
34
- const { buildId } = e.data;
35
- const promise = this.buildPromises.get(buildId);
36
- if (promise) {
37
- this.buildPromises.delete(buildId);
38
- if (type === "result") promise.resolve(e.data.result);
39
- else {
40
- const { error, stack } = e.data;
41
- const err = new Error(error);
42
- if (stack) err.stack = stack;
43
- promise.reject(err);
44
- }
45
- }
46
- }
47
- };
48
- keepAlive() {
49
- clearTimeout(this.timer);
50
- this.timer = setTimeout(() => this.terminateWorker(), 1e3 * 60 * 5);
51
- }
52
- bundle(options) {
53
- if (!this.worker) this.initWorker();
54
- this.keepAlive();
55
- return this.initP.then(() => {
56
- return new Promise((resolve, reject) => {
57
- const buildId = this.nextBuildId++;
58
- this.buildPromises.set(buildId, {
59
- resolve,
60
- reject
61
- });
62
- const message = {
63
- type: "bundle",
64
- buildId,
65
- data: options
66
- };
67
- const postMessage = this.worker?.postMessage.bind(this.worker);
68
- postMessage?.(message);
69
- });
70
- });
71
- }
72
- terminateWorker() {
73
- if (this.worker) {
74
- this.worker.removeEventListener("message", this.messageHandler);
75
- this.worker.terminate();
76
- this.worker = null;
77
- this.buildPromises.forEach((p) => p.reject(/* @__PURE__ */ new Error("Worker terminated")));
78
- this.buildPromises.clear();
79
- }
80
- }
81
- };
82
- let bundler;
83
- const getBundler = () => {
84
- if (!bundler) bundler = new Bundler();
85
- return bundler;
86
- };
87
-
88
- //#endregion
89
- export { getBundler };
@@ -1,21 +0,0 @@
1
- import { getBundler } from "./bundler/index.qwik.mjs";
2
-
3
- //#region repl/index.ts
4
- var ReplCompiler = class {
5
- options;
6
- bundler;
7
- constructor(options) {
8
- this.options = options;
9
- this.bundler = getBundler();
10
- }
11
- async compile(input) {
12
- const finalOptions = {
13
- ...this.options,
14
- ...input
15
- };
16
- return this.bundler.bundle(finalOptions);
17
- }
18
- };
19
-
20
- //#endregion
21
- export { ReplCompiler };
@@ -1,5 +0,0 @@
1
- //#region repl/repl-constants.ts
2
- const QWIK_PKG_NAME = "@qwik.dev/core";
3
-
4
- //#endregion
5
- export { QWIK_PKG_NAME };
@@ -1,67 +0,0 @@
1
- import { createRegExp, exactly } from "magic-regexp";
2
- import MagicString from "magic-string";
3
- import { walk } from "oxc-walker";
4
- import { existsSync, readdirSync, statSync } from "node:fs";
5
- import { basename, dirname, extname, join } from "node:path";
6
- import { remark } from "remark";
7
- import remarkMdx from "remark-mdx";
8
-
9
- //#region rolldown/playground.ts
10
- const playground = () => {
11
- const isMDX = createRegExp(exactly(".").and("mdx").at.lineEnd());
12
- return {
13
- name: "vite-plugin-qds-playground",
14
- enforce: "pre",
15
- async transform(code, id) {
16
- if (!isMDX.test(id)) return;
17
- try {
18
- const mdast = remark().use(remarkMdx).parse(code);
19
- const s = new MagicString(code);
20
- let hasPlayground = false;
21
- const scenariosDir = join(dirname(id), "scenarios");
22
- if (!existsSync(scenariosDir) || !statSync(scenariosDir).isDirectory()) return null;
23
- const scenarioFiles = readdirSync(scenariosDir).filter((file) => file.endsWith(".tsx") || file.endsWith(".ts")).map((file) => {
24
- const name = basename(file, extname(file));
25
- return {
26
- name,
27
- file,
28
- componentVar: `Scenario_${name.replace(/[^a-zA-Z0-9]/g, "_")}`,
29
- sourceVar: `Source_${name.replace(/[^a-zA-Z0-9]/g, "_")}`
30
- };
31
- });
32
- if (scenarioFiles.length === 0) return null;
33
- walk(mdast, { enter(node) {
34
- const mdxNode = node;
35
- if ((mdxNode.type === "mdxJsxFlowElement" || mdxNode.type === "mdxJsxTextElement") && mdxNode.name === "Playground") {
36
- if (mdxNode.position?.start?.offset !== void 0 && mdxNode.position?.end?.offset !== void 0) {
37
- if (!mdxNode.attributes.some((attr) => attr.name === "scenarios")) {
38
- const scenariosArrayString = `[${scenarioFiles.map((s$1) => `{name: "${s$1.name}", component: ${s$1.componentVar}, source: ${s$1.sourceVar}}`).join(", ")}]`;
39
- const insertPos$1 = mdxNode.position.start.offset + 11;
40
- s.appendLeft(insertPos$1, ` scenarios={${scenariosArrayString}}`);
41
- hasPlayground = true;
42
- }
43
- }
44
- }
45
- } });
46
- if (!hasPlayground) return null;
47
- const imports = scenarioFiles.map((file) => `import ${file.componentVar} from "./scenarios/${file.file}";\nimport ${file.sourceVar} from "./scenarios/${file.file}?raw";`).join("\n");
48
- let insertPos = 0;
49
- if (code.startsWith("---")) {
50
- const secondDelimiter = code.indexOf("---", 3);
51
- if (secondDelimiter !== -1) insertPos = secondDelimiter + 3;
52
- }
53
- s.appendLeft(insertPos, `\n${imports}\n`);
54
- return {
55
- code: s.toString(),
56
- map: s.generateMap({ hires: true })
57
- };
58
- } catch (error) {
59
- console.error(`Error transforming Playground in ${id}:`, error);
60
- return null;
61
- }
62
- }
63
- };
64
- };
65
-
66
- //#endregion
67
- export { playground };
@@ -1,32 +0,0 @@
1
- import type { Node } from "@oxc-project/types";
2
- import type { Plugin as VitePlugin } from "vite";
3
- export type PropType = {
4
- name: string;
5
- type: "boolean" | "string" | "number" | "union" | "function" | "unknown";
6
- unionValues?: string[];
7
- isBindable: boolean;
8
- isFunction?: boolean;
9
- initialValue?: unknown;
10
- comment?: string;
11
- scenario?: string;
12
- };
13
- export type ComponentPiece = {
14
- name: string;
15
- props: PropType[];
16
- };
17
- export type ComponentMetadata = {
18
- componentName: string;
19
- pieces: ComponentPiece[];
20
- };
21
- export type ComponentPropsPluginOptions = {
22
- componentsDir: string;
23
- outputDir: string;
24
- debug?: boolean;
25
- };
26
- export declare const componentProps: (options: ComponentPropsPluginOptions) => VitePlugin;
27
- export declare function generateAllComponentMetadata(componentsDir: string, outputDir: string, debug: (message: string, ...data: unknown[]) => void): Promise<void>;
28
- export declare function generateComponentMetadata(componentName: string, componentsDir: string, outputDir: string, debug: (message: string, ...data: unknown[]) => void): Promise<void>;
29
- export declare function extractJSDoc(node: Node, source: string, propName?: string): {
30
- comment?: string;
31
- scenario?: string;
32
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export * from "./component-props";
2
- export type { ComponentMetadata, ComponentPiece, PropType } from "./component-props";
@@ -1,9 +0,0 @@
1
- import type { ComponentMetadata } from "./prop-extraction";
2
- export type GenerateJsxOptions = {
3
- metadata: ComponentMetadata;
4
- selectedPieceName: string;
5
- propValues: Record<string, Record<string, unknown>>;
6
- isBindProps: boolean;
7
- baseSource?: string;
8
- };
9
- export declare function generateJsx({ metadata, selectedPieceName, propValues, isBindProps, baseSource }: GenerateJsxOptions): string;
@@ -1,8 +0,0 @@
1
- export declare const playground: () => {
2
- name: string;
3
- enforce: "pre";
4
- transform(code: string, id: string): Promise<{
5
- code: string;
6
- map: import("magic-string").SourceMap;
7
- } | null | undefined>;
8
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};