Skip to content

Commit ee440e9

Browse files
committed
Fix #104
1 parent ab52e5d commit ee440e9

File tree

8 files changed

+1736
-2256
lines changed

8 files changed

+1736
-2256
lines changed

package-lock.json

+1,488-1,080
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424
"qwik": "qwik"
2525
},
2626
"devDependencies": {
27-
"@builder.io/qwik": "1.2.18",
28-
"@builder.io/qwik-city": "1.2.18",
29-
"@playwright/test": "1.38.0",
30-
"@types/eslint": "8.44.6",
31-
"@types/node": "^20.8.9",
32-
"@typescript-eslint/eslint-plugin": "6.9.0",
33-
"@typescript-eslint/parser": "6.9.0",
34-
"eslint": "8.52.0",
35-
"eslint-plugin-qwik": "1.2.18",
27+
"@builder.io/qwik": "1.3.1",
28+
"@builder.io/qwik-city": "1.3.1",
29+
"@playwright/test": "1.40.1",
30+
"@types/eslint": "8.44.8",
31+
"@types/node": "^20.10.3",
32+
"@typescript-eslint/eslint-plugin": "6.13.2",
33+
"@typescript-eslint/parser": "6.13.2",
34+
"eslint": "8.55.0",
35+
"eslint-plugin-qwik": "1.3.1",
3636
"gpt-translate-json": "^0.1.0",
37-
"typescript": "5.2.2",
37+
"typescript": "5.3.2",
3838
"undici": "5.27.0",
39-
"vite": "4.5.0",
39+
"vite": "5.0.10",
4040
"vite-tsconfig-paths": "4.2.1",
41-
"vitest": "^0.34.6"
41+
"vitest": "^1.0.4"
4242
},
4343
"type": "module"
4444
}

packages/qwik-speak/package-lock.json

+222-1,156
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/qwik-speak/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@
1717
"qwik-speak-extract": "./extract/cli.js"
1818
},
1919
"peerDependencies": {
20-
"@builder.io/qwik": ">=1.2.18"
20+
"@builder.io/qwik": ">=1.3.1"
2121
},
2222
"devDependencies": {
23-
"@builder.io/qwik": "1.2.18",
23+
"@builder.io/qwik": "1.3.1",
2424
"@microsoft/api-documenter": "^7.23.12",
2525
"@microsoft/api-extractor": "^7.38.3",
2626
"@types/eslint": "8.44.4",
2727
"@types/node": "^20.8.4",
2828
"@typescript-eslint/eslint-plugin": "6.7.5",
2929
"@typescript-eslint/parser": "6.7.5",
3030
"eslint": "8.51.0",
31-
"eslint-plugin-qwik": "1.2.18",
31+
"eslint-plugin-qwik": "1.3.1",
3232
"np": "^8.0.4",
3333
"rollup-plugin-add-shebang": "^0.3.1",
3434
"typescript": "5.2.2",
3535
"undici": "5.26.0",
36-
"vite": "4.4.11",
36+
"vite": "5.0.10",
3737
"vitest": "^1.0.4"
3838
},
3939
"main": "./lib/index.qwik.cjs",

packages/qwik-speak/src/core.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import type { ValueOrPromise } from '@builder.io/qwik';
12
import { isDev, isServer } from '@builder.io/qwik/build';
23

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

7-
const cache: Record<string, Promise<any>> = {};
8+
const cache: Record<string, ValueOrPromise<Translation | null>> = {};
89

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

6061
for (const lang of resolvedLangs) {
61-
let tasks: Promise<any>[];
62+
let tasks: ValueOrPromise<Translation | null>[];
6263
// Cache requests in prod mode
6364
if (!isDev) {
6465
const memoized = memoize(translationFn.loadTranslation$);

packages/qwik-speak/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type {
66
SpeakConfig,
77
SpeakState,
88
LoadTranslationFn,
9+
ServerQRL,
910
RewriteRouteOption,
1011
DomainBasedRoutingOption
1112
} from './types';

packages/qwik-speak/src/types.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ export type Translation = { [key: string]: any };
4848
/**
4949
* Must contain the logic to load translation data
5050
*/
51-
export type LoadTranslationFn = QRL<(lang: string, asset: string) => ValueOrPromise<Translation | null>>;
51+
export type LoadTranslationFn = QRL<(lang: string, asset: string) => ValueOrPromise<Translation | null>> |
52+
ServerQRL<(lang: string, asset: string) => ValueOrPromise<Translation | null>>;
53+
54+
export type ServerQRL<T extends { (this: any, ...args: any[]): any; }> =
55+
QRL<((abort: AbortSignal, ...args: Parameters<T>) => ReturnType<T>) | ((...args: Parameters<T>) => ReturnType<T>)>;
5256

5357
export interface TranslationFn {
5458
/**

src/routes/plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { RequestHandler } from "@builder.io/qwik-city";
1+
import type { RequestHandler } from '@builder.io/qwik-city';
22
import { validateLocale } from 'qwik-speak';
33

44
import { config } from '../speak-config';

0 commit comments

Comments
 (0)