@mdwrk/mdwrk-studio 0.0.0-stage → 1.4.38
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/LICENSE +201 -0
- package/README.md +67 -3
- package/dist/en-C9wuO-Hv.js +8 -0
- package/dist/en-COn130Qv.js +66 -0
- package/dist/en-D2dLG1zq.js +41 -0
- package/dist/en-DRVntwzK.js +125 -0
- package/dist/es-C9nICgui.js +91 -0
- package/dist/es-CIjFSqx_.js +69 -0
- package/dist/es-DEqPVgcN.js +96 -0
- package/dist/esm-entry-CV-N2FdL.js +53485 -0
- package/dist/favicon.svg +19 -0
- package/dist/icons/icon-192.svg +19 -0
- package/dist/icons/icon-512.svg +19 -0
- package/dist/manifest.webmanifest +26 -0
- package/dist/mdwrk-studio.css +1 -0
- package/dist/mdwrk-studio.js +8 -0
- package/dist/sw.js +310 -0
- package/package.json +60 -4
package/dist/sw.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
const SCOPE_URL = new URL(self.registration.scope);
|
|
2
|
+
const SCOPE_PATH = SCOPE_URL.pathname.endsWith('/') ? SCOPE_URL.pathname : `${SCOPE_URL.pathname}/`;
|
|
3
|
+
const SCOPE_KEY = SCOPE_PATH.replace(/[^\w-]+/g, '_');
|
|
4
|
+
const VERSION_MATCH = SCOPE_PATH.match(/\/client\/versions\/([^/]+)\//);
|
|
5
|
+
const CURRENT_VERSION = VERSION_MATCH?.[1] || 'dev';
|
|
6
|
+
const CACHE_PREFIX = `mdwork-${SCOPE_KEY}-`;
|
|
7
|
+
const META_CACHE = 'mdwork-meta';
|
|
8
|
+
const META_KEY = `/pwa-meta/${SCOPE_KEY}`;
|
|
9
|
+
const CURRENT_CACHE = `${CACHE_PREFIX}${CURRENT_VERSION}`;
|
|
10
|
+
const INDEX_CACHE_KEY = `${SCOPE_PATH}index.html`;
|
|
11
|
+
const BUILD_ASSETS = [];
|
|
12
|
+
const CORE_ASSETS = [
|
|
13
|
+
SCOPE_PATH,
|
|
14
|
+
INDEX_CACHE_KEY,
|
|
15
|
+
`${SCOPE_PATH}manifest.webmanifest`,
|
|
16
|
+
`${SCOPE_PATH}favicon.svg`,
|
|
17
|
+
`${SCOPE_PATH}icons/icon-192.svg`,
|
|
18
|
+
`${SCOPE_PATH}icons/icon-512.svg`,
|
|
19
|
+
...BUILD_ASSETS.map((file) => `${SCOPE_PATH}${file}`),
|
|
20
|
+
];
|
|
21
|
+
const EXTERNAL_ASSETS = [
|
|
22
|
+
'https://cdn.tailwindcss.com',
|
|
23
|
+
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css',
|
|
24
|
+
'https://esm.sh/react@19.0.0',
|
|
25
|
+
'https://esm.sh/react-dom@19.0.0',
|
|
26
|
+
'https://esm.sh/react-dom@19.0.0/client',
|
|
27
|
+
'https://esm.sh/react@19.0.0/jsx-runtime',
|
|
28
|
+
'https://esm.sh/lucide-react@0.475.0',
|
|
29
|
+
'https://esm.sh/react-markdown@9.0.3?bundle',
|
|
30
|
+
'https://esm.sh/remark-gfm@4.0.1?bundle',
|
|
31
|
+
'https://esm.sh/remark-supersub@1.0.0?bundle',
|
|
32
|
+
'https://esm.sh/react-syntax-highlighter@15.6.1',
|
|
33
|
+
'https://esm.sh/react-syntax-highlighter@15.6.1/dist/esm/styles/prism',
|
|
34
|
+
'https://esm.sh/jszip@3.10.1',
|
|
35
|
+
'https://esm.sh/path@^0.12.7',
|
|
36
|
+
'https://esm.sh/url@^0.11.4',
|
|
37
|
+
'https://esm.sh/vite@^7.3.1',
|
|
38
|
+
'https://esm.sh/@vitejs/plugin-react@^5.1.2'
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
let metaState = {
|
|
42
|
+
lastKnownGoodVersion: null,
|
|
43
|
+
failedVersions: []
|
|
44
|
+
};
|
|
45
|
+
let failureTimer = null;
|
|
46
|
+
|
|
47
|
+
const readMeta = async () => {
|
|
48
|
+
const cache = await caches.open(META_CACHE);
|
|
49
|
+
const response = await cache.match(META_KEY);
|
|
50
|
+
if (!response) {
|
|
51
|
+
return metaState;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const data = await response.json();
|
|
55
|
+
metaState = {
|
|
56
|
+
lastKnownGoodVersion: typeof data.lastKnownGoodVersion === 'string' ? data.lastKnownGoodVersion : null,
|
|
57
|
+
failedVersions: Array.isArray(data.failedVersions)
|
|
58
|
+
? data.failedVersions.filter((version) => typeof version === 'string')
|
|
59
|
+
: []
|
|
60
|
+
};
|
|
61
|
+
} catch {
|
|
62
|
+
metaState = { lastKnownGoodVersion: null, failedVersions: [] };
|
|
63
|
+
}
|
|
64
|
+
return metaState;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const writeMeta = async () => {
|
|
68
|
+
const cache = await caches.open(META_CACHE);
|
|
69
|
+
const response = new Response(JSON.stringify(metaState), {
|
|
70
|
+
headers: { 'Content-Type': 'application/json' }
|
|
71
|
+
});
|
|
72
|
+
await cache.put(META_KEY, response);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const isFailedVersion = (version) => metaState.failedVersions.includes(version);
|
|
76
|
+
|
|
77
|
+
const getCacheNameForVersion = (version) => `${CACHE_PREFIX}${version}`;
|
|
78
|
+
|
|
79
|
+
const normalizeRequest = (request) => {
|
|
80
|
+
if (typeof request === 'string') {
|
|
81
|
+
return request;
|
|
82
|
+
}
|
|
83
|
+
const url = new URL(request.url);
|
|
84
|
+
return url.toString();
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const getCachedAppShell = async (activeCacheName) => {
|
|
88
|
+
const cache = await caches.open(activeCacheName);
|
|
89
|
+
return (
|
|
90
|
+
(await cache.match(INDEX_CACHE_KEY)) ||
|
|
91
|
+
(await cache.match(SCOPE_PATH))
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const getActiveCacheName = () => {
|
|
96
|
+
if (isFailedVersion(CURRENT_VERSION) && metaState.lastKnownGoodVersion) {
|
|
97
|
+
return getCacheNameForVersion(metaState.lastKnownGoodVersion);
|
|
98
|
+
}
|
|
99
|
+
return CURRENT_CACHE;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const isSuccessfulResponse = (response) => Boolean(response) && response.ok;
|
|
103
|
+
|
|
104
|
+
const fetchAndCache = async ({ request, cache, cacheKey = request, allowOpaque = false }) => {
|
|
105
|
+
const response = await fetch(request);
|
|
106
|
+
if (isSuccessfulResponse(response) || (allowOpaque && response.type === 'opaque')) {
|
|
107
|
+
await cache.put(cacheKey, response.clone());
|
|
108
|
+
return response;
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const notifyClients = async (payload) => {
|
|
114
|
+
const clients = await self.clients.matchAll({ type: 'window' });
|
|
115
|
+
clients.forEach((client) => client.postMessage(payload));
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const markVersionFailed = async (version) => {
|
|
119
|
+
if (!version || isFailedVersion(version)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
metaState.failedVersions = [...metaState.failedVersions, version];
|
|
123
|
+
await writeMeta();
|
|
124
|
+
await notifyClients({ type: 'PWA_UPDATE_FAILED', version });
|
|
125
|
+
const clients = await self.clients.matchAll({ type: 'window' });
|
|
126
|
+
clients.forEach((client) => client.navigate(client.url));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
self.addEventListener('install', (event) => {
|
|
130
|
+
event.waitUntil(
|
|
131
|
+
(async () => {
|
|
132
|
+
const cache = await caches.open(CURRENT_CACHE);
|
|
133
|
+
const assetsToCache = CORE_ASSETS.concat(EXTERNAL_ASSETS);
|
|
134
|
+
await Promise.allSettled(assetsToCache.map((asset) => cache.add(asset)));
|
|
135
|
+
})()
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const CHECK_FOR_UPDATES_TAG = 'check-for-updates';
|
|
140
|
+
|
|
141
|
+
const runUpdateCheck = async () => {
|
|
142
|
+
const clients = await self.clients.matchAll({ type: 'window' });
|
|
143
|
+
clients.forEach((client) => client.postMessage({ type: 'PWA_BACKGROUND_UPDATE_CHECK' }));
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
self.addEventListener('activate', (event) => {
|
|
147
|
+
event.waitUntil(
|
|
148
|
+
(async () => {
|
|
149
|
+
await readMeta();
|
|
150
|
+
const keys = await caches.keys();
|
|
151
|
+
const keep = new Set([CURRENT_CACHE, META_CACHE]);
|
|
152
|
+
if (metaState.lastKnownGoodVersion) {
|
|
153
|
+
keep.add(getCacheNameForVersion(metaState.lastKnownGoodVersion));
|
|
154
|
+
}
|
|
155
|
+
await Promise.all(
|
|
156
|
+
keys
|
|
157
|
+
.filter((key) => key.startsWith(CACHE_PREFIX) && !keep.has(key))
|
|
158
|
+
.map((key) => caches.delete(key))
|
|
159
|
+
);
|
|
160
|
+
await self.clients.claim();
|
|
161
|
+
if ('periodicSync' in self.registration) {
|
|
162
|
+
try {
|
|
163
|
+
await self.registration.periodicSync.register(CHECK_FOR_UPDATES_TAG, {
|
|
164
|
+
minInterval: 1000 * 60 * 30,
|
|
165
|
+
});
|
|
166
|
+
} catch {
|
|
167
|
+
// Ignore unsupported permission states.
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (failureTimer) {
|
|
171
|
+
clearTimeout(failureTimer);
|
|
172
|
+
}
|
|
173
|
+
if (
|
|
174
|
+
metaState.lastKnownGoodVersion &&
|
|
175
|
+
metaState.lastKnownGoodVersion !== CURRENT_VERSION &&
|
|
176
|
+
!isFailedVersion(CURRENT_VERSION)
|
|
177
|
+
) {
|
|
178
|
+
failureTimer = setTimeout(() => {
|
|
179
|
+
markVersionFailed(CURRENT_VERSION);
|
|
180
|
+
}, 15000);
|
|
181
|
+
}
|
|
182
|
+
})()
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
self.addEventListener('periodicsync', (event) => {
|
|
187
|
+
if (event.tag !== CHECK_FOR_UPDATES_TAG) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
event.waitUntil(runUpdateCheck());
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
self.addEventListener('sync', (event) => {
|
|
194
|
+
if (event.tag !== CHECK_FOR_UPDATES_TAG) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
event.waitUntil(runUpdateCheck());
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
self.addEventListener('message', (event) => {
|
|
201
|
+
if (event.data && event.data.type === 'SKIP_WAITING') {
|
|
202
|
+
self.skipWaiting();
|
|
203
|
+
}
|
|
204
|
+
if (event.data && event.data.type === 'CLIENT_READY') {
|
|
205
|
+
const version = typeof event.data.version === 'string' ? event.data.version : null;
|
|
206
|
+
if (version) {
|
|
207
|
+
metaState.lastKnownGoodVersion = version;
|
|
208
|
+
metaState.failedVersions = metaState.failedVersions.filter((item) => item !== version);
|
|
209
|
+
if (failureTimer) {
|
|
210
|
+
clearTimeout(failureTimer);
|
|
211
|
+
failureTimer = null;
|
|
212
|
+
}
|
|
213
|
+
event.waitUntil(writeMeta());
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (event.data && event.data.type === 'MARK_FAILED_VERSION') {
|
|
217
|
+
const version = typeof event.data.version === 'string' ? event.data.version : null;
|
|
218
|
+
if (version) {
|
|
219
|
+
event.waitUntil(markVersionFailed(version));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
self.addEventListener('fetch', (event) => {
|
|
225
|
+
if (event.request.method !== 'GET') {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const url = new URL(event.request.url);
|
|
229
|
+
if (url.origin === SCOPE_URL.origin && url.pathname === '/client/versions/index.json') {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (event.request.destination === 'style') {
|
|
234
|
+
event.respondWith(
|
|
235
|
+
(async () => {
|
|
236
|
+
const cache = await caches.open(getActiveCacheName());
|
|
237
|
+
try {
|
|
238
|
+
const response = await fetchAndCache({ request: event.request, cache, allowOpaque: true });
|
|
239
|
+
if (!response) {
|
|
240
|
+
throw new Error('Network responded without a cacheable stylesheet response');
|
|
241
|
+
}
|
|
242
|
+
return response;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
const cachedResponse = await cache.match(event.request);
|
|
245
|
+
if (cachedResponse) {
|
|
246
|
+
return cachedResponse;
|
|
247
|
+
}
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
})()
|
|
251
|
+
);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (event.request.mode === 'navigate') {
|
|
256
|
+
event.respondWith(
|
|
257
|
+
(async () => {
|
|
258
|
+
const activeCacheName = getActiveCacheName();
|
|
259
|
+
try {
|
|
260
|
+
const cache = await caches.open(activeCacheName);
|
|
261
|
+
const response = await fetchAndCache({
|
|
262
|
+
request: event.request,
|
|
263
|
+
cache,
|
|
264
|
+
cacheKey: INDEX_CACHE_KEY,
|
|
265
|
+
});
|
|
266
|
+
if (!response) {
|
|
267
|
+
throw new Error('Navigation response was not successful');
|
|
268
|
+
}
|
|
269
|
+
return response;
|
|
270
|
+
} catch (error) {
|
|
271
|
+
const cache = await caches.open(activeCacheName);
|
|
272
|
+
const cachedResponse = await cache.match(INDEX_CACHE_KEY);
|
|
273
|
+
if (cachedResponse) {
|
|
274
|
+
return cachedResponse;
|
|
275
|
+
}
|
|
276
|
+
const cachedAppShell = await getCachedAppShell(activeCacheName);
|
|
277
|
+
if (cachedAppShell) {
|
|
278
|
+
return cachedAppShell;
|
|
279
|
+
}
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
})()
|
|
283
|
+
);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
event.respondWith(
|
|
288
|
+
(async () => {
|
|
289
|
+
const cache = await caches.open(getActiveCacheName());
|
|
290
|
+
const cacheKey = normalizeRequest(event.request);
|
|
291
|
+
const cachedResponse = await cache.match(cacheKey) || await cache.match(event.request);
|
|
292
|
+
const fetchPromise = fetchAndCache({ request: event.request, cache, cacheKey, allowOpaque: true }).catch(() => undefined);
|
|
293
|
+
|
|
294
|
+
if (cachedResponse) {
|
|
295
|
+
event.waitUntil(fetchPromise);
|
|
296
|
+
return cachedResponse;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const response = await fetchPromise;
|
|
300
|
+
if (response) {
|
|
301
|
+
return response;
|
|
302
|
+
}
|
|
303
|
+
const cachedAppShell = await getCachedAppShell(getActiveCacheName());
|
|
304
|
+
if (cachedAppShell) {
|
|
305
|
+
return cachedAppShell;
|
|
306
|
+
}
|
|
307
|
+
return caches.match(INDEX_CACHE_KEY);
|
|
308
|
+
})()
|
|
309
|
+
);
|
|
310
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdwrk/mdwrk-studio",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.4.38",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./dist/mdwrk-studio.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/mdwrk-studio.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@mdwrk/extension-gemini-agent": "1.2.4",
|
|
20
|
+
"@mdwrk/extension-git-ops": "1.2.4",
|
|
21
|
+
"@mdwrk/extension-host": "1.0.7",
|
|
22
|
+
"@mdwrk/extension-language-pack-studio": "1.0.9",
|
|
23
|
+
"@mdwrk/extension-manager": "1.2.4",
|
|
24
|
+
"@mdwrk/extension-manifest": "1.0.5",
|
|
25
|
+
"@mdwrk/extension-runtime": "1.2.4",
|
|
26
|
+
"@mdwrk/extension-theme-studio": "1.2.4",
|
|
27
|
+
"@mdwrk/extension-workspace-files": "1.2.4",
|
|
28
|
+
"@mdwrk/i18n": "1.2.7",
|
|
29
|
+
"@mdwrk/icons": "^1.0.5",
|
|
30
|
+
"@mdwrk/markdown-edit-in-renderer-react": "^1.1.4",
|
|
31
|
+
"@mdwrk/markdown-editor-core": "^1.2.1",
|
|
32
|
+
"@mdwrk/markdown-editor-react": "^1.2.1",
|
|
33
|
+
"@mdwrk/markdown-renderer-core": "^1.2.1",
|
|
34
|
+
"@mdwrk/markdown-renderer-react": "^1.2.1",
|
|
35
|
+
"@mdwrk/theme-contract": "1.2.0",
|
|
36
|
+
"@mdwrk/ui-tokens": "^1.3.1",
|
|
37
|
+
"jszip": "^3.10.1",
|
|
38
|
+
"lucide-react": "^0.475.0",
|
|
39
|
+
"react": "^19.0.0",
|
|
40
|
+
"react-dom": "^19.0.0",
|
|
41
|
+
"react-syntax-highlighter": "^15.6.1"
|
|
42
|
+
},
|
|
43
|
+
"license": "Apache-2.0",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20 <23",
|
|
46
|
+
"npm": ">=10"
|
|
47
|
+
},
|
|
48
|
+
"author": "Jacob Stewart <jacob@swarmauri.com>",
|
|
49
|
+
"homepage": "https://mdwrk.com",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/groupsum/mdwrk-studio.git",
|
|
53
|
+
"directory": "apps/client"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/groupsum/mdwrk-studio/issues"
|
|
57
|
+
},
|
|
58
|
+
"overrides": {
|
|
59
|
+
"postcss@>=8 <8.5.23": "8.5.33",
|
|
60
|
+
"prismjs@<1.30.0": "1.30.0"
|
|
61
|
+
}
|
|
62
|
+
}
|