
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
French for Myopia
Noun
- the quality of being short-sighted
- lack of foresight.
I thought would be a perfect name for a skinned, simplified, alternative to Vue (with some code ripped from ReefJS).
In browser:
<script type="module">
import Myopie from 'https://cdn.jsdelivr.net/gh/StefanoBalocco/myopie.js/myopie.min.js';
...
</script>
In node:
import Myopie from 'myopie.js';
...
new Myopie(document, target, renderFunction, initialState = {}, bindings = [], debounce = 1000)You can create a Myopie instance by calling its constructor:
const myopie = new Myopie(
document,
'#app', // Target selector
(data) => `<div>Hello, ${data.name}!</div>`, // Render function
{ name: 'World' }, // Initial state
[['input', 'name']], // Input bindings
500 // Debounce time in milliseconds
);
document (object): The document object.target (string): Selector for the root element.renderFunction (function): Function returning the HTML string to render.initialState (object): Initial state data.bindings (array): List of input bindings in the format [selector, path].debounce (number): Debounce time in milliseconds for updates.render()Manually triggers the rendering of the DOM. Return false if the target selector is missing, true otherwise.
myopie.render();
renderDebounce()If debounce is greater than zero, set a timer for the next render; otherwise call the render.
myopie.renderDebounce();
destroy()Removes all event listeners (input bindings and permanent handlers) and clears timers.
myopie.destroy();
get(path)Gets the value of a property from the state.
path (string): Slash-separated path to the property.const name = myopie.get('name');
set(path, value, render = true)Sets a property in the state and optionally triggers a re-render.
path (string): Slash-separated path to the property.value: New value to set.render (boolean): Whether to trigger a render after setting.myopie.set('name', 'World');
handlersPermanentAdd(selector, event, listener)Register a permanent event listener for elements matching selector. Returns false if an identical listener was already added.
const handler = (e) => { myopie.set( 'name', 'Foo' ) };
myopie.handlersPermanentAdd('input[name="foo"]', 'click', handler );
handlersPermanentDel(selector, event?, listener?)Remove permanent handlers. If event and optionally also the listener provided, removes matching ones; otherwise clears all for that selector.
myopie.handlersPermanentDel('input[name="foo"]', 'click', handler );
myopie.handlersPermanentDel('input[name="foo"]', 'click' );
myopie.handlersPermanentDel('input[name="foo"]' );
Myopie provides several lifecycle hooks that allow you to inject custom behavior at specific points during the component's initialization and rendering process. These hooks are executed with specific parameters based on the type of hook.
hooksInitAddPre( hookFunction )Executed before the component is rendered the first time. Receives the current state data as a parameter.
myopie.HooksInitAddPre((dataCurrent) => {
console.log('This runs before initialization.', dataCurrent);
});
hooksInitAddPost( hookFunction )Executed after the component is rendered the first time. Receives the current state data as a parameter.
myopie.HooksInitAddPost((dataCurrent) => {
console.log('This runs after initialization.', dataCurrent);
});
hooksRenderAddPre( hookFunction )Executed before the component renders after the first time. Receives the current and previous state data arrays as parameters.
myopie.HooksRenderAddPre((dataCurrent, dataPrevious) => {
console.log('This runs before rendering.', dataCurrent, dataPrevious);
});
hooksRenderAddPost( hookFunction )Executed after the component renders after the first time. Receives the current and previous state data arrays as parameters.
myopie.HooksRenderAddPost((dataCurrent, dataPrevious) => {
console.log('This runs after rendering.', dataCurrent, dataPrevious);
});
<div id="app"></div>
<script type="module">
import Myopie from 'https://cdn.jsdelivr.net/gh/StefanoBalocco/myopie.js/myopie.min.js';
const myopie = new Myopie(
'#app',
(data) => `<div>
<input type="text" value="${data.name}" />
<p>Hello, ${data.name}!</p>
</div>`,
{ name: 'World' },
[['input', 'name']]
);
// Update the name dynamically
setTimeout(() => myopie.set('name', 'User'), 2000);
</script>
Contributions are welcome! Please submit issues or pull requests on the GitHub repository.
Myopie is released under the BSD-3-Clause License.
FAQs
View in MVC, but without foresight
We found that myopie.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.