@qwik.dev/core 2.0.0-beta.18 → 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.
- package/dist/backpatch/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/core-internal.d.ts +10 -3
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +107 -91
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +64 -61
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +889 -884
- package/dist/server.mjs +4 -3
- package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
- package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
- package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
- package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
- package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
- package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
- package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
- package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
- package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
- package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
- package/dist/starters/adapters/express/package.json +1 -1
- package/dist/starters/features/compiled-i18n/package.json +37 -0
- package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
- package/dist/starters/features/{localize → compiled-i18n}/src/entry.ssr.tsx +7 -2
- package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
- package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
- package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
- package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
- package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
- package/dist/testing/index.mjs +71 -44
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
- package/dist/starters/features/localize/package.json +0 -37
- package/dist/starters/features/localize/src/locales/message.en.json +0 -8
- package/dist/starters/features/localize/src/locales/message.it.json +0 -8
- package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
- package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
- package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
package/dist/core.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core 2.0.0-beta.19-dev+0d046fb
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
@@ -14,7 +14,7 @@ import { p } from '@qwik.dev/core/preloader';
|
|
|
14
14
|
*
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
const version = "2.0.0-beta.
|
|
17
|
+
const version = "2.0.0-beta.19-dev+0d046fb";
|
|
18
18
|
|
|
19
19
|
// same as isDev but separate so we can test
|
|
20
20
|
const qDev = globalThis.qDev !== false;
|
|
@@ -468,79 +468,6 @@ function assertNumber(value1, text, ...parts) {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
let _locale = undefined;
|
|
472
|
-
let localAsyncStore;
|
|
473
|
-
if (isServer) {
|
|
474
|
-
import('node:async_hooks')
|
|
475
|
-
.then((module) => {
|
|
476
|
-
localAsyncStore = new module.AsyncLocalStorage();
|
|
477
|
-
})
|
|
478
|
-
.catch(() => {
|
|
479
|
-
// ignore if AsyncLocalStorage is not available
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Retrieve the current locale.
|
|
484
|
-
*
|
|
485
|
-
* If no current locale and there is no `defaultLocale` the function throws an error.
|
|
486
|
-
*
|
|
487
|
-
* @returns The locale.
|
|
488
|
-
* @public
|
|
489
|
-
*/
|
|
490
|
-
function getLocale(defaultLocale) {
|
|
491
|
-
// Prefer per-request locale from local AsyncLocalStorage if available (server-side)
|
|
492
|
-
if (localAsyncStore) {
|
|
493
|
-
const locale = localAsyncStore.getStore();
|
|
494
|
-
if (locale) {
|
|
495
|
-
return locale;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (_locale === undefined) {
|
|
499
|
-
const ctx = tryGetInvokeContext();
|
|
500
|
-
if (ctx && ctx.$locale$) {
|
|
501
|
-
return ctx.$locale$;
|
|
502
|
-
}
|
|
503
|
-
if (defaultLocale !== undefined) {
|
|
504
|
-
return defaultLocale;
|
|
505
|
-
}
|
|
506
|
-
throw new Error('Reading `locale` outside of context.');
|
|
507
|
-
}
|
|
508
|
-
return _locale;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Override the `getLocale` with `lang` within the `fn` execution.
|
|
512
|
-
*
|
|
513
|
-
* @public
|
|
514
|
-
*/
|
|
515
|
-
function withLocale(locale, fn) {
|
|
516
|
-
if (localAsyncStore) {
|
|
517
|
-
return localAsyncStore.run(locale, fn);
|
|
518
|
-
}
|
|
519
|
-
const previousLang = _locale;
|
|
520
|
-
try {
|
|
521
|
-
_locale = locale;
|
|
522
|
-
return fn();
|
|
523
|
-
}
|
|
524
|
-
finally {
|
|
525
|
-
_locale = previousLang;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Globally set a lang.
|
|
530
|
-
*
|
|
531
|
-
* This can be used only in browser. Server execution requires that each request could potentially
|
|
532
|
-
* be a different lang, therefore setting a global lang would produce incorrect responses.
|
|
533
|
-
*
|
|
534
|
-
* @public
|
|
535
|
-
*/
|
|
536
|
-
function setLocale(locale) {
|
|
537
|
-
if (localAsyncStore) {
|
|
538
|
-
localAsyncStore.enterWith(locale);
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
_locale = locale;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
471
|
/**
|
|
545
472
|
* A friendly name tag for a VirtualVNode.
|
|
546
473
|
*
|
|
@@ -2226,12 +2153,13 @@ function clearEffectSubscription(container, effect) {
|
|
|
2226
2153
|
return;
|
|
2227
2154
|
}
|
|
2228
2155
|
for (const producer of backRefs) {
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
}
|
|
2232
|
-
else if (producer instanceof AsyncComputedSignalImpl) {
|
|
2156
|
+
// Check AsyncComputedSignalImpl before SignalImpl since it extends SignalImpl
|
|
2157
|
+
if (producer instanceof AsyncComputedSignalImpl) {
|
|
2233
2158
|
clearAsyncComputedSignal(producer, effect);
|
|
2234
2159
|
}
|
|
2160
|
+
else if (producer instanceof SignalImpl) {
|
|
2161
|
+
clearSignal(container, producer, effect);
|
|
2162
|
+
}
|
|
2235
2163
|
else if (isPropsProxy(producer)) {
|
|
2236
2164
|
const propsHandler = producer[_PROPS_HANDLER];
|
|
2237
2165
|
clearStoreOrProps(propsHandler, effect);
|
|
@@ -2249,7 +2177,8 @@ function clearSignal(container, producer, effect) {
|
|
|
2249
2177
|
if (effects && effects.has(effect)) {
|
|
2250
2178
|
effects.delete(effect);
|
|
2251
2179
|
}
|
|
2252
|
-
if (producer instanceof WrappedSignalImpl) {
|
|
2180
|
+
if (producer instanceof WrappedSignalImpl && !effects?.size) {
|
|
2181
|
+
// Only clear if there are no more subscribers
|
|
2253
2182
|
producer.$hostElement$ = undefined;
|
|
2254
2183
|
clearAllEffects(container, producer);
|
|
2255
2184
|
}
|
|
@@ -4931,6 +4860,7 @@ function getResourceValueAsPromise(props) {
|
|
|
4931
4860
|
const isBrowser = !isServerPlatform();
|
|
4932
4861
|
if (isBrowser) {
|
|
4933
4862
|
if (state === 'pending' && props.onPending) {
|
|
4863
|
+
resource.value.catch(() => { });
|
|
4934
4864
|
return Promise.resolve().then(useBindInvokeContext(props.onPending));
|
|
4935
4865
|
}
|
|
4936
4866
|
else if (state === 'rejected' && props.onRejected) {
|
|
@@ -7672,6 +7602,79 @@ const vnode_getProjectionParentComponent = (vHost) => {
|
|
|
7672
7602
|
return vHost;
|
|
7673
7603
|
};
|
|
7674
7604
|
|
|
7605
|
+
let _locale = undefined;
|
|
7606
|
+
let localAsyncStore;
|
|
7607
|
+
if (isServer) {
|
|
7608
|
+
import('node:async_hooks')
|
|
7609
|
+
.then((module) => {
|
|
7610
|
+
localAsyncStore = new module.AsyncLocalStorage();
|
|
7611
|
+
})
|
|
7612
|
+
.catch(() => {
|
|
7613
|
+
// ignore if AsyncLocalStorage is not available
|
|
7614
|
+
});
|
|
7615
|
+
}
|
|
7616
|
+
/**
|
|
7617
|
+
* Retrieve the current locale.
|
|
7618
|
+
*
|
|
7619
|
+
* If no current locale and there is no `defaultLocale` the function throws an error.
|
|
7620
|
+
*
|
|
7621
|
+
* @returns The locale.
|
|
7622
|
+
* @public
|
|
7623
|
+
*/
|
|
7624
|
+
function getLocale(defaultLocale) {
|
|
7625
|
+
// Prefer per-request locale from local AsyncLocalStorage if available (server-side)
|
|
7626
|
+
if (localAsyncStore) {
|
|
7627
|
+
const locale = localAsyncStore.getStore();
|
|
7628
|
+
if (locale) {
|
|
7629
|
+
return locale;
|
|
7630
|
+
}
|
|
7631
|
+
}
|
|
7632
|
+
if (_locale === undefined) {
|
|
7633
|
+
const ctx = tryGetInvokeContext();
|
|
7634
|
+
if (ctx && ctx.$locale$) {
|
|
7635
|
+
return ctx.$locale$;
|
|
7636
|
+
}
|
|
7637
|
+
if (defaultLocale !== undefined) {
|
|
7638
|
+
return defaultLocale;
|
|
7639
|
+
}
|
|
7640
|
+
throw new Error('Reading `locale` outside of context.');
|
|
7641
|
+
}
|
|
7642
|
+
return _locale;
|
|
7643
|
+
}
|
|
7644
|
+
/**
|
|
7645
|
+
* Override the `getLocale` with `lang` within the `fn` execution.
|
|
7646
|
+
*
|
|
7647
|
+
* @public
|
|
7648
|
+
*/
|
|
7649
|
+
function withLocale(locale, fn) {
|
|
7650
|
+
if (localAsyncStore) {
|
|
7651
|
+
return localAsyncStore.run(locale, fn);
|
|
7652
|
+
}
|
|
7653
|
+
const previousLang = _locale;
|
|
7654
|
+
try {
|
|
7655
|
+
_locale = locale;
|
|
7656
|
+
return fn();
|
|
7657
|
+
}
|
|
7658
|
+
finally {
|
|
7659
|
+
_locale = previousLang;
|
|
7660
|
+
}
|
|
7661
|
+
}
|
|
7662
|
+
/**
|
|
7663
|
+
* Globally set a lang.
|
|
7664
|
+
*
|
|
7665
|
+
* This can be used only in browser. Server execution requires that each request could potentially
|
|
7666
|
+
* be a different lang, therefore setting a global lang would produce incorrect responses.
|
|
7667
|
+
*
|
|
7668
|
+
* @public
|
|
7669
|
+
*/
|
|
7670
|
+
function setLocale(locale) {
|
|
7671
|
+
if (localAsyncStore) {
|
|
7672
|
+
localAsyncStore.enterWith(locale);
|
|
7673
|
+
return;
|
|
7674
|
+
}
|
|
7675
|
+
_locale = locale;
|
|
7676
|
+
}
|
|
7677
|
+
|
|
7675
7678
|
let _context;
|
|
7676
7679
|
const tryGetInvokeContext = () => {
|
|
7677
7680
|
if (!_context) {
|
|
@@ -7767,24 +7770,37 @@ function newInvokeContext(locale, hostElement, event, url) {
|
|
|
7767
7770
|
return ctx;
|
|
7768
7771
|
}
|
|
7769
7772
|
/**
|
|
7770
|
-
*
|
|
7773
|
+
* Get the value of the expression without tracking listeners. A function will be invoked, signals
|
|
7774
|
+
* will return their value, and stores will be unwrapped (they return the backing object).
|
|
7775
|
+
*
|
|
7776
|
+
* When you pass a function, you can also pass additional arguments that the function will receive.
|
|
7771
7777
|
*
|
|
7778
|
+
* Note that stores are not unwrapped recursively.
|
|
7779
|
+
*
|
|
7780
|
+
* @param expr - The function or object to evaluate without tracking.
|
|
7781
|
+
* @param args - Additional arguments to pass when `expr` is a function.
|
|
7772
7782
|
* @public
|
|
7773
7783
|
*/
|
|
7774
|
-
const untrack = (
|
|
7775
|
-
if (
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7784
|
+
const untrack = (expr, ...args) => {
|
|
7785
|
+
if (typeof expr === 'function') {
|
|
7786
|
+
if (_context) {
|
|
7787
|
+
const sub = _context.$effectSubscriber$;
|
|
7788
|
+
try {
|
|
7789
|
+
_context.$effectSubscriber$ = undefined;
|
|
7790
|
+
return expr(...args);
|
|
7791
|
+
}
|
|
7792
|
+
finally {
|
|
7793
|
+
_context.$effectSubscriber$ = sub;
|
|
7794
|
+
}
|
|
7780
7795
|
}
|
|
7781
|
-
|
|
7782
|
-
|
|
7796
|
+
else {
|
|
7797
|
+
return expr(...args);
|
|
7783
7798
|
}
|
|
7784
7799
|
}
|
|
7785
|
-
|
|
7786
|
-
return
|
|
7800
|
+
if (isSignal(expr)) {
|
|
7801
|
+
return expr.untrackedValue;
|
|
7787
7802
|
}
|
|
7803
|
+
return unwrapStore(expr);
|
|
7788
7804
|
};
|
|
7789
7805
|
const trackInvocation = /*#__PURE__*/ newRenderInvokeContext(undefined, undefined, undefined);
|
|
7790
7806
|
/**
|