├── .babelrc
├── .editorconfig
├── .eslintrc.yml
├── .gitignore
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── docs
├── Graph_index.js.html
├── Node_index.js.html
├── fonts
│ ├── Lato-Regular.ttf
│ ├── OFL.txt
│ └── SourceCodePro-Regular.ttf
├── global.html
├── graph-crdt.module_Graph-Graph.html
├── graph-crdt.module_Graph.html
├── graph-crdt.module_Node-Node.html
├── graph-crdt.module_Node.html
├── index.html
├── scripts
│ ├── linenumber.js
│ └── prettify
│ │ ├── Apache-License-2.0.txt
│ │ ├── lang-css.js
│ │ └── prettify.js
├── styles
│ ├── ionicons.min.css
│ ├── jsdoc-default.css
│ ├── prettify-jsdoc.css
│ └── prettify-tomorrow.css
├── test-helpers.js.html
└── union_index.js.html
├── jsdoc.config.json
├── mocha.opts
├── package.json
├── src
├── Graph
│ ├── index.js
│ └── test.js
├── Node
│ ├── index.js
│ ├── merge.test.js
│ └── test.js
├── index.js
└── union
│ ├── index.js
│ └── test.js
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-2"],
3 | "plugins": ["transform-runtime"]
4 | }
5 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | # global file settings
4 | [*]
5 | end_of_line = lf
6 | insert_final_newline = true
7 | charset = utf-8
8 | indent_style = space
9 | indent_size = 2
10 | trim_trailing_whitespace = true
11 |
--------------------------------------------------------------------------------
/.eslintrc.yml:
--------------------------------------------------------------------------------
1 | env:
2 | browser: true
3 | node: true
4 | es6: true
5 |
6 | plugins:
7 | - babel
8 |
9 | extends:
10 | - eslint:recommended
11 | - llama
12 | - prettier
13 |
14 | parserOptions:
15 | sourceType: module
16 |
17 | parser: babel-eslint
18 |
19 | rules:
20 | lines-around-comment: off
21 | require-jsdoc: off
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | npm-debug.log
4 | dist/
5 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Only publish compiled code.
2 | src/
3 |
4 | docs/
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: node_js
3 |
4 | node_js:
5 | - 4
6 | - 5
7 | - 6
8 |
9 | script:
10 | - npm run test
11 | - npm run lint
12 |
13 | deploy:
14 | provider: npm
15 | email: Jesse_Gibson@me.com
16 | api_key:
17 | secure: D2i15mHlb2VWiRaCm/U0mEkhaoqtaKo7dMKglOkmbG1Cc1S7+JSfxQFyF2tNSQsgJNqIO3ik/l/09lm3nz1mV197/VMKyYKASsdlIg4elX3WaiyvMtQk82OUfNkCYrBskDaX3oqspByhiGfBXIrJqLQ/I2L1YJ/7rLVdx3t+/E2IYYZ6N/l4iWr/7Iq33Y+jy1mg4rm4R+UOS06QsRfMde4AxSGXjNGs9w6pm8C4cNgZx5rhHyJV6FJextofSCxp0idIOUtE8FeDDqpVccTUaD/phe128zWXnoN6pk7efxVgDlxhR94HCPXLfQBJyL+J3P5KjNNzz94IwTaVnuomwfnsxg7Wnrc2ZiVqNA/xV4CUphlpumiHi3Z7SfxIZno47pKbOh7UlCmEeNNdtFI88/YBrWaGEfDPFph6LQCgvXQbopbNYkUNIq2QA9vaXUG9r0NJr3o9WsoptAmfmrSkhP7RvrpqPOez6zlcxBX5OoryJTR21HIW8jP1Pn5+KRIynb3GJZF5dOHiiFJhZORr55IGslxddt0ze7INS+6N/9i6GBGZDA/5jqd+IWII+v2iB/rRDvafrqvOwQ8tTC1xtDpjYZJbTbSeQD36WQXmzENvGqHixa1mC8onZwEhIoP1VgmVpLx43HIMEQW54BkYwzhFIfP4q+0gwBHnt121gV8=
18 | on:
19 | tags: true
20 | repo: PsychoLlama/graph-crdt
21 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | `graph-crdt` uses [this changelog style](http://keepachangelog.com/en/0.3.0/), and versions after `0.1.0` follow [semver](http://semver.org/).
4 |
5 | ## v0.7.0
6 | ### Added
7 | - New `Node#snapshot` method.
8 |
9 | ## v0.6.2
10 | ### Fixed
11 | - Removed `Graph` and `Node` globals.
12 |
13 | ## v0.6.1
14 | ### Added
15 | - New documentation using JSDoc.
16 |
17 | ## v0.6.0
18 | ### Added
19 | - New `Node#setMetadata` method.
20 |
21 | ## v0.5.0
22 | ### Added
23 | - New `Node#overlap` method.
24 | - New `Graph#overlap` method.
25 |
26 | ## v0.4.0
27 | ### Added
28 | - New `Node#rebase` method.
29 | - New `Graph#rebase` method.
30 |
31 | ## v0.3.1
32 | ### Fixed
33 | - Prematurely resolved update merges caused by a `break` statement in the merge loop. Caused some updates to never fully merge.
34 |
35 | ## v0.3.0
36 | ### Changed
37 | - Replaced wall clocks with logical clocks.
38 |
39 | ### Removed
40 | - Deferred updates are gone! They don't make sense with Lamport time.
41 | - `Node#compare` is gone.
42 |
43 | ## v0.2.0
44 | ### Changed
45 | - Renamed `Graph#read` to `Graph#value`.
46 |
47 | ### Added
48 | - New `Graph#new` method, primarily for subclasses.
49 |
50 | ## v0.1.0
51 | ### Added
52 | - `Node#new` method, creates a new instance of the same type using the same configuration (such as `uid`).
53 |
54 | ### Changed
55 | - `Node#read` has been renamed to `Node#value`.
56 |
57 | ### Removed
58 | - `Node#clone` has been replaced in favor of `Node#new`, which does not copy properties.
59 | - `Graph#add` has been removed in favor of `Graph#merge`.
60 |
61 | ## v0.0.5
62 | ### Added
63 | - New `Node#clone` method which creates a copy of the node.
64 |
65 | ## v0.0.4
66 | ### Added
67 | - New `conflict` event on Node instances (only happens when a conflict overwrites the current value).
68 |
69 | ### Changed
70 | - `Node#compare` returns `"conflict"` on conflicts, instead of attempting to interpret them as `"update"` or `"history"`.
71 |
72 | ## v0.0.3
73 | ### Changed
74 | - Node `historical` event renamed to `history`.
75 |
76 | ### Added
77 | - New `Node#schedule` method schedules deferred updates.
78 |
79 | ### Fixed
80 | - Calling `Node#merge` wouldn't merge the incoming node's deferred updates.
81 |
82 | ## v0.0.2
83 | ### Fixed
84 | - Graph members are no longer globally mutated (allows graph time travel).
85 |
86 | ## v0.0.1
87 | ### Added
88 | - `Node` class
89 | - `Graph` class
90 | - Merge capabilities
91 | - `update`, `historical`, `deferred` events.
92 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # MIT License
2 |
3 | Copyright (c) 2016 Jesse Gibson
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Distributed Graph Engine
2 | [](https://travis-ci.org/PsychoLlama/graph-crdt)
3 |
4 | Designed for serializing arbitrary data structures, making offline edits, and seamlessly merging changes back in. All data is observable and event driven.
5 |
6 | For the technical, `graph-crdt` is a modified version of a [LWW-E-Set](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type#LWW-Element-Set_(Last-Write-Wins-Element-Set)) with inline garbage collection using [lamport clocks](https://en.wikipedia.org/wiki/Lamport_timestamps) and JavaScript's [lexicographic comparison](https://en.wikipedia.org/wiki/Lexicographical_order) on deterministically serialized JSON for the predetermined conflict resolution bias.
7 |
8 | # Maintenance notice
9 | If it isn't obvious from the lack of recent commits, `graph-crdt` is **unmaintained**.
10 |
11 | I'm still pursuing the concepts through [the mytosis framework](https://github.com/PsychoLlama/mytosis) along with more ambitious ideas, but development has kinda paused there too. I hit some project burnout.
12 |
13 | # What for?
14 | This graph library aims to ease the complexity of synchronizing complex and interconnected state between peers, without assuming centralized authority.
15 |
16 | # How does it work?
17 | Truly offline systems **cannot** rely on any form of collaboration. They must (at some point) assume the editor is in complete isolation, such as a smartphone that lost cell service, or a server who's network is unreachable.
18 |
19 | You have a few options:
20 | - **Block writes**
21 | Probably the worst experience, block all writes until the network heals. This is essentially the same as losing socket connection to your database (Rethink, Neo4j, Redis, MySQL, etc.)
22 |
23 | - **Defer the updates**
24 | You allow writes on the offline machine, wait for the network to heal, then publish them. If not handled perfectly, you're susceptible to merge hell on an active production environment.
25 |
26 | - **Use a CRDT**
27 | CRDTs ([Convergent Replicated Data Types](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type)) are similar to the option above, but come with additional guarantees: regardless of the order which updates are received in, every machine will arrive at the exact same result *every time*, and if implemented correctly, make merge conflicts impossible.
28 |
29 | > `graph-crdt` uses Lamport time to track state mutation and resolves concurrent edit conflicts using a deterministic sorting algorithm.
30 |
31 | This library opts for the latter, implementing a delta graph CvRDT. However, as great as they may seem, there are some cons (some specific to this library):
32 |
33 | - You need more data.
34 | Merges need a state integer on each field.
35 |
36 | - There is no "true" delete.
37 | You can remove the value, but some metadata has to stay around.
38 |
39 | - It only plays nice with other CRDTs.
40 | To merge two states, both must have the CRDT metadata (though this library allows you to upgrade nearly any data).
41 |
42 | ## Features
43 | - Commutative, idempotent, conflict-resolved `Node` unions.
44 | - Delta emission on `Node` and `Graph` unions.
45 | - Time travel (track and selectively apply deltas).
46 |
47 | ## [Documentation](https://psychollama.github.io/graph-crdt/)
48 | All the API docs [can be found here](https://psychollama.github.io/graph-crdt/).
49 |
50 | ## Roadmap
51 | 1. Node field tombstones.
52 | 2. Graph member tombstones.
53 | 3. Custom conflict resolvers.
54 | 4. A new data structure (this one is a surprise).
55 |
56 | ## Disclaimer
57 | Although I have working experience with decentralized systems (at [GunDB](//gundb.io)), I'm still a n00b. This library is my best understanding of CvRDTs and how they operate. I'm open to most suggestions.
58 |
--------------------------------------------------------------------------------
/docs/Graph_index.js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
/**
42 | * @module graph-crdt.Node
43 | */
44 |
45 | import Emitter from 'eventemitter3';
46 | import { v4 as uuid } from 'uuid';
47 | import { conflict } from '../union';
48 |
49 | const node = Symbol('source object');
50 |
51 | /**
52 | * Increments each state given an object of key/value pairs.
53 | * @private
54 | * @param {Node} current - Current state.
55 | * @param {Object} update - Key-value update pairs.
56 | * @return {Node} - Incremented update.
57 | */
58 | const getIncrementedState = (current, update) => {
59 | const result = current.new();
60 |
61 | for (const field in update) {
62 | if (update.hasOwnProperty(field)) {
63 | const state = current.state(field) + 1;
64 | const value = update[field];
65 |
66 | result[node][field] = { value, state };
67 | }
68 | }
69 |
70 | return result;
71 | };
72 |
73 | /**
74 | * An observable object with conflict-resolution.
75 | *
76 | * @class Node
77 | * @param {Object} [config] - Instance level configuration.
78 | * @param {Object} [config.uid] - Override the randomly generated
79 | * node uid.
80 | */
81 | export default class Node extends Emitter {
82 |
83 | /**
84 | * Creates a new Node instance without using
85 | * `new`.
86 | *
87 | * @param {Object} [config] - The constructor configuration object.
88 | * @returns {Node} - The new node instance.
89 | */
90 | static create (config) {
91 | return new Node(config);
92 | }
93 |
94 | /**
95 | * Turns a normal object into a Node instance.
96 | * Properties to be imported must be enumerable
97 | * and cannot be inherited via prototype.
98 | *
99 | * @param {Object} object - Any enumerable object.
100 | * @returns {Node} - A node interface constructed from the object.
101 | */
102 | static from (object) {
103 | const instance = Node.create();
104 | const state = 1;
105 |
106 | for (const key in object) {
107 | if (object.hasOwnProperty(key)) {
108 | const value = object[key];
109 | instance[node][key] = { value, state };
110 | }
111 | }
112 |
113 | return instance;
114 | }
115 |
116 | /**
117 | * Take an object and use it as the data source for a new
118 | * node. This method is used with properly formatted
119 | * objects, such as stringified, then parsed node instances.
120 | *
121 | * @param {Object} object - The preformatted object.
122 | * @returns {Node} - A new node instance.
123 | *
124 | * @example
125 | * const original = Node.create()
126 | * original.merge({ data: 'intact' })
127 | * const serialized = JSON.stringify(original)
128 | * const parsed = JSON.parse(serialized)
129 | *
130 | * const node = Node.source(parsed)
131 | * node.value('data') // 'intact'
132 | */
133 | static source (object) {
134 | const instance = Node.create();
135 | instance[node] = object;
136 |
137 | return instance;
138 | }
139 |
140 | constructor (config = {}) {
141 |
142 | super();
143 |
144 | const uid = config.uid || uuid();
145 |
146 | this[node] = {
147 | '@object': { uid },
148 | };
149 | }
150 |
151 | /**
152 | * Read metadata, either on a field, or
153 | * on the entire object.
154 | *
155 | * @param {String} [field] - The property to read metadata from.
156 | * @returns {Object|null} - If metadata is found, it returns the object.
157 | * Otherwise `null` is given.
158 | */
159 | meta (field) {
160 |
161 | if (field === undefined) {
162 |
163 | /** Returns the object metadata if no field is specified. */
164 | return this[node]['@object'];
165 | }
166 |
167 | /** Returns the field given, and null if metadata isn't found. */
168 | return this[node][field] || null;
169 | }
170 |
171 | /**
172 | * Show the value of a node's property.
173 | *
174 | * @param {String} field - The name of the property
175 | * to retrieve.
176 | * @returns {Mixed} - The value of the property,
177 | * or undefined if it doesn't exist. Cannot be called
178 | * on reserved fields (like "@object").
179 | */
180 | value (field) {
181 | if (field === '@object') {
182 | return undefined;
183 | }
184 |
185 | /** Gets the field metadata. */
186 | const subject = this.meta(field);
187 |
188 | /**
189 | * If the field exists, it returns the corresponding
190 | * value, otherwise it returns undefined.
191 | */
192 | return subject ? subject.value : undefined;
193 | }
194 |
195 | /**
196 | * Get the current state of a property.
197 | *
198 | * @param {String} field - Property name.
199 | * @returns {Number} - Current lamport state (or 0).
200 | */
201 | state (field) {
202 |
203 | /** Get the field metadata. */
204 | const meta = this.meta(field);
205 |
206 | return meta ? meta.state : 0;
207 | }
208 |
209 | /**
210 | * Sets metadata for a field, bumping the current state.
211 | * @param {String} field - A field to update.
212 | * @param {Object} metadata - What metadata the field should contain.
213 | * @return {Object} - The metadata object (not the same one given).
214 | */
215 | setMetadata (field, metadata) {
216 | const state = this.state(field) + 1;
217 |
218 | const update = this.new();
219 | update[node][field] = { ...metadata, state };
220 |
221 | return this.merge(update);
222 | }
223 |
224 | /**
225 | * Takes the changes from the current node and plays them after the
226 | * changes in the target node.
227 | * Similar to git rebase, but without the conflicts.
228 | * @param {Node} target - Preceding state.
229 | * @return {Node} - A new, rebased node.
230 | */
231 | rebase (target) {
232 | const rebased = this.new();
233 |
234 | rebased.merge(target);
235 | rebased.merge(this);
236 |
237 | // Bump state for older fields.
238 | for (const [key] of this) {
239 | if (target.state(key) >= this.state(key)) {
240 |
241 | // Avoids mutation of metadata.
242 | rebased[node][key] = {
243 | ...this.meta(key),
244 | state: target.state(key) + 1,
245 | };
246 | }
247 | }
248 |
249 | return rebased;
250 | }
251 |
252 | /**
253 | * Calculates the intersection between two nodes.
254 | * @param {Node} target - Any other node.
255 | * @return {Node} - A collection of fields common to both nodes.
256 | */
257 | overlap (target) {
258 | const shared = this.new();
259 |
260 | for (const [field] of this) {
261 | if (this.state(field) && target.state(field)) {
262 | shared[node][field] = this.meta(field);
263 | }
264 | }
265 |
266 | return shared;
267 | }
268 |
269 | /**
270 | * Merges an update into the current node.
271 | *
272 | * @param {Node} incoming - The node to merge from.
273 | * If a plain object is passed, it will be upgraded to a node
274 | * using `Node.from`.
275 | * @returns {Object} - A collection of changes caused by the merge.
276 | */
277 | merge (incoming) {
278 | if (!(incoming instanceof Node)) {
279 | incoming = getIncrementedState(this, incoming);
280 | }
281 |
282 | /** Track all mutations. */
283 | const changes = {
284 | history: this.new(),
285 | update: this.new(),
286 | };
287 |
288 | for (const [field] of incoming) {
289 | let forceUpdate = false;
290 |
291 | const current = this.meta(field);
292 | const update = incoming.meta(field);
293 | const state = {
294 | incoming: incoming.state(field),
295 | current: this.state(field),
296 | };
297 |
298 | /** Handle conflicts. */
299 | if (state.current === state.incoming) {
300 | const winner = conflict(current, update);
301 |
302 | /** No further action needed. */
303 | if (winner === current) {
304 | continue;
305 | }
306 |
307 | /** Replace the current value */
308 | this.emit('conflict', update, current);
309 | forceUpdate = true;
310 | }
311 |
312 | if (state.current < state.incoming || forceUpdate) {
313 |
314 | /** Track overwritten values. */
315 | if (current) {
316 | changes.history[node][field] = current;
317 | }
318 |
319 | changes.update[node][field] = update;
320 |
321 | /** Immediately apply updates. */
322 | this[node][field] = update;
323 | } else {
324 | changes.history[node][field] = update;
325 | }
326 | }
327 |
328 | /** Only emit when there's a change. */
329 | const changed = [...changes.update].length > 0;
330 | const overwritten = [...changes.history].length > 0;
331 |
332 | if (overwritten) {
333 | this.emit('history', changes.history);
334 | }
335 | if (changed) {
336 | this.emit('update', changes.update);
337 | }
338 |
339 | return changes;
340 | }
341 |
342 | /**
343 | * Creates an empty instance with the same configuration.
344 | * @return {Node} - A new node instance with the same properties.
345 | */
346 | new () {
347 | const { uid } = this.meta();
348 | const clone = new Node({ uid });
349 |
350 | return clone;
351 | }
352 |
353 | /**
354 | * Takes a snapshot of the current state.
355 | * @return {Object} - Every key and value (currently) in the node.
356 | */
357 | snapshot () {
358 | const object = {};
359 |
360 | for (const [key, value] of this) {
361 | object[key] = value;
362 | }
363 |
364 | return object;
365 | }
366 |
367 | /**
368 | * Iterates over the node keys & values, ignoring metadata.
369 | * @return {Array} - Each value yielded is a [key, value] pair.
370 | */
371 | * [Symbol.iterator] () {
372 | const object = this[node];
373 | const meta = '@object';
374 |
375 | /** Iterate over the source object. */
376 | for (const key in object) {
377 |
378 | /** Ignore prototype values and node metadata. */
379 | if (object.hasOwnProperty(key) && key !== meta) {
380 | const value = this.value(key);
381 | yield [key, value];
382 | }
383 |
384 | }
385 | }
386 |
387 | /* Coercion interfaces */
388 |
389 | /**
390 | * Returns the node's uid. Not meant for end developers,
391 | * instead used by JavaScript for type coercion.
392 | *
393 | * @private
394 | * @returns {String} - The node's unique ID.
395 | */
396 | toString () {
397 | const { uid } = this.meta();
398 |
399 | return uid;
400 | }
401 |
402 | /**
403 | * Returns the actual object, called when JSON needs something
404 | * to stringify. Obviously dangerous as it exposes the object
405 | * to untracked mutation. Please don't use it.
406 | *
407 | * @private
408 | * @returns {Object} - The actual node object.
409 | */
410 | toJSON () {
411 | return this[node];
412 | }
413 | }
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
428 |
429 |
430 |
431 |
432 |
433 |
--------------------------------------------------------------------------------
/docs/fonts/Lato-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PsychoLlama/graph-crdt/e8e186541780acac07290b7e67a27def918d85e1/docs/fonts/Lato-Regular.ttf
--------------------------------------------------------------------------------
/docs/fonts/OFL.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010-2014 by tyPoland Lukasz Dziedzic (team@latofonts.com) with Reserved Font Name "Lato"
2 | This Font Software is licensed under the SIL Open Font License, Version 1.1.
3 | This license is copied below, and is also available with a FAQ at:
4 | http://scripts.sil.org/OFL
5 |
6 |
7 | -----------------------------------------------------------
8 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9 | -----------------------------------------------------------
10 |
11 | PREAMBLE
12 | The goals of the Open Font License (OFL) are to stimulate worldwide
13 | development of collaborative font projects, to support the font creation
14 | efforts of academic and linguistic communities, and to provide a free and
15 | open framework in which fonts may be shared and improved in partnership
16 | with others.
17 |
18 | The OFL allows the licensed fonts to be used, studied, modified and
19 | redistributed freely as long as they are not sold by themselves. The
20 | fonts, including any derivative works, can be bundled, embedded,
21 | redistributed and/or sold with any software provided that any reserved
22 | names are not used by derivative works. The fonts and derivatives,
23 | however, cannot be released under any other type of license. The
24 | requirement for fonts to remain under this license does not apply
25 | to any document created using the fonts or their derivatives.
26 |
27 | DEFINITIONS
28 | "Font Software" refers to the set of files released by the Copyright
29 | Holder(s) under this license and clearly marked as such. This may
30 | include source files, build scripts and documentation.
31 |
32 | "Reserved Font Name" refers to any names specified as such after the
33 | copyright statement(s).
34 |
35 | "Original Version" refers to the collection of Font Software components as
36 | distributed by the Copyright Holder(s).
37 |
38 | "Modified Version" refers to any derivative made by adding to, deleting,
39 | or substituting -- in part or in whole -- any of the components of the
40 | Original Version, by changing formats or by porting the Font Software to a
41 | new environment.
42 |
43 | "Author" refers to any designer, engineer, programmer, technical
44 | writer or other person who contributed to the Font Software.
45 |
46 | PERMISSION & CONDITIONS
47 | Permission is hereby granted, free of charge, to any person obtaining
48 | a copy of the Font Software, to use, study, copy, merge, embed, modify,
49 | redistribute, and sell modified and unmodified copies of the Font
50 | Software, subject to the following conditions:
51 |
52 | 1) Neither the Font Software nor any of its individual components,
53 | in Original or Modified Versions, may be sold by itself.
54 |
55 | 2) Original or Modified Versions of the Font Software may be bundled,
56 | redistributed and/or sold with any software, provided that each copy
57 | contains the above copyright notice and this license. These can be
58 | included either as stand-alone text files, human-readable headers or
59 | in the appropriate machine-readable metadata fields within text or
60 | binary files as long as those fields can be easily viewed by the user.
61 |
62 | 3) No Modified Version of the Font Software may use the Reserved Font
63 | Name(s) unless explicit written permission is granted by the corresponding
64 | Copyright Holder. This restriction only applies to the primary font name as
65 | presented to the users.
66 |
67 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68 | Software shall not be used to promote, endorse or advertise any
69 | Modified Version, except to acknowledge the contribution(s) of the
70 | Copyright Holder(s) and the Author(s) or with their explicit written
71 | permission.
72 |
73 | 5) The Font Software, modified or unmodified, in part or in whole,
74 | must be distributed entirely under this license, and must not be
75 | distributed under any other license. The requirement for fonts to
76 | remain under this license does not apply to any document created
77 | using the Font Software.
78 |
79 | TERMINATION
80 | This license becomes null and void if any of the above conditions are
81 | not met.
82 |
83 | DISCLAIMER
84 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92 | OTHER DEALINGS IN THE FONT SOFTWARE.
93 |
--------------------------------------------------------------------------------
/docs/fonts/SourceCodePro-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PsychoLlama/graph-crdt/e8e186541780acac07290b7e67a27def918d85e1/docs/fonts/SourceCodePro-Regular.ttf
--------------------------------------------------------------------------------
/docs/global.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Global - Postman Documentation
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
28 |
29 |
236 | Imports a format compliant graph into a new one. It expects
237 | nested nodes to use the node metadata format. Useful for
238 | sending and importing graphs over the network.
239 |
364 | Turns a normal object into a Node instance.
365 | Properties to be imported must be enumerable
366 | and cannot be inherited via prototype.
367 |
519 | Take an object and use it as the data source for a new
520 | node. This method is used with properly formatted
521 | objects, such as stringified, then parsed node instances.
522 |
1267 | Takes the changes from the current node and plays them after the
1268 | changes in the target node.
1269 | Similar to git rebase, but without the conflicts.
1270 |
graph-crdt is a work in progress with frequent breaking changes.
53 |
54 |
Designed for serializing arbitrary data structures, making offline edits, and seamlessly merging changes back in. All data is observable and event driven.
55 |
What for?
This graph library aims to ease the complexity of synchronizing complex and interconnected state between peers, without assuming centralized authority.
56 |
How does it work?
Truly offline systems cannot rely on any form of collaboration. They must (at some point) assume the editor is in complete isolation, such as a smartphone that lost cell service, or a server who's network is unreachable.
57 |
You have a few options:
58 |
59 |
Block writes
60 | Probably the worst experience, block all writes until the network heals. This is essentially the same as losing socket connection to your database (Rethink, Neo4j, Redis, MySQL, etc.)
61 |
62 |
Defer the updates
63 | You allow writes on the offline machine, wait for the network to heal, then publish them. If not handled perfectly, you're susceptible to merge hell on an active production environment.
64 |
65 |
Use a CRDT
66 | CRDTs (Convergent Replicated Data Types) are similar to the option above, but come with additional guarantees: regardless of the order which updates are received in, every machine will arrive at the exact same result every time, and if implemented correctly, make merge conflicts impossible*.
67 |
68 |
69 |
70 | *graph-crdt uses Lamport time to track state mutation and resolves concurrent edit conflicts using a deterministic sorting algorithm.
71 |
72 |
This library opts for the latter, implementing a delta graph CvRDT. However, as great as they may seem, there are some cons (some specific to this library):
73 |
74 |
You need more data.
75 | Merges need a state integer on each field.
76 |
77 |
There is no "true" delete.
78 | You can remove the value, but some metadata has to stay around.
79 |
80 |
It only plays nice with other CRDTs.
81 | To merge two states, both must have the CRDT metadata (though this library allows you to upgrade nearly any data).
Although I have working experience with decentralized systems (at GunDB), I'm still a n00b. This library is my best understanding of CvRDTs and how they operate. I'm open to most suggestions.
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/docs/scripts/linenumber.js:
--------------------------------------------------------------------------------
1 | /*global document */
2 | (function() {
3 | var source = document.getElementsByClassName('prettyprint source linenums');
4 | var i = 0;
5 | var lineNumber = 0;
6 | var lineId;
7 | var lines;
8 | var totalLines;
9 | var anchorHash;
10 |
11 | if (source && source[0]) {
12 | anchorHash = document.location.hash.substring(1);
13 | lines = source[0].getElementsByTagName('li');
14 | totalLines = lines.length;
15 |
16 | for (; i < totalLines; i++) {
17 | lineNumber++;
18 | lineId = 'line' + lineNumber;
19 | lines[i].id = lineId;
20 | if (lineId === anchorHash) {
21 | lines[i].className += ' selected';
22 | }
23 | }
24 | }
25 | })();
26 |
--------------------------------------------------------------------------------
/docs/scripts/prettify/Apache-License-2.0.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/docs/scripts/prettify/lang-css.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
3 |
--------------------------------------------------------------------------------
/docs/scripts/prettify/prettify.js:
--------------------------------------------------------------------------------
1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]+/],["dec",/^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
28 |
29 |