Socket
Socket
Sign inDemoInstall

@astrojs/preact

Package Overview
Dependencies
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astrojs/preact - npm Package Compare versions

Comparing version 3.5.1 to 3.5.2

28

dist/client.js

@@ -12,9 +12,27 @@ import { h, hydrate, render } from "preact";

const { signal } = await import("@preact/signals");
let signals = JSON.parse(element.dataset.preactSignals);
let signals = JSON.parse(
element.dataset.preactSignals
);
for (const [propName, signalId] of Object.entries(signals)) {
if (!sharedSignalMap.has(signalId)) {
const signalValue = signal(props[propName]);
sharedSignalMap.set(signalId, signalValue);
if (Array.isArray(signalId)) {
signalId.forEach(([id, indexOrKeyInProps]) => {
const mapValue = props[propName][indexOrKeyInProps];
let valueOfSignal = mapValue;
if (typeof indexOrKeyInProps !== "string") {
valueOfSignal = mapValue[0];
indexOrKeyInProps = mapValue[1];
}
if (!sharedSignalMap.has(id)) {
const signalValue = signal(valueOfSignal);
sharedSignalMap.set(id, signalValue);
}
props[propName][indexOrKeyInProps] = sharedSignalMap.get(id);
});
} else {
if (!sharedSignalMap.has(signalId)) {
const signalValue = signal(props[propName]);
sharedSignalMap.set(signalId, signalValue);
}
props[propName] = sharedSignalMap.get(signalId);
}
props[propName] = sharedSignalMap.get(signalId);
}

@@ -21,0 +39,0 @@ }

14

dist/server.js

@@ -17,11 +17,9 @@ import { Component as BaseComponent, h } from "preact";

try {
try {
const { html } = await renderToStaticMarkup.call(this, Component, props, children, void 0);
if (typeof html !== "string") {
return false;
}
return html == "" ? false : !/<undefined>/.test(html);
} catch (err) {
const { html } = await renderToStaticMarkup.call(this, Component, props, children, void 0);
if (typeof html !== "string") {
return false;
}
return html == "" ? false : !html.includes("<undefined>");
} catch {
return false;
} finally {

@@ -66,3 +64,3 @@ finishUsingConsoleFilter();

console.error = filteredConsoleError;
} catch (error) {
} catch {
}

@@ -69,0 +67,0 @@ }

@@ -21,13 +21,23 @@ import { incrementId } from "./context.js";

for (const [key, value] of Object.entries(props)) {
if (isSignal(value)) {
const isPropArray = Array.isArray(value);
const isPropObject = !isSignal(value) && typeof props[key] === "object" && !isPropArray;
if (isPropObject || isPropArray) {
const values = isPropObject ? Object.keys(props[key]) : value;
values.forEach((valueKey, valueIndex) => {
const signal = isPropObject ? props[key][valueKey] : valueKey;
if (isSignal(signal)) {
const keyOrIndex = isPropObject ? valueKey.toString() : valueIndex;
props[key] = isPropObject ? Object.assign({}, props[key], { [keyOrIndex]: signal.peek() }) : props[key].map(
(v, i) => i === valueIndex ? [signal.peek(), i] : v
);
const currentMap = map.get(key) || [];
map.set(key, [...currentMap, [signal, keyOrIndex]]);
const currentSignals = signals[key] || [];
signals[key] = [...currentSignals, [getSignalId(ctx, signal), keyOrIndex]];
}
});
} else if (isSignal(value)) {
props[key] = value.peek();
map.set(key, value);
let id;
if (ctx.signals.has(value)) {
id = ctx.signals.get(value);
} else {
id = incrementId(ctx);
ctx.signals.set(value, id);
}
signals[key] = id;
signals[key] = getSignalId(ctx, value);
}

@@ -39,2 +49,10 @@ }

}
function getSignalId(ctx, item) {
let id = ctx.signals.get(item);
if (!id) {
id = incrementId(ctx);
ctx.signals.set(item, id);
}
return id;
}
export {

@@ -41,0 +59,0 @@ restoreSignalsOnProps,

@@ -8,5 +8,8 @@ import type { SSRResult } from 'astro';

};
export type PropNameToSignalMap = Map<string, SignalLike>;
export type ArrayObjectMapping = [string, number | string][];
export type Signals = Record<string, string | ArrayObjectMapping>;
export type SignalToKeyOrIndexMap = [SignalLike, number | string][];
export type PropNameToSignalMap = Map<string, SignalLike | SignalToKeyOrIndexMap>;
export type AstroPreactAttrs = {
['data-preact-signals']?: string;
};
{
"name": "@astrojs/preact",
"description": "Use Preact components within Astro",
"version": "3.5.1",
"version": "3.5.2",
"type": "module",

@@ -33,3 +33,3 @@ "types": "./dist/index.d.ts",

"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.24.7",
"@babel/plugin-transform-react-jsx": "^7.25.2",
"@babel/plugin-transform-react-jsx-development": "^7.24.7",

@@ -39,7 +39,7 @@ "@preact/preset-vite": "2.8.2",

"babel-plugin-transform-hook-names": "^1.0.2",
"preact-render-to-string": "^6.5.5"
"preact-render-to-string": "^6.5.9"
},
"devDependencies": {
"preact": "^10.22.1",
"astro": "4.11.6",
"preact": "^10.23.2",
"astro": "4.14.6",
"astro-scripts": "0.0.14"

@@ -46,0 +46,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc