@open-docex/shared 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -2
  3. package/dist/errors/catalogue.d.ts +30 -0
  4. package/dist/errors/catalogue.d.ts.map +1 -0
  5. package/dist/errors/catalogue.js +52 -0
  6. package/dist/errors/catalogue.js.map +1 -0
  7. package/dist/errors/index.d.ts +9 -0
  8. package/dist/errors/index.d.ts.map +1 -0
  9. package/dist/errors/index.js +9 -0
  10. package/dist/errors/index.js.map +1 -0
  11. package/dist/errors/open-docex-error.d.ts +81 -0
  12. package/dist/errors/open-docex-error.d.ts.map +1 -0
  13. package/dist/errors/open-docex-error.js +127 -0
  14. package/dist/errors/open-docex-error.js.map +1 -0
  15. package/dist/ids/index.d.ts +41 -0
  16. package/dist/ids/index.d.ts.map +1 -0
  17. package/dist/ids/index.js +70 -0
  18. package/dist/ids/index.js.map +1 -0
  19. package/dist/index.d.ts +16 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +16 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/ot/index.d.ts +4 -0
  24. package/dist/ot/index.d.ts.map +1 -0
  25. package/dist/ot/index.js +3 -0
  26. package/dist/ot/index.js.map +1 -0
  27. package/dist/ot/types.d.ts +55 -0
  28. package/dist/ot/types.d.ts.map +1 -0
  29. package/dist/ot/types.js +11 -0
  30. package/dist/ot/types.js.map +1 -0
  31. package/dist/protocol/close-codes.d.ts +39 -0
  32. package/dist/protocol/close-codes.d.ts.map +1 -0
  33. package/dist/protocol/close-codes.js +47 -0
  34. package/dist/protocol/close-codes.js.map +1 -0
  35. package/dist/protocol/codec.d.ts +32 -0
  36. package/dist/protocol/codec.d.ts.map +1 -0
  37. package/dist/protocol/codec.js +270 -0
  38. package/dist/protocol/codec.js.map +1 -0
  39. package/dist/protocol/frames.d.ts +45 -0
  40. package/dist/protocol/frames.d.ts.map +1 -0
  41. package/dist/protocol/frames.js +125 -0
  42. package/dist/protocol/frames.js.map +1 -0
  43. package/dist/protocol/index.d.ts +12 -0
  44. package/dist/protocol/index.d.ts.map +1 -0
  45. package/dist/protocol/index.js +12 -0
  46. package/dist/protocol/index.js.map +1 -0
  47. package/dist/protocol/messages.d.ts +250 -0
  48. package/dist/protocol/messages.d.ts.map +1 -0
  49. package/dist/protocol/messages.js +7 -0
  50. package/dist/protocol/messages.js.map +1 -0
  51. package/dist/protocol/validate.d.ts +61 -0
  52. package/dist/protocol/validate.d.ts.map +1 -0
  53. package/dist/protocol/validate.js +139 -0
  54. package/dist/protocol/validate.js.map +1 -0
  55. package/dist/text/apply.d.ts +27 -0
  56. package/dist/text/apply.d.ts.map +1 -0
  57. package/dist/text/apply.js +151 -0
  58. package/dist/text/apply.js.map +1 -0
  59. package/dist/text/chunk.d.ts +33 -0
  60. package/dist/text/chunk.d.ts.map +1 -0
  61. package/dist/text/chunk.js +152 -0
  62. package/dist/text/chunk.js.map +1 -0
  63. package/dist/text/equal.d.ts +4 -0
  64. package/dist/text/equal.d.ts.map +1 -0
  65. package/dist/text/equal.js +16 -0
  66. package/dist/text/equal.js.map +1 -0
  67. package/dist/text/href.d.ts +13 -0
  68. package/dist/text/href.d.ts.map +1 -0
  69. package/dist/text/href.js +31 -0
  70. package/dist/text/href.js.map +1 -0
  71. package/dist/text/index.d.ts +18 -0
  72. package/dist/text/index.d.ts.map +1 -0
  73. package/dist/text/index.js +14 -0
  74. package/dist/text/index.js.map +1 -0
  75. package/dist/text/ot.d.ts +7 -0
  76. package/dist/text/ot.d.ts.map +1 -0
  77. package/dist/text/ot.js +136 -0
  78. package/dist/text/ot.js.map +1 -0
  79. package/dist/text/page.d.ts +35 -0
  80. package/dist/text/page.d.ts.map +1 -0
  81. package/dist/text/page.js +31 -0
  82. package/dist/text/page.js.map +1 -0
  83. package/dist/text/rebase.d.ts +50 -0
  84. package/dist/text/rebase.d.ts.map +1 -0
  85. package/dist/text/rebase.js +59 -0
  86. package/dist/text/rebase.js.map +1 -0
  87. package/dist/text/schema.d.ts +43 -0
  88. package/dist/text/schema.d.ts.map +1 -0
  89. package/dist/text/schema.js +482 -0
  90. package/dist/text/schema.js.map +1 -0
  91. package/dist/text/steps.d.ts +17 -0
  92. package/dist/text/steps.d.ts.map +1 -0
  93. package/dist/text/steps.js +14 -0
  94. package/dist/text/steps.js.map +1 -0
  95. package/dist/util/canonical-json.d.ts +16 -0
  96. package/dist/util/canonical-json.d.ts.map +1 -0
  97. package/dist/util/canonical-json.js +28 -0
  98. package/dist/util/canonical-json.js.map +1 -0
  99. package/dist/util/index.d.ts +10 -0
  100. package/dist/util/index.d.ts.map +1 -0
  101. package/dist/util/index.js +10 -0
  102. package/dist/util/index.js.map +1 -0
  103. package/dist/util/random.d.ts +17 -0
  104. package/dist/util/random.d.ts.map +1 -0
  105. package/dist/util/random.js +40 -0
  106. package/dist/util/random.js.map +1 -0
  107. package/dist/util/utf8.d.ts +13 -0
  108. package/dist/util/utf8.d.ts.map +1 -0
  109. package/dist/util/utf8.js +38 -0
  110. package/dist/util/utf8.js.map +1 -0
  111. package/package.json +57 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/util/random.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAEjD;AAQD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAgB/C"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Random bytes and base64url (LLD Part 1 §2, Utilities).
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Returns `n` cryptographically random bytes from `globalThis.crypto.getRandomValues`.
8
+ *
9
+ * `getRandomValues` is used rather than `randomUUID` because it also works in insecure
10
+ * browser contexts (LLD Part 1 §0). It accepts at most 65,536 bytes per call.
11
+ */
12
+ export function randomBytes(n) {
13
+ return globalThis.crypto.getRandomValues(new Uint8Array(n));
14
+ }
15
+ const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
16
+ function char(sextet) {
17
+ return ALPHABET.charAt(sextet & 63);
18
+ }
19
+ /**
20
+ * Encodes `b` as base64url (RFC 4648 §5) without `=` padding, so 16 bytes give 22 characters.
21
+ */
22
+ export function base64url(b) {
23
+ let out = '';
24
+ let i = 0;
25
+ for (; i + 2 < b.length; i += 3) {
26
+ const n = (b[i] << 16) | (b[i + 1] << 8) | b[i + 2];
27
+ out += char(n >> 18) + char(n >> 12) + char(n >> 6) + char(n);
28
+ }
29
+ const rest = b.length - i;
30
+ if (rest === 1) {
31
+ const n = b[i] << 16;
32
+ out += char(n >> 18) + char(n >> 12);
33
+ }
34
+ else if (rest === 2) {
35
+ const n = (b[i] << 16) | (b[i + 1] << 8);
36
+ out += char(n >> 18) + char(n >> 12) + char(n >> 6);
37
+ }
38
+ return out;
39
+ }
40
+ //# sourceMappingURL=random.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/util/random.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,OAAO,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,QAAQ,GAAG,kEAAkE,CAAC;AAEpF,SAAS,IAAI,CAAC,MAAc;IAC1B,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,CAAa;IACrC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,CAAC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, without allocating.
8
+ *
9
+ * The count matches `new TextEncoder().encode(s).length`: a lone surrogate counts as the
10
+ * 3 bytes of U+FFFD, which is what `TextEncoder` writes in its place.
11
+ */
12
+ export declare function utf8Length(s: string): number;
13
+ //# sourceMappingURL=utf8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8.d.ts","sourceRoot":"","sources":["../../src/util/utf8.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAqB5C"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * UTF-8 size measurement (LLD Part 1 §2, Utilities).
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Returns the number of bytes `s` occupies when encoded as UTF-8, without allocating.
8
+ *
9
+ * The count matches `new TextEncoder().encode(s).length`: a lone surrogate counts as the
10
+ * 3 bytes of U+FFFD, which is what `TextEncoder` writes in its place.
11
+ */
12
+ export function utf8Length(s) {
13
+ let bytes = 0;
14
+ for (let i = 0; i < s.length; i++) {
15
+ const c = s.charCodeAt(i);
16
+ if (c < 0x80) {
17
+ bytes += 1;
18
+ }
19
+ else if (c < 0x800) {
20
+ bytes += 2;
21
+ }
22
+ else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {
23
+ const next = s.charCodeAt(i + 1);
24
+ if (next >= 0xdc00 && next <= 0xdfff) {
25
+ bytes += 4;
26
+ i++;
27
+ }
28
+ else {
29
+ bytes += 3;
30
+ }
31
+ }
32
+ else {
33
+ bytes += 3;
34
+ }
35
+ }
36
+ return bytes;
37
+ }
38
+ //# sourceMappingURL=utf8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8.js","sourceRoot":"","sources":["../../src/util/utf8.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;YACb,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;YACrB,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YAC1D,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACrC,KAAK,IAAI,CAAC,CAAC;gBACX,CAAC,EAAE,CAAC;YACN,CAAC;iBAAM,CAAC;gBACN,KAAK,IAAI,CAAC,CAAC;YACb,CAAC;QACH,CAAC;aAAM,CAAC;YACN,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@open-docex/shared",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Isomorphic contracts shared by @open-docex/server and @open-docex/client: protocol, errors, ids, OT and text models.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "@open-docex/source": "./src/index.ts",
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./protocol": {
15
+ "@open-docex/source": "./src/protocol/index.ts",
16
+ "types": "./dist/protocol/index.d.ts",
17
+ "import": "./dist/protocol/index.js"
18
+ },
19
+ "./errors": {
20
+ "@open-docex/source": "./src/errors/index.ts",
21
+ "types": "./dist/errors/index.d.ts",
22
+ "import": "./dist/errors/index.js"
23
+ },
24
+ "./ids": {
25
+ "@open-docex/source": "./src/ids/index.ts",
26
+ "types": "./dist/ids/index.d.ts",
27
+ "import": "./dist/ids/index.js"
28
+ },
29
+ "./ot": {
30
+ "@open-docex/source": "./src/ot/index.ts",
31
+ "types": "./dist/ot/index.d.ts",
32
+ "import": "./dist/ot/index.js"
33
+ },
34
+ "./text": {
35
+ "@open-docex/source": "./src/text/index.ts",
36
+ "types": "./dist/text/index.d.ts",
37
+ "import": "./dist/text/index.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "!dist/**/*.tsbuildinfo"
43
+ ],
44
+ "engines": {
45
+ "node": ">=22.12"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "typecheck": "tsc -p tsconfig.test.json",
52
+ "prepack": "node -e \"require('fs').copyFileSync('../LICENSE', 'LICENSE')\""
53
+ },
54
+ "dependencies": {
55
+ "prosemirror-model": "^1.25.13",
56
+ "prosemirror-tables": "^1.8.5",
57
+ "prosemirror-transform": "^1.12.6"
58
+ }
59
+ }