├── uniqueId ├── pwa ├── files │ └── assets │ │ ├── icons │ │ ├── icon-72x72.png │ │ ├── icon-96x96.png │ │ ├── icon-128x128.png │ │ ├── icon-144x144.png │ │ ├── icon-152x152.png │ │ ├── icon-192x192.png │ │ ├── icon-384x384.png │ │ └── icon-512x512.png │ │ └── manifest.webmanifest ├── schema.js.map ├── schema.js ├── index.d.ts ├── schema.d.ts ├── schema.json ├── index.js.map └── index.js ├── collection.json ├── LICENSE ├── package.json └── README.md /uniqueId: -------------------------------------------------------------------------------- 1 | Tue Dec 16 2025 19:48:19 GMT+0000 (Coordinated Universal Time) -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-72x72.png -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-96x96.png -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-128x128.png -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-144x144.png -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-152x152.png -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-192x192.png -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-384x384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-384x384.png -------------------------------------------------------------------------------- /pwa/files/assets/icons/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/angular/angular-pwa-builds/HEAD/pwa/files/assets/icons/icon-512x512.png -------------------------------------------------------------------------------- /pwa/schema.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF"} -------------------------------------------------------------------------------- /pwa/schema.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE 3 | // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...). 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | //# sourceMappingURL=schema.js.map -------------------------------------------------------------------------------- /pwa/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright Google LLC All Rights Reserved. 4 | * 5 | * Use of this source code is governed by an MIT-style license that can be 6 | * found in the LICENSE file at https://angular.dev/license 7 | */ 8 | import { Rule } from '@angular-devkit/schematics'; 9 | import { Schema as PwaOptions } from './schema'; 10 | export default function (options: PwaOptions): Rule; 11 | -------------------------------------------------------------------------------- /collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "schematics": { 3 | "ng-add": { 4 | "factory": "./pwa", 5 | "description": "Update an application with PWA defaults.", 6 | "schema": "./pwa/schema.json", 7 | "private": true, 8 | "hidden": true 9 | }, 10 | "pwa": { 11 | "factory": "./pwa", 12 | "description": "Update an application with PWA defaults.", 13 | "schema": "./pwa/schema.json" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pwa/schema.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Transforms your Angular application into a Progressive Web App (PWA). PWAs provide a 3 | * native app-like experience, allowing users to install your app on their devices and 4 | * access it offline. This schematic configures your project for PWA functionality, adding a 5 | * service worker, a web app manifest, and other necessary features. 6 | */ 7 | export type Schema = { 8 | /** 9 | * The name of the project to transform into a PWA. If not specified, the CLI will determine 10 | * the project from the current directory. 11 | */ 12 | project?: string; 13 | /** 14 | * The build target to apply the service worker to. This is typically `build`, indicating 15 | * that the service worker should be generated during the standard build process. 16 | */ 17 | target?: string; 18 | /** 19 | * The title of the application. This will be used in the web app manifest, which is a JSON 20 | * file that provides metadata about your PWA (e.g., name, icons, display options). 21 | */ 22 | title?: string; 23 | [property: string]: any; 24 | }; 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2025 Google LLC. https://angular.dev/license 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /pwa/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "SchematicsAngularPWA", 4 | "title": "Angular PWA Options Schema", 5 | "type": "object", 6 | "description": "Transforms your Angular application into a Progressive Web App (PWA). PWAs provide a native app-like experience, allowing users to install your app on their devices and access it offline. This schematic configures your project for PWA functionality, adding a service worker, a web app manifest, and other necessary features.", 7 | "properties": { 8 | "project": { 9 | "type": "string", 10 | "description": "The name of the project to transform into a PWA. If not specified, the CLI will determine the project from the current directory.", 11 | "$default": { 12 | "$source": "projectName" 13 | } 14 | }, 15 | "target": { 16 | "type": "string", 17 | "description": "The build target to apply the service worker to. This is typically `build`, indicating that the service worker should be generated during the standard build process.", 18 | "default": "build" 19 | }, 20 | "title": { 21 | "type": "string", 22 | "description": "The title of the application. This will be used in the web app manifest, which is a JSON file that provides metadata about your PWA (e.g., name, icons, display options)." 23 | } 24 | }, 25 | "required": [] 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@angular/pwa", 3 | "version": "21.1.0-next.2+sha-edeb41c", 4 | "description": "PWA schematics for Angular", 5 | "keywords": [ 6 | "Angular CLI", 7 | "Angular DevKit", 8 | "angular", 9 | "blueprints", 10 | "code generation", 11 | "devkit", 12 | "schematics", 13 | "sdk" 14 | ], 15 | "schematics": "./collection.json", 16 | "ng-add": { 17 | "save": false 18 | }, 19 | "dependencies": { 20 | "@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#edeb41c", 21 | "@schematics/angular": "github:angular/schematics-angular-builds#edeb41c", 22 | "parse5-html-rewriting-stream": "8.0.0" 23 | }, 24 | "peerDependencies": { 25 | "@angular/cli": "github:angular/cli-builds#edeb41c" 26 | }, 27 | "peerDependenciesMeta": { 28 | "@angular/cli": { 29 | "optional": true 30 | } 31 | }, 32 | "repository": { 33 | "type": "git", 34 | "url": "https://github.com/angular/angular-cli.git" 35 | }, 36 | "packageManager": "pnpm@10.25.0", 37 | "engines": { 38 | "node": "^20.19.0 || ^22.12.0 || >=24.0.0", 39 | "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", 40 | "yarn": ">= 1.13.0" 41 | }, 42 | "author": "Angular Authors", 43 | "license": "MIT", 44 | "bugs": { 45 | "url": "https://github.com/angular/angular-cli/issues" 46 | }, 47 | "homepage": "https://github.com/angular/angular-cli" 48 | } 49 | -------------------------------------------------------------------------------- /pwa/files/assets/manifest.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= title %>", 3 | "short_name": "<%= title %>", 4 | "display": "standalone", 5 | "scope": "./", 6 | "start_url": "./", 7 | "icons": [ 8 | { 9 | "src": "<%= iconsPath %>/icon-72x72.png", 10 | "sizes": "72x72", 11 | "type": "image/png", 12 | "purpose": "maskable any" 13 | }, 14 | { 15 | "src": "<%= iconsPath %>/icon-96x96.png", 16 | "sizes": "96x96", 17 | "type": "image/png", 18 | "purpose": "maskable any" 19 | }, 20 | { 21 | "src": "<%= iconsPath %>/icon-128x128.png", 22 | "sizes": "128x128", 23 | "type": "image/png", 24 | "purpose": "maskable any" 25 | }, 26 | { 27 | "src": "<%= iconsPath %>/icon-144x144.png", 28 | "sizes": "144x144", 29 | "type": "image/png", 30 | "purpose": "maskable any" 31 | }, 32 | { 33 | "src": "<%= iconsPath %>/icon-152x152.png", 34 | "sizes": "152x152", 35 | "type": "image/png", 36 | "purpose": "maskable any" 37 | }, 38 | { 39 | "src": "<%= iconsPath %>/icon-192x192.png", 40 | "sizes": "192x192", 41 | "type": "image/png", 42 | "purpose": "maskable any" 43 | }, 44 | { 45 | "src": "<%= iconsPath %>/icon-384x384.png", 46 | "sizes": "384x384", 47 | "type": "image/png", 48 | "purpose": "maskable any" 49 | }, 50 | { 51 | "src": "<%= iconsPath %>/icon-512x512.png", 52 | "sizes": "512x512", 53 | "type": "image/png", 54 | "purpose": "maskable any" 55 | } 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Snapshot build of @angular/pwa 3 | 4 | This repository is a snapshot of a commit on the original repository. The original code used to 5 | generate this is located at http://github.com/angular/angular-cli. 6 | 7 | We do not accept PRs or Issues opened on this repository. You should not use this over a tested and 8 | released version of this package. 9 | 10 | To test this snapshot in your own project, use 11 | 12 | ```bash 13 | npm install git+https://github.com/angular/angular-pwa-builds.git 14 | ``` 15 | 16 | ---- 17 | # `@angular/pwa` 18 | 19 | This is a [schematic](https://angular.dev/tools/cli/schematics) for adding 20 | [Progressive Web App](https://web.dev/progressive-web-apps/) support to an Angular project. Run the 21 | schematic with the [Angular CLI](https://angular.dev/tools/cli): 22 | 23 | ```shell 24 | ng add @angular/pwa --project 25 | ``` 26 | 27 | Executing the command mentioned above will perform the following actions: 28 | 29 | 1. Adds [`@angular/service-worker`](https://npmjs.com/@angular/service-worker) as a dependency to your project. 30 | 1. Enables service worker builds in the Angular CLI. 31 | 1. Imports and registers the service worker in the application module. 32 | 1. Updates the `index.html` file to inlclude a link to add the [manifest.webmanifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) file. 33 | 1. Installs icon files to support the installed Progressive Web App (PWA). 34 | 1. Creates the service worker configuration file called `ngsw-config.json`, specifying caching behaviors and other settings. 35 | 36 | See [Getting started with service workers](https://angular.dev/ecosystem/service-workers/getting-started) 37 | for more information. 38 | -------------------------------------------------------------------------------- /pwa/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DH,4BAkHC;AA1KD,2DAWoC;AACpC,yDAA4E;AAC5E,yCAAkC;AAClC,6CAAuC;AACvC,mDAAgD;AAGhD,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,KAAK,EAAE,IAAU,EAAE,EAAE;QAC1B,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE5C,MAAM,EAAE,eAAe,EAAE,GAAG,wDAAa,8BAA8B,GAAC,CAAC;QAEzE,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;QACvC,IAAI,aAAa,GAAG,I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,qBAAqB,EAAE,gBAAgB,EAAE,SAAS,CAAC;YACrE,IAAA,sBAAS,EACP,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,gBAAgB,CAAC,EAAE,CAAC,IAAA,qBAAQ,EAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAA,iBAAI,EAAC,SAAS,CAAC,CAAC,CAAC,CACrF;YACD,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACxD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"} -------------------------------------------------------------------------------- /pwa/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @license 4 | * Copyright Google LLC All Rights Reserved. 5 | * 6 | * Use of this source code is governed by an MIT-style license that can be 7 | * found in the LICENSE file at https://angular.dev/license 8 | */ 9 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | var desc = Object.getOwnPropertyDescriptor(m, k); 12 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 13 | desc = { enumerable: true, get: function() { return m[k]; } }; 14 | } 15 | Object.defineProperty(o, k2, desc); 16 | }) : (function(o, m, k, k2) { 17 | if (k2 === undefined) k2 = k; 18 | o[k2] = m[k]; 19 | })); 20 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 21 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 22 | }) : function(o, v) { 23 | o["default"] = v; 24 | }); 25 | var __importStar = (this && this.__importStar) || (function () { 26 | var ownKeys = function(o) { 27 | ownKeys = Object.getOwnPropertyNames || function (o) { 28 | var ar = []; 29 | for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; 30 | return ar; 31 | }; 32 | return ownKeys(o); 33 | }; 34 | return function (mod) { 35 | if (mod && mod.__esModule) return mod; 36 | var result = {}; 37 | if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); 38 | __setModuleDefault(result, mod); 39 | return result; 40 | }; 41 | })(); 42 | Object.defineProperty(exports, "__esModule", { value: true }); 43 | exports.default = default_1; 44 | const schematics_1 = require("@angular-devkit/schematics"); 45 | const utility_1 = require("@schematics/angular/utility"); 46 | const node_path_1 = require("node:path"); 47 | const node_stream_1 = require("node:stream"); 48 | const promises_1 = require("node:stream/promises"); 49 | function updateIndexFile(path) { 50 | return async (host) => { 51 | const originalContent = host.readText(path); 52 | const { RewritingStream } = await Promise.resolve().then(() => __importStar(require('parse5-html-rewriting-stream'))); 53 | const rewriter = new RewritingStream(); 54 | let needsNoScript = true; 55 | rewriter.on('startTag', (startTag) => { 56 | if (startTag.tagName === 'noscript') { 57 | needsNoScript = false; 58 | } 59 | rewriter.emitStartTag(startTag); 60 | }); 61 | rewriter.on('endTag', (endTag) => { 62 | if (endTag.tagName === 'head') { 63 | rewriter.emitRaw(' \n'); 64 | } 65 | else if (endTag.tagName === 'body' && needsNoScript) { 66 | rewriter.emitRaw(' \n'); 67 | } 68 | rewriter.emitEndTag(endTag); 69 | }); 70 | return (0, promises_1.pipeline)(node_stream_1.Readable.from(originalContent), rewriter, async function (source) { 71 | const chunks = []; 72 | for await (const chunk of source) { 73 | chunks.push(Buffer.from(chunk)); 74 | } 75 | host.overwrite(path, Buffer.concat(chunks)); 76 | }); 77 | }; 78 | } 79 | function default_1(options) { 80 | return async (host) => { 81 | if (!options.title) { 82 | options.title = options.project; 83 | } 84 | const workspace = await (0, utility_1.readWorkspace)(host); 85 | if (!options.project) { 86 | throw new schematics_1.SchematicsException('Option "project" is required.'); 87 | } 88 | const project = workspace.projects.get(options.project); 89 | if (!project) { 90 | throw new schematics_1.SchematicsException(`Project is not defined in this workspace.`); 91 | } 92 | if (project.extensions['projectType'] !== 'application') { 93 | throw new schematics_1.SchematicsException(`PWA requires a project type of "application".`); 94 | } 95 | // Find all the relevant targets for the project 96 | if (project.targets.size === 0) { 97 | throw new schematics_1.SchematicsException(`Targets are not defined for this project.`); 98 | } 99 | const buildTargets = []; 100 | const testTargets = []; 101 | for (const target of project.targets.values()) { 102 | if (target.builder === '@angular-devkit/build-angular:browser' || 103 | target.builder === '@angular-devkit/build-angular:application' || 104 | target.builder === '@angular/build:application') { 105 | buildTargets.push(target); 106 | } 107 | else if (target.builder === '@angular-devkit/build-angular:karma' || 108 | target.builder === '@angular/build:karma') { 109 | testTargets.push(target); 110 | } 111 | } 112 | // Find all index.html files in build targets 113 | const indexFiles = new Set(); 114 | let checkForDefaultIndex = false; 115 | for (const target of buildTargets) { 116 | if (typeof target.options?.index === 'string') { 117 | indexFiles.add(target.options.index); 118 | } 119 | else if (target.options?.index === undefined) { 120 | checkForDefaultIndex = true; 121 | } 122 | if (!target.configurations) { 123 | continue; 124 | } 125 | for (const options of Object.values(target.configurations)) { 126 | if (typeof options?.index === 'string') { 127 | indexFiles.add(options.index); 128 | } 129 | else if (options?.index === undefined) { 130 | checkForDefaultIndex = true; 131 | } 132 | } 133 | } 134 | // Setup sources for the assets files to add to the project 135 | const sourcePath = project.sourceRoot ?? node_path_1.posix.join(project.root, 'src'); 136 | // Check for a default index file if a configuration path allows for a default usage 137 | if (checkForDefaultIndex) { 138 | const defaultIndexFile = node_path_1.posix.join(sourcePath, 'index.html'); 139 | if (host.exists(defaultIndexFile)) { 140 | indexFiles.add(defaultIndexFile); 141 | } 142 | } 143 | // Setup service worker schematic options 144 | const { title, ...swOptions } = options; 145 | await (0, utility_1.writeWorkspace)(host, workspace); 146 | let assetsDir = node_path_1.posix.join(sourcePath, 'assets'); 147 | let iconsPath; 148 | if (host.exists(assetsDir)) { 149 | // Add manifest to asset configuration 150 | const assetEntry = node_path_1.posix.join(project.sourceRoot ?? node_path_1.posix.join(project.root, 'src'), 'manifest.webmanifest'); 151 | for (const target of [...buildTargets, ...testTargets]) { 152 | if (target.options) { 153 | if (Array.isArray(target.options.assets)) { 154 | target.options.assets.push(assetEntry); 155 | } 156 | else { 157 | target.options.assets = [assetEntry]; 158 | } 159 | } 160 | else { 161 | target.options = { assets: [assetEntry] }; 162 | } 163 | } 164 | iconsPath = 'assets'; 165 | } 166 | else { 167 | assetsDir = node_path_1.posix.join(project.root, 'public'); 168 | iconsPath = 'icons'; 169 | } 170 | return (0, schematics_1.chain)([ 171 | (0, schematics_1.externalSchematic)('@schematics/angular', 'service-worker', swOptions), 172 | (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/assets'), [(0, schematics_1.template)({ ...options, iconsPath }), (0, schematics_1.move)(assetsDir)])), 173 | ...[...indexFiles].map((path) => updateIndexFile(path)), 174 | ]); 175 | }; 176 | } 177 | //# sourceMappingURL=index.js.map --------------------------------------------------------------------------------