If you have to extend an existing object with additional property, always prefer Vue.set()
over Object.assign()
(or spread operator).
Example below explains implications for different implementations.
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Single File Web Component</title> | |
<style> | |
body { | |
background-color: #eee; | |
font-family: Helvetica, sans-serif; | |
} |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Single File Web Component</title> | |
</head> | |
<body> | |
<template id=single-file> | |
<style> | |
h1 { |
import * as THREE from 'three' | |
import { Suspense, useRef, useState } from 'react' | |
import { Canvas, createPortal, applyProps, useFrame, useThree } from '@react-three/fiber' | |
import { useFBO, PerspectiveCamera, ScrollControls, Scroll, useScroll, Image } from '@react-three/drei' | |
function Images() { | |
const { width, height } = useThree(state => state.viewport) | |
const data = useScroll() | |
const group = useRef() | |
useFrame(() => { |
<script lang="ts"> | |
import { defineComponent, onMounted, PropType, ref, watch } from "vue"; | |
type VoidFunction = () => void; | |
const isBrowser = () => { | |
return typeof window === "object"; | |
}; | |
export default defineComponent({ | |
props: { |
// This is a super basic way of mapping Vue props to argTypes in cases | |
// where Storybook (or rather vue-docgen-api) fails. | |
// See https://github.com/storybookjs/storybook/issues/11774 | |
const toType = ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() | |
const controlTypeMappings = { | |
String: 'text', | |
Boolean: 'boolean', | |
Array: 'object', |
/** | |
@func | |
log how long it takes to run a block of code | |
- for a supplied number of times | |
@warning | |
the supplied func runs in a loop | |
- so first make sure there are no log statements in the func | |
- either comment them out, or replace them with lMock... | |
- const l = s => undefined; //lMock |
// ------------------------------------------- IMPORTANT ------------------------------------------- | |
// This is a development file to be minified using https://javascript-minifier.com/ and inlined in | |
// the index.html file. This file is not compiled or processed by webpack so it should be treated as | |
// low-level precompiled es5-compatible javascript. The code here is not meant to be clean, it's | |
// meant to be as light and fast as possible since it runs in the head tag. | |
// HACK: This file a hack to ensure that home-screen apps on mobile devices gets refreshed when they | |
// start. It works by forcing a load of the service-worker.js file and use the precache-manifest | |
// file name as an application version, just like a desktop browser like chrome would do. When | |
// when it detects a change in the application version, it reloads the page and bypass the browser's |
lys is a programming language that produces WASM, and its design goal is to be as simple as possible, yet useful to create utilities.
I've been thinking about a subset of JavaScript that could run natively on the browser, similarly to asm.js, but with the ability, through a dedicated parser, to target another language able, on its own, to produce WASM.
The following crazy non sense works already thanks to an agglomerated of modern and deprecated JS features and it might be interesting as experiment to see if a JS to WASM compiler, through the lys indirection, could be possible.
function lys(fn) {
/*! (c) Andrea Giammarchi */
<template> | |
<div> | |
<slot/> | |
</div> | |
</template> | |
<script> | |
// @ts-check | |
/** |