Giter Club home page Giter Club logo

plugin's People

Contributors

popham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plugin's Issues

Readme instruction does not work.

npm install --save-dev @capnp-js/plugin
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for @capnp-js/plugin

Tried to install from git like this.

npm install --save-dev capnp-js/plugin

Gives me a different error.

npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for @capnp-js/plugin

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\megab\AppData\Roaming\npm-cache\_logs\2019-05-10T15_23_42_566Z-debug.log
PS D:\Source\OperationSpatial\capnp-to-jsbuffer> npm install --save-dev capnp-js/plugin
npm WARN [email protected] No repository field.

npm ERR! path D:\Source\OperationSpatial\capnp-to-jsbuffer\node_modules\@capnp-js\plugin\lib\bin\flow.js
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod 'D:\Source\OperationSpatial\capnp-to-jsbuffer\node_modules\@capnp-js\plugin\lib\bin\flow.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Downloading and manually putting in node_modules in a @capnp-js directory is not found when trying to require it in.

Error: Cannot find module '@capnp-js/trans-readable'

Example:

const { Readable } = require("@capnp-js/trans-readable")

I am wanting to build a plugin for capnp compiler with node.js.

Code generation with syntax errors

Hi,

I get syntax errors in the generated code based on your rtc-github-protocol project.
What I did:

  1. Cloned the repo. I noticed that it comes with already generated code (in amd folder).
  2. I cleaned the project: npm run clean
  3. I wanted to regenerate the code, so I installed the plugin locally: npm install capnp-js-plugin.
    It worked, I got a few warnings but nothing serious:
    install_plugin
  4. Then I compiled the schemas: npm run compileMySchema
    I got this error:
    compile_schema
  5. And as a result the generated files have syntax error (I only checked user.capnp.d/readers.js, lines 21 - 25):
    generated_js

I thought it is due to the unions, but in user.capnp, there are no unions, so even this fails on my pc.
I was using io.js v2.4.0 (npm v2.13.0) and then node v0.12.7 (npm v2.11.3), same problem.
Can you please help me in finding out what can go wrong here?

Working example

Hi,

Would it be possible to have a simple working example that shows how to create/read a message?

Cannot find module './lib/reader/rTypes' during schema compilation

After building the compiler, I try to compile a simple schema with the command:
$ capnp compile -ojs /home/adam/request.capnp

But it gives me this error:
module.js:338
throw err;
^
Error: Cannot find module './lib/reader/rTypes'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/usr/local/lib/node_modules/capnp-js-plugin/index.js:1:80)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
js: plugin failed: exit code 1

It is clear to me that this rTypes module is required in the index.js of the plugin module itself, but I cannot find it anywhere.
It may be relevant that I have an NPM warning during building of the plugin:
npm WARN optional dep failed, continuing [email protected]
image

I use Ubuntu 12.04 32-bit. Any help would be appreciated.

v0.4.0 not available via NPM

After running into #11 I realized that there's also capnp-js-plugin available as a package from the regular NPM registry. Unfortunately that one is still stuck on v0.2.11.

Supported Node Version

Hi
Which node version supported for this plugin ? It didn't mention in README.

I assume version 8.9 ? is that correct?

Thanks
Reza

Remove unreferenced builder and reader import aliases (file0, ...)

Generated builder.js and reader.js files assign aliases to other builders and readers that they import. These imports exist for their side-effects. They assure that prototypes get populated on user import (see reader/readers.dust and builder/builders.dust). As built, Nodefy yields var file0 = require('someSchema.capnp.d/reader').

Removing the file0 alias, Nodefy generates no require, missing the sought side-effects at runtime. Miller sounds open to a pull request that would provide require('someSchema.capnp.d/reader') without the var file0 = bit. That change is blocking this issue.

Plugin uses master branch of CapnProto lib

Hi,

I noticed that the plugin uses the master branch of CapnProto c++ lib, which seems to be the branch where the active development is being done (currently 0.6-dev, last commit was 2 days ago):

Taken from installCompiler.js:
var git = spawn('git', [
'clone',
'--branch', 'master',
'--depth', '1',
'https://github.com/kentonv/capnproto.git',
'compiler'
]);

The latest release is 0.5.3, which I would like to use if possible.
Is it on purpose?
Do you think it is safe to link against this release branch?

Builder `AnyValue.getAs` doesn't upgrade stale structs

Generated builder struct ctors contain a fromAny method that uses builder-core's RefedStruct.fromAny, but this function doesn't take any metadata to describe the struct that's being used. That metadata is needed to upgrade the value in the case of a stale struct. I anticipate that the signature of RefedStruct.fromAny should be (guts: AnyGutsB, bytes: Bytes) instead of its current (guts: AnyGutsB).

Whoops. The late upgrade will need to clobber the source pointer with the upgraded value's location instead of the stale value's location. This is a catastrophe. How about an upgradeSomeField(struct: StructCtor): void method for AnyPointer fields, where AnyValue's getAs throws for stale structs? And should AnyValue expose a getAsReader method that doesn't sweat staleness?

Given an AnyPointer field occupied by a struct pointer with 8 bytes in its data section and 8 bytes in its pointers section, I want to wrap an upgrade of that struct around this struct pointer's data. Calling upgradeSomeField(UpgradedStruct) clones the 8 bytes and 8 bytes into a sufficiently wide object and then it updates the pointer to target the new object. Fine.

Calling upgradeSomeField on an AnyPointer that references a List(Bool) should error at runtime.

What about an inline composite list? Suppose that I've got a list of stale structs (or basic data types) and I want builder access to the list elements as fresh structs. Again I've got to upgrade, but this time should structs(UpgradedStruct) parametrize upgradeSomeField instead of UpgradedStruct? Or maybe the upgradeSomeField method upgrades all list pointers to an inline composite list pointer for the UpgradedStruct width, whereas the upgradeSomeField method upgrades all struct pointers to a widened struct pointer? The user is going to be parametrizing getAs with structs(UpgradedStruct), so I see no downside in using this value to parametrize upgradeSomeField in the inline composite list case. I prefer this handling because unexpected pointer types within an AnyPointer field will get discovered sooner rather than later.

Conclusion: Given an AnyPointer field named "SomeField," the struct's builder exposes

upgradeSomeField<R: {+guts: StructGutsR}, B: ReaderCtor<StructGutsR, R>>(
  type: StructCtorB<R, B> | StructListCtorB<R, B>
): void { /* ... */ }

What about a generic parametrized field with an AnyPointer binding? How do I upgrade such a field? I think that I need to expose an upgradeSomeField analogue for generic parametrized fields, but calling this method for non-AnyPointer bindings is goofy.

Unions unsupported?

I get this error with any capnp using unions:

% capnp compile -ojs union.capnp
Dust rendering error: Error: Template Not Found: [object Object],builders/union/bit

Here is a sample .capnp reproducing the issue:

@0xb7a9f7a90ff6bddd;

struct Test {
    union {
        a @0 :Bool;
        b @1 :Text;
    }
}

Is there any plan to support unions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.