zeed 1.0.21 → 1.1.1

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 (145) hide show
  1. package/README.md +217 -234
  2. package/dist/{chunk-2Z75UI2C.js → chunk-3LSWLKUP.js} +2 -2
  3. package/dist/{chunk-Z3CCAUP7.js → chunk-4X7UJTXJ.js} +2 -2
  4. package/dist/chunk-5RJ6XORD.cjs +2 -0
  5. package/dist/chunk-5RJ6XORD.cjs.map +1 -0
  6. package/dist/{chunk-AVGEBKCV.js → chunk-5WAO44ET.js} +2 -2
  7. package/dist/{chunk-EXAC332B.cjs → chunk-DAD3M2IM.cjs} +2 -2
  8. package/dist/{chunk-EXAC332B.cjs.map → chunk-DAD3M2IM.cjs.map} +1 -1
  9. package/dist/{chunk-OWX5SXG3.js → chunk-FGAKPO3O.js} +2 -2
  10. package/dist/{chunk-4VAH6DEB.js → chunk-IBGLNGGT.js} +2 -2
  11. package/dist/{chunk-4K3FOY2Z.js → chunk-IQWBYSWG.js} +2 -2
  12. package/dist/chunk-JWON4PLZ.cjs +2 -0
  13. package/dist/{chunk-67WN7TPU.cjs.map → chunk-JWON4PLZ.cjs.map} +1 -1
  14. package/dist/{chunk-PCT5BR7B.cjs → chunk-K4IRAHZV.cjs} +2 -2
  15. package/dist/{chunk-PCT5BR7B.cjs.map → chunk-K4IRAHZV.cjs.map} +1 -1
  16. package/dist/{chunk-IMURZASN.js → chunk-KIKHNNKK.js} +2 -2
  17. package/dist/{chunk-KJKNVADW.cjs → chunk-L5OF6DSH.cjs} +2 -2
  18. package/dist/{chunk-KJKNVADW.cjs.map → chunk-L5OF6DSH.cjs.map} +1 -1
  19. package/dist/chunk-LAGM3ULD.js +1 -0
  20. package/dist/chunk-LLDVPAUS.js +2 -0
  21. package/dist/chunk-LLDVPAUS.js.map +1 -0
  22. package/dist/chunk-MIEXPALS.cjs +1 -0
  23. package/dist/chunk-MIEXPALS.cjs.map +1 -0
  24. package/dist/chunk-MQNZQKBT.js +1 -0
  25. package/dist/chunk-MQNZQKBT.js.map +1 -0
  26. package/dist/chunk-NPQ77LO4.cjs +1 -0
  27. package/dist/chunk-NPQ77LO4.cjs.map +1 -0
  28. package/dist/{chunk-IQQCKTKP.cjs → chunk-NVLJOTGF.cjs} +2 -2
  29. package/dist/{chunk-IQQCKTKP.cjs.map → chunk-NVLJOTGF.cjs.map} +1 -1
  30. package/dist/{chunk-GRMMMGD6.cjs → chunk-RMTW3TW2.cjs} +2 -2
  31. package/dist/{chunk-GRMMMGD6.cjs.map → chunk-RMTW3TW2.cjs.map} +1 -1
  32. package/dist/chunk-SHOLGUSO.cjs +2 -0
  33. package/dist/{chunk-2DDHD4HB.cjs.map → chunk-SHOLGUSO.cjs.map} +1 -1
  34. package/dist/{chunk-W4VPTJY3.js → chunk-UAU7GDLR.js} +2 -2
  35. package/dist/{chunk-YNFT35YQ.js → chunk-UFYY2K4G.js} +2 -2
  36. package/dist/{chunk-4GFUK2NK.cjs → chunk-VR7T3I5N.cjs} +2 -2
  37. package/dist/{chunk-4GFUK2NK.cjs.map → chunk-VR7T3I5N.cjs.map} +1 -1
  38. package/dist/chunk-ZEQQVU3K.cjs +2 -0
  39. package/dist/{chunk-6CVV5WAD.cjs.map → chunk-ZEQQVU3K.cjs.map} +1 -1
  40. package/dist/common/bin/index.cjs +1 -1
  41. package/dist/common/bin/index.js +1 -1
  42. package/dist/common/bin/lib0/buffer.cjs +1 -1
  43. package/dist/common/bin/lib0/buffer.js +1 -1
  44. package/dist/common/bin/lib0/decoding.cjs +1 -1
  45. package/dist/common/bin/lib0/decoding.js +1 -1
  46. package/dist/common/bin/lib0/encoding.cjs +1 -1
  47. package/dist/common/bin/lib0/encoding.js +1 -1
  48. package/dist/common/data/datauri.cjs +1 -1
  49. package/dist/common/data/datauri.js +1 -1
  50. package/dist/common/data/index.cjs +1 -1
  51. package/dist/common/data/index.js +1 -1
  52. package/dist/common/index.cjs +1 -1
  53. package/dist/common/index.cjs.map +1 -1
  54. package/dist/common/index.d.cts +1 -0
  55. package/dist/common/index.d.ts +1 -0
  56. package/dist/common/index.js +1 -1
  57. package/dist/common/schema/export-json-schema.cjs +1 -1
  58. package/dist/common/schema/export-json-schema.js +1 -1
  59. package/dist/common/schema/export-swift.cjs +1 -1
  60. package/dist/common/schema/export-swift.js +1 -1
  61. package/dist/common/schema/index.cjs +1 -1
  62. package/dist/common/schema/index.cjs.map +1 -1
  63. package/dist/common/schema/index.d.cts +1 -0
  64. package/dist/common/schema/index.d.ts +1 -0
  65. package/dist/common/schema/index.js +1 -1
  66. package/dist/common/schema/parse-args.cjs +1 -1
  67. package/dist/common/schema/parse-args.js +1 -1
  68. package/dist/common/schema/parse-env.cjs +1 -1
  69. package/dist/common/schema/parse-env.js +1 -1
  70. package/dist/common/schema/parse-object.cjs +1 -1
  71. package/dist/common/schema/parse-object.js +1 -1
  72. package/dist/common/schema/schema-standard.cjs +2 -0
  73. package/dist/common/schema/schema-standard.cjs.map +1 -0
  74. package/dist/common/schema/schema-standard.d.cts +57 -0
  75. package/dist/common/schema/schema-standard.d.ts +57 -0
  76. package/dist/common/schema/schema-standard.js +2 -0
  77. package/dist/common/schema/schema-standard.js.map +1 -0
  78. package/dist/common/schema/schema.cjs +1 -1
  79. package/dist/common/schema/schema.d.cts +10 -0
  80. package/dist/common/schema/schema.d.ts +10 -0
  81. package/dist/common/schema/schema.js +1 -1
  82. package/dist/common/schema/serialize.cjs +1 -1
  83. package/dist/common/schema/serialize.js +1 -1
  84. package/dist/common/schema/z-collection.cjs +1 -1
  85. package/dist/common/schema/z-collection.js +1 -1
  86. package/dist/common/schema/z.cjs +1 -1
  87. package/dist/common/schema/z.js +1 -1
  88. package/dist/common/test.cjs +1 -1
  89. package/dist/common/test.js +1 -1
  90. package/dist/index.all.cjs +1 -1
  91. package/dist/index.all.cjs.map +1 -1
  92. package/dist/index.all.d.cts +1 -0
  93. package/dist/index.all.d.ts +1 -0
  94. package/dist/index.all.js +1 -1
  95. package/dist/index.browser.cjs +1 -1
  96. package/dist/index.browser.cjs.map +1 -1
  97. package/dist/index.browser.d.cts +1 -0
  98. package/dist/index.browser.d.ts +1 -0
  99. package/dist/index.browser.js +1 -1
  100. package/dist/index.node.cjs +1 -1
  101. package/dist/index.node.cjs.map +1 -1
  102. package/dist/index.node.d.cts +1 -0
  103. package/dist/index.node.d.ts +1 -0
  104. package/dist/index.node.js +1 -1
  105. package/dist/node/index.cjs +1 -1
  106. package/dist/node/index.cjs.map +1 -1
  107. package/dist/node/index.js +1 -1
  108. package/dist/node/log/index.cjs +1 -1
  109. package/dist/node/log/index.cjs.map +1 -1
  110. package/dist/node/log/index.js +1 -1
  111. package/dist/node/log/log-context-node.cjs +1 -1
  112. package/dist/node/log/log-context-node.cjs.map +1 -1
  113. package/dist/node/log/log-context-node.js +1 -1
  114. package/dist/node/log/log-file-rotation.cjs +1 -1
  115. package/dist/node/log/log-file-rotation.cjs.map +1 -1
  116. package/dist/node/log/log-file-rotation.js +1 -1
  117. package/dist/node/log/log-file.cjs +1 -1
  118. package/dist/node/log/log-file.cjs.map +1 -1
  119. package/dist/node/log/log-file.js +1 -1
  120. package/package.json +2 -2
  121. package/src/common/schema/README.md +96 -1
  122. package/src/common/schema/index.ts +1 -0
  123. package/src/common/schema/schema-standard.spec.ts +327 -0
  124. package/src/common/schema/schema-standard.ts +76 -0
  125. package/src/common/schema/schema.ts +225 -0
  126. package/dist/chunk-2DDHD4HB.cjs +0 -2
  127. package/dist/chunk-5VUEFXFJ.js +0 -1
  128. package/dist/chunk-67WN7TPU.cjs +0 -2
  129. package/dist/chunk-6CVV5WAD.cjs +0 -2
  130. package/dist/chunk-IPZOSTTO.cjs +0 -1
  131. package/dist/chunk-IPZOSTTO.cjs.map +0 -1
  132. package/dist/chunk-UC5TCP5S.cjs +0 -2
  133. package/dist/chunk-UC5TCP5S.cjs.map +0 -1
  134. package/dist/chunk-VFRJ7C3X.js +0 -2
  135. package/dist/chunk-VFRJ7C3X.js.map +0 -1
  136. /package/dist/{chunk-2Z75UI2C.js.map → chunk-3LSWLKUP.js.map} +0 -0
  137. /package/dist/{chunk-Z3CCAUP7.js.map → chunk-4X7UJTXJ.js.map} +0 -0
  138. /package/dist/{chunk-AVGEBKCV.js.map → chunk-5WAO44ET.js.map} +0 -0
  139. /package/dist/{chunk-OWX5SXG3.js.map → chunk-FGAKPO3O.js.map} +0 -0
  140. /package/dist/{chunk-4VAH6DEB.js.map → chunk-IBGLNGGT.js.map} +0 -0
  141. /package/dist/{chunk-4K3FOY2Z.js.map → chunk-IQWBYSWG.js.map} +0 -0
  142. /package/dist/{chunk-IMURZASN.js.map → chunk-KIKHNNKK.js.map} +0 -0
  143. /package/dist/{chunk-5VUEFXFJ.js.map → chunk-LAGM3ULD.js.map} +0 -0
  144. /package/dist/{chunk-W4VPTJY3.js.map → chunk-UAU7GDLR.js.map} +0 -0
  145. /package/dist/{chunk-YNFT35YQ.js.map → chunk-UFYY2K4G.js.map} +0 -0
