@es-joy/jsoe 0.27.0 → 0.28.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 (49) hide show
  1. package/CHANGES.md +33 -0
  2. package/README.md +3 -1
  3. package/badges/coverage-badge.svg +1 -1
  4. package/badges/tests-badge.svg +1 -0
  5. package/dist/formats/schema.d.ts +11 -0
  6. package/dist/formats/schema.d.ts.map +1 -1
  7. package/dist/formats/structuredCloning.d.ts.map +1 -1
  8. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/typeChoices.d.ts +32 -2
  12. package/dist/typeChoices.d.ts.map +1 -1
  13. package/dist/types.d.ts +8 -2
  14. package/dist/types.d.ts.map +1 -1
  15. package/dist/utils/rawTypesonEditor.d.ts +110 -0
  16. package/dist/utils/rawTypesonEditor.d.ts.map +1 -0
  17. package/dist/vendor-imports.d.ts +4 -0
  18. package/docs/proposals/raw-typeson-edit-view.md +575 -0
  19. package/mmr.json +6 -0
  20. package/package.json +13 -4
  21. package/pnpm-workspace.yaml +1 -0
  22. package/src/formats/schema.js +3 -1
  23. package/src/formats/structuredCloning.js +24 -17
  24. package/src/fundamentalTypes/arrayType.js +105 -1
  25. package/src/jsoe.css +12 -0
  26. package/src/typeChoices.js +36 -7
  27. package/src/types.js +13 -2
  28. package/src/utils/rawTypesonEditor.js +669 -0
  29. package/src/vendor-imports.js +12 -0
  30. package/tsconfig.json +1 -1
  31. package/typings/json-6.d.ts +12 -0
  32. package/vendor/@codemirror/autocomplete/dist/index.js +2125 -0
  33. package/vendor/@codemirror/commands/dist/index.js +1826 -0
  34. package/vendor/@codemirror/lang-javascript/dist/index.js +513 -0
  35. package/vendor/@codemirror/language/dist/index.js +2693 -0
  36. package/vendor/@codemirror/lint/dist/index.js +956 -0
  37. package/vendor/@codemirror/search/dist/index.js +1238 -0
  38. package/vendor/@codemirror/state/dist/index.js +3947 -0
  39. package/vendor/@codemirror/view/dist/index.js +11867 -0
  40. package/vendor/@lezer/common/dist/index.js +2202 -0
  41. package/vendor/@lezer/highlight/dist/index.js +927 -0
  42. package/vendor/@lezer/javascript/dist/index.js +192 -0
  43. package/vendor/@lezer/lr/dist/index.js +1889 -0
  44. package/vendor/@marijn/find-cluster-break/src/index.js +87 -0
  45. package/vendor/codemirror/dist/index.js +96 -0
  46. package/vendor/crelt/index.js +28 -0
  47. package/vendor/json-6/dist/index.mjs +1783 -0
  48. package/vendor/style-mod/src/style-mod.js +172 -0
  49. package/vendor/w3c-keyname/index.js +119 -0
