@qds.dev/code 0.9.1 → 0.10.0

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.
Files changed (47) hide show
  1. package/README.md +7 -5
  2. package/lib/preview/bundler/repl-bundler-worker.qwik.mjs +6307 -5686
  3. package/lib/preview/bundler/rolldown-binding.wasm32-wasi.wasm +0 -0
  4. package/lib/preview/bundler/wasi-worker-browser.mjs +3051 -3051
  5. package/lib-types/src/debug.d.ts +1 -0
  6. package/lib-types/src/index.d.ts +2 -0
  7. package/lib-types/src/preview/bundler/bundled-config.d.ts +33 -0
  8. package/lib-types/src/preview/bundler/bundled.d.ts +3 -0
  9. package/lib-types/src/preview/bundler/bundled.unit.d.ts +1 -0
  10. package/lib-types/src/preview/bundler/client-events-listener.d.ts +1 -0
  11. package/lib-types/src/preview/bundler/index.d.ts +34 -0
  12. package/lib-types/src/preview/bundler/repl-bundler-worker.d.ts +30 -0
  13. package/lib-types/src/preview/bundler/repl-ssr-worker.d.ts +27 -0
  14. package/lib-types/src/preview/bundler/rollup-plugins.d.ts +5 -0
  15. package/lib-types/src/preview/bundler/rollup-plugins.unit.d.ts +1 -0
  16. package/lib-types/src/preview/constants.d.ts +5 -0
  17. package/lib-types/src/preview/index.d.ts +19 -0
  18. package/lib-types/src/preview/mocks/browser.d.ts +2 -0
  19. package/lib-types/src/preview/preview-sw.d.ts +20 -0
  20. package/lib-types/src/preview/preview-sw.unit.d.ts +1 -0
  21. package/lib-types/src/preview/register-preview-sw.d.ts +2 -0
  22. package/lib-types/src/preview/register-preview-sw.unit.d.ts +1 -0
  23. package/lib-types/src/preview/repl-editor.d.ts +1 -0
  24. package/lib-types/src/preview/repl-helpers-node.d.ts +4 -0
  25. package/lib-types/src/preview/repl-helpers.unit.d.ts +1 -0
  26. package/lib-types/src/preview/test-extend.d.ts +9 -0
  27. package/lib-types/src/preview/types.d.ts +70 -0
  28. package/lib-types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +29 -25
  30. package/LICENSE +0 -21
  31. package/lib/node_modules/.pnpm/@emnapi_core@1.7.1/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.qwik.mjs +0 -5533
  32. package/lib/node_modules/.pnpm/@emnapi_runtime@1.8.1/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.qwik.mjs +0 -1225
  33. package/lib/node_modules/.pnpm/@emnapi_wasi-threads@1.1.0/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.qwik.mjs +0 -619
  34. package/lib/node_modules/.pnpm/@napi-rs_wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/dist/fs.qwik.mjs +0 -14854
  35. package/lib/node_modules/.pnpm/@napi-rs_wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/fs-proxy.qwik.mjs +0 -109
  36. package/lib/node_modules/.pnpm/@napi-rs_wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/runtime.qwik.mjs +0 -4
  37. package/lib/node_modules/.pnpm/@qwik.dev_core@2.0.0-beta.15_vite@7.1.5_@types_node@24.9.0_jiti@2.6.1_lightningcss@1.30.1_ter_sl453hnfnrysgqsj6ikt4cdmnq/node_modules/@qwik.dev/core/dist/qwikloader.qwik.mjs +0 -152
  38. package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/index.browser.qwik.mjs +0 -13
  39. package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/normalize-string-or-regex-BB1FWNyl.qwik.mjs +0 -789
  40. package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/rolldown-binding.wasi-browser.qwik.mjs +0 -107
  41. package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/rolldown-build-Bfw5c2c3.qwik.mjs +0 -4157
  42. package/lib/node_modules/.pnpm/@tybys_wasm-util@0.10.1/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.qwik.mjs +0 -1968
  43. package/lib/node_modules/.pnpm/magic-regexp@0.10.0/node_modules/magic-regexp/dist/index.qwik.mjs +0 -10
  44. package/lib/node_modules/.pnpm/magic-regexp@0.10.0/node_modules/magic-regexp/dist/shared/magic-regexp.DKp_q_HX.qwik.mjs +0 -95
  45. package/lib/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.qwik.mjs +0 -34
  46. package/lib/vite/repl-plugin.qwik.mjs +0 -31
  47. package/lib-types/src/vite/repl-plugin.d.ts +0 -7
