@sarcio/angular
v0.2.0
Published
Makes an Angular app fixable by Sarcio: approved code fixes take effect in the running page, without a deploy.
Readme
@sarcio/angular
Makes an Angular app fixable by Sarcio: an approved code fix takes effect in the running page, without a deploy.
Setup guides and the full reference are in the Sarcio docs.
Build
npm install --save-dev @sarcio/angularAdd the esbuild plugin to your Angular application build (it requires
metafile: true):
import { sarcioAngularEsbuildPlugin } from '@sarcio/angular';
plugins: [
sarcioAngularEsbuildPlugin({ outDir: 'dist/app', autoRegister: true })
];| Option | Default | Meaning |
| ---------------------- | -------------------------- | ----------------------------------------- |
| outDir | esbuild outdir | Your build output folder |
| manifestFileName | .sarcio/manifest.json | Where the build summary is written |
| include | all .js | Limit which output files are covered |
| autoRegister | false | Also emit the registration module (below) |
| autoRegisterFileName | .sarcio/auto-register.js | Path of that module |
Runtime
// main.ts (once):
import './.sarcio/auto-register.js';
import {
connectSarcioAngular,
createRecreateApplier,
sarcioCreateComponent,
SarcioHostRegistry
} from '@sarcio/angular/runtime';
const registry = new SarcioHostRegistry();
connectSarcioAngular({
wsUrl,
apiBase,
siteKey,
applier: createRecreateApplier({
registry,
// Fields that must not be carried over, such as live subscriptions.
ignoreState: ['subscription']
})
});
// Wherever you create a component dynamically, instead of vcr.createComponent:
const ref = sarcioCreateComponent(viewContainerRef, CartComponent, registry);When a fix arrives, the affected component is re-created and its fields,
including @Input values, are carried over for you; its constructor runs
again. This applies to dynamically created components
(ViewContainerRef.createComponent, ngComponentOutlet). Anything else falls
back to a page reload, which is always correct. You can also register a
component by hand with registry.register(...).
Security
Every fix is cryptographically signed, and the runtime verifies that signature against your workspace's key before it applies anything.
License
Business Source License 1.1: production use to connect your own applications to a Sarcio subscription or trial is granted; offering a competing service is not. Each version converts to Apache-2.0 four years after its release.
