{"_id":"fittings","_rev":"267445","name":"fittings","description":"Framework provider for BigPipe","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"3rdeden","email":""}],"time":{"modified":"2023-06-28T11:49:39.000Z","created":"2015-03-04T08:09:41.903Z","1.2.0":"2015-03-16T08:27:37.531Z","1.1.1":"2015-03-10T13:11:05.913Z","1.1.0":"2015-03-07T04:40:36.602Z","1.0.1":"2015-03-06T01:38:37.914Z","1.0.0":"2015-03-05T06:21:32.124Z","0.0.0":"2015-03-04T08:09:41.903Z"},"users":{},"author":{"name":"Arnout Kazemier"},"repository":{"type":"git","url":"https://github.com/bigpipe/fittings"},"versions":{"1.2.0":{"name":"fittings","version":"1.2.0","description":"Framework provider for BigPipe","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/fittings"},"keywords":["bigpipe","fittings"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/fittings/issues"},"homepage":"https://github.com/bigpipe/fittings","dependencies":{"demolish":"1.0.x","diagnostics":"0.0.x","extendible":"0.1.x","replaces":"1.0.x","ultron":"1.0.x"},"devDependencies":{"assume":"1.1.x","bigpipe":"git+https://github.com/bigpipe/bigpipe","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"1.0.x"},"gitHead":"0e3a8c11313442ef075d71af60b4e99e6e0ef7d3","_id":"fittings@1.2.0","_shasum":"de038f64c55a7e10b691e2452c311ac64bd59353","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"de038f64c55a7e10b691e2452c311ac64bd59353","size":9584,"noattachment":false,"key":"/fittings/-/fittings-1.2.0.tgz","tarball":"http://name.csiicloud.com:7001/fittings/download/fittings-1.2.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:49.220Z","publish_time":1426494457531,"_cnpm_publish_time":1426494457531},"1.1.1":{"name":"fittings","version":"1.1.1","description":"Framework provider for BigPipe","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/fittings"},"keywords":["bigpipe","fittings"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/fittings/issues"},"homepage":"https://github.com/bigpipe/fittings","dependencies":{"demolish":"1.0.x","diagnostics":"0.0.x","extendible":"0.1.x","ultron":"1.0.x"},"devDependencies":{"assume":"1.1.x","bigpipe":"git+https://github.com/bigpipe/bigpipe","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"1.0.x"},"gitHead":"31bfa7044df3eb2b96fa4cdb086d10eb8abb4d28","_id":"fittings@1.1.1","_shasum":"fc21f4b9b1ca2b8b2e7c882d9d80698e780aa509","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"fc21f4b9b1ca2b8b2e7c882d9d80698e780aa509","size":8249,"noattachment":false,"key":"/fittings/-/fittings-1.1.1.tgz","tarball":"http://name.csiicloud.com:7001/fittings/download/fittings-1.1.1.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:48.337Z","publish_time":1425993065913,"_cnpm_publish_time":1425993065913},"1.1.0":{"name":"fittings","version":"1.1.0","description":"Framework provider for BigPipe","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/fittings"},"keywords":["bigpipe","fittings"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/fittings/issues"},"homepage":"https://github.com/bigpipe/fittings","dependencies":{"diagnostics":"0.0.x","extendible":"0.1.x"},"devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"1.0.x"},"gitHead":"66603aebcc17293d3de31d6843a658e08a10aa7e","_id":"fittings@1.1.0","_shasum":"bb511a061175dae178cae29a7f3ceed312936b94","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"bb511a061175dae178cae29a7f3ceed312936b94","size":6465,"noattachment":false,"key":"/fittings/-/fittings-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/fittings/download/fittings-1.1.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:47.420Z","publish_time":1425703236602,"_cnpm_publish_time":1425703236602},"1.0.1":{"name":"fittings","version":"1.0.1","description":"Framework provider for BigPipe","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/fittings"},"keywords":["bigpipe","fittings"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/fittings/issues"},"homepage":"https://github.com/bigpipe/fittings","dependencies":{"diagnostics":"0.0.4","extendible":"0.1.x"},"devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"1.0.x"},"gitHead":"6ffb49dc1c2c3264709ebba16eda3d79b0881d1a","_id":"fittings@1.0.1","_shasum":"aaa5816d0fc7d2a9d9e27d5f749a55a95d754951","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"aaa5816d0fc7d2a9d9e27d5f749a55a95d754951","size":5429,"noattachment":false,"key":"/fittings/-/fittings-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/fittings/download/fittings-1.0.1.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:46.559Z","publish_time":1425605917914,"_cnpm_publish_time":1425605917914},"1.0.0":{"name":"fittings","version":"1.0.0","description":"Framework provider for BigPipe","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/fittings"},"keywords":["bigpipe","fittings"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/fittings/issues"},"homepage":"https://github.com/bigpipe/fittings","dependencies":{"diagnostics":"0.0.4","extendible":"0.1.x"},"devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"1.0.x"},"gitHead":"75212e1a05b3309d1ba5226bccb7a60811b37ce9","_id":"fittings@1.0.0","_shasum":"40b87106a8495758b19362328e3e0dbe14b593d9","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"40b87106a8495758b19362328e3e0dbe14b593d9","size":3720,"noattachment":false,"key":"/fittings/-/fittings-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/fittings/download/fittings-1.0.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:45.672Z","publish_time":1425536492124,"_cnpm_publish_time":1425536492124},"0.0.0":{"name":"fittings","version":"0.0.0","description":"Framework provider for BigPipe","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/fittings"},"keywords":["bigpipe","fittings"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/fittings/issues"},"homepage":"https://github.com/bigpipe/fittings","dependencies":{"bigpipe.js":"0.9.x","extendible":"0.1.x"},"devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"1.0.x"},"_id":"fittings@0.0.0","_shasum":"83c24d9f8ae35fcae760b2a17f104c279e9a2d77","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"83c24d9f8ae35fcae760b2a17f104c279e9a2d77","size":2149,"noattachment":false,"key":"/fittings/-/fittings-0.0.0.tgz","tarball":"http://name.csiicloud.com:7001/fittings/download/fittings-0.0.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:44.809Z","publish_time":1425456581903,"_cnpm_publish_time":1425456581903}},"readme":"# fittings\n\n[![From bigpipe.io][from]](http://bigpipe.io)[![Version npm][version]](http://browsenpm.org/package/fittings)[![Build Status][build]](https://travis-ci.org/bigpipe/fittings)[![Dependencies][david]](https://david-dm.org/bigpipe/fittings)[![Coverage Status][cover]](https://coveralls.io/r/bigpipe/fittings?branch=master)\n\n[from]: https://img.shields.io/badge/from-bigpipe.io-9d8dff.svg?style=flat-square\n[version]: http://img.shields.io/npm/v/fittings.svg?style=flat-square\n[build]: http://img.shields.io/travis/bigpipe/fittings/master.svg?style=flat-square\n[david]: https://img.shields.io/david/bigpipe/fittings.svg?style=flat-square\n[cover]: http://img.shields.io/coveralls/bigpipe/fittings/master.svg?style=flat-square\n\nFittings allows you to easily fit different client-side frameworks in to\nBigPipe. It allows you to control:\n\n- Which frameworks/libraries should be loaded in on every page.\n- How the client/server-side shared templates should be exported and exposed on\n  the client.\n- Initialize the client-side plugins.\n- Bootstrap the loading of the page.\n- Control the structure of the HTML fragments that are written.\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n  - [Processing](#processing)\n    - [fittings.tag](#fittingstag)\n    - [fittings.template](#fittingstemplate)\n    - [fittings.plugins](#fittingsplugins)\n    - [fittings.bootstrap](#fittingsbootstrap)\n    - [fittings.fragment](#fittingsfragment)\n    - [fittings.library](#fittingslibrary)\n    - [fittings.middleware](#fittingsmiddleware)\n    - [fittings.use](#fittingsuse)\n    - [fittings.on](#fittingson)\n  - [API](#API)\n    - [fittings.get](#fittingsget)\n- [License](#license)\n\n## Install\n\nThis module is intended for server-side usage and is released in the public npm\nregistry. It can be installed by running the following command on the CLI:\n\n```\nnpm install --save fittings\n```\n\n## Usage\n\nThis part of the documentation focuses on implementing, adding a new Framework\nfor the BigPipe framework. To create your own framework you need to extend the\nreturned Fittings class as seen in the following example:\n\n```js\nvar Fittings = require('fittings');\n\nFittings.extend({\n  template: 'foo.bar[{fittings:hash}] = {fittings:client};',\n}).on(module);\n```\n\nThe `.on(module)` automatically registers framework for you on the module so you\ndon't need add `module.exports = ..` anymore. We also use it to extract the\ncurrent directory of your file so we can do relative file lookups etc.\n\nTo understand how you can specify the framework you need to know how we process\nyour instructions and which properties are used by BigPipe and what each\nproperty does.\n\n### Processing\n\nThe processing engine understands the set properties in two different ways: \n\n1. When the property is a function it will call the function with an object and\n   assumes that it returns a **string** that can be used.\n2. If it's a string it will our sophisticated template engine over it which\n   replaces all `{fittings:<key>}` with the value of `<key>` and returns the\n   newly generated string.\n\nThis applies to all properties except the library property as is processed in an\ncompletely different way:\n\n- If it's an Array, assumes that it should be left alone as is.\n- If it's a function it will execute it and assumes it returns an Array.\n- An object, which should have a `path` and `expose` property.\n- When it's a string that starts with `require('path').sep`, it assumes it's the\n  absolute path to a library that needs to be included and automatically wraps\n  it in an array.\n- Last case, it will attempt to the module systems module resolving method\n  (`require.resolve`) on the string to get the absolute path for the given\n  module.\n\nPlease do note that when you are using the **function** syntax that these\nfunctions will be called for every single page/pagelet that is processed by\nBigPipe. So try to keep these methods as light and fast as possible.\n\nThe template tags that we're using should be prefixed with `{fittings:` then the\nname of the property you want to add here and finally closing with the `}`\nagain.\n\n```\n{fittings:name}\n```\n\nWill output:\n\n```\njohn\n```\n\nIf the supplied data object contains `{ name: 'john' }`. We also support extracting deeply nested properties using a dot notation. For example:\n\n```\n{fittings:data.array.2.thing}\n```\n\nThis will says we should get the `data` property, which is an object and we want\nit's `array` property. This property contains an array and we want the second\nitem. The second item is also an object so we want the property `thing` as\ncontent.\n\nThe `:` char is a special data modifier instruction the modifier is the first\nnon word character that follows the fittings prefix. All our template tags are\nprocessed by the [replaces] module which supports a variety of data output\nmodifiers:\n\n- **`{fittings<>key}`** Make sure that the data we're trying to add to the\n  template is save\n  to use inside of HTML tags.\n- **`{fittings~key}`** Transform the receiving data in to a JSON.stringify\n  structure.\n- **`{fittings@key}`** Transform the receiving data in to a JSON.stringify\n  structure\n  **without** crashing on circular references like a normal stringify operation\n  would.\n- **`{fittings$key}`** Transform the data using the circular JSON parser and\n  ensure that every value inside the JSON is encoded using the `<>` modifier.\n- **`{fittings%key}`** Escape the data using the `escape` function.\n- Any other non `\\W` is just ignored and will indicated that the data should\n  just be pasted in as normal (like {fittings:key} is).\n\nYou can actually change the name and syntax of these placeholders as they are\nprocessed using a regular expression.\n\n#### fittings.tag\n\nThis is the regular expression that is used to find the special {fittings:what}\nkeywords in your templates. If want to use a custom syntax you can change this\nregular expression to anything you want as long as it follows the following\nrestrictions:\n\n- The first capturing group should be a modifier that is supported by the\n  [replaces] module.\n- The second capturing group is the name of the key or pattern that is used to\n  extract the data.\n\n#### fittings.template\n\nThe template should contain a small template which introduces the templates that\nis shared between client and server. This template receives 2 properties:\n\n- `name` Which is the name or md5 hash of library.\n- `client` which contains the template function that needs to be added (already\n  a string).\n\nAn example implementation could be:\n\n```js\nmylibrary.register({fittings~name}, {fittings:client});\n```\n\nWhich would result in to something like:\n\n```js\nmylibrary.register(\"0f8bf99b55994d676634fae81fff2405\", function (data) {\n  with (data) return '<div>your '+ name +'</div>';\n});\n```\n\n#### fittings.plugins\n\nKinda the same as the `fittings.template`, but instead of introducing templates\nyou're adding new plugins. Just like the template, it has a `name` and `client`\ntemplate key.\n\n#### fittings.bootstrap\n\nThe bootstrap property allows you to provide a small bootstrap template which\nwill be included by the [bootstrap-pagelet][bootstrap] as `bootstrap` property.\nThis template receives all the information of the bootstrap pagelet so you can\npass the amount pagelets the page expects to flush out etc.\n\n```html\n<script>\nvar BigPipe = require('bigpipe')\n  , pipe;\n\npipe = new BigPipe(undefined, { pagelets: {fittings:length}, id: {fittings~id} });\n</script>\n```\n\nPlease see [fittings.library](#fittingslibrary) on how to use `require` to\naccess your supplied libraries.\n\n#### fittings.fragment\n\nThis is the actual fragment that is written to the page when a pagelet is\nrendered.\n\nThis is the actual HTML fragment that is written to the page once a pagelet is\nrendering. It has the following template tags available:\n\n- `template` The HTML string that the pagelet generated. It has all\n  it's HTML comments removed so it should be save be added within a HTML comment\n  if needed.\n- `name` The name of pagelet that is flushing it's output.\n- `id` The unique id of this pagelet.\n- `data` Additional data object that the pagelet has generated which should be\n  synced to the client. See the Pagelet's internal render method for all various\n  of properties that this object contains.\n- `state` The state data that needs to be synced from server to client.\n\nAn example template could be:\n\n```html\n<script type=\"pagelet/html\" name={fittings~name} id={fittings~id}>\n  {fittings:template}\n</script>\n<script>render({fittings$data}, {fittings$state});</script>\n```\n\n#### fittings.library\n\nThe location of the client side libraries that should be included. As you might\nhave read in the [processing](#processing) section, there are many ways of\nspecifying the location of the libraries. The specified libraries will be passed\nin to Browserify by default. If you've set an object it will use the `expose`\nproperty to \"register\" it in the require method. If you passed it a full string\nit will use the file name as module name. This allows you to require the library\non the client side and initialize it anyway you want it.\n\n```js\nFittings.extend({\n  library: require('path').join(__dirname, 'file.extension'),\n  library: [require.resolve('module-name')],\n  library: {\n    path: require('path').join(__dirname, 'lib', 'whatever.extension'),\n    expose: 'woop'\n  }\n}).on(module);\n```\n\n#### fittings.middleware\n\nAdditional middleware layers that need to be added to the BigPipe server. This\nshould be an object where the key is the name of the middleware layer and the\nvalue is a pre-configured middleware layer.\n\n```js\nFittings.extend({\n  middleware: {\n    static: require('serve-static')(__dirname)\n  }\n}).on(module);\n```\n\n#### fittings.use\n\nAdditional plugins that need to be added to the BigPipe server. This should be\nan object where the key is the name of the plugin and the value is the required\nplugin:\n\n```js\nFittings.extend({\n  use: {\n    progress: require('bigpipe-progress')\n  }\n}).on(module);\n```\n\n#### fittings.on\n\nAdditional event that we listen on. We assume that this is an object where the\nkey is name of the event you want listen on and the value is the function that\nshould be executed for it. This uses the `EventEmitter#on` method internally so\nyour function will be called for each and every event.\n\n```js\nFittings.extend({\n  on: {\n    log: function (line) {\n      console.log(line);\n    }\n  }\n}).on(module);\n```\n\nPlease see the BigPipe framework documentation for the events that you can\nlisten for.\n\n#### fittings.initialize\n\nWhen you add an initialize function to fittings it will be called once a new\ninstance of the framework is created. It will receive the supplied BigPipe\ninstance as argument so you unlimited control.\n\n```js\nFittings.extend({\n  initialize: function initialize(bigpipe) {\n  }\n}).on(module);\n```\n\n### API\n\nThe library provides a small API for processing all the specified processing\ninstructions.\n\n#### fittings.get\n\nThis method processes the set instructions for the given property name. If it's\na function it will execute it, if it's a string it will replace all the things\netc. The method accepts 2 arguments:\n\n1. `property` The name of the property you want to have processed.\n2. `data` Optional data object which will be passed in the processing function\n   or used as replacement content for the `{fitting:*}` tags.\n\n```js\nvar Framework = Fittings.extend({\n  template: ..\n});\n\nvar f = new Framework(bigpipe);\n```\n\n## License\n\nMIT\n\n[bigpipe.js]: https://github.com/bigpipe/bigpipe.js\n[bootstrap]: https://github.com/bigpipe/bootstrap-pagelet\n[replaces]: https://github.com/bigpipe/replaces\n","_attachments":{},"homepage":"https://github.com/bigpipe/fittings","bugs":{"url":"https://github.com/bigpipe/fittings/issues"},"license":"MIT"}