Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/protons-benchmark/src/implementations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ $ npx playwright-test dist/src/index.js --runner benchmark
import { create, toBinary, fromBinary } from '@bufbuild/protobuf'
import { expect } from 'aegir/chai'
import Benchmark from 'benchmark'
import { encodeTest as pbjsEncodeTest, decodeTest as pbjsDecodeTest } from './pbjs/bench.js'
import { TestSchema as ProtobufEsTest } from './protobuf-es/bench_pb.js'
import { Test as ProtobufTsTest } from './protobuf-ts/bench.js'
import { Test as ProtobufjsTest } from './protobufjs/bench.js'
import { Test as ProtonsTest } from './protons/bench.js'
import { encodeTest as pbjsEncodeTest, decodeTest as pbjsDecodeTest } from './pbjs/bench.ts'
import { TestSchema as ProtobufEsTest } from './protobuf-es/bench_pb.ts'
import { Test as ProtobufTsTest } from './protobuf-ts/bench.ts'
import { Test as ProtobufjsTest } from './protobufjs/bench.ts'
import { Test as ProtonsTest } from './protons/bench.ts'

const message = {
meh: {
Expand Down
4 changes: 2 additions & 2 deletions packages/protons-benchmark/src/numbers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ $ node dist/src/numbers/index.js
$ npx playwright-test dist/src/numbers/index.js --runner benchmark
*/

import { readBenchmark } from './read.js'
import { writeBenchmark } from './write.js'
import { readBenchmark } from './read.ts'
import { writeBenchmark } from './write.ts'

console.info('-- read --')
await readBenchmark()
Expand Down
2 changes: 1 addition & 1 deletion packages/protons-runtime/src/codec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Writer, Reader } from './index.js'
import type { Writer, Reader } from './index.ts'

// https://developers.google.com/protocol-buffers/docs/encoding#structure
export enum CODEC_TYPES {
Expand Down
4 changes: 2 additions & 2 deletions packages/protons-runtime/src/codecs/enum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCodec, CODEC_TYPES } from '../codec.js'
import type { DecodeFunction, EncodeFunction, Codec } from '../codec.js'
import { createCodec, CODEC_TYPES } from '../codec.ts'
import type { DecodeFunction, EncodeFunction, Codec } from '../codec.ts'

export function enumeration <T> (v: any): Codec<T> {
function findValue (val: string | number): number {
Expand Down
4 changes: 2 additions & 2 deletions packages/protons-runtime/src/codecs/message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCodec, CODEC_TYPES } from '../codec.js'
import type { EncodeFunction, DecodeFunction, Codec } from '../codec.js'
import { createCodec, CODEC_TYPES } from '../codec.ts'
import type { EncodeFunction, DecodeFunction, Codec } from '../codec.ts'

export interface Factory<A, T> {
new (obj: A): T
Expand Down
4 changes: 2 additions & 2 deletions packages/protons-runtime/src/decode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createReader } from './utils/reader.js'
import type { Codec, DecodeOptions } from './codec.js'
import { createReader } from './utils/reader.ts'
import type { Codec, DecodeOptions } from './codec.ts'
import type { Uint8ArrayList } from 'uint8arraylist'

export function decodeMessage <T> (buf: Uint8Array | Uint8ArrayList, codec: Pick<Codec<T>, 'decode'>, opts?: DecodeOptions<T>): T {
Expand Down
4 changes: 2 additions & 2 deletions packages/protons-runtime/src/encode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createWriter } from './utils/writer.js'
import type { Codec } from './codec.js'
import { createWriter } from './utils/writer.ts'
import type { Codec } from './codec.ts'

export function encodeMessage <T> (message: Partial<T>, codec: Pick<Codec<T>, 'encode'>): Uint8Array {
const w = createWriter()
Expand Down
16 changes: 8 additions & 8 deletions packages/protons-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* ```
*/

import type { Codec } from './codec.js'
import type { Codec } from './codec.ts'

export interface FieldDef {
name: string
Expand All @@ -22,17 +22,17 @@ export interface FieldDef {

export {
decodeMessage
} from './decode.js'
} from './decode.ts'

export {
encodeMessage
} from './encode.js'
} from './encode.ts'

export { enumeration } from './codecs/enum.js'
export { message } from './codecs/message.js'
export { createReader as reader } from './utils/reader.js'
export { createWriter as writer } from './utils/writer.js'
export type { Codec, EncodeOptions, DecodeOptions } from './codec.js'
export { enumeration } from './codecs/enum.ts'
export { message } from './codecs/message.ts'
export { createReader as reader } from './utils/reader.ts'
export { createWriter as writer } from './utils/writer.ts'
export type { Codec, EncodeOptions, DecodeOptions } from './codec.ts'

export interface Writer {
/**
Expand Down
8 changes: 4 additions & 4 deletions packages/protons-runtime/src/utils/reader.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { decodeUint8Array, encodingLength } from 'uint8-varint'
import { readFloatLE, readDoubleLE } from './float.js'
import { LongBits } from './longbits.js'
import * as utf8 from './utf8.js'
import type { Reader } from '../index.js'
import { readFloatLE, readDoubleLE } from './float.ts'
import { LongBits } from './longbits.ts'
import * as utf8 from './utf8.ts'
import type { Reader } from '../index.ts'
import type { Uint8ArrayList } from 'uint8arraylist'

/* istanbul ignore next */
Expand Down
10 changes: 5 additions & 5 deletions packages/protons-runtime/src/utils/writer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { encodeUint8Array, encodingLength } from 'uint8-varint'
import { allocUnsafe } from 'uint8arrays/alloc'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { writeFloatLE, writeDoubleLE } from './float.js'
import { LongBits } from './longbits.js'
import pool from './pool.js'
import * as utf8 from './utf8.js'
import type { Writer } from '../index.js'
import { writeFloatLE, writeDoubleLE } from './float.ts'
import { LongBits } from './longbits.ts'
import pool from './pool.ts'
import * as utf8 from './utf8.ts'
import type { Writer } from '../index.ts'

interface WriterOperation<T> {
(val: T, buf: Uint8Array, pos: number): any
Expand Down
2 changes: 1 addition & 1 deletion packages/protons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $ tsc
In your code import the generated classes and use them to transform to/from bytes:

```js
import { Foo } from './foo.js'
import { Foo } from './foo.ts'

const foo = {
message: 'hello world'
Expand Down
2 changes: 1 addition & 1 deletion packages/protons/bin/protons.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env node

import meow from 'meow'
import { generate } from '../src/index.js'
import { generate } from '../src/index.ts'

async function main (): Promise<void> {
const cli = meow(`
Expand Down
2 changes: 1 addition & 1 deletion packages/protons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* In your code import the generated classes and use them to transform to/from bytes:
*
* ```js
* import { Foo } from './foo.js'
* import { Foo } from './foo.ts'
*
* const foo = {
* message: 'hello world'
Expand Down
16 changes: 7 additions & 9 deletions packages/protons/test/compatibility.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/* eslint-env mocha */

import fs from 'fs'
import { expect } from 'aegir/chai'
import Long from 'long'
import pbjs from 'pbjs'
import protobufjs from 'protobufjs'
import { Basic, Empty } from './fixtures/basic.js'
import { Message as Bitswap } from './fixtures/bitswap.js'
import { CircuitRelay } from './fixtures/circuit.js'
import { Optional, OptionalEnum } from './fixtures/optional.js'
import { Peer } from './fixtures/peer.js'
import { Singular, SingularEnum } from './fixtures/singular.js'
import { AllTheTypes, AnEnum } from './fixtures/test.js'
import { Basic, Empty } from './fixtures/basic.ts'
import { Message as Bitswap } from './fixtures/bitswap.ts'
import { CircuitRelay } from './fixtures/circuit.ts'
import { Optional, OptionalEnum } from './fixtures/optional.ts'
import { Peer } from './fixtures/peer.ts'
import { Singular, SingularEnum } from './fixtures/singular.ts'
import { AllTheTypes, AnEnum } from './fixtures/test.ts'
import type { Type as PBType } from 'protobufjs'

function longifyBigInts (obj: any): any {
Expand Down
4 changes: 1 addition & 3 deletions packages/protons/test/custom-options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { CustomOptionNumber, CustomOptionString } from './fixtures/custom-option-jstype.js'
import { CustomOptionNumber, CustomOptionString } from './fixtures/custom-option-jstype.ts'

describe('custom options', () => {
it('should allow overriding 64 bit numbers with numbers', () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/protons/test/maps.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import Long from 'long'
import protobufjs from 'protobufjs'
import { MapTypes } from './fixtures/maps.js'
import type { SubMessage, EnumValue } from './fixtures/maps.js'
import { MapTypes } from './fixtures/maps.ts'
import type { SubMessage, EnumValue } from './fixtures/maps.ts'

function longifyBigInts (obj: any): any {
const output = {
Expand Down
2 changes: 0 additions & 2 deletions packages/protons/test/oneof.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import Long from 'long'
import protobufjs from 'protobufjs'
Expand Down
4 changes: 1 addition & 3 deletions packages/protons/test/proto2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { MessageWithRequired } from './fixtures/proto2.js'
import { MessageWithRequired } from './fixtures/proto2.ts'

describe('proto2 support', () => {
it('should write a required field with a default value', () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/protons/test/protons-options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { MessageWithSizeLimitedMap, MessageWithSizeLimitedRepeatedField } from './fixtures/protons-options.js'
import { MessageWithSizeLimitedMap, MessageWithSizeLimitedRepeatedField } from './fixtures/protons-options.ts'

describe('protons options', () => {
it('should not decode message with map that is too big', () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/protons/test/repeated.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { RepeatedTypes } from './fixtures/repeated.js'
import { RepeatedTypes } from './fixtures/repeated.ts'

describe('repeated', () => {
it('should encode repeated fields', () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/protons/test/unsupported.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { generate } from '../src/index.js'
import { generate } from '../src/index.ts'

describe('unsupported', () => {
it('should refuse to generate source from proto2 definition', async () => {
Expand Down
Loading