solid-js 2.0.0-experimental.3 → 2.0.0-experimental.4

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/server.js CHANGED
@@ -1,129 +1,95 @@
1
- const equalFn = (a, b) => a === b;
2
- const $PROXY = Symbol("solid-proxy");
3
- const $TRACK = Symbol("solid-track");
4
- const $DEVCOMP = Symbol("solid-dev-component");
5
- const DEV = undefined;
6
- const ERROR = Symbol("error");
7
- function castError(err) {
8
- if (err instanceof Error) return err;
9
- return new Error(typeof err === "string" ? err : "Unknown error", {
10
- cause: err
11
- });
12
- }
13
- function handleError(err, owner = Owner) {
14
- const fns = owner && owner.context && owner.context[ERROR];
15
- const error = castError(err);
16
- if (!fns) throw error;
17
- try {
18
- for (const f of fns) f(error);
19
- } catch (e) {
20
- handleError(e, (owner && owner.owner) || null);
21
- }
22
- }
23
- const UNOWNED = {
24
- context: null,
25
- owner: null,
26
- owned: null,
27
- cleanups: null
28
- };
1
+ import { flatten } from "@solidjs/signals";
2
+ export { $PROXY, $RAW, $TRACK, catchError, flatten, isEqual, isWrappable } from "@solidjs/signals";
3
+
29
4
  let Owner = null;
