How to use the codesandbox-api.registerFrame function in codesandbox-api

To help you get started, we’ve selected a few codesandbox-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / packages / common / src / components / Preview / index.tsx View on Github external
handleMessage = (data: any, source: any) => {
    if (data && data.codesandbox) {
      if (data.type === 'initialized' && source) {
        registerFrame(
          source,
          this.serverPreview
            ? getSSEUrl(this.props.sandbox.id)
            : frameUrl(this.props.sandbox.id)
        );

        if (!this.state.frameInitialized && this.props.onInitialized) {
          this.disposeInitializer = this.props.onInitialized(this);
        }

        setTimeout(() => {
          // We show a screenshot of the sandbox (if available) on top of the preview if the frame
          // hasn't loaded yet
          this.setState({ showScreenshot: false });
        }, this.serverPreview ? 0 : 600);
github codesandbox / codesandbox-client / standalone-packages / sandpack / src / manager / index.ts View on Github external
this.listener = listen((message: any) => {
      switch (message.type) {
        case 'initialized': {
          if (this.iframe) {
            if (this.iframe.contentWindow) {
              registerFrame(this.iframe.contentWindow, this.bundlerURL);

              if (this.options.fileResolver) {
                this.fileResolverProtocol = new Protocol(
                  'file-resolver',
                  async (data: { m: 'isFile' | 'readFile'; p: string }) => {
                    if (data.m === 'isFile') {
                      return this.options.fileResolver!.isFile(data.p);
                    }

                    return this.options.fileResolver!.readFile(data.p);
                  },
                  this.iframe.contentWindow
                );
              }
            }

codesandbox-api

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Greenkeeper badge](https://badges.greenkeeper.io/alexjoverm/typescript-library-starter.svg)](https://greenkeeper.io/) [![Travi

MIT
Latest version published 4 years ago

Package Health Score

73 / 100
Full package analysis

Similar packages