@@ -0,0 +1,87 @@
1
+ // These are filled with ranges (rangeFrom[i] up to but not including
2
+ // rangeTo[i]) of code points that count as extending characters.
3
+ let rangeFrom = [], rangeTo = []
4
+
5
+ ;(() => {
6
+ // Compressed representation of the Grapheme_Cluster_Break=Extend
7
+ // information from
8
+ // http://www.unicode.org/Public/17.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
9
+ // Each pair of elements represents a range, as an offet from the
10
+ // previous range and a length. Numbers are in base-36, with the empty
11
+ // string being a shorthand for 1. See bin/build-extenders.js.
12
+ let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(s => s ? parseInt(s, 36) : 1)
13
+ for (let i = 0, n = 0; i < numbers.length; i++)
14
+ (i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i])
15
+ })()
16
+
17
+ export function isExtendingChar(code) {
18
+ if (code < 768) return false
19
+ for (let from = 0, to = rangeFrom.length;;) {
20
+ let mid = (from + to) >> 1
21
+ if (code < rangeFrom[mid]) to = mid
22
+ else if (code >= rangeTo[mid]) from = mid + 1
23
+ else return true
24
+ if (from == to) return false
25
+ }
26
+ }
27
+
28
+ function isRegionalIndicator(code) {
29
+ return code >= 0x1F1E6 && code <= 0x1F1FF
30
+ }
31
+
32
+ function check(code) {
33
+ for (let i = 0; i < rangeFrom.length; i++) {
34
+ if (rangeTo[i] > code) return rangeFrom[i] <= code
35
+ }
36
+ return false
37
+ }
38
+
39
+ const ZWJ = 0x200d
40
+
41
+ export function findClusterBreak(str, pos, forward = true, includeExtending = true) {
42
+ return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
43
+ }
44
+
45
+ function nextClusterBreak(str, pos, includeExtending) {
46
+ if (pos == str.length) return pos
47
+ // If pos is in the middle of a surrogate pair, move to its start
48
+ if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--
49
+ let prev = codePointAt(str, pos)
50
+ pos += codePointSize(prev)
51
+ while (pos < str.length) {
52
+ let next = codePointAt(str, pos)
53
+ if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
54
+ pos += codePointSize(next)
55
+ prev = next
56
+ } else if (isRegionalIndicator(next)) {
57
+ let countBefore = 0, i = pos - 2
58
+ while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2 }
59
+ if (countBefore % 2 == 0) break
60
+ else pos += 2
61
+ } else {
62
+ break
63
+ }
64
+ }
65
+ return pos
66
+ }
67
+
68
+ function prevClusterBreak(str, pos, includeExtending) {
69
+ while (pos > 1) {
70
+ let found = nextClusterBreak(str, pos - 2, includeExtending)
71
+ if (found < pos) return found
72
+ pos--
73
+ }
74
+ return 0
75
+ }
76
+
77
+ function codePointAt(str, pos) {
78
+ let code0 = str.charCodeAt(pos)
79
+ if (!surrogateHigh(code0) || pos + 1 == str.length) return code0
80
+ let code1 = str.charCodeAt(pos + 1)
81
+ if (!surrogateLow(code1)) return code0
82
+ return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
83
+ }
84
+
85
+ function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }
86
+ function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }
87
+ function codePointSize(code) { return code < 0x10000 ? 1 : 2 }
@@ -0,0 +1,96 @@
1
+ import { lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine, keymap } from '@codemirror/view';
2
+ export { EditorView } from '@codemirror/view';
3
+ import { EditorState } from '@codemirror/state';
4
+ import { foldGutter, indentOnInput, syntaxHighlighting, defaultHighlightStyle, bracketMatching, foldKeymap } from '@codemirror/language';
5
+ import { history, defaultKeymap, historyKeymap } from '@codemirror/commands';
6
+ import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
7
+ import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
8
+ import { lintKeymap } from '@codemirror/lint';
9
+
10
+ // (The superfluous function calls around the list of extensions work
11
+ // around current limitations in tree-shaking software.)
12
+ /**
13
+ This is an extension value that just pulls together a number of
14
+ extensions that you might want in a basic editor. It is meant as a
15
+ convenient helper to quickly set up CodeMirror without installing
16
+ and importing a lot of separate packages.
17
+
18
+ Specifically, it includes...
19
+
20
+ - [the default command bindings](https://codemirror.net/6/docs/ref/#commands.defaultKeymap)
21
+ - [line numbers](https://codemirror.net/6/docs/ref/#view.lineNumbers)
22
+ - [special character highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars)
23
+ - [the undo history](https://codemirror.net/6/docs/ref/#commands.history)
24
+ - [a fold gutter](https://codemirror.net/6/docs/ref/#language.foldGutter)
25
+ - [custom selection drawing](https://codemirror.net/6/docs/ref/#view.drawSelection)
26
+ - [drop cursor](https://codemirror.net/6/docs/ref/#view.dropCursor)
27
+ - [multiple selections](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
28
+ - [reindentation on input](https://codemirror.net/6/docs/ref/#language.indentOnInput)
29
+ - [the default highlight style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle) (as fallback)
30
+ - [bracket matching](https://codemirror.net/6/docs/ref/#language.bracketMatching)
31
+ - [bracket closing](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets)
32
+ - [autocompletion](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion)
33
+ - [rectangular selection](https://codemirror.net/6/docs/ref/#view.rectangularSelection) and [crosshair cursor](https://codemirror.net/6/docs/ref/#view.crosshairCursor)
34
+ - [active line highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLine)
35
+ - [active line gutter highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLineGutter)
36
+ - [selection match highlighting](https://codemirror.net/6/docs/ref/#search.highlightSelectionMatches)
37
+ - [search](https://codemirror.net/6/docs/ref/#search.searchKeymap)
38
+ - [linting](https://codemirror.net/6/docs/ref/#lint.lintKeymap)
39
+
40
+ (You'll probably want to add some language package to your setup
41
+ too.)
42
+
43
+ This extension does not allow customization. The idea is that,
44
+ once you decide you want to configure your editor more precisely,
45
+ you take this package's source (which is just a bunch of imports
46
+ and an array literal), copy it into your own code, and adjust it
47
+ as desired.
48
+ */
49
+ const basicSetup = /*@__PURE__*/(() => [
50
+ lineNumbers(),
51
+ highlightActiveLineGutter(),
52
+ highlightSpecialChars(),
53
+ history(),
54
+ foldGutter(),
55
+ drawSelection(),
56
+ dropCursor(),
57
+ EditorState.allowMultipleSelections.of(true),
58
+ indentOnInput(),
59
+ syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
60
+ bracketMatching(),
61
+ closeBrackets(),
62
+ autocompletion(),
63
+ rectangularSelection(),
64
+ crosshairCursor(),
65
+ highlightActiveLine(),
66
+ highlightSelectionMatches(),
67
+ keymap.of([
68
+ ...closeBracketsKeymap,
69
+ ...defaultKeymap,
70
+ ...searchKeymap,
71
+ ...historyKeymap,
72
+ ...foldKeymap,
73
+ ...completionKeymap,
74
+ ...lintKeymap
75
+ ])
76
+ ])();
77
+ /**
78
+ A minimal set of extensions to create a functional editor. Only
79
+ includes [the default keymap](https://codemirror.net/6/docs/ref/#commands.defaultKeymap), [undo
80
+ history](https://codemirror.net/6/docs/ref/#commands.history), [special character
81
+ highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars), [custom selection
82
+ drawing](https://codemirror.net/6/docs/ref/#view.drawSelection), and [default highlight
83
+ style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle).
84
+ */
85
+ const minimalSetup = /*@__PURE__*/(() => [
86
+ highlightSpecialChars(),
87
+ history(),
88
+ drawSelection(),
89
+ syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
90
+ keymap.of([
91
+ ...defaultKeymap,
92
+ ...historyKeymap,
93
+ ])
94
+ ])();
95
+
96
+ export { basicSetup, minimalSetup };
@@ -0,0 +1,28 @@
1
+ export default function crelt() {
2
+ var elt = arguments[0]
3
+ if (typeof elt == "string") elt = document.createElement(elt)
4
+ var i = 1, next = arguments[1]
5
+ if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
6
+ for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
7
+ var value = next[name]
8
+ if (typeof value == "string") elt.setAttribute(name, value)
9
+ else if (value != null) elt[name] = value
10
+ }
11
+ i++
12
+ }
13
+ for (; i < arguments.length; i++) add(elt, arguments[i])
14
+ return elt
15
+ }
16
+
17
+ function add(elt, child) {
18
+ if (typeof child == "string") {
19
+ elt.appendChild(document.createTextNode(child))
20
+ } else if (child == null) {
21
+ } else if (child.nodeType != null) {
22
+ elt.appendChild(child)
23
+ } else if (Array.isArray(child)) {
24
+ for (var i = 0; i < child.length; i++) add(elt, child[i])
25
+ } else {
26
+ throw new RangeError("Unsupported child node: " + child)
27
+ }
28
+ }