From 0c4750340b6a2700ecb80878d8c6bbedc8777525 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Sep 2024 13:36:08 +0000 Subject: [PATCH] e37930c Version Packages https://github.com/QwikDev/qwik/commit/6ed6a4dafd9617b8014b810f9dcea77dbfc2d2a8 --- lib/index.qwik.cjs | 126 +++++++++++++++++++++++++++++--------------- lib/index.qwik.mjs | 128 ++++++++++++++++++++++++++++++--------------- package.json | 4 +- 3 files changed, 171 insertions(+), 87 deletions(-) diff --git a/lib/index.qwik.cjs b/lib/index.qwik.cjs index d51566e..ee082d7 100644 --- a/lib/index.qwik.cjs +++ b/lib/index.qwik.cjs @@ -1,5 +1,6 @@ "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const jsxRuntime = require("@builder.io/qwik/jsx-runtime"); const qwik = require("@builder.io/qwik"); var util; (function(util2) { @@ -3760,17 +3761,14 @@ const InsightsPayload = z.object({ InsightSymbol._type; InsightsPayload._type; InsightsError._type; -const Insights = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => { - return /* @__PURE__ */ qwik._jsxQ("script", { - dangerouslySetInnerHTML: `(${symbolTracker.toString()})(window, document, location, navigator, ${JSON.stringify(props.publicApiKey)}, - ${JSON.stringify(props.postUrl || "https://qwik-insights.builder.io/api/v1/${publicApiKey}/post/")} +const Insights = qwik.component$(({ publicApiKey, postUrl }) => { + return /* @__PURE__ */ jsxRuntime.jsx("script", { + "data-insights": publicApiKey, + dangerouslySetInnerHTML: `(${symbolTracker.toString()})(window, document, location, navigator, ${JSON.stringify(publicApiKey)}, + ${JSON.stringify(postUrl || "https://qwik-insights.builder.io/api/v1/${publicApiKey}/post/")} )` - }, { - "data-insights": qwik._fnSignal((p0) => p0.publicApiKey, [ - props - ], "p0.publicApiKey") - }, null, 3, "6Q_0"); -}, "Insights_component_0GjlblR0ECA")); + }); +}); function symbolTracker(window, document, location, navigator, publicApiKey, postUrl) { const qVersion = document.querySelector("[q\\:version]")?.getAttribute("q:version") || "unknown"; const manifestHash = document.querySelector("[q\\:manifest-hash]")?.getAttribute("q:manifest-hash") || "dev"; @@ -3788,7 +3786,9 @@ function symbolTracker(window, document, location, navigator, publicApiKey, post if (qRouteEl) { const observer = new MutationObserver((mutations) => { const mutation = mutations.find((m) => m.attributeName === "q:route"); - if (mutation) qRouteChangeTime = performance.now(); + if (mutation) { + qRouteChangeTime = performance.now(); + } }); observer.observe(qRouteEl, { attributes: true @@ -3861,20 +3861,30 @@ const untypedAppUrl = function appUrl(route, params, paramsPrefix = "") { const value = params ? params[paramsPrefix + key] || params[key] : ""; path[i] = isSpread ? value : encodeURIComponent(value); } - if (segment.startsWith("(") && segment.endsWith(")")) path.splice(i, 1); + if (segment.startsWith("(") && segment.endsWith(")")) { + path.splice(i, 1); + } } let url = path.join("/"); let baseURL = "/"; if (baseURL) { - if (!baseURL.endsWith("/")) baseURL += "/"; - while (url.startsWith("/")) url = url.substring(1); + if (!baseURL.endsWith("/")) { + baseURL += "/"; + } + while (url.startsWith("/")) { + url = url.substring(1); + } url = baseURL + url; } return url; }; function omitProps(obj, keys) { const omittedObj = {}; - for (const key in obj) if (!key.startsWith("param:") && !keys.includes(key)) omittedObj[key] = obj[key]; + for (const key in obj) { + if (!key.startsWith("param:") && !keys.includes(key)) { + omittedObj[key] = obj[key]; + } + } return omittedObj; } function runQwikJsonDebug(window, document, debug) { @@ -3885,8 +3895,11 @@ function runQwikJsonDebug(window, document, debug) { window.qwikJson = debugData; console.log(debugData); }; - if (document.querySelector('script[type="qwik/json"]')) parseQwikJSON(); - else document.addEventListener("DOMContentLoaded", parseQwikJSON); + if (document.querySelector('script[type="qwik/json"]')) { + parseQwikJSON(); + } else { + document.addEventListener("DOMContentLoaded", parseQwikJSON); + } } function qwikJsonDebug(document, qwikJson, derivedFns) { class Base { @@ -4031,7 +4044,9 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { attrs.set(key, value); }); const sstyle = attrs.get("q:sstyle"); - if (sstyle) ctx.scopeIds = sstyle.split("|"); + if (sstyle) { + ctx.scopeIds = sstyle.split("|"); + } } if (rawCtx.h) { const [qrl, props] = rawCtx.h.split(" ").map((h) => h ? getObject(h, ctx) : null); @@ -4045,8 +4060,12 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { contexts2.set(key, getObject(value, ctx)); } } - if (rawCtx.s) ctx.seq = rawCtx.s.split(" ").map((s) => getObject(parseNumber(s), ctx)); - if (rawCtx.w) ctx.tasks = rawCtx.w.split(" ").map((s) => getObject(parseNumber(s), ctx)); + if (rawCtx.s) { + ctx.seq = rawCtx.s.split(" ").map((s) => getObject(parseNumber(s), ctx)); + } + if (rawCtx.w) { + ctx.tasks = rawCtx.w.split(" ").map((s) => getObject(parseNumber(s), ctx)); + } } function getRef(idx) { const rawRefs = qwikJson.refs[idx]; @@ -4061,12 +4080,18 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { if (typeof idx == "string") { if (idx.startsWith("#")) { const node = nodeMap.get(idx.substring(1)); - if (!node.__backRefs) node.__backRefs = []; - if (node.__backRefs.indexOf(parent) === -1) node.__backRefs.push(parent); + if (!node.__backRefs) { + node.__backRefs = []; + } + if (node.__backRefs.indexOf(parent) === -1) { + node.__backRefs.push(parent); + } return node; } const num = parseNumber(idx); - if (isNaN(num)) throw new Error("Invalid index: " + idx); + if (isNaN(num)) { + throw new Error("Invalid index: " + idx); + } idx = num; } while (objs.length < idx) objs.push(null); @@ -4074,12 +4099,19 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { if (!obj) { const rawValue = qwikJson.objs[idx]; let value = rawValue; - if (typeof value === "number") obj = new number_(idx, value); - else if (typeof value === "boolean") obj = new boolean_(idx, value); - else if (typeof value === "undefined") obj = new undefined_(idx); - else if (typeof value === "object") { + if (typeof value === "number") { + obj = new number_(idx, value); + } else if (typeof value === "boolean") { + obj = new boolean_(idx, value); + } else if (typeof value === "undefined") { + obj = new undefined_(idx); + } else if (typeof value === "object") { obj = Array.isArray(value) ? new Array_(idx) : new Object_(idx); - for (const key in value) if (Object.prototype.hasOwnProperty.call(value, key)) obj[key] = getObject(parseNumber(value[key]), obj); + for (const key in value) { + if (Object.prototype.hasOwnProperty.call(value, key)) { + obj[key] = getObject(parseNumber(value[key]), obj); + } + } } else if (typeof rawValue === "string") { const data = rawValue.substring(1); switch (rawValue.charCodeAt(0)) { @@ -4093,12 +4125,12 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { case 3: const [flags, index, objId] = data.split(" "); const flagString = [ - parseNumber(flags) & 1 ? "Visible" : "", - parseNumber(flags) & 2 ? "Task" : "", - parseNumber(flags) & 4 ? "Resource" : "", - parseNumber(flags) & 8 ? "Computed" : "", - parseNumber(flags) & 16 ? "Dirty" : "", - parseNumber(flags) & 32 ? "Cleanup" : "" + parseNumber(flags) & 1 << 0 ? "Visible" : "", + parseNumber(flags) & 1 << 1 ? "Task" : "", + parseNumber(flags) & 1 << 2 ? "Resource" : "", + parseNumber(flags) & 1 << 3 ? "Computed" : "", + parseNumber(flags) & 1 << 4 ? "Dirty" : "", + parseNumber(flags) & 1 << 5 ? "Cleanup" : "" ].filter(Boolean).join("|"); obj = new Task(idx, flagString, parseNumber(index), getObject(objId, parent)); break; @@ -4138,10 +4170,14 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { default: obj = new string_(idx, rawValue); } - } else throw new Error("Unexpected type: " + JSON.stringify(rawValue)); + } else { + throw new Error("Unexpected type: " + JSON.stringify(rawValue)); + } objs[idx] = obj; } - if (parent && obj && obj.__backRefs.indexOf(parent) === -1) obj.__backRefs.push(parent); + if (parent && obj && obj.__backRefs.indexOf(parent) === -1) { + obj.__backRefs.push(parent); + } return obj; } function getNodeMap() { @@ -4154,19 +4190,25 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { return map; } function getId(node) { - if (isElement(node)) return node.getAttribute("q:id"); - else if (isComment(node)) { + if (isElement(node)) { + return node.getAttribute("q:id"); + } else if (isComment(node)) { const text = node.nodeValue || ""; - if (text.startsWith("t=")) return text.substring(2); - else if (text.startsWith("qv ")) { + if (text.startsWith("t=")) { + return text.substring(2); + } else if (text.startsWith("qv ")) { const parts = text.split(" "); for (let i = 0; i < parts.length; i++) { const part = parts[i]; - if (part.startsWith("q:id=")) return part.substring(5); + if (part.startsWith("q:id=")) { + return part.substring(5); + } } } return null; - } else throw new Error("Unexpected node type: " + node.nodeType); + } else { + throw new Error("Unexpected node type: " + node.nodeType); + } } function isElement(node) { return node && typeof node == "object" && node.nodeType === Node.ELEMENT_NODE; diff --git a/lib/index.qwik.mjs b/lib/index.qwik.mjs index 096e84b..4da1004 100644 --- a/lib/index.qwik.mjs +++ b/lib/index.qwik.mjs @@ -1,4 +1,5 @@ -import { componentQrl, inlinedQrl, _jsxQ, _fnSignal } from "@builder.io/qwik"; +import { jsx } from "@builder.io/qwik/jsx-runtime"; +import { component$ } from "@builder.io/qwik"; var util; (function(util2) { util2.assertEqual = (val) => val; @@ -3758,17 +3759,14 @@ const InsightsPayload = z.object({ InsightSymbol._type; InsightsPayload._type; InsightsError._type; -const Insights = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => { - return /* @__PURE__ */ _jsxQ("script", { - dangerouslySetInnerHTML: `(${symbolTracker.toString()})(window, document, location, navigator, ${JSON.stringify(props.publicApiKey)}, - ${JSON.stringify(props.postUrl || "https://qwik-insights.builder.io/api/v1/${publicApiKey}/post/")} +const Insights = component$(({ publicApiKey, postUrl }) => { + return /* @__PURE__ */ jsx("script", { + "data-insights": publicApiKey, + dangerouslySetInnerHTML: `(${symbolTracker.toString()})(window, document, location, navigator, ${JSON.stringify(publicApiKey)}, + ${JSON.stringify(postUrl || "https://qwik-insights.builder.io/api/v1/${publicApiKey}/post/")} )` - }, { - "data-insights": _fnSignal((p0) => p0.publicApiKey, [ - props - ], "p0.publicApiKey") - }, null, 3, "6Q_0"); -}, "Insights_component_0GjlblR0ECA")); + }); +}); function symbolTracker(window, document, location, navigator, publicApiKey, postUrl) { const qVersion = document.querySelector("[q\\:version]")?.getAttribute("q:version") || "unknown"; const manifestHash = document.querySelector("[q\\:manifest-hash]")?.getAttribute("q:manifest-hash") || "dev"; @@ -3786,7 +3784,9 @@ function symbolTracker(window, document, location, navigator, publicApiKey, post if (qRouteEl) { const observer = new MutationObserver((mutations) => { const mutation = mutations.find((m) => m.attributeName === "q:route"); - if (mutation) qRouteChangeTime = performance.now(); + if (mutation) { + qRouteChangeTime = performance.now(); + } }); observer.observe(qRouteEl, { attributes: true @@ -3859,20 +3859,30 @@ const untypedAppUrl = function appUrl(route, params, paramsPrefix = "") { const value = params ? params[paramsPrefix + key] || params[key] : ""; path[i] = isSpread ? value : encodeURIComponent(value); } - if (segment.startsWith("(") && segment.endsWith(")")) path.splice(i, 1); + if (segment.startsWith("(") && segment.endsWith(")")) { + path.splice(i, 1); + } } let url = path.join("/"); let baseURL = "/"; if (baseURL) { - if (!baseURL.endsWith("/")) baseURL += "/"; - while (url.startsWith("/")) url = url.substring(1); + if (!baseURL.endsWith("/")) { + baseURL += "/"; + } + while (url.startsWith("/")) { + url = url.substring(1); + } url = baseURL + url; } return url; }; function omitProps(obj, keys) { const omittedObj = {}; - for (const key in obj) if (!key.startsWith("param:") && !keys.includes(key)) omittedObj[key] = obj[key]; + for (const key in obj) { + if (!key.startsWith("param:") && !keys.includes(key)) { + omittedObj[key] = obj[key]; + } + } return omittedObj; } function runQwikJsonDebug(window, document, debug) { @@ -3883,8 +3893,11 @@ function runQwikJsonDebug(window, document, debug) { window.qwikJson = debugData; console.log(debugData); }; - if (document.querySelector('script[type="qwik/json"]')) parseQwikJSON(); - else document.addEventListener("DOMContentLoaded", parseQwikJSON); + if (document.querySelector('script[type="qwik/json"]')) { + parseQwikJSON(); + } else { + document.addEventListener("DOMContentLoaded", parseQwikJSON); + } } function qwikJsonDebug(document, qwikJson, derivedFns) { class Base { @@ -4029,7 +4042,9 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { attrs.set(key, value); }); const sstyle = attrs.get("q:sstyle"); - if (sstyle) ctx.scopeIds = sstyle.split("|"); + if (sstyle) { + ctx.scopeIds = sstyle.split("|"); + } } if (rawCtx.h) { const [qrl, props] = rawCtx.h.split(" ").map((h) => h ? getObject(h, ctx) : null); @@ -4043,8 +4058,12 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { contexts2.set(key, getObject(value, ctx)); } } - if (rawCtx.s) ctx.seq = rawCtx.s.split(" ").map((s) => getObject(parseNumber(s), ctx)); - if (rawCtx.w) ctx.tasks = rawCtx.w.split(" ").map((s) => getObject(parseNumber(s), ctx)); + if (rawCtx.s) { + ctx.seq = rawCtx.s.split(" ").map((s) => getObject(parseNumber(s), ctx)); + } + if (rawCtx.w) { + ctx.tasks = rawCtx.w.split(" ").map((s) => getObject(parseNumber(s), ctx)); + } } function getRef(idx) { const rawRefs = qwikJson.refs[idx]; @@ -4059,12 +4078,18 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { if (typeof idx == "string") { if (idx.startsWith("#")) { const node = nodeMap.get(idx.substring(1)); - if (!node.__backRefs) node.__backRefs = []; - if (node.__backRefs.indexOf(parent) === -1) node.__backRefs.push(parent); + if (!node.__backRefs) { + node.__backRefs = []; + } + if (node.__backRefs.indexOf(parent) === -1) { + node.__backRefs.push(parent); + } return node; } const num = parseNumber(idx); - if (isNaN(num)) throw new Error("Invalid index: " + idx); + if (isNaN(num)) { + throw new Error("Invalid index: " + idx); + } idx = num; } while (objs.length < idx) objs.push(null); @@ -4072,12 +4097,19 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { if (!obj) { const rawValue = qwikJson.objs[idx]; let value = rawValue; - if (typeof value === "number") obj = new number_(idx, value); - else if (typeof value === "boolean") obj = new boolean_(idx, value); - else if (typeof value === "undefined") obj = new undefined_(idx); - else if (typeof value === "object") { + if (typeof value === "number") { + obj = new number_(idx, value); + } else if (typeof value === "boolean") { + obj = new boolean_(idx, value); + } else if (typeof value === "undefined") { + obj = new undefined_(idx); + } else if (typeof value === "object") { obj = Array.isArray(value) ? new Array_(idx) : new Object_(idx); - for (const key in value) if (Object.prototype.hasOwnProperty.call(value, key)) obj[key] = getObject(parseNumber(value[key]), obj); + for (const key in value) { + if (Object.prototype.hasOwnProperty.call(value, key)) { + obj[key] = getObject(parseNumber(value[key]), obj); + } + } } else if (typeof rawValue === "string") { const data = rawValue.substring(1); switch (rawValue.charCodeAt(0)) { @@ -4091,12 +4123,12 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { case 3: const [flags, index, objId] = data.split(" "); const flagString = [ - parseNumber(flags) & 1 ? "Visible" : "", - parseNumber(flags) & 2 ? "Task" : "", - parseNumber(flags) & 4 ? "Resource" : "", - parseNumber(flags) & 8 ? "Computed" : "", - parseNumber(flags) & 16 ? "Dirty" : "", - parseNumber(flags) & 32 ? "Cleanup" : "" + parseNumber(flags) & 1 << 0 ? "Visible" : "", + parseNumber(flags) & 1 << 1 ? "Task" : "", + parseNumber(flags) & 1 << 2 ? "Resource" : "", + parseNumber(flags) & 1 << 3 ? "Computed" : "", + parseNumber(flags) & 1 << 4 ? "Dirty" : "", + parseNumber(flags) & 1 << 5 ? "Cleanup" : "" ].filter(Boolean).join("|"); obj = new Task(idx, flagString, parseNumber(index), getObject(objId, parent)); break; @@ -4136,10 +4168,14 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { default: obj = new string_(idx, rawValue); } - } else throw new Error("Unexpected type: " + JSON.stringify(rawValue)); + } else { + throw new Error("Unexpected type: " + JSON.stringify(rawValue)); + } objs[idx] = obj; } - if (parent && obj && obj.__backRefs.indexOf(parent) === -1) obj.__backRefs.push(parent); + if (parent && obj && obj.__backRefs.indexOf(parent) === -1) { + obj.__backRefs.push(parent); + } return obj; } function getNodeMap() { @@ -4152,19 +4188,25 @@ function qwikJsonDebug(document, qwikJson, derivedFns) { return map; } function getId(node) { - if (isElement(node)) return node.getAttribute("q:id"); - else if (isComment(node)) { + if (isElement(node)) { + return node.getAttribute("q:id"); + } else if (isComment(node)) { const text = node.nodeValue || ""; - if (text.startsWith("t=")) return text.substring(2); - else if (text.startsWith("qv ")) { + if (text.startsWith("t=")) { + return text.substring(2); + } else if (text.startsWith("qv ")) { const parts = text.split(" "); for (let i = 0; i < parts.length; i++) { const part = parts[i]; - if (part.startsWith("q:id=")) return part.substring(5); + if (part.startsWith("q:id=")) { + return part.substring(5); + } } } return null; - } else throw new Error("Unexpected node type: " + node.nodeType); + } else { + throw new Error("Unexpected node type: " + node.nodeType); + } } function isElement(node) { return node && typeof node == "object" && node.nodeType === Node.ELEMENT_NODE; diff --git a/package.json b/package.json index 10ca696..ee8e910 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,13 @@ "description": "Qwik Labs - Where you can try the latest Qwik ideas.", "version": "0.0.1", "devDependencies": { - "@builder.io/qwik": "1.8.0", + "@builder.io/qwik": "1.9.0", "@types/eslint": "8.56.10", "@types/node": "20.14.11", "@typescript-eslint/eslint-plugin": "7.16.1", "@typescript-eslint/parser": "7.16.1", "eslint": "^8.57.0", - "eslint-plugin-qwik": "1.8.0", + "eslint-plugin-qwik": "1.9.0", "np": "10.0.1", "prettier": "3.3.3", "typescript": "5.4.5",