turbo-stream 2.1.0 → 2.2.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.
- package/dist/flatten.js +24 -2
- package/dist/turbo-stream.mjs +22 -2
- package/package.json +1 -1
package/dist/flatten.js
CHANGED
|
@@ -135,8 +135,30 @@ function stringify(input, index) {
|
|
|
135
135
|
}
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
|
-
default:
|
|
139
|
-
|
|
138
|
+
default: {
|
|
139
|
+
const isArray = Array.isArray(input);
|
|
140
|
+
let pluginHandled = false;
|
|
141
|
+
if (!isArray && plugins) {
|
|
142
|
+
for (const plugin of plugins) {
|
|
143
|
+
const pluginResult = plugin(input);
|
|
144
|
+
if (Array.isArray(pluginResult)) {
|
|
145
|
+
pluginHandled = true;
|
|
146
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
147
|
+
str[index] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
148
|
+
if (rest.length > 0) {
|
|
149
|
+
str[index] += `,${rest
|
|
150
|
+
.map((v) => flatten.call(this, v))
|
|
151
|
+
.join(",")}`;
|
|
152
|
+
}
|
|
153
|
+
str[index] += "]";
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (!pluginHandled) {
|
|
159
|
+
throw new Error("Cannot encode function or unexpected type");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
140
162
|
}
|
|
141
163
|
}
|
|
142
164
|
const objectProtoNames = Object.getOwnPropertyNames(Object.prototype)
|
package/dist/turbo-stream.mjs
CHANGED
|
@@ -163,8 +163,28 @@ function stringify(input, index) {
|
|
|
163
163
|
}
|
|
164
164
|
break;
|
|
165
165
|
}
|
|
166
|
-
default:
|
|
167
|
-
|
|
166
|
+
default: {
|
|
167
|
+
const isArray = Array.isArray(input);
|
|
168
|
+
let pluginHandled = false;
|
|
169
|
+
if (!isArray && plugins) {
|
|
170
|
+
for (const plugin of plugins) {
|
|
171
|
+
const pluginResult = plugin(input);
|
|
172
|
+
if (Array.isArray(pluginResult)) {
|
|
173
|
+
pluginHandled = true;
|
|
174
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
175
|
+
str[index] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
176
|
+
if (rest.length > 0) {
|
|
177
|
+
str[index] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
|
|
178
|
+
}
|
|
179
|
+
str[index] += "]";
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!pluginHandled) {
|
|
185
|
+
throw new Error("Cannot encode function or unexpected type");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
168
188
|
}
|
|
169
189
|
}
|
|
170
190
|
var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
package/package.json
CHANGED