{"_id":"@granite-elements/granite-yaml","_rev":"4-f5ecc52eaed6a309326f17f726322a54","name":"@granite-elements/granite-yaml","dist-tags":{"latest":"3.0.0"},"versions":{"2.0.0":{"name":"@granite-elements/granite-yaml","version":"2.0.0","license":"Apache-2.0","_id":"@granite-elements/granite-yaml@2.0.0","maintainers":[{"name":"lostinbrittany","email":"horacio.gonzalez@gmail.com"}],"homepage":"https://github.com/LostInBrittany/granite-yaml","bugs":{"url":"https://github.com/LostInBrittany/granite-yaml/issues"},"dist":{"shasum":"c82a4bb459ed8ad5d42040baec4542c86b126510","tarball":"https://registry.npmjs.org/@granite-elements/granite-yaml/-/granite-yaml-2.0.0.tgz","fileCount":15,"integrity":"sha512-1Om0MQyKjlVfVe302mGHr2MqId3aiON/edSSTbQ+HZ3MZVCHw6c7J/BTvDmsHdEI8BCVa7nvR/vJDF5zxOdTRg==","signatures":[{"sig":"MEUCIHoYwoq8bCkcgMmzIha9Rg0EfwIlVrdqEDsFyFK+lQRoAiEA616XgPxB3k0aArfNQLs7Gqp0YuHOT8t5WhzbvGXgqZE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":206033,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbaY3DCRA9TVsSAnZWagAAK/wP/1YQIPW9PRkGqPzpiSik\nh42xSm7L+L5mc61897A8Db5NanErRPZuhArnYjY+GPma+uIafFKQlfxdmaF4\n5ojxmagny6H8BimP65mSRj2VDEDqp6++oKbEyu62eK1n7EMhtgJUv0RinvWW\nVpDZYJ9vGCwZHMCHoHmr/KEYBPQVfIEhF+xxqk/AJmfkw5tFUDUcBaaoaYOc\nluKVj8go77Tk8Mu64l+Cq7zl/8eylYFP52nSwsu2nIJEeSgjS+/p8zn7gJJD\npPg2ME2HMLAu8v+eYmvYcsUQQ9kU6QBpUvgeDYxQSv96/pyXXxrkz4Rlrna7\nNtGpl/JkabWfZy7xtdtPmjaK4v5NaFO7xQYS3WarGfD3If3MqNXS+0Jb7GD3\nKcVQ5/BtOoK/iYFglUE3oZ8L4aCRC7/smrb50vWFu6BDUuA4t+v9x8DxO9f1\nnVcZvBLoxxJwuJDOl58hbcZYss+oXc/KqLlZxweSm5YXhpHxKoW5FWXN/TVk\n7VQhNdoC5fEflQL1RBszH4xfmP76tE/VRq/QfvibxFVb0tLU4qZ13A4HmvoC\neML15RGqfHuhZP3U9loKeQqc9pT6CcIpNi3pWC64L6eOy96OuckrovfRS8SZ\nNWuBRqeYcw9MoyX7l9NO5cbObqbIBKegynq4RnfTHD709HgOV44u4GsaNHJK\nijDQ\r\n=awru\r\n-----END PGP SIGNATURE-----\r\n"},"main":"granite-yaml-parser.js","gitHead":"01ae1a1fbf200c017d7be06e0734713e0e03be1b","_npmUser":{"name":"lostinbrittany","email":"horacio.gonzalez@gmail.com"},"repository":{"url":"git+https://github.com/LostInBrittany/granite-yaml.git","type":"git"},"_npmVersion":"6.3.0","description":"A set of Custom Elements to deal with YAML files","directories":{},"resolutions":{"samsam":"1.1.3","inherits":"2.0.3","type-detect":"1.0.0","supports-color":"3.1.2","@webcomponents/webcomponentsjs":"2.0.0-beta.2"},"_nodeVersion":"8.9.4","dependencies":{"js-yaml":"^3.12.0","@polymer/polymer":"^3.0.0","@polymer/iron-ajax":"^3.0.0-pre.18"},"_hasShrinkwrap":false,"devDependencies":{"@polymer/iron-icon":"^3.0.0-pre.18","wct-browser-legacy":"^0.0.1-pre.11","@polymer/iron-icons":"^3.0.0-pre.18","@polymer/iron-demo-helpers":"^3.0.0-pre.18","@polymer/iron-component-page":"^3.0.0-pre.18","@webcomponents/webcomponentsjs":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/granite-yaml_2.0.0_1533644219912_0.8993642029925053","host":"s3://npm-registry-packages"}},"2.0.1":{"name":"@granite-elements/granite-yaml","version":"2.0.1","license":"Apache-2.0","_id":"@granite-elements/granite-yaml@2.0.1","maintainers":[{"name":"lostinbrittany","email":"horacio.gonzalez@gmail.com"}],"homepage":"https://github.com/LostInBrittany/granite-yaml","bugs":{"url":"https://github.com/LostInBrittany/granite-yaml/issues"},"dist":{"shasum":"1b346fbd4a9829ac036ae65105b46b7912cd87b6","tarball":"https://registry.npmjs.org/@granite-elements/granite-yaml/-/granite-yaml-2.0.1.tgz","fileCount":15,"integrity":"sha512-Y9s2D1ICX5YdhXZNQDJwk0yUWd2QjHKKIaSBA2PllM4FXdpOLn0DbgTZMZfav1R6AQU95iVsWEARS73YNMzeig==","signatures":[{"sig":"MEQCICCsjs8N3RLOCFjWMspxHdkKLx0bN7iUi/nRQk12dim3AiA5cgcqNG/np8cS/WGxp8vW4l9ipjZ+sP1dvXXUxMxQeQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":206053,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbaY6ACRA9TVsSAnZWagAA5iYP/3YM6mIu4gEPXwULjZMs\nOfQhNtun4XFSogy2NeUswYav3MNHZ6aUw7ZwGhzzVSf2ntkHCqfFLIQE03Dx\nSqv+opZAfQcM54/9Xkq/Z/4W7dEfD0O8UsUHQuuGWywXPfN3oRBnbE+VZZnS\nvmbc1/SVOMWI6A7f7iKmawILh2jbi+4ba6mGzISSchl+Y/CDTwwt8Sk98jUa\nVueTfO8/wTw5r0JIpWIAAHgrCP0GE2Neny/8qUBW7b8I5U6KHS7ONjFD6Pix\n873UGUsdXVnzRQ+i7yxqZnYp1ZfFSaevjXHsQXe64GEZ+4NzrShRPfJoGbgw\nTgyMQKUlLTZAFxCQFwSP8LDMlj/oe/fqHpISnofWS3EgnKrmOT8JuKzCgBsW\nZjk8Ue5POhoceXTX+bOa7J3AAsmH6hl7De08mPnb3fWQiJGLveWzyVCRTE1d\n5OXr79M/wbmLdEIHmoRQMAg5nCFc75XfyA77mUIbUsOexMJm4opT/zpNzNav\njV0lPy6VJfIR8MIie4bhWENZsb/a58nEMdnO24RNzuD/pRceohjN0haxag3B\nqPbq9LfKxh5ZiOqDxvK0p1EPHd7DWVhRaLgAxuUrbqdEO02UOwpD11e/7PRc\neAVzjbMDRustT+4B4Ic1rZX73RKR18fDXPpks8+5Nrbe7I6cyl9qiTCWpKoQ\nD6Z1\r\n=WJov\r\n-----END PGP SIGNATURE-----\r\n"},"main":"granite-yaml-parser.js","gitHead":"079a33b1052d207796c8cc1e58d4d0f96a7ea6ef","_npmUser":{"name":"lostinbrittany","email":"horacio.gonzalez@gmail.com"},"repository":{"url":"git+https://github.com/LostInBrittany/granite-yaml.git","type":"git"},"_npmVersion":"6.3.0","description":"A set of Custom Elements to deal with YAML files","directories":{},"resolutions":{"samsam":"1.1.3","inherits":"2.0.3","type-detect":"1.0.0","supports-color":"3.1.2","@webcomponents/webcomponentsjs":"2.0.0-beta.2"},"_nodeVersion":"8.9.4","dependencies":{"js-yaml":"^3.12.0","@polymer/polymer":"^3.0.0","@polymer/iron-ajax":"^3.0.0-pre.18"},"_hasShrinkwrap":false,"devDependencies":{"@polymer/iron-icon":"^3.0.0-pre.18","wct-browser-legacy":"^0.0.1-pre.11","@polymer/iron-icons":"^3.0.0-pre.18","@polymer/iron-demo-helpers":"^3.0.0-pre.18","@polymer/iron-component-page":"^3.0.0-pre.18","@webcomponents/webcomponentsjs":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/granite-yaml_2.0.1_1533644415779_0.2992834707672769","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"@granite-elements/granite-yaml","version":"3.0.0","description":"A set of web components to parse YAML files into JS objects","main":"granite-yaml-parser.js","module":"granite-yaml-parser.js","type":"module","scripts":{"start":"web-dev-server --open demo/ --node-resolve --watch"},"dependencies":{"js-yaml":"^4.1.0"},"devDependencies":{"@web/dev-server":"^0.4.6"},"keywords":["web-component","web-components","custom-element","lostinbrittany","yaml","parser","js-yaml"],"author":{"name":"Horacio Gonzalez","email":"horacio.gonzalez@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/LostInBrittany/granite-yaml.git"},"homepage":"https://github.com/LostInBrittany/granite-yaml","gitHead":"6520c66604c841887b85c44c5c08e2acc778aa36","_id":"@granite-elements/granite-yaml@3.0.0","bugs":{"url":"https://github.com/LostInBrittany/granite-yaml/issues"},"_nodeVersion":"24.4.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-+HScPNGep17nGXqxTtTsOW1PEszv3En2uWH/FtRve/5t7ec+Zny0828Dl4Ty5oxnnS0gqwe/UnOl7zR31iboZA==","shasum":"be23c9781aad55401ad865386364a644abb4534b","tarball":"https://registry.npmjs.org/@granite-elements/granite-yaml/-/granite-yaml-3.0.0.tgz","fileCount":5,"unpackedSize":21704,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDU3m8HMxIpfDvpbhMwyXIAADVj7ox82zhSFLanO5o6kgIhAOVaazDf7djfE069s2c/3EBe8vqhLbHbMDAD6IP+NWZv"}]},"_npmUser":{"name":"lostinbrittany","email":"horacio.gonzalez@gmail.com"},"directories":{},"maintainers":[{"name":"lostinbrittany","email":"horacio.gonzalez@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/granite-yaml_3.0.0_1780738806094_0.6984604273923409"},"_hasShrinkwrap":false}},"time":{"created":"2018-08-07T12:16:59.673Z","modified":"2026-06-06T09:40:06.402Z","2.0.0":"2018-08-07T12:16:59.992Z","2.0.1":"2018-08-07T12:20:16.601Z","3.0.0":"2026-06-06T09:40:06.259Z"},"bugs":{"url":"https://github.com/LostInBrittany/granite-yaml/issues"},"license":"MIT","homepage":"https://github.com/LostInBrittany/granite-yaml","repository":{"type":"git","url":"git+https://github.com/LostInBrittany/granite-yaml.git"},"description":"A set of web components to parse YAML files into JS objects","maintainers":[{"name":"lostinbrittany","email":"horacio.gonzalez@gmail.com"}],"readme":"# granite-yaml\n\n> A set of web components to parse YAML files into JS objects, based on\n> [js-yaml](https://github.com/nodeca/js-yaml)\n>\n> Vanilla custom elements, no framework needed\n\nAvailable elements:\n\n- `granite-yaml-parser`: parses a YAML text into a JS object\n- `granite-yaml-remote-parser`: fetches a YAML file from an URL and parses it\n  into a JS object\n\n## Doc & demo\n\n[https://lostinbrittany.github.io/granite-yaml](https://lostinbrittany.github.io/granite-yaml)\n\n## Usage example\n\n```html\n<granite-yaml-parser yaml=\"aNumber: 42\"></granite-yaml-parser>\n```\n\n```html\n<granite-yaml-remote-parser url=\"./assets/aYamlFile.yml\" auto></granite-yaml-remote-parser>\n```\n\nBoth elements are non-visual: they parse the YAML and expose the result via\nthe read-only `obj` property and the `yaml-parsed` event.\n\n## Install\n\nInstall the component using [npm](https://www.npmjs.com/):\n\n```sh\nnpm install @granite-elements/granite-yaml\n```\n\n## Usage\n\n1. Import the custom element:\n\n    ```html\n    <script type=\"module\" src=\"node_modules/@granite-elements/granite-yaml/granite-yaml-parser.js\"></script>\n    ```\n\n    Or from JavaScript:\n\n    ```js\n    import '@granite-elements/granite-yaml/granite-yaml-parser.js';\n    ```\n\n    The elements import `js-yaml` as a bare module specifier, so use a bundler\n    or a dev server with node resolution — or an\n    [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap)\n    if you serve without a build step:\n\n    ```html\n    <script type=\"importmap\">\n      { \"imports\": { \"js-yaml\": \"https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/dist/js-yaml.mjs\" } }\n    </script>\n    ```\n\n2. Start using it!\n\n    ```html\n    <granite-yaml-parser id=\"parser\"></granite-yaml-parser>\n    <script>\n      const parser = document.getElementById('parser');\n      parser.addEventListener('yaml-parsed', (evt) => {\n        console.log(evt.detail.obj);\n      });\n      parser.yaml = 'aNumber: 42';\n    </script>\n    ```\n\nYou can also skip the elements and use the parsing helper directly:\n\n```js\nimport { parseYaml } from '@granite-elements/granite-yaml/granite-yaml-parser.js';\n\nconst obj = parseYaml('aNumber: 42');\n```\n\n## API\n\n### granite-yaml-parser\n\n#### Attributes / properties\n\n| Attribute | Property | Type | Default | Description |\n|---|---|---|---|---|\n| `yaml` | `yaml` | `String` | `''` | The YAML text to parse. Setting it triggers parsing |\n| `multi-document` | `multiDocument` | `Boolean` | `false` | If `true`, parsing deals with multi-document sources and `obj` is `{ documents: [...] }` |\n| `debug` | `debug` | `Boolean` | `false` | If `true`, debug logs are sent to the console |\n| — | `obj` | `Object` | — | The JS object resulting from parsing `yaml` (read-only) |\n\n#### Events\n\n| Event | Detail | Description |\n|---|---|---|\n| `yaml-parsed` | `{ yaml, obj }` | Fired when a YAML text has been parsed |\n| `yaml-error` | `{ yaml, error }` | Fired when parsing fails |\n\n### granite-yaml-remote-parser\n\n#### Attributes / properties\n\n| Attribute | Property | Type | Default | Description |\n|---|---|---|---|---|\n| `url` | `url` | `String` | `''` | The URL of the remote YAML file |\n| `auto` | `auto` | `Boolean` | `false` | If `true`, automatically performs a request when `url` changes |\n| `headers` | `headers` | `Object` | `{}` | HTTP request headers to send, as a JSON object in the attribute |\n| `with-credentials` | `withCredentials` | `Boolean` | `false` | If `true`, cookies are sent with cross-origin requests |\n| `timeout` | `timeout` | `Number` | `0` | Request timeout in milliseconds (`0` means no timeout) |\n| `multi-document` | `multiDocument` | `Boolean` | `false` | If `true`, parsing deals with multi-document sources and `obj` is `{ documents: [...] }` |\n| `debug` | `debug` | `Boolean` | `false` | If `true`, debug logs are sent to the console |\n| — | `obj` | `Object` | — | The JS object resulting from parsing the fetched YAML (read-only) |\n| — | `loading` | `Boolean` | — | `true` while a request is in flight (read-only) |\n\n#### Methods\n\n| Method | Description |\n|---|---|\n| `fetchYaml()` | Fetches the YAML file at `url` and parses it. Returns a Promise of the parsed object. A new call aborts any request still in flight |\n\n#### Events\n\n| Event | Detail | Description |\n|---|---|---|\n| `yaml-parsed` | `{ url, yaml, obj }` | Fired when the YAML file has been fetched and parsed |\n| `yaml-error` | `{ url, error }` | Fired when fetching or parsing fails |\n\n## Migrating from 2.x (Polymer 3)\n\nVersion 3.0 is a rewrite as dependency-light vanilla custom elements\n(js-yaml is the only runtime dependency).\n\n- No more Polymer: load with `<script type=\"module\">`, no polyfills needed\n- `granite-yaml-remote-parser` uses `fetch` instead of `iron-ajax`;\n  `generateRequest()` is replaced by `fetchYaml()`, and the `iron-ajax`\n  passthrough properties are gone\n- js-yaml 4.x parses safely by default, so the `unsafe` property is removed\n- Errors fire a `yaml-error` event instead of throwing\n\n## Running the demo locally\n\n```sh\nnpm install\nnpm run start\n```\n\nThis launches [@web/dev-server](https://modern-web.dev/docs/dev-server/overview/) and opens the demo in your browser.\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -m 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## License\n\n[MIT License](http://opensource.org/licenses/MIT)\n","readmeFilename":"README.md","keywords":["web-component","web-components","custom-element","lostinbrittany","yaml","parser","js-yaml"],"author":{"name":"Horacio Gonzalez","email":"horacio.gonzalez@gmail.com"}}