2016-09-17 26 views
1

でDDPを使用して、私は拡張子から流星サーバーに接続したいウィンドウをポップアップ、ユーザ登録、ログインおよび私が構築していChromeの拡張機能でChromeの拡張機能

のために私はからの簡単な説明を見つけましたMeteor Spotting from 2014これは、ddp.jsを使用してこれを実行することが可能であることを示していますが、説明されているプロジェクトは消えているようです。

現在のバージョンddp.jsは、Chromeが対応するimportステートメントを使用しています。私の理解では、これらのスクリプトはNode.js向けに設計されています。これらのスクリプトを、Meteor Spottingの記事に記載されているChrome拡張機能で使用できるように編集するにはどうすればよいですか?

また、私はインスピレーションのために使うことができるベアボーンのMeteorサーバーとDPPを介して接続するベアボーンChrome拡張の例はありますか?

答えて

3

私自身の解決策を見つけました。ここでChrome拡張機能から流星サーバへのコールの最低限の実装である:

manifest.jsonを { "manifest_version":2のjQuery-3.1.0.jsをすることができる

, "name": "DDP Test" 
, "version": "0.1" 

, "background": { 
    "scripts": [ 
     "jquery-3.1.0.js" 
    , "meteor-ddp.js" 
    , "meteor.js" 
    , "background.js" 
    ] 
    } 
} 

流星-ddp.jsは(Meteor Spottingから適応)here

meteor.js

を見出すことができる here
eddfirsを発見

background.js

拡張がロードされているサーバーのコンソールで
;(function background(){ 
    "use strict" 

    Meteor.call("test", 1, "two", { three: [4]}) 
    Meteor.call("test", "using", "a", "custom", callback) 

    function callback(error, result) { 
    console.log("Custom callback error:", error, ", Result:", result) 
    } 
})() 

出力:

Connected! 
meteor.js:18 Result of test call: null test method activated with arguments {"0":1,"1":"two","2":{"three":[4]}} 
meteor.js:25 Connected! 
background.js:8 Custom callback error: null , Result: test method activated with arguments {"0":"using","1":"a","2":"custom"} 
:背景ビューのインスペクタで

I20160917-19:35:19.352(-4)? test 1 two { three: [ 4 ] } 
I20160917-19:35:19.377(-4)? test using a custom 

出力

関連する問題