package/README.md CHANGED
@@ -1,28 +1,70 @@
1
- # 🌱 Zeed Library
1
+ <div align="center">
2
+
3
+ # 🌱 Zeed
4
+
5
+ **A zero-dependency TypeScript utility library for universal JavaScript**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/zeed.svg)](https://www.npmjs.com/package/zeed)
8
+ [![License](https://img.shields.io/npm/l/zeed.svg)](https://github.com/holtwick/zeed/blob/main/LICENSE)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
10
+
11
+ [Documentation](https://zeed.holtwick.de/) • [GitHub](https://github.com/holtwick/zeed) • [Codeberg](https://codeberg.org/holtwick/zeed)
12
+
13
+ </div>
14
+
15
+ ---
2
16
 
3
17
  > [!CAUTION]
4
18
  > The main repository is now at <https://codeberg.org/holtwick/zeed> to strengthen European sovereignty. Learn more at [UnplugTrump](https://holtwick.de/blog/unplug-trump).
5
19
 
6
- - Strict **TypeScript**
7
- - **Zero dependencies** and lightweight, **tree-shakable**
8
- - **Universal** for browsers, as well as node, deno and bun
9
- - Modern **ESM**, fallback to CommonJS available
10
- - Mostly covered by **tests**
20
+ ## Features
21
+
22
+ <table>
23
+ <tr>
24
+ <td width="50%">
25
+
26
+ ### 🎯 **Type-Safe**
27
+ Strict TypeScript with full type inference
28
+
29
+ ### 📦 **Zero Dependencies**
30
+ Lightweight and completely tree-shakable
31
+
32
+ ### 🌍 **Universal**
33
+ Works in browsers, Node.js, Deno, and Bun
34
+
35
+ </td>
36
+ <td width="50%">
37
+
38
+ ### ⚡ **Modern ESM**
39
+ ES Modules with CommonJS fallback
11
40
 
12
- Get started like this:
41
+ ### **Well Tested**
42
+ Comprehensive test coverage
43
+
44
+ ### 🔌 **Standard Schema**
45
+ Compatible with tRPC, TanStack, Hono & more
46
+
47
+ </td>
48
+ </tr>
49
+ </table>
50
+
51
+ ## 🚀 Quick Start
13
52
 
14
53
  ```sh
15
- npm i zeed
54
+ npm install zeed
55
+ # or
56
+ pnpm add zeed
57
+ # or
58
+ yarn add zeed
16
59
  ```
17
60
 
18
- Links:
61
+ ---
19
62
 
20
- - API docs at https://zeed.holtwick.de/
21
- - Github repo at https://github.com/holtwick/zeed
63
+ ## 📚 Core Features
22
64
 
23
- ## Universal Logging
65
+ ### 🪵 Universal Logging
24
66
 
25
- Powerful logging for browser and terminal.
67
+ Powerful, filterable logging for browser and terminal with colorful output and stack traces.
26
68
 
27
69
  ```ts
28
70
  import { Logger } from 'zeed'
@@ -35,339 +77,280 @@ log.warn('Warning')
35
77
  log.error('Error')
36
78
  ```
37
79
 
38
- Sample output on a terminal:
80
+ **Terminal output:**
39
81
 
40
82
  <img src=".assets/node-console@2x.png" width="566" style="max-width:100%">
41
83
 
42
- Sample output in Safari:
84
+ **Browser output:**
43
85
 
44
86
  <img src=".assets/safari-console.png" style="max-width:100%">
45
87
 
46
- By default, the most appropriate log handlers are activated. By default, a colorful output is applied for better orientation. Each line has trace info to allow direct jumps back into the code where the log has been issued. Logs can easily be filtered by level.
88
+ <details>
89
+ <summary>📖 Learn more about logging features</summary>
47
90
 
48
- ### Filtering
91
+ **Filtering:**
49
92
 
50
- **By default logs are muted!** Show the logs by applying filters. On the browser enter this an the web inspector console:
93
+ By default, logs are muted. Enable them with filters:
51
94
 
95
+ **Browser:**
52
96
  ```ts
53
97
  localStorage.zeed = '*'
54
98
  ```
55
99
 
56
- On node set an environment variable like this
57
-
100
+ **Node.js:**
58
101
  ```sh
59
102
  ZEED=* node myapp.js
60
103
  ```
61
104
 
62
- Instead of the `*` more advanced filters can be applied compatible to the well known [debug syntax](https://github.com/visionmedia/debug#wildcards). Instead of `ZEED` variable you may also use `DEBUG`. Please note that `ZEED` will supersede `DEBUG`.
105
+ You can use advanced filters compatible with [debug syntax](https://github.com/visionmedia/debug#wildcards). Use `ZEED` or `DEBUG` environment variables (`ZEED` supersedes `DEBUG`).
63
106
 
64
- Filtering by level is possible by setting `ZEED_LEVEL`, `LEVEL` or `DEBUG_LEVEL` to set the filter e.g. `ZEED_LEVEL=info` to hide debug logs.
107
+ Filter by level: `ZEED_LEVEL=info` to hide debug logs.
65
108
 
66
- To also write logs to a file you may set `ZEED_LOG` to the file path. All levels will be written to the file, no matter what other filtering has been chosen.
109
+ Write to file: `ZEED_LOG=/path/to/file.log`
67
110
 
68
- ### Log handlers
111
+ **Log Handlers:**
69
112
 
70
- It is also possible to set (`Logger.setHandlers([handlers])`) or add (`Logger.registerHandler(handler)`) new log handlers. You can choose from:
113
+ - `LoggerConsoleHandler(opt)` - Plain console output
114
+ - `LoggerBrowserHandler(opt)` - Colorful browser logs
115
+ - `LoggerNodeHandler(opt)` - Colorful Node.js logs
116
+ - `LoggerFileHandler(path, opt)` - File output with optional rotation
71
117
 
72
- - `LoggerConsoleHandler(opt)`: Plain basic output via `console` (default) - _(muted by default)_
73
- - `LoggerBrowserHandler(opt)`: Colorful log entries - _(muted by default)_
74
- - `LoggerNodeHandler(opt)`: Colorful logging for node.js - _(muted by default)_
75
- - `LoggerFileHandler(path, opt)`: Write to file
118
+ **Log Rotation Example:**
119
+ ```ts
120
+ import { LoggerFileHandler } from 'zeed'
76
121
 
77
- The file handler supports optional log rotation. You can enable rotation by providing a `rotation` option with rotation settings:
122
+ LoggerFileHandler('/var/log/app.log', {
123
+ rotation: {
124
+ size: '10M',
125
+ maxFiles: 5,
126
+ compress: 'gzip'
127
+ }
128
+ })
129
+ ```
78
130
 
79
- ```ts
80
- import { LoggerFileHandler } from 'zeed'
131
+ </details>
81
132
 
82
- // Enable rotation with default settings (10MB size, 5 files, gzip compression)
83
- LoggerFileHandler('/var/log/app.log', {
84
- rotation: true
85
- })
133
+ ---
86
134
 
87
- // Rotate logs daily
88
- LoggerFileHandler('/var/log/app.log', {
89
- rotation: { interval: '1d' }
90
- })
135
+ ### ⚙️ Async/Promise Utilities
91
136
 
92
- // Rotate when file reaches 10MB, keep max 5 files
93
- LoggerFileHandler('/var/log/app.log', {
94
- rotation: {
95
- size: '10M',
96
- maxFiles: 5,
97
- compress: 'gzip'
98
- }
99
- })
137
+ Powerful utilities for working with async operations:
100
138
 
101
- // Rotate hourly with custom settings
102
- LoggerFileHandler('/var/log/app.log', {
103
- rotation: {
104
- interval: '1h',
105
- maxSize: '100M',
106
- compress: true
107
- }
108
- })
109
- ```
139
+ ```ts
140
+ // Wait for an event
141
+ await waitOn(emitter, 'action', 1000)
110
142
 
111
- Available rotation options:
112
- - `size`: Rotate when file reaches this size (e.g., `'10M'`, `'1G'`)
113
- - `interval`: Rotate at time intervals (e.g., `'1d'`, `'1h'`, `'30m'`)
114
- - `maxFiles`: Maximum number of rotated files to keep
115
- - `maxSize`: Maximum total size of all log files
116
- - `compress`: Compress rotated files (`true`, `'gzip'`, or custom compressor function)
117
- - `rotate`: Number of files to keep in classical rotation mode
143
+ // Sleep for milliseconds
144
+ await sleep(1000)
118
145
 
119
- `opt` are general options like `level` for the log level or `filter` for custom filtering (see below). But it can also hold individual settings specific for a log handler.
146
+ // Timeout a promise
147
+ await timeout(asyncFn, 1000)
148
+
149
+ // Ensure a value is a Promise
150
+ await promisify(returnValue)
151
+ ```
120
152
 
121
- Examples for custom loggers are [breadcrumb tracking in Sentry.io](https://gist.github.com/holtwick/949d04151586cec529a671859ebbb650) or showing notifications to users on errors in a UI.
153
+ ---
122
154
 
123
- ### Global logging context
155
+ ### 🆔 Unique ID Generation
124
156
 
125
- You can use `Logger` in submodules and Zeed will make sure all logging goes through the same handlers, no matter what bundler is used. With `Logger.setLock(true)` any further changes to handlers, factories and log levels can be forbidden, to ensure no conflicting settings with submodules. You should set up the Logging very early in your main project before loading submodules.
157
+ Multiple ID generation strategies for different use cases:
126
158
 
127
- Loggers can be extended. `const newLog = log.extend("demo")` will append `:demo` to the current namespace.
159
+ ```ts
160
+ // UUID (Base62, 22 chars) - cryptographically secure
161
+ const id = uuid()
128
162
 
129
- ### Traces to source code
163
+ // Sortable UID with timestamp
164
+ const sortable = suid()
165
+ suidDate(sortable) // Extract timestamp
130
166
 
131
- Zeed tries to identify the origin in the source code of the log being issued. To get appropriate results in Node environments consider using the Source Map option:
167
+ // Named incremental IDs (great for debugging)
168
+ uname('user') // => 'user-0'
169
+ uname('user') // => 'user-1'
132
170
 
133
- ```sh
134
- node --enable-source-maps myapp.js
171
+ // Classic UUID v4
172
+ const classic = uuidv4() // => 'a7755f8d-ef6f-45e9-8db3-d29347a4a2a1'
135
173
  ```
136
174
 
137
- > Alternative logging solutions: [debug](https://github.com/visionmedia/debug), [tslog](https://github.com/fullstack-build/tslog), [consola](https://github.com/unjs/consola), [pino](https://getpino.io) or [winston](https://github.com/winstonjs/winston) to name just a few.
175
+ **Available ID types:** `uuid`, `uuidB32`, `suid`, `quid`, `uuidv4`
138
176
 
139
- ## Promise / async / await utilities
177
+ ---
140
178
 
141
- Wait for an event via `on` or `addEventListener`, useful in unit tests.
142
-
143
- ```ts
144
- await waitOn(emitter, 'action', 1000) // 1000 is optional timeout in ms
145
- ```
179
+ ### 🎯 Typed Event Emitter
146
180
 
147
- Wait for milliseconds.
181
+ Type-safe, async event emitter with full TypeScript support:
148
182
 
149
183
  ```ts
150
- await sleep(1000) // wait 1s
151
- ```
184
+ interface MyEvents {
185
+ inc: (count: number) => number
186
+ }
152
187
 
153
- Throw an error after timeout of 1 second.
188
+ const e = new Emitter<MyEvents>()
189
+ e.on('inc', async count => counter + 1)
190
+ await e.emit('inc', 1)
154
191
 
155
- ```ts
156
- await timeout(asynFn, 1000)
192
+ // Or use the .call proxy
193
+ await e.call.inc(1)
157
194
  ```
158
195
 
159
- If a value is not yet a Promise, wrap it to become one.
196
+ **Global emitter** for cross-module communication:
160
197
 
161
198
  ```ts
162
- await promisify(returnValue)
163
- ```
199
+ declare global {
200
+ interface ZeedGlobalEmitter {
201
+ test: (x: string) => void
202
+ }
203
+ }
164
204
 
165
- ## Unique ID
205
+ getGlobalEmitter().call.test('Hello World')
206
+ ```
166
207
 
167
- Get a random unique ID of fixed length of 22 chars (these are 16 bytes = 128 bit, encoded in Base62). According to [Nano ID Collision Calculator](https://zelark.github.io/nano-id-cc/): "~597 billion years needed, in order to have a 1% probability of at least one collision."
208
+ ---
168
209
 
169
- ```ts
170
- const id1 = uuid() // base62 encoded => 22 chars
171
- const id2 = uuidB32() // base32 encoded => 26 chars
172
- ```
210
+ ### 💬 Messaging
173
211
 
174
- Get an incremental unique ID for current process with named groups, great for debugging.
212
+ Type-safe messaging infrastructure for client-server communication:
175
213
 
176
214
  ```ts
177
- uname('something') // => 'something-0'
178
- uname('other') // => 'other-0'
179
- uname('something') // => 'something-1'
215
+ const m = useMessageHub({ channel }).send<MyMessages>()
216
+ m.echo({ hello: 'world' })
180
217
  ```
181
218
 
182
- Sortable unique ID inspired by [go-uuid](https://github.com/rsms/go-uuid). 6 bytes encode time and 10 bytes are random. String is Base62 encoded. Date can be extracted from the ID.
219
+ > 📖 [Full messaging documentation](./src/common/msg/README.md)
183
220
 
184
- ```ts
185
- const shortSortableId = suid() // = '000iMi10bt6YK8buKlYPsd'
186
- suidDate(shortSortableId) // = 2021-07-03T22:42:40.727Z
187
- shortSortableId < suid() // = true
188
- ```
221
+ ---
189
222
 
190
- Overview of available IDs:
223
+ ### Schema Validation
191
224
 
192
- - `uuid`
193
- - `uuidB32`
194
- - `suid`
195
- - `quid`: Quick ID great for UI purposes of patter `id-1`, `id-2`, ...
196
- - `uuidv4`: The _classic_ UID like `a7755f8d-ef6f-45e9-8db3-d29347a4a2a1`
225
+ <div align="center">
197
226
 
198
- ## Typed event emitter
227
+ **🎯 Type-safe 🔄 Standard Schema Compatible • 🚀 Zero Dependencies**
199
228
 
200
- Typed and async emitter:
229
+ </div>
230
+
231
+ Powerful schema validation with full TypeScript inference and [Standard Schema](https://github.com/standard-schema/standard-schema) support:
201
232
 
202
233
  ```ts
203
- interface MyEvents {
204
- inc: (count: number) => number
205
- }
234
+ import { z } from 'zeed'
235
+
236
+ // Define and validate schemas
237
+ const userSchema = z.object({
238
+ name: z.string(),
239
+ email: z.string(),
240
+ age: z.number().optional(),
241
+ role: z.stringLiterals(['admin', 'user', 'guest']),
242
+ })
206
243
 
207
- const counter = 0
244
+ // Full type inference
245
+ type User = z.infer<typeof userSchema>
208
246
 
209
- const e = new Emitter() < MyEvents > e.on('inc', async count => counter + 1)
210
- await e.emit('inc', 1) // counter === 1
247
+ // Parse and validate
248
+ const user = schemaParseObject(userSchema, data)
211
249
  ```
212
250
 
213
- It is also possible to alternatively use a Proxy called `.call` that makes nice dynamic function calls of the events:
214
-
215
- ```ts
216
- await e.call.inc(1)
217
- ```
251
+ <details>
252
+ <summary>🔗 Standard Schema Compatibility</summary>
218
253
 
219
- We can also alternatively declare the listeners this way:
254
+ Compatible with **tRPC**, **TanStack Form/Router**, **Hono**, and [40+ other libraries](https://github.com/standard-schema/standard-schema#what-tools--frameworks-accept-spec-compliant-schemas):
220
255
 
221
256
  ```ts
222
- e.onCall({
223
- async inc(count: number): number {
224
- return counter + 1
225
- },
257
+ // Use with any standard-schema-compatible library
258
+ const schema = z.object({
259
+ name: z.string(),
260
+ count: z.number(),
226
261
  })
227
- ```
228
-
229
- You can also use a global emitter that will be available even over module boundaries:
230
262
 
231
- ```ts
232
- declare global {
233
- interface ZeedGlobalEmitter {
234
- test: (x: string) => void
235
- }
263
+ const result = schema['~standard'].validate({ name: 'test', count: 42 })
264
+ if (result.issues) {
265
+ console.error('Validation failed:', result.issues)
266
+ }
267
+ else {
268
+ console.log('Valid data:', result.value)
236
269
  }
237
-
238
- getGlobalEmitter().emit('test', 'Hello World') // or
239
- getGlobalEmitter().call.test('Hello World')
240
270
  ```
241
271
 
242
- ## Messaging
272
+ **Features:**
273
+ - Primitives: `string()`, `number()`, `int()`, `boolean()`, `any()`
274
+ - Objects: `object()`, `record()`, `pick()`, `omit()`, `extend()`, `partial()`, `required()`
275
+ - Arrays & Tuples: `array()`, `tuple()`
276
+ - Unions & Literals: `union()`, `literal()`, `stringLiterals()`
277
+ - Modifiers: `.optional()`, `.default()`, `.describe()`
243
278
 
244
- Communicating to servers or other remote parts through messages as if they were methods on a local object in a type safe way:
279
+ </details>
245
280
 
246
- ```ts
247
- const m = useMessageHub({ cannel }).send<MyMessages>()
248
- m.echo({ hello: 'world' })
249
- ```
281
+ > 📖 [Complete schema documentation](./src/common/schema/README.md)
250
282
 
251
- > But there is much more basic infrastructure for communication available in `zeed`. More details at [src/common/msg/README.md](./src/common/msg/README.md)
283
+ ---
252
284
 
253
- ## CRDT compatible sorting
285
+ ### 📊 Additional Utilities
254
286
 
255
- A conflict free sorting algorithm with minimal data changes. Just extend an object from `SortableItem`, which will provide an additional property of type number called `sort_weight`.
287
+ <table>
288
+ <tr>
289
+ <td width="50%">
256
290
 
291
+ **🔄 CRDT Sorting**
257
292
  ```ts
258
293
  interface Row extends SortedItem {
259
294
  id: string
260
295
  title: string
261
296
  }
262
-
263
- const rows: Row[] = []
264
-
265
- function getSortedRows() {
266
- return sortedItems(rows)
267
- }
297
+ sortedItems(rows)
268
298
  ```
269
299
 
270
- Use `startSortWeight`, `endSortWeight` and `moveSortWeight` to get initial values for new entries or manipulate existing ones.
271
-
272
- > Essays:
273
- >
274
- > - [Holtwick: Smart Reordering for UITableView](https://holtwick.de/en/blog/smart-table-reordering)
275
- > - [Figma: Fractional Indexing](https://www.figma.com/blog/realtime-editing-of-ordered-sequences/#fractional-indexing)
276
- >
277
- > The implementation in Zeed is pretty straight forward, but there are also more sophisticated approaches available as alternatives:
278
- >
279
- > - [Implementing Fractional Indexing](https://observablehq.com/@dgreensp/implementing-fractional-indexing)
280
- > - [fractional-indexing](https://github.com/rocicorp/fractional-indexing) - npm module
281
-
282
- ## Custom binary data encoding / decoding
283
-
284
- Integration of the [base-x](https://github.com/cryptocoinjs/base-x) code to support encoding and decoding to any alphabet, but especially base2, base16 (hex), base32, base62, base64.
285
- Human-readable yet efficient encoding of binary data.
286
-
300
+ **🔐 Binary Encoding**
287
301
  ```ts
288
- const sample = new UInt8Array([1, 2, 3])
289
302
  const { encode, decode } = useBase(62)
290
- decode(encode(sample)) === sample // = true
303
+ decode(encode(data)) === data
291
304
  ```
292
305
 
293
- ## Deeply nested object utilities
294
-
295
- Handle complex objects.
306
+ </td>
307
+ <td width="50%">
296
308
 
309
+ **🔍 Deep Object Utils**
297
310
  ```ts
298
- deepEqual({ a: { b: 1 } }, { a: { b: 2 } }) // false
299
- deepMerge({ a: { b: 1 } }, { c: 3, a: { d: 4 } }) // {a:{b:1, d:4}, c:4}
311
+ deepEqual(obj1, obj2)
312
+ deepMerge(obj1, obj2)
300
313
  ```
301
314
 
302
- ## Disposer
303
-
304
- `useDispose` will simplify cleaning up objects. You just need to `add` a function or and object with `dispose` method to be called for cleanup. This can also be nested. A simple example is a timer:
305
-
315
+ **🧹 Resource Disposal**
306
316
  ```ts
307
- function disposableTimer() {
308
- const timeout = setTimeout(() => console.log('hello world'), 1000)
309
- return () => clearTimeout(timeout)
310
- }
311
-
312
317
  const dispose = useDispose()
313
-
314
- const obj = disposableTimer()
315
- dispose.add(obj)
316
-
317
- // or
318
-
319
- const untrackTimer = dispose.add(disposableTimer())
320
- untrackTimer() // dispose single object by return value of .track
321
-
322
- // then later dispose all
323
-
324
- dispose()
318
+ dispose.add(cleanup)
319
+ await dispose()
325
320
  ```
326
321
 
327
- You can also `untrack` single entries. Entries are untracked LIFO. Disposers can also return a Promise and therefore `await` async disposals.
322
+ </td>
323
+ </tr>
324
+ </table>
328
325
 
329
- The disposer itself is also a call to dispose i.e. for convenience you can add it to objects and provide `dispose` easily like this:
326
+ ---
330
327
 
331
- ```ts
332
- class DisposeExample {
333
- // the trick is to assign to member `dispose`, will be both
334
- // the destructor and the registration point for disposables
335
- dispose = useDispose()
328
+ ## 📦 More Features
336
329
 
337
- constructor() {
338
- this.dispose.add(disposableTimer())
339
- }
340
- }
330
+ Zeed includes many more utilities - explore the [full API documentation](https://zeed.holtwick.de/)!
341
331
 
342
- const obj = new DisposeExample()
343
- // ...
344
- obj.dispose() // or async via `await obj.dispose()`
345
- ```
332
+ ## 🤝 Related Projects
346
333
 
347
- ## Much more...
334
+ **By the same author:**
335
+ - [zeed-dom](https://github.com/holtwick/zeed-dom) - DOM manipulation utilities
336
+ - [zerva](https://github.com/holtwick/zerva) - Modular server framework
348
337
 
349
- ...browse the source!
338
+ **Similar utility libraries:**
339
+ - [lib0](https://github.com/dmonad/lib0) - Fundamental utility functions
340
+ - [antfu/utils](https://github.com/antfu/utils) - Collection of common utilities
341
+ - [vueuse](https://vueuse.org/) - Vue composition utilities
342
+ - [unjs](https://github.com/unjs/) - Unified JavaScript tools
350
343
 
351
- ## Related and Links
344
+ ## 📄 License
352
345
 
353
- Related projects:
346
+ MIT
354
347
 
355
- - [zeed-dom](https://github.com/holtwick/zeed-dom)
356
- - [zerva](https://github.com/holtwick/zerva)
348
+ ---
357
349
 
358
- Recommended other collections of common JS utils:
350
+ <div align="center">
359
351
 
360
- - [lib0](https://github.com/dmonad/lib0)
361
- - [antfu/utils](https://github.com/antfu/utils)
362
- - [vueuse](https://vueuse.org/)
363
- - [unjs](https://github.com/unjs/)
352
+ **Built with ❤️ by [Dirk Holtwick](https://holtwick.de)**
364
353
 
365
- Code integrated from other sources:
354
+ [⭐ Star on GitHub](https://github.com/holtwick/zeed) • [📖 Documentation](https://zeed.holtwick.de/) • [🐛 Report Issue](https://github.com/holtwick/zeed/issues)
366
355
 
367
- - [base-x](https://github.com/cryptocoinjs/base-x/blob/master/ts_src/index.ts) MIT
368
- - [debug](https://github.com/visionmedia/debug) MIT
369
- - [dotenv](https://github.com/motdotla/dotenv) BSD-2
370
- - [filenamify](https://github.com/sindresorhus/filenamify) MIT
371
- - [gravatar](https://github.com/mazondo/gravatarjs/blob/master/gravatar.js) MIT
372
- - [lib0](https://github.com/dmonad/lib0) MIT
373
- - [birpc](https://github.com/antfu/birpc) MIT
356
+ </div>
@@ -1,2 +1,2 @@
1
- import{b as k,c as S,d as g,e as j,f as m,g as p,k as i,l,m as T,n as V,o as x,p as b,q as s,r as c,s as f}from"./chunk-VFRJ7C3X.js";import{b as d,e as _}from"./chunk-6VFFIKPT.js";import{a as r}from"./chunk-5NKC2EQJ.js";function y(e){let n={type:e.type};if(e._optional!==void 0&&(n.optional=e._optional),e._meta!==void 0&&(n.meta=e._meta),e._default!==void 0&&!d(e._default)&&(n.default=e._default),e._object!==void 0){n.object={};for(let[t,a]of Object.entries(e._object))n.object[t]=y(a)}return e._type!==void 0&&(_(e._type)?n.tupleTypes=e._type.map(t=>y(t)):n.itemType=y(e._type)),e._union!==void 0&&(n.union=e._union.map(t=>y(t))),e._enumValues!==void 0&&(n.enumValues=e._enumValues),e._args!==void 0&&(n.args=e._args.map(t=>y(t))),e._ret!==void 0&&(n.ret=y(e._ret)),e._info!==void 0&&(n.info=y(e._info)),e.type==="literal"&&e._default!==void 0&&(n.literalValue=e._default),n}r(y,"serializeSchema");function o(e){let n;switch(e.type){case"string":e.enumValues?n=x(e.enumValues):n=k();break;case"number":n=S();break;case"int":n=g();break;case"boolean":n=j();break;case"none":n=m();break;case"any":n=p();break;case"object":if(e.object){let t={};for(let[a,u]of Object.entries(e.object))t[a]=o(u);n=i(t)}else n=i({});break;case"record":e.itemType?n=l(o(e.itemType)):n=l(p());break;case"array":e.itemType?n=s(o(e.itemType)):n=s(p());break;case"tuple":if(e.tupleTypes){let t=e.tupleTypes.map(a=>o(a));n=b(t)}else n=b([]);break;case"union":if(e.union){let t=e.union.map(a=>o(a));n=T(t)}else n=T([]);break;case"literal":e.literalValue!==void 0?n=V(e.literalValue):n=p();break;case"function":if(e.args&&e.ret){let t=e.args.map(u=>o(u)),a=o(e.ret);n=c(t,a)}else n=c([],p());break;case"rpc":if(e.info&&e.ret){let t=o(e.info),a=o(e.ret);n=f(t,a)}else if(e.ret){let t=o(e.ret);n=f(void 0,t)}else n=f();break;default:n=p();break}return e.optional&&(n=n.optional()),e.default!==void 0&&(n=n.default(e.default)),e.meta&&(n=n.meta(e.meta)),n}r(o,"deserializeSchema");export{y as a,o as b};
2
- //# sourceMappingURL=chunk-2Z75UI2C.js.map
1
+ import{b as k,c as S,d as g,e as j,f as m,g as p,k as i,l,m as T,n as V,o as x,p as b,q as s,r as c,s as f}from"./chunk-LLDVPAUS.js";import{b as d,e as _}from"./chunk-6VFFIKPT.js";import{a as r}from"./chunk-5NKC2EQJ.js";function y(e){let n={type:e.type};if(e._optional!==void 0&&(n.optional=e._optional),e._meta!==void 0&&(n.meta=e._meta),e._default!==void 0&&!d(e._default)&&(n.default=e._default),e._object!==void 0){n.object={};for(let[t,a]of Object.entries(e._object))n.object[t]=y(a)}return e._type!==void 0&&(_(e._type)?n.tupleTypes=e._type.map(t=>y(t)):n.itemType=y(e._type)),e._union!==void 0&&(n.union=e._union.map(t=>y(t))),e._enumValues!==void 0&&(n.enumValues=e._enumValues),e._args!==void 0&&(n.args=e._args.map(t=>y(t))),e._ret!==void 0&&(n.ret=y(e._ret)),e._info!==void 0&&(n.info=y(e._info)),e.type==="literal"&&e._default!==void 0&&(n.literalValue=e._default),n}r(y,"serializeSchema");function o(e){let n;switch(e.type){case"string":e.enumValues?n=x(e.enumValues):n=k();break;case"number":n=S();break;case"int":n=g();break;case"boolean":n=j();break;case"none":n=m();break;case"any":n=p();break;case"object":if(e.object){let t={};for(let[a,u]of Object.entries(e.object))t[a]=o(u);n=i(t)}else n=i({});break;case"record":e.itemType?n=l(o(e.itemType)):n=l(p());break;case"array":e.itemType?n=s(o(e.itemType)):n=s(p());break;case"tuple":if(e.tupleTypes){let t=e.tupleTypes.map(a=>o(a));n=b(t)}else n=b([]);break;case"union":if(e.union){let t=e.union.map(a=>o(a));n=T(t)}else n=T([]);break;case"literal":e.literalValue!==void 0?n=V(e.literalValue):n=p();break;case"function":if(e.args&&e.ret){let t=e.args.map(u=>o(u)),a=o(e.ret);n=c(t,a)}else n=c([],p());break;case"rpc":if(e.info&&e.ret){let t=o(e.info),a=o(e.ret);n=f(t,a)}else if(e.ret){let t=o(e.ret);n=f(void 0,t)}else n=f();break;default:n=p();break}return e.optional&&(n=n.optional()),e.default!==void 0&&(n=n.default(e.default)),e.meta&&(n=n.meta(e.meta)),n}r(o,"deserializeSchema");export{y as a,o as b};
2
+ //# sourceMappingURL=chunk-3LSWLKUP.js.map
@@ -1,3 +1,3 @@
1
- import{c as L}from"./chunk-DTFGASVV.js";import{b as d}from"./chunk-IMURZASN.js";import{b as g}from"./chunk-ACQZBCFF.js";import{b as f,d as p}from"./chunk-D3NCJPFL.js";import{c as k,d as H,e as W}from"./chunk-RZR3ECDT.js";import{a as m}from"./chunk-5NKC2EQJ.js";import{createWriteStream as x,mkdirSync as I}from"fs";import{basename as M,dirname as N,resolve as D}from"path";import E from"process";var u={};function B(e,v={}){let{level:y=void 0,filter:O=void 0,time:R=!0,pretty:S=!1,rotation:$}=v;e=D(E.cwd(),e);let l=N(e);I(l,{recursive:!0});let i=d($),a;i?(i.path=l,a=L(M(e),i)):a=x(e,{flags:"a"});let b=f(O),w=p(y);return t=>{if(!w(t.level)||!b(t.name))return;let o=R?`${new Date().toISOString()} `:"",s=t.name||"",c=u[s||""];c==null&&(u[s]=c);let r=[`[${s||"*"}]`,g(t.messages,{pretty:S})];function n(...F){a.write(`${F.join(" ")}
1
+ import{c as L}from"./chunk-DTFGASVV.js";import{b as d}from"./chunk-KIKHNNKK.js";import{b as g}from"./chunk-ACQZBCFF.js";import{b as f,d as p}from"./chunk-D3NCJPFL.js";import{c as k,d as H,e as W}from"./chunk-RZR3ECDT.js";import{a as m}from"./chunk-5NKC2EQJ.js";import{createWriteStream as x,mkdirSync as I}from"fs";import{basename as M,dirname as N,resolve as D}from"path";import E from"process";var u={};function B(e,v={}){let{level:y=void 0,filter:O=void 0,time:R=!0,pretty:S=!1,rotation:$}=v;e=D(E.cwd(),e);let l=N(e);I(l,{recursive:!0});let i=d($),a;i?(i.path=l,a=L(M(e),i)):a=x(e,{flags:"a"});let b=f(O),w=p(y);return t=>{if(!w(t.level)||!b(t.name))return;let o=R?`${new Date().toISOString()} `:"",s=t.name||"",c=u[s||""];c==null&&(u[s]=c);let r=[`[${s||"*"}]`,g(t.messages,{pretty:S})];function n(...F){a.write(`${F.join(" ")}
2
2
  `)}switch(m(n,"write"),t.level){case 1:n(`${o}I|* `,...r);break;case 2:n(`${o}W|** `,...r);break;case 3:n(`${o}E|***`,...r);break;default:n(`${o}D| `,...r);break}}}m(B,"LoggerFileHandler");export{B as a};
3
- //# sourceMappingURL=chunk-Z3CCAUP7.js.map
3
+ //# sourceMappingURL=chunk-4X7UJTXJ.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkIVUEQANCcjs = require('./chunk-IVUEQANC.cjs');var _chunkP7XCQ7WVcjs = require('./chunk-P7XCQ7WV.cjs');var i=class s{static{_chunkP7XCQ7WVcjs.a.call(void 0, this,"Type")}constructor(e,t={}){this.type=e,Object.assign(this,t)}get"~standard"(){return{version:1,vendor:"zeed",validate:_chunkP7XCQ7WVcjs.a.call(void 0, e=>this.validate(e),"validate"),types:{input:void 0,output:void 0}}}validate(e){if(e==null)return this._optional?{value:void 0}:this._default!==void 0?{value:_chunkIVUEQANCcjs.b.call(void 0, this._default)?this._default(this):this._default}:{issues:[{message:"Required value is missing",path:[]}]};if(this.type==="literal"&&this._default!==e)return{issues:[{message:`Expected literal value ${this._default}, got ${e}`,path:[]}]};if(this._enumValues&&Array.isArray(this._enumValues)&&!this._enumValues.includes(e))return{issues:[{message:`Expected one of [${this._enumValues.join(", ")}], got ${e}`,path:[]}]};if(this._union&&Array.isArray(this._union)){for(let t of this._union){let n=t.validate(e);if(!n.issues)return n}return{issues:[{message:"Value does not match any union variant",path:[]}]}}if(this.type==="array"||this.type==="tuple"){if(!Array.isArray(e))return{issues:[{message:`Expected array, got ${typeof e}`,path:[]}]};if(this.type==="tuple"&&this._type){let t=this._type;if(e.length!==t.length)return{issues:[{message:`Expected tuple of length ${t.length}, got ${e.length}`,path:[]}]};let n=[];for(let r=0;r<t.length;r++){let a=t[r].validate(e[r]);if(a.issues)for(let p of a.issues)n.push({message:p.message,path:[r,...p.path||[]]})}if(n.length>0)return{issues:n}}else if(this._type){let t=this._type,n=[];for(let r=0;r<e.length;r++){let a=t.validate(e[r]);if(a.issues)for(let p of a.issues)n.push({message:p.message,path:[r,...p.path||[]]})}if(n.length>0)return{issues:n}}}if(this._object){if(!_chunkIVUEQANCcjs.a.call(void 0, e))return{issues:[{message:`Expected object, got ${typeof e}`,path:[]}]};let t=[],n=e;for(let r in this._object){let a=this._object[r],p=n[r],y=a.validate(p);if(y.issues)for(let f of y.issues)t.push({message:f.message,path:[r,...f.path||[]]})}return t.length>0?{issues:t}:{value:e,issues:void 0}}if(this.type==="record"&&this._type){if(!_chunkIVUEQANCcjs.a.call(void 0, e))return{issues:[{message:`Expected object, got ${typeof e}`,path:[]}]};let t=this._type,n=[],r=e;for(let a in r){let p=t.validate(r[a]);if(p.issues)for(let y of p.issues)n.push({message:y.message,path:[a,...y.path||[]]})}if(n.length>0)return{issues:n}}return this._check&&!this._check(e)?{issues:[{message:`Expected ${this.type}, got ${typeof e}`,path:[]}]}:{value:e}}_cloneWithProps(e={}){let t=new s(this.type),n=["_default","_optional","_meta","_check","_object","_type","_union","_enumValues","_args","_ret","_info"];for(let r of n)this[r]!==void 0&&(t[r]=this[r]);return Object.assign(t,e),t}static _copyTypeProperties(e,t){let n=["_check","_default","_meta","_object","_type","_enumValues"];for(let r of n)e[r]!==void 0&&(t[r]=e[r])}optional(){return this._cloneWithProps({_optional:!0})}default(e){return this._cloneWithProps({_default:e})}meta(e){return this._cloneWithProps({_meta:e})}describe(e){let t=this._meta||{};return t.desc=e,this._cloneWithProps({_meta:t})}extend(e){if(!this._object)throw new Error("extend() can only be used on object schemas");let t={...this._object,...e};return T(t)}pick(e){if(!this._object)throw new Error("pick() can only be used on object schemas");let t={};for(let n of Object.keys(e))n in this._object&&(t[n]=this._object[n]);return T(t)}omit(e){if(!this._object)throw new Error("omit() can only be used on object schemas");let t={...this._object};for(let n of Object.keys(e))delete t[n];return T(t)}_transformObjectProperties(e,t){if(!this._object)throw new Error("This operation can only be used on object schemas");let n={},r=this._object;for(let[a,p]of Object.entries(r)){let y=!t||a in t;n[a]=e(a,p,y)}return T(n)}partial(e){if(!this._object)throw new Error("partial() can only be used on object schemas");return this._transformObjectProperties((t,n,r)=>r?s._cloneTypeWithOptional(n,!0):n,e)}required(e){if(!this._object)throw new Error("required() can only be used on object schemas");return this._transformObjectProperties((t,n,r)=>r?s._cloneTypeWithOptional(n,!1):n,e)}static _cloneTypeWithOptional(e,t){let n=new s(e.type);return s._copyTypeProperties(e,n),n._optional=t,n}};function k(){return new i("string",{_check:_chunkIVUEQANCcjs.h})}_chunkP7XCQ7WVcjs.a.call(void 0, k,"string");function d(){return new i("number",{_check:_chunkIVUEQANCcjs.i})}_chunkP7XCQ7WVcjs.a.call(void 0, d,"number");function j(){return new i("int",{_check:_chunkIVUEQANCcjs.j})}_chunkP7XCQ7WVcjs.a.call(void 0, j,"int");function R(){return new i("boolean",{_check:_chunkIVUEQANCcjs.l})}_chunkP7XCQ7WVcjs.a.call(void 0, R,"boolean");function g(){return new i("none",{_check:_chunkP7XCQ7WVcjs.a.call(void 0, s=>s==null,"_check"),_optional:!0})}_chunkP7XCQ7WVcjs.a.call(void 0, g,"none");function K(){return new i("any",{_check:_chunkP7XCQ7WVcjs.a.call(void 0, s=>s!=null,"_check")})}_chunkP7XCQ7WVcjs.a.call(void 0, K,"any");var w=d,O= exports.i =d,P= exports.j =d;function T(s){return new i("object",{_check:_chunkIVUEQANCcjs.a,_object:s})}_chunkP7XCQ7WVcjs.a.call(void 0, T,"object");function V(s){return new i("record",{_check:_chunkIVUEQANCcjs.a,_type:s})}_chunkP7XCQ7WVcjs.a.call(void 0, V,"record");function I(s){return new i("union",{_check:_chunkP7XCQ7WVcjs.a.call(void 0, e=>s.some(t=>_nullishCoalesce(_optionalChain([t, 'access', _2 => _2._check, 'optionalCall', _3 => _3(e)]), () => (!1))),"_check"),_union:s})}_chunkP7XCQ7WVcjs.a.call(void 0, I,"union");function A(s){return new i("literal",{_check:_chunkP7XCQ7WVcjs.a.call(void 0, e=>e===s,"_check"),_default:s})}_chunkP7XCQ7WVcjs.a.call(void 0, A,"literal");function E(s){return new i("string",{_check:_chunkP7XCQ7WVcjs.a.call(void 0, e=>typeof e=="string"&&s.includes(e),"_check"),_enumValues:s})}_chunkP7XCQ7WVcjs.a.call(void 0, E,"stringLiterals");function S(s){return new i("tuple",{_check:_chunkP7XCQ7WVcjs.a.call(void 0, e=>Array.isArray(e)&&e.length===s.length&&s.every((t,n)=>_nullishCoalesce(_optionalChain([t, 'access', _4 => _4._check, 'optionalCall', _5 => _5(e[n])]), () => (!1))),"_check"),_type:s})}_chunkP7XCQ7WVcjs.a.call(void 0, S,"tuple");function $(s){return new i("array",{_check:_chunkIVUEQANCcjs.e,_type:s})}_chunkP7XCQ7WVcjs.a.call(void 0, $,"array");function q(s,e){return new i("function",{_check:_chunkIVUEQANCcjs.b,_args:s,_ret:e})}_chunkP7XCQ7WVcjs.a.call(void 0, q,"func");function F(s,e){return new i("rpc",{_check:_chunkIVUEQANCcjs.b,_info:s,_ret:_nullishCoalesce(e, () => (g()))})}_chunkP7XCQ7WVcjs.a.call(void 0, F,"rpc");exports.a = i; exports.b = k; exports.c = d; exports.d = j; exports.e = R; exports.f = g; exports.g = K; exports.h = w; exports.i = O; exports.j = P; exports.k = T; exports.l = V; exports.m = I; exports.n = A; exports.o = E; exports.p = S; exports.q = $; exports.r = q; exports.s = F;
2
+ //# sourceMappingURL=chunk-5RJ6XORD.cjs.map