30
- function createOwner() {
31
- const o = {
32
- owner: Owner,
33
- context: Owner ? Owner.context : null,
34
- owned: null,
35
- cleanups: null
36
- };
37
- if (Owner) {
38
- if (!Owner.owned) Owner.owned = [o];
39
- else Owner.owned.push(o);
40
- }
41
- return o;
42
- }
43
- function createRoot(fn, detachedOwner) {
5
+ let Observer = null;
6
+ function createRoot(fn) {
44
7
  const owner = Owner,
45
- current = detachedOwner === undefined ? owner : detachedOwner,
46
- root =
47
- fn.length === 0
48
- ? UNOWNED
49
- : {
50
- context: current ? current.context : null,
51
- owner: current,
52
- owned: null,
53
- cleanups: null
54
- };
8
+ root = {
9
+ context: owner ? owner.context : null,
10
+ owner: owner,
11
+ owned: null,
12
+ cleanups: null
13
+ };
55
14
  Owner = root;
56
- let result;
57
15
  try {
58
- result = fn(fn.length === 0 ? () => {} : () => cleanNode(root));
59
- } catch (err) {
60
- handleError(err);
16
+ return fn(fn.length === 0 ? () => {} : () => cleanNode(root));
61
17
  } finally {
62
18
  Owner = owner;
63
19
  }
64
- return result;
65
20
  }
66
- function createSignal(value, options) {
21
+ function createSignal(first, second, third) {
22
+ if (typeof first === "function") {
23
+ const memo = createMemo(p => {
24
+ let value = first(p ? p[0]() : second);
25
+ return [
26
+ () => value,
27
+ v => {
28
+ return (value = typeof v === "function" ? v(first) : v);
29
+ }
30
+ ];
31
+ });
32
+ return [() => memo()[0](), v => memo()[1](v)];
33
+ }
67
34
  return [
68
- () => value,
35
+ () => first,
69
36
  v => {
70
- return (value = typeof v === "function" ? v(value) : v);
37
+ return (first = typeof v === "function" ? v(first) : v);
71
38
  }
72
39
  ];
73
40
  }
74
- function createComputed(fn, value) {
41
+ function createMemo(compute, value, options) {
75
42
  Owner = createOwner();
43
+ let v;
76
44
  try {
77
- fn(value);
78
- } catch (err) {
79
- handleError(err);
45
+ v = compute(value);
80
46
  } finally {
81
47
  Owner = Owner.owner;
82
48
  }
49
+ return () => v;
83
50
  }
84
- const createRenderEffect = createComputed;
85
- function createEffect(fn, value) {}
86
- function createReaction(fn) {
87
- return fn => {
88
- fn();
89
- };
90
- }
91
- function createMemo(fn, value) {
51
+ function createRenderEffect(compute, effect, value, options) {
92
52
  Owner = createOwner();
93
- let v;
94
53
  try {
95
- v = fn(value);
54
+ effect(compute(value), value);
96
55
  } catch (err) {
97
- handleError(err);
98
56
  } finally {
99
57
  Owner = Owner.owner;
100
58
  }
101
- return () => v;
102
59
  }
103
- function createDeferred(source) {
104
- return source;
60
+ function createEffect(compute, effect, error, value, options) {}
61
+ function createAsync() {}
62
+ function isPending() {}
63
+ function latest() {}
64
+ function resolve() {}
65
+ function flushSync() {}
66
+ function getObserver() {
67
+ return Observer;
105
68
  }
106
- function createSelector(source, fn = equalFn) {
107
- return k => fn(k, source());
69
+ function getOwner() {
70
+ return Owner;
108
71
  }
109
- function batch(fn) {
110
- return fn();
72
+ function runWithOwner(o, fn) {
73
+ const prev = Owner;
74
+ Owner = o;
75
+ try {
76
+ return fn();
77
+ } finally {
78
+ Owner = prev;
79
+ }
111
80
  }
112
- const untrack = batch;
113
- function on(deps, fn, options = {}) {
114
- const isArray = Array.isArray(deps);
115
- const defer = options.defer;
116
- return () => {
117
- if (defer) return undefined;
118
- let value;
119
- if (isArray) {
120
- value = [];
121
- for (let i = 0; i < deps.length; i++) value.push(deps[i]());
122
- } else value = deps();
123
- return fn(value);
124
- };
81
+ function runWithObserver(o, fn) {
82
+ const prev = Observer;
83
+ Observer = o;
84
+ try {
85
+ return fn();
86
+ } finally {
87
+ Observer = prev;
88
+ }
89
+ }
90
+ function untrack(fn) {
91
+ return fn();
125
92
  }
126
- function onMount(fn) {}
127
93
  function onCleanup(fn) {
128
94
  if (Owner) {
129
95
  if (!Owner.cleanups) Owner.cleanups = [fn];
@@ -131,6 +97,42 @@ function onCleanup(fn) {
131
97
  }
132
98
  return fn;
133
99
  }
100
+ function mapArray(list, mapFn, options = {}) {
101
+ const items = list();
102
+ let s = [];
103
+ if (items && items.length) {
104
+ for (let i = 0, len = items.length; i < len; i++)
105
+ s.push(
106
+ mapFn(
107
+ () => items[i],
108
+ () => i
109
+ )
110
+ );
111
+ } else if (options.fallback) s = [options.fallback()];
112
+ return () => s;
113
+ }
114
+ function repeat(count, mapFn, options = {}) {
115
+ const len = count();
116
+ const offset = options.from?.() || 0;
117
+ let s = [];
118
+ if (len) {
119
+ for (let i = 0; i < len; i++) s.push(mapFn(i + offset));
120
+ } else if (options.fallback) s = [options.fallback()];
121
+ return () => s;
122
+ }
123
+ function createOwner() {
124
+ const o = {
125
+ owner: Owner,
126
+ context: Owner ? Owner.context : null,
127
+ owned: null,
128
+ cleanups: null
129
+ };
130
+ if (Owner) {
131
+ if (!Owner.owned) Owner.owned = [o];
132
+ else Owner.owned.push(o);
133
+ }
134
+ return o;
135
+ }
134
136
  function cleanNode(node) {
135
137
  if (node.owned) {
136
138
  for (let i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
@@ -141,131 +143,47 @@ function cleanNode(node) {
141
143
  node.cleanups = null;
142
144
  }
143
145
  }
144
- function catchError(fn, handler) {
145
- const owner = createOwner();
146
- owner.context = {
147
- ...owner.context,
148
- [ERROR]: [handler]
149
- };
150
- Owner = owner;
151
- try {
152
- return fn();
153
- } catch (err) {
154
- handleError(err);
155
- } finally {
156
- Owner = Owner.owner;
157
- }
158
- }
159
- function getListener() {
160
- return null;
161
- }
146
+
147
+ function onMount(fn) {}
162
148
  function createContext(defaultValue) {
163
149
  const id = Symbol("context");
164
- return {
165
- id,
166
- Provider: createProvider(id),
167
- defaultValue
168
- };
150
+ const P = createProvider(id);
151
+ P.id = id;
152
+ P.defaultValue = defaultValue;
153
+ return P;
169
154
  }
170
155
  function useContext(context) {
171
- return Owner && Owner.context && Owner.context[context.id] !== undefined
172
- ? Owner.context[context.id]
156
+ const owner = getOwner();
157
+ return owner && owner.context && owner.context[context.id] !== undefined
158
+ ? owner.context[context.id]
173
159
  : context.defaultValue;
174
160
  }
175
- function getOwner() {
176
- return Owner;
177
- }
178
161
  function children(fn) {
179
- const memo = createMemo(() => resolveChildren(fn()));
162
+ const children = createMemo(fn);
163
+ const memo = createMemo(() => flatten(children()));
180
164
  memo.toArray = () => {
181
165
  const c = memo();
182
166
  return Array.isArray(c) ? c : c != null ? [c] : [];
183
167
  };
184
168
  return memo;
185
169
  }
186
- function runWithOwner(o, fn) {
187
- const prev = Owner;
188
- Owner = o;
189
- try {
190
- return fn();
191
- } catch (err) {
192
- handleError(err);
193
- } finally {
194
- Owner = prev;
195
- }
196
- }
197
- function resolveChildren(children) {
198
- if (typeof children === "function" && !children.length) return resolveChildren(children());
199
- if (Array.isArray(children)) {
200
- const results = [];
201
- for (let i = 0; i < children.length; i++) {
202
- const result = resolveChildren(children[i]);
203
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
204
- }
205
- return results;
206
- }
207
- return children;
208
- }
209
170
  function createProvider(id) {
210
171
  return function provider(props) {
211
172
  return createMemo(() => {
212
- Owner.context = {
213
- ...Owner.context,
173
+ const owner = getOwner();
174
+ owner.context = {
175
+ ...owner.context,
214
176
  [id]: props.value
215
177
  };
216
178
  return children(() => props.children);
217
179
  });
218
180
  };
219
181
  }
220
- function requestCallback(fn, options) {
221
- return {
222
- id: 0,
223
- fn: () => {},
224
- startTime: 0,
225
- expirationTime: 0
226
- };
227
- }
228
- function mapArray(list, mapFn, options = {}) {
229
- const items = list();
230
- let s = [];
231
- if (items && items.length) {
232
- for (let i = 0, len = items.length; i < len; i++) s.push(mapFn(items[i], () => i));
233
- } else if (options.fallback) s = [options.fallback()];
234
- return () => s;
235
- }
236
- function indexArray(list, mapFn, options = {}) {
237
- const items = list();
238
- let s = [];
239
- if (items && items.length) {
240
- for (let i = 0, len = items.length; i < len; i++) s.push(mapFn(() => items[i], i));
241
- } else if (options.fallback) s = [options.fallback()];
242
- return () => s;
243
- }
244
182
  function observable(input) {
245
183
  return {
246
184
  subscribe(observer) {
247
- if (!(observer instanceof Object) || observer == null) {
248
- throw new TypeError("Expected the observer to be an object.");
249
- }
250
- const handler =
251
- typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
252
- if (!handler) {
253
- return {
254
- unsubscribe() {}
255
- };
256
- }
257
- const dispose = createRoot(disposer => {
258
- createEffect(() => {
259
- const v = input();
260
- untrack(() => handler(v));
261
- });
262
- return disposer;
263
- });
264
- if (getOwner()) onCleanup(dispose);
265
185
  return {
266
- unsubscribe() {
267
- dispose();
268
- }
186
+ unsubscribe() {}
269
187
  };
270
188
  },
271
189
  [Symbol.observable || "@@observable"]() {
@@ -274,7 +192,9 @@ function observable(input) {
274
192
  };
275
193
  }
276
194
  function from(producer) {
277
- const [s, set] = createSignal(undefined);
195
+ const [s, set] = createSignal(undefined, {
196
+ equals: false
197
+ });
278
198
  if ("subscribe" in producer) {
279
199
  const unsub = producer.subscribe(v => set(() => v));
280
200
  onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
@@ -284,96 +204,85 @@ function from(producer) {
284
204
  }
285
205
  return s;
286
206
  }
287
- function enableExternalSource(factory) {}
288
- function onError(fn) {
289
- if (Owner) {
290
- if (Owner.context === null || !Owner.context[ERROR]) {
291
- Owner.context = {
292
- ...Owner.context,
293
- [ERROR]: [fn]
294
- };
295
- mutateContext(Owner, ERROR, [fn]);
296
- } else Owner.context[ERROR].push(fn);
297
- }
207
+
208
+ function isWrappable(obj) {
209
+ return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
298
210
  }
299
- function mutateContext(o, key, value) {
300
- if (o.owned) {
301
- for (let i = 0; i < o.owned.length; i++) {
302
- if (o.owned[i].context === o.context) mutateContext(o.owned[i], key, value);
303
- if (!o.owned[i].context) {
304
- o.owned[i].context = o.context;
305
- mutateContext(o.owned[i], key, value);
306
- } else if (!o.owned[i].context[key]) {
307
- o.owned[i].context[key] = value;
308
- mutateContext(o.owned[i], key, value);
309
- }
310
- }
211
+ function unwrap(item) {
212
+ return item;
213
+ }
214
+ function setProperty(state, property, value) {
215
+ if (state[property] === value) return;
216
+ if (value === undefined) {
217
+ delete state[property];
218
+ } else state[property] = value;
219
+ }
220
+ function createStore(state) {
221
+ function setStore(fn) {
222
+ fn(state);
311
223
  }
224
+ return [state, setStore];
312
225
  }
313
-
314
- function escape(s, attr) {
315
- const t = typeof s;
316
- if (t !== "string") {
317
- if (t === "function") return escape(s());
318
- if (Array.isArray(s)) {
319
- for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
320
- return s;
226
+ function createProjection(fn, initialValue = {}) {
227
+ const [state] = createStore(initialValue);
228
+ fn(state);
229
+ return state;
230
+ }
231
+ function reconcile(value) {
232
+ return state => {
233
+ if (!isWrappable(state) || !isWrappable(value)) return value;
234
+ const targetKeys = Object.keys(value);
235
+ const previousKeys = Object.keys(state);
236
+ for (let i = 0, len = targetKeys.length; i < len; i++) {
237
+ const key = targetKeys[i];
238
+ setProperty(state, key, value[key]);
321
239
  }
322
- return s;
323
- }
324
- const delim = "<";
325
- const escDelim = "&lt;";
326
- let iDelim = s.indexOf(delim);
327
- let iAmp = s.indexOf("&");
328
- if (iDelim < 0 && iAmp < 0) return s;
329
- let left = 0,
330
- out = "";
331
- while (iDelim >= 0 && iAmp >= 0) {
332
- if (iDelim < iAmp) {
333
- if (left < iDelim) out += s.substring(left, iDelim);
334
- out += escDelim;
335
- left = iDelim + 1;
336
- iDelim = s.indexOf(delim, left);
337
- } else {
338
- if (left < iAmp) out += s.substring(left, iAmp);
339
- out += "&amp;";
340
- left = iAmp + 1;
341
- iAmp = s.indexOf("&", left);
240
+ for (let i = 0, len = previousKeys.length; i < len; i++) {
241
+ if (value[previousKeys[i]] === undefined) setProperty(state, previousKeys[i], undefined);
342
242
  }
343
- }
344
- if (iDelim >= 0) {
345
- do {
346
- if (left < iDelim) out += s.substring(left, iDelim);
347
- out += escDelim;
348
- left = iDelim + 1;
349
- iDelim = s.indexOf(delim, left);
350
- } while (iDelim >= 0);
351
- } else
352
- while (iAmp >= 0) {
353
- if (left < iAmp) out += s.substring(left, iAmp);
354
- out += "&amp;";
355
- left = iAmp + 1;
356
- iAmp = s.indexOf("&", left);
243
+ return state;
244
+ };
245
+ }
246
+ function merge(...sources) {
247
+ const target = {};
248
+ for (let i = 0; i < sources.length; i++) {
249
+ let source = sources[i];
250
+ if (typeof source === "function") source = source();
251
+ if (source) {
252
+ const descriptors = Object.getOwnPropertyDescriptors(source);
253
+ for (const key in descriptors) {
254
+ if (key in target) continue;
255
+ Object.defineProperty(target, key, {
256
+ enumerable: true,
257
+ get() {
258
+ for (let i = sources.length - 1; i >= 0; i--) {
259
+ let v,
260
+ s = sources[i],
261
+ t = typeof s;
262
+ if (t === "function") s = s();
263
+ if (t === "object" && t !== null && key in s) return v;
264
+ }
265
+ }
266
+ });
267
+ }
357
268
  }
358
- return left < s.length ? out + s.substring(left) : out;
359
- }
360
- function resolveSSRNode(node) {
361
- const t = typeof node;
362
- if (t === "string") return node;
363
- if (node == null || t === "boolean") return "";
364
- if (Array.isArray(node)) {
365
- let prev = {};
366
- let mapped = "";
367
- for (let i = 0, len = node.length; i < len; i++) {
368
- if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
369
- mapped += resolveSSRNode((prev = node[i]));
269
+ }
270
+ return target;
271
+ }
272
+ function omit(props, ...keys) {
273
+ const descriptors = Object.getOwnPropertyDescriptors(props),
274
+ descriptorKeys = Object.keys(descriptors),
275
+ clone = {};
276
+ for (let i = 0; i < descriptorKeys.length; i++) {
277
+ const key = descriptorKeys[i];
278
+ if (keys.indexOf(key) === -1) {
279
+ Object.defineProperty(clone, key, descriptors[key]);
280
+ delete descriptors[key];
370
281
  }
371
- return mapped;
372
282
  }
373
- if (t === "object") return node.t;
374
- if (t === "function") return resolveSSRNode(node());
375
- return String(node);
283
+ return clone;
376
284
  }
285
+
377
286
  const sharedConfig = {
378
287
  context: undefined,
379
288
  getContextId() {
@@ -416,69 +325,26 @@ function createComponent(Comp, props) {
416
325
  }
417
326
  return Comp(props || {});
418
327
  }
419
- function mergeProps(...sources) {
420
- const target = {};
421
- for (let i = 0; i < sources.length; i++) {
422
- let source = sources[i];
423
- if (typeof source === "function") source = source();
424
- if (source) {
425
- const descriptors = Object.getOwnPropertyDescriptors(source);
426
- for (const key in descriptors) {
427
- if (key in target) continue;
428
- Object.defineProperty(target, key, {
429
- enumerable: true,
430
- get() {
431
- for (let i = sources.length - 1; i >= 0; i--) {
432
- let v,
433
- s = sources[i];
434
- if (typeof s === "function") s = s();
435
- v = (s || {})[key];
436
- if (v !== undefined) return v;
437
- }
438
- }
439
- });
440
- }
441
- }
442
- }
443
- return target;
444
- }
445
- function splitProps(props, ...keys) {
446
- const descriptors = Object.getOwnPropertyDescriptors(props),
447
- split = k => {
448
- const clone = {};
449
- for (let i = 0; i < k.length; i++) {
450
- const key = k[i];
451
- if (descriptors[key]) {
452
- Object.defineProperty(clone, key, descriptors[key]);
453
- delete descriptors[key];
454
- }
455
- }
456
- return clone;
457
- };
458
- return keys.map(split).concat(split(Object.keys(descriptors)));
459
- }
460
- function simpleMap(props, wrap) {
461
- const list = props.each || [],
462
- len = list.length,
463
- fn = props.children;
464
- if (len) {
465
- let mapped = Array(len);
466
- for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
467
- return mapped;
468
- }
469
- return props.fallback;
470
- }
471
328
  function For(props) {
472
- return simpleMap(props, (fn, item, i) => fn(item, () => i));
329
+ return mapArray(() => props.each, props.children, {
330
+ fallback: () => props.fallback
331
+ });
473
332
  }
474
- function Index(props) {
475
- return simpleMap(props, (fn, item, i) => fn(() => item, i));
333
+ function Repeat(props) {
334
+ return repeat(
335
+ () => props.count,
336
+ index => props.children(index),
337
+ {
338
+ fallback: () => props.fallback,
339
+ from: () => props.from
340
+ }
341
+ );
476
342
  }
477
343
  function Show(props) {
478
344
  let c;
479
345
  return props.when
480
346
  ? typeof (c = props.children) === "function"
481
- ? c(props.keyed ? props.when : () => props.when)
347
+ ? c(() => props.when)
482
348
  : c
483
349
  : props.fallback || "";
484
350
  }
@@ -489,7 +355,7 @@ function Switch(props) {
489
355
  const w = conditions[i].when;
490
356
  if (w) {
491
357
  const c = conditions[i].children;
492
- return typeof c === "function" ? c(conditions[i].keyed ? w : () => w) : c;
358
+ return typeof c === "function" ? c(() => w) : c;
493
359
  }
494
360
  }
495
361
  return props.fallback || "";
@@ -497,374 +363,59 @@ function Switch(props) {
497
363
  function Match(props) {
498
364
  return props;
499
365
  }
500
- function resetErrorBoundaries() {}
501
- function ErrorBoundary(props) {
502
- let error,
503
- res,
504
- clean,
505
- sync = true;
506
- const ctx = sharedConfig.context;
507
- const id = sharedConfig.getContextId();
508
- function displayFallback() {
509
- cleanNode(clean);
510
- ctx.serialize(id, error);
511
- setHydrateContext({
512
- ...ctx,
513
- count: 0
514
- });
515
- const f = props.fallback;
516
- return typeof f === "function" && f.length ? f(error, () => {}) : f;
517
- }
518
- createMemo(() => {
519
- clean = Owner;
520
- return catchError(
521
- () => (res = props.children),
522
- err => {
523
- error = err;
524
- !sync && ctx.replace("e" + id, displayFallback);
525
- sync = true;
526
- }
527
- );
528
- });
529
- if (error) return displayFallback();
530
- sync = false;
531
- return {
532
- t: `<!--!$e${id}-->${resolveSSRNode(escape(res))}<!--!$/e${id}-->`
533
- };
534
- }
535
- const SuspenseContext = createContext();
536
- let resourceContext = null;
537
- function createResource(source, fetcher, options = {}) {
538
- if (typeof fetcher !== "function") {
539
- options = fetcher || {};
540
- fetcher = source;
541
- source = true;
542
- }
543
- const contexts = new Set();
544
- const id = sharedConfig.getNextContextId();
545
- let resource = {};
546
- let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
547
- let p;
548
- let error;
549
- if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
550
- resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
551
- if (resource.ref) {
552
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
553
- resource.ref[1].refetch();
554
- return resource.ref;
555
- }
556
- }
557
- const read = () => {
558
- if (error) throw error;
559
- const resolved =
560
- options.ssrLoadFrom !== "initial" &&
561
- sharedConfig.context.async &&
562
- "data" in sharedConfig.context.resources[id];
563
- if (!resolved && resourceContext) resourceContext.push(id);
564
- if (!resolved && read.loading) {
565
- const ctx = useContext(SuspenseContext);
566
- if (ctx) {
567
- ctx.resources.set(id, read);
568
- contexts.add(ctx);
569
- }
570
- }
571
- return resolved ? sharedConfig.context.resources[id].data : value;
572
- };
573
- read.loading = false;
574
- read.error = undefined;
575
- read.state = "initialValue" in options ? "ready" : "unresolved";
576
- Object.defineProperty(read, "latest", {
577
- get() {
578
- return read();
579
- }
580
- });
581
- function load() {
582
- const ctx = sharedConfig.context;
583
- if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
584
- if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
585
- value = ctx.resources[id].data;
586
- return;
587
- }
588
- let lookup;
589
- try {
590
- resourceContext = [];
591
- lookup = typeof source === "function" ? source() : source;
592
- if (resourceContext.length) return;
593
- } finally {
594
- resourceContext = null;
595
- }
596
- if (!p) {
597
- if (lookup == null || lookup === false) return;
598
- p = fetcher(lookup, {
599
- value
600
- });
601
- }
602
- if (p != undefined && typeof p === "object" && "then" in p) {
603
- read.loading = true;
604
- read.state = "pending";
605
- p = p
606
- .then(res => {
607
- read.loading = false;
608
- read.state = "ready";
609
- ctx.resources[id].data = res;
610
- p = null;
611
- notifySuspense(contexts);
612
- return res;
613
- })
614
- .catch(err => {
615
- read.loading = false;
616
- read.state = "errored";
617
- read.error = error = castError(err);
618
- p = null;
619
- notifySuspense(contexts);
620
- throw error;
621
- });
622
- if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
623
- return p;
624
- }
625
- ctx.resources[id].data = p;
626
- if (ctx.serialize) ctx.serialize(id, p);
627
- p = null;
628
- return ctx.resources[id].data;
629
- }
630
- if (options.ssrLoadFrom !== "initial") load();
631
- return (resource.ref = [
632
- read,
633
- {
634
- refetch: load,
635
- mutate: v => (value = v)
636
- }
637
- ]);
638
- }
366
+ function ErrorBoundary(props) {}
639
367
  function lazy(fn) {
640
- let p;
641
- let load = id => {
642
- if (!p) {
643
- p = fn();
644
- p.then(mod => (p.resolved = mod.default));
645
- if (id) sharedConfig.context.lazy[id] = p;
646
- }
647
- return p;
648
- };
649
- const contexts = new Set();
650
- const wrap = props => {
651
- const id = sharedConfig.context.id;
652
- let ref = sharedConfig.context.lazy[id];
653
- if (ref) p = ref;
654
- else load(id);
655
- if (p.resolved) return p.resolved(props);
656
- const ctx = useContext(SuspenseContext);
657
- const track = {
658
- loading: true,
659
- error: undefined
660
- };
661
- if (ctx) {
662
- ctx.resources.set(id, track);
663
- contexts.add(ctx);
664
- }
665
- if (sharedConfig.context.async) {
666
- sharedConfig.context.block(
667
- p.then(() => {
668
- track.loading = false;
669
- notifySuspense(contexts);
670
- })
671
- );
672
- }
673
- return "";
674
- };
675
- wrap.preload = load;
676
- return wrap;
368
+ return {};
677
369
  }
678
- function suspenseComplete(c) {
679
- for (const r of c.resources.values()) {
680
- if (r.loading) return false;
681
- }
682
- return true;
683
- }
684
- function notifySuspense(contexts) {
685
- for (const c of contexts) {
686
- if (!suspenseComplete(c)) {
687
- continue;
688
- }
689
- c.completed();
690
- contexts.delete(c);
691
- }
692
- }
693
- function enableScheduling() {}
694
370
  function enableHydration() {}
695
- function startTransition(fn) {
696
- fn();
697
- }
698
- function useTransition() {
699
- return [
700
- () => false,
701
- fn => {
702
- fn();
703
- }
704
- ];
705
- }
706
- function SuspenseList(props) {
707
- return props.children;
708
- }
709
- function Suspense(props) {
710
- let done;
711
- const ctx = sharedConfig.context;
712
- const id = sharedConfig.getContextId();
713
- const o = createOwner();
714
- const value =
715
- ctx.suspense[id] ||
716
- (ctx.suspense[id] = {
717
- resources: new Map(),
718
- completed: () => {
719
- const res = runSuspense();
720
- if (suspenseComplete(value)) {
721
- done(resolveSSRNode(escape(res)));
722
- }
723
- }
724
- });
725
- function suspenseError(err) {
726
- if (!done || !done(undefined, err)) {
727
- runWithOwner(o.owner, () => {
728
- throw err;
729
- });
730
- }
731
- }
732
- function runSuspense() {
733
- setHydrateContext({
734
- ...ctx,
735
- count: 0
736
- });
737
- cleanNode(o);
738
- return runWithOwner(o, () =>
739
- createComponent(SuspenseContext.Provider, {
740
- value,
741
- get children() {
742
- return catchError(() => props.children, suspenseError);
743
- }
744
- })
745
- );
746
- }
747
- const res = runSuspense();
748
- if (suspenseComplete(value)) {
749
- delete ctx.suspense[id];
750
- return res;
751
- }
752
- done = ctx.async ? ctx.registerFragment(id) : undefined;
753
- return catchError(() => {
754
- if (ctx.async) {
755
- setHydrateContext({
756
- ...ctx,
757
- count: 0,
758
- id: ctx.id + "0F",
759
- noHydrate: true
760
- });
761
- const res = {
762
- t: `<template id="pl-${id}"></template>${resolveSSRNode(
763
- escape(props.fallback)
764
- )}<!--pl-${id}-->`
765
- };
766
- setHydrateContext(ctx);
767
- return res;
768
- }
769
- setHydrateContext({
770
- ...ctx,
771
- count: 0,
772
- id: ctx.id + "0F"
773
- });
774
- ctx.serialize(id, "$$f");
775
- return props.fallback;
776
- }, suspenseError);
777
- }
371
+ function Suspense(props) {}
778
372
 
779
- function isWrappable(obj) {
780
- return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
781
- }
782
- function unwrap(item) {
783
- return item;
784
- }
785
- function setProperty(state, property, value) {
786
- if (state[property] === value) return;
787
- if (value === undefined) {
788
- delete state[property];
789
- } else state[property] = value;
790
- }
791
- function createStore(state) {
792
- function setStore(fn) {
793
- fn(state);
794
- }
795
- return [state, setStore];
796
- }
797
- function reconcile(value) {
798
- return state => {
799
- if (!isWrappable(state) || !isWrappable(value)) return value;
800
- const targetKeys = Object.keys(value);
801
- const previousKeys = Object.keys(state);
802
- for (let i = 0, len = targetKeys.length; i < len; i++) {
803
- const key = targetKeys[i];
804
- setProperty(state, key, value[key]);
805
- }
806
- for (let i = 0, len = previousKeys.length; i < len; i++) {
807
- if (value[previousKeys[i]] === undefined) setProperty(state, previousKeys[i], undefined);
808
- }
809
- return state;
810
- };
811
- }
373
+ const $DEVCOMP = Symbol("solid-dev-component");
374
+ const DEV = undefined;
812
375
 
813
376
  export {
814
377
  $DEVCOMP,
815
- $PROXY,
816
- $TRACK,
817
378
  DEV,
818
379
  ErrorBoundary,
819
380
  For,
820
- Index,
821
381
  Match,
382
+ Repeat,
822
383
  Show,
823
384
  Suspense,
824
- SuspenseList,
825
385
  Switch,
826
- batch,
827
- catchError,
828
386
  children,
387
+ createAsync,
829
388
  createComponent,
830
389
  createContext,
831
- createDeferred,
832
390
  createEffect,
833
391
  createMemo,
834
- createReaction,
392
+ createProjection,
835
393
  createRenderEffect,
836
- createResource,
837
394
  createRoot,
838
- createSelector,
839
395
  createSignal,
840
396
  createStore,
841
397
  createUniqueId,
842
- enableExternalSource,
843
398
  enableHydration,
844
- enableScheduling,
845
- equalFn,
399
+ flushSync,
846
400
  from,
847
- getListener,
401
+ getObserver,
848
402
  getOwner,
849
- indexArray,
850
- isWrappable,
403
+ isPending,
404
+ latest,
851
405
  lazy,
852
406
  mapArray,
853
- mergeProps,
407
+ merge,
854
408
  observable,
855
- on,
409
+ omit,
856
410
  onCleanup,
857
- onError,
858
411
  onMount,
859
412
  reconcile,
860
- requestCallback,
861
- resetErrorBoundaries,
413
+ repeat,
414
+ resolve,
415
+ runWithObserver,
862
416
  runWithOwner,
863
417
  sharedConfig,
864
- splitProps,
865
- startTransition,
866
418
  untrack,
867
419
  unwrap,
868
- useContext,
869
- useTransition
420
+ useContext
870
421
  };