Skip to content

Commit

Permalink
Update to seroval 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Nov 22, 2023
1 parent 1c11da4 commit c151285
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/dom-expressions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
},
"peerDependencies": {
"csstype": "^3.0",
"seroval": "^0.13.2"
"seroval": "^0.14.0"
},
"devDependencies": {
"babel-plugin-jsx-dom-expressions": "^0.37.8",
"csstype": "^3.1",
"seroval": "^0.13.2"
"seroval": "^0.14.0"
}
}
6 changes: 1 addition & 5 deletions packages/dom-expressions/src/serializer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Feature, GLOBAL_CONTEXT_API_SCRIPT, Serializer, getCrossReferenceHeader } from "seroval"
import { Feature, Serializer, getCrossReferenceHeader } from "seroval"

const ES2017FLAG =
Feature.AggregateError // ES2021
Expand All @@ -18,10 +18,6 @@ export function createSerializer({ onData, onDone, scopeId, onError }) {
});
}

export function getGlobalHeaderScript() {
return GLOBAL_CONTEXT_API_SCRIPT;
}

export function getLocalHeaderScript(id) {
return getCrossReferenceHeader(id);
}
4 changes: 2 additions & 2 deletions packages/dom-expressions/src/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Aliases, BooleanAttributes, ChildProperties } from "./constants";
import { sharedConfig, root } from "rxcore";
import { createSerializer, getGlobalHeaderScript, getLocalHeaderScript } from "./serializer";
import { createSerializer, getLocalHeaderScript } from "./serializer";
export { createComponent } from "rxcore";

// Based on https://github.com/WebReflection/domtagger/blob/master/esm/sanitizer.js
Expand Down Expand Up @@ -485,7 +485,7 @@ export function generateHydrationScript({ eventNames = ["click", "input"], nonce
nonce ? ` nonce="${nonce}"` : ""
}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join(
'", "'
)}"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});${getGlobalHeaderScript()}</script><!--xs-->`;
)}"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
}

export function Hydration(props) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dom-expressions/test/ssr/ssr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ globalThis.TextEncoder = function () {

const fixture = `<div data-hk="0" id="main" data-id="12" aria-role="button" class="static selected" checked style="color:red" ><h1 custom-attr="1" disabled title="Hello John" style="background-color:red" class="selected"><a href="/">Welcome</a></h1></div>`;
const fixture2 = `<span data-hk="0" class="Hello John" > Hello &lt;div/> </span>`;
const fixture3 = `<span> Hello &lt;div/><script nonce=\"1a2s3d4f5g\">window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute(\"data-hk\")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));[\"click\", \"input\"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});self._$=self._$||{P:function(s,f,p){return(p=new Promise(function(a,b){s=a,f=b})).s=s,p.f=f,p},uP:function(p){delete p.s;delete p.f},Ps:function(p,d){p.s(d),p.status=\"success\",p.value=d,this.uP(p)},Pf:function(p,d){p.f(d),p.status=\"failure\",p.value=d,this.uP(p)},uS:function(s){delete s.c},Sc:function(s){s.c.close(),this.uS(s)},St:function(s,e){s.c.error(e),this.uS(s)},Se:function(s,d){s.c.enqueue(d)},S:function(s,c){return(s=new ReadableStream({start:function(x){c=x}})).c=c,s}}</script><!--xs--><link rel=\"modulepreload\" href=\"chunk.js\"></span>`;
const fixture3 = `<span> Hello &lt;div/><script nonce=\"1a2s3d4f5g\">window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute(\"data-hk\")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));[\"click\", \"input\"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs--><link rel=\"modulepreload\" href=\"chunk.js\"></span>`;
const fixture4 = `<span > Hello &lt;div/> </span>`;

const Comp1 = () => {
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c151285

Please sign in to comment.