Closed PatrikStenmark closed 2 days ago
Actually we polyfill Intl and Temporal already in the client (the browser's main thread), so it's already available to Space Script: https://github.com/silverbulletmd/silverbullet/blob/main/common/space_script.ts#L12 , what I missed is that this polyfill isn't available in web workers, which plugs run in 🤦🏻
Two possible fixes: also expose this polyfill in plugs code, the other is indeed to fall back to a simpler implementation. I'd have to check how big the polyfill is (because this size would be added to each individual plug JS bundle), but perhaps the fallback you suggest is the more pragmatic solution.
Thinking about this more: let's go with the fallback approach, if you could give that a try I'd much appreciate it!
I'm willing to try. It might take a couple of days though. My computer decided to spontaneously die so I have to wait for a new one.
I just tried to create a function for displaying a relative time and noticed the issue that I cannot use Intl.RelativeTimeFormat
.
It looks like the Intl exported from js-temporal/polyfill exports an Intl
object which only has the DateTimeFormat
. Also it maybe does not polyfill it, but just exports the original one? https://github.com/js-temporal/temporal-polyfill/blob/e1a1452b712dbaddf1fb856b869667510b6768fc/lib/intl.ts#L41
I guess this also causes some of the properties from Intl
to be removed in a space-script
. I get this in the terminal when logging Intl
in a space-script
:
[Object: null prototype] {
DateTimeFormat: [Function: DateTimeFormat] {
supportedLocalesOf: [Function (anonymous)]
}
}
@daniel-michel I think you fixed this since with #836 correct?
Yes
It seems that the changes in 89e2e7a broke Silverbullet running in Firefox, due to the usage of
Intl.Segmenter
. This is only available in Firefox Nightly.Is there any thoughts around browser compatibility?
Would it be a good idea to add a check for
Intl.Segmenter
availability and fall back to just splitting by whitespace and taking the n words before/after the index? I might be able to make a PR for that if that seems like a good idea.