Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pelagiccreatures/sargasso

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pelagiccreatures/sargasso - npm Package Compare versions

Comparing version 0.5.21 to 0.5.22

dist/sargasso.cjs.js

156

lib/dependencies.js

@@ -1,159 +0,9 @@

import camelCase
from './lodash-modularize/camelCase.js'
import camelCase from 'lodash/camelCase'
import debounce
from './lodash-modularize/debounce.js'
import debounce from 'lodash/debounce'
// does not play well with rollup yet. TODO: revisit once js-cookie ES out of beta
let Cookies
import Cookies from 'js-cookie'
/*!
* JavaScript Cookie v2.2.1
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;
(function (factory) {
Cookies = factory()
}(function () {
function extend () {
var i = 0
var result = {}
for (; i < arguments.length; i++) {
var attributes = arguments[i]
for (var key in attributes) {
result[key] = attributes[key]
}
}
return result
}
function decode (s) {
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent)
}
function init (converter) {
function api () {}
function set (key, value, attributes) {
if (typeof document === 'undefined') {
return
}
attributes = extend({
path: '/'
}, api.defaults, attributes)
if (typeof attributes.expires === 'number') {
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5)
}
// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''
try {
var result = JSON.stringify(value)
if (/^[\{\[]/.test(result)) {
value = result
}
} catch (e) {}
value = converter.write ? converter.write(value, key) : encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent)
key = encodeURIComponent(String(key))
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
.replace(/[\(\)]/g, escape)
var stringifiedAttributes = ''
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue
}
stringifiedAttributes += '; ' + attributeName
if (attributes[attributeName] === true) {
continue
}
// Considers RFC 6265 section 5.2:
// ...
// 3. If the remaining unparsed-attributes contains a %x3B (";")
// character:
// Consume the characters of the unparsed-attributes up to,
// not including, the first %x3B (";") character.
// ...
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0]
}
return (document.cookie = key + '=' + value + stringifiedAttributes)
}
function get (key, json) {
if (typeof document === 'undefined') {
return
}
var jar = {}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all.
var cookies = document.cookie ? document.cookie.split('; ') : []
var i = 0
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=')
var cookie = parts.slice(1).join('=')
if (!json && cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1)
}
try {
var name = decode(parts[0])
cookie = (converter.read || converter)(cookie, name) ||
decode(cookie)
if (json) {
try {
cookie = JSON.parse(cookie)
} catch (e) {}
}
jar[name] = cookie
if (key === name) {
break
}
} catch (e) {}
}
return key ? jar[key] : jar
}
api.set = set
api.get = function (key) {
return get(key, false /* read as raw */)
}
api.getJSON = function (key) {
return get(key, true /* read as json */)
}
api.remove = function (key, attributes) {
set(key, '', extend(attributes, {
expires: -1
}))
}
api.defaults = {}
api.withConverter = init
return api
}
return init(function () {})
}))
export {
camelCase, debounce, Cookies
}
{
"name": "@pelagiccreatures/sargasso",
"version": "0.5.21",
"version": "0.5.22",
"description": "Simple, Fast, Reactive, supervised Javascript controllers for html elements.",

@@ -29,2 +29,5 @@ "keywords": [

"@babel/preset-env": "^7.7.7",
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-json": "^4.0.1",
"@rollup/plugin-node-resolve": "^7.0.0",
"babel-loader": "^8.0.6",

@@ -44,2 +47,3 @@ "babel-plugin-lodash": "^3.3.4",

"dependencies": {
"js-cookie": "^2.2.1",
"lodash": "^4.17.15"

@@ -46,0 +50,0 @@ },

@@ -23,3 +23,2 @@ # @PelagicCreatures/Sargasso

```npm install @pelagiccreatures/sargasso```

@@ -36,16 +35,13 @@

[Most browsers](https://caniuse.com/#search=modules) are aware of ES6 and modules these days but but you can use the module/nomodule scheme to fall back to the common js bundle if needed.
```
<script type="module">
import from "https://cdn.jsdelivr.net/npm/@pelagiccreatures/sargasso/dist/sargasso.es.js"
<script type="module" src="https://cdn.jsdelivr.net/npm/@pelagiccreatures/sargasso/dist/sargasso.es.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@pelagiccreatures/sargasso/dist/sargasso.cjs.js" nomodule></script>
<script defer>
... your code here ...
</script>
// optional - deal with the antiques if yo see fit.
<script src="https://cdn.jsdelivr.net/npm/@pelagiccreatures/sargasso/dist/sargasso.common.js" nomodule></script>
<script nomodule defer>
... your code here ...
</script>
```
In production you probably want to host the bundles yourself instead of using the CDN and probably even make your own bundles including your subclasses using webpack or rollup or something.
In production you probably want to host the bundles yourself instead of using the CDN and probably even make your own bundles including your subclasses using webpack or rollup or something. See rollup section below.
For the '... your code here ...' part, it's the same in both cases. You need to at least start up the services.

@@ -90,2 +86,3 @@

New pages are loaded via AJAX and are merged with the current page only replacing elements marked with `data-hijax` from the new page.
```

@@ -114,3 +111,4 @@ <html>

Note that data-hijax elements must have well formed child html elements. Not like this:
Note that data-hijax elements must have well formed child html elements. **Not** like this:
```<div>I'm just text. No child elements. Won't work.</div>```

@@ -146,4 +144,6 @@

**Properties**
| property | description |

@@ -153,4 +153,6 @@ | ------ | ----------- |

**Utility Methods:**
| method | description |

@@ -166,2 +168,3 @@ | ------ | ----------- |

You need to let sargasso know about your class:

@@ -278,9 +281,50 @@ ```registerSargassoClass('MyClass', MyClass)```

### Viewing the Test Page in the example directory
### Rollup ES6 Bundling
To use Hijax you have to serve the files (window.popstate can't deal with file://...) so run SimpleHTTPServer in the project example directory to see demo page
While you can use the libs in /dist in you project you would typically want to bundle your own ES6 (and perhaps commonJS) bundles to serve with your pages.
The example below is for the /example directory pages.
rollup.config.app.js
```
import commonjs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
export default {
input: './example/app.js', // load the app root
output: [{
format: 'es',
file: './example/app-bundle.es.js' // output the bundle
}],
plugins: [
json(),
nodeResolve({
preferBuiltins: false
}),
commonjs({
namedExports: {}
})
]
}
```
Just run `rollup -c rollup.config.app.js` and you have an ES6 bundle which includes all your dependancies
### Example directory
To use Hijax you have to serve the files (window.popstate can't deal with file://...) so run SimpleHTTPServer in the project example directory to see demo pages which provide examples of how to integrate with html.
```
python -m localhost.py
```
then point your browser to `http://localhost:8000/index.html`
There are 3 entry points:
`http://localhost:8000/index.html` - use ES6 example.js app bundled with sargasso
`http://localhost:8000/index-cjs.html` - use common js library from /dist
`http://localhost:8000/index-es.html` - use ES6 library from /dist

@@ -8,3 +8,3 @@ const webpack = require('webpack')

output: {
filename: './sargasso.common.js'
filename: './sargasso.cjs.js'
},

@@ -11,0 +11,0 @@ name: 'antique',

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc