Skip to content

Releases: Claviz/drayman

v2.9.0

11 Mar 14:18
Compare
Choose a tag to compare
  • You can now pass an object with specific options (ref, wait, customSelector) to browser commands with elements instead of a simple string reference. Read more in docs.

v2.8.0

05 Dec 10:13
Compare
Choose a tag to compare
  • You can now handle event cancellation. Read more about this feature here.

v2.6.0

06 Oct 17:37
Compare
Choose a tag to compare
  • You can now use any custom rule for style attribute, for example:
<div style={{ '--dynamic-bg-image': `url('')` }}></div>
  • Added debounce for emit in browserCommands:
    This option is useful, for example, when viewport of the browser was resized and you need to execute callback only after user has stopped resizing it:

public/index.html

...

<script>
  initializeDraymanFramework({
    browserCommands: (emit) => ({
      events: async ({ onViewportChanged }) => {
        window.onresize = () => {
          emit(
            onViewportChanged,
            {
              width: window.innerWidth,
              height: window.innerHeight,
            },
            {
              debounce: 500,
            }
          );
        };
      },
    }),
  });
</script>

...

src/components/home.tsx

export const component: DraymanComponent<any> = async ({
  Browser,
  forceUpdate,
}) => {
  let dimensions = ``;

  Browser.events({
    onViewportChanged: async (data) => {
      dimensions = `${data.width}x${data.height}`;
      await forceUpdate();
    },
  });

  return () => {
    return <div>{dimensions}</div>;
  };
};

In the example above, onViewportChanged callback will be executed and text of window dimensions will be updated only after user has stopped resizing browser window for 500ms.

  • Server object can now be used to listen to events from EventHub or emit events to EventHub. This can be used when you want to communicate from server to all or specific components at once. You can read more about EventHub object here.

src/index.ts

export const Server: DraymanServer = async ({ EventHub }) => {
  EventHub.on("my-event", (data) => {
    console.log(data);
  });

  return {
    sendEvent: async () => {
      EventHub.emit("my-event", { hello: "world" });
    },
  };
};

v2.5.0

27 Mar 10:11
Compare
Choose a tag to compare

Added Event Guards. This feature prevents unnecessary server requests when listening for specific events, such as keyboard shortcuts.

For example, you can now easily create a keyboard shortcut that only triggers a server-side action when a specific key combination is pressed. Check out the example in our docs to see how to implement an Event Guard for a keyboard event here.

v.2.4.0

03 Nov 12:31
Compare
Choose a tag to compare

It is now possible to pass an event to <drayman-element /> from client-side and it will be executed as expected.

Client HTML:

<body>
    <drayman-element component="home"></drayman-element>

    <script>
        initializeDraymanFramework();
        const draymanElement = document.getElementsByTagName('drayman-element')[0];
        // Passing `onRootEvent` as an `option`:
        draymanElement.options = {
            onRootEvent: async ({ text }) => {
                let el = document.createElement('div');
                el.innerText = text;
                document.body.appendChild(el);
            }
        };
    </script>
</body>

Server-side home.tsx component:

export const component: DraymanComponent<{ onRootEvent: any; }> = async ({ props }) => {

    return () => {
        return (
            <button
                onclick={async () => {
                    await props.onRootEvent({ text: `Nice!` });
                }}
            >Click!</button>
        )
    }
}

v.2.3.0

02 Nov 09:39
Compare
Choose a tag to compare

v.2.1.0

14 Sep 17:13
Compare
Choose a tag to compare
  • It is now possible to pass onInit (executed when first view is received) and onDestroy (executed when element is removed from DOM) functions to <drayman-element />.

v.2.0.0

23 Jun 08:58
Compare
Choose a tag to compare
  • Error boundaries implementation - previously a parent component couldn't be rendered if some of the components in a component tree failed to initialise or render. Now a parent is rendered with problematic parts highlighted and descriptive error is shown.
  • Console events (log, error, etc.) are now pretty-printed.
  • Components are now transpiled with source maps. This allows to see exact line of the error inside a source code.

v.1.8.0

25 Nov 14:19
Compare
Choose a tag to compare
  • It is possible now to create a middleware for requests via Server object.

v.1.7.0

02 Nov 09:21
Compare
Choose a tag to compare
  • A new Server object is now available for components.