TypeScript

toxi,
@toxi@mastodon.thi.ng avatar

Example #167, and the very first example showing basic usage of the new https://thi.ng/geom-webgl interop package (still unreleased): Parsing a SVG path, sampling it with uniform vertex density (configurable), converting it into a complex polygon (w/ holes) and then into WebGL buffers (w/ vertex color option enabled), randomizing colors via probabilistic color theme, and — finally — drawing it all...

Demo (reload for new variation):
https://demo.thi.ng/umbrella/geom-webgl-basics/

Source code:
https://github.com/thi-ng/umbrella/blob/develop/examples/geom-webgl-basics/src/index.ts

#ThingUmbrella #WebGL #SVG #Geometry #Tessellation #Triangulation #DebugArt #TypeScript #Typography #Polygon
#ThingUmbrella

toxi,
@toxi@mastodon.thi.ng avatar

Btw. More background details about this ongoing work in this thread: https://mastodon.thi.ng/@toxi/112564848531261742

toxi,
@toxi@mastodon.thi.ng avatar

Testing/debugging the dynamic tessellation feature of the upcoming thi.ng/geom-webgl interop package... This will provide a single polymorphic function to convert https://thi.ng/geom shapes into WebGL binary data & model/attribute specs, with lots of options for memory layout, indexing, instancing and other advanced usage...

By default (and as shown here), polygons are tessellated via ear cutting[1], but users have a choice of 9 other algorithm presets (or their own custom ones), incl. iterative application of multiple tessellation strategies..

[1] https://en.wikipedia.org/wiki/Polygon_triangulation

A random, blobby, triangulated polygon, with each triangle tinted in a random colorful gradient
A random, blobby, triangulated polygon, with each triangle tinted in a random colorful gradient
A random, blobby, triangulated polygon, with each triangle tinted in a random colorful gradient

toxi,
@toxi@mastodon.thi.ng avatar
toxi,
@toxi@mastodon.thi.ng avatar

As part of the work on the upcoming thi.ng/geom-webgl package, today I've also been completely rewriting all tessellators in https://thi.ng/geom-tessellate and extending the package with more features, incl. an adapted version of https://github.com/mapbox/earcut to handle complex polygons (with holes, but can also be combined/nested with all the other tessellators, incl. the non-triangular ones)...

Instead of producing an array of faces (each itself an vertex array), all tessellators are now producing/populating/adding to a single tessellation, consisting of a vertex array and another array of face vertex IDs. This makes the result much more flexible for a number of use cases, incl. WebGL/WebGPU conversion.

Very happy with how the new API for both packages is turning out. The last image shows the source code for generating a single frame of the "SB" anim, starting with parsing two SVG paths, grouping & fitting them into a target bounding rect, then tessellating the entire group, rebuilding a new group from the resulting triangles, and finally serializing everything to SVG. For WebGL, there'll be a single asWebGLModel() function which performs shape tessellation automatically behind the scenes (fully configurable, though)...

The letter "B" tessellated into dozens of triangles, each tinted with a randon, iridescent, rainbow colored gradient
TypeScript source code snippet to create a single frame of the anim in the previous image: // create paths/shapes from SVG definitions (truncated here) const S = pathFromSvg(

Animated GIF of the letters "SB" tessellated into dozens/hundreds of pink triangles with black wireframes

toxi,
@toxi@mastodon.thi.ng avatar

Added a convolution kernel filtering operator for polygons/polylines to https://thi.ng/geom, incl. some useful preset kernels: box filter, triangle, gaussian, all with configurable size...

The image shows effects of various kernel sizes & iterations. Unlike with subdivision smoothing, here each version has the exact same number of vertices, only their positions are impacted: orange = box, magenta = triangle, blue = gaussian

(For now the operator is only implemented for polygons (also w/ holes) & polylines, but can be extended to other shape types...)

#ThingUmbrella #Geometry #Polygon #Curve #Convolution #Gaussian #TypeScript

jbzfn,
@jbzfn@mastodon.social avatar

🦾 Functional TypeScript #1: Algebraic Data Types | Injuly

"In functional programming, algebraic types are so ubiquitous that you would be hard pressed to find a language that doesn't support them. Strangely though, nothing about them demands that a language be functional by paradigm. That imperative languages have avoided ADTs for decades seems almost an accident."

https://injuly.in/blog/ts-adt/

toxi, (edited )
@toxi@mastodon.thi.ng avatar

Useful snippet for computing pixel dimensions from paper sizes (both metric (DIN) and (US) imperial presets included) using https://thi.ng/units, an elaborate & powerful unit converter/calculator/DSL for all SI dimensions:

Full list of predefined constants:
https://github.com/thi-ng/umbrella/tree/develop/packages/units#constants

#ThingUmbrella #Units #Conversion #TypeScript #JavaScript

nclslbrn,
@nclslbrn@mstdn.io avatar

@toxi Great, I saw that another package could do this, glad to see that thi.ng/umbrella already does.

