Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reboost

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reboost - npm Package Compare versions

Comparing version 0.18.0 to 0.18.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 0.18.1
- Update Hot Reload API
- Support for Hot Reloading in [SveltePlugin](/packages/plugin-svelte/README.md)
## 0.18.0

@@ -2,0 +6,0 @@ - Updated file caching algorithm with better cache invalidation

@@ -0,17 +1,53 @@

declare type AcceptCB = {
/**
* @param module The updated module
*/
(module: any): void;
};
declare type DisposeCB = {
/**
* @param data A object that you can use to pass the data to the updated module
*/
(data: Record<string, any>): void;
};
export declare type Hot = Readonly<{
/** The data passed from the disposal callbacks */
data: Record<string, any>;
/** The id of the module, it can be used as a key to store data about the module */
id: string;
self: Readonly<{
accept(callback: (module: any) => void): void;
dispose(callback: (data: Record<string, any>) => void): void;
decline(): void;
}>;
accept(dependency: string, callback: (module: any) => void): void;
dispose(dependency: string, callback: (data: Record<string, any>) => void): void;
/**
* Sets accept listener for the module itself
* @param callback The callback which will be triggered on module update
*/
accept(callback: AcceptCB): void;
/**
* Sets accept listener for a dependency of the module
* @param dependency Path to the dependency
* @param callback The callback which will be triggered on module update
*/
accept(dependency: string, callback: AcceptCB): void;
/**
* Sets dispose listener for the module itself
* @param callback The callback which will triggered on module disposal
*/
dispose(callback: DisposeCB): void;
/**
* Sets dispose listener for a dependency of the module
* @param dependency Path to the dependency
* @param callback The callback which will triggered on module disposal
*/
dispose(dependency: string, callback: DisposeCB): void;
/** Marks the module itself as not Hot Reload-able */
decline(): void;
/**
* Marks the dependency of the module as not Hot Reload-able
* @param dependency Path to the dependency
*/
decline(dependency: string): void;
/** Invalidates the Hot Reload phase and causes a full page reload */
invalidate(): void;
}>;
export interface HandlerObject {
accept?: (module: any) => void;
dispose?: (data: Record<string, any>) => void;
accept?: AcceptCB;
dispose?: DisposeCB;
}

@@ -18,0 +54,0 @@ export declare type HotMapType = Map<string, {

85

dist/browser/hot.js

@@ -20,6 +20,6 @@ let Hot_Map;

};
const resolveDependency = async (dependency) => {
const resolveDependency = async (dependency, fnName) => {
const response = await fetch(`${address}/resolve?from=${filePath}&to=${dependency}`);
if (!response.ok) {
console.error(`[reboost] Unable to resolve dependency "${dependency}" of "${filePath}" while using hot.accept()`);
console.error(`[reboost] Unable to resolve dependency "${dependency}" of "${filePath}" while using hot.${fnName}()`);
return 'UNRESOLVED';

@@ -29,2 +29,20 @@ }

};
const makeSetCallbackFn = (type) => {
return async (a, b) => {
let dependencyFilePath;
let callback;
if (typeof a === 'function') {
// Self
dependencyFilePath = filePath;
callback = a;
}
else {
dependencyFilePath = await resolveDependency(a, type);
callback = b;
}
const listenerData = getListenerFileData(dependencyFilePath, filePath);
if (!listenerData[type])
listenerData[type] = callback;
};
};
const hot = {

@@ -36,47 +54,28 @@ get data() {

id: filePath,
self: {
accept(callback) {
const listenerData = getListenerFileData(filePath, filePath);
if (!listenerData.accept)
listenerData.accept = callback;
accept: makeSetCallbackFn('accept'),
dispose: makeSetCallbackFn('dispose'),
decline: async (dependency) => {
getEmitterFileData(dependency || await resolveDependency(dependency, 'decline')).declined = true;
},
invalidate: () => Reboost.reload()
};
// TODO: Remove these in v1.0
{
Object.defineProperties(hot, {
selfAccept: {
value: hot.accept
},
dispose(callback) {
const listenerData = getListenerFileData(filePath, filePath);
if (!listenerData.dispose)
listenerData.dispose = callback;
selfDispose: {
value: hot.dispose
},
decline() {
getEmitterFileData(filePath).declined = true;
self: {
value: {
accept: hot.accept,
dispose: hot.dispose
}
}
},
async accept(dependency, callback) {
const listenerData = getListenerFileData(await resolveDependency(dependency), filePath);
if (!listenerData.accept)
listenerData.accept = callback;
},
async dispose(dependency, callback) {
const listenerData = getListenerFileData(await resolveDependency(dependency), filePath);
if (!listenerData.dispose)
listenerData.dispose = callback;
},
async decline(dependency) {
getEmitterFileData(await resolveDependency(dependency)).declined = true;
},
invalidate() {
Reboost.reload();
}
};
// TODO: Remove it in v1.0
Object.defineProperties(hot, {
selfAccept: {
enumerable: false,
value: hot.self.accept
},
selfDispose: {
enumerable: false,
value: hot.self.dispose
}
});
Object.freeze(hot.self);
});
Object.freeze(hot.self);
}
Object.freeze(hot);
export { hot };
{
"name": "reboost",
"version": "0.18.0",
"version": "0.18.1",
"description": "A super fast dev server for rapid web development",

@@ -90,3 +90,3 @@ "main": "./dist/node/index.js",

},
"gitHead": "89dd8e115b8ba36289485b3b7a941d68cf4f24f9"
"gitHead": "80dc6186e84a9dbd9979d7b376765614089dec6a"
}

@@ -86,3 +86,3 @@ <p align="center">

- [Solid](/docs/recipes.md#solid)
- [Svelte](/docs/recipes.md#svelte)
- [Svelte (with Hot Reloading)](/docs/recipes.md#svelte)
- [TSX](/docs/recipes.md#tsx)

@@ -89,0 +89,0 @@ - [TypeScript](/docs/recipes.md#typescript)

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