@qwik.dev/core 2.0.0-beta.17 → 2.0.0-beta.19

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 (51) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.linux-x64-gnu.node +0 -0
  3. package/bindings/qwik.win32-x64-msvc.node +0 -0
  4. package/bindings/qwik_wasm_bg.wasm +0 -0
  5. package/dist/backpatch/package.json +1 -1
  6. package/dist/build/package.json +1 -1
  7. package/dist/cli.mjs +57 -57
  8. package/dist/core-internal.d.ts +32 -32
  9. package/dist/core.min.mjs +1 -1
  10. package/dist/core.mjs +1234 -788
  11. package/dist/core.mjs.map +1 -1
  12. package/dist/core.prod.mjs +815 -553
  13. package/dist/loader/index.mjs +2 -2
  14. package/dist/loader/package.json +1 -1
  15. package/dist/optimizer.mjs +1007 -1000
  16. package/dist/qwikloader.debug.js +1 -1
  17. package/dist/qwikloader.js +1 -1
  18. package/dist/server.mjs +65 -106
  19. package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
  20. package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
  21. package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
  22. package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
  23. package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
  24. package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
  25. package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
  26. package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
  27. package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
  28. package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
  29. package/dist/starters/adapters/express/package.json +1 -1
  30. package/dist/starters/features/compiled-i18n/package.json +37 -0
  31. package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
  32. package/dist/starters/features/{localize → compiled-i18n}/src/entry.ssr.tsx +7 -2
  33. package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
  34. package/dist/starters/features/csr/package.json +1 -1
  35. package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
  36. package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
  37. package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
  38. package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
  39. package/dist/starters/features/playwright/playwright-report/index.html +0 -19
  40. package/dist/testing/index.d.ts +11 -11
  41. package/dist/testing/index.mjs +2966 -2498
  42. package/dist/testing/package.json +1 -1
  43. package/package.json +14 -11
  44. package/bindings/qwik.darwin-x64.node +0 -0
  45. package/bindings/qwik.wasm.cjs +0 -471
  46. package/dist/starters/features/localize/package.json +0 -37
  47. package/dist/starters/features/localize/src/locales/message.en.json +0 -8
  48. package/dist/starters/features/localize/src/locales/message.it.json +0 -8
  49. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
  50. package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
  51. package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
@@ -0,0 +1,41 @@
1
+ /**
2
+ * For more details on how to configure Wrangler, refer to:
3
+ * https://developers.cloudflare.com/workers/wrangler/configuration/
4
+ */
5
+ {
6
+ "$schema": "node_modules/wrangler/config-schema.json",
7
+ "name": "my-qwik-app",
8
+ "main": "./dist/_worker.js",
9
+ "compatibility_date": "2025-12-28",
10
+ "compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
11
+ "assets": {
12
+ "binding": "ASSET",
13
+ "directory": "./dist",
14
+ },
15
+ "observability": {
16
+ "enabled": true,
17
+ },
18
+ /**
19
+ * Smart Placement
20
+ * https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
21
+ */
22
+ // "placement": { "mode": "smart" }
23
+ /**
24
+ * Bindings
25
+ * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
26
+ * databases, object storage, AI inference, real-time communication and more.
27
+ * https://developers.cloudflare.com/workers/runtime-apis/bindings/
28
+ */
29
+ /**
30
+ * Environment Variables
31
+ * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
32
+ * Note: Use secrets to store sensitive data.
33
+ * https://developers.cloudflare.com/workers/configuration/secrets/
34
+ */
35
+ // "vars": { "MY_VARIABLE": "production_value" }
36
+ /**
37
+ * Service Bindings (communicate between multiple Workers)
38
+ * https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
39
+ */
40
+ // "services": [ { "binding": "MY_SERVICE", "service": "my-service" } ]
41
+ }
@@ -5,7 +5,7 @@
5
5
  "serve": "node server/entry.express"
6
6
  },
7
7
  "dependencies": {
8
- "express": "4.20.0"
8
+ "express": "4.22.0"
9
9
  },
