Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env node
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// Copyright (c) 2015-present, Facebook, Inc.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const debugger_1 = require("./debugger");
/* global process */
const commander = new commander_1.Command();
commander
.option("-h, --host <host>", "The hostname where the packager is running.")
.option("-p, --port <port>", "The port where the packager is running.")
.parse(process.argv);
const options = commander.opts();
(0, debugger_1.run)(options.host, options.port);
//# sourceMappingURL=cli.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA,4DAA4D;AAC5D,kCAAkC;AAClC,6CAA6C;AAC7C,kEAAkE;AAClE,0DAA0D;;AAE1D,yCAAoC;AACpC,yCAAiC;AAEjC,oBAAoB;AAEpB,MAAM,SAAS,GAAG,IAAI,mBAAO,EAAE,CAAC;AAEhC,SAAS;KACN,MAAM,CAAC,mBAAmB,EAAE,6CAA6C,CAAC;KAC1E,MAAM,CAAC,mBAAmB,EAAE,yCAAyC,CAAC;KACtE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;AACjC,IAAA,cAAG,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export declare function run(host?: string, port?: string, role?: string, debuggerName?: string): void;
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/env node
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// Copyright (c) 2015-present, Facebook, Inc.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = void 0;
const child_process_1 = require("child_process");
const WebSocket = require("ws");
/* global console setTimeout __dirname */
function run(host = "localhost", port = "8081", role = "debugger", debuggerName = "OfficeAddinDebugger") {
const debuggerWorkerRelativePath = "\\debuggerWorker.js";
const debuggerWorkerFullPath = `${__dirname}${debuggerWorkerRelativePath}`;
const websocketRetryTimeout = 500;
function connectToDebuggerProxy() {
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
var ws = new WebSocket(`ws://${host}:${port}/debugger-proxy?role=${role}&name=${debuggerName}`);
var worker;
function createJSRuntime() {
// This worker will run the application javascript code.
worker = (0, child_process_1.fork)(`${debuggerWorkerFullPath}`, [], {
stdio: ["pipe", "pipe", "pipe", "ipc"],
execArgv: ["--inspect"],
});
worker.on("message", (message) => {
ws.send(JSON.stringify(message));
});
}
function shutdownJSRuntime() {
if (worker) {
worker.kill();
worker.unref();
}
}
ws.onopen = () => {
console.log("Web socket opened...");
};
ws.onmessage = (message) => {
if (!message.data) {
return;
}
var object = JSON.parse(message.data.toString());
if (object.$event === "client-disconnected") {
shutdownJSRuntime();
return;
}
if (!object.method) {
return;
}
// Special message that asks for a new JS runtime
if (object.method === "prepareJSRuntime") {
shutdownJSRuntime();
//console.clear();
createJSRuntime();
ws.send(JSON.stringify({ replyID: object.id }));
}
else if (object.method === "$disconnected") {
shutdownJSRuntime();
}
else {
worker.send(object);
}
};
ws.onclose = (e) => {
shutdownJSRuntime();
if (e.reason) {
console.log(`Web socket closed because the following reason: ${e.reason}`);
}
setTimeout(connectToDebuggerProxy, websocketRetryTimeout);
};
ws.onerror = (event) => {
console.log(`${event.error}`);
};
}
connectToDebuggerProxy();
}
exports.run = run;
//# sourceMappingURL=debugger.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.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AC;AA3ED,kBA2EC"}
+1
View File
@@ -0,0 +1 @@
export {};
+101
View File
@@ -0,0 +1,101 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
/*
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
/* global __fbBatchedBridge, importScripts */
/* eslint @typescript-eslint/no-unused-vars: 0 */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_fetch_1 = __importDefault(require("node-fetch"));
process.on("message", (message) => {
let shouldQueueMessages = false;
const messageQueue = [];
const processEnqueuedMessages = () => {
while (messageQueue.length) {
const messageProcess = messageQueue.shift();
if (messageProcess) {
messageProcess();
}
}
shouldQueueMessages = false;
};
const messageHandlers = {
executeApplicationScript(message) {
for (const key in message.inject) {
global[key] = JSON.parse(message.inject[key]);
}
shouldQueueMessages = true;
function evalJS(js) {
try {
/* eslint-disable-next-line no-eval */
eval(js
.replace(/this\["webpackHotUpdate"\]/g, 'self["webpackHotUpdate"]')
.replace("GLOBAL", "global"));
}
catch (error) {
console.log(`Error Message: ${error.message}`);
console.log(`Error stack: ${error.stack}`);
}
finally {
if (process.send) {
process.send({ replyID: message.id });
processEnqueuedMessages();
}
}
}
// load platform bundles
if (global.__platformBundles != undefined) {
const platformBundles = global.__platformBundles.concat();
delete global.__platformBundles;
for (const [index, pb] of platformBundles.entries()) {
//console.log(`PB start ${index + 1}/${platformBundles.length}`);
eval(pb); // eslint-disable-line no-eval
//console.log(`PB done ${index + 1}/${platformBundles.length}`);
}
}
node_fetch_1.default
.default(message.url)
.then((resp) => resp.text())
.then(evalJS);
},
};
const processMessage = () => {
const sendReply = function (result, error) {
if (process.send) {
process.send({ replyID: message.id, result, error });
}
};
const handler = messageHandlers[message.method];
// Special cased handlers
if (handler) {
handler(message);
return;
}
// Other methods get called on the bridge
let returnValue = [[], [], [], 0];
try {
if (typeof __fbBatchedBridge === "object") {
returnValue = __fbBatchedBridge[message.method].apply(null, message.arguments);
}
}
finally {
sendReply(JSON.stringify(returnValue));
}
};
if (shouldQueueMessages) {
messageQueue.push(processMessage);
}
else {
processMessage();
}
});
//# sourceMappingURL=debuggerWorker.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"debuggerWorker.js","sourceRoot":"","sources":["../src/debuggerWorker.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;AAClC;;;;;;;GAOG;AACH,6CAA6C;AAC7C,iDAAiD;;;;;AAEjD,4DAA+B;AAO/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,IAAI,mBAAmB,GAAG,KAAK,CAAC;IAChC,MAAM,YAAY,GAAmB,EAAE,CAAC;IAExC,MAAM,uBAAuB,GAAG,GAAG,EAAE;QACnC,OAAO,YAAY,CAAC,MAAM,EAAE;YAC1B,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;YAC5C,IAAI,cAAc,EAAE;gBAClB,cAAc,EAAE,CAAC;aAClB;SACF;QACD,mBAAmB,GAAG,KAAK,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,eAAe,GAAQ;QAC3B,wBAAwB,CAAC,OAAY;YACnC,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE;gBAC/B,MAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;aACxD;YAED,mBAAmB,GAAG,IAAI,CAAC;YAE3B,SAAS,MAAM,CAAC,EAAU;gBACxB,IAAI;oBACF,sCAAsC;oBACtC,IAAI,CACF,EAAE;yBACC,OAAO,CAAC,6BAA6B,EAAE,0BAA0B,CAAC;yBAClE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAC/B,CAAC;iBACH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