49
49
50
50
Ƭ ** AbstractPath** : { toString: () => string }
51
51
52
- * Defined in [ types.ts:32] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L32 ) *
52
+ * Defined in [ types.ts:32] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L32 ) *
53
53
54
54
An abstract way to specify a path. It could be a simple string or a object like an URL. An AbstractPath must always be convertible to a string.
55
55
65
65
66
66
Ƭ ** Cache** : { get: (key: string) => Promise<string\> ; set: (key: string, value: string) => Promise<void\> }
67
67
68
- * Defined in [ types.ts:20] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L20 ) *
68
+ * Defined in [ types.ts:20] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L20 ) *
69
69
70
70
#### Type declaration:
71
71
80
80
81
81
Ƭ ** ContentData** : string \| ArrayBuffer
82
82
83
- * Defined in [ types.ts:71] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L71 ) *
83
+ * Defined in [ types.ts:71] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L71 ) *
84
84
85
85
___
86
86
87
87
### CustomBlock
88
88
89
89
Ƭ ** CustomBlock** : { attrs: Record<string, string \| true\> ; content: string ; type: string }
90
90
91
- * Defined in [ types.ts:109] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L109 ) *
91
+ * Defined in [ types.ts:109] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L109 ) *
92
92
93
93
A custom block
94
94
106
106
107
107
Ƭ ** CustomBlockCallback** : (component: [ ModuleExport] ( README.md#moduleexport ) ) => void
108
108
109
- * Defined in [ types.ts:103] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L103 ) *
109
+ * Defined in [ types.ts:103] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L103 ) *
110
110
111
111
CustomBlockCallback function type
112
112
116
116
117
117
Ƭ ** File** : { getContentData: (asBinary: Boolean) => Promise<[ ContentData] ( README.md#contentdata ) \> ; type: string }
118
118
119
- * Defined in [ types.ts:77] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L77 ) *
119
+ * Defined in [ types.ts:77] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L77 ) *
120
120
121
121
Represents a file content and the extension name.
122
122
@@ -133,15 +133,15 @@ ___
133
133
134
134
Ƭ ** LangProcessor** : (source: string, preprocessOptions?: any) => Promise<string\> \| string
135
135
136
- * Defined in [ types.ts:399 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L399 ) *
136
+ * Defined in [ types.ts:422 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L422 ) *
137
137
138
138
___
139
139
140
140
### Module
141
141
142
142
Ƭ ** Module** : { exports: [ ModuleExport] ( README.md#moduleexport ) }
143
143
144
- * Defined in [ types.ts:129 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L129 ) *
144
+ * Defined in [ types.ts:128 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L128 ) *
145
145
146
146
This just represents a loaded js module
147
147
@@ -157,15 +157,15 @@ ___
157
157
158
158
Ƭ ** ModuleCacheId** : string
159
159
160
- * Defined in [ types.ts:26] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L26 ) *
160
+ * Defined in [ types.ts:26] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L26 ) *
161
161
162
162
___
163
163
164
164
### ModuleExport
165
165
166
- Ƭ ** ModuleExport** : {}
166
+ Ƭ ** ModuleExport** : {} \| null
167
167
168
- * Defined in [ types.ts:123] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L123 ) *
168
+ * Defined in [ types.ts:123] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L123 ) *
169
169
170
170
This just represents a loaded js module exports
171
171
175
175
176
176
Ƭ ** ModuleHandler** : (type: string, getContentData: File[ \" getContentData\" ] , path: [ AbstractPath] ( README.md#abstractpath ) , options: [ Options] ( README.md#options ) ) => Promise<[ ModuleExport] ( README.md#moduleexport ) \| null\>
177
177
178
- * Defined in [ types.ts:68] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L68 ) *
178
+ * Defined in [ types.ts:68] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L68 ) *
179
179
180
180
Used by the library when it needs to handle a does not know how to handle a given file type (eg. ` .json ` files).
181
181
198
198
199
199
### Options
200
200
201
- Ƭ **Options**: { additionalBabelParserPlugins?: babel\_ParserPlugin[] ; additionalBabelPlugins?: Record<string, any\> ; compiledCache?: [Cache](README.md#cache) ; delimiters?: [string, string] ; handleModule?: [ModuleHandler](README.md#modulehandler) ; moduleCache: Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> ; pathResolve: [PathResolve](README.md#pathresolve) ; addStyle: (style: string, scopeId: string \| undefined) => void ; customBlockHandler?: (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> ; getFile: (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> ; getResource: (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) ; loadModule?: (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> ; log?: (type: string, ...data: any[]) => void }
201
+ Ƭ **Options**: { additionalBabelParserPlugins?: babel\_ParserPlugin[] ; additionalBabelPlugins?: Record<string, any\> ; compiledCache?: [Cache](README.md#cache) ; delimiters?: [string, string] ; devMode?: boolean ; handleModule?: [ModuleHandler](README.md#modulehandler) ; isCustomElement: (tag: string) => boolean \| undefined ; moduleCache: Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> ; pathResolve: [PathResolve](README.md#pathresolve) ; whitespace?: \"preserve\" \| \"condense\" ; addStyle: (style: string, scopeId: string \| undefined) => void ; customBlockHandler?: (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> ; getFile: (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> ; getResource: (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) ; loadModule?: (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> ; log?: (type: string, ...data: any[]) => void }
202
202
203
- * Defined in [ types.ts:140 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L140 ) *
203
+ * Defined in [ types.ts:139 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L139 ) *
204
204
205
205
#### Type declaration:
206
206
@@ -210,9 +210,12 @@ Name | Type | Description |
210
210
` additionalBabelPlugins? ` | Record<string, any\> | Additional babel plugins. [ TBD] ``` javascript ... ... ``` |
211
211
`compiledCache?` | [Cache](README.md#cache) | [get](README.md#get)() and [set](README.md#set)() functions of this object are called when the lib needs to save or load already compiled code. get and set functions must return a `Promise` (or can be `async`). Since compilation consume a lot of CPU, is is always a good idea to provide this object. **example:** In the following example, we cache the compiled code in the browser's local storage. Note that local storage is a limited place (usually 5MB). Here we handle space limitation in a very basic way. Maybe (not tested), the following libraries may help you to gain more space [pako](https://github.com/nodeca/pako), [lz-string](https://github.com/pieroxy/lz-string/) ```javascript ... compiledCache: { set(key, str) { // naive storage space management for (;;) { try { // doc: https://developer.mozilla.org/en-US/docs/Web/API/Storage window.localStorage.setItem(key, str); break; } catch(ex) { // here we handle DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'XXX' exceeded the quota window.localStorage.removeItem(window.localStorage.key(0)); } } }, get(key) { return window.localStorage.getItem(key); }, }, ... ``` |
212
212
` delimiters? ` | [ string, string] | Sets the delimiters used for text interpolation within the template. Typically this is used to avoid conflicting with server-side frameworks that also use mustache syntax. ``` javascript ... <script> // <!-- const vueContent = ` <template> Hello [[[[ who ]]]] !</template> <script> export default { data() { return { who: 'world' } } } </script> `; // --> const options = { moduleCache: { vue: Vue }, getFile: () => vueContent, addStyle: () => {}, delimiters: ['[[[[', ']]]]'], } const app = Vue.createApp(Vue.defineAsyncComponent(() => window['vue3-sfc-loader'].loadModule('file.vue', options))); app.mount(document.body); </script> ... ``` |
213
+ ` devMode? ` | boolean | Set development mode prevent minification, allow debugger statement, |
213
214
` handleModule? ` | [ ModuleHandler] ( README.md#modulehandler ) | Handle additional module types (eg. '.svg', '.json' ). see [ ModuleHandler] ( README.md#modulehandler ) |
215
+ ` isCustomElement ` | (tag: string) => boolean \| undefined | Specifies a check method to recognize native custom elements. see. https://vuejs.org/api/application.html#app-config-compileroptions-iscustomelement note: this option has no effect on vue2 |
214
216
` moduleCache ` | Record<[ ModuleCacheId] ( README.md#modulecacheid ) , LoadingType<[ ModuleExport] ( README.md#moduleexport ) \> \| [ ModuleExport] ( README.md#moduleexport ) \> | Initial cache that will contain resolved dependencies. All new modules go here. ` vue ` must initially be contained in this object. [ moduleCache] ( README.md#modulecache ) is mandatory and should be shared between options objects used for you application (note that you can also pass the same options object through multiple loadModule calls) It is recommended to provide a prototype-less object (` Object.create(null) ` ) to avoid potential conflict with ` Object ` properties (constructor, __ proto__ , hasOwnProperty, ...). * See also [[ options.loadModule]] . ** example:** ``` javascript ... moduleCache: Object.assign(Object.create(null), { vue: Vue, }), ... ``` |
215
217
` pathResolve ` | [ PathResolve] ( README.md#pathresolve ) | Abstact path handling |
218
+ ` whitespace? ` | \" preserve\" \| \" condense\" | Whitespace handling strategy see https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler#options |
216
219
` addStyle ` | (style: string, scopeId: string \| undefined) => void | - |
217
220
` customBlockHandler? ` | (block: [ CustomBlock] ( README.md#customblock ) , filename: [ AbstractPath] ( README.md#abstractpath ) , options: [ Options] ( README.md#options ) ) => Promise<[ CustomBlockCallback] ( README.md#customblockcallback ) \| undefined\> | - |
218
221
` getFile ` | (path: [ AbstractPath] ( README.md#abstractpath ) ) => Promise<[ File] ( README.md#file ) \| [ ContentData] ( README.md#contentdata ) \> | - |
@@ -226,10 +229,10 @@ ___
226
229
227
230
Ƭ ** PathContext** : { refPath: [ AbstractPath] ( README.md#abstractpath ) ; relPath: [ AbstractPath] ( README.md#abstractpath ) }
228
231
229
- * Defined in [ types.ts:41] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L41 ) *
232
+ * Defined in [ types.ts:41] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L41 ) *
230
233
231
234
A PathContext represents a path (relPath) relative to an abolute path (refPath)
232
- Note that relPath is not necessary relative, but it is, relPath is relative to refPath.
235
+ Note that relPath is not necessary relative, but when it is, relPath is relative to refPath.
233
236
234
237
#### Type declaration:
235
238
244
247
245
248
Ƭ ** PathResolve** : (pathCx: [ PathContext] ( README.md#pathcontext ) ) => [ AbstractPath] ( README.md#abstractpath )
246
249
247
- * Defined in [ types.ts:50] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L50 ) *
250
+ * Defined in [ types.ts:50] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L50 ) *
248
251
249
252
relative to absolute module path resolution
250
253
254
257
255
258
Ƭ ** Resource** : { getContent: () => Promise<[ File] ( README.md#file ) \> ; id: [ ModuleCacheId] ( README.md#modulecacheid ) ; path: [ AbstractPath] ( README.md#abstractpath ) }
256
259
257
- * Defined in [ types.ts:88] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/types.ts#L88 ) *
260
+ * Defined in [ types.ts:88] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/types.ts#L88 ) *
258
261
259
262
Represents a resource.
260
263
@@ -270,11 +273,11 @@ Name | Type | Description |
270
273
271
274
### version
272
275
273
- • ` Const ` ** version** : string = process.env.VERSION
276
+ • ` Const ` ** version** : string = process.env.VERSION as string
274
277
275
- * Defined in [ tools.ts:47 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/tools.ts#L47 ) *
278
+ * Defined in [ tools.ts:49 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/tools.ts#L49 ) *
276
279
277
- * Defined in [ index.ts:26] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/index.ts#L26 ) *
280
+ * Defined in [ index.ts:26] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/index.ts#L26 ) *
278
281
279
282
the version of the library (process.env.VERSION is set by webpack, at compile-time)
280
283
@@ -284,15 +287,15 @@ ___
284
287
285
288
• ` Const ` ** vueVersion** : string
286
289
287
- * Defined in [ createSFCModule.ts:4] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/createSFCModule.ts#L4 ) *
290
+ * Defined in [ createSFCModule.ts:4] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/createSFCModule.ts#L4 ) *
288
291
289
292
## Functions
290
293
291
294
### buildTemplateProcessor
292
295
293
296
▸ ** buildTemplateProcessor** (` processor ` : [ LangProcessor] ( README.md#langprocessor ) ): object
294
297
295
- * Defined in [ index.ts:179 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/index.ts#L179 ) *
298
+ * Defined in [ index.ts:184 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/index.ts#L184 ) *
296
299
297
300
Convert a function to template processor interface (consolidate)
298
301
314
317
315
318
▸ ** createSFCModule** (` source ` : string, ` filename ` : [ AbstractPath] ( README.md#abstractpath ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \>
316
319
317
- * Defined in [ createSFCModule.ts:3] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/createSFCModule.ts#L3 ) *
320
+ * Defined in [ createSFCModule.ts:3] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/createSFCModule.ts#L3 ) *
318
321
319
322
#### Parameters:
320
323
332
335
333
336
▸ ** defaultGetResource** (` pathCx ` : [ PathContext] ( README.md#pathcontext ) , ` options ` : [ Options] ( README.md#options ) ): [ Resource] ( README.md#resource )
334
337
335
- * Defined in [ index.ts:76] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/index.ts#L76 ) *
338
+ * Defined in [ index.ts:76] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/index.ts#L76 ) *
336
339
337
340
Default getResource implementation
338
341
by default, getContent() use the file extension as file type.
350
353
351
354
### defaultHandleModule
352
355
353
- ▸ ** defaultHandleModule** (` type ` : string, ` getContentData ` : File[ \" getContentData\" ] , ` path ` : [ AbstractPath] ( README.md#abstractpath ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \| null \>
356
+ ▸ ** defaultHandleModule** (` type ` : string, ` getContentData ` : File[ \" getContentData\" ] , ` path ` : [ AbstractPath] ( README.md#abstractpath ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \| undefined \>
354
357
355
- * Defined in [ tools.ts:370 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/tools.ts#L370 ) *
358
+ * Defined in [ tools.ts:388 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/tools.ts#L388 ) *
356
359
357
360
Default implementation of handleModule
358
361
@@ -365,15 +368,15 @@ Name | Type |
365
368
` path ` | [ AbstractPath] ( README.md#abstractpath ) |
366
369
` options ` | [ Options] ( README.md#options ) |
367
370
368
- ** Returns:** Promise<[ ModuleExport] ( README.md#moduleexport ) \| null \>
371
+ ** Returns:** Promise<[ ModuleExport] ( README.md#moduleexport ) \| undefined \>
369
372
370
373
___
371
374
372
375
### defaultPathResolve
373
376
374
377
▸ ` Const ` ** defaultPathResolve** (` __namedParameters ` : { refPath: [ AbstractPath] ( README.md#abstractpath ) ; relPath: [ AbstractPath] ( README.md#abstractpath ) }): string \| [ AbstractPath] ( README.md#abstractpath )
375
378
376
- * Defined in [ index.ts:53] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/index.ts#L53 ) *
379
+ * Defined in [ index.ts:53] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/index.ts#L53 ) *
377
380
378
381
Default resolve implementation
379
382
resolve() should handle 3 situations :
@@ -395,11 +398,11 @@ ___
395
398
396
399
▸ ** loadModule** (` path ` : [ AbstractPath] ( README.md#abstractpath ) , ` options? ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \>
397
400
398
- * Defined in [ index.ts:152 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/index.ts#L152 ) *
401
+ * Defined in [ index.ts:157 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/index.ts#L157 ) *
399
402
400
403
This is the main function.
401
404
This function is intended to be used only to load the entry point of your application.
402
- If for some reason you need to use it in your components, be sure to share at least the options.` compiledCache ` object between all calls.
405
+ If for some reason you need to use it in your components, be sure to share at least the options.` moduleCache ` object between all calls.
403
406
404
407
#### Parameters:
405
408
449
452
450
453
▸ ** loadModuleInternal** (` pathCx ` : [ PathContext] ( README.md#pathcontext ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \>
451
454
452
- * Defined in [ tools.ts:258 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/tools.ts#L258 ) *
455
+ * Defined in [ tools.ts:276 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/tools.ts#L276 ) *
453
456
454
457
#### Parameters:
455
458
@@ -466,6 +469,6 @@ Name | Type |
466
469
467
470
▪ ` Const ` ** targetBrowserBabelPlugins** : object
468
471
469
- * Defined in [ tools.ts:205 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4211825 /src/tools.ts#L205 ) *
472
+ * Defined in [ tools.ts:211 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/70777c8 /src/tools.ts#L211 ) *
470
473
471
474
#### Properties:
0 commit comments