Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: digitalbazaar/jsonld.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4ac1ffc0cfc09fdb2a29adb058c97d8adfcd9c64
Choose a base ref
...
head repository: digitalbazaar/jsonld.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9764d0ca453a22bbd909b350b4f90c65d5f448d9
Choose a head ref
Loading
Showing with 1,328 additions and 1,909 deletions.
  1. +80 −0 .github/workflows/main.yml
  2. +0 −25 .travis.yml
  3. +119 −0 CHANGELOG.md
  4. +23 −7 README.md
  5. +1 −0 karma.conf.js
  6. +25 −11 lib/ContextResolver.js
  7. +0 −140 lib/Rdfa.js
  8. +73 −104 lib/compact.js
  9. +3 −0 lib/constants.js
  10. +274 −41 lib/context.js
  11. +19 −6 lib/documentLoaders/node.js
  12. +17 −6 lib/documentLoaders/xhr.js
  13. +100 −12 lib/expand.js
  14. +310 −140 lib/frame.js
  15. +21 −3 lib/fromRdf.js
  16. +7 −0 lib/index.js
  17. +32 −28 lib/jsonld.js
  18. +12 −1 lib/nodeMap.js
  19. +15 −6 lib/toRdf.js
  20. +2 −1 lib/types.js
  21. +6 −6 lib/url.js
  22. +21 −19 lib/util.js
  23. +11 −10 package.json
  24. +5 −0 tests/.eslintrc.js
  25. +18 −8 tests/earl-report.js
  26. +3 −8 tests/misc.js
  27. +0 −20 tests/new-embed-api/frame-0001-frame.jsonld
  28. +0 −29 tests/new-embed-api/frame-0001-in.jsonld
  29. +0 −28 tests/new-embed-api/frame-0001-out.jsonld
  30. +0 −20 tests/new-embed-api/frame-0002-frame.jsonld
  31. +0 −29 tests/new-embed-api/frame-0002-in.jsonld
  32. +0 −25 tests/new-embed-api/frame-0002-out.jsonld
  33. +0 −20 tests/new-embed-api/frame-0003-frame.jsonld
  34. +0 −29 tests/new-embed-api/frame-0003-in.jsonld
  35. +0 −25 tests/new-embed-api/frame-0003-out.jsonld
  36. +0 −21 tests/new-embed-api/frame-0004-frame.jsonld
  37. +0 −40 tests/new-embed-api/frame-0004-in.jsonld
  38. +0 −38 tests/new-embed-api/frame-0004-out.jsonld
  39. +0 −24 tests/new-embed-api/frame-0005-frame.jsonld
  40. +0 −50 tests/new-embed-api/frame-0005-in.jsonld
  41. +0 −48 tests/new-embed-api/frame-0005-out.jsonld
  42. +0 −24 tests/new-embed-api/frame-0006-frame.jsonld
  43. +0 −73 tests/new-embed-api/frame-0006-in.jsonld
  44. +0 −89 tests/new-embed-api/frame-0006-out.jsonld
  45. +0 −35 tests/new-embed-api/frame-0007-frame.jsonld
  46. +0 −77 tests/new-embed-api/frame-0007-in.jsonld
  47. +0 −95 tests/new-embed-api/frame-0007-out.jsonld
  48. +0 −15 tests/new-embed-api/frame-0008-frame.jsonld
  49. +0 −52 tests/new-embed-api/frame-0008-in.jsonld
  50. +0 −40 tests/new-embed-api/frame-0008-out.jsonld
  51. +0 −65 tests/new-embed-api/manifest.jsonld
  52. +2 −2 tests/node-document-loader-tests.js
  53. +125 −312 tests/test-common.js
  54. +1 −0 tests/test-karma.js
  55. +1 −2 tests/test.js
  56. +2 −0 webpack.config.js
80 changes: 80 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Node.js CI

on: [push]

