nuxt-studio 0.0.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/README.md +241 -0
- package/dist/app/main.d.ts +342 -0
- package/dist/app/main.js +38597 -0
- package/dist/app/mdc-import-BDMct_Gn.js +4 -0
- package/dist/app/service-worker.d.ts +3 -0
- package/dist/app/service-worker.js +118 -0
- package/dist/app/shared-D04791PA.js +25754 -0
- package/dist/app/shared-DI6F-ifc.js +25774 -0
- package/dist/app/shared-R5zYJ3Dl.js +25803 -0
- package/dist/app/shared.d.ts +22 -0
- package/dist/app/shared.js +6 -0
- package/dist/app/utils-DI6F-ifc.js +25774 -0
- package/dist/app/utils.d.ts +22 -0
- package/dist/app/utils.js +6 -0
- package/dist/module/module.d.mts +68 -0
- package/dist/module/module.json +10 -0
- package/dist/module/module.mjs +185 -0
- package/dist/module/runtime/composables/useMeta.d.ts +6 -0
- package/dist/module/runtime/composables/useMeta.js +17 -0
- package/dist/module/runtime/host.d.ts +2 -0
- package/dist/module/runtime/host.dev.d.ts +2 -0
- package/dist/module/runtime/host.dev.js +46 -0
- package/dist/module/runtime/host.js +257 -0
- package/dist/module/runtime/plugins/studio.client.d.ts +2 -0
- package/dist/module/runtime/plugins/studio.client.dev.d.ts +2 -0
- package/dist/module/runtime/plugins/studio.client.dev.js +23 -0
- package/dist/module/runtime/plugins/studio.client.js +11 -0
- package/dist/module/runtime/server/routes/admin.d.ts +2 -0
- package/dist/module/runtime/server/routes/admin.js +192 -0
- package/dist/module/runtime/server/routes/auth/github.get.d.ts +53 -0
- package/dist/module/runtime/server/routes/auth/github.get.js +155 -0
- package/dist/module/runtime/server/routes/auth/google.get.d.ts +2 -0
- package/dist/module/runtime/server/routes/auth/google.get.js +13 -0
- package/dist/module/runtime/server/routes/auth/session.delete.d.ts +4 -0
- package/dist/module/runtime/server/routes/auth/session.delete.js +10 -0
- package/dist/module/runtime/server/routes/auth/session.get.d.ts +4 -0
- package/dist/module/runtime/server/routes/auth/session.get.js +12 -0
- package/dist/module/runtime/server/routes/dev/content/[...path].d.ts +2 -0
- package/dist/module/runtime/server/routes/dev/content/[...path].js +57 -0
- package/dist/module/runtime/server/routes/dev/public/[...path].d.ts +8 -0
- package/dist/module/runtime/server/routes/dev/public/[...path].js +61 -0
- package/dist/module/runtime/server/routes/meta.d.ts +17 -0
- package/dist/module/runtime/server/routes/meta.js +39 -0
- package/dist/module/runtime/server/routes/sw.d.ts +2 -0
- package/dist/module/runtime/server/routes/sw.js +6 -0
- package/dist/module/runtime/utils/activation.d.ts +2 -0
- package/dist/module/runtime/utils/activation.js +23 -0
- package/dist/module/runtime/utils/collection.d.ts +22 -0
- package/dist/module/runtime/utils/collection.js +154 -0
- package/dist/module/runtime/utils/ensure.d.ts +1 -0
- package/dist/module/runtime/utils/ensure.js +22 -0
- package/dist/module/runtime/utils/object.d.ts +3 -0
- package/dist/module/runtime/utils/object.js +3 -0
- package/dist/module/runtime/utils/path-meta.d.ts +50 -0
- package/dist/module/runtime/utils/path-meta.js +49 -0
- package/dist/module/types.d.mts +7 -0
- package/package.json +100 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const e = () => `
|
|
2
|
+
const DB_NAME = 'studio-media'
|
|
3
|
+
const STORE_NAME = 'drafts'
|
|
4
|
+
|
|
5
|
+
const DraftStatus = {
|
|
6
|
+
Deleted: 'deleted',
|
|
7
|
+
Created: 'created',
|
|
8
|
+
Updated: 'updated',
|
|
9
|
+
Pristine: 'pristine'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const IMAGE_EXTENSIONS = [
|
|
13
|
+
'png',
|
|
14
|
+
'jpg',
|
|
15
|
+
'jpeg',
|
|
16
|
+
'svg',
|
|
17
|
+
'webp',
|
|
18
|
+
'ico',
|
|
19
|
+
'gif',
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
self.addEventListener('fetch', event => {
|
|
23
|
+
const url = new URL(event.request.url);
|
|
24
|
+
const isSameDomain = url.origin === self.location.origin;
|
|
25
|
+
|
|
26
|
+
if (!isSameDomain) {
|
|
27
|
+
return event.respondWith(fetch(event.request));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (url.pathname.startsWith('/_ipx/_/') || IMAGE_EXTENSIONS.includes(url.pathname.split('.').pop())) {
|
|
31
|
+
return event.respondWith(fetchFromIndexedDB(event, url));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
event.respondWith(fetch(event.request))
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
function fetchFromIndexedDB(event, url) {
|
|
38
|
+
console.log('Fetching from IndexedDB:', url.pathname);
|
|
39
|
+
const dbKey = ['public-assets:', url.pathname.replace(/^\\/+(_ipx\\/_\\/)?/, '').replace('/', ':')].join('')
|
|
40
|
+
return getData(dbKey).then(data => {
|
|
41
|
+
if (!data) {
|
|
42
|
+
console.log('No data found in IndexedDB:', url.pathname, dbKey);
|
|
43
|
+
return fetch(event.request);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const dbItem = JSON.parse(data)
|
|
47
|
+
|
|
48
|
+
console.log('Data found in IndexedDB:', dbItem);
|
|
49
|
+
|
|
50
|
+
// Deleted file
|
|
51
|
+
if (dbItem.status === DraftStatus.Deleted) {
|
|
52
|
+
return fetch('https://placehold.co/1200x800?text=Deleted');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Renamed file
|
|
56
|
+
if (dbItem.original?.path) {
|
|
57
|
+
return fetch(dbItem.original.path);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Created file
|
|
61
|
+
const parsed = parseDataUrl(dbItem.modified.raw);
|
|
62
|
+
const bytes = base64ToUint8Array(parsed.base64);
|
|
63
|
+
|
|
64
|
+
return new Response(bytes, {
|
|
65
|
+
headers: { 'Content-Type': parsed.mime }
|
|
66
|
+
});
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function parseDataUrl(dataUrl) {
|
|
71
|
+
// Example: data:image/png;base64,iVBORw0KG...
|
|
72
|
+
const match = dataUrl.match(/^data:(.+);base64,(.+)$/);
|
|
73
|
+
if (!match) return null;
|
|
74
|
+
return {
|
|
75
|
+
mime: match[1],
|
|
76
|
+
base64: match[2]
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function base64ToUint8Array(base64) {
|
|
81
|
+
const binary = atob(base64);
|
|
82
|
+
const len = binary.length;
|
|
83
|
+
const bytes = new Uint8Array(len);
|
|
84
|
+
for (let i = 0; i < len; i++) {
|
|
85
|
+
bytes[i] = binary.charCodeAt(i);
|
|
86
|
+
}
|
|
87
|
+
return bytes;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// IndexedDB
|
|
91
|
+
function openDB() {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const request = indexedDB.open(DB_NAME, 1);
|
|
94
|
+
request.onupgradeneeded = event => {
|
|
95
|
+
const db = event.target.result;
|
|
96
|
+
db.createObjectStore(STORE_NAME, { keyPath: 'id' });
|
|
97
|
+
};
|
|
98
|
+
request.onsuccess = event => resolve(event.target.result);
|
|
99
|
+
request.onerror = event => reject(event.target.error);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Read data from the object store
|
|
104
|
+
function getData(key) {
|
|
105
|
+
return openDB().then(db => {
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
const tx = db.transaction('drafts', 'readonly');
|
|
108
|
+
const store = tx.objectStore('drafts');
|
|
109
|
+
const request = store.get(key);
|
|
110
|
+
request.onsuccess = () => resolve(request.result);
|
|
111
|
+
request.onerror = () => reject(request.error);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
export {
|
|
117
|
+
e as serviceWorker
|
|
118
|
+
};
|