Skip to content

Commit

Permalink
b7c31bd fix: fix up PrefetchServiceWorker with multiple Qwik containe…
Browse files Browse the repository at this point in the history
…rs (#6468)

QwikDev/qwik@b7c31bd
  • Loading branch information
gioboa committed Jun 12, 2024
1 parent 228f3a1 commit 7085eb3
Show file tree
Hide file tree
Showing 29 changed files with 58 additions and 43 deletions.
Binary file modified bindings/qwik.win32-x64-msvc.node
Binary file not shown.
2 changes: 1 addition & 1 deletion build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/build",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "index.mjs",
"types": "index.d.ts",
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions cli.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik/cli 1.5.6-dev20240612104725
* @builder.io/qwik/cli 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -4889,7 +4889,7 @@ async function printHelp(app) {
await runCommand2(Object.assign(app, { task: args[0], args }));
}
function printVersion() {
console.log("1.5.6-dev20240612104725");
console.log("1.5.6-dev20240612120028");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions core.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik 1.5.6-dev20240612104725
* @builder.io/qwik 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -1555,7 +1555,7 @@
*
* @public
*/
const version = "1.5.6-dev20240612104725";
const version = "1.5.6-dev20240612120028";

const hashCode = (text, hash = 0) => {
for (let i = 0; i < text.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3830,7 +3830,7 @@ export declare type ValueOrPromise<T> = T | Promise<T>;
export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;

/**
* 1.5.6-dev20240612104725
* 1.5.6-dev20240612120028
*
* @public
*/
Expand Down
2 changes: 1 addition & 1 deletion core.min.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik 1.5.6-dev20240612104725
* @builder.io/qwik 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -1551,7 +1551,7 @@ const dangerouslySetInnerHTML = 'dangerouslySetInnerHTML';
*
* @public
*/
const version = "1.5.6-dev20240612104725";
const version = "1.5.6-dev20240612120028";

const hashCode = (text, hash = 0) => {
for (let i = 0; i < text.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions core.prod.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik 1.5.6-dev20240612104725
* @builder.io/qwik 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -539,7 +539,7 @@
}
const shouldWrapFunctional = (res, node) => !!node.key && (!isJSXNode(res) || !isFunction(res.type) && res.key != node.key);
const dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
const version = "1.5.6-dev20240612104725";
const version = "1.5.6-dev20240612120028";
const hashCode = (text, hash = 0) => {
for (let i = 0; i < text.length; i++) {
hash = (hash << 5) - hash + text.charCodeAt(i), hash |= 0;
Expand Down
4 changes: 2 additions & 2 deletions core.prod.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik 1.5.6-dev20240612104725
* @builder.io/qwik 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -823,7 +823,7 @@ const static_subtree = 2;

const dangerouslySetInnerHTML = "dangerouslySetInnerHTML";

const version = "1.5.6-dev20240612104725";
const version = "1.5.6-dev20240612120028";

const hashCode = (text, hash = 0) => {
for (let i = 0; i < text.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/core",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "../core.mjs",
"module": "../core.mjs",
"types": "../core.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion jsx-dev-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/jsx-dev-runtime",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "../core.mjs",
"module": "../core.mjs",
"types": "../jsx-runtime.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion jsx-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/jsx-runtime",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "../core.mjs",
"module": "../core.mjs",
"types": "../jsx-runtime.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/loader",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "index.mjs",
"types": "index.d.ts",
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions optimizer.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik/optimizer 1.5.6-dev20240612104725
* @builder.io/qwik/optimizer 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -1256,7 +1256,7 @@ globalThis.qwikOptimizer = function(module) {
}
};
var versions = {
qwik: "1.5.6-dev20240612104725"
qwik: "1.5.6-dev20240612120028"
};
async function getSystem() {
const sysEnv = getEnv();
Expand Down
4 changes: 2 additions & 2 deletions optimizer.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik/optimizer 1.5.6-dev20240612104725
* @builder.io/qwik/optimizer 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -1282,7 +1282,7 @@ var QWIK_BINDING_MAP = {
};

var versions = {
qwik: "1.5.6-dev20240612104725"
qwik: "1.5.6-dev20240612120028"
};

async function getSystem() {
Expand Down
2 changes: 1 addition & 1 deletion optimizer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/optimizer",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "../optimizer.mjs",
"module": "../optimizer.mjs",
"types": "../optimizer.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"license": "MIT",
"main": "./core.mjs",
Expand Down
4 changes: 2 additions & 2 deletions prefetch/index.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions prefetch/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion prefetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/prefetch",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "index.mjs",
"types": "index.d.ts",
"private": true,
Expand Down
3 changes: 2 additions & 1 deletion qwik-prefetch.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
}(state, msg[1]) : "ping" === type ? log("ping") : "verbose" === type ? (state.$log$ = log)("mode: verbose") : console.error("UNKNOWN MESSAGE:", msg);
};
async function processBundleGraph(swState, base, graph, cleanup) {
const existingBaseIndex = swState.$bases$.findIndex((base2 => base2 == base2));
const existingBaseIndex = swState.$bases$.findIndex((b => b.$path$ === base));
-1 !== existingBaseIndex && swState.$bases$.splice(existingBaseIndex, 1);
swState.$log$("adding base:", base);
swState.$bases$.push({
Expand Down Expand Up @@ -143,6 +143,7 @@
if (!swState.$msgQueuePromise$ && swState.$msgQueue$.length) {
const top = swState.$msgQueue$.shift();
swState.$msgQueuePromise$ = processMessage(swState, top).then((() => {
swState.$msgQueuePromise$ = null;
drainMsgQueue(swState);
}));
}
Expand Down
2 changes: 1 addition & 1 deletion qwik-prefetch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions server.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik/server 1.5.6-dev20240612104725
* @builder.io/qwik/server 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -156,7 +156,7 @@ function getBuildBase(opts) {
return `${import_meta.env.BASE_URL}build/`;
}
var versions = {
qwik: "1.5.6-dev20240612104725",
qwik: "1.5.6-dev20240612120028",
qwikDom: "2.1.19"
};

Expand Down Expand Up @@ -260,8 +260,15 @@ function prefetchUrlsEventScript(prefetchResources) {
const data = {
bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
};
return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}))`;
return `(${PREFETCH_BUNDLES_CODE})(
document.currentScript.closest('[q\\\\:container]'),
window.qwikPrefetchSW||(window.qwikPrefetchSW=[]),
${JSON.stringify(data.bundles)}
);`;
}
var PREFETCH_BUNDLES_CODE = /* @__PURE__ */ ((qc, q, bundles) => {
q.push(["prefetch", qc.getAttribute("q:base"), ...bundles]);
}).toString();
function flattenPrefetchResources(prefetchResources) {
const urls = [];
const addPrefetchResource = (prefetchResources2) => {
Expand Down Expand Up @@ -338,7 +345,7 @@ function prefetchUrlsEvent(prefetchNodes, prefetchResources, nonce) {
prefetchNodes.push(
(0, import_qwik2.jsx)("script", {
"q:type": "prefetch-bundles",
dangerouslySetInnerHTML: prefetchUrlsEventScript(prefetchResources) + `;document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`,
dangerouslySetInnerHTML: prefetchUrlsEventScript(prefetchResources) + `document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`,
nonce
})
);
Expand Down
2 changes: 1 addition & 1 deletion server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export declare function getQwikLoaderScript(opts?: {

/**
* Provides the `qwik-prefetch-service-worker.js` file as a string. Useful for tooling to inline the
* qwikloader script into HTML.
* qwik-prefetch-service-worker script into HTML.
*
* @public
*/
Expand Down
15 changes: 11 additions & 4 deletions server.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik/server 1.5.6-dev20240612104725
* @builder.io/qwik/server 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down Expand Up @@ -111,7 +111,7 @@ function getBuildBase(opts) {
return `${import.meta.env.BASE_URL}build/`;
}
var versions = {
qwik: "1.5.6-dev20240612104725",
qwik: "1.5.6-dev20240612120028",
qwikDom: "2.1.19"
};

Expand Down Expand Up @@ -215,8 +215,15 @@ function prefetchUrlsEventScript(prefetchResources) {
const data = {
bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
};
return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}))`;
return `(${PREFETCH_BUNDLES_CODE})(
document.currentScript.closest('[q\\\\:container]'),
window.qwikPrefetchSW||(window.qwikPrefetchSW=[]),
${JSON.stringify(data.bundles)}
);`;
}
var PREFETCH_BUNDLES_CODE = /* @__PURE__ */ ((qc, q, bundles) => {
q.push(["prefetch", qc.getAttribute("q:base"), ...bundles]);
}).toString();
function flattenPrefetchResources(prefetchResources) {
const urls = [];
const addPrefetchResource = (prefetchResources2) => {
Expand Down Expand Up @@ -293,7 +300,7 @@ function prefetchUrlsEvent(prefetchNodes, prefetchResources, nonce) {
prefetchNodes.push(
jsx("script", {
"q:type": "prefetch-bundles",
dangerouslySetInnerHTML: prefetchUrlsEventScript(prefetchResources) + `;document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`,
dangerouslySetInnerHTML: prefetchUrlsEventScript(prefetchResources) + `document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`,
nonce
})
);
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/server",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "../server.mjs",
"module": "../server.mjs",
"types": "../server.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion testing/index.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik/testing 1.5.6-dev20240612104725
* @builder.io/qwik/testing 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion testing/index.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* @builder.io/qwik/testing 1.5.6-dev20240612104725
* @builder.io/qwik/testing 1.5.6-dev20240612120028
* Copyright Builder.io, Inc. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik/testing",
"version": "1.5.6-dev20240612104725",
"version": "1.5.6-dev20240612120028",
"main": "index.mjs",
"types": "index.d.ts",
"private": true,
Expand Down

0 comments on commit 7085eb3

Please sign in to comment.