@qwik.dev/core 2.0.0-beta.36 → 2.0.0-beta.37

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/core.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-beta.36-dev+3268fab
3
+ * @qwik.dev/core 2.0.0-beta.37-dev+82dc74d
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
@@ -465,6 +465,7 @@ const QDefaultSlot = '';
465
465
  const ELEMENT_ID = 'q:id';
466
466
  const ELEMENT_KEY = 'q:key';
467
467
  const ELEMENT_PROPS = 'q:props';
468
+ /** @internal */
468
469
  const ELEMENT_SEQ = 'q:seq';
469
470
  const ELEMENT_SEQ_IDX = 'q:seqIdx';
470
471
  const ITERATION_ITEM_SINGLE = 'q:p'; // Single iteration parameter (not an array)
@@ -504,6 +505,12 @@ const maybeThen = (valueOrPromise, thenFn) => {
504
505
  ? valueOrPromise.then(thenFn)
505
506
  : thenFn(valueOrPromise);
506
507
  };
508
+ /** @internal */
509
+ const delay = (timeout) => {
510
+ return new Promise((resolve) => {
511
+ setTimeout(resolve, timeout);
512
+ });
513
+ };
507
514
  const checkError = (e) => {
508
515
  if (isServer && e instanceof ReferenceError && e.message.includes('window')) {
509
516
  e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
@@ -515,6 +522,8 @@ const justThrow = (e) => {
515
522
  /**
516
523
  * Retries a function that throws a promise. If you pass `onError`, you're responsible for handling
517
524
  * errors.
525
+ *
526
+ * @internal
518
527
  */
519
528
  function retryOnPromise(fn, onError = justThrow) {
520
529
  let ok = false;
@@ -1233,7 +1242,7 @@ const COMMA = ',';
1233
1242
  *
1234
1243
  * @public
1235
1244
  */
1236
- const version = "2.0.0-beta.36-dev+3268fab";
1245
+ const version = "2.0.0-beta.37-dev+82dc74d";
1237
1246
 
1238
1247
  const isNode = (value) => {
1239
1248
  return value && typeof value.nodeType === 'number';
@@ -1840,6 +1849,7 @@ const STORE_TARGET = Symbol('store.target');
1840
1849
  const STORE_HANDLER = Symbol('store.handler');
1841
1850
  const STORE_ALL_PROPS = Symbol('store.all');
1842
1851
 
1852
+ /** @internal */
1843
1853
  function getSubscriber(effect, prop, data) {
1844
1854
  if (!effect[_EFFECT_BACK_REF]) {
1845
1855
  if (isServer && isSsrNode(effect)) {
@@ -2641,6 +2651,19 @@ class AsyncSignalImpl extends ComputedSignalImpl {
2641
2651
  }
2642
2652
  }
2643
2653
  }
2654
+ /**
2655
+ * Inject a pre-loaded value into an AsyncSignal while preserving track() subscriptions. Calls
2656
+ * `invalidate({ __v })` so the compute function reads the value from `info`, then triggers an
2657
+ * immediate synchronous compute via the private $computeIfNeeded$() method (which is mangled in
2658
+ * core builds, so callers from other packages must go through this helper).
2659
+ *
2660
+ * @internal
2661
+ */
2662
+ const _injectAsyncSignalValue = (signal, value) => {
2663
+ const impl = signal;
2664
+ impl.invalidate({ __v: value });
2665
+ impl.$computeIfNeeded$();
2666
+ };
2644
2667
 
2645
2668
  /** @internal */
2646
2669
  const _CONST_PROPS = Symbol('CONST');
@@ -6222,9 +6245,17 @@ function executeNodeDiff(vNode, container, journal, cursor) {
6222
6245
  * @returns Promise if component execution is async, void otherwise
6223
6246
  */
6224
6247
  function executeComponentChore(vNode, container, journal, cursor) {
6225
- vNode.dirty &= -5 /* ChoreBits.COMPONENT */;
6226
6248
  const host = vNode;
6227
6249
  const componentQRL = container.getHostProp(host, OnRenderProp);
6250
+ if (componentQRL && !componentQRL.resolved) {
6251
+ /**
6252
+ * If the component QRL is not resolved, we need to wait for it to resolve before we can execute
6253
+ * it. We just return the promise and we'll be called again, possibly with updated props, which
6254
+ * is why we don't clear the dirty bit yet.
6255
+ */
6256
+ return componentQRL.resolve();
6257
+ }
6258
+ vNode.dirty &= -5 /* ChoreBits.COMPONENT */;
6228
6259
  if (!componentQRL) {
6229
6260
  return;
6230
6261
  }
@@ -9233,6 +9264,7 @@ const runTask = (task, container, host) => {
9233
9264
  }
9234
9265
  return result;
9235
9266
  };
9267
+ /** @internal */
9236
9268
  class Task extends BackRef {
9237
9269
  $flags$;
9238
9270
  $index$;
@@ -9556,6 +9588,7 @@ const unwrapStore = (value) => {
9556
9588
  const isStore = (value) => {
9557
9589
  return STORE_TARGET in value;
9558
9590
  };
9591
+ /** @internal */
9559
9592
  function createStore(container, obj, flags) {
9560
9593
  return new Proxy(obj, new StoreHandler(flags, container || null));
9561
9594
  }
@@ -10268,6 +10301,9 @@ class Serializer {
10268
10301
  else if (value === explicitUndefined) {
10269
10302
  this.output(3 /* TypeIds.Constant */, 0 /* Constants.Undefined */);
10270
10303
  }
10304
+ else {
10305
+ throw qError(20 /* QError.serializeErrorUnknownType */, [typeof value]);
10306
+ }
10271
10307
  break;
10272
10308
  case 'function':
10273
10309
  if (value === Slot) {
@@ -12411,16 +12447,20 @@ const useOnEventsSequentialScope = () => {
12411
12447
  * @internal
12412
12448
  */
12413
12449
  const _hmr = function (event, element) {
12414
- if (!event.detail.files.some((file) => element.getAttribute('data-qwik-inspector')?.startsWith(file))) {
12415
- return;
12416
- }
12417
12450
  // Deserialize captures from `this` when called via qwikloader/attribute dispatch
12451
+ const container = getDomContainer(element);
12418
12452
  if (typeof this === 'string') {
12419
- const container = getDomContainer(element);
12420
12453
  setCaptures(deserializeCaptures(container, this));
12421
12454
  }
12422
- const host = _captures[0];
12423
- const container = getDomContainer(element);
12455
+ const devPath = _captures?.[1];
12456
+ const hmrPath = devPath ?? element.getAttribute('data-qwik-inspector');
12457
+ if (!hmrPath || !event.detail.files.some((file) => hmrPath.startsWith(file))) {
12458
+ return;
12459
+ }
12460
+ const host = _captures?.[0];
12461
+ if (!host || host.flags & 32 /* VNodeFlags.Deleted */) {
12462
+ return;
12463
+ }
12424
12464
  markVNodeDirty(container, host, 4 /* ChoreBits.COMPONENT */);
12425
12465
  // Mark HMR as handled
12426
12466
  const doc = element.ownerDocument;
@@ -12441,7 +12481,7 @@ function _useHmr(devPath) {
12441
12481
  hmrQrl ||= inlinedQrl(_hmr, '_hmr');
12442
12482
  const hostElement = iCtx.$hostElement$;
12443
12483
  // We must capture the vnode to be able to re-render
12444
- const qrl = hmrQrl.w([hostElement]);
12484
+ const qrl = hmrQrl.w([hostElement, devPath]);
12445
12485
  useOnDocument('qHmr', qrl);
12446
12486
  }
12447
12487
 
@@ -14361,7 +14401,11 @@ const useInvokeContext = () => {
14361
14401
  isDev && assertDefined(ctx.$effectSubscriber$, `invoke: $effectSubscriber$ must be defined`, ctx);
14362
14402
  return ctx;
14363
14403
  };
14364
- /** Call a function with the given InvokeContext and given arguments. */
14404
+ /**
14405
+ * Call a function with the given InvokeContext and given arguments.
14406
+ *
14407
+ * @internal
14408
+ */
14365
14409
  function invoke(context, fn, ...args) {
14366
14410
  return invokeApply.call(this, context, fn, args);
14367
14411
  }
@@ -14397,6 +14441,7 @@ function newRenderInvokeContext(locale, hostElement, container) {
14397
14441
  seal(ctx);
14398
14442
  return ctx;
14399
14443
  }
14444
+ /** @internal */
14400
14445
  // TODO how about putting url and locale (and event/custom?) in to a "static" object
14401
14446
  function newInvokeContext(locale, hostElement, event) {
14402
14447
  // ServerRequestEvent has .locale, but it's not always defined.
@@ -14555,7 +14600,7 @@ const setupHmr = (LazyRefClass, setGetLazyRef) => {
14555
14600
  params.push(`t=${t}`);
14556
14601
  return `${path}?${params.join('&')}`;
14557
14602
  };
14558
- document.addEventListener('qHmr', (ev) => {
14603
+ const hmrHandler = (ev) => {
14559
14604
  const files = ev.detail.files;
14560
14605
  const t = ev.detail.t || document.__hmrT || Date.now();
14561
14606
  let didReload = false;
@@ -14591,7 +14636,6 @@ const setupHmr = (LazyRefClass, setGetLazyRef) => {
14591
14636
  }
14592
14637
  if (didReload) {
14593
14638
  lazy.$ref$ = undefined;
14594
- document.__hmrDone = document.__hmrT;
14595
14639
  if (lazy.qrls) {
14596
14640
  for (const qrlRef of lazy.qrls) {
14597
14641
  const qrl = qrlRef.deref();
@@ -14607,7 +14651,8 @@ const setupHmr = (LazyRefClass, setGetLazyRef) => {
14607
14651
  }
14608
14652
  }
14609
14653
  }
14610
- });
14654
+ };
14655
+ document.addEventListener('qHmr', hmrHandler, true);
14611
14656
  };
14612
14657
 
14613
14658
  // keep these imports above the rest to prevent circular dep issues
@@ -16563,5 +16608,5 @@ if (import.meta.hot) {
16563
16608
  });
16564
16609
  }
16565
16610
 
16566
- export { $, Each, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, Reveal, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, Suspense, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, EMPTY_OBJ as _EMPTY_OBJ, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, SubscriptionPatch as _SubscriptionPatch, _UNINITIALIZED, _VAR_PROPS, _addProjection, _captures, _chk, _createDeserializeContainer, createQRL as _createQRL, _deserialize, _dumpState, eachCmp as _eaC, eachCmpTask as _eaT, _executeSsrChores, _fnSignal, getAsyncLocalStorage as _getAsyncLocalStorage, _getConstProps, _getContextContainer, _getContextEvent, _getContextHostElement, getDomContainer as _getDomContainer, _getQContainerElement, _getVarProps, _hasStoreEffects, _hmr, isJSXNode as _isJSXNode, isStore as _isStore, isStringifiable as _isStringifiable, isTask as _isTask, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, mapApp_findIndx as _mapApp_findIndx, mapArray_get as _mapArray_get, mapArray_set as _mapArray_set, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, qrlToString as _qrlToString, _qrlWithChunk, _qrlWithChunkDEV, revealCmp as _reC, revealCanReveal as _reR, revealCleanupTask as _reT, _regSymbol, _removeProjection, _res, _resolveContextWithoutSequentialScope, _restProps, _rsc, _run, _serialize, setEvent as _setEvent, _setProjectionTarget, suspenseCmp as _suC, suspenseTask as _suT, scheduleTask as _task, _updateProjectionProps, _useHmr, _val, verifySerializable as _verifySerializable, vnode_ensureElementInflated as _vnode_ensureElementInflated, vnode_getAttrKeys as _vnode_getAttrKeys, vnode_getElementName as _vnode_getElementName, vnode_getFirstChild as _vnode_getFirstChild, vnode_getProp as _vnode_getProp, vnode_getVNodeForChildNode as _vnode_getVNodeForChildNode, vnode_insertBefore as _vnode_insertBefore, vnode_isElementVNode as _vnode_isElementVNode, vnode_isMaterialized as _vnode_isMaterialized, vnode_isTextVNode as _vnode_isTextVNode, vnode_isVirtualVNode as _vnode_isVirtualVNode, vnode_newVirtual as _vnode_newVirtual, vnode_remove as _vnode_remove, vnode_setProp as _vnode_setProp, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _wrapProp, _wrapSignal, component$, componentQrl, createAsync$, createAsyncSignal as createAsyncQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, forceStoreEffects, getClientManifest, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsync$, useAsyncQrl, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useSerializer$, useSerializerQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };
16611
+ export { $, Each, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, Reveal, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, Suspense, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, ELEMENT_SEQ as _ELEMENT_SEQ, EMPTY_ARRAY as _EMPTY_ARRAY, EMPTY_OBJ as _EMPTY_OBJ, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, SubscriptionPatch as _SubscriptionPatch, Task as _Task, _UNINITIALIZED, _VAR_PROPS, _addProjection, _captures, _chk, _createDeserializeContainer, createQRL as _createQRL, createStore as _createStore, delay as _delay, _deserialize, _dumpState, eachCmp as _eaC, eachCmpTask as _eaT, _executeSsrChores, _fnSignal, getAsyncLocalStorage as _getAsyncLocalStorage, _getConstProps, _getContextContainer, _getContextEvent, _getContextHostElement, getDomContainer as _getDomContainer, _getQContainerElement, getSubscriber as _getSubscriber, _getVarProps, _hasStoreEffects, _hmr, _injectAsyncSignalValue, invoke as _invoke, isJSXNode as _isJSXNode, isStore as _isStore, isStringifiable as _isStringifiable, isTask as _isTask, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, mapApp_findIndx as _mapApp_findIndx, mapArray_get as _mapArray_get, mapArray_set as _mapArray_set, newInvokeContext as _newInvokeContext, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, qrlToString as _qrlToString, _qrlWithChunk, _qrlWithChunkDEV, revealCmp as _reC, revealCanReveal as _reR, revealCleanupTask as _reT, _regSymbol, _removeProjection, _res, _resolveContextWithoutSequentialScope, _restProps, retryOnPromise as _retryOnPromise, _rsc, _run, _serialize, setEvent as _setEvent, _setProjectionTarget, suspenseCmp as _suC, suspenseTask as _suT, scheduleTask as _task, _updateProjectionProps, _useHmr, _val, verifySerializable as _verifySerializable, vnode_ensureElementInflated as _vnode_ensureElementInflated, vnode_getAttrKeys as _vnode_getAttrKeys, vnode_getElementName as _vnode_getElementName, vnode_getFirstChild as _vnode_getFirstChild, vnode_getProp as _vnode_getProp, vnode_getVNodeForChildNode as _vnode_getVNodeForChildNode, vnode_insertBefore as _vnode_insertBefore, vnode_isElementVNode as _vnode_isElementVNode, vnode_isMaterialized as _vnode_isMaterialized, vnode_isTextVNode as _vnode_isTextVNode, vnode_isVirtualVNode as _vnode_isVirtualVNode, vnode_newVirtual as _vnode_newVirtual, vnode_remove as _vnode_remove, vnode_setProp as _vnode_setProp, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _wrapProp, _wrapSignal, component$, componentQrl, createAsync$, createAsyncSignal as createAsyncQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, forceStoreEffects, getClientManifest, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsync$, useAsyncQrl, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useSerializer$, useSerializerQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };
16567
16612
  //# sourceMappingURL=core.mjs.map