dynamic-mui 4.0.0 → 4.0.2

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.
@@ -0,0 +1,165 @@
1
+ import { t as z, s as k } from "./index-Nx4sGg5x.mjs";
2
+ class M {
3
+ marshaller;
4
+ serializer;
5
+ deserializer;
6
+ serdeContext;
7
+ defaultContentType;
8
+ constructor({ marshaller: i, serializer: n, deserializer: l, serdeContext: c, defaultContentType: y }) {
9
+ this.marshaller = i, this.serializer = n, this.deserializer = l, this.serdeContext = c, this.defaultContentType = y;
10
+ }
11
+ async serializeEventStream({ eventStream: i, requestSchema: n, initialRequest: l }) {
12
+ const c = this.marshaller, y = n.getEventStreamMember(), p = n.getMemberSchema(y), d = this.serializer, h = this.defaultContentType, u = /* @__PURE__ */ Symbol("initialRequestMarker"), S = {
13
+ async *[Symbol.asyncIterator]() {
14
+ if (l) {
15
+ const r = {
16
+ ":event-type": { type: "string", value: "initial-request" },
17
+ ":message-type": { type: "string", value: "event" },
18
+ ":content-type": { type: "string", value: h }
19
+ };
20
+ d.write(n, l);
21
+ const e = d.flush();
22
+ yield {
23
+ [u]: !0,
24
+ headers: r,
25
+ body: e
26
+ };
27
+ }
28
+ for await (const r of i)
29
+ yield r;
30
+ }
31
+ };
32
+ return c.serialize(S, (r) => {
33
+ if (r[u])
34
+ return {
35
+ headers: r.headers,
36
+ body: r.body
37
+ };
38
+ let e = "";
39
+ for (const s in r)
40
+ if (s !== "__type") {
41
+ e = s;
42
+ break;
43
+ }
44
+ const { additionalHeaders: t, body: a, eventType: o, explicitPayloadContentType: m } = this.writeEventBody(e, p, r);
45
+ return {
46
+ headers: {
47
+ ":event-type": { type: "string", value: o },
48
+ ":message-type": { type: "string", value: "event" },
49
+ ":content-type": { type: "string", value: m ?? h },
50
+ ...t
51
+ },
52
+ body: a
53
+ };
54
+ });
55
+ }
56
+ async deserializeEventStream({ response: i, responseSchema: n, initialResponseContainer: l }) {
57
+ const c = this.marshaller, y = n.getEventStreamMember(), d = n.getMemberSchema(y).getMemberSchemas(), h = /* @__PURE__ */ Symbol("initialResponseMarker"), u = c.deserialize(i.body, async (e) => {
58
+ let t = "";
59
+ for (const o in e)
60
+ if (o !== "__type") {
61
+ t = o;
62
+ break;
63
+ }
64
+ const a = e[t].body;
65
+ if (t === "initial-response") {
66
+ const o = await this.deserializer.read(n, a);
67
+ return delete o[y], {
68
+ [h]: !0,
69
+ ...o
70
+ };
71
+ } else if (t in d) {
72
+ const o = d[t];
73
+ if (o.isStructSchema()) {
74
+ const m = {};
75
+ let f = !1;
76
+ for (const [s, g] of o.structIterator()) {
77
+ const { eventHeader: v, eventPayload: w } = g.getMergedTraits();
78
+ if (f = f || !!(v || w), w)
79
+ g.isBlobSchema() ? m[s] = a : g.isStringSchema() ? m[s] = (this.serdeContext?.utf8Encoder ?? z)(a) : g.isStructSchema() && (m[s] = await this.deserializer.read(g, a));
80
+ else if (v) {
81
+ const b = e[t].headers[s]?.value;
82
+ b != null && (g.isNumericSchema() ? b && typeof b == "object" && "bytes" in b ? m[s] = BigInt(b.toString()) : m[s] = Number(b) : m[s] = b);
83
+ }
84
+ }
85
+ if (f)
86
+ return {
87
+ [t]: m
88
+ };
89
+ if (a.byteLength === 0)
90
+ return {
91
+ [t]: {}
92
+ };
93
+ }
94
+ return {
95
+ [t]: await this.deserializer.read(o, a)
96
+ };
97
+ } else
98
+ return {
99
+ $unknown: e
100
+ };
101
+ }), S = u[Symbol.asyncIterator](), r = await S.next();
102
+ if (r.done)
103
+ return u;
104
+ if (r.value?.[h]) {
105
+ if (!n)
106
+ throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
107
+ for (const e in r.value)
108
+ l[e] = r.value[e];
109
+ }
110
+ return {
111
+ async *[Symbol.asyncIterator]() {
112
+ for (r?.value?.[h] || (yield r.value); ; ) {
113
+ const { done: e, value: t } = await S.next();
114
+ if (e)
115
+ break;
116
+ yield t;
117
+ }
118
+ }
119
+ };
120
+ }
121
+ writeEventBody(i, n, l) {
122
+ const c = this.serializer;
123
+ let y = i, p = null, d;
124
+ const h = n.getSchema()[4].includes(i), u = {};
125
+ if (h) {
126
+ const e = n.getMemberSchema(i);
127
+ if (e.isStructSchema()) {
128
+ for (const [t, a] of e.structIterator()) {
129
+ const { eventHeader: o, eventPayload: m } = a.getMergedTraits();
130
+ if (m)
131
+ p = t;
132
+ else if (o) {
133
+ const f = l[i][t];
134
+ let s = "binary";
135
+ a.isNumericSchema() ? (-2) ** 31 <= f && f <= 2 ** 31 - 1 ? s = "integer" : s = "long" : a.isTimestampSchema() ? s = "timestamp" : a.isStringSchema() ? s = "string" : a.isBooleanSchema() && (s = "boolean"), f != null && (u[t] = {
136
+ type: s,
137
+ value: f
138
+ }, delete l[i][t]);
139
+ }
140
+ }
141
+ if (p !== null) {
142
+ const t = e.getMemberSchema(p);
143
+ t.isBlobSchema() ? d = "application/octet-stream" : t.isStringSchema() && (d = "text/plain"), c.write(t, l[i][p]);
144
+ } else
145
+ c.write(e, l[i]);
146
+ } else if (e.isUnitSchema())
147
+ c.write(e, {});
148
+ else
149
+ throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
150
+ } else {
151
+ const [e, t] = l[i];
152
+ y = e, c.write(15, t);
153
+ }
154
+ const S = c.flush() ?? new Uint8Array();
155
+ return {
156
+ body: typeof S == "string" ? (this.serdeContext?.utf8Decoder ?? k)(S) : S,
157
+ eventType: y,
158
+ explicitPayloadContentType: d,
159
+ additionalHeaders: u
160
+ };
161
+ }
162
+ }
163
+ export {
164
+ M as EventStreamSerde
165
+ };