zotero-plugin-scaffold 0.0.4 → 0.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A scaffold for Zotero plugin development.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "files": [
32
32
  "bin/**/*",
33
- "dist/**/*.d.ts",
34
- "dist/**/*.js",
33
+ "dist/**/*",
34
+ "template/**/*",
35
35
  "docs/**/*",
36
36
  "types/**/*.d.ts"
37
37
  ],
@@ -0,0 +1,56 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v**
7
+
8
+ permissions:
9
+ contents: write
10
+ issues: write
11
+ pull-requests: write
12
+
13
+ jobs:
14
+ release-it:
15
+ runs-on: ubuntu-latest
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.GitHub_TOKEN }}
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ # - name: Setup pnpm
25
+ # uses: pnpm/action-setup@v2
26
+ # with:
27
+ # version: 8.12.1
28
+
29
+ - name: Setup Node.js
30
+ uses: actions/setup-node@v4
31
+ with:
32
+ node-version: 20
33
+
34
+ - name: Install deps
35
+ run: |
36
+ npm install
37
+ # echo "public-hoist-pattern[]=@types*" >> .npmrc
38
+ # pnpm install
39
+
40
+ - name: Build
41
+ run: |
42
+ npm run build
43
+
44
+ - name: Release to GitHub
45
+ run: |
46
+ npx release-it -- --no-increment --no-git --no-npm.publish --github.release --ci --VV
47
+ # pnpm dlx release-it --no-increment --no-git --no-npm.publish --github.release --ci --VV
48
+ sleep 1s
49
+
50
+ - name: Notify release
51
+ uses: apexskier/github-release-commenter@v1
52
+ continue-on-error: true
53
+ with:
54
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55
+ comment-template: |
56
+ :rocket: _This ticket has been resolved in {release_tag}. See {release_link} for release notes._
File without changes
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Most of this code is from Zotero team's official Make It Red example[1]
3
+ * or the Zotero 7 documentation[2].
4
+ * [1] https://github.com/zotero/make-it-red
5
+ * [2] https://www.zotero.org/support/dev/zotero_7_for_developers
6
+ */
7
+
8
+ var chromeHandle;
9
+
10
+ function install(data, reason) {}
11
+
12
+ async function startup({ id, version, resourceURI, rootURI }, reason) {
13
+ await Zotero.initializationPromise;
14
+
15
+ // String 'rootURI' introduced in Zotero 7
16
+ if (!rootURI) {
17
+ rootURI = resourceURI.spec;
18
+ }
19
+
20
+ var aomStartup = Components.classes[
21
+ "@mozilla.org/addons/addon-manager-startup;1"
22
+ ].getService(Components.interfaces.amIAddonManagerStartup);
23
+ var manifestURI = Services.io.newURI(rootURI + "manifest.json");
24
+ chromeHandle = aomStartup.registerChrome(manifestURI, [
25
+ ["content", "__addonRef__", rootURI + "chrome/content/"],
26
+ ]);
27
+
28
+ /**
29
+ * Global variables for plugin code.
30
+ * The `_globalThis` is the global root variable of the plugin sandbox environment
31
+ * and all child variables assigned to it is globally accessible.
32
+ * See `src/index.ts` for details.
33
+ */
34
+ const ctx = {
35
+ rootURI,
36
+ };
37
+ ctx._globalThis = ctx;
38
+
39
+ Services.scriptloader.loadSubScript(
40
+ `${rootURI}/chrome/content/scripts/__addonRef__.js`,
41
+ ctx,
42
+ );
43
+ Zotero.__addonInstance__.hooks.onStartup();
44
+ }
45
+
46
+ async function onMainWindowLoad({ window }, reason) {
47
+ Zotero.__addonInstance__?.hooks.onMainWindowLoad(window);
48
+ }
49
+
50
+ async function onMainWindowUnload({ window }, reason) {
51
+ Zotero.__addonInstance__?.hooks.onMainWindowUnload(window);
52
+ }
53
+
54
+ function shutdown({ id, version, resourceURI, rootURI }, reason) {
55
+ if (reason === APP_SHUTDOWN) {
56
+ return;
57
+ }
58
+
59
+ if (typeof Zotero === "undefined") {
60
+ Zotero = Components.classes["@zotero.org/Zotero;1"].getService(
61
+ Components.interfaces.nsISupports,
62
+ ).wrappedJSObject;
63
+ }
64
+ Zotero.__addonInstance__?.hooks.onShutdown();
65
+
66
+ Cc["@mozilla.org/intl/stringbundle;1"]
67
+ .getService(Components.interfaces.nsIStringBundleService)
68
+ .flushBundles();
69
+
70
+ Cu.unload(`${rootURI}/chrome/content/scripts/__addonRef__.js`);
71
+
72
+ if (chromeHandle) {
73
+ chromeHandle.destruct();
74
+ chromeHandle = null;
75
+ }
76
+ }
77
+
78
+ function uninstall(data, reason) {}
File without changes