-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiling typescript in modules, separated out cucumber
- Loading branch information
Showing
156 changed files
with
1,974 additions
and
2,953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,8 @@ | |
"scripts": { | ||
"test": "yarn workspaces foreach --all test" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"devDependencies": { | ||
"typescript": "^5.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
["@babel/preset-env", { targets: { node: "current" } }], | ||
"@babel/preset-typescript", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { hello } from "hello-lib"; | ||
|
||
describe("hello", () => { | ||
it("hello jkl", () => { | ||
expect(hello("jkl")).toEqual("Hello, jkl"); | ||
}); | ||
|
||
it("hello uiop", () => { | ||
expect(hello("uiop")).toEqual("Hello, uiop"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "hello-lib-test", | ||
"scripts": { | ||
"build": "tsc -b", | ||
"test": "jest" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.16.7", | ||
"@babel/preset-env": "^7.16.8", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@types/jest": "^27.4.0", | ||
"babel-jest": "^27.4.6", | ||
"hello-lib": "workspace:*", | ||
"jest": "^27.4.7", | ||
"typescript": "^4.5.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.root.json", | ||
"compilerOptions": { | ||
"noEmit": true | ||
}, | ||
"references": [ | ||
{ | ||
"path": "../hello-lib" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare function hello(s: string): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hello = void 0; | ||
function hello(s) { | ||
return "Hello, ".concat(s); | ||
} | ||
exports.hello = hello; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "hello-lib", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"typescript": "^4.5.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function hello(s: string): string { | ||
return `Hello, ${s}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../tsconfig.root.json", | ||
"compilerOptions": { | ||
"lib": ["es2019"], | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"target": "es5", | ||
"composite": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"program":{"fileNames":["../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es5.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2016.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2017.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2018.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2019.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../../../.yarn/berry/cache/typescript-patch-32ada147aa-10c0.zip/node_modules/typescript/lib/lib.es2019.intl.d.ts","./src/index.ts"],"fileInfos":[{"version":"8730f4bf322026ff5229336391a18bcaa1f94d4f82416c8b2f3954e2ccaae2ba","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","4b421cbfb3a38a27c279dec1e9112c3d1da296f77a1a85ddadf7e7a425d45d18",{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"5f406584aef28a331c36523df688ca3650288d14f39c5d2e555c95f0d2ff8f6f","affectsGlobalScope":true},{"version":"22f230e544b35349cfb3bd9110b6ef37b41c6d6c43c3314a31bd0d9652fcec72","affectsGlobalScope":true},{"version":"7ea0b55f6b315cf9ac2ad622b0a7813315bb6e97bf4bb3fbf8f8affbca7dc695","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"eb26de841c52236d8222f87e9e6a235332e0788af8c87a71e9e210314300410a","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"5e5e095c4470c8bab227dbbc61374878ecead104c74ab9960d3adcccfee23205","affectsGlobalScope":true},{"version":"0f3c67e48c626fe1b31f623822cee9efae5bfcd5ac5d4e0b50cd4fa5e86af14c","signature":"6d8dca9d4a2d7c4033382049629956ae114b8765aaf16c1d116528035713ef1e"}],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"noFallthroughCasesInSwitch":true,"outDir":"./dist","rootDir":"./src","strict":true,"target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[8,7,2,9,10,11,12,13,14,15,16,3,4,20,17,18,19,21,22,23,5,24,25,26,27,6,31,28,29,30,1,32],"latestChangedDtsFile":"./dist/index.d.ts"},"version":"4.9.5"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const hello_lib_1 = require("hello-lib"); | ||
function helloCli() { | ||
console.log((0, hello_lib_1.hello)("World")); | ||
} | ||
helloCli(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "hello-cli", | ||
"scripts": { | ||
"build": "tsc -b", | ||
"go": "node dist/hello-cli.js" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16", | ||
"hello-lib": "workspace:*", | ||
"typescript": "^4.5.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { hello } from "hello-lib"; | ||
|
||
function helloCli() { | ||
console.log(hello("World")); | ||
} | ||
|
||
helloCli(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"extends": "../tsconfig.root.json", | ||
"compilerOptions": { | ||
"lib": ["es2019"], | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"target": "es6", | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"include": ["src"], | ||
"references": [ | ||
{ | ||
"path": "../hello-lib" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.supply = void 0; | ||
var src_1 = require("../../../packages/common/src"); | ||
/** | ||
* This configures the postMessage listener to respond to requests for desktop agent APIs. | ||
* Called by the desktop agent | ||
*/ | ||
var supply = function (checker, detailsResolvers) { | ||
function createResponseMessage(source, method, detailsResolver) { | ||
return { | ||
type: src_1.FDC3_API_RESPONSE_MESSAGE_TYPE, | ||
method: method, | ||
details: detailsResolver(source) | ||
}; | ||
} | ||
window.addEventListener("message", function (event) { | ||
console.log("Received: " + JSON.stringify(event)); | ||
var data = event.data; | ||
if (data.type == src_1.FDC3_API_REQUEST_MESSAGE_TYPE) { | ||
var origin_1 = event.origin; | ||
var source = event.source; | ||
if (checker(source)) { | ||
console.log("API Request Origin: ".concat(origin_1)); | ||
var methods = event.data.methods; | ||
for (var i = 0; i < methods.length; i++) { | ||
var currentMethod = methods[i]; | ||
var detailsResolver = detailsResolvers[currentMethod]; | ||
if (detailsResolver) { | ||
source.postMessage(createResponseMessage(source, currentMethod, detailsResolver), origin_1); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
}; | ||
exports.supply = supply; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.load = exports.DEFAULT_OPTIONS = exports.DEFAULT_METHODS = exports.POST_MESSAGE_PROTOCOL = exports.JS_INJECT = void 0; | ||
/* | ||
* this part is the different ways that we can use to talk with the | ||
* desktop agent once we have a reference to it. | ||
*/ | ||
exports.JS_INJECT = "js-inject"; | ||
exports.POST_MESSAGE_PROTOCOL = "post-message-protocol"; | ||
/** | ||
* This is in preference order, chosen by the app. | ||
*/ | ||
exports.DEFAULT_METHODS = [exports.POST_MESSAGE_PROTOCOL, exports.JS_INJECT]; | ||
exports.DEFAULT_OPTIONS = { | ||
setWindowGlobal: false, | ||
fireFdc3Ready: false, | ||
methods: exports.DEFAULT_METHODS, | ||
strategies: [postMessage, electronEvent], | ||
frame: (_a = window.opener) !== null && _a !== void 0 ? _a : window.parent | ||
}; | ||
/** | ||
* This return an FDC3 API. Called by Apps. | ||
*/ | ||
function load(optionsOverride) { | ||
if (optionsOverride === void 0) { optionsOverride = exports.DEFAULT_OPTIONS; } | ||
var options = __assign(__assign({}, exports.DEFAULT_OPTIONS), optionsOverride); | ||
function handleGenericOptions(da) { | ||
if ((options.setWindowGlobal) && (window.fdc3 == null)) { | ||
window.fdc3 = da; | ||
} | ||
return da; | ||
} | ||
var strategies = options.strategies.map(function (s) { return s(options); }); | ||
return Promise.any(strategies) | ||
.then(function (da) { return handleGenericOptions(da); }); | ||
} | ||
exports.load = load; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* This loads the script using an import | ||
*/ | ||
var method = function (data, options) { | ||
return Promise.resolve("".concat(/* @vite-ignore */ data.details.url)).then(function (s) { return require(s); }).then(function (ns) { | ||
var init = ns.default; | ||
var da = init(data.details, options); | ||
return da; | ||
}); | ||
}; | ||
exports.default = method; |
File renamed without changes.
51 changes: 51 additions & 0 deletions
51
packages-3/web-fdc3-client/src/methods/post-message-protocol/PostMessageDesktopAgent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PostMessageDesktopAgent = void 0; | ||
var BridgingTypes_1 = require("../../BridgingTypes"); | ||
var AbstractDesktopAgent_1 = require("../../../../packages/client/src/AbstractDesktopAgent"); | ||
/** | ||
* Desktop Agent implemented over post-message protocol, using DesktopAgentBridging. | ||
* As before, just implementing broadcast, addContextListener and getInfo. | ||
*/ | ||
var PostMessageDesktopAgent = /** @class */ (function (_super) { | ||
__extends(PostMessageDesktopAgent, _super); | ||
function PostMessageDesktopAgent(details, options) { | ||
var _this = _super.call(this, details, options) || this; | ||
_this.origin = details.origin; | ||
// set up the post message listener for events coming from the server | ||
window.addEventListener("message", function (event) { | ||
var data = event.data; | ||
if (data.type == BridgingTypes_1.RequestMessageType.BroadcastRequest) { | ||
var typedData = data; | ||
var meta_1 = typedData.meta; | ||
var payload = typedData.payload; | ||
var context_1 = payload.context; | ||
_this.listeners.forEach(function (l) { return l.handle(context_1, meta_1); }); | ||
} | ||
}); | ||
return _this; | ||
} | ||
PostMessageDesktopAgent.prototype.getIcon = function () { | ||
return "/static/da/noun-mailbox-6010513.png"; | ||
}; | ||
PostMessageDesktopAgent.prototype.postInternal = function (m) { | ||
this.options.frame.postMessage(m, this.origin); | ||
}; | ||
return PostMessageDesktopAgent; | ||
}(AbstractDesktopAgent_1.AbstractDesktopAgent)); | ||
exports.PostMessageDesktopAgent = PostMessageDesktopAgent; |
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
packages-3/web-fdc3-client/src/methods/post-message-protocol/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var PostMessageDesktopAgent_1 = require("./PostMessageDesktopAgent"); | ||
var method = function (r, options) { | ||
return new Promise(function (resolve, _reject) { | ||
// nasty bit of casting to avoid the problem we've only implemented 3 methods. | ||
resolve(new PostMessageDesktopAgent_1.PostMessageDesktopAgent(r.details, options)); | ||
}); | ||
}; | ||
exports.default = method; |
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
packages-3/web-fdc3-client/src/strategies/electron-event.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fdc3_1 = require("@finos/fdc3"); | ||
/** | ||
* This approach will resolve the loader promise if the fdc3Ready event occurs. | ||
* This is done by electron implementations setting window.fdc3. | ||
*/ | ||
var loader = function (_options) { | ||
var out = new Promise(function (resolve) { | ||
(0, fdc3_1.fdc3Ready)().then(function () { | ||
resolve(window.fdc3); | ||
}); | ||
}); | ||
return out; | ||
}; | ||
exports.default = loader; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var src_1 = require("../../../packages/common/src"); | ||
var js_inject_1 = require("../methods/js-inject"); | ||
var post_message_protocol_1 = require("../methods/post-message-protocol"); | ||
var METHOD_MAP = { | ||
"js-inject": js_inject_1.default, | ||
"post-message-protocol": post_message_protocol_1.default | ||
}; | ||
var loader = function (options) { | ||
function handleOptions(da) { | ||
return da; | ||
} | ||
var out = new Promise(function (resolve, reject) { | ||
// setup listener for message and retrieve JS URL from it | ||
window.addEventListener("message", function (event) { | ||
var data = event.data; | ||
if (data.type == src_1.FDC3_API_RESPONSE_MESSAGE_TYPE) { | ||
var method = METHOD_MAP[data.method]; | ||
method(data, options) | ||
.then(function (da) { return handleOptions(da); }) | ||
.then(function (da) { return resolve(da); }); | ||
} | ||
else { | ||
reject("Incorrect API Response Message"); | ||
} | ||
}, { once: true }); | ||
}); | ||
var da = options.frame; | ||
if (da != null) { | ||
var requestMessage = { | ||
type: src_1.FDC3_API_REQUEST_MESSAGE_TYPE, | ||
methods: options.methods | ||
}; | ||
da.postMessage(requestMessage, "*"); | ||
} | ||
return out; | ||
}; | ||
exports.default = loader; |
File renamed without changes.
Oops, something went wrong.