ycpp 0.1.0__cp314-cp314-win_amd64.whl

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 (142) hide show
  1. ycpp/__init__.py +110 -0
  2. ycpp/_array.py +318 -0
  3. ycpp/_awareness.py +268 -0
  4. ycpp/_doc.py +718 -0
  5. ycpp/_event.py +188 -0
  6. ycpp/_id_map.py +620 -0
  7. ycpp/_map.py +267 -0
  8. ycpp/_provider.py +180 -0
  9. ycpp/_snapshot.py +28 -0
  10. ycpp/_sticky_index.py +59 -0
  11. ycpp/_stream.py +91 -0
  12. ycpp/_sync.py +192 -0
  13. ycpp/_text.py +239 -0
  14. ycpp/_transaction.py +287 -0
  15. ycpp/_typed.py +122 -0
  16. ycpp/_undo.py +201 -0
  17. ycpp/_update.py +18 -0
  18. ycpp/_xml.py +452 -0
  19. ycpp/_ycpp.cp314-win_amd64.lib +0 -0
  20. ycpp/_ycpp.cp314-win_amd64.pyd +0 -0
  21. ycpp-0.1.0.data/headers/fast_float/ascii_number.h +766 -0
  22. ycpp-0.1.0.data/headers/fast_float/bigint.h +638 -0
  23. ycpp-0.1.0.data/headers/fast_float/constexpr_feature_detect.h +53 -0
  24. ycpp-0.1.0.data/headers/fast_float/decimal_to_binary.h +212 -0
  25. ycpp-0.1.0.data/headers/fast_float/digit_comparison.h +455 -0
  26. ycpp-0.1.0.data/headers/fast_float/fast_float.h +91 -0
  27. ycpp-0.1.0.data/headers/fast_float/fast_table.h +708 -0
  28. ycpp-0.1.0.data/headers/fast_float/float_common.h +1432 -0
  29. ycpp-0.1.0.data/headers/fast_float/parse_number.h +488 -0
  30. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
  31. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_bit.hpp +230 -0
  32. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
  33. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
  34. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_details.hpp +386 -0
  35. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
  36. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
  37. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
  38. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
  39. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
  40. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
  41. ycpp-0.1.0.data/headers/xsimd/arch/utils/shifts.hpp +82 -0
  42. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx.hpp +2111 -0
  43. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx2.hpp +1591 -0
  44. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512bw.hpp +724 -0
  45. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512cd.hpp +28 -0
  46. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512dq.hpp +270 -0
  47. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512er.hpp +17 -0
  48. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512f.hpp +2919 -0
  49. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
  50. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512pf.hpp +17 -0
  51. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
  52. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
  53. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
  54. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
  55. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avxvnni.hpp +17 -0
  56. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common.hpp +26 -0
  57. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common_fwd.hpp +127 -0
  58. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_constants.hpp +393 -0
  59. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_emulated.hpp +787 -0
  60. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
  61. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
  62. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
  63. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma4.hpp +92 -0
  64. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
  65. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_isa.hpp +146 -0
  66. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon.hpp +3580 -0
  67. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon64.hpp +1614 -0
  68. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_rvv.hpp +1515 -0
  69. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_scalar.hpp +1210 -0
  70. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse2.hpp +2333 -0
  71. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse3.hpp +66 -0
  72. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_1.hpp +510 -0
  73. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_2.hpp +44 -0
  74. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_ssse3.hpp +186 -0
  75. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sve.hpp +1186 -0
  76. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vsx.hpp +916 -0
  77. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vxe.hpp +787 -0
  78. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_wasm.hpp +1819 -0
  79. ycpp-0.1.0.data/headers/xsimd/config/xsimd_arch.hpp +242 -0
  80. ycpp-0.1.0.data/headers/xsimd/config/xsimd_config.hpp +620 -0
  81. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features.hpp +50 -0
  82. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
  83. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
  84. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
  85. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
  86. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_x86.hpp +1044 -0
  87. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpuid.hpp +144 -0
  88. ycpp-0.1.0.data/headers/xsimd/config/xsimd_getauxval.hpp +159 -0
  89. ycpp-0.1.0.data/headers/xsimd/config/xsimd_macros.hpp +76 -0
  90. ycpp-0.1.0.data/headers/xsimd/math/xsimd_rem_pio2.hpp +707 -0
  91. ycpp-0.1.0.data/headers/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
  92. ycpp-0.1.0.data/headers/xsimd/memory/xsimd_alignment.hpp +102 -0
  93. ycpp-0.1.0.data/headers/xsimd/types/xsimd_all_registers.hpp +57 -0
  94. ycpp-0.1.0.data/headers/xsimd/types/xsimd_api.hpp +3106 -0
  95. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx2_register.hpp +44 -0
  96. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
  97. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
  98. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
  99. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512er_register.hpp +51 -0
  100. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512f_register.hpp +77 -0
  101. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
  102. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
  103. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
  104. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
  105. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
  106. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
  107. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx_register.hpp +64 -0
  108. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
  109. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch.hpp +1665 -0
  110. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_constant.hpp +571 -0
  111. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_fwd.hpp +41 -0
  112. ycpp-0.1.0.data/headers/xsimd/types/xsimd_common_arch.hpp +49 -0
  113. ycpp-0.1.0.data/headers/xsimd/types/xsimd_emulated_register.hpp +80 -0
  114. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
  115. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
  116. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
  117. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma4_register.hpp +50 -0
  118. ycpp-0.1.0.data/headers/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
  119. ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon64_register.hpp +55 -0
  120. ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon_register.hpp +130 -0
  121. ycpp-0.1.0.data/headers/xsimd/types/xsimd_register.hpp +96 -0
  122. ycpp-0.1.0.data/headers/xsimd/types/xsimd_rvv_register.hpp +491 -0
  123. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse2_register.hpp +59 -0
  124. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse3_register.hpp +49 -0
  125. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
  126. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
  127. ycpp-0.1.0.data/headers/xsimd/types/xsimd_ssse3_register.hpp +48 -0
  128. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sve_register.hpp +216 -0
  129. ycpp-0.1.0.data/headers/xsimd/types/xsimd_traits.hpp +408 -0
  130. ycpp-0.1.0.data/headers/xsimd/types/xsimd_utils.hpp +462 -0
  131. ycpp-0.1.0.data/headers/xsimd/types/xsimd_vsx_register.hpp +77 -0
  132. ycpp-0.1.0.data/headers/xsimd/types/xsimd_vxe_register.hpp +86 -0
  133. ycpp-0.1.0.data/headers/xsimd/types/xsimd_wasm_register.hpp +59 -0
  134. ycpp-0.1.0.data/headers/xsimd/utils/bits.hpp +122 -0
  135. ycpp-0.1.0.data/headers/xsimd/utils/xsimd_type_traits.hpp +145 -0
  136. ycpp-0.1.0.data/headers/xsimd/xsimd.hpp +43 -0
  137. ycpp-0.1.0.dist-info/DELVEWHEEL +2 -0
  138. ycpp-0.1.0.dist-info/METADATA +15 -0
  139. ycpp-0.1.0.dist-info/RECORD +142 -0
  140. ycpp-0.1.0.dist-info/WHEEL +4 -0
  141. ycpp.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
  142. ycpp.libs/msvcp140_1-226498d4bfcb4f07974757b596ebec45.dll +0 -0
