@polymarket-developers/clob-client 1.0.7

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 (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +78 -0
  4. package/cache/LICENSE +21 -0
  5. package/cache/README.md +62 -0
  6. package/cache/dist/declarations/src/index.d.ts +2 -0
  7. package/cache/dist/declarations/types/index.d.ts +45 -0
  8. package/cache/dist/emotion-cache.browser.cjs.default.js +1 -0
  9. package/cache/dist/emotion-cache.browser.cjs.js +471 -0
  10. package/cache/dist/emotion-cache.browser.cjs.mjs +2 -0
  11. package/cache/dist/emotion-cache.browser.development.cjs.default.js +1 -0
  12. package/cache/dist/emotion-cache.browser.development.cjs.js +616 -0
  13. package/cache/dist/emotion-cache.browser.development.cjs.mjs +2 -0
  14. package/cache/dist/emotion-cache.browser.development.esm.js +612 -0
  15. package/cache/dist/emotion-cache.browser.esm.js +467 -0
  16. package/cache/dist/emotion-cache.cjs.d.mts +3 -0
  17. package/cache/dist/emotion-cache.cjs.d.ts +3 -0
  18. package/cache/dist/emotion-cache.cjs.default.d.ts +1 -0
  19. package/cache/dist/emotion-cache.cjs.default.js +1 -0
  20. package/cache/dist/emotion-cache.cjs.js +565 -0
  21. package/cache/dist/emotion-cache.cjs.mjs +2 -0
  22. package/cache/dist/emotion-cache.development.cjs.default.js +1 -0
  23. package/cache/dist/emotion-cache.development.cjs.js +714 -0
  24. package/cache/dist/emotion-cache.development.cjs.mjs +2 -0
  25. package/cache/dist/emotion-cache.development.edge-light.cjs.default.js +1 -0
  26. package/cache/dist/emotion-cache.development.edge-light.cjs.js +621 -0
  27. package/cache/dist/emotion-cache.development.edge-light.cjs.mjs +2 -0
  28. package/cache/dist/emotion-cache.development.edge-light.esm.js +612 -0
  29. package/cache/dist/emotion-cache.development.esm.js +705 -0
  30. package/cache/dist/emotion-cache.edge-light.cjs.default.js +1 -0
  31. package/cache/dist/emotion-cache.edge-light.cjs.js +490 -0
  32. package/cache/dist/emotion-cache.edge-light.cjs.mjs +2 -0
  33. package/cache/dist/emotion-cache.edge-light.esm.js +481 -0
  34. package/cache/dist/emotion-cache.esm.js +556 -0
  35. package/cache/package.json +100 -0
  36. package/cache/src/conditions/false.js +1 -0
  37. package/cache/src/conditions/is-browser.js +1 -0
  38. package/cache/src/conditions/true.js +1 -0
  39. package/cache/src/index.d.ts +2 -0
  40. package/cache/src/index.js +257 -0
  41. package/cache/src/prefixer.js +340 -0
  42. package/cache/src/stylis-plugins.js +269 -0
  43. package/cache/src/types.js +26 -0
  44. package/cache/types/index.d.ts +45 -0
  45. package/index.d.ts +63 -0
  46. package/index.js +204 -0
  47. package/package.json +27 -0
  48. package/utils.js +15 -0
@@ -0,0 +1,257 @@
1
+ import { StyleSheet } from '@emotion/sheet'
2
+ /* import { type EmotionCache, type SerializedStyles } from '@emotion/utils' */
3
+ import {
4
+ serialize,
5
+ compile,
6
+ middleware,
7
+ rulesheet,
8
+ stringify,
9
+ COMMENT
10
+ } from 'stylis'
11
+ import weakMemoize from '@emotion/weak-memoize'
12
+ import memoize from '@emotion/memoize'
13
+ import isDevelopment from '#is-development'
14
+ import isBrowser from '#is-browser'
15
+ import {
16
+ compat,
17
+ removeLabel,
18
+ createUnsafeSelectorsAlarm,
19
+ incorrectImportAlarm
20
+ } from './stylis-plugins'
21
+ import { prefixer } from './prefixer'
22
+ /* import type { StylisPlugin } from './types' */
23
+
24
+ /*
25
+ export type Options = {
26
+ nonce?: string,
27
+ stylisPlugins?: StylisPlugin[],
28
+ key: string,
29
+ container?: HTMLElement,
30
+ speedy?: boolean,
31
+ prepend?: boolean,
32
+ insertionPoint?: HTMLElement
33
+ }
34
+ */
35
+
36
+ let getServerStylisCache = isBrowser
37
+ ? undefined
38
+ : weakMemoize(() =>
39
+ memoize(() => {
40
+ let cache = {}
41
+ return name => cache[name]
42
+ })
43
+ )
44
+
45
+ const defaultStylisPlugins = [prefixer]
46
+
47
+ let createCache = (options /*: Options */) /*: EmotionCache */ => {
48
+ let key = options.key
49
+
50
+ if (isDevelopment && !key) {
51
+ throw new Error(
52
+ "You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\n" +
53
+ `If multiple caches share the same key they might "fight" for each other's style elements.`
54
+ )
55
+ }
56
+
57
+ if (isBrowser && key === 'css') {
58
+ const ssrStyles = document.querySelectorAll(
59
+ `style[data-emotion]:not([data-s])`
60
+ )
61
+
62
+ // get SSRed styles out of the way of React's hydration
63
+ // document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
64
+ // note this very very intentionally targets all style elements regardless of the key to ensure
65
+ // that creating a cache works inside of render of a React component
66
+ Array.prototype.forEach.call(ssrStyles, (node /*: HTMLStyleElement */) => {
67
+ // we want to only move elements which have a space in the data-emotion attribute value
68
+ // because that indicates that it is an Emotion 11 server-side rendered style elements
69
+ // while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
70
+ // Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
71
+ // so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
72
+ // will not result in the Emotion 10 styles being destroyed
73
+ const dataEmotionAttribute = node.getAttribute('data-emotion')
74
+ if (dataEmotionAttribute.indexOf(' ') === -1) {
75
+ return
76
+ }
77
+
78
+ document.head.appendChild(node)
79
+ node.setAttribute('data-s', '')
80
+ })
81
+ }
82
+
83
+ const stylisPlugins = options.stylisPlugins || defaultStylisPlugins
84
+
85
+ if (isDevelopment) {
86
+ if (/[^a-z-]/.test(key)) {
87
+ throw new Error(
88
+ `Emotion key must only contain lower case alphabetical characters and - but "${key}" was passed`
89
+ )
90
+ }
91
+ }
92
+ let inserted = {}
93
+ let container /* : Node */
94
+ const nodesToHydrate = []
95
+ if (isBrowser) {
96
+ container = options.container || document.head
97
+
98
+ Array.prototype.forEach.call(
99
+ // this means we will ignore elements which don't have a space in them which
100
+ // means that the style elements we're looking at are only Emotion 11 server-rendered style elements
101
+ document.querySelectorAll(`style[data-emotion^="${key} "]`),
102
+ (node /*: HTMLStyleElement */) => {
103
+ const attrib = node.getAttribute(`data-emotion`).split(' ')
104
+ for (let i = 1; i < attrib.length; i++) {
105
+ inserted[attrib[i]] = true
106
+ }
107
+ nodesToHydrate.push(node)
108
+ }
109
+ )
110
+ }
111
+
112
+ let insert /*: (
113
+ selector: string,
114
+ serialized: SerializedStyles,
115
+ sheet: StyleSheet,
116
+ shouldCache: boolean
117
+ ) => string | void */
118
+ const omnipresentPlugins = [compat, removeLabel]
119
+
120
+ if (isDevelopment) {
121
+ omnipresentPlugins.push(
122
+ createUnsafeSelectorsAlarm({
123
+ get compat() {
124
+ return cache.compat
125
+ }
126
+ }),
127
+ incorrectImportAlarm
128
+ )
129
+ }
130
+
131
+ if (isBrowser) {
132
+ let currentSheet
133
+
134
+ const finalizingPlugins = [
135
+ stringify,
136
+ isDevelopment
137
+ ? element => {
138
+ if (!element.root) {
139
+ if (element.return) {
140
+ currentSheet.insert(element.return)
141
+ } else if (element.value && element.type !== COMMENT) {
142
+ // insert empty rule in non-production environments
143
+ // so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet
144
+ currentSheet.insert(`${element.value}{}`)
145
+ }
146
+ }
147
+ }
148
+ : rulesheet(rule => {
149
+ currentSheet.insert(rule)
150
+ })
151
+ ]
152
+
153
+ const serializer = middleware(
154
+ omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)
155
+ )
156
+ const stylis = styles => serialize(compile(styles), serializer)
157
+
158
+ insert = (
159
+ selector /*: string */,
160
+ serialized /*: SerializedStyles */,
161
+ sheet /*: StyleSheet */,
162
+ shouldCache /*: boolean */
163
+ ) /*: void */ => {
164
+ currentSheet = sheet
165
+ if (isDevelopment && serialized.map !== undefined) {
166
+ currentSheet = {
167
+ insert: (rule /*: string */) => {
168
+ sheet.insert(rule + serialized.map)
169
+ }
170
+ }
171
+ }
172
+
173
+ stylis(selector ? `${selector}{${serialized.styles}}` : serialized.styles)
174
+
175
+ if (shouldCache) {
176
+ cache.inserted[serialized.name] = true
177
+ }
178
+ }
179
+ } else {
180
+ const finalizingPlugins = [stringify]
181
+ const serializer = middleware(
182
+ omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)
183
+ )
184
+ const stylis = styles => serialize(compile(styles), serializer)
185
+
186
+ let serverStylisCache = getServerStylisCache(stylisPlugins)(key)
187
+ let getRules = (
188
+ selector /*: string */,
189
+ serialized /*: SerializedStyles */
190
+ ) /*: string */ => {
191
+ let name = serialized.name
192
+ if (serverStylisCache[name] === undefined) {
193
+ serverStylisCache[name] = stylis(
194
+ selector ? `${selector}{${serialized.styles}}` : serialized.styles
195
+ )
196
+ }
197
+ return serverStylisCache[name]
198
+ }
199
+ insert = (
200
+ selector /*: string */,
201
+ serialized /*: SerializedStyles */,
202
+ sheet /*: StyleSheet */,
203
+ shouldCache /*: boolean */
204
+ ) /*: string | void */ => {
205
+ let name = serialized.name
206
+ let rules = getRules(selector, serialized)
207
+ if (cache.compat === undefined) {
208
+ // in regular mode, we don't set the styles on the inserted cache
209
+ // since we don't need to and that would be wasting memory
210
+ // we return them so that they are rendered in a style tag
211
+ if (shouldCache) {
212
+ cache.inserted[name] = true
213
+ }
214
+ if (isDevelopment && serialized.map !== undefined) {
215
+ return rules + serialized.map
216
+ }
217
+ return rules
218
+ } else {
219
+ // in compat mode, we put the styles on the inserted cache so
220
+ // that emotion-server can pull out the styles
221
+ // except when we don't want to cache it which was in Global but now
222
+ // is nowhere but we don't want to do a major right now
223
+ // and just in case we're going to leave the case here
224
+ // it's also not affecting client side bundle size
225
+ // so it's really not a big deal
226
+
227
+ if (shouldCache) {
228
+ cache.inserted[name] = rules
229
+ } else {
230
+ return rules
231
+ }
232
+ }
233
+ }
234
+ }
235
+
236
+ const cache /*: EmotionCache */ = {
237
+ key,
238
+ sheet: new StyleSheet({
239
+ key,
240
+ container,
241
+ nonce: options.nonce,
242
+ speedy: options.speedy,
243
+ prepend: options.prepend,
244
+ insertionPoint: options.insertionPoint
245
+ }),
246
+ nonce: options.nonce,
247
+ inserted,
248
+ registered: {},
249
+ insert
250
+ }
251
+
252
+ cache.sheet.hydrate(nodesToHydrate)
253
+
254
+ return cache
255
+ }
256
+
257
+ export default createCache
@@ -0,0 +1,340 @@
1
+ /* eslint-disable no-fallthrough */
2
+ /* eslint-disable eqeqeq */
3
+ import {
4
+ charat,
5
+ combine,
6
+ copy,
7
+ DECLARATION,
8
+ hash,
9
+ indexof,
10
+ KEYFRAMES,
11
+ match,
12
+ MOZ,
13
+ MS,
14
+ replace,
15
+ RULESET,
16
+ serialize,
17
+ strlen,
18
+ WEBKIT
19
+ } from 'stylis'
20
+
21
+ // this is a copy of stylis@4.0.13 prefixer, the latter version introduced grid prefixing which we don't want
22
+
23
+ function prefix(value, length) {
24
+ switch (hash(value, length)) {
25
+ // color-adjust
26
+ case 5103:
27
+ return WEBKIT + 'print-' + value + value
28
+ // animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
29
+ case 5737:
30
+ case 4201:
31
+ case 3177:
32
+ case 3433:
33
+ case 1641:
34
+ case 4457:
35
+ case 2921:
36
+ // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
37
+ case 5572:
38
+ case 6356:
39
+ case 5844:
40
+ case 3191:
41
+ case 6645:
42
+ case 3005:
43
+ // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
44
+ case 6391:
45
+ case 5879:
46
+ case 5623:
47
+ case 6135:
48
+ case 4599:
49
+ case 4855:
50
+ // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
51
+ case 4215:
52
+ case 6389:
53
+ case 5109:
54
+ case 5365:
55
+ case 5621:
56
+ case 3829:
57
+ return WEBKIT + value + value
58
+ // appearance, user-select, transform, hyphens, text-size-adjust
59
+ case 5349:
60
+ case 4246:
61
+ case 4810:
62
+ case 6968:
63
+ case 2756:
64
+ return WEBKIT + value + MOZ + value + MS + value + value
65
+ // flex, flex-direction
66
+ case 6828:
67
+ case 4268:
68
+ return WEBKIT + value + MS + value + value
69
+ // order
70
+ case 6165:
71
+ return WEBKIT + value + MS + 'flex-' + value + value
72
+ // align-items
73
+ case 5187:
74
+ return (
75
+ WEBKIT +
76
+ value +
77
+ replace(
78
+ value,
79
+ /(\w+).+(:[^]+)/,
80
+ WEBKIT + 'box-$1$2' + MS + 'flex-$1$2'
81
+ ) +
82
+ value
83
+ )
84
+ // align-self
85
+ case 5443:
86
+ return (
87
+ WEBKIT +
88
+ value +
89
+ MS +
90
+ 'flex-item-' +
91
+ replace(value, /flex-|-self/, '') +
92
+ value
93
+ )
94
+ // align-content
95
+ case 4675:
96
+ return (
97
+ WEBKIT +
98
+ value +
99
+ MS +
100
+ 'flex-line-pack' +
101
+ replace(value, /align-content|flex-|-self/, '') +
102
+ value
103
+ )
104
+ // flex-shrink
105
+ case 5548:
106
+ return WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value
107
+ // flex-basis
108
+ case 5292:
109
+ return (
110
+ WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value
111
+ )
112
+ // flex-grow
113
+ case 6060:
114
+ return (
115
+ WEBKIT +
116
+ 'box-' +
117
+ replace(value, '-grow', '') +
118
+ WEBKIT +
119
+ value +
120
+ MS +
121
+ replace(value, 'grow', 'positive') +
122
+ value
123
+ )
124
+ // transition
125
+ case 4554:
126
+ return (
127
+ WEBKIT +
128
+ replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') +
129
+ value
130
+ )
131
+ // cursor
132
+ case 6187:
133
+ return (
134
+ replace(
135
+ replace(
136
+ replace(value, /(zoom-|grab)/, WEBKIT + '$1'),
137
+ /(image-set)/,
138
+ WEBKIT + '$1'
139
+ ),
140
+ value,
141
+ ''
142
+ ) + value
143
+ )
144
+ // background, background-image
145
+ case 5495:
146
+ case 3959:
147
+ return replace(value, /(image-set\([^]*)/, WEBKIT + '$1' + '$`$1')
148
+ // justify-content
149
+ case 4968:
150
+ return (
151
+ replace(
152
+ replace(
153
+ value,
154
+ /(.+:)(flex-)?(.*)/,
155
+ WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'
156
+ ),
157
+ /s.+-b[^;]+/,
158
+ 'justify'
159
+ ) +
160
+ WEBKIT +
161
+ value +
162
+ value
163
+ )
164
+ // (margin|padding)-inline-(start|end)
165
+ case 4095:
166
+ case 3583:
167
+ case 4068:
168
+ case 2532:
169
+ return replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value
170
+ // (min|max)?(width|height|inline-size|block-size)
171
+ case 8116:
172
+ case 7059:
173
+ case 5753:
174
+ case 5535:
175
+ case 5445:
176
+ case 5701:
177
+ case 4933:
178
+ case 4677:
179
+ case 5533:
180
+ case 5789:
181
+ case 5021:
182
+ case 4765:
183
+ // stretch, max-content, min-content, fill-available
184
+ if (strlen(value) - 1 - length > 6)
185
+ switch (charat(value, length + 1)) {
186
+ // (m)ax-content, (m)in-content
187
+ case 109:
188
+ // -
189
+ if (charat(value, length + 4) !== 45) break
190
+ // (f)ill-available, (f)it-content
191
+ case 102:
192
+ return (
193
+ replace(
194
+ value,
195
+ /(.+:)(.+)-([^]+)/,
196
+ '$1' +
197
+ WEBKIT +
198
+ '$2-$3' +
199
+ '$1' +
200
+ MOZ +
201
+ (charat(value, length + 3) == 108 ? '$3' : '$2-$3')
202
+ ) + value
203
+ )
204
+ // (s)tretch
205
+ case 115:
206
+ return ~indexof(value, 'stretch')
207
+ ? prefix(replace(value, 'stretch', 'fill-available'), length) +
208
+ value
209
+ : value
210
+ }
211
+ break
212
+ // position: sticky
213
+ case 4949:
214
+ // (s)ticky?
215
+ if (charat(value, length + 1) !== 115) break
216
+ // display: (flex|inline-flex)
217
+ case 6444:
218
+ switch (
219
+ charat(value, strlen(value) - 3 - (~indexof(value, '!important') && 10))
220
+ ) {
221
+ // stic(k)y
222
+ case 107:
223
+ return replace(value, ':', ':' + WEBKIT) + value
224
+ // (inline-)?fl(e)x
225
+ case 101:
226
+ return (
227
+ replace(
228
+ value,
229
+ /(.+:)([^;!]+)(;|!.+)?/,
230
+ '$1' +
231
+ WEBKIT +
232
+ (charat(value, 14) === 45 ? 'inline-' : '') +
233
+ 'box$3' +
234
+ '$1' +
235
+ WEBKIT +
236
+ '$2$3' +
237
+ '$1' +
238
+ MS +
239
+ '$2box$3'
240
+ ) + value
241
+ )
242
+ }
243
+ break
244
+ // writing-mode
245
+ case 5936:
246
+ switch (charat(value, length + 11)) {
247
+ // vertical-l(r)
248
+ case 114:
249
+ return (
250
+ WEBKIT +
251
+ value +
252
+ MS +
253
+ replace(value, /[svh]\w+-[tblr]{2}/, 'tb') +
254
+ value
255
+ )
256
+ // vertical-r(l)
257
+ case 108:
258
+ return (
259
+ WEBKIT +
260
+ value +
261
+ MS +
262
+ replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') +
263
+ value
264
+ )
265
+ // horizontal(-)tb
266
+ case 45:
267
+ return (
268
+ WEBKIT +
269
+ value +
270
+ MS +
271
+ replace(value, /[svh]\w+-[tblr]{2}/, 'lr') +
272
+ value
273
+ )
274
+ }
275
+
276
+ return WEBKIT + value + MS + value + value
277
+ }
278
+
279
+ return value
280
+ }
281
+
282
+ export let prefixer = (element, index, children, callback) => {
283
+ if (element.length > -1)
284
+ if (!element.return)
285
+ switch (element.type) {
286
+ case DECLARATION:
287
+ element.return = prefix(element.value, element.length)
288
+ break
289
+ case KEYFRAMES:
290
+ return serialize(
291
+ [
292
+ copy(element, {
293
+ value: replace(element.value, '@', '@' + WEBKIT)
294
+ })
295
+ ],
296
+ callback
297
+ )
298
+ case RULESET:
299
+ if (element.length)
300
+ return combine(element.props, function (value) {
301
+ switch (match(value, /(::plac\w+|:read-\w+)/)) {
302
+ // :read-(only|write)
303
+ case ':read-only':
304
+ case ':read-write':
305
+ return serialize(
306
+ [
307
+ copy(element, {
308
+ props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]
309
+ })
310
+ ],
311
+ callback
312
+ )
313
+ // :placeholder
314
+ case '::placeholder':
315
+ return serialize(
316
+ [
317
+ copy(element, {
318
+ props: [
319
+ replace(
320
+ value,
321
+ /:(plac\w+)/,
322
+ ':' + WEBKIT + 'input-$1'
323
+ )
324
+ ]
325
+ }),
326
+ copy(element, {
327
+ props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]
328
+ }),
329
+ copy(element, {
330
+ props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]
331
+ })
332
+ ],
333
+ callback
334
+ )
335
+ }
336
+
337
+ return ''
338
+ })
339
+ }
340
+ }