toxi,
@toxi@mastodon.thi.ng avatar

@nclslbrn Yeah, it's one of the more unknown packages in the collection, but I'm finding myself using it much more often than I thought I would initially... :)

ohmrun,
@ohmrun@hachyderm.io avatar

still has a better type system than , soz.

tanepiper,
@tanepiper@tane.codes avatar

@ohmrun I loved working with Haxe back in the day - it's a shame it never quite took off the same way

chriskrycho,
@chriskrycho@mastodon.social avatar

The first of my two talks—this one, born out of my experiences with versioning and and over the past 7 years. Script and slides now, video once it’s up! https://v5.chriskrycho.com/elsewhere/cutting-edge-of-versioning/

toxi,
@toxi@mastodon.thi.ng avatar

Still only on a feature branch, but over the past few days I've been working on updating https://thi.ng/geom to add support for polygons with holes and paths with holes (or more generally support for sub-paths, e.g. multiple curves). Since both of these shape types are containers of multiple geometries and therefore require in some situations (e.g. shape conversions) different handling than the other shapes with a single boundary/geometry, adding support for these also includes updating a dozen or so polymorphic shape operators/functions and unfortunately will involve a few of breaking changes. For instance, some of these functions are returning an array of shapes now, instead of just a single one. Also related, some of the other geom support packages (e.g. https://thi.ng/geom-axidraw, https://thi.ng/geom-sdf) will have to be refactored more and partially have been already (likely only internally, though)...

As part of this work, I've also just added example (!!!) to demonstrate & test out some of this new functionality:

Demo:
https://demo.thi.ng/umbrella/geom-complex-poly/

Source:
https://github.com/thi-ng/umbrella/blob/feature/geom-complex-paths/examples/geom-complex-poly/src/index.ts

Commits:
https://github.com/thi-ng/umbrella/compare/feature/geom-complex-paths

I will of course send another update once this all has been merged & released...

casraf,
hongminhee,
@hongminhee@todon.eu avatar

Should I rewrite in a programming language other than ? 😅

https://todon.eu/@hongminhee/112359155272283786

hongminhee,
@hongminhee@todon.eu avatar

@thisismissem When you say ESM builds, do you mean do the Fedify package published to npm support ESM? If that's what you mean, then yes, it does.

I'm constantly improving the documentation, but it's not easy (especially writing in English as a non-native English speaker). 😅

thisismissem,
@thisismissem@hachyderm.io avatar

@hongminhee perhaps that's an area to get beginners involved? Documentation can help people learn the framework & find flaws/rough edges in it.

davidbisset,
@davidbisset@phpc.social avatar

Extension.js: a plug-and-play, zero-config, cross-browser extension development tool with built-in support for #TypeScript, #WebAssembly, React, and modern #JavaScript.

https://github.com/cezaraugusto/extension.js #opensource

alexelcu,
@alexelcu@social.alexn.org avatar

Async/await in is essentially “direct style”. It will be interesting to see if Effect, a monadic effect system, will take off, as a case study for & — although for “direct style”, these have the advantage of context parameters.

https://effect.website

Profpatsch,
@Profpatsch@mastodon.xyz avatar

Okay, so

After spending some time with , going back to is a real hard sell, ngl

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

@Profpatsch Oof, pass. I got really stoked around typescript for a little while, but they stopped maintaining the spec, and these days I greatly prefer #Purescript if I have to target a browser and have a choice. (It doesn't have a spec either, but I find it a much nicer language.)

At work, we still just do JS, but that's because it's likely to come out of a julius splice from #Yesod.

hongminhee,
@hongminhee@todon.eu avatar

My short yak shaving journey is over. Lacking a decent logging library, so I created #LogTape and started logging in #Fedify using it, which should make inbox/outbox debugging easier starting with Fedify 0.7.0. ✌️

https://unstable.fedify.dev/manual/log

#fedidev #TypeScript

thisismissem,
@thisismissem@hachyderm.io avatar

@hongminhee mildly curious why a well established package like pino (or winston) didn't meet your needs?

davidbisset,
@davidbisset@phpc.social avatar

Pragmatic drag and drop lib that can be used with any view layer (react, svelte, vue, angular and so on).

Powers Trello, Jira and Confluence.

https://github.com/atlassian/pragmatic-drag-and-drop

aeveltstra,
@aeveltstra@mastodon.social avatar

Hey, #typescript devs: is there any way to compile typescript without needing NPM and Node?

Microsoft’s documentation says the easiest way to install tcl is by using NPM. That means they aren’t saying it’s the only way. But it also lacks mention of other ways.

I’m not adverse to building tcl myself if needed, or use different methods for different operating systems.

Please advise!

aeveltstra,
@aeveltstra@mastodon.social avatar

@lukem Thank you, I’ll check it out.

aeveltstra,
@aeveltstra@mastodon.social avatar

@castarco Thank you!

toxi,
@toxi@mastodon.thi.ng avatar

