Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #79 from nightwatchjs/main
Browse files Browse the repository at this point in the history
Merge `main` to `release/v1.0` branch.
  • Loading branch information
beatfactor authored Mar 11, 2024
2 parents 22cbadf + cf78cc8 commit 10b0de6
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 67 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"test": "postdoc test -- test/src -o tests_output --headless",
"start": "postdoc run",
"prebuild": "postdoc build",
"clone:docs": "rm -rf nightwatch-docs/ && git clone https://github.com/nightwatchjs/nightwatch-docs.git",
"clone:nightwatch": "rm -rf nightwatch/ && git clone https://github.com/nightwatchjs/nightwatch.git",
"build": "npm run partytown && postdoc build && node build/optimize.mjs",
"netlify": "npm run clone:docs && npm run clone:nightwatch && npm run build",
"partytown": "partytown copylib public/~partytown",
"eslint": "eslint src test --quiet"
},
Expand Down
31 changes: 15 additions & 16 deletions public/~partytown/debug/partytown-atomics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Partytown 0.8.0 - MIT builder.io */
/* Partytown 0.8.2 - MIT builder.io */
(window => {
const isPromise = v => "object" == typeof v && v && v.then;
const noop = () => {};
Expand Down Expand Up @@ -282,11 +282,12 @@
let win = winCtx.$window$;
let doc = win.document;
let scriptSelector = 'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])';
let blockingScriptSelector = scriptSelector + ":not([async]):not([defer])";
let scriptElm;
let $instanceId$;
let scriptData;
if (doc && doc.body) {
scriptElm = doc.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])');
scriptElm = doc.querySelector(blockingScriptSelector);
scriptElm || (scriptElm = doc.querySelector(scriptSelector));
if (scriptElm) {
scriptElm.dataset.ptid = $instanceId$ = getAndSetInstanceId(scriptElm, $winId$);
Expand Down Expand Up @@ -367,16 +368,14 @@
const pushState = history.pushState.bind(history);
const replaceState = history.replaceState.bind(history);
const onLocationChange = (type, state, newUrl, oldUrl) => () => {
setTimeout((() => {
worker.postMessage([ 13, {
$winId$: $winId$,
type: type,
state: state,
url: doc.baseURI,
newUrl: newUrl,
oldUrl: oldUrl
} ]);
}));
worker.postMessage([ 13, {
$winId$: $winId$,
type: type,
state: state,
url: doc.baseURI,
newUrl: newUrl,
oldUrl: oldUrl
} ]);
};
history.pushState = (state, _, newUrl) => {
pushState(state, _, newUrl);
Expand Down Expand Up @@ -433,8 +432,8 @@
})(docImpl, interfaceName))).filter((elm => elm)).map((elm => [ elm ]));
return readImplementations(elms, []);
};
const cstrs = new Set([ "Object" ]);
const readImplementations = (impls, interfaces) => {
const cstrs = new Set([ "Object" ]);
const cstrImpls = impls.filter((implData => implData[0])).map((implData => {
const impl = implData[0];
const interfaceType = implData[1];
Expand Down Expand Up @@ -476,7 +475,7 @@
(String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]);
} else if ("object" === memberType && null != value) {
cstrName = getConstructorName(value);
"Object" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
"Object" !== cstrName && "Function" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
} else {
"symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]));
}
Expand Down Expand Up @@ -557,14 +556,14 @@
};
})(((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))).then((onMessageHandler => {
if (onMessageHandler) {
worker = new Worker(libPath + "partytown-ww-atomics.js?v=0.8.0", {
worker = new Worker(libPath + "partytown-ww-atomics.js?v=0.8.2", {
name: "Partytown 🎉"
});
worker.onmessage = ev => {
const msg = ev.data;
12 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, msg);
};
logMain("Created Partytown web worker (0.8.0)");
logMain("Created Partytown web worker (0.8.2)");
worker.onerror = ev => console.error("Web Worker Error", ev);
mainWindow.addEventListener("pt1", (ev => registerWindow(worker, getAndSetInstanceId(ev.detail.frameElement), ev.detail)));
}
Expand Down
2 changes: 1 addition & 1 deletion public/~partytown/debug/partytown-media.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Partytown 0.8.0 - MIT builder.io */
/* Partytown 0.8.2 - MIT builder.io */
(self => {
const [getter, setter, callMethod, constructGlobal, definePrototypePropertyDescriptor, randomId, WinIdKey, InstanceIdKey, ApplyPathKey] = self.$bridgeToMedia$;
delete self.$bridgeToMedia$;
Expand Down
31 changes: 15 additions & 16 deletions public/~partytown/debug/partytown-sandbox-sw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Partytown 0.8.0 - MIT builder.io */
/* Partytown 0.8.2 - MIT builder.io */
(window => {
const isPromise = v => "object" == typeof v && v && v.then;
const noop = () => {};
Expand Down Expand Up @@ -282,11 +282,12 @@
let win = winCtx.$window$;
let doc = win.document;
let scriptSelector = 'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])';
let blockingScriptSelector = scriptSelector + ":not([async]):not([defer])";
let scriptElm;
let $instanceId$;
let scriptData;
if (doc && doc.body) {
scriptElm = doc.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])');
scriptElm = doc.querySelector(blockingScriptSelector);
scriptElm || (scriptElm = doc.querySelector(scriptSelector));
if (scriptElm) {
scriptElm.dataset.ptid = $instanceId$ = getAndSetInstanceId(scriptElm, $winId$);
Expand Down Expand Up @@ -367,16 +368,14 @@
const pushState = history.pushState.bind(history);
const replaceState = history.replaceState.bind(history);
const onLocationChange = (type, state, newUrl, oldUrl) => () => {
setTimeout((() => {
worker.postMessage([ 13, {
$winId$: $winId$,
type: type,
state: state,
url: doc.baseURI,
newUrl: newUrl,
oldUrl: oldUrl
} ]);
}));
worker.postMessage([ 13, {
$winId$: $winId$,
type: type,
state: state,
url: doc.baseURI,
newUrl: newUrl,
oldUrl: oldUrl
} ]);
};
history.pushState = (state, _, newUrl) => {
pushState(state, _, newUrl);
Expand Down Expand Up @@ -466,8 +465,8 @@
})(docImpl, interfaceName))).filter((elm => elm)).map((elm => [ elm ]));
return readImplementations(elms, []);
};
const cstrs = new Set([ "Object" ]);
const readImplementations = (impls, interfaces) => {
const cstrs = new Set([ "Object" ]);
const cstrImpls = impls.filter((implData => implData[0])).map((implData => {
const impl = implData[0];
const interfaceType = implData[1];
Expand Down Expand Up @@ -509,7 +508,7 @@
(String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]);
} else if ("object" === memberType && null != value) {
cstrName = getConstructorName(value);
"Object" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
"Object" !== cstrName && "Function" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
} else {
"symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]));
}
Expand Down Expand Up @@ -544,14 +543,14 @@
}));
})(((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))).then((onMessageHandler => {
if (onMessageHandler) {
worker = new Worker(libPath + "partytown-ww-sw.js?v=0.8.0", {
worker = new Worker(libPath + "partytown-ww-sw.js?v=0.8.2", {
name: "Partytown 🎉"
});
worker.onmessage = ev => {
const msg = ev.data;
12 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, msg);
};
logMain("Created Partytown web worker (0.8.0)");
logMain("Created Partytown web worker (0.8.2)");
worker.onerror = ev => console.error("Web Worker Error", ev);
mainWindow.addEventListener("pt1", (ev => registerWindow(worker, getAndSetInstanceId(ev.detail.frameElement), ev.detail)));
}
Expand Down
4 changes: 2 additions & 2 deletions public/~partytown/debug/partytown-sw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Partytown 0.8.0 - MIT builder.io */
/* Partytown 0.8.2 - MIT builder.io */
const resolves = new Map;

const swMessageError = (accessReq, $error$) => ({
Expand Down Expand Up @@ -52,7 +52,7 @@ self.onfetch = ev => {
const url = new URL(req.url);
const pathname = url.pathname;
if (pathname.endsWith("sw.html")) {
ev.respondWith(response('<!DOCTYPE html><html><head><meta charset="utf-8"><script src="./partytown-sandbox-sw.js?v=0.8.0"><\/script></head></html>'));
ev.respondWith(response('<!DOCTYPE html><html><head><meta charset="utf-8"><script src="./partytown-sandbox-sw.js?v=0.8.2"><\/script></head></html>'));
} else {
pathname.endsWith("proxytown") && ev.respondWith(httpRequestFromWebWorker(req));
}
Expand Down
36 changes: 26 additions & 10 deletions public/~partytown/debug/partytown-ww-atomics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Partytown 0.8.0 - MIT builder.io */
/* Partytown 0.8.2 - MIT builder.io */
(self => {
const WinIdKey = Symbol();
const InstanceIdKey = Symbol();
Expand Down Expand Up @@ -706,7 +706,11 @@
};
const run = (env, scriptContent, scriptUrl) => {
env.$runWindowLoadEvent$ = 1;
scriptContent = `with(this){${scriptContent.replace(/\bthis\b/g, ((match, offset, originalStr) => offset > 0 && "$" !== originalStr[offset - 1] ? "(thi$(this)?window:this)" : match)).replace(/\/\/# so/g, "//Xso")}\n;function thi$(t){return t===this}};${(webWorkerCtx.$config$.globalFns || []).filter((globalFnName => /[a-zA-Z_$][0-9a-zA-Z_$]*/.test(globalFnName))).map((g => `(typeof ${g}=='function'&&(this.${g}=${g}))`)).join(";")};` + (scriptUrl ? "\n//# sourceURL=" + scriptUrl : "");
let sourceWithReplacedThis = ((scriptContent, newThis) => scriptContent.replace(/([a-zA-Z0-9_$\.\'\"\`])?(\.\.\.)?this(?![a-zA-Z0-9_$:])/g, ((match, p1, p2) => {
const prefix = (p1 || "") + (p2 || "");
return null != p1 ? prefix + "this" : prefix + newThis;
})))(scriptContent, "(thi$(this)?window:this)");
scriptContent = `with(this){${sourceWithReplacedThis.replace(/\/\/# so/g, "//Xso")}\n;function thi$(t){return t===this}};${(webWorkerCtx.$config$.globalFns || []).filter((globalFnName => /[a-zA-Z_$][0-9a-zA-Z_$]*/.test(globalFnName))).map((g => `(typeof ${g}=='function'&&(this.${g}=${g}))`)).join(";")};` + (scriptUrl ? "\n//# sourceURL=" + scriptUrl : "");
env.$isSameOrigin$ || (scriptContent = scriptContent.replace(/.postMessage\(/g, `.postMessage('${env.$winId$}',`));
new Function(scriptContent).call(env.$window$);
env.$runWindowLoadEvent$ = 0;
Expand Down Expand Up @@ -736,7 +740,7 @@
return resolvedUrl;
};
const resolveUrl = (env, url, type) => resolveToUrl(env, url, type) + "";
const getPartytownScript = () => `<script src="${partytownLibUrl("partytown.js?v=0.8.0")}"><\/script>`;
const getPartytownScript = () => `<script src="${partytownLibUrl("partytown.js?v=0.8.2")}"><\/script>`;
const createImageConstructor = env => class HTMLImageElement {
constructor() {
this.s = "";
Expand Down Expand Up @@ -768,6 +772,10 @@
"load" === eventName && this.l.push(cb);
"error" === eventName && this.e.push(cb);
}
removeEventListener(eventName, cb) {
"load" === eventName && (this.l = this.l.filter((fn => fn !== cb)));
"error" === eventName && (this.e = this.e.filter((fn => fn !== cb)));
}
get onload() {
return this.l[0];
}
Expand Down Expand Up @@ -844,7 +852,7 @@
setter(this, [ "src" ], url);
orgUrl !== url && setter(this, [ "dataset", "ptsrc" ], orgUrl);
if (this.type && config.loadScriptsOnMainThread) {
const shouldExecuteScriptViaMainThread = config.loadScriptsOnMainThread.some((scriptUrl => scriptUrl === url));
const shouldExecuteScriptViaMainThread = config.loadScriptsOnMainThread.some((scriptUrl => new RegExp(scriptUrl).test(url)));
shouldExecuteScriptViaMainThread && setter(this, [ "type" ], "text/javascript");
}
}
Expand Down Expand Up @@ -1053,6 +1061,11 @@
return getter(this, [ "images" ]);
}
},
scripts: {
get() {
return getter(this, [ "scripts" ]);
}
},
implementation: {
get() {
return {
Expand Down Expand Up @@ -1147,6 +1160,9 @@
let href;
if ("string" != typeof value) {
href = getter(this, [ "href" ]);
if ("" === href) {
return "protocol" === anchorProp ? ":" : "";
}
setInstanceStateValue(this, 4, href);
value = new URL(href)[anchorProp];
}
Expand Down Expand Up @@ -1356,6 +1372,11 @@
const WorkerWindow = defineConstructorName(class extends WorkerBase {
constructor() {
super($winId$, $winId$);
this.addEventListener = (...args) => {
"load" === args[0] ? env.$runWindowLoadEvent$ && setTimeout((() => args[1]({
type: "load"
}))) : callMethod(this, [ "addEventListener" ], args, 2);
};
let win = this;
let value;
let historyState;
Expand All @@ -1365,7 +1386,7 @@
(() => {
if (!webWorkerCtx.$initWindowMedia$) {
self.$bridgeToMedia$ = [ getter, setter, callMethod, constructGlobal, definePrototypePropertyDescriptor, randomId, WinIdKey, InstanceIdKey, ApplyPathKey ];
webWorkerCtx.$importScripts$(partytownLibUrl("partytown-media.js?v=0.8.0"));
webWorkerCtx.$importScripts$(partytownLibUrl("partytown-media.js?v=0.8.2"));
webWorkerCtx.$initWindowMedia$ = self.$bridgeFromMedia$;
delete self.$bridgeFromMedia$;
}
Expand Down Expand Up @@ -1561,11 +1582,6 @@
}
win.Worker = void 0;
}
addEventListener(...args) {
"load" === args[0] ? env.$runWindowLoadEvent$ && setTimeout((() => args[1]({
type: "load"
}))) : callMethod(this, [ "addEventListener" ], args, 2);
}
get body() {
return env.$body$;
}
Expand Down
Loading

0 comments on commit 10b0de6

Please sign in to comment.