10
10
  "devDependencies": {
11
11
  "@types/compression": "^1.7.2",
@@ -0,0 +1,37 @@
1
+ {
2
+ "description": "Add compiled-i18n to your Qwik app",
3
+ "__qwik__": {
4
+ "displayName": "Integration: compiled-i18n (compile time translations)",
5
+ "priority": -10,
6
+ "viteConfig": {
7
+ "imports": [
8
+ {
9
+ "namedImports": [
10
+ "i18nPlugin"
11
+ ],
12
+ "importPath": "compiled-i18n/vite"
13
+ }
14
+ ],
15
+ "vitePlugins": [
16
+ "i18nPlugin({ locales: ['en'] })"
17
+ ]
18
+ },
19
+ "docs": [
20
+ "https://qwik.dev/docs/integrations/i18n/#localize",
21
+ "https://github.com/wmertens/compiled-i18n/blob/main/Readme.md"
22
+ ],
23
+ "nextSteps": {
24
+ "title": "Next Steps",
25
+ "lines": [
26
+ " - Change the `locales` array in the vite config to add more languages",
27
+ " - Use the `src/components/locale-selector/locale-selector.tsx` component to switch languages",
28
+ "",
29
+ " Check out the compiled-i18n docs:",
30
+ " - https://github.com/wmertens/compiled-i18n/blob/main/Readme.md"
31
+ ]
32
+ }
33
+ },
34
+ "devDependencies": {
35
+ "compiled-i18n": "latest"
36
+ }
37
+ }
@@ -0,0 +1,30 @@
1
+ import { component$, getLocale } from "@builder.io/qwik";
2
+ import { _, locales } from "compiled-i18n";
3
+
4
+ export const LocaleSelector = component$(() => {
5
+ const currentLocale = getLocale();
6
+ return (
7
+ <>
8
+ {locales.map((locale) => {
9
+ const isCurrent = locale === currentLocale;
10
+ return (
11
+ // Note, you must use `<a>` and not `<Link>` so the page reloads
12
+ <a
13
+ key={locale}
14
+ // When using route-based locale selection, build the URL here
15
+ href={`?locale=${locale}`}
16
+ aria-disabled={isCurrent}
17
+ class={
18
+ "btn btn-ghost btn-sm" +
19
+ (isCurrent
20
+ ? " bg-neutralContent text-neutral pointer-events-none"
21
+ : " bg-base-100 text-base-content")
22
+ }
23
+ >
24
+ {locale}
25
+ </a>
26
+ );
27
+ })}
28
+ </>
29
+ );
30
+ });
@@ -7,15 +7,20 @@
7
7
  * On the client, containers resume and do not call render.
8
8
  */
9
9
  import { createRenderer } from "@qwik.dev/router";
10
+ import { extractBase, setSsrLocaleGetter } from "compiled-i18n/qwik";
10
11
  import Root from "./root";
11
- import { extractBase } from "./routes/[locale]/i18n-utils";
12
+
13
+ setSsrLocaleGetter();
12
14
 
13
15
  export default createRenderer((opts) => {
14
16
  return {
15
17
  jsx: <Root />,
16
18
  options: {
17
19
  ...opts,
18
- base: extractBase, // determine the base URL for the client code
20
+
21
+ // determine the base URL for the client code
22
+ base: extractBase,
23
+
19
24
  // Use container attributes to set attributes on the html tag.
20
25
  containerAttributes: {
21
26
  lang: opts.serverData?.locale ?? "en-us",
@@ -0,0 +1,28 @@
1
+ // ... other imports
2
+ import { guessLocale } from "compiled-i18n";
3
+ import type { RequestHandler } from "@builder.io/qwik-city";
4
+
5
+ /**
6
+ * Handle incoming requests to determine and set the appropriate locale.
7
+ * This function checks for a 'locale' query parameter, then a `locale` cookie,
8
+ * and finally falls back to the 'Accept-Language' header.
9
+ */
10
+ export const onRequest: RequestHandler = async ({
11
+ query,
12
+ cookie,
13
+ headers,
14
+ locale,
15
+ }) => {
16
+ // Allow overriding locale with query param `locale`
17
+ if (query.has("locale")) {
18
+ const newLocale = guessLocale(query.get("locale"));
19
+ cookie.delete("locale");
20
+ cookie.set("locale", newLocale, {});
21
+ locale(newLocale);
22
+ } else {
23
+ // Choose locale based on cookie or accept-language header
24
+ const maybeLocale =
25
+ cookie.get("locale")?.value || headers.get("accept-language");
26
+ locale(guessLocale(maybeLocale));
27
+ }
28
+ };
@@ -20,7 +20,7 @@
20
20
  "@qwik.dev/core": "workspace:*"
21
21
  },
22
22
  "devDependencies": {
23
- "vite": "7.2.2"
23
+ "vite": "7.3.1"
24
24
  },
25
25
  "scripts": {
26
26
  "dev": "vite",
@@ -0,0 +1,5 @@
1
+ import { routeAction$ } from "@builder.io/qwik-city";
2
+
3
+ export const useExampleAction = routeAction$(() => {
4
+ return "This is example action data.";
5
+ });
@@ -1,18 +1,60 @@
1
+ import { $, component$ } from "@builder.io/qwik";
2
+ import { QwikCityMockProvider } from "@builder.io/qwik-city";
3
+
1
4
  import { ExampleTest } from "./example";
5
+ import { useExampleLoader } from "../../loaders/example.loader";
6
+ import { useExampleAction } from "../../actions/example.action";
7
+
8
+ const Template = component$((props: { flag: boolean }) => {
9
+ const loadersMock = [
10
+ {
11
+ loader: useExampleLoader,
12
+ data: "Loader Data",
13
+ },
14
+ ];
15
+
16
+ const actionStub = $(() => cy.stub().as("actionStub"))();
17
+ const actionsMock = [
18
+ {
19
+ action: useExampleAction,
20
+ handler: $(async () => {
21
+ await actionStub.then((_) => _());
22
+ return { status: 200, result: "Action Data" };
23
+ }),
24
+ },
25
+ ];
26
+
27
+ return (
28
+ <QwikCityMockProvider loaders={loadersMock} actions={actionsMock}>
29
+ <ExampleTest flag={props.flag} />
30
+ </QwikCityMockProvider>
31
+ );
32
+ });
2
33
 
3
34
  it("should render ⭐", () => {
4
- cy.mount(<ExampleTest flag={true} />);
5
- cy.get("div.icon").should("contain.text", "⭐");
35
+ cy.mount(<Template flag={true} />);
36
+ cy.get("#icon").should("contain.text", "⭐");
6
37
  });
7
38
 
8
39
  it("should render 💣", () => {
9
- cy.mount(<ExampleTest flag={false} />);
10
- cy.get("div.icon").should("contain.text", "💣");
40
+ cy.mount(<Template flag={false} />);
41
+ cy.get("#icon").should("contain.text", "💣");
11
42
  });
12
43
 
13
44
  it("should count clicks", () => {
14
- cy.mount(<ExampleTest flag={true} />);
15
- cy.get("span").should("contain.text", "Count:0");
16
- cy.get("button").click();
17
- cy.get("span").should("contain.text", "Count:1");
45
+ cy.mount(<Template flag={true} />);
46
+ cy.get("#count").should("contain.text", "Count:0");
47
+ cy.get("#btn-counter").click();
48
+ cy.get("#count").should("contain.text", "Count:1");
49
+ });
50
+
51
+ it("should render loader data", () => {
52
+ cy.mount(<Template flag={true} />);
53
+ cy.get("#loader-data").should("contain.text", "Loader Data");
54
+ });
55
+
56
+ it("should call action on button click", () => {
57
+ cy.mount(<Template flag={true} />);
58
+ cy.get("#btn-action").click();
59
+ cy.get("@actionStub").should("have.been.called");
18
60
  });
@@ -1,17 +1,27 @@
1
1
  import { component$, useStore } from "@qwik.dev/core";
2
2
 
3
+ import { useExampleLoader } from "../../loaders/example.loader";
4
+ import { useExampleAction } from "../../actions/example.action";
5
+
3
6
  export const ExampleTest = component$((props: { flag: boolean }) => {
4
7
  const state = useStore({
5
8
  counter: 0,
6
9
  });
7
10
 
11
+ const loaderState = useExampleLoader();
12
+ const action = useExampleAction();
13
+
8
14
  return (
9
15
  <>
10
- <span>Count:{state.counter}</span>
11
- <div class="icon">Flag: {props.flag ? "⭐" : "💣"}</div>
12
- <button class="btn-counter" onClick$={() => state.counter++}>
16
+ <span id="count">Count:{state.counter}</span>
17
+ <div id="icon">Flag: {props.flag ? "⭐" : "💣"}</div>
18
+ <button id="btn-counter" onClick$={() => state.counter++}>
13
19
  Increment counter
14
20
  </button>
21
+ <span id="loader-data">{loaderState.value}</span>
22
+ <button id="btn-action" onClick$={() => action.submit()}>
23
+ Call action
24
+ </button>
15
25
  </>
16
26
  );
17
27
  });
@@ -0,0 +1,5 @@
1
+ import { routeLoader$ } from "@builder.io/qwik-city";
2
+
3
+ export const useExampleLoader = routeLoader$(() => {
4
+ return "This is example loader data.";
5
+ });
@@ -833,7 +833,6 @@
833
833
  for (
834
834
  T &= 15, N = R[G + 2] + (M & Pe[T]), M >>= T, O -= T;
835
835
  O < 15;
836
-
837
836
  )
838
837
  (U--, (M |= (S.read_byte(q++) & 255) << O), (O += 8));
839
838
  ((C = M & H), (R = y), (D = k), (G = (D + C) * 3), (T = R[G]));
@@ -991,7 +990,6 @@
991
990
  D = g.write,
992
991
  T = D < g.read ? g.read - D - 1 : g.end - D;
993
992
  ;
994
-
995
993
  )
996
994
  switch (t) {
997
995
  case so:
@@ -1346,7 +1344,6 @@
1346
1344
  w = n.write,
1347
1345
  S = w < n.read ? n.read - w - 1 : n.end - w;
1348
1346
  ;
1349
-
1350
1347
  ) {
1351
1348
  let R, D, T, M, O, q, U, B;
1352
1349
  switch (r) {
@@ -1579,7 +1576,6 @@
1579
1576
  for (
1580
1577
  C = I == 18 ? 7 : I - 14, Y = I == 18 ? 11 : 3;
1581
1578
  d < u + C;
1582
-
1583
1579
  ) {
1584
1580
  if (k !== 0) g = V;
1585
1581
  else
@@ -2327,7 +2323,6 @@
2327
2323
  for (
2328
2324
  t.push(Math.floor(e._length / 4294967296)), t.push(e._length | 0);
2329
2325
  t.length;
2330
-
2331
2326
  )
2332
2327
  e._block(t.splice(0, 16));
2333
2328
  return (e.reset(), n);
@@ -4526,7 +4521,6 @@
4526
4521
  for (
4527
4522
  d(H), m = n(c);
4528
4523
  m !== null && (!(m.expirationTime > H) || (I && !T()));
4529
-
4530
4524
  ) {
4531
4525
  var z = m.callback;
4532
4526
  if (typeof z == "function") {
@@ -5013,7 +5007,6 @@
5013
5007
  i = o.length - 1,
5014
5008
  l = s.length - 1;
5015
5009
  1 <= i && 0 <= l && o[i] !== s[l];
5016
-
5017
5010
  )
5018
5011
  l--;
5019
5012
  for (; 1 <= i && 0 <= l; i--, l--)
@@ -5418,7 +5411,6 @@
5418
5411
  po.innerHTML = "<svg>" + t.valueOf().toString() + "</svg>",
5419
5412
  t = po.firstChild;
5420
5413
  e.firstChild;
5421
-
5422
5414
  )
5423
5415
  e.removeChild(e.firstChild);
5424
5416
  for (; t.firstChild; ) e.appendChild(t.firstChild);
@@ -5932,7 +5924,6 @@
5932
5924
  o = e.expirationTimes,
5933
5925
  s = e.pendingLanes;
5934
5926
  0 < s;
5935
-
5936
5927
  ) {
5937
5928
  var i = 31 - rt(s),
5938
5929
  l = 1 << i,
@@ -8166,7 +8157,6 @@
8166
8157
  for (
8167
8158
  e = e.return;
8168
8159
  e !== null && e.tag !== 5 && e.tag !== 3 && e.tag !== 13;
8169
-
8170
8160
  )
8171
8161
  e = e.return;
8172
8162
  Be = e;
@@ -9853,7 +9843,6 @@ Error generating stack: ` +
9853
9843
  r = n,
9854
9844
  n = t.child;
9855
9845
  n !== null;
9856
-
9857
9846
  )
9858
9847
  ((s = n),
9859
9848
  (e = r),
@@ -10539,7 +10528,6 @@ Error generating stack: ` +
10539
10528
  for (
10540
10529
  e = t.child, n = Jt(e, e.pendingProps), t.child = n, n.return = t;
10541
10530
  e.sibling !== null;
10542
-
10543
10531
  )
10544
10532
  ((e = e.sibling),
10545
10533
  (n = n.sibling = Jt(e, e.pendingProps)),
@@ -10703,7 +10691,6 @@ Error generating stack: ` +
10703
10691
  m !== s || (r !== 0 && m.nodeType !== 3) || (c = i + r),
10704
10692
  m.nodeType === 3 && (i += m.nodeValue.length),
10705
10693
  (x = m.firstChild) !== null;
10706
-
10707
10694
  )
10708
10695
  ((h = m), (m = x));
10709
10696
  for (;;) {
@@ -10726,7 +10713,6 @@ Error generating stack: ` +
10726
10713
  for (
10727
10714
  ol = { focusedElem: e, selectionRange: n }, ts = !1, P = t;
10728
10715
  P !== null;
10729
-
10730
10716
  )
10731
10717
  if (
10732
10718
  ((t = P),
@@ -10862,7 +10848,6 @@ Error generating stack: ` +
10862
10848
  for (
10863
10849
  e.sibling.return = e.return, e = e.sibling;
10864
10850
  e.tag !== 5 && e.tag !== 6 && e.tag !== 18;
10865
-
10866
10851
  ) {
10867
10852
  if (e.flags & 2 || e.child === null || e.tag === 4) continue e;
10868
10853
  ((e.child.return = e), (e = e.child));
@@ -11782,7 +11767,6 @@ Error generating stack: ` +
11782
11767
  e.pingedLanes &= ~t,
11783
11768
  e = e.expirationTimes;
11784
11769
  0 < t;
11785
-
11786
11770
  ) {
11787
11771
  var n = 31 - rt(t),
11788
11772
  r = 1 << n;
@@ -12466,7 +12450,6 @@ Error generating stack: ` +
12466
12450
  n = Ep(t, null, r, n),
12467
12451
  t.child = n;
12468
12452
  n;
12469
-
12470
12453
  )
12471
12454
  ((n.flags = (n.flags & -3) | 4096), (n = n.sibling));
12472
12455
  else {
@@ -12536,7 +12519,6 @@ Error generating stack: ` +
12536
12519
  for (
12537
12520
  s = t.child, s !== null && (s.return = t);
12538
12521
  s !== null;
12539
-
12540
12522
  ) {
12541
12523
  var l = s.dependencies;
12542
12524
  if (l !== null) {
@@ -18985,7 +18967,6 @@ Error generating stack: ` +
18985
18967
  var l = i;
18986
18968
  l < t.length - 1 &&
18987
18969
  t[l].charCodeAt(1) + 1 === t[l + 1].charCodeAt(1);
18988
-
18989
18970
  )
18990
18971
  l += 1;
18991
18972
  var c = 1 + l - i;
@@ -67,6 +67,7 @@ declare interface Container {
67
67
  $renderPromise$: Promise<void> | null;
68
68
  $resolveRenderPromise$: (() => void) | null;
69
69
  $cursorCount$: number;
70
+ $pausedCursorCount$: number;
70
71
  handleError(err: any, $host$: HostElement | null): void;
71
72
  getParentHost(host: HostElement): HostElement | null;
72
73
  setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
@@ -238,15 +239,13 @@ declare const enum EffectProperty {
238
239
  * - `EffectProperty.COMPONENT` if component
239
240
  * - `EffectProperty.VNODE` if VNode
240
241
  */
241
- declare type EffectSubscription = [
242
- Consumer,
243
- // EffectSubscriptionProp.CONSUMER
244
- EffectProperty | string,
245
- // EffectSubscriptionProp.PROPERTY or string for attributes
246
- Set<SignalImpl | StoreTarget> | null,
247
- // EffectSubscriptionProp.BACK_REF
248
- SubscriptionData | null
249
- ];
242
+ declare class EffectSubscription {
243
+ consumer: Consumer;
244
+ property: EffectProperty | string;
245
+ backRef: Set<SignalImpl | StoreTarget> | null;
246
+ data: SubscriptionData | null;
247
+ constructor(consumer: Consumer, property: EffectProperty | string, backRef?: Set<SignalImpl | StoreTarget> | null, data?: SubscriptionData | null);
248
+ }
250
249
 
251
250
  /**
252
251
  * Creates a simple DOM structure for testing components.
@@ -754,12 +753,13 @@ export declare function trigger(root: Element, queryOrElement: string | Element
754
753
  declare type ValueOrPromise<T> = T | Promise<T>;
755
754
 
756
755
  /** @internal */
757
- declare abstract class VNode extends BackRef {
756
+ declare abstract class VNode implements BackRef {
758
757
  flags: VNodeFlags;
759
758
  parent: VNode | null;
760
759
  previousSibling: VNode | null | undefined;
761
760
  nextSibling: VNode | null | undefined;
762
761
  props: Props | null;
762
+ [_EFFECT_BACK_REF]: Map<any, any> | undefined;
763
763
  slotParent: VNode | null;
764
764
  dirty: ChoreBits;
765
765
  dirtyChildren: VNode[] | null;
@@ -770,7 +770,7 @@ declare abstract class VNode extends BackRef {
770
770
 
771
771
  /** @public */
772
772
  export declare function vnode_fromJSX(jsx: JSXOutput): {
773
- vParent: _ElementVNode | _VirtualVNode;
773
+ vParent: _VirtualVNode | _ElementVNode;
774
774
  vNode: _VNode | null;
775
775
  document: _QDocument;
776
776
  container: ClientContainer_2;