mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-07-16 00:00:04 +08:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4d7f60a3b | ||
|
|
6764b252cd | ||
|
|
b7d9d9022f | ||
|
|
c6c21acf37 | ||
|
|
8e54b98941 | ||
|
|
412320dd44 | ||
|
|
3447bd33f5 | ||
|
|
d2fb499b30 | ||
|
|
87e1f12993 | ||
|
|
ac35af8abf |
@@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "9.1.2"
|
||||
".": "9.1.3"
|
||||
}
|
||||
|
||||
@@ -256,6 +256,24 @@
|
||||
|
||||
|
||||
|
||||
## [9.1.3](https://github.com/danielsogl/awesome-cordova-plugins/compare/awesome-cordova-plugins-v9.1.2...awesome-cordova-plugins-v9.1.3) (2026-04-15)
|
||||
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* **deps-dev:** bump picomatch from 2.3.1 to 2.3.2 ([#5132](https://github.com/danielsogl/awesome-cordova-plugins/issues/5132)) ([ac35af8](https://github.com/danielsogl/awesome-cordova-plugins/commit/ac35af8abf33534782d44cf24785cd991202d03b))
|
||||
* **deps:** update dependency @swc/core to ^1.15.24 ([#5136](https://github.com/danielsogl/awesome-cordova-plugins/issues/5136)) ([3447bd3](https://github.com/danielsogl/awesome-cordova-plugins/commit/3447bd33f5fbe6faacb495a3546db9d97723d687))
|
||||
* **deps:** update dependency @types/node to ^22.19.17 ([#5137](https://github.com/danielsogl/awesome-cordova-plugins/issues/5137)) ([412320d](https://github.com/danielsogl/awesome-cordova-plugins/commit/412320dd447ded3bc36e1051b496b146f9a21937))
|
||||
* **deps:** update dependency rollup to ^4.60.1 ([#5142](https://github.com/danielsogl/awesome-cordova-plugins/issues/5142)) ([c6c21ac](https://github.com/danielsogl/awesome-cordova-plugins/commit/c6c21acf37fefa169ceba0d6a73e5ac0602fa21d))
|
||||
* **deps:** update dependency typedoc to ^0.28.18 ([#5134](https://github.com/danielsogl/awesome-cordova-plugins/issues/5134)) ([87e1f12](https://github.com/danielsogl/awesome-cordova-plugins/commit/87e1f1299331d3e1eef498b559c477e7d22388b3))
|
||||
* **deps:** update dependency typedoc to ^0.28.19 ([#5141](https://github.com/danielsogl/awesome-cordova-plugins/issues/5141)) ([8e54b98](https://github.com/danielsogl/awesome-cordova-plugins/commit/8e54b98941b8df3a348e0a54b235829dc6cd1903))
|
||||
* **deps:** update linting and formatting ([#5135](https://github.com/danielsogl/awesome-cordova-plugins/issues/5135)) ([d2fb499](https://github.com/danielsogl/awesome-cordova-plugins/commit/d2fb499b30fbc1728b72e2c592dac01abef5741a))
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* **core:** fix dead link to Capacitor docs ([#5143](https://github.com/danielsogl/awesome-cordova-plugins/issues/5143)) ([b7d9d90](https://github.com/danielsogl/awesome-cordova-plugins/commit/b7d9d9022fe98938f94c9c338f1e0cfffd535ff4))
|
||||
|
||||
## [9.1.2](https://github.com/danielsogl/awesome-cordova-plugins/compare/awesome-cordova-plugins-v9.1.1...awesome-cordova-plugins-v9.1.2) (2026-03-23)
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ These plugins are submitted and maintained by the community. While community mem
|
||||
|
||||
## Capacitor Support
|
||||
|
||||
In addition to Cordova, Awesome Cordova Plugins also works with [Capacitor](https://capacitorjs.com/), Ionic's official native runtime. Basic usage below. For complete details, [see the Capacitor documentation](https://capacitorjs.com/docs/cordova/using-cordova-plugins).
|
||||
In addition to Cordova, Awesome Cordova Plugins also works with [Capacitor](https://capacitorjs.com/), Ionic's official native runtime. Basic usage below. For complete details, [see the Capacitor documentation](https://capacitorjs.com/docs/plugins/cordova).
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
Generated
+311
-287
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "awesome-cordova-plugins",
|
||||
"version": "9.1.2",
|
||||
"version": "9.1.3",
|
||||
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
|
||||
"homepage": "https://awesome-cordova-plugins.com",
|
||||
"author": "Daniel Sogl <me@danielsogl.com> (https://danielsogl.com)",
|
||||
@@ -32,25 +32,25 @@
|
||||
"@angular/compiler-cli": "20.3.18",
|
||||
"@angular/core": "20.3.18",
|
||||
"@eslint/js": "^10.0.0",
|
||||
"@swc/core": "^1.15.21",
|
||||
"@swc/core": "^1.15.24",
|
||||
"@swc/jest": "^0.2.39",
|
||||
"@types/cordova": "11.0.3",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^22.19.15",
|
||||
"@types/node": "^22.19.17",
|
||||
"eslint": "^10.1.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"eslint-plugin-jsdoc": "^62.8.0",
|
||||
"eslint-plugin-jsdoc": "^62.8.1",
|
||||
"jest": "^30.3.0",
|
||||
"jest-environment-jsdom": "^30.3.0",
|
||||
"lefthook": "^2.1.4",
|
||||
"prettier": "^3.8.1",
|
||||
"rollup": "^4.59.0",
|
||||
"rollup": "^4.60.1",
|
||||
"rxjs": "^7.8.2",
|
||||
"tsx": "^4.21.0",
|
||||
"typedoc": "^0.28.17",
|
||||
"typedoc": "^0.28.19",
|
||||
"typedoc-plugin-markdown": "^4.11.0",
|
||||
"typescript": "~5.8.3",
|
||||
"typescript-eslint": "^8.57.1"
|
||||
"typescript-eslint": "^8.57.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { rewriteInjectableExports } from './esm-exports';
|
||||
|
||||
describe('rewriteInjectableExports', () => {
|
||||
test('rewrites inline class exports into instance exports', () => {
|
||||
const jsFile = `import { AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
export class File extends AwesomeCordovaNativePlugin {
|
||||
static pluginName = 'File';
|
||||
}
|
||||
//# sourceMappingURL=index.js.map`;
|
||||
|
||||
expect(rewriteInjectableExports(jsFile, [{ className: 'File', dirName: 'file', file: '/tmp/file/index.ts' }]))
|
||||
.toBe(`import { AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
class FileOriginal extends AwesomeCordovaNativePlugin {
|
||||
static pluginName = 'File';
|
||||
}
|
||||
const File = new FileOriginal();
|
||||
export { File };
|
||||
//# sourceMappingURL=index.js.map`);
|
||||
});
|
||||
|
||||
test('keeps supporting legacy named exports', () => {
|
||||
const jsFile = `class SocialSharingOriginal {}
|
||||
export { SocialSharingOriginal };`;
|
||||
|
||||
expect(
|
||||
rewriteInjectableExports(jsFile, [
|
||||
{ className: 'SocialSharing', dirName: 'social-sharing', file: '/tmp/social-sharing/index.ts' },
|
||||
])
|
||||
).toBe(`class SocialSharingOriginal {}
|
||||
const SocialSharing = new SocialSharingOriginal();
|
||||
export { SocialSharing };`);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
import { InjectableClassEntry } from './transformers/extract-injectables';
|
||||
|
||||
const SOURCE_MAP_COMMENT = '\n//# sourceMappingURL=';
|
||||
|
||||
function insertBeforeSourceMapComment(contents: string, addition: string): string {
|
||||
const sourceMapIndex = contents.lastIndexOf(SOURCE_MAP_COMMENT);
|
||||
if (sourceMapIndex === -1) {
|
||||
return `${contents}\n${addition}`;
|
||||
}
|
||||
|
||||
return `${contents.slice(0, sourceMapIndex)}\n${addition}${contents.slice(sourceMapIndex)}`;
|
||||
}
|
||||
|
||||
export function rewriteInjectableExports(jsFile: string, classes: InjectableClassEntry[]): string {
|
||||
let rewrittenFile = jsFile;
|
||||
const exportBlocks: string[] = [];
|
||||
|
||||
classes.forEach((entry) => {
|
||||
const originalClassName = `${entry.className}Original`;
|
||||
|
||||
rewrittenFile = rewrittenFile.replace(
|
||||
new RegExp(`([\\s\\(])${entry.className}([\\s\\.;\\(,])`, 'g'),
|
||||
`$1${originalClassName}$2`
|
||||
);
|
||||
|
||||
const legacyExportPattern = new RegExp(`\\nexport\\s*\\{\\s*${originalClassName}\\s*\\};?`);
|
||||
if (legacyExportPattern.test(rewrittenFile)) {
|
||||
rewrittenFile = rewrittenFile.replace(legacyExportPattern, '');
|
||||
} else {
|
||||
const inlineClassExportPattern = new RegExp(`export\\s+class\\s+${originalClassName}(?=\\s)`);
|
||||
if (!inlineClassExportPattern.test(rewrittenFile)) {
|
||||
throw new Error(`Could not rewrite ESM export for injectable class "${entry.className}"`);
|
||||
}
|
||||
rewrittenFile = rewrittenFile.replace(inlineClassExportPattern, `class ${originalClassName}`);
|
||||
}
|
||||
|
||||
exportBlocks.push(`const ${entry.className} = new ${originalClassName}();\nexport { ${entry.className} };`);
|
||||
});
|
||||
|
||||
if (exportBlocks.length === 0) {
|
||||
return rewrittenFile;
|
||||
}
|
||||
|
||||
return insertBeforeSourceMapComment(rewrittenFile, exportBlocks.join('\n'));
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { rewriteInjectableExports } from '../build/esm-exports';
|
||||
import { PLUGIN_PATHS, ROOT } from '../build/helpers';
|
||||
import { InjectableClassEntry, EMIT_PATH } from '../build/transformers/extract-injectables';
|
||||
import { generateDeclarations, transpile } from '../build/transpile';
|
||||
@@ -17,17 +18,11 @@ outDirs.forEach((dir: string) => {
|
||||
let jsFile: string = readFileSync(join(dir, 'index.js'), 'utf-8'),
|
||||
dtsFile: string = readFileSync(join(dir, 'index.d.ts'), 'utf-8');
|
||||
|
||||
jsFile = rewriteInjectableExports(jsFile, classes);
|
||||
|
||||
classes.forEach((entry) => {
|
||||
dtsFile = dtsFile.replace(`class ${entry.className} `, 'class ' + entry.className + 'Original ');
|
||||
dtsFile += `\nexport declare const ${entry.className}: ${entry.className}Original;`;
|
||||
jsFile = jsFile.replace(
|
||||
new RegExp(`([\\s\\(])${entry.className}([\\s\\.;\\(,])`, 'g'),
|
||||
'$1' + entry.className + 'Original$2'
|
||||
);
|
||||
jsFile = jsFile.replace(
|
||||
`export { ${entry.className}Original }`,
|
||||
`var ${entry.className} = new ${entry.className}Original();\nexport { ${entry.className} }`
|
||||
);
|
||||
});
|
||||
|
||||
writeFileSync(join(dir, 'index.js'), jsFile, 'utf-8');
|
||||
|
||||
Reference in New Issue
Block a user