monacozen 0.0.1 → 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 (109) hide show
  1. package/README.md +124 -0
  2. package/assets/antimono-ClsI0fxy.js +5 -0
  3. package/assets/antimono-zBXMptjq.css +1 -0
  4. package/assets/azcli-ue5GhsHI.js +55 -0
  5. package/assets/bat-C6DzPBcU.js +125 -0
  6. package/assets/bicep-B6UDBWZN.js +220 -0
  7. package/assets/cameligo-BoKy-zSd.js +191 -0
  8. package/assets/clojure-D8WHGr6v.js +148 -0
  9. package/assets/coffee-C16Mnhbm.js +262 -0
  10. package/assets/cpp-_HbkGdoj.js +232 -0
  11. package/assets/csharp-DeGXkEgi.js +262 -0
  12. package/assets/csp-DGVEba9U.js +48 -0
  13. package/assets/css-DmO2GtiT.js +286 -0
  14. package/assets/css.worker-B59bB4vF.js +6 -0
  15. package/assets/css.worker-zFzGcGyJ.js +96 -0
  16. package/assets/cssMode-B-yiAIn5.js +65 -0
  17. package/assets/cypher-5654EJL_.js +214 -0
  18. package/assets/dart-BjXVSQM-.js +238 -0
  19. package/assets/dist-Bx9hOuoB.js +624 -0
  20. package/assets/dockerfile-DSA8TJLS.js +193 -0
  21. package/assets/ecl-DoDWSDGs.js +228 -0
  22. package/assets/editor.api-C_6h_pYy.js +83476 -0
  23. package/assets/editorWebWorkerMain-Cpqca1A3.js +6 -0
  24. package/assets/editorWebWorkerMain-_4oyTYIl.js +33 -0
  25. package/assets/elixir-CzC02SL7.js +525 -0
  26. package/assets/freemarker2-Jvnudjht.js +718 -0
  27. package/assets/fsharp-DRGCXPNW.js +149 -0
  28. package/assets/go-CyErB8P9.js +167 -0
  29. package/assets/graphql-CNnvnjR8.js +176 -0
  30. package/assets/handlebars-B9HHtHT5.js +412 -0
  31. package/assets/hcl-D4a6HBjk.js +221 -0
  32. package/assets/html-B5_5MvV-.js +333 -0
  33. package/assets/html.worker-Czi9KUKj.js +6 -0
  34. package/assets/html.worker-D4M1xqlZ.js +509 -0
  35. package/assets/htmlMode-DcETbRqN.js +74 -0
  36. package/assets/ini-CpSjysbn.js +96 -0
  37. package/assets/java-DkRrYYRp.js +175 -0
  38. package/assets/javascript-Da2MNB2t.js +20 -0
  39. package/assets/json.worker-D3-21m4I.js +65 -0
  40. package/assets/json.worker-pkLWnKxn.js +6 -0
  41. package/assets/jsonMode-BtwFVp_X.js +450 -0
  42. package/assets/julia-DXDdnD4p.js +416 -0
  43. package/assets/kotlin-BNDyMshT.js +184 -0
  44. package/assets/less-3yDKfG4U.js +244 -0
  45. package/assets/liquid-DCciKNzb.js +199 -0
  46. package/assets/lspLanguageFeatures-CAn_K3Js.js +1455 -0
  47. package/assets/lua-CqDy9oHE.js +202 -0
  48. package/assets/m3-DyBtJGhR.js +195 -0
  49. package/assets/main-16cPxgwS.js +107 -0
  50. package/assets/main-CB71Lf5W.js +129 -0
  51. package/assets/main-HEYSEiwe.js +66 -0
  52. package/assets/markdown-DIkeztiD.js +264 -0
  53. package/assets/mdx-BcOG7QFm.js +329 -0
  54. package/assets/mips-BUbWxz0r.js +130 -0
  55. package/assets/monaco-BMsB0TPD.js +39430 -0
  56. package/assets/monaco-ffd8b062.css +3 -0
  57. package/assets/msdax-95fojGvn.js +158 -0
  58. package/assets/mysql-CX3tETwr.js +170 -0
  59. package/assets/objective-c-CK2i53vc.js +146 -0
  60. package/assets/pascal-wnGRqmNG.js +178 -0
  61. package/assets/pascaligo-DR2NqTqc.js +203 -0
  62. package/assets/perl-DXuijcFO.js +318 -0
  63. package/assets/pgsql-BFvD7ctB.js +160 -0
  64. package/assets/php-FZHoZ5C_.js +473 -0
  65. package/assets/pla-Cmb_VVG6.js +148 -0
  66. package/assets/postiats-DUwtyBVk.js +506 -0
  67. package/assets/powerquery-wUlwxvME.js +192 -0
  68. package/assets/powershell-Wf4X7WOf.js +213 -0
  69. package/assets/protobuf-CcMDFVG6.js +661 -0
  70. package/assets/pug-OPBd_9cN.js +302 -0
  71. package/assets/python-D2Z49Cw8.js +254 -0
  72. package/assets/qsharp-C4P6iWbB.js +145 -0
  73. package/assets/r-FHjiK9Ff.js +191 -0
  74. package/assets/razor-CfcSDTvR.js +519 -0
  75. package/assets/redis-CLJ_Tkzp.js +125 -0
  76. package/assets/redshift-Cn0YgnO8.js +160 -0
  77. package/assets/restructuredtext-Ckzl4aRZ.js +289 -0
  78. package/assets/ruby-Dhjv9xsd.js +529 -0
  79. package/assets/rust-Bq7le2bN.js +180 -0
  80. package/assets/scala-Bth6QY64.js +553 -0
  81. package/assets/scheme-BHXdn3HT.js +172 -0
  82. package/assets/scss-DVPfVfp2.js +419 -0
  83. package/assets/shell-DYY2DoAm.js +225 -0
  84. package/assets/solidity-C2dWya5C.js +149 -0
  85. package/assets/sophia-BdPli0VA.js +149 -0
  86. package/assets/sparql-Ca6NBL_y.js +126 -0
  87. package/assets/sql-CE5EfRV1.js +173 -0
  88. package/assets/st-BKcHiAlg.js +478 -0
  89. package/assets/swift-v0LuaFKN.js +215 -0
  90. package/assets/systemverilog-BRC61WOW.js +300 -0
  91. package/assets/tcl-Xx48oN1j.js +225 -0
  92. package/assets/ts.worker-CokkJ1Lk.js +6 -0
  93. package/assets/ts.worker-De3FAST6.js +67741 -0
  94. package/assets/tsMode-cdcRizUc.js +567 -0
  95. package/assets/twig-Dq5WyzaF.js +390 -0
  96. package/assets/typescript-B25ZZJLy.js +257 -0
  97. package/assets/typespec-DVZXVZWY.js +236 -0
  98. package/assets/vb--Ows3SAS.js +262 -0
  99. package/assets/wgsl-gwRTfDFE.js +147 -0
  100. package/assets/workers-qpP7-_JR.js +48 -0
  101. package/assets/xml-BD6eVsMx.js +130 -0
  102. package/assets/yaml-unVkvP57.js +223 -0
  103. package/lib.d.ts +8379 -0
  104. package/package.json +1 -1
  105. package/src/main.js +24 -0
  106. package/index.d.ts +0 -6
  107. package/index.js +0 -1
  108. package/readme.md +0 -1
  109. /package/{license.txt → LICENSE} +0 -0
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # monacozen
2
+
3
+ An opinionated React editor with a lazily loaded Monaco backend and a lightweight native alternative.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install monacozen
9
+ ```
10
+
11
+ React and React DOM are peer dependencies. Monaco, its workers and Antimono are included in the built package. Use a browser bundler that supports CSS imports, dynamic imports and worker asset URLs. The production package is tested through a separate Vite consumer build.
12
+
13
+ ## Monaco editor
14
+
15
+ ```tsx
16
+ import Monacozen from 'monacozen'
17
+
18
+ <Monacozen
19
+ language='typescript'
20
+ monaco={{padding: {top: 6}, readOnly: false}}
21
+ value={text}
22
+ onChange={value => setText(value ?? '')}
23
+ />
24
+ ```
25
+
26
+ `monaco` replaces the former `options` prop. Omit it to use the shared defaults or pass an options object to override them. `fontFamily` and `disableMonospaceOptimizations` are excluded because the `font` prop controls them. Padding is not part of the shared defaults.
27
+
28
+ The existing Monaco props, including `beforeMount`, `onMount`, `onChange`, `onValidate`, model paths, language settings and view-state options, remain available in Monaco mode. Ordinary DOM events such as `onFocus`, `onBlur`, `onKeyDown`, `onPaste` and `onContextMenu` are handled on the enclosing element and bubble from the editor. `wrapperProps` provides additional wrapper attributes.
29
+
30
+ The common `readOnly`, `disabled`, `placeholder`, `autoFocus` and `aria-label` props work in both modes. Explicit common props take precedence over the corresponding Monaco options.
31
+
32
+ ## Native editor
33
+
34
+ ```tsx
35
+ <Monacozen
36
+ monaco={false}
37
+ font='mono'
38
+ name='query'
39
+ placeholder='Enter text'
40
+ value={text}
41
+ onChange={value => setText(value)}
42
+ onKeyDown={event => {
43
+ if (event.key === 'Escape') event.currentTarget.blur()
44
+ }}
45
+ />
46
+ ```
47
+
48
+ `monaco={false}` renders `DummyEditor`, a multiline `<textarea>`. It does not load Monaco JavaScript, Monaco CSS or workers. Native input props such as `name`, `required`, `maxLength`, `readOnly`, `disabled` and `ref` are supported.
49
+
50
+ The native component is also a named export:
51
+
52
+ ```tsx
53
+ import {DummyEditor} from 'monacozen'
54
+
55
+ <DummyEditor defaultValue='Hello' onMount={textarea => textarea.select()} />
56
+ ```
57
+
58
+ Native `onChange` receives `(value, event)`, with a string value and the actual React textarea change event. Native `onMount` receives the textarea itself. Focus, keyboard, input, selection, composition, clipboard, pointer, mouse and other native `on*` handlers are forwarded to that element. Monaco-only lifecycle callbacks are not synthesized for a textarea.
59
+
60
+ A dynamically selected mode is supported too:
61
+
62
+ ```tsx
63
+ <Monacozen
64
+ monaco={useMonaco ? {wordWrap: 'on'} : false}
65
+ value={text}
66
+ onChange={value => setText(value ?? '')}
67
+ />
68
+ ```
69
+
70
+ Uncontrolled text is retained when switching modes. For controlled input, keep supplying `value`. The callback types reflect the backend: a dynamically selected mode has a change-event union and an `onMount` callback that may receive either editor kind. Use `SwitchableEditorProps` when explicitly typing a dynamically selected mode.
71
+
72
+ ## Appearance
73
+
74
+ `dark` defaults to `true`. Monaco uses the bundled, modified `vs-dark` theme with a black background. `dark={false}` selects its light theme. The native editor uses white text on black or black text on white.
75
+
76
+ `font` defaults to `antimono` and also accepts `mono` for the system monospace font or `dense` for the system sans-serif font. Both backends support `height`, `width`, `className` and `style`.
77
+
78
+ ## Loading
79
+
80
+ Importing Monacozen does not initialize Monaco or load either stylesheet. Rendering the Monaco backend starts the React adapter and Monaco imports concurrently. A Suspense boundary displays the `loading` prop while they load. Monaco's stylesheet belongs to its lazy chunks rather than the public entry, so it is fetched before the editor mounts.
81
+
82
+ Antimono has a separate stylesheet and lazy import. It is loaded only when a mounted editor selects `font='antimono'`, including when that selection comes from the default. Selecting `mono` or `dense` alone does not load it. Once the font finishes loading, mounted Monaco editors remeasure their font metrics.
83
+
84
+ Modules and styles are reused across instances and mode changes. Styles are not removed when a component unmounts. Language workers are constructed on demand; an existing `MonacoEnvironment` worker configuration is respected. Loading errors can be handled by the application's React error boundary.
85
+
86
+ ## Additional languages
87
+
88
+ Set `language` to one of these IDs:
89
+
90
+ | ID | Language | Extension |
91
+ |---|---|---|
92
+ | `logsql` | VictoriaLogs LogsQL | `.logsql` |
93
+ | `metricsql` | VictoriaMetrics MetricsQL | `.metricsql` |
94
+ | `clank` | Clank, as emitted by `stringify-clank` | `.clank` |
95
+
96
+ Each definition has its own lazy chunk. Registration metadata is available when Monaco loads; the tokenizer and editor configuration load when that language is used.
97
+
98
+ The definitions provide syntax highlighting and basic editing configuration, not query execution, schema validation or a language server. LogsQL and MetricsQL cover their query operators, keywords, field or label names, calls, numeric values, durations, comments and quoted strings. Clank follows its whitespace-delimited format, including bare strings, special values, raw single-quoted strings and escaped double-quoted strings. It does not invent JSON commas, colons or comments.
99
+
100
+ The Monaco build continues to exclude `abap`, `apex`, `lexon`, `sb` and `flow9`.
101
+
102
+ ## Build
103
+
104
+ ```sh
105
+ bun install
106
+ bun run build
107
+ ```
108
+
109
+ Vite compiles the JSX with React Compiler, produces `out/intermediate/src/main.js` and preserves lazy chunks and styles under `out/intermediate/assets`. `build_lib` packages that project without recombining its runtime chunks. The result is in `dist/monacozen/production`.
110
+
111
+ The intermediate plugin attaches CSS imports to the chunks that own them. Monaco CSS and Antimono CSS remain separate. Runtime files keep the same relative layout through both build stages, including worker URLs. Monaco's public declarations are inlined into `lib.d.ts`; consumers do not need a separate `monaco-editor` installation for types.
112
+
113
+ The workspace plugins handle intermediate packaging, built-in theme overrides, language omission and additional lazy language registration. Additional language modules export `{language, configuration}`, using Monaco's Monarch tokenizer and language-configuration types.
114
+
115
+ ## Verification
116
+
117
+ ```sh
118
+ bun run typecheck
119
+ bun run lint
120
+ bun run test
121
+ bun run test:browser
122
+ ```
123
+
124
+ The browser test requires Chromium. It uses Chrome's standard Windows installation by default; set `CHROME_PATH` for another installation. It creates a clean consumer without `monaco-editor`, checks its types with strict library checking, builds it with Vite and verifies actual requests and editor behavior in Chromium.
@@ -0,0 +1,5 @@
1
+ import "./antimono-zBXMptjq.css";
2
+ //#region src/styles/antimono.ts
3
+ var e = "Antimono";
4
+ //#endregion
5
+ export { e as default };