Skip to content

Commit

Permalink
Fix #104
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed Dec 21, 2023
1 parent ab52e5d commit ee440e9
Show file tree
Hide file tree
Showing 8 changed files with 1,736 additions and 2,256 deletions.
2,568 changes: 1,488 additions & 1,080 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
"qwik": "qwik"
},
"devDependencies": {
"@builder.io/qwik": "1.2.18",
"@builder.io/qwik-city": "1.2.18",
"@playwright/test": "1.38.0",
"@types/eslint": "8.44.6",
"@types/node": "^20.8.9",
"@typescript-eslint/eslint-plugin": "6.9.0",
"@typescript-eslint/parser": "6.9.0",
"eslint": "8.52.0",
"eslint-plugin-qwik": "1.2.18",
"@builder.io/qwik": "1.3.1",
"@builder.io/qwik-city": "1.3.1",
"@playwright/test": "1.40.1",
"@types/eslint": "8.44.8",
"@types/node": "^20.10.3",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"eslint": "8.55.0",
"eslint-plugin-qwik": "1.3.1",
"gpt-translate-json": "^0.1.0",
"typescript": "5.2.2",
"typescript": "5.3.2",
"undici": "5.27.0",
"vite": "4.5.0",
"vite": "5.0.10",
"vite-tsconfig-paths": "4.2.1",
"vitest": "^0.34.6"
"vitest": "^1.0.4"
},
"type": "module"
}
1,378 changes: 222 additions & 1,156 deletions packages/qwik-speak/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/qwik-speak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
"qwik-speak-extract": "./extract/cli.js"
},
"peerDependencies": {
"@builder.io/qwik": ">=1.2.18"
"@builder.io/qwik": ">=1.3.1"
},
"devDependencies": {
"@builder.io/qwik": "1.2.18",
"@builder.io/qwik": "1.3.1",
"@microsoft/api-documenter": "^7.23.12",
"@microsoft/api-extractor": "^7.38.3",
"@types/eslint": "8.44.4",
"@types/node": "^20.8.4",
"@typescript-eslint/eslint-plugin": "6.7.5",
"@typescript-eslint/parser": "6.7.5",
"eslint": "8.51.0",
"eslint-plugin-qwik": "1.2.18",
"eslint-plugin-qwik": "1.3.1",
"np": "^8.0.4",
"rollup-plugin-add-shebang": "^0.3.1",
"typescript": "5.2.2",
"undici": "5.26.0",
"vite": "4.4.11",
"vite": "5.0.10",
"vitest": "^1.0.4"
},
"main": "./lib/index.qwik.cjs",
Expand Down
5 changes: 3 additions & 2 deletions packages/qwik-speak/src/core.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { ValueOrPromise } from '@builder.io/qwik';
import { isDev, isServer } from '@builder.io/qwik/build';

import type { Translation, SpeakState, LoadTranslationFn } from './types';
import { getSpeakContext } from './context';
import { logWarn } from './log';

const cache: Record<string, Promise<any>> = {};
const cache: Record<string, ValueOrPromise<Translation | null>> = {};

/**
* Cache the requests on server and on client in SPA mode
Expand Down Expand Up @@ -58,7 +59,7 @@ export const loadTranslations = async (
resolvedLangs.add(locale.lang);

for (const lang of resolvedLangs) {
let tasks: Promise<any>[];
let tasks: ValueOrPromise<Translation | null>[];
// Cache requests in prod mode
if (!isDev) {
const memoized = memoize(translationFn.loadTranslation$);
Expand Down
1 change: 1 addition & 0 deletions packages/qwik-speak/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type {
SpeakConfig,
SpeakState,
LoadTranslationFn,
ServerQRL,
RewriteRouteOption,
DomainBasedRoutingOption
} from './types';
Expand Down
6 changes: 5 additions & 1 deletion packages/qwik-speak/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export type Translation = { [key: string]: any };
/**
* Must contain the logic to load translation data
*/
export type LoadTranslationFn = QRL<(lang: string, asset: string) => ValueOrPromise<Translation | null>>;
export type LoadTranslationFn = QRL<(lang: string, asset: string) => ValueOrPromise<Translation | null>> |
ServerQRL<(lang: string, asset: string) => ValueOrPromise<Translation | null>>;

export type ServerQRL<T extends { (this: any, ...args: any[]): any; }> =
QRL<((abort: AbortSignal, ...args: Parameters<T>) => ReturnType<T>) | ((...args: Parameters<T>) => ReturnType<T>)>;

export interface TranslationFn {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/routes/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RequestHandler } from "@builder.io/qwik-city";
import type { RequestHandler } from '@builder.io/qwik-city';
import { validateLocale } from 'qwik-speak';

import { config } from '../speak-config';
Expand Down

0 comments on commit ee440e9

Please sign in to comment.