PlasmoHQ / plasmo

🧩 The Browser Extension Framework
https://www.plasmo.com
MIT License
10.18k stars 352 forks source link

[RFC] Officially Support Safari target #233

Open louisgv opened 1 year ago

louisgv commented 1 year ago

How do you envision this feature/change to look/work like?

When specifying --target=safari-mv3, it should spit out an actual XCode project suitable to be used on Safari

What is the purpose of this change/feature? Why?

Without freedom of choice there is no creativity

(OPTIONAL) Example implementations

No response

(OPTIONAL) Contact Details

No response

Verify canary release

Code of Conduct

louisgv commented 1 year ago

https://developer.apple.com/documentation/safariservices/safari_web_extensions/developing_a_safari_web_extension

louisgv commented 1 year ago

@ColdSauce according to their sample example - there's a layer of native messaging with the host browser which is interesting. Tho, for the shake of brevity, I wonder how much can we reduce from their example to have the popup sample extension working in Safari?

tyn1998 commented 1 year ago

really looking forward to this wonderful feature!

wangrongding commented 1 year ago

really looking forward to this wonderful feature! +1🤖

process1024 commented 1 year ago

I have successfully converted plasmo extension to safari, change the egines config of parcel to "IE 11", build mv2 and then use safari-web-extension-converter, then it works, see this pr337

louisgv commented 1 year ago

@process1024 AFAIK, the safari converter uses the old MV2 format which is largely deprecated. The latest Safari webkit version support MV3. We should head there eventually imo, but the stop-gaps solution should help extension to move to safari with the provided converter

g-sam commented 1 year ago

Having gone through the Safarification process, I don't think Plasmo should include generation of the xcode project in it's build. There are various reasons developers might want control over the xcode project (e.g. altering the native app to display a different message) and it's faster if the project is already there. For an MVP all Plasmo needs to do I think is trigger a custom command after repacking in dev to compile and install the xcode project. It would probably help people to document the required xcode commands as they are poorly documented by apple.

Plasmo could perhaps take care of the one-off generation of the xcode project and modify the default output in some useful ways. Main modifications I found useful: (a) create separate xcode targets for Dev and prod and mv2 and mv3, (b) replace the bundle resources build step with a run script which copies the files from the relevant plasmo build directory, which avoids the need to manually manage resources in the xcode project.

Now if Plasmo could work out a way to update the resources in the installed app package on the fly from the dev server, that would be amazing - no need to recompile/install if the native parts haven't changed.

spookyuser commented 7 months ago

Another issue i just noticed is that web workers in safari don't work with plasmo, well parcel.

Parcel seems to do this thing where it throws an error to find the bundle url:

https://github.com/parcel-bundler/parcel/blob/2215d360dc531ec46c112223763404650b0a8be1/packages/runtimes/js/src/helpers/bundle-url.js#L15

Which in safari just results in webkit-masked-url://hidden/ (https://bugs.webkit.org/show_bug.cgi?id=246010)

morganwu277 commented 5 months ago

url importurl:/xxxx still have issues for content scripts in safari target

tnagss commented 1 month ago

url importurl:/xxxx still have issues for content scripts in safari target

is there any workaround available for safari?

naan commented 1 month ago

url importurl:/xxxx still have issues for content scripts in safari target

is there any workaround available for safari?

I have the same problem, and I used data-text or data-base64 for loading stylesheets and images.