ycpp/_event.py ADDED
@@ -0,0 +1,188 @@
1
+ from __future__ import annotations
2
+
3
+ from inspect import iscoroutinefunction, signature
4
+
5
+
6
+ class _AsyncCallbackInSyncTransaction(RuntimeError):
7
+ """Collected like an observer error, but the transaction exit raises it on the caller's side as
8
+ pycrdt's async wrapper does: a sync transaction cannot have async observers at all."""
9
+
10
+
11
+ class Subscription:
12
+ def __init__(self, doc, observer: int) -> None:
13
+ self._doc = doc
14
+ self._observer = observer
15
+ self._active = observer != 0
16
+
17
+ def drop(self) -> None:
18
+ if self._active:
19
+ self._active = False
20
+ self._doc._unobserve(self._observer)
21
+
22
+ def __repr__(self) -> str:
23
+ state = "active" if self._active else "dropped"
24
+ return f"Subscription({state})"
25
+
26
+
27
+ class _Event:
28
+ """What the four event kinds share: a transaction built on first access.
29
+
30
+ A one-argument callback, the common case, never asks for it, so the event costs no Transaction.
31
+ """
32
+
33
+ __slots__ = ()
34
+
35
+ @property
36
+ def transaction(self):
37
+ transaction = self._transaction
38
+ if transaction is None:
39
+ transaction = self._transaction = self._doc._event_transaction()
40
+ return transaction
41
+
42
+
43
+ class MapEvent(_Event):
44
+ """A map change, shaped like pycrdt's: ``keys`` maps a key to its action and values."""
45
+
46
+ __slots__ = ("target", "keys", "path", "_doc", "_transaction")
47
+
48
+ def __init__(self, target, keys, doc, path=None) -> None:
49
+ self.target = target
50
+ self.keys = keys
51
+ self.path = [] if path is None else path
52
+ self._doc = doc
53
+ self._transaction = None
54
+
55
+ def __str__(self) -> str:
56
+ return (
57
+ f"{{target: {self.target}, keys: {self.keys}, path: {self.path}, "
58
+ f"transaction: {self.transaction}}}"
59
+ )
60
+
61
+
62
+ class TextEvent(_Event):
63
+ """A text change: ``delta`` is Yjs's delta list (insert/retain/delete operations)."""
64
+
65
+ __slots__ = ("target", "delta", "path", "_doc", "_transaction")
66
+
67
+ def __init__(self, target, delta, doc, path=None) -> None:
68
+ self.target = target
69
+ self.delta = delta
70
+ self.path = [] if path is None else path
71
+ self._doc = doc
72
+ self._transaction = None
73
+
74
+ def __str__(self) -> str:
75
+ return (
76
+ f"{{target: {self.target}, delta: {self.delta}, path: {self.path}, "
77
+ f"transaction: {self.transaction}}}"
78
+ )
79
+
80
+
81
+ class ArrayEvent(_Event):
82
+ """An array change: ``delta`` is Yjs's YArrayEvent delta (retain/insert/delete operations)."""
83
+
84
+ __slots__ = ("target", "delta", "path", "_doc", "_transaction")
85
+
86
+ def __init__(self, target, delta, doc, path=None) -> None:
87
+ self.target = target
88
+ self.delta = delta
89
+ self.path = [] if path is None else path
90
+ self._doc = doc
91
+ self._transaction = None
92
+
93
+ def __str__(self) -> str:
94
+ return (
95
+ f"{{target: {self.target}, delta: {self.delta}, path: {self.path}, "
96
+ f"transaction: {self.transaction}}}"
97
+ )
98
+
99
+
100
+ class SubdocsEvent(_Event):
101
+ """The subdocuments a transaction added, removed or loaded.
102
+
103
+ ``added``, ``removed`` and ``loaded`` are lists of guids, as pycrdt's SubdocsEvent.
104
+ """
105
+
106
+ __slots__ = ("added", "removed", "loaded", "_doc", "_transaction")
107
+
108
+ def __init__(self, added, removed, loaded, doc) -> None:
109
+ self.added = added
110
+ self.removed = removed
111
+ self.loaded = loaded
112
+ self._doc = doc
113
+ self._transaction = None
114
+
115
+ def __str__(self) -> str:
116
+ return (
117
+ f"{{added: {self.added}, removed: {self.removed}, loaded: {self.loaded}, "
118
+ f"transaction: {self.transaction}}}"
119
+ )
120
+
121
+
122
+ class TransactionEvent(_Event):
123
+ """A document update.
124
+
125
+ ``before_state`` and ``after_state`` are state vectors encoded like pycrdt's, captured around
126
+ the operation that produced the update.
127
+ """
128
+
129
+ __slots__ = ("update", "before_state", "after_state", "_doc", "_transaction")
130
+
131
+ def __init__(self, update, before_state, after_state, doc) -> None:
132
+ self.update = update
133
+ self.before_state = before_state
134
+ self.after_state = after_state
135
+ self._doc = doc
136
+ self._transaction = None
137
+
138
+ def __str__(self) -> str:
139
+ return f"{{update: {self.update.hex()}}}"
140
+
141
+
142
+ def arg_count(callback) -> int:
143
+ try:
144
+ return len(signature(callback).parameters)
145
+ except (TypeError, ValueError):
146
+ return 1
147
+
148
+
149
+ def _call(doc, callback, *args) -> None:
150
+ """Run one observer callback: a coroutine function joins the async transaction's task group.
151
+
152
+ anyio rather than asyncio, so the same code runs under trio as pycrdt's does.
153
+ """
154
+ if iscoroutinefunction(callback):
155
+ task_group = doc._task_group
156
+ if task_group is None:
157
+ raise _AsyncCallbackInSyncTransaction(
158
+ "Async callback in non-async transaction"
159
+ )
160
+ task_group.start_soon(callback, *args)
161
+ return
162
+ callback(*args)
163
+
164
+
165
+ def invoke(doc, callback, argc: int, event) -> None:
166
+ try:
167
+ if argc >= 2:
168
+ _call(doc, callback, event, event.transaction)
169
+ elif argc == 1:
170
+ _call(doc, callback, event)
171
+ else:
172
+ _call(doc, callback)
173
+ except Exception as exc:
174
+ # pycrdt collects observer errors on the doc and raises them when the transaction exits.
175
+ doc._add_exception(exc)
176
+
177
+
178
+ def invoke_deep(doc, callback, argc: int, events) -> None:
179
+ """observeDeep: the callback receives the list of events, then the transaction."""
180
+ try:
181
+ if argc >= 2:
182
+ _call(doc, callback, events, doc._event_transaction())
183
+ elif argc == 1:
184
+ _call(doc, callback, events)
185
+ else:
186
+ _call(doc, callback)
187
+ except Exception as exc:
188
+ doc._add_exception(exc)