/*
 * Copyright 2010-2015 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jetbrains.kotlin.metadata.js;

// Whenever you change this proto in an incompatible way, don't forget to bump JsMetadataVersion

import "core/metadata/src/metadata.proto";

option java_outer_classname = "JsProtoBuf";
option optimize_for = LITE_RUNTIME;

message Header {
  /*
    preRelease
  */
  optional int32 flags = 1;

  // (patch << 16) + (minor << 8) + major
  optional int32 js_code_binary_version = 2 [default = 1];

  optional string package_fq_name = 3;

  optional StringTable strings = 4;

  optional QualifiedNameTable qualified_names = 5;

  // Annotations on the whole module
  repeated Annotation annotation = 6;
}

message File {
  // If absent, id is the index of the file in the Files.file list
  optional int32 id = 1;

  repeated Annotation annotation = 2;
}

message Files {
  repeated File file = 1;
}

extend Package {
  optional int32 package_fq_name = 131;
}

extend Class {
  repeated Annotation class_annotation = 130;
  optional int32 class_containing_file_id = 135;
}

extend Constructor {
  repeated Annotation constructor_annotation = 130;
}

extend Function {
  repeated Annotation function_annotation = 130;
  optional int32 function_containing_file_id = 135;
}

extend Property {
  repeated Annotation property_annotation = 130;
  repeated Annotation property_getter_annotation = 132;
  repeated Annotation property_setter_annotation = 133;
  optional Annotation.Argument.Value compile_time_value = 131;
  optional int32 property_containing_file_id = 135;
}

extend EnumEntry {
  repeated Annotation enum_entry_annotation = 130;
}

extend ValueParameter {
  repeated Annotation parameter_annotation = 130;
}

extend Type {
  repeated Annotation type_annotation = 130;
}

extend TypeParameter {
  repeated Annotation type_parameter_annotation = 130;
}

extend PackageFragment {
  optional Files package_fragment_files = 130;
}

message Classes {
  // id in StringTable
  repeated int32 class_name = 1 [packed = true];
}

message Library {
  enum Kind {
    PLAIN = 1;
    AMD = 2;
    COMMON_JS = 3;
    UMD = 4;
  }

  optional Kind kind = 1 [default = PLAIN];

  repeated PackageFragment package_fragment = 2;

  repeated string imported_module = 3;
}
