@justin06lee/subaru 0.1.0
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/dist/card-BFhpWbA5.d.ts +32 -0
- package/dist/chunk-CPOOJ2JD.js +213 -0
- package/dist/chunk-CPOOJ2JD.js.map +1 -0
- package/dist/chunk-K7IY5EW6.js +138 -0
- package/dist/chunk-K7IY5EW6.js.map +1 -0
- package/dist/chunk-MI26ZEPP.js +92 -0
- package/dist/chunk-MI26ZEPP.js.map +1 -0
- package/dist/chunk-POOH3Z7G.js +178 -0
- package/dist/chunk-POOH3Z7G.js.map +1 -0
- package/dist/chunk-SRQ3JWJK.js +261 -0
- package/dist/chunk-SRQ3JWJK.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +59 -0
- package/dist/cli.js.map +1 -0
- package/dist/core-DmEjLKLp.d.ts +104 -0
- package/dist/electron-renderer.d.ts +34 -0
- package/dist/electron-renderer.js +81 -0
- package/dist/electron-renderer.js.map +1 -0
- package/dist/electron.d.ts +239 -0
- package/dist/electron.js +428 -0
- package/dist/electron.js.map +1 -0
- package/dist/github-Ds4DWDq9.d.ts +37 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/react.d.ts +42 -0
- package/dist/react.js +109 -0
- package/dist/react.js.map +1 -0
- package/dist/source.d.ts +57 -0
- package/dist/source.js +11 -0
- package/dist/source.js.map +1 -0
- package/dist/styles-zfa0Pc0l.d.ts +47 -0
- package/dist/tauri.d.ts +71 -0
- package/dist/tauri.js +109 -0
- package/dist/tauri.js.map +1 -0
- package/dist/web.d.ts +59 -0
- package/dist/web.js +79 -0
- package/dist/web.js.map +1 -0
- package/package.json +120 -0
package/dist/web.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/web.ts"],"sourcesContent":["import { createUpdater, webStorage, type Adapter, type Policy, type Release, type Updater } from './core';\nimport { mountCard, type MountCardOptions } from './card';\n\n/**\n * The stamp file `subaru stamp` writes at build time and this adapter polls.\n * Any change to `id` is a new deploy.\n */\nexport interface Stamp {\n id: string;\n version?: string;\n commit?: string;\n builtAt?: string;\n notes?: string;\n url?: string;\n}\n\nexport interface WebAdapterOptions {\n /** Where the stamp is served. Default \"/subaru.json\". */\n url?: string;\n /** Minimum time between polls. Default 5 minutes. */\n interval?: number;\n /**\n * The id of the build the page was loaded with. Defaults to a\n * <meta name=\"subaru-version\" content=\"...\"> tag when present, otherwise to\n * whatever the first poll returns.\n */\n current?: string;\n /** Injection points for tests. */\n fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n reload?: () => void;\n document?: Document;\n window?: Window;\n}\n\n/**\n * Updates for a web app: a new deploy is detected by polling a tiny JSON stamp\n * and applied by reloading the page. \"Install and restart\" reloads now;\n * \"apply, take effect later\" reloads the moment the tab is hidden, so a\n * person mid-typing never loses the page under their hands.\n */\nexport function webAdapter(options: WebAdapterOptions = {}): Adapter {\n const url = options.url ?? '/subaru.json';\n const doFetch = options.fetch ?? ((input, init) => fetch(input, init));\n const doc = options.document ?? (typeof document !== 'undefined' ? document : undefined);\n const win = options.window ?? (typeof window !== 'undefined' ? window : undefined);\n const reload = options.reload ?? (() => win?.location.reload());\n let current: string | undefined = options.current ?? metaVersion(doc);\n let pendingReload = false;\n\n return {\n kind: 'web',\n name: `web:${typeof location !== 'undefined' ? location.host : ''}${url}`,\n interval: options.interval ?? 5 * 60 * 1000,\n storage: webStorage(),\n async check(signal) {\n const res = await doFetch(url, { cache: 'no-store', signal, headers: { accept: 'application/json' } });\n if (!res.ok) throw new Error(`${url}: ${res.status}`);\n const stamp = (await res.json()) as Stamp;\n if (!stamp || typeof stamp.id !== 'string' || !stamp.id) throw new Error(`${url}: no id`);\n if (current === undefined) {\n current = stamp.id;\n return null;\n }\n if (stamp.id === current) return null;\n const release: Release = { tag: stamp.id };\n if (stamp.version) release.version = stamp.version;\n if (stamp.notes) release.notes = stamp.notes;\n if (stamp.url) release.url = stamp.url;\n if (stamp.builtAt) release.date = stamp.builtAt;\n return release;\n },\n async install(_release, { relaunch }) {\n if (relaunch || !doc || doc.visibilityState === 'hidden') {\n reload();\n return 'restarting';\n }\n if (!pendingReload) {\n pendingReload = true;\n const onHide = () => {\n if (doc.visibilityState === 'hidden') {\n doc.removeEventListener('visibilitychange', onHide);\n reload();\n }\n };\n doc.addEventListener('visibilitychange', onHide);\n }\n return 'ready';\n },\n async restart() {\n reload();\n },\n };\n}\n\nfunction metaVersion(doc: Document | undefined): string | undefined {\n const content = doc?.querySelector('meta[name=\"subaru-version\"]')?.getAttribute('content');\n return content || undefined;\n}\n\nexport interface WebAutoOptions extends WebAdapterOptions {\n policy?: Policy;\n /** Program name shown on the card. */\n name?: string;\n /** false: no card; bring your own UI with updater.subscribe or useUpdater. */\n ui?: boolean | MountCardOptions;\n debug?: (message: string) => void;\n}\n\n/**\n * The whole integration in one call: poll the deploy stamp, show the card\n * when a new deploy lands, reload on \"Update now\". Returns the updater for\n * anything more.\n *\n * import { subaru } from '@justin06lee/subaru/web';\n * subaru({ name: 'hours' });\n */\nexport function subaru(options: WebAutoOptions = {}): Updater {\n const updater = createUpdater({ adapter: webAdapter(options), policy: options.policy, debug: options.debug });\n if (options.ui !== false && typeof document !== 'undefined') {\n mountCard(updater, { name: options.name, ...(typeof options.ui === 'object' ? options.ui : {}) });\n }\n updater.start();\n return updater;\n}\n"],"mappings":";;;;;;;;;;AAwCO,SAAS,WAAW,UAA6B,CAAC,GAAY;AACnE,QAAM,MAAM,QAAQ,OAAO;AAC3B,QAAM,UAAU,QAAQ,UAAU,CAAC,OAAO,SAAS,MAAM,OAAO,IAAI;AACpE,QAAM,MAAM,QAAQ,aAAa,OAAO,aAAa,cAAc,WAAW;AAC9E,QAAM,MAAM,QAAQ,WAAW,OAAO,WAAW,cAAc,SAAS;AACxE,QAAM,SAAS,QAAQ,WAAW,MAAM,KAAK,SAAS,OAAO;AAC7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YAAI,iBAAiB,oBAAoB,MAAM;AAAA,MACjD;AACA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,UAAU;AACd,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,SAAS,YAAY,KAA+C;AAClE,QAAM,UAAU,KAAK,cAAc,6BAA6B,GAAG,aAAa,SAAS;AACzF,SAAO,WAAW;AACpB;AAmBO,SAAS,OAAO,UAA0B,CAAC,GAAY;AAC5D,QAAM,UAAU,cAAc,EAAE,SAAS,WAAW,OAAO,GAAG,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC;AAC5G,MAAI,QAAQ,OAAO,SAAS,OAAO,aAAa,aAAa;AAC3D,cAAU,SAAS,EAAE,MAAM,QAAQ,MAAM,GAAI,OAAO,QAAQ,OAAO,WAAW,QAAQ,KAAK,CAAC,EAAG,CAAC;AAAA,EAClG;AACA,UAAQ,MAAM;AACd,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justin06lee/subaru",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "One update flow for web apps, Tauri and Electron desktop apps: check in the background, then ask, tell, or just do it.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Justin Lee <tenet.sh@gmail.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/justin06lee/subaru.git",
|
|
11
|
+
"directory": "js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"update",
|
|
15
|
+
"updater",
|
|
16
|
+
"self-update",
|
|
17
|
+
"auto-update",
|
|
18
|
+
"tauri",
|
|
19
|
+
"electron",
|
|
20
|
+
"web",
|
|
21
|
+
"react",
|
|
22
|
+
"github-releases",
|
|
23
|
+
"source",
|
|
24
|
+
"make"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20"
|
|
28
|
+
},
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"bin": {
|
|
33
|
+
"subaru": "./dist/cli.js"
|
|
34
|
+
},
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./web": {
|
|
41
|
+
"types": "./dist/web.d.ts",
|
|
42
|
+
"import": "./dist/web.js"
|
|
43
|
+
},
|
|
44
|
+
"./source": {
|
|
45
|
+
"types": "./dist/source.d.ts",
|
|
46
|
+
"import": "./dist/source.js"
|
|
47
|
+
},
|
|
48
|
+
"./tauri": {
|
|
49
|
+
"types": "./dist/tauri.d.ts",
|
|
50
|
+
"import": "./dist/tauri.js"
|
|
51
|
+
},
|
|
52
|
+
"./electron": {
|
|
53
|
+
"types": "./dist/electron.d.ts",
|
|
54
|
+
"import": "./dist/electron.js"
|
|
55
|
+
},
|
|
56
|
+
"./electron/renderer": {
|
|
57
|
+
"types": "./dist/electron-renderer.d.ts",
|
|
58
|
+
"import": "./dist/electron-renderer.js"
|
|
59
|
+
},
|
|
60
|
+
"./react": {
|
|
61
|
+
"types": "./dist/react.d.ts",
|
|
62
|
+
"import": "./dist/react.js"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"files": [
|
|
66
|
+
"dist",
|
|
67
|
+
"README.md"
|
|
68
|
+
],
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsup",
|
|
71
|
+
"typecheck": "tsc --noEmit",
|
|
72
|
+
"test": "bun test",
|
|
73
|
+
"demo": "bun run demo/server.ts",
|
|
74
|
+
"prepublishOnly": "bun run typecheck && bun test && bun run build"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"@tauri-apps/plugin-process": ">=2",
|
|
78
|
+
"@tauri-apps/plugin-shell": ">=2",
|
|
79
|
+
"@tauri-apps/plugin-updater": ">=2",
|
|
80
|
+
"electron": ">=28",
|
|
81
|
+
"electron-updater": ">=6",
|
|
82
|
+
"react": ">=18"
|
|
83
|
+
},
|
|
84
|
+
"peerDependenciesMeta": {
|
|
85
|
+
"@tauri-apps/plugin-process": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"@tauri-apps/plugin-shell": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"@tauri-apps/plugin-updater": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"electron": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"electron-updater": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"react": {
|
|
101
|
+
"optional": true
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"devDependencies": {
|
|
105
|
+
"@happy-dom/global-registrator": "^20.14.0",
|
|
106
|
+
"@tauri-apps/plugin-process": "^2.3.1",
|
|
107
|
+
"@tauri-apps/plugin-shell": "^2.3.6",
|
|
108
|
+
"@tauri-apps/plugin-updater": "^2.11.0",
|
|
109
|
+
"@types/bun": "^1.4.1",
|
|
110
|
+
"@types/react": "^19.2.18",
|
|
111
|
+
"@types/react-dom": "^19.2.7",
|
|
112
|
+
"electron": "^44.2.0",
|
|
113
|
+
"electron-updater": "^6.8.9",
|
|
114
|
+
"happy-dom": "^20.14.0",
|
|
115
|
+
"react": "^19.2.8",
|
|
116
|
+
"react-dom": "^19.2.8",
|
|
117
|
+
"tsup": "^8.5.1",
|
|
118
|
+
"typescript": "^6.0.3"
|
|
119
|
+
}
|
|
120
|
+
}
|