Skip to content

Commit

Permalink
e37930c Version Packages
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 17, 2024
1 parent 0906088 commit 0c47503
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 87 deletions.
126 changes: 84 additions & 42 deletions lib/index.qwik.cjs
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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];
Expand All @@ -4061,25 +4080,38 @@ 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);
let obj = objs[idx];
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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 0c47503

Please sign in to comment.