For @made and others who might have questions about the new https://thi.ng/transducers-async library, I've tried to illuminate the behind-the-scenes approach over here:

https://github.com/thi-ng/umbrella/discussions/461#discussioncomment-9102966

alxd,
@alxd@writing.exchange avatar

Time for a post!

I'm looking for a / / 100% position, both contract and permanent, GMT+2 timezone.

I previously worked as a Senior / Lead / Principal developer with , and experience.

I specialize in , , , , , , , , and .

https://www.linkedin.com/in/paul-ngei/

schizanon,
@schizanon@mastodon.social avatar
louisrcouture,
@louisrcouture@jasette.facil.services avatar

@schizanon typescript is cool but it's annoying sometimes

schizanon,
@schizanon@mastodon.social avatar

@louisrcouture typescript is fine as long as I can //@ts it. It's the people who insist that everyone use it that get on my nerves. the extensions you use in your IDE are between you and your god. Don't foist a transpiler on your teammates just to do some fancy linting.

julian,
@julian@fietkau.social avatar

What am I doing this weekend? Learning , , and @hongminhee's all at the same time, for a project which I'm hoping will be used by many people.

What could possibly go wrong? 💪

box464,
@box464@mastodon.social avatar

@julian when you need a tester, holler. 📝

calisti,
@calisti@chaos.social avatar

TailwindCSS is looking to hire a perfectionist staff software engineer, fully remote, ET - CET timezones, 275‘000 USD.

https://tailwindcss.com/careers/staff-software-engineer

#FediHire #TypeScript #RustLang #NodeJS #React #a11y #TailwindCSS

toxi,
@toxi@mastodon.thi.ng avatar

Earlier today[1], helped my son with a raycasting issue and then ended up updating/extending the 2D shape intersection function in https://thi.ng/geom, which now also supports ray intersections with nested shape groups/hierarchies (via same single function call) and a new option to return all intersection points found (rather than just the first/closest). Both of these features are shown in a new example project (forthcoming) and in the anim below...

#2D #Geometry #Shapes #Intersection #RayCasting #ThingUmbrella #TypeScript #JavaScript

[1] It also was the first day of the year for us working outside on a bench in the woods, yay!

2D line art animation showing some shapes (rectangles, circles, hexagon, wavy polyline...) and a line/ray rotating anti-clockwise. The intersection points between that ray and the static shapes are highlighted as pink dots. Each dot also has a label showing the distance from the ray origin (center of image). Depending on the angle and shapes intersected, the number of intersections varies (max. approx. 10 points)

toxi,
@toxi@mastodon.thi.ng avatar
rauschma,
@rauschma@fosstodon.org avatar

1/ #TypeScript: Common approach for validating untyped data—e.g. Zod: https://2ality.com/2020/06/validating-data-typescript.html
– Encode type via runtime data (“schema”).
– Schema is converted to static type for type-checking.

New approach—Typia. https://typia.io/docs/setup/
– Compile static type to (runtime) validation code.
– Downside: Tools don’t work that strip out types and run result.

Rust does latter approach well. For TS, I prefer former.

reconbot,
@reconbot@toot.cafe avatar

@rauschma I love zod and found https://valibot.dev which is zod but functional instead of chaining (and smaller bundle size?)

brawaru,
@brawaru@mstdn.social avatar

@reconbot I have tried Valibot in the past and it was a pain to write, it very quickly turns into a parentheses hell and Prettier doesn't help it... chaining is a lot more convenient :sad_dog:

That said though, I have honestly completely gave up on those libraries, because they are either pain to set up, or like Zod, completely tank TypeScript's performance doing black magic with types. Perhaps things weren't meant to be strictly validated and writing a custom validator is enough.

@rauschma

joshhunt,
@joshhunt@hachyderm.io avatar

Inspired by a recent conversation, I wrote down my thoughts on why Typescript's user-defined type guards are still not safe, and a few alternatives

https://joshhunt.dev/posts/typescripts-user-defined-type-guards-are-not-safe

#typescript #frontend #blog

joshhunt,
@joshhunt@hachyderm.io avatar

I'm trying the whole "lets blog" thing that seems to be in vogue now to get better at writing things longer than a single reddit comment. Open to feedback (be kind 🥺) on my writing :)

joshhunt,
@joshhunt@hachyderm.io avatar

I posted this on reddit and they didn't like it 😭

schizanon,

Typescript is just JavaScript for people who hate freedom.

Agree?

atzanteol,
@atzanteol@techhub.social avatar

@schizanon
Not at all. In computing, however, types are not subjective. JavaScript won't let you add items to an int. Or do math with an Object. You have types. It's just "someone else's problem" to figure out which type it is.

schizanon,

@atzanteol my tests tell me when I have type errors

  • All
  • Subscribed
  • Moderated
  • Favorites
  • typescript
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • JUstTest
  • tacticalgear
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • ethstaker
  • anitta
  • provamag3
  • Leos
  • cisconetworking
  • megavids
  • lostlight
  • All magazines