How to use @swim/codec - 10 common examples

To help you get started, we’ve selected a few @swim/codec 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 swimos / swim / swim-system-js / swim-core-js / @swim / build / main / Target.ts View on Github external
protected onCompileResult(status: ts.Diagnostic) {
    if (this.canCompile()) {
      if (status.code === 6031) {
        // watching
        this.failed = false;
        this.compileStart = Date.now();
      } else if (status.code === 6032) {
        // change detected
        this.failed = false;
        this.compileStart = Date.now();
        const output = Unicode.stringOutput(OutputSettings.styled());
        OutputStyle.greenBold(output);
        output.write("recompiling");
        OutputStyle.reset(output);
        output.write(" ");
        OutputStyle.yellow(output);
        output.write(this.uid);
        OutputStyle.reset(output);
        console.log(output.bind());
      } else if (status.code === 6194) {
        // complete
        if (!this.failed) {
          this.lint();
        }
        this.emittedSourceFiles.length = 0;
        if (!this.failed) {
          this.onCompileSuccess();
github swimos / swim / swim-js / swim-core-js / @swim / build / main / Target.ts View on Github external
protected onCompileResult(status: ts.Diagnostic) {
    if (status.code === 6031) {
      // watching
      this.failed = false;
      this.compileStart = Date.now();
    } else if (status.code === 6032) {
      // change detected
      this.failed = false;
      this.compileStart = Date.now();
      const output = Unicode.stringOutput(OutputSettings.styled());
      OutputStyle.greenBold(output);
      output.write("recompiling");
      OutputStyle.reset(output);
      output.write(" ");
      OutputStyle.yellow(output);
      output.write(this.uid);
      OutputStyle.reset(output);
      console.log(output.bind());
    } else if (status.code === 6194) {
      // complete
      if (!this.failed) {
        this.lint();
      }
      if (!this.failed) {
        this.onCompileSuccess();
        if (this.selected) {
github swimos / swim / swim-js / swim-core-js / @swim / build / main / Build.ts View on Github external
if (project) {
          if (targetId) { // :
            const target = project.targets[targetId];
            if (target) {
              target.selected = true;
              targets = target.transitiveDeps(targets);
            }
          } else { // (:?)
            for (let j = 0; j < project.targetList.length; j += 1) {
              const target = project.targetList[j];
              target.selected = true;
              targets = target.transitiveDeps(targets);
            }
          }
        } else {
          const output = Unicode.stringOutput(OutputSettings.styled());
          OutputStyle.redBold(output);
          output.write("unknown project");
          OutputStyle.reset(output);
          output.write(" ");
          OutputStyle.yellow(output);
          output.write(projectId);
          OutputStyle.reset(output);
          console.log(output.bind());
        }
      } else if (targetId) { // :
        for (let j = 0; j < this.projectList.length; j += 1) {
          const target = this.projectList[j].targets[targetId];
          if (target) {
            target.selected = true;
            targets = target.transitiveDeps(targets);
          }
github swimos / swim / swim-js / swim-core-js / @swim / build / main / Build.ts View on Github external
if (target) {
              target.selected = true;
              targets = target.transitiveDeps(targets);
            }
          } else { // (:?)
            for (let j = 0; j < project.targetList.length; j += 1) {
              const target = project.targetList[j];
              target.selected = true;
              targets = target.transitiveDeps(targets);
            }
          }
        } else {
          const output = Unicode.stringOutput(OutputSettings.styled());
          OutputStyle.redBold(output);
          output.write("unknown project");
          OutputStyle.reset(output);
          output.write(" ");
          OutputStyle.yellow(output);
          output.write(projectId);
          OutputStyle.reset(output);
          console.log(output.bind());
        }
      } else if (targetId) { // :
        for (let j = 0; j < this.projectList.length; j += 1) {
          const target = this.projectList[j].targets[targetId];
          if (target) {
            target.selected = true;
            targets = target.transitiveDeps(targets);
          }
        }
      }
    }
github swimos / swim / swim-system-js / swim-core-js / @swim / build / main / Target.ts View on Github external
protected onCompileResult(status: ts.Diagnostic) {
    if (this.canCompile()) {
      if (status.code === 6031) {
        // watching
        this.failed = false;
        this.compileStart = Date.now();
      } else if (status.code === 6032) {
        // change detected
        this.failed = false;
        this.compileStart = Date.now();
        const output = Unicode.stringOutput(OutputSettings.styled());
        OutputStyle.greenBold(output);
        output.write("recompiling");
        OutputStyle.reset(output);
        output.write(" ");
        OutputStyle.yellow(output);
        output.write(this.uid);
        OutputStyle.reset(output);
        console.log(output.bind());
      } else if (status.code === 6194) {
        // complete
        if (!this.failed) {
          this.lint();
        }
        this.emittedSourceFiles.length = 0;
        if (!this.failed) {
          this.onCompileSuccess();
          if (this.selected) {
            this.throttleBundle();
          }
        } else {
          this.onCompileFailure();
github swimos / swim / swim-system-js / swim-core-js / @swim / build / main / Target.ts View on Github external
protected onCompileResult(status: ts.Diagnostic) {
    if (this.canCompile()) {
      if (status.code === 6031) {
        // watching
        this.failed = false;
        this.compileStart = Date.now();
      } else if (status.code === 6032) {
        // change detected
        this.failed = false;
        this.compileStart = Date.now();
        const output = Unicode.stringOutput(OutputSettings.styled());
        OutputStyle.greenBold(output);
        output.write("recompiling");
        OutputStyle.reset(output);
        output.write(" ");
        OutputStyle.yellow(output);
        output.write(this.uid);
        OutputStyle.reset(output);
        console.log(output.bind());
      } else if (status.code === 6194) {
        // complete
        if (!this.failed) {
          this.lint();
        }
        this.emittedSourceFiles.length = 0;
        if (!this.failed) {
          this.onCompileSuccess();
          if (this.selected) {
github swimos / swim / swim-js / swim-core-js / @swim / build / main / Build.ts View on Github external
if (targetId) { // :
            const target = project.targets[targetId];
            if (target) {
              target.selected = true;
              targets = target.transitiveDeps(targets);
            }
          } else { // (:?)
            for (let j = 0; j < project.targetList.length; j += 1) {
              const target = project.targetList[j];
              target.selected = true;
              targets = target.transitiveDeps(targets);
            }
          }
        } else {
          const output = Unicode.stringOutput(OutputSettings.styled());
          OutputStyle.redBold(output);
          output.write("unknown project");
          OutputStyle.reset(output);
          output.write(" ");
          OutputStyle.yellow(output);
          output.write(projectId);
          OutputStyle.reset(output);
          console.log(output.bind());
        }
      } else if (targetId) { // :
        for (let j = 0; j < this.projectList.length; j += 1) {
          const target = this.projectList[j].targets[targetId];
          if (target) {
            target.selected = true;
            targets = target.transitiveDeps(targets);
          }
        }
github swimos / swim / swim-system-js / swim-core-js / @swim / build / main / Target.ts View on Github external
return; // Suppress .tsbuildinfo file overwrite error.
    }
    let message = error.messageText;
    if (typeof message !== "string") {
      message = message.messageText;
    }
    const severity = Target.tsSeverity(error.category);
    if (severity.level() >= Severity.ERROR_LEVEL) {
      this.failed = true;
    }
    if (error.file) {
      let tag: Tag;
      if (error.length! > 1) {
        const start = Target.tsMark(error.start!, error.file);
        const end = Target.tsMark(error.start! + error.length! - 1, error.file, message);
        tag = Span.from(start, end);
      } else {
        tag = Target.tsMark(error.start!, error.file, message);
      }

      const input = Unicode.stringInput(error.file.text).id(error.file.fileName);
      const diagnostic = new Diagnostic(input, tag, severity, "" + error.code, null, null);
      console.log(diagnostic.toString(OutputSettings.styled()));
    } else {
      const output = Unicode.stringOutput(OutputSettings.styled());
      Diagnostic.displayMessage(severity, message, output);
      console.log(output.bind());
    }
  }
github swimos / swim / swim-js / swim-core-js / @swim / build / main / Target.ts View on Github external
protected onBundleWarning(warning: rollup.RollupWarning): void {
    if (warning.code === "CIRCULAR_DEPENDENCY" || warning.code === "MISSING_NODE_BUILTINS") {
      return; // suppress superfluous warnings
    }
    const output = Unicode.stringOutput(OutputSettings.styled());
    if (warning.importer) {
      output.write(warning.importer);
      output.write(" ");
    }
    OutputStyle.blue(output);
    output.write("warning:");
    OutputStyle.reset(output);
    if (warning.message) {
      output.write(" ");
      output.write(warning.message);
    }
    console.log(output.bind());
  }
github swimos / swim / swim-system-js / swim-core-js / @swim / build / main / Target.ts View on Github external
protected onBundleWarning(warning: rollup.RollupWarning): void {
    if (warning.code === "CIRCULAR_DEPENDENCY" || warning.code === "MISSING_NODE_BUILTINS") {
      return; // suppress superfluous warnings
    }
    const output = Unicode.stringOutput(OutputSettings.styled());
    if (warning.importer) {
      output.write(warning.importer);
      output.write(" ");
    }
    OutputStyle.blue(output);
    output.write("warning:");
    OutputStyle.reset(output);
    if (warning.message) {
      output.write(" ");
      output.write(warning.message);
    }
    console.log(output.bind());
  }