@qwik.dev/core 2.0.0-beta.5 → 2.0.0-beta.7
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/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +51 -13
- package/dist/core.cjs +239 -105
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +224 -105
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +117 -63
- package/dist/core.prod.mjs +113 -58
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +138 -202
- package/dist/optimizer.d.ts +9 -15
- package/dist/optimizer.mjs +129 -195
- package/dist/server.cjs +33 -16
- package/dist/server.d.ts +1 -0
- package/dist/server.mjs +32 -16
- package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/vite.config.mts +1 -1
- package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +1 -5
- package/dist/starters/adapters/azure-swa/adapters/azure-swa/vite.config.mts +1 -1
- package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +1 -2
- package/dist/starters/adapters/bun/adapters/bun/vite.config.mts +1 -1
- package/dist/starters/adapters/bun/src/entry.bun.ts +0 -2
- package/dist/starters/adapters/cloud-run/adapters/cloud-run/vite.config.mts +1 -1
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +0 -2
- package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/vite.config.mts +1 -1
- package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +1 -2
- package/dist/starters/adapters/deno/adapters/deno/vite.config.mts +1 -1
- package/dist/starters/adapters/deno/src/entry.deno.ts +0 -2
- package/dist/starters/adapters/express/adapters/express/vite.config.mts +1 -1
- package/dist/starters/adapters/express/src/entry.express.tsx +0 -2
- package/dist/starters/adapters/fastify/adapters/fastify/vite.config.mts +1 -1
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
- package/dist/starters/adapters/firebase/adapters/firebase/vite.config.mts +1 -1
- package/dist/starters/adapters/firebase/src/entry-firebase.tsx +1 -2
- package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/vite.config.mts +1 -1
- package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +1 -2
- package/dist/starters/adapters/node-server/adapters/node-server/vite.config.mts +1 -1
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +0 -2
- package/dist/starters/adapters/{static/adapters/static → ssg/adapters/ssg}/vite.config.mts +2 -2
- package/dist/starters/adapters/ssg/package.json +19 -0
- package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/vite.config.mts +1 -1
- package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +1 -2
- package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
- package/dist/starters/features/localize/src/entry.ssr.tsx +17 -21
- package/dist/testing/index.cjs +183 -121
- package/dist/testing/index.mjs +176 -115
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
- package/dist/starters/adapters/static/package.json +0 -19
- /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
package/dist/core.prod.cjs
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.7-dev+2dd89a6
|
|
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
|
|
@@ -400,7 +400,7 @@
|
|
|
400
400
|
set(1));
|
|
401
401
|
};
|
|
402
402
|
const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
|
|
403
|
-
const version = "2.0.0-beta.
|
|
403
|
+
const version = "2.0.0-beta.7-dev+2dd89a6";
|
|
404
404
|
const EMPTY_ARRAY = [];
|
|
405
405
|
const EMPTY_OBJ = {};
|
|
406
406
|
Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
|
|
@@ -466,6 +466,28 @@
|
|
|
466
466
|
}
|
|
467
467
|
return scheduler(2, hostElement, runQrl, args);
|
|
468
468
|
};
|
|
469
|
+
const mapApp_findIndx = (array, key, start) => {
|
|
470
|
+
assertTrue();
|
|
471
|
+
let bottom = start >> 1;
|
|
472
|
+
let top = array.length - 2 >> 1;
|
|
473
|
+
for (;bottom <= top; ) {
|
|
474
|
+
const mid = bottom + (top - bottom >> 1);
|
|
475
|
+
const midKey = array[mid << 1];
|
|
476
|
+
if (midKey === key) {
|
|
477
|
+
return mid << 1;
|
|
478
|
+
}
|
|
479
|
+
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
480
|
+
}
|
|
481
|
+
return ~(bottom << 1);
|
|
482
|
+
};
|
|
483
|
+
const mapArray_set = (array, key, value, start) => {
|
|
484
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
485
|
+
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(-1 ^ indx, 0, key, value);
|
|
486
|
+
};
|
|
487
|
+
const mapArray_get = (array, key, start) => {
|
|
488
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
489
|
+
return indx >= 0 ? array[indx + 1] : null;
|
|
490
|
+
};
|
|
469
491
|
const _CONST_PROPS = Symbol("CONST");
|
|
470
492
|
const _VAR_PROPS = Symbol("VAR");
|
|
471
493
|
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
@@ -970,26 +992,30 @@
|
|
|
970
992
|
componentFn(props)), jsx => {
|
|
971
993
|
const useOnEvents = container.getHostProp(renderHost, ":on");
|
|
972
994
|
return useOnEvents ? function(jsx, useOnEvents) {
|
|
973
|
-
const jsxElement =
|
|
995
|
+
const jsxElement = findFirstElementNode(jsx);
|
|
974
996
|
let jsxResult = jsx;
|
|
997
|
+
const qVisibleEvent = "onQvisible$";
|
|
975
998
|
return maybeThen(jsxElement, jsxElement => {
|
|
976
|
-
|
|
977
|
-
|
|
999
|
+
const isHeadless = !jsxElement;
|
|
1000
|
+
let placeholderElement = null;
|
|
978
1001
|
for (const key in useOnEvents) {
|
|
979
1002
|
if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
} else if (key.startsWith("document:") || key.startsWith("window:")) {
|
|
985
|
-
const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
986
|
-
jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
|
|
987
|
-
} else {
|
|
1003
|
+
let targetElement = jsxElement;
|
|
1004
|
+
let eventKey = key;
|
|
1005
|
+
if (isHeadless) {
|
|
1006
|
+
if (key !== qVisibleEvent && !key.startsWith("document:on") && !key.startsWith("window:on")) {
|
|
988
1007
|
build.isDev && logWarn('You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component has a valid element node. ');
|
|
1008
|
+
continue;
|
|
989
1009
|
}
|
|
990
|
-
|
|
991
|
-
|
|
1010
|
+
if (!placeholderElement) {
|
|
1011
|
+
const [createdElement, newJsx] = injectPlaceholderElement(jsxResult);
|
|
1012
|
+
jsxResult = newJsx, placeholderElement = createdElement;
|
|
1013
|
+
}
|
|
1014
|
+
targetElement = placeholderElement;
|
|
992
1015
|
}
|
|
1016
|
+
targetElement && ("script" === targetElement.type && key === qVisibleEvent && (eventKey = "document:onQinit$",
|
|
1017
|
+
logWarn('You are trying to add an event "' + key + '" using `useVisibleTask$` hook, but a node to which you can add an event is not found. Using document:onQinit$ instead.')),
|
|
1018
|
+
addUseOnEvent(targetElement, eventKey, useOnEvents[key]));
|
|
993
1019
|
}
|
|
994
1020
|
}
|
|
995
1021
|
return jsxResult;
|
|
@@ -1013,7 +1039,7 @@
|
|
|
1013
1039
|
void 0 === propValue ? propValue = [] : Array.isArray(propValue) || (propValue = [ propValue ]),
|
|
1014
1040
|
propValue.push(...value), props[key] = propValue;
|
|
1015
1041
|
}
|
|
1016
|
-
function
|
|
1042
|
+
function findFirstElementNode(jsx) {
|
|
1017
1043
|
const queue = [ jsx ];
|
|
1018
1044
|
for (;queue.length; ) {
|
|
1019
1045
|
const jsx = queue.shift();
|
|
@@ -1022,33 +1048,41 @@
|
|
|
1022
1048
|
return jsx;
|
|
1023
1049
|
}
|
|
1024
1050
|
queue.push(jsx.children);
|
|
1025
|
-
} else if (
|
|
1051
|
+
} else if (isArray(jsx)) {
|
|
1026
1052
|
queue.push(...jsx);
|
|
1027
1053
|
} else {
|
|
1028
1054
|
if (isPromise(jsx)) {
|
|
1029
|
-
return maybeThen(jsx, jsx =>
|
|
1055
|
+
return maybeThen(jsx, jsx => findFirstElementNode(jsx));
|
|
1030
1056
|
}
|
|
1031
1057
|
if (isSignal(jsx)) {
|
|
1032
|
-
return
|
|
1058
|
+
return findFirstElementNode(untrack(() => jsx.value));
|
|
1033
1059
|
}
|
|
1034
1060
|
}
|
|
1035
1061
|
}
|
|
1036
1062
|
return null;
|
|
1037
1063
|
}
|
|
1038
|
-
function
|
|
1064
|
+
function injectPlaceholderElement(jsx) {
|
|
1039
1065
|
if (isJSXNode(jsx)) {
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1066
|
+
const placeholder = createPlaceholderScriptNode();
|
|
1067
|
+
return jsx.type === Slot ? [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ] : (null == jsx.children ? jsx.children = placeholder : isArray(jsx.children) ? jsx.children.push(placeholder) : jsx.children = [ jsx.children, placeholder ],
|
|
1068
|
+
[ placeholder, jsx ]);
|
|
1069
|
+
}
|
|
1070
|
+
if ("object" != typeof (v = jsx) && "function" != typeof v && null != v) {
|
|
1071
|
+
const placeholder = createPlaceholderScriptNode();
|
|
1072
|
+
return [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
|
|
1073
|
+
}
|
|
1074
|
+
var v;
|
|
1075
|
+
if (isArray(jsx) && jsx.length > 0) {
|
|
1076
|
+
const [createdElement, _] = injectPlaceholderElement(jsx[0]);
|
|
1077
|
+
return [ createdElement, jsx ];
|
|
1078
|
+
}
|
|
1079
|
+
return [ null, jsx ];
|
|
1080
|
+
}
|
|
1081
|
+
function createPlaceholderScriptNode() {
|
|
1082
|
+
return new JSXNodeImpl("script", {}, {
|
|
1083
|
+
type: "placeholder",
|
|
1084
|
+
hidden: ""
|
|
1085
|
+
}, null, 3);
|
|
1052
1086
|
}
|
|
1053
1087
|
class ParentComponentData {
|
|
1054
1088
|
$scopedStyle$;
|
|
@@ -1468,28 +1502,6 @@
|
|
|
1468
1502
|
}
|
|
1469
1503
|
}
|
|
1470
1504
|
const directGetPropsProxyProp = (jsx, prop) => jsx.constProps && prop in jsx.constProps ? jsx.constProps[prop] : jsx.varProps[prop];
|
|
1471
|
-
const mapApp_findIndx = (array, key, start) => {
|
|
1472
|
-
assertTrue();
|
|
1473
|
-
let bottom = start >> 1;
|
|
1474
|
-
let top = array.length - 2 >> 1;
|
|
1475
|
-
for (;bottom <= top; ) {
|
|
1476
|
-
const mid = bottom + (top - bottom >> 1);
|
|
1477
|
-
const midKey = array[mid << 1];
|
|
1478
|
-
if (midKey === key) {
|
|
1479
|
-
return mid << 1;
|
|
1480
|
-
}
|
|
1481
|
-
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
1482
|
-
}
|
|
1483
|
-
return ~(bottom << 1);
|
|
1484
|
-
};
|
|
1485
|
-
const mapArray_set = (array, key, value, start) => {
|
|
1486
|
-
const indx = mapApp_findIndx(array, key, start);
|
|
1487
|
-
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(-1 ^ indx, 0, key, value);
|
|
1488
|
-
};
|
|
1489
|
-
const mapArray_get = (array, key, start) => {
|
|
1490
|
-
const indx = mapApp_findIndx(array, key, start);
|
|
1491
|
-
return indx >= 0 ? array[indx + 1] : null;
|
|
1492
|
-
};
|
|
1493
1505
|
const isForeignObjectElement = elementName => build.isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
|
|
1494
1506
|
function cloneElementWithNamespace(element, elementName, namespace) {
|
|
1495
1507
|
const newElement = element.ownerDocument.createElementNS(namespace, elementName);
|
|
@@ -1588,6 +1600,26 @@
|
|
|
1588
1600
|
elementNamespaceFlag
|
|
1589
1601
|
};
|
|
1590
1602
|
}
|
|
1603
|
+
function getAttributeNamespace(attributeName) {
|
|
1604
|
+
switch (attributeName) {
|
|
1605
|
+
case "xlink:href":
|
|
1606
|
+
case "xlink:actuate":
|
|
1607
|
+
case "xlink:arcrole":
|
|
1608
|
+
case "xlink:role":
|
|
1609
|
+
case "xlink:show":
|
|
1610
|
+
case "xlink:title":
|
|
1611
|
+
case "xlink:type":
|
|
1612
|
+
return "http://www.w3.org/1999/xlink";
|
|
1613
|
+
|
|
1614
|
+
case "xml:base":
|
|
1615
|
+
case "xml:lang":
|
|
1616
|
+
case "xml:space":
|
|
1617
|
+
return "http://www.w3.org/XML/1998/namespace";
|
|
1618
|
+
|
|
1619
|
+
default:
|
|
1620
|
+
return null;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1591
1623
|
function escapeHTML(html) {
|
|
1592
1624
|
let escapedHTML = "";
|
|
1593
1625
|
const length = html.length;
|
|
@@ -1810,7 +1842,16 @@
|
|
|
1810
1842
|
}
|
|
1811
1843
|
if ("dangerouslySetInnerHTML" !== key) {
|
|
1812
1844
|
if ("textarea" !== elementName || "value" !== key) {
|
|
1813
|
-
value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value
|
|
1845
|
+
if (value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value) {
|
|
1846
|
+
if (64 & vNewNode[0]) {
|
|
1847
|
+
const namespace = getAttributeNamespace(key);
|
|
1848
|
+
if (namespace) {
|
|
1849
|
+
element.setAttributeNS(namespace, key, String(value));
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
element.setAttribute(key, String(value));
|
|
1854
|
+
}
|
|
1814
1855
|
} else {
|
|
1815
1856
|
if (value && "string" != typeof value) {
|
|
1816
1857
|
if (build.isDev) {
|
|
@@ -3817,7 +3858,7 @@
|
|
|
3817
3858
|
const idx = mapApp_findIndx(props, key, 0);
|
|
3818
3859
|
idx >= 0 ? props[idx + 1] = value : null != value && props.splice(-1 ^ idx, 0, key, value);
|
|
3819
3860
|
};
|
|
3820
|
-
const
|
|
3861
|
+
const vnode_getPropStartIndex = vnode => {
|
|
3821
3862
|
const type = 7 & vnode[0];
|
|
3822
3863
|
if (1 === type) {
|
|
3823
3864
|
return 8;
|
|
@@ -3826,7 +3867,8 @@
|
|
|
3826
3867
|
return 6;
|
|
3827
3868
|
}
|
|
3828
3869
|
throw qError(26, [ type ]);
|
|
3829
|
-
}
|
|
3870
|
+
};
|
|
3871
|
+
const vnode_getProps = vnode => vnode[vnode_getPropStartIndex(vnode)];
|
|
3830
3872
|
const vnode_getParent = vnode => vnode[1] || null;
|
|
3831
3873
|
const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[6] : (assertTrue(vnode_isTextVNode(vnode)),
|
|
3832
3874
|
vnode[4]);
|
|
@@ -4300,7 +4342,7 @@
|
|
|
4300
4342
|
case 11:
|
|
4301
4343
|
const vNode = retrieveVNodeOrDocument(container, value);
|
|
4302
4344
|
if (vnode_isVNode(vNode)) {
|
|
4303
|
-
return vnode_getNode(vNode);
|
|
4345
|
+
return ensureMaterialized(vNode), vnode_getNode(vNode);
|
|
4304
4346
|
}
|
|
4305
4347
|
throw qError(17, [ typeof vNode ]);
|
|
4306
4348
|
|
|
@@ -5557,9 +5599,9 @@
|
|
|
5557
5599
|
return iCtx.$event$;
|
|
5558
5600
|
}
|
|
5559
5601
|
}, exports._getDomContainer = getDomContainer, exports._getQContainerElement = _getQContainerElement,
|
|
5560
|
-
exports._isJSXNode = isJSXNode, exports._isStringifiable = function(value) {
|
|
5602
|
+
exports._isJSXNode = isJSXNode, exports._isStore = isStore, exports._isStringifiable = function(value) {
|
|
5561
5603
|
return null === value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value;
|
|
5562
|
-
}, exports._jsxBranch = input => input, exports._jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key),
|
|
5604
|
+
}, exports._isTask = isTask, exports._jsxBranch = input => input, exports._jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key),
|
|
5563
5605
|
exports._jsxQ = (type, mutable, immutable, children, _flags, key) => jsx(type, {
|
|
5564
5606
|
...immutable,
|
|
5565
5607
|
...mutable,
|
|
@@ -5567,7 +5609,8 @@
|
|
|
5567
5609
|
}, key), exports._jsxS = (type, mutable, immutable, _flags, key) => jsx(type, {
|
|
5568
5610
|
...immutable,
|
|
5569
5611
|
...mutable
|
|
5570
|
-
}, key), exports._jsxSorted = _jsxSorted, exports._jsxSplit = _jsxSplit, exports.
|
|
5612
|
+
}, key), exports._jsxSorted = _jsxSorted, exports._jsxSplit = _jsxSplit, exports._mapApp_findIndx = mapApp_findIndx,
|
|
5613
|
+
exports._mapArray_get = mapArray_get, exports._mapArray_set = mapArray_set, exports._noopQrl = _noopQrl,
|
|
5571
5614
|
exports._noopQrlDEV = (symbolName, opts, lexicalScopeCapture = EMPTY_ARRAY) => {
|
|
5572
5615
|
const newQrl = _noopQrl(symbolName, lexicalScopeCapture);
|
|
5573
5616
|
return newQrl.dev = opts, newQrl;
|
|
@@ -5575,7 +5618,13 @@
|
|
|
5575
5618
|
return void 0 === serializedFn && (serializedFn = fn.toString()), fn.serialized = serializedFn,
|
|
5576
5619
|
createQRL("", "<sync>", fn, null, null, null);
|
|
5577
5620
|
}, exports._regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
|
|
5578
|
-
globalThis.__qwik_reg_symbols.set(hash, symbol), symbol), exports.
|
|
5621
|
+
globalThis.__qwik_reg_symbols.set(hash, symbol), symbol), exports._resolveContextWithoutSequentialScope = context => {
|
|
5622
|
+
const iCtx = getInvokeContext();
|
|
5623
|
+
const hostElement = iCtx.$hostElement$;
|
|
5624
|
+
if (hostElement) {
|
|
5625
|
+
return iCtx.$container$?.resolveContext(hostElement, context);
|
|
5626
|
+
}
|
|
5627
|
+
}, exports._restProps = (props, omit, target = {}) => {
|
|
5579
5628
|
let constPropsTarget = null;
|
|
5580
5629
|
const constProps = props[_CONST_PROPS];
|
|
5581
5630
|
if (constProps) {
|
|
@@ -5596,7 +5645,12 @@
|
|
|
5596
5645
|
serializationContext.$addRoot$(root);
|
|
5597
5646
|
}
|
|
5598
5647
|
return await serializationContext.$serialize$(), serializationContext.$writer$.toString();
|
|
5599
|
-
}, exports._task = scheduleTask, exports.
|
|
5648
|
+
}, exports._task = scheduleTask, exports._verifySerializable = verifySerializable,
|
|
5649
|
+
exports._vnode_ensureElementInflated = vnode_ensureElementInflated, exports._vnode_getAttr = vnode_getAttr,
|
|
5650
|
+
exports._vnode_getAttrKeys = vnode_getAttrKeys, exports._vnode_getFirstChild = vnode_getFirstChild,
|
|
5651
|
+
exports._vnode_getNextSibling = vnode_getNextSibling, exports._vnode_getPropStartIndex = vnode_getPropStartIndex,
|
|
5652
|
+
exports._vnode_getProps = vnode_getProps, exports._vnode_isMaterialized = vnode_isMaterialized,
|
|
5653
|
+
exports._vnode_isTextVNode = vnode_isTextVNode, exports._vnode_isVirtualVNode = vnode_isVirtualVNode,
|
|
5600
5654
|
exports._vnode_toString = vnode_toString, exports._waitUntilRendered = elm => {
|
|
5601
5655
|
const containerEl = _getQContainerElement(elm);
|
|
5602
5656
|
if (!containerEl) {
|
package/dist/core.prod.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.7-dev+2dd89a6
|
|
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
|
|
@@ -68,6 +68,8 @@ const isString = v => "string" == typeof v;
|
|
|
68
68
|
|
|
69
69
|
const isFunction = v => "function" == typeof v;
|
|
70
70
|
|
|
71
|
+
const isPrimitive = v => "object" != typeof v && "function" != typeof v && null != v;
|
|
72
|
+
|
|
71
73
|
const codeToText = code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
|
|
72
74
|
|
|
73
75
|
const qError = (code, errorMessageArgs = []) => {
|
|
@@ -150,6 +152,10 @@ const SVG_NS = "http://www.w3.org/2000/svg";
|
|
|
150
152
|
|
|
151
153
|
const MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
152
154
|
|
|
155
|
+
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
156
|
+
|
|
157
|
+
const XML_NS = "http://www.w3.org/XML/1998/namespace";
|
|
158
|
+
|
|
153
159
|
const ResourceEvent = "qResource";
|
|
154
160
|
|
|
155
161
|
const RenderEvent = "qRender";
|
|
@@ -699,11 +705,19 @@ const validateContext = context => {
|
|
|
699
705
|
}
|
|
700
706
|
};
|
|
701
707
|
|
|
708
|
+
const _resolveContextWithoutSequentialScope = context => {
|
|
709
|
+
const iCtx = getInvokeContext();
|
|
710
|
+
const hostElement = iCtx.$hostElement$;
|
|
711
|
+
if (hostElement) {
|
|
712
|
+
return iCtx.$container$?.resolveContext(hostElement, context);
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
702
716
|
const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
|
|
703
717
|
|
|
704
718
|
const isRecoverable = err => !(err && err instanceof Error && "plugin" in err);
|
|
705
719
|
|
|
706
|
-
const version = "2.0.0-beta.
|
|
720
|
+
const version = "2.0.0-beta.7-dev+2dd89a6";
|
|
707
721
|
|
|
708
722
|
const EMPTY_ARRAY = [];
|
|
709
723
|
|
|
@@ -799,6 +813,31 @@ const queueQRL = (...args) => {
|
|
|
799
813
|
return scheduler(2, hostElement, runQrl, args);
|
|
800
814
|
};
|
|
801
815
|
|
|
816
|
+
const mapApp_findIndx = (array, key, start) => {
|
|
817
|
+
assertTrue(start % 2 == 0, "Expecting even number.");
|
|
818
|
+
let bottom = start >> 1;
|
|
819
|
+
let top = array.length - 2 >> 1;
|
|
820
|
+
for (;bottom <= top; ) {
|
|
821
|
+
const mid = bottom + (top - bottom >> 1);
|
|
822
|
+
const midKey = array[mid << 1];
|
|
823
|
+
if (midKey === key) {
|
|
824
|
+
return mid << 1;
|
|
825
|
+
}
|
|
826
|
+
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
827
|
+
}
|
|
828
|
+
return ~(bottom << 1);
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
const mapArray_set = (array, key, value, start) => {
|
|
832
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
833
|
+
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(-1 ^ indx, 0, key, value);
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
const mapArray_get = (array, key, start) => {
|
|
837
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
838
|
+
return indx >= 0 ? array[indx + 1] : null;
|
|
839
|
+
};
|
|
840
|
+
|
|
802
841
|
const _CONST_PROPS = Symbol("CONST");
|
|
803
842
|
|
|
804
843
|
const _VAR_PROPS = Symbol("VAR");
|
|
@@ -1439,26 +1478,29 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
|
|
|
1439
1478
|
};
|
|
1440
1479
|
|
|
1441
1480
|
function addUseOnEvents(jsx, useOnEvents) {
|
|
1442
|
-
const jsxElement =
|
|
1481
|
+
const jsxElement = findFirstElementNode(jsx);
|
|
1443
1482
|
let jsxResult = jsx;
|
|
1444
1483
|
return maybeThen(jsxElement, jsxElement => {
|
|
1445
|
-
|
|
1446
|
-
|
|
1484
|
+
const isHeadless = !jsxElement;
|
|
1485
|
+
let placeholderElement = null;
|
|
1447
1486
|
for (const key in useOnEvents) {
|
|
1448
1487
|
if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
} else if (key.startsWith("document:") || key.startsWith("window:")) {
|
|
1454
|
-
const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
1455
|
-
jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
|
|
1456
|
-
} else {
|
|
1488
|
+
let targetElement = jsxElement;
|
|
1489
|
+
let eventKey = key;
|
|
1490
|
+
if (isHeadless) {
|
|
1491
|
+
if ("onQvisible$" !== key && !key.startsWith("document:on") && !key.startsWith("window:on")) {
|
|
1457
1492
|
isDev && logWarn('You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component has a valid element node. ');
|
|
1493
|
+
continue;
|
|
1458
1494
|
}
|
|
1459
|
-
|
|
1460
|
-
|
|
1495
|
+
if (!placeholderElement) {
|
|
1496
|
+
const [createdElement, newJsx] = injectPlaceholderElement(jsxResult);
|
|
1497
|
+
jsxResult = newJsx, placeholderElement = createdElement;
|
|
1498
|
+
}
|
|
1499
|
+
targetElement = placeholderElement;
|
|
1461
1500
|
}
|
|
1501
|
+
targetElement && ("script" === targetElement.type && "onQvisible$" === key && (eventKey = "document:onQinit$",
|
|
1502
|
+
logWarn('You are trying to add an event "' + key + '" using `useVisibleTask$` hook, but a node to which you can add an event is not found. Using document:onQinit$ instead.')),
|
|
1503
|
+
addUseOnEvent(targetElement, eventKey, useOnEvents[key]));
|
|
1462
1504
|
}
|
|
1463
1505
|
}
|
|
1464
1506
|
return jsxResult;
|
|
@@ -1473,7 +1515,7 @@ function addUseOnEvent(jsxElement, key, value) {
|
|
|
1473
1515
|
propValue.push(...value), props[key] = propValue;
|
|
1474
1516
|
}
|
|
1475
1517
|
|
|
1476
|
-
function
|
|
1518
|
+
function findFirstElementNode(jsx) {
|
|
1477
1519
|
const queue = [ jsx ];
|
|
1478
1520
|
for (;queue.length; ) {
|
|
1479
1521
|
const jsx = queue.shift();
|
|
@@ -1482,34 +1524,42 @@ function findFirstStringJSX(jsx) {
|
|
|
1482
1524
|
return jsx;
|
|
1483
1525
|
}
|
|
1484
1526
|
queue.push(jsx.children);
|
|
1485
|
-
} else if (
|
|
1527
|
+
} else if (isArray(jsx)) {
|
|
1486
1528
|
queue.push(...jsx);
|
|
1487
1529
|
} else {
|
|
1488
1530
|
if (isPromise(jsx)) {
|
|
1489
|
-
return maybeThen(jsx, jsx =>
|
|
1531
|
+
return maybeThen(jsx, jsx => findFirstElementNode(jsx));
|
|
1490
1532
|
}
|
|
1491
1533
|
if (isSignal(jsx)) {
|
|
1492
|
-
return
|
|
1534
|
+
return findFirstElementNode(untrack(() => jsx.value));
|
|
1493
1535
|
}
|
|
1494
1536
|
}
|
|
1495
1537
|
}
|
|
1496
1538
|
return null;
|
|
1497
1539
|
}
|
|
1498
1540
|
|
|
1499
|
-
function
|
|
1541
|
+
function injectPlaceholderElement(jsx) {
|
|
1500
1542
|
if (isJSXNode(jsx)) {
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1543
|
+
const placeholder = createPlaceholderScriptNode();
|
|
1544
|
+
return jsx.type === Slot ? [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ] : (null == jsx.children ? jsx.children = placeholder : isArray(jsx.children) ? jsx.children.push(placeholder) : jsx.children = [ jsx.children, placeholder ],
|
|
1545
|
+
[ placeholder, jsx ]);
|
|
1546
|
+
}
|
|
1547
|
+
if (isPrimitive(jsx)) {
|
|
1548
|
+
const placeholder = createPlaceholderScriptNode();
|
|
1549
|
+
return [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
|
|
1507
1550
|
}
|
|
1508
|
-
if (
|
|
1509
|
-
const [
|
|
1510
|
-
return [
|
|
1551
|
+
if (isArray(jsx) && jsx.length > 0) {
|
|
1552
|
+
const [createdElement, _] = injectPlaceholderElement(jsx[0]);
|
|
1553
|
+
return [ createdElement, jsx ];
|
|
1511
1554
|
}
|
|
1512
|
-
return [ null,
|
|
1555
|
+
return [ null, jsx ];
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
function createPlaceholderScriptNode() {
|
|
1559
|
+
return new JSXNodeImpl("script", {}, {
|
|
1560
|
+
type: "placeholder",
|
|
1561
|
+
hidden: ""
|
|
1562
|
+
}, null, 3);
|
|
1513
1563
|
}
|
|
1514
1564
|
|
|
1515
1565
|
const applyInlineComponent = (ssr, componentHost, inlineComponentFunction, jsx) => {
|
|
@@ -1999,31 +2049,6 @@ class PropsProxyHandler {
|
|
|
1999
2049
|
|
|
2000
2050
|
const directGetPropsProxyProp = (jsx, prop) => jsx.constProps && prop in jsx.constProps ? jsx.constProps[prop] : jsx.varProps[prop];
|
|
2001
2051
|
|
|
2002
|
-
const mapApp_findIndx = (array, key, start) => {
|
|
2003
|
-
assertTrue(start % 2 == 0, "Expecting even number.");
|
|
2004
|
-
let bottom = start >> 1;
|
|
2005
|
-
let top = array.length - 2 >> 1;
|
|
2006
|
-
for (;bottom <= top; ) {
|
|
2007
|
-
const mid = bottom + (top - bottom >> 1);
|
|
2008
|
-
const midKey = array[mid << 1];
|
|
2009
|
-
if (midKey === key) {
|
|
2010
|
-
return mid << 1;
|
|
2011
|
-
}
|
|
2012
|
-
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
2013
|
-
}
|
|
2014
|
-
return ~(bottom << 1);
|
|
2015
|
-
};
|
|
2016
|
-
|
|
2017
|
-
const mapArray_set = (array, key, value, start) => {
|
|
2018
|
-
const indx = mapApp_findIndx(array, key, start);
|
|
2019
|
-
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(-1 ^ indx, 0, key, value);
|
|
2020
|
-
};
|
|
2021
|
-
|
|
2022
|
-
const mapArray_get = (array, key, start) => {
|
|
2023
|
-
const indx = mapApp_findIndx(array, key, start);
|
|
2024
|
-
return indx >= 0 ? array[indx + 1] : null;
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
2052
|
const isForeignObjectElement = elementName => isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
|
|
2028
2053
|
|
|
2029
2054
|
const isSvgElement = elementName => "svg" === elementName || isForeignObjectElement(elementName);
|
|
@@ -2169,6 +2194,27 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
|
|
|
2169
2194
|
};
|
|
2170
2195
|
}
|
|
2171
2196
|
|
|
2197
|
+
function getAttributeNamespace(attributeName) {
|
|
2198
|
+
switch (attributeName) {
|
|
2199
|
+
case "xlink:href":
|
|
2200
|
+
case "xlink:actuate":
|
|
2201
|
+
case "xlink:arcrole":
|
|
2202
|
+
case "xlink:role":
|
|
2203
|
+
case "xlink:show":
|
|
2204
|
+
case "xlink:title":
|
|
2205
|
+
case "xlink:type":
|
|
2206
|
+
return XLINK_NS;
|
|
2207
|
+
|
|
2208
|
+
case "xml:base":
|
|
2209
|
+
case "xml:lang":
|
|
2210
|
+
case "xml:space":
|
|
2211
|
+
return XML_NS;
|
|
2212
|
+
|
|
2213
|
+
default:
|
|
2214
|
+
return null;
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2172
2218
|
function escapeHTML(html) {
|
|
2173
2219
|
let escapedHTML = "";
|
|
2174
2220
|
const length = html.length;
|
|
@@ -2392,7 +2438,16 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2392
2438
|
}
|
|
2393
2439
|
if (key !== dangerouslySetInnerHTML) {
|
|
2394
2440
|
if ("textarea" !== elementName || "value" !== key) {
|
|
2395
|
-
value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value
|
|
2441
|
+
if (value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value) {
|
|
2442
|
+
if (64 & vNewNode[0]) {
|
|
2443
|
+
const namespace = getAttributeNamespace(key);
|
|
2444
|
+
if (namespace) {
|
|
2445
|
+
element.setAttributeNS(namespace, key, String(value));
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
element.setAttribute(key, String(value));
|
|
2450
|
+
}
|
|
2396
2451
|
} else {
|
|
2397
2452
|
if (value && "string" != typeof value) {
|
|
2398
2453
|
if (isDev) {
|
|
@@ -5111,7 +5166,7 @@ const allocate = (container, typeId, value) => {
|
|
|
5111
5166
|
case 11:
|
|
5112
5167
|
const vNode = retrieveVNodeOrDocument(container, value);
|
|
5113
5168
|
if (vnode_isVNode(vNode)) {
|
|
5114
|
-
return vnode_getNode(vNode);
|
|
5169
|
+
return ensureMaterialized(vNode), vnode_getNode(vNode);
|
|
5115
5170
|
}
|
|
5116
5171
|
throw qError(17, [ typeof vNode ]);
|
|
5117
5172
|
|
|
@@ -6540,4 +6595,4 @@ const PREFETCH_CODE = /*#__PURE__*/ (c => {
|
|
|
6540
6595
|
|
|
6541
6596
|
const PrefetchGraph = () => null;
|
|
6542
6597
|
|
|
6543
|
-
export { $, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _UNINITIALIZED, _VAR_PROPS, _deserialize, dumpState as _dumpState, _fnSignal, _getContextContainer, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, _regSymbol, _restProps, queueQRL as _run, _serializationWeakRef, _serialize, scheduleTask as _task,
|
|
6598
|
+
export { $, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _UNINITIALIZED, _VAR_PROPS, _deserialize, dumpState as _dumpState, _fnSignal, _getContextContainer, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, 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, _regSymbol, _resolveContextWithoutSequentialScope, _restProps, queueQRL as _run, _serializationWeakRef, _serialize, scheduleTask as _task, verifySerializable as _verifySerializable, vnode_ensureElementInflated as _vnode_ensureElementInflated, vnode_getAttr as _vnode_getAttr, vnode_getAttrKeys as _vnode_getAttrKeys, vnode_getFirstChild as _vnode_getFirstChild, vnode_getNextSibling as _vnode_getNextSibling, vnode_getPropStartIndex as _vnode_getPropStartIndex, vnode_getProps as _vnode_getProps, vnode_isMaterialized as _vnode_isMaterialized, vnode_isTextVNode as _vnode_isTextVNode, vnode_isVirtualVNode as _vnode_isVirtualVNode, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _wrapProp, _wrapSignal, component$, componentQrl, createAsyncComputed$, createAsyncComputedSignal as createAsyncComputedQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsyncComputed$, useAsyncComputedQrl, 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 };
|