@@ -0,0 +1 @@
1
+ export declare function debug(...args: unknown[]): void;
@@ -0,0 +1,2 @@
1
+ export * from "./debug";
2
+ export * from "./preview";
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Shared configuration for bundled Qwik dependencies.
3
+ * This defines which files from @qwik.dev/core should be bundled.
4
+ *
5
+ * Both the library (using ?inline-asset) and docs (using ?no-transform)
6
+ * use this same configuration to ensure consistency.
7
+ */
8
+ import type { PkgUrls } from "../types";
9
+ export declare const QWIK_PKG_NAME = "@qwik.dev/core";
10
+ /**
11
+ * List of file paths within @qwik.dev/core that need to be bundled
12
+ */
13
+ export declare const BUNDLED_FILE_PATHS: readonly ["/dist/build/index.d.ts", "/dist/core.d.ts", "/dist/core.min.mjs", "/dist/core.mjs", "/dist/optimizer.mjs", "/dist/server.mjs", "/dist/server.d.ts", "/dist/preloader.mjs", "/dist/qwikloader.js", "/bindings/qwik.wasm.mjs", "/bindings/qwik_wasm_bg.wasm", "/handlers.mjs"];
14
+ /**
15
+ * Map of internal path aliases to actual file paths
16
+ * Some internal references use core.d.ts but the actual file is core-internal.d.ts
17
+ */
18
+ export declare const FILE_PATH_ALIASES: Record<string, string>;
19
+ /**
20
+ * Get the actual file path to import, considering aliases
21
+ */
22
+ export declare function getImportPath(path: string): string;
23
+ /**
24
+ * Helper to create a bundled object from imported assets.
25
+ * This ensures both files use the same structure without duplication.
26
+ *
27
+ * The imports array must be in the same order as BUNDLED_FILE_PATHS.
28
+ *
29
+ * @param imports - Array of imported content (string URLs or inline content) in BUNDLED_FILE_PATHS order
30
+ * @param version - The Qwik version
31
+ * @returns A properly structured PkgUrls object
32
+ */
33
+ export declare function createBundledConfig(imports: readonly string[], version: string): PkgUrls;
@@ -0,0 +1,3 @@
1
+ import type { PkgUrls } from "../types";
2
+ export declare const bundled: PkgUrls;
3
+ export declare const getDeps: () => PkgUrls;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ /** Bundler that manages WebWorkers */
2
+ import type { PkgUrls, PreviewInputOptions, PreviewResult } from "../types";
3
+ import type { OutgoingMessage } from "./repl-bundler-worker";
4
+ declare class Bundler {
5
+ worker: Worker | null;
6
+ private initP;
7
+ private ready;
8
+ private deps;
9
+ private qwikWasm?;
10
+ private timer;
11
+ buildPromises: Map<number, {
12
+ resolve: (value: PreviewResult) => void;
13
+ reject: (reason?: any) => void;
14
+ }>;
15
+ nextBuildId: number;
16
+ constructor(deps: PkgUrls, qwikWasm?: WebAssembly.Module);
17
+ initWorker(): void;
18
+ messageHandler: (e: MessageEvent<OutgoingMessage>) => void;
19
+ keepAlive(): void;
20
+ bundle(options: Omit<PreviewInputOptions, "version" | "serverUrl">): Promise<PreviewResult>;
21
+ terminateWorker(): void;
22
+ private _ssrWorker;
23
+ private _ssrWorkerP;
24
+ private _ssrKey;
25
+ private _resultResolver;
26
+ private getSsrWorker;
27
+ executeSSR(result: PreviewResult): Promise<{
28
+ html: string;
29
+ events?: any[];
30
+ }>;
31
+ hasQwikWasm(): boolean;
32
+ }
33
+ export declare const getBundler: (deps?: PkgUrls, qwikWasm?: WebAssembly.Module) => Bundler;
34
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { PkgUrls, ReplInputOptions, ReplResult } from "../types";
2
+ interface MessageBase {
3
+ type: string;
4
+ }
5
+ export interface InitMessage extends MessageBase {
6
+ type: "init";
7
+ deps: PkgUrls;
8
+ qwikWasm?: WebAssembly.Module;
9
+ }
10
+ export interface BundleMessage extends MessageBase {
11
+ type: "bundle";
12
+ buildId: number;
13
+ data: Omit<ReplInputOptions, "version" | "serverUrl">;
14
+ }
15
+ export interface ReadyMessage extends MessageBase {
16
+ type: "ready";
17
+ }
18
+ export interface ResultMessage extends MessageBase {
19
+ type: "result";
20
+ buildId: number;
21
+ result: ReplResult;
22
+ }
23
+ export interface ErrorMessage extends MessageBase {
24
+ type: "error";
25
+ buildId: number;
26
+ error: string;
27
+ stack?: string;
28
+ }
29
+ export type OutgoingMessage = ReadyMessage | ResultMessage | ErrorMessage;
30
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { QwikManifest } from "@qwik.dev/core/optimizer";
2
+ import type { PreviewEvent } from "../types";
3
+ interface MessageBase {
4
+ type: string;
5
+ }
6
+ export interface InitSSRMessage extends MessageBase {
7
+ type: "run-ssr";
8
+ replId: string;
9
+ entry: string;
10
+ baseUrl: string;
11
+ manifest: QwikManifest | undefined;
12
+ }
13
+ export interface SSRReadyMessage extends MessageBase {
14
+ type: "ready";
15
+ }
16
+ export interface SSRResultMessage extends MessageBase {
17
+ type: "ssr-result";
18
+ html: string;
19
+ events: PreviewEvent[];
20
+ }
21
+ export interface SSRErrorMessage extends MessageBase {
22
+ type: "ssr-error";
23
+ error: string;
24
+ stack?: string;
25
+ }
26
+ export type OutgoingMessage = SSRReadyMessage | SSRResultMessage | SSRErrorMessage;
27
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Plugin } from "@rolldown/browser";
2
+ import type { PkgUrls, PreviewInputOptions } from "../types";
3
+ export declare const definesPlugin: (defines: Record<string, string>) => Plugin;
4
+ export declare const replResolver: (deps: PkgUrls, options: Pick<PreviewInputOptions, "srcInputs" | "buildMode">, target: "client" | "ssr") => Plugin;
5
+ export declare const replCss: (options: Pick<PreviewInputOptions, "srcInputs">) => Plugin;
@@ -0,0 +1,5 @@
1
+ export declare const QWIK_PKG_NAME = "@qwik.dev/core";
2
+ export declare const PREVIEW_CONFIG: {
3
+ serviceWorkerPath: string;
4
+ scope: string;
5
+ };
@@ -0,0 +1,19 @@
1
+ import type { PkgUrls, PreviewInputOptions, PreviewResult } from "./types";
2
+ export * from "./bundler";
3
+ export { BUNDLED_FILE_PATHS, createBundledConfig, FILE_PATH_ALIASES, getImportPath, QWIK_PKG_NAME } from "./bundler/bundled-config";
4
+ export * from "./constants";
5
+ export * from "./repl-helpers";
6
+ export * from "./register-preview-sw";
7
+ export type { PkgUrls, PreviewInputOptions, PreviewInputOptions as ReplInputOptions, PreviewModuleInput, PreviewModuleInput as ReplModuleInput, PreviewModuleOutput, PreviewModuleOutput as ReplModuleOutput, PreviewResult, PreviewResult as ReplResult } from "./types";
8
+ export * from "./types";
9
+ export interface PreviewCompilerOptions extends Partial<PreviewInputOptions> {
10
+ /** Qwik dependency URLs - must be provided by consuming app */
11
+ deps: PkgUrls;
12
+ }
13
+ export declare class PreviewCompiler {
14
+ options: PreviewCompilerOptions;
15
+ private bundler;
16
+ constructor(options: PreviewCompilerOptions);
17
+ compile(input: Partial<PreviewInputOptions>): Promise<PreviewResult>;
18
+ }
19
+ export { PreviewCompiler as ReplCompiler };
@@ -0,0 +1,2 @@
1
+ export declare const handlers: import("msw").HttpHandler[];
2
+ export declare const worker: import("msw/browser").SetupWorker;
@@ -0,0 +1,20 @@
1
+ export type RequestMessage = {
2
+ type: "preview-request";
3
+ requestId: number;
4
+ previewId: string;
5
+ url: string;
6
+ };
7
+ export type ResponseMessage = {
8
+ type: "preview-response";
9
+ requestId: number;
10
+ response: {
11
+ status: number;
12
+ statusText: string;
13
+ headers: Record<string, string>;
14
+ body: string;
15
+ } | null;
16
+ };
17
+ type SendPreviewMessage = (msg: RequestMessage) => void;
18
+ /** Intercept requests for `/repl/[id]/*` and request them over the broadcast channel */
19
+ export declare const handleFetch: (ev: FetchEvent, selfOrigin: string, sendMessage: SendPreviewMessage) => void;
20
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const registerReplSW: () => Promise<ServiceWorkerRegistration | null>;
2
+ export declare const _resetPromise: () => void;
@@ -0,0 +1 @@
1
+ export declare const ReplEditor: import("@qwik.dev/core").Component<unknown>;
@@ -0,0 +1,4 @@
1
+ export interface CopyReplAssetsOptions {
2
+ publicDir: string;
3
+ }
4
+ export declare const copyReplAssets: ({ publicDir }: CopyReplAssetsOptions) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Extended test with MSW worker fixture.
3
+ * - Starts MSW before each test
4
+ * - Exposes `worker` in test context for adding handlers
5
+ * - Resets handlers after each test
6
+ */
7
+ export declare const test: import("vitest").TestAPI<{
8
+ worker: import("msw/browser").SetupWorker;
9
+ }>;
@@ -0,0 +1,70 @@
1
+ import type { Signal } from "@qwik.dev/core";
2
+ import type { Diagnostic, QwikManifest, QwikRollupPluginOptions, TransformModule } from "@qwik.dev/core/optimizer";
3
+ export interface PreviewAppInput {
4
+ files: PreviewModuleInput[];
5
+ version: string;
6
+ buildMode: "development" | "production";
7
+ entryStrategy: string;
8
+ debug?: boolean;
9
+ }
10
+ export type PkgUrls = {
11
+ [pkgName: string]: {
12
+ [path: string]: string;
13
+ version: string;
14
+ };
15
+ };
16
+ export interface PreviewInputOptions extends Omit<QwikRollupPluginOptions, "srcDir"> {
17
+ replId: string;
18
+ srcInputs: PreviewModuleInput[];
19
+ version: string;
20
+ buildMode: "development" | "production";
21
+ debug?: boolean;
22
+ qwikWasm?: WebAssembly.Module;
23
+ }
24
+ export interface PreviewModuleInput {
25
+ path: string;
26
+ code: string;
27
+ hidden?: boolean;
28
+ }
29
+ export interface PreviewModuleOutput {
30
+ path: string;
31
+ code: string;
32
+ size?: string;
33
+ shorten?: Signal<boolean>;
34
+ }
35
+ export interface PreviewEvent {
36
+ start: number;
37
+ end?: number;
38
+ kind: "console-log" | "console-debug" | "console-warn" | "console-error" | "symbol" | "pause" | "resume" | "client-module" | "prefetch";
39
+ scope: "ssr" | "client" | "build" | "network";
40
+ message: string[];
41
+ element?: Element;
42
+ }
43
+ export interface PreviewResult {
44
+ buildId: number;
45
+ replId: string;
46
+ html: string;
47
+ transformedModules: TransformModule[];
48
+ clientBundles: PreviewModuleOutput[];
49
+ ssrModules: PreviewModuleOutput[];
50
+ manifest: QwikManifest | undefined;
51
+ diagnostics: Diagnostic[];
52
+ events: PreviewEvent[];
53
+ }
54
+ export type SSROutgoingMessage = {
55
+ type: "ready";
56
+ } | {
57
+ type: "ssr-result";
58
+ html: string;
59
+ events: any[];
60
+ } | {
61
+ type: "ssr-error";
62
+ error: string;
63
+ stack?: string;
64
+ };
65
+ export type ReplAppInput = PreviewAppInput;
66
+ export type ReplInputOptions = PreviewInputOptions;
67
+ export type ReplModuleInput = PreviewModuleInput;
68
+ export type ReplModuleOutput = PreviewModuleOutput;
69
+ export type ReplEvent = PreviewEvent;
70
+ export type ReplResult = PreviewResult;