Skip to content

Instantly share code, notes, and snippets.

View ljmotta's full-sized avatar

Luiz João Motta ljmotta

  • Senior Software Engineer - IBM
  • São Paulo, SP - Brazil
View GitHub Profile
@ljmotta
ljmotta / todo-list-view.ts
Created October 14, 2020 20:31
TodoListView Envelope Init
import { init } from "todo-list-view/dist/envelope";
import { EnvelopeBusMessage } from "@kogito-tooling/envelope-bus/dist/api";
init({
container: document.getElementById("envelope-app")!,
bus: {
postMessage<D, Type>(message: EnvelopeBusMessage<D, Type>, targetOrigin?: string, transfer?: any) {
window.parent.postMessage(message, "*", transfer);
},
},
@ljmotta
ljmotta / GwtEditorWrapperFactory.ts
Last active October 14, 2020 20:35
GwtEditorWrapperFactory
import { ChannelType, getOperatingSystem } from "@kogito-tooling/channel-common-api";
import { init } from "@kogito-tooling/editor/dist/envelope";
import { CompositeEditorFactory } from "@kogito-tooling/editor/dist/envelope";
import { EnvelopeBusMessage } from "@kogito-tooling/envelope-bus/dist/api";
import { GwtEditorWrapperFactory } from "@kogito-tooling/kie-bc-editors";
init({
container: document.getElementById("envelope-app")!,
bus: {
postMessage<D, Type>(message: EnvelopeBusMessage<D, Type>, targetOrigin?: string, _?: any) {
@ljmotta
ljmotta / base64-editor.ts
Created October 14, 2020 20:26
Base64PngEditor Envelope Init
import { init } from "@kogito-tooling/editor/dist/envelope";
import { CompositeEditorFactory } from "@kogito-tooling/editor/dist/envelope";
import { EnvelopeBusMessage } from "@kogito-tooling/envelope-bus/dist/api";
import { ChannelType, getOperatingSystem } from "@kogito-tooling/channel-common-api";
import { Base64PngEditorFactory } from "base64png-editor";
init({
container: document.getElementById("envelope-app")!,
bus: {
postMessage<D, Type>(message: EnvelopeBusMessage<D, Type>, targetOrigin?: string, _?: any) {
@ljmotta
ljmotta / base64-editor.html
Created October 14, 2020 20:24
Base64Png Editor HTML
<!DOCTYPE html>
<html lang="en">
<head>
<style>
html,
body,
div#envelope-app {
margin: 0;
border: 0;
padding: 0;
@ljmotta
ljmotta / PingPongReactImplFactory.tsx
Last active October 14, 2020 19:54
PingPongReactImplFactory
import { MessageBusClientApi } from "@kogito-tooling/envelope-bus/dist/api";
// ...
export class PingPongReactImplFactory implements PingPongFactory {
public create(initArgs: PingPongInitArgs, channelApi: MessageBusClientApi<PingPongChannelApi>) {
const ref = React.createRef<PingPongApi>();
const pingPongView: PingPong = {
reactComponent: () => <PingPongReactImpl initArgs={initArgs} channelApi={channelApi} ref={ref} />,
};
@ljmotta
ljmotta / PingPongEnvelopeView.tsx
Created October 14, 2020 19:48
PingPongEnvelopeView
export interface PingPongEnvelopeViewApi {
setView(page: PingPong): Promise<void>;
}
export const PingPongEnvelopeView = React.forwardRef((props, forwardedRef) => {
const [view, setView] = useState<PingPong>();
useImperativeHandle(forwardedRef, () => ({ setView: setView }), []);
return (
@ljmotta
ljmotta / PingPongEnvelopeApiImpl.ts
Created October 14, 2020 19:44
PingPongEnvelopeApiImpl
import { EnvelopeApiFactoryArgs } from "@kogito-tooling/envelope";
import { Association, PingPongChannelApi, PingPongEnvelopeApi, PingPongInitArgs } from "../api";
// ...
export class PingPongEnvelopeApiImpl implements PingPongEnvelopeApi {
constructor(
private readonly args: EnvelopeApiFactoryArgs<
PingPongEnvelopeApi,
PingPongChannelApi,
PingPongEnvelopeViewApi,
@ljmotta
ljmotta / PingPongEnvelope.ts
Created October 14, 2020 19:39
PingPongEnvelope
import { EnvelopeBus } from "@kogito-tooling/envelope-bus/dist/api";
import { Envelope } from "@kogito-tooling/envelope";
import { PingPongChannelApi, PingPongEnvelopeApi } from "../api";
// ...
export function init(args: { container: HTMLElement; bus: EnvelopeBus; pingPongViewFactory: PingPongFactory }) {
const envelope = new Envelope<
PingPongEnvelopeApi,
PingPongChannelApi,
PingPongEnvelopeViewApi,
@ljmotta
ljmotta / PingPong.ts
Created October 14, 2020 18:25
PingPong
import { PingPongApi } from "../api";
export interface PingPong extends PingPongApi {
reactComponent?(): React.ReactNode;
}
@ljmotta
ljmotta / PingPongFactory.ts
Last active October 14, 2020 18:24
PingPongFactory
import { MessageBusClientApi } from "@kogito-tooling/envelope-bus/dist/api";
import { PingPongChannelApi, PingPongInitArgs } from "../api";
export interface PingPongFactory {
create(initArgs: PingPongInitArgs, channelApi: MessageBusClientApi<PingPongChannelApi>): PingPong;
}