Skip to content

Commit

Permalink
9ecfa4c Merge pull request #6940 from QwikDev/changeset-release/main
Browse files Browse the repository at this point in the history
  • Loading branch information
shairez committed Nov 11, 2024
1 parent 4b5a6e0 commit 2ddd12f
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 8,556 deletions.
3,919 changes: 90 additions & 3,829 deletions lib/index.qwik.cjs

Large diffs are not rendered by default.

3,883 changes: 72 additions & 3,811 deletions lib/index.qwik.mjs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/insights/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface InsightsPayload {
* is useful for server clustering. Sending previous symbol name allows the server to stitch the
* symbol list together.
*/
previousSymbol: string | null;
previousSymbol?: string | null;
/** List of symbols which have been received since last update. */
symbols: InsightSymbol[];
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export declare const InsightsPayload: z.ZodObject<{
qVersion: z.ZodString;
manifestHash: z.ZodString;
publicApiKey: z.ZodString;
previousSymbol: z.ZodNullable<z.ZodString>;
previousSymbol: z.ZodNullable<z.ZodOptional<z.ZodString>>;
symbols: z.ZodArray<z.ZodObject<{
symbol: z.ZodString;
route: z.ZodString;
Expand All @@ -135,7 +135,6 @@ export declare const InsightsPayload: z.ZodObject<{
manifestHash: string;
qVersion: string;
publicApiKey: string;
previousSymbol: string | null;
symbols: {
symbol: string;
route: string;
Expand All @@ -144,11 +143,11 @@ export declare const InsightsPayload: z.ZodObject<{
timeline: number;
interaction: boolean;
}[];
previousSymbol?: string | null | undefined;
}, {
manifestHash: string;
qVersion: string;
publicApiKey: string;
previousSymbol: string | null;
symbols: {
symbol: string;
route: string;
Expand All @@ -157,6 +156,7 @@ export declare const InsightsPayload: z.ZodObject<{
timeline: number;
interaction: boolean;
}[];
previousSymbol?: string | null | undefined;
}>;
export declare const Insights: import('@builder.io/qwik').Component<{
publicApiKey: string;
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
"description": "Qwik Labs - Where you can try the latest Qwik ideas.",
"version": "0.0.1",
"devDependencies": {
"@builder.io/qwik": "1.9.1",
"@builder.io/qwik": "1.10.0",
"@types/eslint": "8.56.10",
"@types/node": "20.14.11",
"@typescript-eslint/eslint-plugin": "7.16.1",
"@typescript-eslint/parser": "7.16.1",
"eslint": "^8.57.0",
"eslint-plugin-qwik": "1.9.1",
"eslint": "8.57.0",
"eslint-plugin-qwik": "1.10.0",
"np": "10.0.1",
"prettier": "3.3.3",
"typescript": "5.4.5",
"undici": "*",
"vite": "5.3.5"
"vite": "5.3.5",
"zod": "3.22.4"
},
"engines": {
"node": ">=16.8.0 <18.0.0 || >=18.11"
Expand All @@ -36,6 +37,10 @@
"vite"
],
"main": "./lib/index.qwik.mjs",
"peerDependencies": {
"zod": "3.22.4",
"vite": "^5"
},
"private": true,
"qwik": "./lib/index.qwik.mjs",
"scripts": {
Expand Down
29 changes: 12 additions & 17 deletions src-vite/insights/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { type QwikVitePluginOptions } from '@builder.io/qwik/optimizer';
import { existsSync, mkdirSync } from 'fs';
import { readFile, writeFile } from 'fs/promises';
import { join } from 'node:path';
import { resolve } from 'path';
import { type PluginOption } from 'vite';

const logWarn = (message?: any) => {
const logWarn = (message?: any, ...rest) => {
// eslint-disable-next-line no-console
console.warn('\x1b[33m%s\x1b[0m', `qwikInsight()[WARN]: ${message}`);
console.warn('\x1b[33m%s\x1b[0m', `qwikInsight()[WARN]: ${message}`, ...rest);
};

const log = (message?: any) => {
Expand All @@ -19,11 +20,7 @@ export async function qwikInsights(qwikInsightsOpts: {
baseUrl?: string;
outDir?: string;
}): Promise<PluginOption> {
const {
publicApiKey,
baseUrl = 'https://qwik-insights.builder.io',
outDir = 'dist',
} = qwikInsightsOpts;
const { publicApiKey, baseUrl = 'https://insights.qwik.dev', outDir = '' } = qwikInsightsOpts;
let isProd = false;
const vitePlugin: PluginOption = {
name: 'vite-plugin-qwik-insights',
Expand All @@ -37,20 +34,18 @@ export async function qwikInsights(qwikInsightsOpts: {
const response = await fetch(`${baseUrl}/api/v1/${publicApiKey}/bundles/strategy/`);
const strategy = await response.json();
Object.assign(qManifest, strategy);
const path = resolve(viteConfig.root || '.', outDir);
const pathJson = join(path, 'q-insights.json');
mkdirSync(path, { recursive: true });
log('Fetched latest Qwik Insight data into: ' + pathJson);
await writeFile(pathJson, JSON.stringify(qManifest));
} catch (e) {
logWarn('fail to fetch manifest from Insights DB');
logWarn('Failed to fetch manifest from Insights DB', e);
}
const cwdRelativePath = join(viteConfig.root || '.', outDir);
const cwdRelativePathJson = join(cwdRelativePath, 'q-insights.json');
if (!existsSync(join(process.cwd(), cwdRelativePath))) {
mkdirSync(join(process.cwd(), cwdRelativePath), { recursive: true });
}
log('Fetched latest Qwik Insight data into: ' + cwdRelativePathJson);
await writeFile(join(process.cwd(), cwdRelativePathJson), JSON.stringify(qManifest));
}
},
closeBundle: async () => {
const path = join(process.cwd(), outDir, 'q-manifest.json');
const path = resolve(outDir, 'q-manifest.json');
if (isProd && existsSync(path)) {
const qManifest = await readFile(path, 'utf-8');

Expand All @@ -60,7 +55,7 @@ export async function qwikInsights(qwikInsightsOpts: {
body: qManifest,
});
} catch (e) {
logWarn('fail to post manifest to Insights DB');
logWarn('Failed to post manifest to Insights DB', e);
}
}
},
Expand Down
3 changes: 0 additions & 3 deletions src/devtools/index.ts

This file was deleted.

Loading

0 comments on commit 2ddd12f

Please sign in to comment.