@electrojs/renderer 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @electrojs/renderer
|
|
2
2
|
|
|
3
|
-
Typed renderer-side runtime for
|
|
3
|
+
Typed renderer-side runtime for ElectroJS applications.
|
|
4
4
|
|
|
5
|
-
`@electrojs/renderer` is the only public entrypoint that renderer code uses to talk to the
|
|
5
|
+
`@electrojs/renderer` is the only public entrypoint that renderer code uses to talk to the ElectroJS runtime. It exposes:
|
|
6
6
|
|
|
7
7
|
- `ElectroRenderer.initialize(...)` — bootstraps the renderer package
|
|
8
8
|
- `bridge` — typed query/command API
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class extends Error{constructor(e,t,n){super(e),this.name=new.target.name,this.code=t,this.context=n,Object.setPrototypeOf(this,new.target.prototype)}},t=class t extends e{static alreadyInitialized(){return new t(`ElectroRenderer.initialize() can only be called once.`,`ELECTRO_RENDERER_ALREADY_INITIALIZED`)}static preloadApiMissing(e){return new t(`
|
|
1
|
+
var e=class extends Error{constructor(e,t,n){super(e),this.name=new.target.name,this.code=t,this.context=n,Object.setPrototypeOf(this,new.target.prototype)}},t=class t extends e{static alreadyInitialized(){return new t(`ElectroRenderer.initialize() can only be called once.`,`ELECTRO_RENDERER_ALREADY_INITIALIZED`)}static preloadApiMissing(e){return new t(`ElectroJS renderer preload API is not available on window.${e}.`,`ELECTRO_RENDERER_PRELOAD_API_MISSING`,{windowKey:e})}},n=class t extends e{static notInitialized(e){return new t(`${e} cannot be used before ElectroRenderer.initialize() has completed.`,`ELECTRO_RENDERER_NOT_INITIALIZED`,{operation:e})}static invalidBridgeNamespaceKey(e){return new t(`Bridge namespace key must be a non-empty string.`,`ELECTRO_RENDERER_INVALID_BRIDGE_NAMESPACE_KEY`,{received:e})}static invalidBridgeMethodKey(e,n){return new t(`Bridge method key for namespace "${e}" must be a non-empty string.`,`ELECTRO_RENDERER_INVALID_BRIDGE_METHOD_KEY`,{namespace:e,received:n})}static invalidSignalKey(e){return new t(`Signal key must be a non-empty string.`,`ELECTRO_RENDERER_INVALID_SIGNAL_KEY`,{received:e})}static invalidSignalHandler(e,n){return new t(`Signal handler for "${String(e)}" must be a function.`,`ELECTRO_RENDERER_INVALID_SIGNAL_HANDLER`,{signalKey:e,receivedType:typeof n})}},r=class t extends e{static invokeFailed(e,n){return new t(`Bridge transport invocation failed for channel "${e}".`,`ELECTRO_RENDERER_TRANSPORT_INVOKE_FAILED`,{channel:e,cause:n})}static subscribeFailed(e,n){return new t(`Signal subscription failed for "${e}".`,`ELECTRO_RENDERER_SIGNAL_SUBSCRIBE_FAILED`,{signalKey:e,cause:n})}};let i;function a(e){i=e}function o(){i=void 0}function s(){if(!i)throw n.notInitialized(`bridge`);return i}function c(e,t){return new Proxy({},{get(r,i){if(typeof i!=`string`||i===`then`)return;let a=i.trim();if(a.length===0)throw n.invalidBridgeMethodKey(t,i);return async(...n)=>e.invoke(`${t}:${a}`,n)},has(e,t){return typeof t==`string`&&t.trim().length>0&&t!==`then`},getOwnPropertyDescriptor(e,t){if(!(typeof t!=`string`||t===`then`||t.trim().length===0))return{configurable:!0,enumerable:!0}}})}function l(e){return new Proxy({},{get(t,r){if(typeof r!=`string`||r===`then`)return;let i=r.trim();if(i.length===0)throw n.invalidBridgeNamespaceKey(r);return c(e,i)},has(e,t){return typeof t==`string`&&t.trim().length>0&&t!==`then`},getOwnPropertyDescriptor(e,t){if(!(typeof t!=`string`||t===`then`||t.trim().length===0))return{configurable:!0,enumerable:!0}}})}var u=class{constructor(e){this.preloadApi=e}async invoke(e,t){try{return await this.preloadApi.invoke(e,t)}catch(t){throw r.invokeFailed(e,t)}}};let d;function f(e){d=e}function p(){d=void 0}function m(){if(!d)throw n.notInitialized(`signals`);return d}var h=class{constructor(e){this.dispose=e,this.unsubscribed=!1}unsubscribe(){this.unsubscribed||(this.unsubscribed=!0,this.dispose())}},g=class{constructor(e){this.preloadApi=e}subscribe(e,t){this.ensureValidHandler(e,t);try{return new h(this.preloadApi.subscribe(e,this.createInternalHandler(t)))}catch(t){throw r.subscribeFailed(e,t)}}once(e,t){this.ensureValidHandler(e,t);try{return new h(this.preloadApi.once(e,this.createInternalHandler(t)))}catch(t){throw r.subscribeFailed(e,t)}}createInternalHandler(e){return t=>{if(t===void 0){e();return}e(t)}}ensureValidHandler(e,t){if(typeof e!=`string`||e.trim().length===0)throw n.invalidSignalKey(e);if(typeof t!=`function`)throw n.invalidSignalHandler(e,t)}},_=class{constructor(){this.initialized=!1,this.initializing=!1}isInitialized(){return this.initialized}isInitializing(){return this.initializing}ensureCanInitialize(){if(this.initialized||this.initializing)throw t.alreadyInitialized()}markInitializing(){this.initializing=!0}markInitialized(){this.initializing=!1,this.initialized=!0}reset(){this.initializing=!1,this.initialized=!1}};const v=`__ELECTRO_RENDERER__`;var y=class{static getPreloadApi(e=window){let n=e[v];if(!n)throw t.preloadApiMissing(v);return n}};const b=new class{constructor(){this.state=new _}async initialize(e){this.state.ensureCanInitialize(),this.state.markInitializing();try{let t=y.getPreloadApi(),n=l(new u(t)),r=new g(t);a(n),f(r),e&&await e(),this.state.markInitialized()}catch(e){throw o(),p(),this.state.reset(),e}}isInitialized(){return this.state.isInitialized()}},x=new Proxy({},{get(e,t){return Reflect.get(s(),t)}}),S={subscribe(e,t){return m().subscribe(e,t)},once(e,t){return m().once(e,t)}};export{b as ElectroRenderer,e as RendererError,t as RendererInitializationError,r as RendererTransportError,n as RendererUsageError,x as bridge,S as signals};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electrojs/renderer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Library for working with the renderer process in @electro",
|
|
5
|
-
"homepage": "https://
|
|
5
|
+
"homepage": "https://electrojs.myraxbyte.dev/",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"publint": "^0.3.18",
|
|
33
33
|
"tsdown": "^0.21.4",
|
|
34
34
|
"vitest": "^4.1.1",
|
|
35
|
-
"@electrojs/config": "1.0.
|
|
35
|
+
"@electrojs/config": "1.0.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@electrojs/config": "
|
|
38
|
+
"@electrojs/config": "1.0.2"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown",
|