jobs:
test-node:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [8.x, 10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm install
- name: Fetch test suites
run: npm run fetch-test-suites
- name: Run test with Node.js ${{ matrix.node-version }}
run: npm run test-node
test-karma:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm install
- name: Fetch test suites
run: npm run fetch-test-suites
- name: Run karma tests
run: npm run test-karma
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Run eslint
run: npm run lint
coverage:
needs: [test-node, test-karma]
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm install
- name: Fetch test suites
run: npm run fetch-test-suites
- name: Generate coverage report
run: npm run coverage-ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage/lcov.info
fail_ci_if_error: true
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

119 changes: 119 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,124 @@
# jsonld ChangeLog

## 4.0.0 - 2021-02-11

### Removed
- **BREAKING**: RDFa parser moved to `jsonld-rdfa` package, remove `xmldom`
dependency.

## 3.3.1 - 2021-02-10

### Fixed
- Add `lru-cache` to packages run through babel for bundles. Fixes use of arrow
functions.

## 3.3.0 - 2021-01-21

### Changed
- Update `rdf-canonize` to 2.0.1.
- **NOTE**: The `rdf-canonize` update changes browser support and removes forge
in favor of the WebCrypto `crypto.subtle` API. A WebCrypto polyfill *may* be
required if a jsonld.js API is used that calls `rdf-canonize`. The polyfill
is needed if older browsers are targeted or when not using a secure context
on some modern browsers. Due to other concerns and the expected minimal
impact of this change, it is happening in a minor release. Please provide
feedback if this decision causes problems.
- Node.js 6 is no longer tested due to development tool dependency updates and
to avoid adding additional testing complexity. Node.js 6 will otherwise still
be supported until the next major release. Please report any issues found.

## 3.2.0 - 2020-10-13

### Fixed
- Empty-property scoped context should not effect the outer context. Note that
in situations where this fix is used there is now an extra clone of the
active context which could potentially cause performance issues.

## 3.1.1 - 2020-05-22

### Fixed
- Fix XHR document loader Link header processing.

## 3.1.0 - 2020-04-15

### Fixed
- Support recusrive scoped contexts.
- Various EARL report updates.
- Fixed `prependBase` to start path with a '/' for a zero length path
if there is an authority in base.

### Changed
- Better support for using a processed context for `null` and caching
`@import`.
- Don't set `@base` in initial context and don't resolve a relative IRI
when setting `@base` in a context, so that the document location can
be kept separate from the context itself.
- Use `package.json` `version` field for EARL reports.

## 3.0.1 - 2020-03-10

### Fixed
- Exclude `@type` from added values in Merge Node Maps step 2.2.1.

## 3.0.0 - 2020-03-10

### Notes
- This release adds support for a majority of JSON-LD 1.1. Significant thanks
goes to Gregg Kellogg!
- **BREAKING**: A notable change is that the framing `omitGraph` default
changed to match the JSON-LD 1.1 Framing spec. This is likely to cause issues
in most current uses of `frame()`. Result handling similar to
`framed['@graph'][0]` will have to be changed. Check your code.
- The spec calls for various situations to issue warnings. This is currently
done with `console.warn`. This will be replaced by a new event notification
API in an upcoming release.

### Fixed
- More support for `"@type": "@none"`.
- JSON literal value handling issues (`null` and `[]`).
- Always pass `typeScopedContext` to `_expandObject`.
- Allow a keyword to exist when expanding in `_expandObject` when the key is
`@included` or `@type`.
- Improve `isDouble` to look for big integers.
- URI `removeDotSegments` only ensures preceding '/' if was already absolute.
- Do minimal checking to see if IRIs are valid by making sure they contain no
whitespace.
- Terms of the form of an IRI must map to the same IRI.
- Terms of the form of a relative IRI may not be used as prefixes.
- Match spec error code "invalid context entry" vs "invalid context member".
- Keywords may not be used as prefixes.
- Handle term definition on `@type` with empty map.
- Handling of `@` values for `@reverse`.
- Changes in object embedding.
- Better support for graph framing.
- Better frame validation.
- Wildcard matching on `@id` and other `requireAll` semantics.
- Default frame for lists.
- Check unused scoped contexts for validity.

### Changed
- Keep term definitions mapping to null so they may be protected.
- **NOTE**: `LINK_HEADER_REL` in `lib/constants.js` has been deprecated and
renamed to `LINK_HEADER_CONTEXT`. It remains for now but will be removed in a
future release.
- Changed framing defaults
- `embed` to "@once" and warn on "@first" or "@last".
- `pruneBlankNodeIdentifiers` based on processingMode.
- `omitGraph` based on processingMode.
- Replaced `removePreserve` with `cleanupPreserve` and `cleanupNulls`.
- Remove unused framing `graphStack` code that was removed from the spec.

### Added
- Support for `"@import"`.
- Added support for `@included` blocks
- Skip things that have the form of a keyword, with warning.
- Support for expansion and compaction of values container `"@direction"`.
- Support for RDF transformation of `@direction` when `rdfDirection` is
'i18n-datatype'.
- Top level `@graph` omitted if `omitGraph` is `true`.
- Check for invalid values of `@embed`.
- Support default values for `@type` when framing.

## 2.0.2 - 2020-01-17

### Fixed
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
jsonld.js
=========

[![Build status](https://img.shields.io/travis/digitalbazaar/jsonld.js.svg)](https://travis-ci.org/digitalbazaar/jsonld.js)
[![Build status](https://img.shields.io/github/workflow/status/digitalbazaar/jsonld.js/Node.js%20CI)](https://github.com/digitalbazaar/jsonld.js/actions?query=workflow%3A%22Node.js+CI%22)
[![Coverage status](https://img.shields.io/codecov/c/github/digitalbazaar/jsonld.js)](https://codecov.io/gh/digitalbazaar/jsonld.js)
[![Dependency Status](https://img.shields.io/david/digitalbazaar/jsonld.js.svg)](https://david-dm.org/digitalbazaar/jsonld.js)

Introduction
@@ -83,7 +84,7 @@ yet supported.
Installation
------------

### node.js + npm
### Node.js + npm

```
npm install jsonld
@@ -146,7 +147,7 @@ import {promises} from 'jsonld';
import {JsonLdProcessor} from 'jsonld';
```

### node.js native canonize bindings
### Node.js native canonize bindings

For specialized use cases there is an optional [rdf-canonize-native][] package
available which provides a native implementation for `canonize()`. It is used
@@ -288,7 +289,7 @@ const CONTEXTS = {
}, ...
};

// grab the built-in node.js doc loader
// grab the built-in Node.js doc loader
const nodeDocumentLoader = jsonld.documentLoaders.node();
// or grab the XHR one: jsonld.documentLoaders.xhr()

@@ -390,14 +391,28 @@ Remote context tests are also available:

JSONLD_TESTS=`pwd`/tests npm test

To generate earl reports:
To generate EARL reports:

# generate the earl report for node.js
# generate the EARL report for Node.js
EARL=earl-node.jsonld npm test

# generate the earl report for the browser
# generate the EARL report for the browser
EARL=earl-firefox.jsonld npm run test-karma -- --browser Firefox

To generate an EARL report with the `json-ld-api` and `json-ld-framing` tests
as used on the official [JSON-LD Processor Conformance][] page

JSONLD_TESTS="`pwd`/../json-ld-api/tests `pwd`/../json-ld-framing/tests" EARL="jsonld-js-earl.jsonld" npm test

The EARL `.jsonld` output can be converted to `.ttl` using the [rdf][] tool:

rdf serialize jsonld-js-earl.jsonld --output-format turtle -o jsonld-js-earl.ttl

Optionally follow the [report
instructions](https://github.com/w3c/json-ld-api/tree/master/reports) to
generate the HTML report for inspection. Maintainers can
[submit](https://github.com/w3c/json-ld-api/pulls) updated results as needed.

Benchmarks
----------

@@ -428,6 +443,7 @@ Use a command line with a test suite and a benchmark flag:
[JSON-LD WG Framing latest]: https://w3c.github.io/json-ld-framing/
[JSON-LD WG latest]: https://w3c.github.io/json-ld-syntax/

[JSON-LD Processor Conformance]: https://w3c.github.io/json-ld-api/reports
[JSON-LD WG]: https://www.w3.org/2018/json-ld-wg/
[JSON-LD]: https://json-ld.org/
[Microdata]: http://www.w3.org/TR/microdata/
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ module.exports = function(config) {
// include specific packages
include: [
/(node_modules\/canonicalize)/,
/(node_modules\/lru-cache)/,
/(node_modules\/rdf-canonize)/
]
}],
Loading