solid-js 1.1.7 → 1.2.0-beta.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/dev.cjs +11 -3
- package/dist/dev.js +11 -3
- package/dist/solid.cjs +11 -3
- package/dist/solid.js +11 -3
- package/html/dist/html.cjs +24 -6
- package/html/dist/html.js +25 -7
- package/package.json +14 -2
- package/types/jsx.d.ts +1 -0
- package/types/render/component.d.ts +1 -1
- package/universal/dist/dev.cjs +258 -0
- package/universal/dist/dev.js +254 -0
- package/universal/dist/universal.cjs +258 -0
- package/universal/dist/universal.js +254 -0
- package/universal/package.json +8 -0
- package/universal/types/index.d.ts +2 -0
- package/universal/types/universal.d.ts +29 -0
- package/web/types/client.d.ts +1 -1
package/dist/dev.cjs
CHANGED
|
@@ -455,6 +455,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
455
455
|
Scheduler = scheduler;
|
|
456
456
|
}
|
|
457
457
|
function startTransition(fn, cb) {
|
|
458
|
+
if (Transition && Transition.running) {
|
|
459
|
+
fn();
|
|
460
|
+
cb && Transition.cb.push(cb);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
458
463
|
queueMicrotask(() => {
|
|
459
464
|
if (Scheduler || SuspenseContext) {
|
|
460
465
|
Transition || (Transition = {
|
|
@@ -1166,23 +1171,26 @@ const propTraps = {
|
|
|
1166
1171
|
return _.keys();
|
|
1167
1172
|
}
|
|
1168
1173
|
};
|
|
1174
|
+
function resolveSource(s) {
|
|
1175
|
+
return typeof s === "function" ? s() : s;
|
|
1176
|
+
}
|
|
1169
1177
|
function mergeProps(...sources) {
|
|
1170
1178
|
return new Proxy({
|
|
1171
1179
|
get(property) {
|
|
1172
1180
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1173
|
-
const v = sources[i][property];
|
|
1181
|
+
const v = resolveSource(sources[i])[property];
|
|
1174
1182
|
if (v !== undefined) return v;
|
|
1175
1183
|
}
|
|
1176
1184
|
},
|
|
1177
1185
|
has(property) {
|
|
1178
1186
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1179
|
-
if (property in sources[i]) return true;
|
|
1187
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1180
1188
|
}
|
|
1181
1189
|
return false;
|
|
1182
1190
|
},
|
|
1183
1191
|
keys() {
|
|
1184
1192
|
const keys = [];
|
|
1185
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1193
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1186
1194
|
return [...new Set(keys)];
|
|
1187
1195
|
}
|
|
1188
1196
|
}, propTraps);
|
package/dist/dev.js
CHANGED
|
@@ -451,6 +451,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
451
451
|
Scheduler = scheduler;
|
|
452
452
|
}
|
|
453
453
|
function startTransition(fn, cb) {
|
|
454
|
+
if (Transition && Transition.running) {
|
|
455
|
+
fn();
|
|
456
|
+
cb && Transition.cb.push(cb);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
454
459
|
queueMicrotask(() => {
|
|
455
460
|
if (Scheduler || SuspenseContext) {
|
|
456
461
|
Transition || (Transition = {
|
|
@@ -1162,23 +1167,26 @@ const propTraps = {
|
|
|
1162
1167
|
return _.keys();
|
|
1163
1168
|
}
|
|
1164
1169
|
};
|
|
1170
|
+
function resolveSource(s) {
|
|
1171
|
+
return typeof s === "function" ? s() : s;
|
|
1172
|
+
}
|
|
1165
1173
|
function mergeProps(...sources) {
|
|
1166
1174
|
return new Proxy({
|
|
1167
1175
|
get(property) {
|
|
1168
1176
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1169
|
-
const v = sources[i][property];
|
|
1177
|
+
const v = resolveSource(sources[i])[property];
|
|
1170
1178
|
if (v !== undefined) return v;
|
|
1171
1179
|
}
|
|
1172
1180
|
},
|
|
1173
1181
|
has(property) {
|
|
1174
1182
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1175
|
-
if (property in sources[i]) return true;
|
|
1183
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1176
1184
|
}
|
|
1177
1185
|
return false;
|
|
1178
1186
|
},
|
|
1179
1187
|
keys() {
|
|
1180
1188
|
const keys = [];
|
|
1181
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1189
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1182
1190
|
return [...new Set(keys)];
|
|
1183
1191
|
}
|
|
1184
1192
|
}, propTraps);
|
package/dist/solid.cjs
CHANGED
|
@@ -452,6 +452,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
452
452
|
Scheduler = scheduler;
|
|
453
453
|
}
|
|
454
454
|
function startTransition(fn, cb) {
|
|
455
|
+
if (Transition && Transition.running) {
|
|
456
|
+
fn();
|
|
457
|
+
cb && Transition.cb.push(cb);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
455
460
|
queueMicrotask(() => {
|
|
456
461
|
if (Scheduler || SuspenseContext) {
|
|
457
462
|
Transition || (Transition = {
|
|
@@ -1090,23 +1095,26 @@ const propTraps = {
|
|
|
1090
1095
|
return _.keys();
|
|
1091
1096
|
}
|
|
1092
1097
|
};
|
|
1098
|
+
function resolveSource(s) {
|
|
1099
|
+
return typeof s === "function" ? s() : s;
|
|
1100
|
+
}
|
|
1093
1101
|
function mergeProps(...sources) {
|
|
1094
1102
|
return new Proxy({
|
|
1095
1103
|
get(property) {
|
|
1096
1104
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1097
|
-
const v = sources[i][property];
|
|
1105
|
+
const v = resolveSource(sources[i])[property];
|
|
1098
1106
|
if (v !== undefined) return v;
|
|
1099
1107
|
}
|
|
1100
1108
|
},
|
|
1101
1109
|
has(property) {
|
|
1102
1110
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1103
|
-
if (property in sources[i]) return true;
|
|
1111
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1104
1112
|
}
|
|
1105
1113
|
return false;
|
|
1106
1114
|
},
|
|
1107
1115
|
keys() {
|
|
1108
1116
|
const keys = [];
|
|
1109
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1117
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1110
1118
|
return [...new Set(keys)];
|
|
1111
1119
|
}
|
|
1112
1120
|
}, propTraps);
|
package/dist/solid.js
CHANGED
|
@@ -448,6 +448,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
448
448
|
Scheduler = scheduler;
|
|
449
449
|
}
|
|
450
450
|
function startTransition(fn, cb) {
|
|
451
|
+
if (Transition && Transition.running) {
|
|
452
|
+
fn();
|
|
453
|
+
cb && Transition.cb.push(cb);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
451
456
|
queueMicrotask(() => {
|
|
452
457
|
if (Scheduler || SuspenseContext) {
|
|
453
458
|
Transition || (Transition = {
|
|
@@ -1086,23 +1091,26 @@ const propTraps = {
|
|
|
1086
1091
|
return _.keys();
|
|
1087
1092
|
}
|
|
1088
1093
|
};
|
|
1094
|
+
function resolveSource(s) {
|
|
1095
|
+
return typeof s === "function" ? s() : s;
|
|
1096
|
+
}
|
|
1089
1097
|
function mergeProps(...sources) {
|
|
1090
1098
|
return new Proxy({
|
|
1091
1099
|
get(property) {
|
|
1092
1100
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1093
|
-
const v = sources[i][property];
|
|
1101
|
+
const v = resolveSource(sources[i])[property];
|
|
1094
1102
|
if (v !== undefined) return v;
|
|
1095
1103
|
}
|
|
1096
1104
|
},
|
|
1097
1105
|
has(property) {
|
|
1098
1106
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1099
|
-
if (property in sources[i]) return true;
|
|
1107
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1100
1108
|
}
|
|
1101
1109
|
return false;
|
|
1102
1110
|
},
|
|
1103
1111
|
keys() {
|
|
1104
1112
|
const keys = [];
|
|
1105
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1113
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1106
1114
|
return [...new Set(keys)];
|
|
1107
1115
|
}
|
|
1108
1116
|
}, propTraps);
|
package/html/dist/html.cjs
CHANGED
|
@@ -213,7 +213,7 @@ function createHTML(r, {
|
|
|
213
213
|
markup = markup + statics[i] + "<!--#-->";
|
|
214
214
|
}
|
|
215
215
|
markup = markup + statics[i];
|
|
216
|
-
markup = markup.replace(selfClosing, fullClosing).replace(/<(<!--#-->)/g, "<###").replace(attrSeeker, attrReplacer).replace(/>\n+\s*/g, ">").replace(/\n+\s*</g, "<").replace(/\s+</g, " <").replace(/>\s+/g, "> ");
|
|
216
|
+
markup = markup.replace(selfClosing, fullClosing).replace(/<(<!--#-->)/g, "<###").replace(/\.\.\.(<!--#-->)/g, "###").replace(attrSeeker, attrReplacer).replace(/>\n+\s*/g, ">").replace(/\n+\s*</g, "<").replace(/\s+</g, " <").replace(/>\s+/g, "> ");
|
|
217
217
|
const [html, code] = parseTemplate(parse(markup)),
|
|
218
218
|
templates = [];
|
|
219
219
|
for (let i = 0; i < html.length; i++) {
|
|
@@ -323,16 +323,29 @@ function createHTML(r, {
|
|
|
323
323
|
options.counter = childOptions.counter;
|
|
324
324
|
options.templateId = childOptions.templateId;
|
|
325
325
|
}
|
|
326
|
+
function processComponentProps(propGroups) {
|
|
327
|
+
let result = [];
|
|
328
|
+
for (const props of propGroups) {
|
|
329
|
+
if (Array.isArray(props)) {
|
|
330
|
+
if (!props.length) continue;
|
|
331
|
+
result.push(`r.wrapProps({${props.join(",") || ""}})`);
|
|
332
|
+
} else result.push(props);
|
|
333
|
+
}
|
|
334
|
+
return result.length > 1 ? `r.mergeProps(${result.join(",")})` : result[0];
|
|
335
|
+
}
|
|
326
336
|
function processComponent(node, options) {
|
|
337
|
+
let props = [];
|
|
327
338
|
const keys = Object.keys(node.attrs),
|
|
328
|
-
|
|
339
|
+
propGroups = [props],
|
|
329
340
|
componentIdentifier = options.counter++;
|
|
330
341
|
for (let i = 0; i < keys.length; i++) {
|
|
331
342
|
const name = keys[i],
|
|
332
343
|
value = node.attrs[name];
|
|
333
|
-
if (
|
|
334
|
-
|
|
335
|
-
|
|
344
|
+
if (name === "###") {
|
|
345
|
+
propGroups.push(`exprs[${options.counter++}]`);
|
|
346
|
+
propGroups.push(props = []);
|
|
347
|
+
} else if (value === "###") {
|
|
348
|
+
props.push(`${name}: exprs[${options.counter++}]`);
|
|
336
349
|
} else props.push(`${name}: "${value}"`);
|
|
337
350
|
}
|
|
338
351
|
if (node.children.length === 1 && node.children[0].type === "comment" && node.children[0].content === "#") {
|
|
@@ -357,7 +370,7 @@ function createHTML(r, {
|
|
|
357
370
|
tag = `_$el${uuid++}`;
|
|
358
371
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
359
372
|
}
|
|
360
|
-
if (options.parent) options.exprs.push(`r.insert(${options.parent}, r.createComponent(exprs[${componentIdentifier}]
|
|
373
|
+
if (options.parent) options.exprs.push(`r.insert(${options.parent}, r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})${tag ? `, ${tag}` : ""})`);else options.exprs.push(`${options.fragment ? "" : "return "}r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})`);
|
|
361
374
|
options.path = tag;
|
|
362
375
|
options.first = false;
|
|
363
376
|
}
|
|
@@ -410,6 +423,9 @@ function createHTML(r, {
|
|
|
410
423
|
if (value === "###") {
|
|
411
424
|
delete node.attrs[name];
|
|
412
425
|
parseAttribute(tag, name, isSVG, isCE, options);
|
|
426
|
+
} else if (name === "###") {
|
|
427
|
+
delete node.attrs[name];
|
|
428
|
+
options.exprs.push(`r.spread(${tag},exprs[${options.counter++}],${isSVG},${!!node.children.length})`);
|
|
413
429
|
}
|
|
414
430
|
}
|
|
415
431
|
options.path = tag;
|
|
@@ -470,9 +486,11 @@ var index = createHTML({
|
|
|
470
486
|
effect: web.effect,
|
|
471
487
|
style: web.style,
|
|
472
488
|
insert: web.insert,
|
|
489
|
+
spread: web.spread,
|
|
473
490
|
createComponent: web.createComponent,
|
|
474
491
|
delegateEvents: web.delegateEvents,
|
|
475
492
|
classList: web.classList,
|
|
493
|
+
mergeProps: web.mergeProps,
|
|
476
494
|
dynamicProperty: web.dynamicProperty,
|
|
477
495
|
setAttribute: web.setAttribute,
|
|
478
496
|
setAttributeNS: web.setAttributeNS,
|
package/html/dist/html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { effect, style, insert, createComponent, delegateEvents, classList, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, PropAliases, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web';
|
|
1
|
+
import { effect, style, insert, spread, createComponent, delegateEvents, classList, mergeProps, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, PropAliases, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web';
|
|
2
2
|
|
|
3
3
|
var attrRE, lookup, parseTag, pushCommentNode, pushTextNode, tagRE;
|
|
4
4
|
tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
|
|
@@ -211,7 +211,7 @@ function createHTML(r, {
|
|
|
211
211
|
markup = markup + statics[i] + "<!--#-->";
|
|
212
212
|
}
|
|
213
213
|
markup = markup + statics[i];
|
|
214
|
-
markup = markup.replace(selfClosing, fullClosing).replace(/<(<!--#-->)/g, "<###").replace(attrSeeker, attrReplacer).replace(/>\n+\s*/g, ">").replace(/\n+\s*</g, "<").replace(/\s+</g, " <").replace(/>\s+/g, "> ");
|
|
214
|
+
markup = markup.replace(selfClosing, fullClosing).replace(/<(<!--#-->)/g, "<###").replace(/\.\.\.(<!--#-->)/g, "###").replace(attrSeeker, attrReplacer).replace(/>\n+\s*/g, ">").replace(/\n+\s*</g, "<").replace(/\s+</g, " <").replace(/>\s+/g, "> ");
|
|
215
215
|
const [html, code] = parseTemplate(parse(markup)),
|
|
216
216
|
templates = [];
|
|
217
217
|
for (let i = 0; i < html.length; i++) {
|
|
@@ -321,16 +321,29 @@ function createHTML(r, {
|
|
|
321
321
|
options.counter = childOptions.counter;
|
|
322
322
|
options.templateId = childOptions.templateId;
|
|
323
323
|
}
|
|
324
|
+
function processComponentProps(propGroups) {
|
|
325
|
+
let result = [];
|
|
326
|
+
for (const props of propGroups) {
|
|
327
|
+
if (Array.isArray(props)) {
|
|
328
|
+
if (!props.length) continue;
|
|
329
|
+
result.push(`r.wrapProps({${props.join(",") || ""}})`);
|
|
330
|
+
} else result.push(props);
|
|
331
|
+
}
|
|
332
|
+
return result.length > 1 ? `r.mergeProps(${result.join(",")})` : result[0];
|
|
333
|
+
}
|
|
324
334
|
function processComponent(node, options) {
|
|
335
|
+
let props = [];
|
|
325
336
|
const keys = Object.keys(node.attrs),
|
|
326
|
-
|
|
337
|
+
propGroups = [props],
|
|
327
338
|
componentIdentifier = options.counter++;
|
|
328
339
|
for (let i = 0; i < keys.length; i++) {
|
|
329
340
|
const name = keys[i],
|
|
330
341
|
value = node.attrs[name];
|
|
331
|
-
if (
|
|
332
|
-
|
|
333
|
-
|
|
342
|
+
if (name === "###") {
|
|
343
|
+
propGroups.push(`exprs[${options.counter++}]`);
|
|
344
|
+
propGroups.push(props = []);
|
|
345
|
+
} else if (value === "###") {
|
|
346
|
+
props.push(`${name}: exprs[${options.counter++}]`);
|
|
334
347
|
} else props.push(`${name}: "${value}"`);
|
|
335
348
|
}
|
|
336
349
|
if (node.children.length === 1 && node.children[0].type === "comment" && node.children[0].content === "#") {
|
|
@@ -355,7 +368,7 @@ function createHTML(r, {
|
|
|
355
368
|
tag = `_$el${uuid++}`;
|
|
356
369
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
357
370
|
}
|
|
358
|
-
if (options.parent) options.exprs.push(`r.insert(${options.parent}, r.createComponent(exprs[${componentIdentifier}]
|
|
371
|
+
if (options.parent) options.exprs.push(`r.insert(${options.parent}, r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})${tag ? `, ${tag}` : ""})`);else options.exprs.push(`${options.fragment ? "" : "return "}r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})`);
|
|
359
372
|
options.path = tag;
|
|
360
373
|
options.first = false;
|
|
361
374
|
}
|
|
@@ -408,6 +421,9 @@ function createHTML(r, {
|
|
|
408
421
|
if (value === "###") {
|
|
409
422
|
delete node.attrs[name];
|
|
410
423
|
parseAttribute(tag, name, isSVG, isCE, options);
|
|
424
|
+
} else if (name === "###") {
|
|
425
|
+
delete node.attrs[name];
|
|
426
|
+
options.exprs.push(`r.spread(${tag},exprs[${options.counter++}],${isSVG},${!!node.children.length})`);
|
|
411
427
|
}
|
|
412
428
|
}
|
|
413
429
|
options.path = tag;
|
|
@@ -468,9 +484,11 @@ var index = createHTML({
|
|
|
468
484
|
effect,
|
|
469
485
|
style,
|
|
470
486
|
insert,
|
|
487
|
+
spread,
|
|
471
488
|
createComponent,
|
|
472
489
|
delegateEvents,
|
|
473
490
|
classList,
|
|
491
|
+
mergeProps,
|
|
474
492
|
dynamicProperty,
|
|
475
493
|
setAttribute,
|
|
476
494
|
setAttributeNS,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0-beta.0",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/solidjs/solid#readme",
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
"h/types",
|
|
30
30
|
"html/dist",
|
|
31
31
|
"html/types",
|
|
32
|
+
"universal/dist",
|
|
33
|
+
"universal/types",
|
|
32
34
|
"types",
|
|
33
35
|
"jsx-runtime.d.ts"
|
|
34
36
|
],
|
|
@@ -84,6 +86,15 @@
|
|
|
84
86
|
"require": "./web/dist/web.cjs"
|
|
85
87
|
},
|
|
86
88
|
"./web/dist/*": "./web/dist/*",
|
|
89
|
+
"./universal": {
|
|
90
|
+
"development": {
|
|
91
|
+
"import": "./universal/dist/dev.js",
|
|
92
|
+
"require": "./universal/dist/dev.cjs"
|
|
93
|
+
},
|
|
94
|
+
"import": "./universal/dist/universal.js",
|
|
95
|
+
"require": "./universal/dist/universal.cjs"
|
|
96
|
+
},
|
|
97
|
+
"./universal/dist/*": "./universal/dist/*",
|
|
87
98
|
"./h": {
|
|
88
99
|
"import": "./h/dist/h.js",
|
|
89
100
|
"require": "./h/dist/h.cjs"
|
|
@@ -106,6 +117,7 @@
|
|
|
106
117
|
"build:types-web": "tsc --project ./web/tsconfig.json && tsconfig-replace-paths --project ./web/tsconfig.types.json",
|
|
107
118
|
"build:types-html": "tsc --project ./html/tsconfig.json",
|
|
108
119
|
"build:types-h": "tsc --project ./h/tsconfig.json",
|
|
120
|
+
"build:types-universal": "tsc --project ./universal/tsconfig.json",
|
|
109
121
|
"bench": "node --allow-natives-syntax bench/bench.cjs",
|
|
110
122
|
"test": "jest && npm run test:types",
|
|
111
123
|
"test:coverage": "jest --coverage && npm run test:types",
|
|
@@ -120,5 +132,5 @@
|
|
|
120
132
|
"compiler",
|
|
121
133
|
"performance"
|
|
122
134
|
],
|
|
123
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "ec5bfa3adc09c0efd9210be6ff5096ec18c06d02"
|
|
124
136
|
}
|
package/types/jsx.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function createComponent<T>(Comp: (props: T) => JSX.Element, prop
|
|
|
15
15
|
declare type BoxedTupleTypes<T extends any[]> = {
|
|
16
16
|
[P in keyof T]: [T[P]];
|
|
17
17
|
}[Exclude<keyof T, keyof any[]>];
|
|
18
|
-
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
18
|
+
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
19
19
|
declare type UnboxIntersection<T> = T extends {
|
|
20
20
|
0: infer U;
|
|
21
21
|
} ? U : never;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var solidJs = require('solid-js');
|
|
6
|
+
|
|
7
|
+
function memo(fn, equals) {
|
|
8
|
+
return solidJs.createMemo(fn, undefined, !equals ? {
|
|
9
|
+
equals
|
|
10
|
+
} : undefined);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function createRenderer$1({
|
|
14
|
+
createElement,
|
|
15
|
+
createTextNode,
|
|
16
|
+
isTextNode,
|
|
17
|
+
replaceText,
|
|
18
|
+
insertNode,
|
|
19
|
+
removeNode,
|
|
20
|
+
setProperty,
|
|
21
|
+
getParentNode,
|
|
22
|
+
getFirstChild,
|
|
23
|
+
getNextSibling
|
|
24
|
+
}) {
|
|
25
|
+
function insert(parent, accessor, marker, initial) {
|
|
26
|
+
if (marker !== undefined && !initial) initial = [];
|
|
27
|
+
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
28
|
+
solidJs.createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial);
|
|
29
|
+
}
|
|
30
|
+
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
31
|
+
while (typeof current === "function") current = current();
|
|
32
|
+
if (value === current) return current;
|
|
33
|
+
const t = typeof value,
|
|
34
|
+
multi = marker !== undefined;
|
|
35
|
+
if (t === "string" || t === "number") {
|
|
36
|
+
if (t === "number") value = value.toString();
|
|
37
|
+
if (multi) {
|
|
38
|
+
let node = current[0];
|
|
39
|
+
if (node && isTextNode(node)) {
|
|
40
|
+
replaceText(node, value);
|
|
41
|
+
} else node = createTextNode(value);
|
|
42
|
+
current = cleanChildren(parent, current, marker, node);
|
|
43
|
+
} else {
|
|
44
|
+
if (current !== "" && typeof current === "string") {
|
|
45
|
+
replaceText(getFirstChild(parent), current = value);
|
|
46
|
+
} else {
|
|
47
|
+
cleanChildren(parent, current, marker, createTextNode(value));
|
|
48
|
+
current = value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} else if (value == null || t === "boolean") {
|
|
52
|
+
current = cleanChildren(parent, current, marker);
|
|
53
|
+
} else if (t === "function") {
|
|
54
|
+
solidJs.createRenderEffect(() => {
|
|
55
|
+
let v = value();
|
|
56
|
+
while (typeof v === "function") v = v();
|
|
57
|
+
current = insertExpression(parent, v, current, marker);
|
|
58
|
+
});
|
|
59
|
+
return () => current;
|
|
60
|
+
} else if (Array.isArray(value)) {
|
|
61
|
+
const array = [];
|
|
62
|
+
if (normalizeIncomingArray(array, value, unwrapArray)) {
|
|
63
|
+
solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
64
|
+
return () => current;
|
|
65
|
+
}
|
|
66
|
+
if (array.length === 0) {
|
|
67
|
+
const replacement = cleanChildren(parent, current, marker);
|
|
68
|
+
if (multi) return current = replacement;
|
|
69
|
+
} else {
|
|
70
|
+
if (Array.isArray(current)) {
|
|
71
|
+
if (current.length === 0) {
|
|
72
|
+
appendNodes(parent, array, marker);
|
|
73
|
+
} else reconcileArrays(parent, current, array);
|
|
74
|
+
} else if (current == null || current === "") {
|
|
75
|
+
appendNodes(parent, array);
|
|
76
|
+
} else {
|
|
77
|
+
reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
current = array;
|
|
81
|
+
} else {
|
|
82
|
+
if (Array.isArray(current)) {
|
|
83
|
+
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
84
|
+
cleanChildren(parent, current, null, value);
|
|
85
|
+
} else if (current == null || current === "" || !getFirstChild(parent)) {
|
|
86
|
+
insertNode(parent, value);
|
|
87
|
+
} else replaceNode(parent, value, getFirstChild(parent));
|
|
88
|
+
current = value;
|
|
89
|
+
}
|
|
90
|
+
return current;
|
|
91
|
+
}
|
|
92
|
+
function normalizeIncomingArray(normalized, array, unwrap) {
|
|
93
|
+
let dynamic = false;
|
|
94
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
95
|
+
let item = array[i],
|
|
96
|
+
t;
|
|
97
|
+
if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
|
|
98
|
+
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
|
|
99
|
+
} else if ((t = typeof item) === "string" || t === "number") {
|
|
100
|
+
normalized.push(createTextNode(item));
|
|
101
|
+
} else if (t === "function") {
|
|
102
|
+
if (unwrap) {
|
|
103
|
+
while (typeof item === "function") item = item();
|
|
104
|
+
dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
105
|
+
} else {
|
|
106
|
+
normalized.push(item);
|
|
107
|
+
dynamic = true;
|
|
108
|
+
}
|
|
109
|
+
} else normalized.push(item);
|
|
110
|
+
}
|
|
111
|
+
return dynamic;
|
|
112
|
+
}
|
|
113
|
+
function reconcileArrays(parentNode, a, b) {
|
|
114
|
+
let bLength = b.length,
|
|
115
|
+
aEnd = a.length,
|
|
116
|
+
bEnd = bLength,
|
|
117
|
+
aStart = 0,
|
|
118
|
+
bStart = 0,
|
|
119
|
+
after = getNextSibling(a[aEnd - 1]),
|
|
120
|
+
map = null;
|
|
121
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
122
|
+
if (a[aStart] === b[bStart]) {
|
|
123
|
+
aStart++;
|
|
124
|
+
bStart++;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
while (a[aEnd - 1] === b[bEnd - 1]) {
|
|
128
|
+
aEnd--;
|
|
129
|
+
bEnd--;
|
|
130
|
+
}
|
|
131
|
+
if (aEnd === aStart) {
|
|
132
|
+
const node = bEnd < bLength ? bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart] : after;
|
|
133
|
+
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
|
|
134
|
+
} else if (bEnd === bStart) {
|
|
135
|
+
while (aStart < aEnd) {
|
|
136
|
+
if (!map || !map.has(a[aStart])) removeNode(parentNode, a[aStart]);
|
|
137
|
+
aStart++;
|
|
138
|
+
}
|
|
139
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
140
|
+
const node = getNextSibling(a[--aEnd]);
|
|
141
|
+
insertNode(parentNode, b[bStart++], getNextSibling(a[aStart++]));
|
|
142
|
+
insertNode(parentNode, b[--bEnd], node);
|
|
143
|
+
a[aEnd] = b[bEnd];
|
|
144
|
+
} else {
|
|
145
|
+
if (!map) {
|
|
146
|
+
map = new Map();
|
|
147
|
+
let i = bStart;
|
|
148
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
149
|
+
}
|
|
150
|
+
const index = map.get(a[aStart]);
|
|
151
|
+
if (index != null) {
|
|
152
|
+
if (bStart < index && index < bEnd) {
|
|
153
|
+
let i = aStart,
|
|
154
|
+
sequence = 1,
|
|
155
|
+
t;
|
|
156
|
+
while (++i < aEnd && i < bEnd) {
|
|
157
|
+
if ((t = map.get(a[i])) == null || t !== index + sequence) break;
|
|
158
|
+
sequence++;
|
|
159
|
+
}
|
|
160
|
+
if (sequence > index - bStart) {
|
|
161
|
+
const node = a[aStart];
|
|
162
|
+
while (bStart < index) insertNode(parentNode, b[bStart++], node);
|
|
163
|
+
} else replaceNode(parentNode, b[bStart++], a[aStart++]);
|
|
164
|
+
} else aStart++;
|
|
165
|
+
} else removeNode(parentNode, a[aStart++]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function cleanChildren(parent, current, marker, replacement) {
|
|
170
|
+
if (marker === undefined) {
|
|
171
|
+
let removed;
|
|
172
|
+
while (removed = getFirstChild(parent)) removeNode(parent, removed);
|
|
173
|
+
replacement && insertNode(parent, replacement);
|
|
174
|
+
return "";
|
|
175
|
+
}
|
|
176
|
+
const node = replacement || createTextNode("");
|
|
177
|
+
if (current.length) {
|
|
178
|
+
let inserted = false;
|
|
179
|
+
for (let i = current.length - 1; i >= 0; i--) {
|
|
180
|
+
const el = current[i];
|
|
181
|
+
if (node !== el) {
|
|
182
|
+
const isParent = getParentNode(el) === parent;
|
|
183
|
+
if (!inserted && !i) isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);else isParent && removeNode(parent, el);
|
|
184
|
+
} else inserted = true;
|
|
185
|
+
}
|
|
186
|
+
} else insertNode(parent, node, marker);
|
|
187
|
+
return [node];
|
|
188
|
+
}
|
|
189
|
+
function appendNodes(parent, array, marker) {
|
|
190
|
+
for (let i = 0, len = array.length; i < len; i++) insertNode(parent, array[i], marker);
|
|
191
|
+
}
|
|
192
|
+
function replaceNode(parent, newNode, oldNode) {
|
|
193
|
+
insertNode(parent, newNode, oldNode);
|
|
194
|
+
removeNode(parent, oldNode);
|
|
195
|
+
}
|
|
196
|
+
function spreadExpression(node, props, prevProps = {}, skipChildren) {
|
|
197
|
+
if (!skipChildren && "children" in props) {
|
|
198
|
+
solidJs.createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
|
|
199
|
+
}
|
|
200
|
+
solidJs.createRenderEffect(() => {
|
|
201
|
+
for (const prop in props) {
|
|
202
|
+
if (prop === "children") continue;
|
|
203
|
+
const value = props[prop];
|
|
204
|
+
if (value === prevProps[prop]) continue;
|
|
205
|
+
if (prop === "ref") value(node);else {
|
|
206
|
+
setProperty(node, prop, value, prevProps[prop]);
|
|
207
|
+
prevProps[prop] = value;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return prevProps;
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
render(code, element) {
|
|
215
|
+
let disposer;
|
|
216
|
+
solidJs.createRoot(dispose => {
|
|
217
|
+
disposer = dispose;
|
|
218
|
+
insert(element, code());
|
|
219
|
+
});
|
|
220
|
+
return disposer;
|
|
221
|
+
},
|
|
222
|
+
insert,
|
|
223
|
+
spread(node, accessor, skipChildren) {
|
|
224
|
+
if (typeof accessor === "function") {
|
|
225
|
+
solidJs.createRenderEffect(current => spreadExpression(node, accessor(), current, skipChildren));
|
|
226
|
+
} else spreadExpression(node, accessor, undefined, skipChildren);
|
|
227
|
+
},
|
|
228
|
+
createElement,
|
|
229
|
+
createTextNode,
|
|
230
|
+
insertNode,
|
|
231
|
+
setProp(node, name, value, prev) {
|
|
232
|
+
setProperty(node, name, value, prev);
|
|
233
|
+
return value;
|
|
234
|
+
},
|
|
235
|
+
mergeProps,
|
|
236
|
+
effect: solidJs.createRenderEffect,
|
|
237
|
+
memo,
|
|
238
|
+
createComponent: solidJs.createComponent
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function mergeProps(...sources) {
|
|
242
|
+
const target = {};
|
|
243
|
+
for (let i = 0; i < sources.length; i++) {
|
|
244
|
+
let source = sources[i];
|
|
245
|
+
if (typeof source === "function") source = source();
|
|
246
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
247
|
+
Object.defineProperties(target, descriptors);
|
|
248
|
+
}
|
|
249
|
+
return target;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function createRenderer(options) {
|
|
253
|
+
const renderer = createRenderer$1(options);
|
|
254
|
+
renderer.mergeProps = solidJs.mergeProps;
|
|
255
|
+
return renderer;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
exports.createRenderer = createRenderer;
|