vitral 0.2.0 → 0.4.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 +1 -1
- package/dist/angular.d.ts +3 -2
- package/dist/angular.js +7 -6
- package/dist/auto.js +7 -6
- package/dist/capture-TT5WBLJ6.js +42 -0
- package/dist/channel-2YPYGX3J.js +95 -0
- package/dist/chunk-463H6B56.js +50 -0
- package/dist/chunk-54CBIZES.js +105 -0
- package/dist/chunk-6EX5KYT5.js +64 -0
- package/dist/{chunk-6Y3VMWHH.js → chunk-BCC25ANK.js} +11 -5
- package/dist/{chunk-2XF5BKV3.js → chunk-EMSB2NVX.js} +26 -13
- package/dist/{chunk-HP6QWU6K.js → chunk-IH3ZT3QU.js} +2 -2
- package/dist/{chunk-PX7PBCCT.js → chunk-TW7KYJQ6.js} +7 -17
- package/dist/{chunk-S5MZT5IT.js → chunk-UYOPJ4XQ.js} +1 -1
- package/dist/{chunk-UTYAX6MU.js → chunk-W6322KGP.js} +2 -2
- package/dist/{chunk-NCONW6WS.js → chunk-WD4CDGDZ.js} +73 -44
- package/dist/cli.js +1196 -31
- package/dist/contract-46EZFQPQ.js +17 -0
- package/dist/{dedupe-IWFIXRWG.js → dedupe-S7BHQMOZ.js} +4 -3
- package/dist/devtools.d.ts +32 -2
- package/dist/devtools.js +27 -12
- package/dist/element.d.ts +13 -4
- package/dist/element.js +7 -6
- package/dist/embed.js +2 -0
- package/dist/{errors-KKB8FGCz.d.ts → errors-kjBv6IH_.d.ts} +7 -1
- package/dist/{events-DUdjhfps.d.ts → events-Dkpkw_Sv.d.ts} +1 -1
- package/dist/expose-OVWTPHH5.js +15 -0
- package/dist/federation.d.ts +89 -0
- package/dist/federation.js +101 -0
- package/dist/iframe.d.ts +1 -1
- package/dist/iframe.js +13 -10
- package/dist/index.d.ts +23 -21
- package/dist/index.js +5 -4
- package/dist/otel.d.ts +44 -0
- package/dist/otel.js +27 -0
- package/dist/overrides-NP754HY7.js +27 -0
- package/dist/preact.d.ts +5 -5
- package/dist/preact.js +6 -5
- package/dist/react.d.ts +12 -4
- package/dist/react.js +11 -6
- package/dist/routes.d.ts +3 -3
- package/dist/routes.js +5 -4
- package/dist/sentry.d.ts +25 -0
- package/dist/sentry.js +11 -0
- package/dist/shadow-PVSETNMZ.js +159 -0
- package/dist/single-spa.d.ts +40 -0
- package/dist/single-spa.js +52 -0
- package/dist/{slot-pB276oPt.d.ts → slot-UPg6ob9v.d.ts} +2 -2
- package/dist/solid.d.ts +4 -4
- package/dist/solid.js +6 -5
- package/dist/{sri-BVKZNX5Q.js → sri-M7ZRU57G.js} +43 -11
- package/dist/svelte.d.ts +5 -5
- package/dist/svelte.js +6 -5
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +5 -4
- package/dist/{types-BV-hUrms.d.ts → types-CA2p9KHC.d.ts} +174 -4
- package/dist/vite.d.ts +26 -0
- package/dist/vite.js +686 -51
- package/dist/vue.d.ts +11 -4
- package/dist/vue.js +10 -5
- package/package.json +115 -23
- package/dist/chunk-DXORSF4X.js +0 -42
- package/dist/chunk-SFL6LTP3.js +0 -56
- package/dist/expose-53BEJB34.js +0 -14
- package/dist/overrides-NZAIUGK5.js +0 -15
- package/dist/shadow-MYRJQLLY.js +0 -72
package/dist/vue.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { PropType, App, ShallowRef, WritableComputedRef, ComputedRef, Component } from 'vue';
|
|
3
|
-
import { P as Props, I as Isolation, R as RemoteContext, S as Shared, a as RemoteModule } from './types-
|
|
4
|
-
export { e as events } from './events-
|
|
3
|
+
import { P as Props, I as Isolation, R as RemoteContext, S as Shared, a as RemoteModule } from './types-CA2p9KHC.js';
|
|
4
|
+
export { e as events } from './events-Dkpkw_Sv.js';
|
|
5
5
|
import { L as Loading, P as Prefetch } from './host-slot-Cz6EiGsB.js';
|
|
6
|
+
import './errors-kjBv6IH_.js';
|
|
6
7
|
|
|
7
8
|
interface VueRemoteOptions {
|
|
8
9
|
/** Instale plugins (router, pinia, i18n…) no app do remote. */
|
|
@@ -12,6 +13,12 @@ interface VueRemoteOptions {
|
|
|
12
13
|
declare function vueRemote<P extends Props>(component: Component, options?: VueRemoteOptions): RemoteModule<P>;
|
|
13
14
|
/** Dentro de um remote: dá acesso ao contexto (nome, eventos, baseUrl). */
|
|
14
15
|
declare function useVitral(): RemoteContext | null;
|
|
16
|
+
/**
|
|
17
|
+
* Dentro de um remote: onde renderizar portais. No Shadow DOM é um elemento
|
|
18
|
+
* dentro do shadow root (com os estilos do remote); senão, `'body'`. Use em
|
|
19
|
+
* `<Teleport :to="portal">`.
|
|
20
|
+
*/
|
|
21
|
+
declare function usePortalContainer(): HTMLElement | 'body';
|
|
15
22
|
/** Assina um evento do barramento global enquanto o componente existir. */
|
|
16
23
|
declare function useEvent<T = unknown>(type: string, handler: (payload: T) => void): void;
|
|
17
24
|
/** Ref com o último valor emitido em `type`. */
|
|
@@ -120,8 +127,8 @@ declare const VitralRemote: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
120
127
|
onError?: ((...args: any[]) => any) | undefined;
|
|
121
128
|
onReady?: ((...args: any[]) => any) | undefined;
|
|
122
129
|
}>, {
|
|
123
|
-
isolate: Isolation;
|
|
124
130
|
name: string;
|
|
131
|
+
isolate: Isolation;
|
|
125
132
|
priority: RequestPriority;
|
|
126
133
|
loading: Loading;
|
|
127
134
|
src: string;
|
|
@@ -130,4 +137,4 @@ declare const VitralRemote: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
130
137
|
keepAlive: number | boolean;
|
|
131
138
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
132
139
|
|
|
133
|
-
export { VitralRemote, type VueRemoteOptions, useEvent, useEventValue, useShared, useVitral, vueRemote };
|
|
140
|
+
export { VitralRemote, type VueRemoteOptions, useEvent, useEventValue, usePortalContainer, useShared, useVitral, vueRemote };
|
package/dist/vue.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostSlot,
|
|
3
3
|
timings
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-W6322KGP.js";
|
|
5
5
|
import {
|
|
6
6
|
defineRemote,
|
|
7
7
|
events,
|
|
8
8
|
memoSelect,
|
|
9
9
|
same,
|
|
10
10
|
shared
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-WD4CDGDZ.js";
|
|
12
|
+
import "./chunk-EMSB2NVX.js";
|
|
13
|
+
import "./chunk-6EX5KYT5.js";
|
|
14
14
|
import {
|
|
15
15
|
absolute
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-TW7KYJQ6.js";
|
|
17
|
+
import "./chunk-463H6B56.js";
|
|
17
18
|
import "./chunk-GNPFWISJ.js";
|
|
18
19
|
|
|
19
20
|
// src/vue.ts
|
|
@@ -55,6 +56,9 @@ function vueRemote(component, options = {}) {
|
|
|
55
56
|
function useVitral() {
|
|
56
57
|
return inject(VitralKey, null);
|
|
57
58
|
}
|
|
59
|
+
function usePortalContainer() {
|
|
60
|
+
return useVitral()?.portalContainer ?? "body";
|
|
61
|
+
}
|
|
58
62
|
function useEvent(type, handler) {
|
|
59
63
|
let off;
|
|
60
64
|
onMounted(() => off = events.on(type, handler));
|
|
@@ -142,6 +146,7 @@ export {
|
|
|
142
146
|
events,
|
|
143
147
|
useEvent,
|
|
144
148
|
useEventValue,
|
|
149
|
+
usePortalContainer,
|
|
145
150
|
useShared,
|
|
146
151
|
useVitral,
|
|
147
152
|
vueRemote
|
package/package.json
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitral",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Micro-frontends sem burocracia: um contrato mount/unmount, carregamento em runtime e adaptadores para React, Next, Vue, Nuxt, Angular, Svelte, Solid, Preact, Lit e JS/TS puro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"micro-frontend",
|
|
7
|
+
"micro-frontends",
|
|
8
|
+
"microfrontend",
|
|
7
9
|
"microfrontends",
|
|
10
|
+
"mfe",
|
|
8
11
|
"module-federation",
|
|
9
12
|
"single-spa",
|
|
13
|
+
"vite",
|
|
14
|
+
"vite-plugin",
|
|
15
|
+
"runtime",
|
|
16
|
+
"shadow-dom",
|
|
10
17
|
"react",
|
|
11
18
|
"nextjs",
|
|
12
19
|
"vue",
|
|
13
20
|
"nuxt",
|
|
14
21
|
"angular",
|
|
15
22
|
"svelte",
|
|
23
|
+
"sveltekit",
|
|
16
24
|
"solid",
|
|
25
|
+
"solidjs",
|
|
17
26
|
"preact",
|
|
27
|
+
"astro",
|
|
18
28
|
"lit",
|
|
19
29
|
"web-components",
|
|
20
|
-
"
|
|
30
|
+
"typescript"
|
|
21
31
|
],
|
|
22
32
|
"homepage": "https://github.com/joaogabriel15/vitral#readme",
|
|
23
33
|
"bugs": {
|
|
@@ -101,6 +111,22 @@
|
|
|
101
111
|
"./testing": {
|
|
102
112
|
"types": "./dist/testing.d.ts",
|
|
103
113
|
"import": "./dist/testing.js"
|
|
114
|
+
},
|
|
115
|
+
"./sentry": {
|
|
116
|
+
"types": "./dist/sentry.d.ts",
|
|
117
|
+
"import": "./dist/sentry.js"
|
|
118
|
+
},
|
|
119
|
+
"./otel": {
|
|
120
|
+
"types": "./dist/otel.d.ts",
|
|
121
|
+
"import": "./dist/otel.js"
|
|
122
|
+
},
|
|
123
|
+
"./single-spa": {
|
|
124
|
+
"types": "./dist/single-spa.d.ts",
|
|
125
|
+
"import": "./dist/single-spa.js"
|
|
126
|
+
},
|
|
127
|
+
"./federation": {
|
|
128
|
+
"types": "./dist/federation.d.ts",
|
|
129
|
+
"import": "./dist/federation.js"
|
|
104
130
|
}
|
|
105
131
|
},
|
|
106
132
|
"publishConfig": {
|
|
@@ -194,9 +220,12 @@
|
|
|
194
220
|
"./overrides-*",
|
|
195
221
|
"./sri-*",
|
|
196
222
|
"./dedupe-*",
|
|
197
|
-
"./
|
|
223
|
+
"./contract-*",
|
|
224
|
+
"./expose-*",
|
|
225
|
+
"./capture-*",
|
|
226
|
+
"./channel-*"
|
|
198
227
|
],
|
|
199
|
-
"limit": "4.
|
|
228
|
+
"limit": "4.65 kB"
|
|
200
229
|
},
|
|
201
230
|
{
|
|
202
231
|
"name": "núcleo",
|
|
@@ -204,21 +233,38 @@
|
|
|
204
233
|
"import": "{ RemoteError, __reset, component, configure, createEventBus, createSlot, defineRemote, events, html, loadRemote, mountRemote, navigate, preload, register, render, unsafeHTML }",
|
|
205
234
|
"ignore": [
|
|
206
235
|
"./shadow-*",
|
|
236
|
+
"./overrides-*",
|
|
207
237
|
"./sri-*",
|
|
208
238
|
"./dedupe-*",
|
|
209
|
-
"./
|
|
239
|
+
"./contract-*",
|
|
240
|
+
"./expose-*",
|
|
241
|
+
"./capture-*",
|
|
242
|
+
"./channel-*"
|
|
210
243
|
],
|
|
211
|
-
"limit": "5.
|
|
244
|
+
"limit": "5.78 kB"
|
|
212
245
|
},
|
|
213
246
|
{
|
|
214
247
|
"name": "SRI e dedupe (sob demanda, com as dependências)",
|
|
215
248
|
"path": "dist/sri-*.js",
|
|
216
|
-
"limit": "2.
|
|
249
|
+
"limit": "2.59 kB"
|
|
217
250
|
},
|
|
218
251
|
{
|
|
219
252
|
"name": "dedupe (sob demanda, para hosts que oferecem dependências)",
|
|
220
253
|
"path": "dist/dedupe-*.js",
|
|
221
|
-
"limit": "0.
|
|
254
|
+
"limit": "0.67 kB"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"name": "overrides (sob demanda)",
|
|
258
|
+
"path": "dist/overrides-*.js",
|
|
259
|
+
"limit": "1.29 kB"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"name": "canal: canary e rollback (sob demanda)",
|
|
263
|
+
"path": "dist/channel-*.js",
|
|
264
|
+
"ignore": [
|
|
265
|
+
"./chunk-*"
|
|
266
|
+
],
|
|
267
|
+
"limit": "1.02 kB"
|
|
222
268
|
},
|
|
223
269
|
{
|
|
224
270
|
"name": "host mínimo + store",
|
|
@@ -229,9 +275,12 @@
|
|
|
229
275
|
"./overrides-*",
|
|
230
276
|
"./sri-*",
|
|
231
277
|
"./dedupe-*",
|
|
232
|
-
"./
|
|
278
|
+
"./contract-*",
|
|
279
|
+
"./expose-*",
|
|
280
|
+
"./capture-*",
|
|
281
|
+
"./channel-*"
|
|
233
282
|
],
|
|
234
|
-
"limit": "5 kB"
|
|
283
|
+
"limit": "5.34 kB"
|
|
235
284
|
},
|
|
236
285
|
{
|
|
237
286
|
"name": "host mínimo + store + persist + syncTabs",
|
|
@@ -242,9 +291,12 @@
|
|
|
242
291
|
"./overrides-*",
|
|
243
292
|
"./sri-*",
|
|
244
293
|
"./dedupe-*",
|
|
245
|
-
"./
|
|
294
|
+
"./contract-*",
|
|
295
|
+
"./expose-*",
|
|
296
|
+
"./capture-*",
|
|
297
|
+
"./channel-*"
|
|
246
298
|
],
|
|
247
|
-
"limit": "5.
|
|
299
|
+
"limit": "5.57 kB"
|
|
248
300
|
},
|
|
249
301
|
{
|
|
250
302
|
"name": "estilos do Shadow DOM (além do núcleo)",
|
|
@@ -252,7 +304,7 @@
|
|
|
252
304
|
"ignore": [
|
|
253
305
|
"./chunk-*"
|
|
254
306
|
],
|
|
255
|
-
"limit": "1 kB"
|
|
307
|
+
"limit": "1.72 kB"
|
|
256
308
|
},
|
|
257
309
|
{
|
|
258
310
|
"name": "react",
|
|
@@ -262,9 +314,13 @@
|
|
|
262
314
|
"react",
|
|
263
315
|
"react-dom",
|
|
264
316
|
"./shadow-*",
|
|
317
|
+
"./overrides-*",
|
|
265
318
|
"./sri-*",
|
|
266
319
|
"./dedupe-*",
|
|
267
|
-
"./
|
|
320
|
+
"./contract-*",
|
|
321
|
+
"./expose-*",
|
|
322
|
+
"./capture-*",
|
|
323
|
+
"./channel-*"
|
|
268
324
|
],
|
|
269
325
|
"limit": "6.2 kB"
|
|
270
326
|
},
|
|
@@ -275,11 +331,15 @@
|
|
|
275
331
|
"ignore": [
|
|
276
332
|
"vue",
|
|
277
333
|
"./shadow-*",
|
|
334
|
+
"./overrides-*",
|
|
278
335
|
"./sri-*",
|
|
279
336
|
"./dedupe-*",
|
|
280
|
-
"./
|
|
337
|
+
"./contract-*",
|
|
338
|
+
"./expose-*",
|
|
339
|
+
"./capture-*",
|
|
340
|
+
"./channel-*"
|
|
281
341
|
],
|
|
282
|
-
"limit": "6 kB"
|
|
342
|
+
"limit": "6.12 kB"
|
|
283
343
|
},
|
|
284
344
|
{
|
|
285
345
|
"name": "element",
|
|
@@ -287,41 +347,73 @@
|
|
|
287
347
|
"import": "{ defineVitralElement }",
|
|
288
348
|
"ignore": [
|
|
289
349
|
"./shadow-*",
|
|
350
|
+
"./overrides-*",
|
|
290
351
|
"./sri-*",
|
|
291
352
|
"./dedupe-*",
|
|
292
|
-
"./
|
|
353
|
+
"./contract-*",
|
|
354
|
+
"./expose-*",
|
|
355
|
+
"./capture-*",
|
|
356
|
+
"./channel-*"
|
|
293
357
|
],
|
|
294
|
-
"limit": "6.
|
|
358
|
+
"limit": "6.33 kB"
|
|
295
359
|
},
|
|
296
360
|
{
|
|
297
361
|
"name": "devtools",
|
|
298
362
|
"path": "dist/devtools.js",
|
|
299
363
|
"import": "{ devtools }",
|
|
300
|
-
"limit": "2 kB"
|
|
364
|
+
"limit": "2.05 kB"
|
|
301
365
|
},
|
|
302
366
|
{
|
|
303
367
|
"name": "auto",
|
|
304
368
|
"path": "dist/auto.js",
|
|
305
|
-
"limit": "6 kB",
|
|
369
|
+
"limit": "6.12 kB",
|
|
306
370
|
"ignore": [
|
|
307
371
|
"./shadow-*",
|
|
308
372
|
"./overrides-*",
|
|
309
373
|
"./sri-*",
|
|
310
374
|
"./dedupe-*",
|
|
311
|
-
"./
|
|
375
|
+
"./contract-*",
|
|
376
|
+
"./expose-*",
|
|
377
|
+
"./capture-*",
|
|
378
|
+
"./channel-*"
|
|
312
379
|
]
|
|
313
380
|
},
|
|
314
381
|
{
|
|
315
382
|
"name": "routes",
|
|
316
383
|
"path": "dist/routes.js",
|
|
317
384
|
"import": "{ routes }",
|
|
318
|
-
"limit": "
|
|
385
|
+
"limit": "9.12 kB",
|
|
386
|
+
"ignore": [
|
|
387
|
+
"./overrides-*",
|
|
388
|
+
"./channel-*"
|
|
389
|
+
]
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"name": "single-spa",
|
|
393
|
+
"path": "dist/single-spa.js",
|
|
394
|
+
"import": "{ singleSpaRemote }",
|
|
395
|
+
"limit": "0.5 kB"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"name": "federation",
|
|
399
|
+
"path": "dist/federation.js",
|
|
400
|
+
"import": "{ federationRemote }",
|
|
401
|
+
"limit": "1.25 kB"
|
|
319
402
|
},
|
|
320
403
|
{
|
|
321
404
|
"name": "iframe",
|
|
322
405
|
"path": "dist/iframe.js",
|
|
323
406
|
"import": "{ enableIframe }",
|
|
324
|
-
"limit": "6 kB"
|
|
407
|
+
"limit": "6 kB",
|
|
408
|
+
"ignore": [
|
|
409
|
+
"./overrides-*",
|
|
410
|
+
"./channel-*"
|
|
411
|
+
]
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"name": "embed (loader de sites de terceiros, arquivo único com Shadow DOM, SRI e canal)",
|
|
415
|
+
"path": "dist/embed.js",
|
|
416
|
+
"limit": "11.95 kB"
|
|
325
417
|
}
|
|
326
418
|
],
|
|
327
419
|
"scripts": {
|
package/dist/chunk-DXORSF4X.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
protocol
|
|
3
|
-
} from "./chunk-GNPFWISJ.js";
|
|
4
|
-
|
|
5
|
-
// src/core/overrides.ts
|
|
6
|
-
var OVERRIDES_KEY = "vitral:overrides";
|
|
7
|
-
function overridesEnabled() {
|
|
8
|
-
return !!protocol().settings().devOverrides || typeof location !== "undefined" && /^(localhost|127\.0\.0\.1|\[::1\])$/.test(location.hostname);
|
|
9
|
-
}
|
|
10
|
-
var manifestUrl = (url) => /\.(json|m?js)(\?|$)/.test(url) ? url : url.replace(/\/?$/, "/vitral.json");
|
|
11
|
-
function storedOverrides() {
|
|
12
|
-
try {
|
|
13
|
-
return JSON.parse(localStorage.getItem(OVERRIDES_KEY) ?? "{}") ?? {};
|
|
14
|
-
} catch {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
var warned = /* @__PURE__ */ new Set();
|
|
19
|
-
function overrideFor(name) {
|
|
20
|
-
if (!overridesEnabled()) return;
|
|
21
|
-
const all = storedOverrides();
|
|
22
|
-
for (const pair of new URLSearchParams(location.search).getAll("vitral").join(",").split(",")) {
|
|
23
|
-
const at = pair.indexOf("@");
|
|
24
|
-
if (at > 0) all[pair.slice(0, at)] = pair.slice(at + 1);
|
|
25
|
-
}
|
|
26
|
-
if (!all[name]) return;
|
|
27
|
-
const url = new URL(manifestUrl(all[name]), location.href).href;
|
|
28
|
-
const p = protocol();
|
|
29
|
-
const trusted = p.settings().trusted ?? [];
|
|
30
|
-
const origin = new URL(url).origin;
|
|
31
|
-
if (!trusted.includes(origin)) p.configure({ trusted: [...trusted, origin] });
|
|
32
|
-
if (!warned.has(name)) console.warn(`[vitral] override ativo: ${name} \u2192 ${url}`), warned.add(name);
|
|
33
|
-
return { url };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
OVERRIDES_KEY,
|
|
38
|
-
overridesEnabled,
|
|
39
|
-
manifestUrl,
|
|
40
|
-
storedOverrides,
|
|
41
|
-
overrideFor
|
|
42
|
-
};
|
package/dist/chunk-SFL6LTP3.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addLink
|
|
3
|
-
} from "./chunk-PX7PBCCT.js";
|
|
4
|
-
import {
|
|
5
|
-
protocol
|
|
6
|
-
} from "./chunk-GNPFWISJ.js";
|
|
7
|
-
|
|
8
|
-
// src/core/css.ts
|
|
9
|
-
var loadedCss = /* @__PURE__ */ new WeakMap();
|
|
10
|
-
var cssText = /* @__PURE__ */ new Map();
|
|
11
|
-
var noop = () => {
|
|
12
|
-
};
|
|
13
|
-
var adopts = () => typeof CSSStyleSheet !== "undefined" && "replaceSync" in CSSStyleSheet.prototype;
|
|
14
|
-
function fetchCssText(href, integrity, priority) {
|
|
15
|
-
let p = cssText.get(href);
|
|
16
|
-
if (!p) {
|
|
17
|
-
p = fetch(href, { credentials: "omit", integrity, priority }).then((r) => r.ok ? r.text() : "").catch(() => "");
|
|
18
|
-
cssText.set(href, p);
|
|
19
|
-
}
|
|
20
|
-
return p;
|
|
21
|
-
}
|
|
22
|
-
function prefetchCss(urls, shadow, sri = {}, priority = "auto") {
|
|
23
|
-
for (const href of urls) {
|
|
24
|
-
if (shadow && adopts()) void fetchCssText(href, sri[href], priority);
|
|
25
|
-
else if (!document.querySelector(`link[href="${href}"]`)) addLink("preload", href, { as: "style", integrity: sri[href] ?? "", fetchPriority: priority });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function injectStyles(urls, root, el, styles, sri = {}) {
|
|
29
|
-
return root ? import("./shadow-MYRJQLLY.js").then((m) => m.attachStyles(root, el, urls, protocol().settings().styles, styles, sri)) : injectCss(urls, null, sri).then(() => noop);
|
|
30
|
-
}
|
|
31
|
-
function injectCss(urls, root, sri = {}) {
|
|
32
|
-
const owner = root ?? document;
|
|
33
|
-
let seen = loadedCss.get(owner);
|
|
34
|
-
if (!seen) loadedCss.set(owner, seen = /* @__PURE__ */ new Map());
|
|
35
|
-
const parent = root ?? document.head;
|
|
36
|
-
return Promise.all(
|
|
37
|
-
urls.map((href) => {
|
|
38
|
-
let p = seen.get(href);
|
|
39
|
-
if (!p) {
|
|
40
|
-
p = new Promise((resolve) => {
|
|
41
|
-
const link = addLink("stylesheet", href, { integrity: sri[href] ?? "" }, parent);
|
|
42
|
-
link.onload = link.onerror = () => resolve();
|
|
43
|
-
});
|
|
44
|
-
seen.set(href, p);
|
|
45
|
-
}
|
|
46
|
-
return p;
|
|
47
|
-
})
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export {
|
|
52
|
-
fetchCssText,
|
|
53
|
-
prefetchCss,
|
|
54
|
-
injectStyles,
|
|
55
|
-
injectCss
|
|
56
|
-
};
|
package/dist/expose-53BEJB34.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveModule,
|
|
3
|
-
resolveTarget,
|
|
4
|
-
splitName
|
|
5
|
-
} from "./chunk-HP6QWU6K.js";
|
|
6
|
-
import "./chunk-2XF5BKV3.js";
|
|
7
|
-
import "./chunk-SFL6LTP3.js";
|
|
8
|
-
import "./chunk-PX7PBCCT.js";
|
|
9
|
-
import "./chunk-GNPFWISJ.js";
|
|
10
|
-
export {
|
|
11
|
-
resolveModule,
|
|
12
|
-
resolveTarget,
|
|
13
|
-
splitName
|
|
14
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OVERRIDES_KEY,
|
|
3
|
-
manifestUrl,
|
|
4
|
-
overrideFor,
|
|
5
|
-
overridesEnabled,
|
|
6
|
-
storedOverrides
|
|
7
|
-
} from "./chunk-DXORSF4X.js";
|
|
8
|
-
import "./chunk-GNPFWISJ.js";
|
|
9
|
-
export {
|
|
10
|
-
OVERRIDES_KEY,
|
|
11
|
-
manifestUrl,
|
|
12
|
-
overrideFor,
|
|
13
|
-
overridesEnabled,
|
|
14
|
-
storedOverrides
|
|
15
|
-
};
|
package/dist/shadow-MYRJQLLY.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fetchCssText,
|
|
3
|
-
injectCss
|
|
4
|
-
} from "./chunk-SFL6LTP3.js";
|
|
5
|
-
import "./chunk-PX7PBCCT.js";
|
|
6
|
-
import "./chunk-GNPFWISJ.js";
|
|
7
|
-
|
|
8
|
-
// src/core/shadow.ts
|
|
9
|
-
var sheets = /* @__PURE__ */ new Map();
|
|
10
|
-
var hoisted = /* @__PURE__ */ new Set();
|
|
11
|
-
var RELATIVE_URL = /url\(\s*(['"]?)(?![a-z]+:|\/\/|#)([^'")]+)\1\s*\)/gi;
|
|
12
|
-
var GLOBAL_RULES = /@property\s+(--[\w-]+)\s*\{[^}]*\}|@font-face\s*\{[^}]*\}|@import\s+(?:url\(\s*)?(?:(['"])(.*?)\2|([^'"\s);]+))\s*\)?[^;]*;/gi;
|
|
13
|
-
async function attachStyles(root, el, css, global = {}, local = {}, sri = {}) {
|
|
14
|
-
const urls = [...global.inherit ?? [], ...local.inherit ?? []].map((u) => new URL(u, document.baseURI).href).concat(css);
|
|
15
|
-
if (typeof CSSStyleSheet !== "undefined" && "replaceSync" in CSSStyleSheet.prototype) {
|
|
16
|
-
const loaded = await Promise.all(urls.map((u) => loadSheet(u, [], sri[u])));
|
|
17
|
-
root.adoptedStyleSheets = [.../* @__PURE__ */ new Set([...root.adoptedStyleSheets, ...loaded.flat()])];
|
|
18
|
-
} else {
|
|
19
|
-
await injectCss(urls, root, sri);
|
|
20
|
-
}
|
|
21
|
-
return (local.mirrorTheme ?? global.mirrorTheme) === false ? () => {
|
|
22
|
-
} : mirrorTheme(el);
|
|
23
|
-
}
|
|
24
|
-
function loadSheet(href, chain, integrity) {
|
|
25
|
-
let p = sheets.get(href);
|
|
26
|
-
if (!p) {
|
|
27
|
-
p = fetchCssText(href, integrity).then((text) => {
|
|
28
|
-
const up = [];
|
|
29
|
-
const imports = [];
|
|
30
|
-
const rest = text.replace(RELATIVE_URL, (_, q, u) => `url(${q}${new URL(u, href).href}${q})`).replace(GLOBAL_RULES, (rule, prop, _q, quoted, bare) => {
|
|
31
|
-
const url = quoted ?? bare;
|
|
32
|
-
if (url) imports.push(new URL(url, href).href);
|
|
33
|
-
else if (!hoisted.has(prop ?? rule)) {
|
|
34
|
-
hoisted.add(prop ?? rule);
|
|
35
|
-
up.push(rule);
|
|
36
|
-
}
|
|
37
|
-
return "";
|
|
38
|
-
});
|
|
39
|
-
if (up.length) {
|
|
40
|
-
const style = document.createElement("style");
|
|
41
|
-
style.setAttribute("data-vitral-properties", "");
|
|
42
|
-
style.textContent = up.join("\n");
|
|
43
|
-
document.head.appendChild(style);
|
|
44
|
-
}
|
|
45
|
-
const sheet = new CSSStyleSheet();
|
|
46
|
-
sheet.replaceSync(rest);
|
|
47
|
-
const next = [...chain, href];
|
|
48
|
-
return Promise.all(imports.filter((u) => !next.includes(u)).map((u) => loadSheet(u, next))).then((found) => [...found.flat(), sheet]);
|
|
49
|
-
}).catch(() => []);
|
|
50
|
-
sheets.set(href, p);
|
|
51
|
-
}
|
|
52
|
-
return p;
|
|
53
|
-
}
|
|
54
|
-
function mirrorTheme(el) {
|
|
55
|
-
const html = document.documentElement;
|
|
56
|
-
let added = [];
|
|
57
|
-
const sync = () => {
|
|
58
|
-
el.classList.remove(...added);
|
|
59
|
-
added = [...html.classList].filter((c) => !el.classList.contains(c));
|
|
60
|
-
el.classList.add(...added);
|
|
61
|
-
const theme = html.getAttribute("data-theme");
|
|
62
|
-
if (theme === null) el.removeAttribute("data-theme");
|
|
63
|
-
else el.setAttribute("data-theme", theme);
|
|
64
|
-
};
|
|
65
|
-
sync();
|
|
66
|
-
const observer = new MutationObserver(sync);
|
|
67
|
-
observer.observe(html, { attributeFilter: ["class", "data-theme"] });
|
|
68
|
-
return () => observer.disconnect();
|
|
69
|
-
}
|
|
70
|
-
export {
|
|
71
|
-
attachStyles
|
|
72
|
-
};
|