@solidjs/web 2.0.0-beta.17 → 2.0.0-beta.18

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 CHANGED
@@ -959,8 +959,7 @@ function insertExpression(parent, value, current, marker) {
959
959
  if (tc === "string" || tc === "number") {
960
960
  parent.firstChild.data = value;
961
961
  } else {
962
- const owned = ownedChildCount(current);
963
- if (owned === -1 || owned === parent.childNodes.length) parent.textContent = value;else {
962
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
964
963
  removeOwnedChildren(parent, current);
965
964
  parent.insertBefore(document.createTextNode(value), parent.firstChild);
966
965
  }
@@ -1027,11 +1026,15 @@ function appendNodes(parent, array, marker = null) {
1027
1026
  if (marker) n[$$SLOT] = marker;
1028
1027
  }
1029
1028
  }
1030
- function ownedChildCount(current) {
1031
- if (Array.isArray(current)) return current.length;
1032
- if (current == null) return -1;
1033
- if (current === "") return 0;
1034
- return 1;
1029
+ function ownsAllChildren(parent, current) {
1030
+ if (current == null) return true;
1031
+ if (Array.isArray(current)) {
1032
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
1033
+ }
1034
+ if (current === "") return parent.firstChild === null;
1035
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
1036
+ const first = parent.firstChild;
1037
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
1035
1038
  }
1036
1039
  function removeOwnedChildren(parent, current) {
1037
1040
  if (Array.isArray(current)) {
@@ -1048,8 +1051,7 @@ function removeOwnedChildren(parent, current) {
1048
1051
  }
1049
1052
  function cleanChildren(parent, current, marker, replacement) {
1050
1053
  if (marker === undefined) {
1051
- const owned = ownedChildCount(current);
1052
- if (owned === -1 || owned === parent.childNodes.length) return parent.textContent = "";
1054
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
1053
1055
  return removeOwnedChildren(parent, current);
1054
1056
  }
1055
1057
  if (current.length) {
@@ -1124,11 +1126,16 @@ const hydrate = (...args) => {
1124
1126
  return hydrate$1(...args);
1125
1127
  };
1126
1128
  function Portal(props) {
1129
+ return solidJs.runWithOwner(solidJs.createOwner(), () => portalImpl(props));
1130
+ }
1131
+ function portalImpl(props) {
1127
1132
  const treeMarker = document.createTextNode(""),
1128
1133
  startMarker = document.createTextNode(""),
1129
1134
  endMarker = document.createTextNode(""),
1130
1135
  mount = () => props.mount || document.body,
1131
- content = solidJs.createMemo(() => [startMarker, props.children]);
1136
+ content = solidJs.createMemo(() => [startMarker, props.children], {
1137
+ ssrSource: "client"
1138
+ });
1132
1139
  solidJs.createRenderEffect(
1133
1140
  () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
1134
1141
  const m = solidJs.untrack(mount);
@@ -1149,8 +1156,10 @@ function Portal(props) {
1149
1156
  c = n;
1150
1157
  }
1151
1158
  };
1152
- }, {
1153
- schedule: true
1159
+ },
1160
+ {
1161
+ schedule: true,
1162
+ ssrSource: "client"
1154
1163
  });
1155
1164
  solidJs.createEffect(mount, () => {
1156
1165
  const m = solidJs.untrack(mount);
@@ -1158,6 +1167,11 @@ function Portal(props) {
1158
1167
  if (!ownerRoot || ownerRoot.contains(m)) return;
1159
1168
  registerDelegatedContainer(m, ownerRoot);
1160
1169
  return () => unregisterDelegatedContainer(m, ownerRoot);
1170
+ }, {
1171
+ ssrSource: "client"
1172
+ });
1173
+ if (solidJs.sharedConfig.hydrating) return solidJs.createMemo(() => treeMarker, {
1174
+ ssrSource: "client"
1161
1175
  });
1162
1176
  return treeMarker;
1163
1177
  }
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, getOwner, createEffect, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createOwner, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush, getOwner, createEffect } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
3
3
 
4
4
  const DOMWithState = {
@@ -958,8 +958,7 @@ function insertExpression(parent, value, current, marker) {
958
958
  if (tc === "string" || tc === "number") {
959
959
  parent.firstChild.data = value;
960
960
  } else {
961
- const owned = ownedChildCount(current);
962
- if (owned === -1 || owned === parent.childNodes.length) parent.textContent = value;else {
961
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
963
962
  removeOwnedChildren(parent, current);
964
963
  parent.insertBefore(document.createTextNode(value), parent.firstChild);
965
964
  }
@@ -1026,11 +1025,15 @@ function appendNodes(parent, array, marker = null) {
1026
1025
  if (marker) n[$$SLOT] = marker;
1027
1026
  }
1028
1027
  }
1029
- function ownedChildCount(current) {
1030
- if (Array.isArray(current)) return current.length;
1031
- if (current == null) return -1;
1032
- if (current === "") return 0;
1033
- return 1;
1028
+ function ownsAllChildren(parent, current) {
1029
+ if (current == null) return true;
1030
+ if (Array.isArray(current)) {
1031
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
1032
+ }
1033
+ if (current === "") return parent.firstChild === null;
1034
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
1035
+ const first = parent.firstChild;
1036
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
1034
1037
  }
1035
1038
  function removeOwnedChildren(parent, current) {
1036
1039
  if (Array.isArray(current)) {
@@ -1047,8 +1050,7 @@ function removeOwnedChildren(parent, current) {
1047
1050
  }
1048
1051
  function cleanChildren(parent, current, marker, replacement) {
1049
1052
  if (marker === undefined) {
1050
- const owned = ownedChildCount(current);
1051
- if (owned === -1 || owned === parent.childNodes.length) return parent.textContent = "";
1053
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
1052
1054
  return removeOwnedChildren(parent, current);
1053
1055
  }
1054
1056
  if (current.length) {
@@ -1123,11 +1125,16 @@ const hydrate = (...args) => {
1123
1125
  return hydrate$1(...args);
1124
1126
  };
1125
1127
  function Portal(props) {
1128
+ return runWithOwner(createOwner(), () => portalImpl(props));
1129
+ }
1130
+ function portalImpl(props) {
1126
1131
  const treeMarker = document.createTextNode(""),
1127
1132
  startMarker = document.createTextNode(""),
1128
1133
  endMarker = document.createTextNode(""),
1129
1134
  mount = () => props.mount || document.body,
1130
- content = createMemo(() => [startMarker, props.children]);
1135
+ content = createMemo(() => [startMarker, props.children], {
1136
+ ssrSource: "client"
1137
+ });
1131
1138
  createRenderEffect(
1132
1139
  () => [mount(), content(), getOwner()], ([, c, owner]) => {
1133
1140
  const m = untrack(mount);
@@ -1148,8 +1155,10 @@ function Portal(props) {
1148
1155
  c = n;
1149
1156
  }
1150
1157
  };
1151
- }, {
1152
- schedule: true
1158
+ },
1159
+ {
1160
+ schedule: true,
1161
+ ssrSource: "client"
1153
1162
  });
1154
1163
  createEffect(mount, () => {
1155
1164
  const m = untrack(mount);
@@ -1157,6 +1166,11 @@ function Portal(props) {
1157
1166
  if (!ownerRoot || ownerRoot.contains(m)) return;
1158
1167
  registerDelegatedContainer(m, ownerRoot);
1159
1168
  return () => unregisterDelegatedContainer(m, ownerRoot);
1169
+ }, {
1170
+ ssrSource: "client"
1171
+ });
1172
+ if (sharedConfig.hydrating) return createMemo(() => treeMarker, {
1173
+ ssrSource: "client"
1160
1174
  });
1161
1175
  return treeMarker;
1162
1176
  }
package/dist/server.cjs CHANGED
@@ -66,25 +66,32 @@ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectF
66
66
  } : transparentOptions);
67
67
  const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
68
68
 
69
- const ES2017FLAG = seroval.Feature.AggregateError |
70
- seroval.Feature.BigIntTypedArray;
71
- const GLOBAL_IDENTIFIER = "_$HY.r";
72
- function createSerializer({
69
+ const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
70
+ const HYDRATION_GLOBAL = "_$HY.r";
71
+ const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
72
+ web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
73
+ web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin]);
74
+ function resolveSerializerPlugins(customPlugins) {
75
+ return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
76
+ }
77
+ function createSerializer(options) {
78
+ return new seroval.Serializer({
79
+ ...options,
80
+ plugins: resolveSerializerPlugins(options.plugins),
81
+ disabledFeatures: options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures
82
+ });
83
+ }
84
+ function createHydrationSerializer({
73
85
  onData,
74
86
  onDone,
75
87
  scopeId,
76
88
  onError,
77
- plugins: customPlugins
89
+ plugins
78
90
  }) {
79
- const defaultPlugins = [web.AbortSignalPlugin,
80
- web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
81
- web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin];
82
- const allPlugins = customPlugins ? [...customPlugins, ...defaultPlugins] : defaultPlugins;
83
- return new seroval.Serializer({
91
+ return createSerializer({
84
92
  scopeId,
85
- plugins: allPlugins,
86
- globalIdentifier: GLOBAL_IDENTIFIER,
87
- disabledFeatures: ES2017FLAG,
93
+ plugins,
94
+ globalIdentifier: HYDRATION_GLOBAL,
88
95
  onData,
89
96
  onDone,
90
97
  onError
@@ -93,6 +100,7 @@ function createSerializer({
93
100
  function getLocalHeaderScript(id) {
94
101
  return seroval.getCrossReferenceHeader(id) + ";";
95
102
  }
103
+ seroval.Feature.RegExp;
96
104
 
97
105
  function joinAssetPath(base, file) {
98
106
  if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
@@ -124,7 +132,7 @@ function resolveAssets(moduleUrl, manifest) {
124
132
  };
125
133
  }
126
134
  function registerEntryAssets(manifest) {
127
- if (!manifest) return;
135
+ if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
128
136
  const ctx = solidJs.sharedConfig.context;
129
137
  if (!ctx?.registerAsset) return;
130
138
  for (const key in manifest) {
@@ -205,10 +213,21 @@ function applyAssetTracking(context, tracking, manifest) {
205
213
  });
206
214
  context.registerModule = tracking.registerModule;
207
215
  context.getBoundaryModules = tracking.getBoundaryModules;
208
- if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
216
+ if (typeof manifest === "function") {
217
+ context.resolveAssets = manifest;
218
+ } else if (manifest && typeof manifest.resolve === "function") {
219
+ context.resolveAssets = key => manifest.resolve(key);
220
+ if (typeof manifest.resolveSync === "function") {
221
+ context.resolveAssetsSync = key => manifest.resolveSync(key);
222
+ }
223
+ } else if (manifest) {
224
+ const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
225
+ context.resolveAssets = resolve;
226
+ context.resolveAssetsSync = resolve;
227
+ }
209
228
  }
210
229
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
211
- const REPLACE_SCRIPT = `function $df(e,n,o,t){if(!(n=document.getElementById(e))||!(o=document.getElementById("pl-"+e)))return 0;for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content),n.remove(),_$HY.fe(e);return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return 0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1;return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
230
+ const REPLACE_SCRIPT = `function $df(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content),n.remove(),_$HY.fe(e),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
212
231
  function renderToString(code, options = {}) {
213
232
  const {
214
233
  renderId = "",
@@ -217,7 +236,7 @@ function renderToString(code, options = {}) {
217
236
  manifest
218
237
  } = options;
219
238
  let scripts = "";
220
- const serializer = createSerializer({
239
+ const serializer = createHydrationSerializer({
221
240
  scopeId: renderId,
222
241
  plugins: options.plugins,
223
242
  onData(script) {
@@ -311,7 +330,7 @@ function renderToStream(code, options = {}) {
311
330
  completed = true;
312
331
  if (firstFlushed) dispose();
313
332
  };
314
- const serializer = createSerializer({
333
+ const serializer = createHydrationSerializer({
315
334
  scopeId: options.renderId,
316
335
  plugins: options.plugins,
317
336
  onData: pushTask,
@@ -1305,7 +1324,9 @@ function Dynamic(props) {
1305
1324
  return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
1306
1325
  }
1307
1326
  function Portal(props) {
1308
- throw new Error("Portal is not supported on the server");
1327
+ const o = solidJs.getOwner();
1328
+ if (o?.id != null) solidJs.getNextChildId(o);
1329
+ return undefined;
1309
1330
  }
1310
1331
 
1311
1332
  Object.defineProperty(exports, "Errored", {
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRenderEffect, createMemo, sharedConfig, createRoot, ssrHandleError, getOwner, runWithOwner, createComponent, omit, getNextChildId, NotReadyError } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, ssrScope as scope, untrack } from 'solid-js';
3
- import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
3
+ import { Serializer, getCrossReferenceHeader, Feature } from 'seroval';
4
4
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
5
5
 
6
6
  const DOMWithState = {
@@ -65,25 +65,32 @@ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, optio
65
65
  } : transparentOptions);
66
66
  const memo = fn => createMemo(() => fn(), syncOptions);
67
67
 
68
- const ES2017FLAG = Feature.AggregateError |
69
- Feature.BigIntTypedArray;
70
- const GLOBAL_IDENTIFIER = "_$HY.r";
71
- function createSerializer({
68
+ const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
69
+ const HYDRATION_GLOBAL = "_$HY.r";
70
+ const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
71
+ CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
72
+ FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin]);
73
+ function resolveSerializerPlugins(customPlugins) {
74
+ return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
75
+ }
76
+ function createSerializer(options) {
77
+ return new Serializer({
78
+ ...options,
79
+ plugins: resolveSerializerPlugins(options.plugins),
80
+ disabledFeatures: options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures
81
+ });
82
+ }
83
+ function createHydrationSerializer({
72
84
  onData,
73
85
  onDone,
74
86
  scopeId,
75
87
  onError,
76
- plugins: customPlugins
88
+ plugins
77
89
  }) {
78
- const defaultPlugins = [AbortSignalPlugin,
79
- CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
80
- FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin];
81
- const allPlugins = customPlugins ? [...customPlugins, ...defaultPlugins] : defaultPlugins;
82
- return new Serializer({
90
+ return createSerializer({
83
91
  scopeId,
84
- plugins: allPlugins,
85
- globalIdentifier: GLOBAL_IDENTIFIER,
86
- disabledFeatures: ES2017FLAG,
92
+ plugins,
93
+ globalIdentifier: HYDRATION_GLOBAL,
87
94
  onData,
88
95
  onDone,
89
96
  onError
@@ -92,6 +99,7 @@ function createSerializer({
92
99
  function getLocalHeaderScript(id) {
93
100
  return getCrossReferenceHeader(id) + ";";
94
101
  }
102
+ Feature.RegExp;
95
103
 
96
104
  function joinAssetPath(base, file) {
97
105
  if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
@@ -123,7 +131,7 @@ function resolveAssets(moduleUrl, manifest) {
123
131
  };
124
132
  }
125
133
  function registerEntryAssets(manifest) {
126
- if (!manifest) return;
134
+ if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
127
135
  const ctx = sharedConfig.context;
128
136
  if (!ctx?.registerAsset) return;
129
137
  for (const key in manifest) {
@@ -204,10 +212,21 @@ function applyAssetTracking(context, tracking, manifest) {
204
212
  });
205
213
  context.registerModule = tracking.registerModule;
206
214
  context.getBoundaryModules = tracking.getBoundaryModules;
207
- if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
215
+ if (typeof manifest === "function") {
216
+ context.resolveAssets = manifest;
217
+ } else if (manifest && typeof manifest.resolve === "function") {
218
+ context.resolveAssets = key => manifest.resolve(key);
219
+ if (typeof manifest.resolveSync === "function") {
220
+ context.resolveAssetsSync = key => manifest.resolveSync(key);
221
+ }
222
+ } else if (manifest) {
223
+ const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
224
+ context.resolveAssets = resolve;
225
+ context.resolveAssetsSync = resolve;
226
+ }
208
227
  }
209
228
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
210
- const REPLACE_SCRIPT = `function $df(e,n,o,t){if(!(n=document.getElementById(e))||!(o=document.getElementById("pl-"+e)))return 0;for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content),n.remove(),_$HY.fe(e);return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return 0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1;return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
229
+ const REPLACE_SCRIPT = `function $df(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content),n.remove(),_$HY.fe(e),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
211
230
  function renderToString(code, options = {}) {
212
231
  const {
213
232
  renderId = "",
@@ -216,7 +235,7 @@ function renderToString(code, options = {}) {
216
235
  manifest
217
236
  } = options;
218
237
  let scripts = "";
219
- const serializer = createSerializer({
238
+ const serializer = createHydrationSerializer({
220
239
  scopeId: renderId,
221
240
  plugins: options.plugins,
222
241
  onData(script) {
@@ -310,7 +329,7 @@ function renderToStream(code, options = {}) {
310
329
  completed = true;
311
330
  if (firstFlushed) dispose();
312
331
  };
313
- const serializer = createSerializer({
332
+ const serializer = createHydrationSerializer({
314
333
  scopeId: options.renderId,
315
334
  plugins: options.plugins,
316
335
  onData: pushTask,
@@ -1304,7 +1323,9 @@ function Dynamic(props) {
1304
1323
  return createComponent(Comp, omit(props, "component"));
1305
1324
  }
1306
1325
  function Portal(props) {
1307
- throw new Error("Portal is not supported on the server");
1326
+ const o = getOwner();
1327
+ if (o?.id != null) getNextChildId(o);
1328
+ return undefined;
1308
1329
  }
1309
1330
 
1310
1331
  export { Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, notSup as getDelegatedRoot, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useAssets };
package/dist/web.cjs CHANGED
@@ -902,8 +902,7 @@ function insertExpression(parent, value, current, marker) {
902
902
  if (tc === "string" || tc === "number") {
903
903
  parent.firstChild.data = value;
904
904
  } else {
905
- const owned = ownedChildCount(current);
906
- if (owned === -1 || owned === parent.childNodes.length) parent.textContent = value;else {
905
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
907
906
  removeOwnedChildren(parent, current);
908
907
  parent.insertBefore(document.createTextNode(value), parent.firstChild);
909
908
  }
@@ -970,11 +969,15 @@ function appendNodes(parent, array, marker = null) {
970
969
  if (marker) n[$$SLOT] = marker;
971
970
  }
972
971
  }
973
- function ownedChildCount(current) {
974
- if (Array.isArray(current)) return current.length;
975
- if (current == null) return -1;
976
- if (current === "") return 0;
977
- return 1;
972
+ function ownsAllChildren(parent, current) {
973
+ if (current == null) return true;
974
+ if (Array.isArray(current)) {
975
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
976
+ }
977
+ if (current === "") return parent.firstChild === null;
978
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
979
+ const first = parent.firstChild;
980
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
978
981
  }
979
982
  function removeOwnedChildren(parent, current) {
980
983
  if (Array.isArray(current)) {
@@ -991,8 +994,7 @@ function removeOwnedChildren(parent, current) {
991
994
  }
992
995
  function cleanChildren(parent, current, marker, replacement) {
993
996
  if (marker === undefined) {
994
- const owned = ownedChildCount(current);
995
- if (owned === -1 || owned === parent.childNodes.length) return parent.textContent = "";
997
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
996
998
  return removeOwnedChildren(parent, current);
997
999
  }
998
1000
  if (current.length) {
@@ -1065,11 +1067,16 @@ const hydrate = (...args) => {
1065
1067
  return hydrate$1(...args);
1066
1068
  };
1067
1069
  function Portal(props) {
1070
+ return solidJs.runWithOwner(solidJs.createOwner(), () => portalImpl(props));
1071
+ }
1072
+ function portalImpl(props) {
1068
1073
  const treeMarker = document.createTextNode(""),
1069
1074
  startMarker = document.createTextNode(""),
1070
1075
  endMarker = document.createTextNode(""),
1071
1076
  mount = () => props.mount || document.body,
1072
- content = solidJs.createMemo(() => [startMarker, props.children]);
1077
+ content = solidJs.createMemo(() => [startMarker, props.children], {
1078
+ ssrSource: "client"
1079
+ });
1073
1080
  solidJs.createRenderEffect(
1074
1081
  () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
1075
1082
  const m = solidJs.untrack(mount);
@@ -1090,8 +1097,10 @@ function Portal(props) {
1090
1097
  c = n;
1091
1098
  }
1092
1099
  };
1093
- }, {
1094
- schedule: true
1100
+ },
1101
+ {
1102
+ schedule: true,
1103
+ ssrSource: "client"
1095
1104
  });
1096
1105
  solidJs.createEffect(mount, () => {
1097
1106
  const m = solidJs.untrack(mount);
@@ -1099,6 +1108,11 @@ function Portal(props) {
1099
1108
  if (!ownerRoot || ownerRoot.contains(m)) return;
1100
1109
  registerDelegatedContainer(m, ownerRoot);
1101
1110
  return () => unregisterDelegatedContainer(m, ownerRoot);
1111
+ }, {
1112
+ ssrSource: "client"
1113
+ });
1114
+ if (solidJs.sharedConfig.hydrating) return solidJs.createMemo(() => treeMarker, {
1115
+ ssrSource: "client"
1102
1116
  });
1103
1117
  return treeMarker;
1104
1118
  }
package/dist/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, getOwner, createEffect, enableHydration, flush } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createOwner, enableHydration, flush, getOwner, createEffect } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
3
3
 
4
4
  const DOMWithState = {
@@ -901,8 +901,7 @@ function insertExpression(parent, value, current, marker) {
901
901
  if (tc === "string" || tc === "number") {
902
902
  parent.firstChild.data = value;
903
903
  } else {
904
- const owned = ownedChildCount(current);
905
- if (owned === -1 || owned === parent.childNodes.length) parent.textContent = value;else {
904
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
906
905
  removeOwnedChildren(parent, current);
907
906
  parent.insertBefore(document.createTextNode(value), parent.firstChild);
908
907
  }
@@ -969,11 +968,15 @@ function appendNodes(parent, array, marker = null) {
969
968
  if (marker) n[$$SLOT] = marker;
970
969
  }
971
970
  }
972
- function ownedChildCount(current) {
973
- if (Array.isArray(current)) return current.length;
974
- if (current == null) return -1;
975
- if (current === "") return 0;
976
- return 1;
971
+ function ownsAllChildren(parent, current) {
972
+ if (current == null) return true;
973
+ if (Array.isArray(current)) {
974
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
975
+ }
976
+ if (current === "") return parent.firstChild === null;
977
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
978
+ const first = parent.firstChild;
979
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
977
980
  }
978
981
  function removeOwnedChildren(parent, current) {
979
982
  if (Array.isArray(current)) {
@@ -990,8 +993,7 @@ function removeOwnedChildren(parent, current) {
990
993
  }
991
994
  function cleanChildren(parent, current, marker, replacement) {
992
995
  if (marker === undefined) {
993
- const owned = ownedChildCount(current);
994
- if (owned === -1 || owned === parent.childNodes.length) return parent.textContent = "";
996
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
995
997
  return removeOwnedChildren(parent, current);
996
998
  }
997
999
  if (current.length) {
@@ -1064,11 +1066,16 @@ const hydrate = (...args) => {
1064
1066
  return hydrate$1(...args);
1065
1067
  };
1066
1068
  function Portal(props) {
1069
+ return runWithOwner(createOwner(), () => portalImpl(props));
1070
+ }
1071
+ function portalImpl(props) {
1067
1072
  const treeMarker = document.createTextNode(""),
1068
1073
  startMarker = document.createTextNode(""),
1069
1074
  endMarker = document.createTextNode(""),
1070
1075
  mount = () => props.mount || document.body,
1071
- content = createMemo(() => [startMarker, props.children]);
1076
+ content = createMemo(() => [startMarker, props.children], {
1077
+ ssrSource: "client"
1078
+ });
1072
1079
  createRenderEffect(
1073
1080
  () => [mount(), content(), getOwner()], ([, c, owner]) => {
1074
1081
  const m = untrack(mount);
@@ -1089,8 +1096,10 @@ function Portal(props) {
1089
1096
  c = n;
1090
1097
  }
1091
1098
  };
1092
- }, {
1093
- schedule: true
1099
+ },
1100
+ {
1101
+ schedule: true,
1102
+ ssrSource: "client"
1094
1103
  });
1095
1104
  createEffect(mount, () => {
1096
1105
  const m = untrack(mount);
@@ -1098,6 +1107,11 @@ function Portal(props) {
1098
1107
  if (!ownerRoot || ownerRoot.contains(m)) return;
1099
1108
  registerDelegatedContainer(m, ownerRoot);
1100
1109
  return () => unregisterDelegatedContainer(m, ownerRoot);
1110
+ }, {
1111
+ ssrSource: "client"
1112
+ });
1113
+ if (sharedConfig.hydrating) return createMemo(() => treeMarker, {
1114
+ ssrSource: "client"
1101
1115
  });
1102
1116
  return treeMarker;
1103
1117
  }