10
10
11
11
* [ AbstractPath] ( README.md#abstractpath )
12
12
* [ Cache] ( README.md#cache )
13
+ * [ ContentData] ( README.md#contentdata )
13
14
* [ CustomBlock] ( README.md#customblock )
14
15
* [ CustomBlockCallback] ( README.md#customblockcallback )
15
16
* [ File] ( README.md#file )
44
45
45
46
Ƭ ** AbstractPath** : { toString: () => string }
46
47
47
- * Defined in [ types.ts:24 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L24 ) *
48
+ * Defined in [ types.ts:29 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L29 ) *
48
49
49
50
#### Type declaration:
50
51
58
59
59
60
Ƭ ** Cache** : { get: (key: string) => Promise<string\> ; set: (key: string, value: string) => Promise<void\> }
60
61
61
- * Defined in [ types.ts:15 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L15 ) *
62
+ * Defined in [ types.ts:20 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L20 ) *
62
63
63
64
#### Type declaration:
64
65
@@ -69,11 +70,19 @@ Name | Type |
69
70
70
71
___
71
72
73
+ ### ContentData
74
+
75
+ Ƭ ** ContentData** : string \| ArrayBuffer
76
+
77
+ * Defined in [ types.ts:71] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0/src/types.ts#L71 ) *
78
+
79
+ ___
80
+
72
81
### CustomBlock
73
82
74
83
Ƭ ** CustomBlock** : { attrs: Record<string, string \| true\> ; content: string ; type: string }
75
84
76
- * Defined in [ types.ts:101 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L101 ) *
85
+ * Defined in [ types.ts:109 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L109 ) *
77
86
78
87
A custom block
79
88
91
100
92
101
Ƭ ** CustomBlockCallback** : (component: [ ModuleExport] ( README.md#moduleexport ) ) => void
93
102
94
- * Defined in [ types.ts:95 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L95 ) *
103
+ * Defined in [ types.ts:103 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L103 ) *
95
104
96
105
CustomBlockCallback function type
97
106
98
107
___
99
108
100
109
### File
101
110
102
- Ƭ ** File** : { content: string \| ArrayBuffer ; type: string }
111
+ Ƭ ** File** : { getContentData: (asBinary: Boolean) => Promise< [ ContentData ] ( README.md#contentdata ) \> ; type: string }
103
112
104
- * Defined in [ types.ts:69 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L69 ) *
113
+ * Defined in [ types.ts:77 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L77 ) *
105
114
106
115
Represents a file content and the extension name.
107
116
108
117
#### Type declaration:
109
118
110
119
Name | Type | Description |
111
120
------ | ------ | ------ |
112
- ` content ` | string \| ArrayBuffer | The content data |
121
+ ` getContentData ` | (asBinary: Boolean) => Promise< [ ContentData ] ( README.md#contentdata ) \> | The content data accessor (request data as text of binary) |
113
122
` type ` | string | The content type (file extension name, eg. '.svg' ) |
114
123
115
124
___
@@ -118,15 +127,15 @@ ___
118
127
119
128
Ƭ ** LangProcessor** : (source: string, preprocessOptions?: any) => Promise<string\> \| string
120
129
121
- * Defined in [ types.ts:374 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L374 ) *
130
+ * Defined in [ types.ts:399 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L399 ) *
122
131
123
132
___
124
133
125
134
### Module
126
135
127
136
Ƭ ** Module** : { exports: [ ModuleExport] ( README.md#moduleexport ) }
128
137
129
- * Defined in [ types.ts:121 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L121 ) *
138
+ * Defined in [ types.ts:129 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L129 ) *
130
139
131
140
This just represents a loaded js module
132
141
@@ -142,25 +151,25 @@ ___
142
151
143
152
Ƭ ** ModuleCacheId** : string
144
153
145
- * Defined in [ types.ts:21 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L21 ) *
154
+ * Defined in [ types.ts:26 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L26 ) *
146
155
147
156
___
148
157
149
158
### ModuleExport
150
159
151
160
Ƭ ** ModuleExport** : {}
152
161
153
- * Defined in [ types.ts:115 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L115 ) *
162
+ * Defined in [ types.ts:123 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L123 ) *
154
163
155
164
This just represents a loaded js module exports
156
165
157
166
___
158
167
159
168
### ModuleHandler
160
169
161
- Ƭ ** ModuleHandler** : (type: string, source: string , path: [ AbstractPath] ( README.md#abstractpath ) , options: [ Options] ( README.md#options ) ) => Promise<[ ModuleExport] ( README.md#moduleexport ) \| null\>
170
+ Ƭ ** ModuleHandler** : (type: string, getContentData: File [ \" getContentData \" ] , path: [ AbstractPath] ( README.md#abstractpath ) , options: [ Options] ( README.md#options ) ) => Promise<[ ModuleExport] ( README.md#moduleexport ) \| null\>
162
171
163
- * Defined in [ types.ts:63 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L63 ) *
172
+ * Defined in [ types.ts:68 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L68 ) *
164
173
165
174
Used by the library when it does not know how to handle a given file type (eg. ` .json ` files).
166
175
see [[ moduleHandlers]]
@@ -185,23 +194,24 @@ ___
185
194
186
195
### Options
187
196
188
- Ƭ **Options**: { 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)\> ; 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 }
197
+ Ƭ **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 }
189
198
190
- * Defined in [ types.ts:132 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L132 ) *
199
+ * Defined in [ types.ts:140 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L140 ) *
191
200
192
201
#### Type declaration:
193
202
194
203
Name | Type | Description |
195
204
------ | ------ | ------ |
205
+ ` additionalBabelParserPlugins? ` | babel\_ ParserPlugin[ ] | Additional babel parser plugins. [ TBD] ``` javascript ... ... ``` |
196
206
` additionalBabelPlugins? ` | Record<string, any\> | Additional babel plugins. [ TBD] ``` javascript ... ... ``` |
197
207
`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); }, }, ... ``` |
198
208
` 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> ... ``` |
199
209
` handleModule? ` | [ ModuleHandler] ( README.md#modulehandler ) | Handle additional module types (eg. '.svg', '.json' ). see [ ModuleHandler] ( README.md#modulehandler ) |
200
- ` 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 for the lib. If you do not provide it, the library will create one. 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, }), ... ``` |
210
+ ` 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, }), ... ``` |
201
211
` pathResolve ` | [ PathResolve] ( README.md#pathresolve ) | Abstact path handling |
202
212
` addStyle ` | (style: string, scopeId: string \| undefined) => void | - |
203
213
` customBlockHandler? ` | (block: [ CustomBlock] ( README.md#customblock ) , filename: [ AbstractPath] ( README.md#abstractpath ) , options: [ Options] ( README.md#options ) ) => Promise<[ CustomBlockCallback] ( README.md#customblockcallback ) \| undefined\> | - |
204
- ` getFile ` | (path: [ AbstractPath] ( README.md#abstractpath ) ) => Promise<[ File] ( README.md#file ) \> | - |
214
+ ` getFile ` | (path: [ AbstractPath] ( README.md#abstractpath ) ) => Promise<[ File] ( README.md#file ) \| [ ContentData ] ( README.md#contentdata ) \> | - |
205
215
` getResource ` | (pathCx: [ PathContext] ( README.md#pathcontext ) , options: [ Options] ( README.md#options ) ) => [ Resource] ( README.md#resource ) | - |
206
216
` loadModule? ` | (path: [ AbstractPath] ( README.md#abstractpath ) , options: [ Options] ( README.md#options ) ) => Promise<[ ModuleExport] ( README.md#moduleexport ) \| undefined\> | - |
207
217
` log? ` | (type: string, ...data: any[ ] ) => void | - |
212
222
213
223
Ƭ ** PathContext** : { refPath: [ AbstractPath] ( README.md#abstractpath ) ; relPath: [ AbstractPath] ( README.md#abstractpath ) }
214
224
215
- * Defined in [ types.ts:33 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L33 ) *
225
+ * Defined in [ types.ts:38 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L38 ) *
216
226
217
227
A PathContext represents a path (relPath) relative to an abolute path (refPath)
218
228
Note that relPath is not necessary relative, but it is, relPath is relative to refPath.
230
240
231
241
Ƭ ** PathResolve** : (pathCx: [ PathContext] ( README.md#pathcontext ) ) => [ AbstractPath] ( README.md#abstractpath )
232
242
233
- * Defined in [ types.ts:42 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L42 ) *
243
+ * Defined in [ types.ts:47 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L47 ) *
234
244
235
245
relative to absolute module path resolution
236
246
240
250
241
251
Ƭ ** Resource** : { getContent: () => Promise<[ File] ( README.md#file ) \> ; id: [ ModuleCacheId] ( README.md#modulecacheid ) ; path: [ AbstractPath] ( README.md#abstractpath ) }
242
252
243
- * Defined in [ types.ts:80 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/types.ts#L80 ) *
253
+ * Defined in [ types.ts:88 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/types.ts#L88 ) *
244
254
245
255
Represents a resource.
246
256
@@ -258,9 +268,9 @@ Name | Type | Description |
258
268
259
269
• ` Const ` ** version** : string = process.env.VERSION
260
270
261
- * Defined in [ tools.ts:53] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/tools.ts#L53 ) *
271
+ * Defined in [ tools.ts:53] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/tools.ts#L53 ) *
262
272
263
- * Defined in [ index.ts:24 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/index.ts#L24 ) *
273
+ * Defined in [ index.ts:26 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/index.ts#L26 ) *
264
274
265
275
the version of the library (process.env.VERSION is set by webpack, at compile-time)
266
276
@@ -270,15 +280,15 @@ ___
270
280
271
281
• ` Const ` ** vueVersion** : string
272
282
273
- * Defined in [ createSFCModule.ts:4] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/createSFCModule.ts#L4 ) *
283
+ * Defined in [ createSFCModule.ts:4] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/createSFCModule.ts#L4 ) *
274
284
275
285
## Functions
276
286
277
287
### buildTemplateProcessor
278
288
279
289
▸ ** buildTemplateProcessor** (` processor ` : [ LangProcessor] ( README.md#langprocessor ) ): object
280
290
281
- * Defined in [ index.ts:157 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/index.ts#L157 ) *
291
+ * Defined in [ index.ts:179 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/index.ts#L179 ) *
282
292
283
293
Convert a function to template processor interface (consolidate)
284
294
300
310
301
311
▸ ** createSFCModule** (` source ` : string, ` filename ` : [ AbstractPath] ( README.md#abstractpath ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \>
302
312
303
- * Defined in [ createSFCModule.ts:3] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/createSFCModule.ts#L3 ) *
313
+ * Defined in [ createSFCModule.ts:3] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/createSFCModule.ts#L3 ) *
304
314
305
315
#### Parameters:
306
316
318
328
319
329
▸ ** defaultGetResource** (` pathCx ` : [ PathContext] ( README.md#pathcontext ) , ` options ` : [ Options] ( README.md#options ) ): [ Resource] ( README.md#resource )
320
330
321
- * Defined in [ index.ts:73 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/index.ts#L73 ) *
331
+ * Defined in [ index.ts:76 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/index.ts#L76 ) *
322
332
323
333
Default getResource implementation
324
334
by default, getContent() use the file extension as file type.
336
346
337
347
### defaultHandleModule
338
348
339
- ▸ ** defaultHandleModule** (` type ` : string, ` source ` : string , ` path ` : [ AbstractPath] ( README.md#abstractpath ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \| null\>
349
+ ▸ ** defaultHandleModule** (` type ` : string, ` getContentData ` : File [ \" getContentData \" ] , ` path ` : [ AbstractPath] ( README.md#abstractpath ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \| null\>
340
350
341
- * Defined in [ tools.ts:377 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/tools.ts#L377 ) *
351
+ * Defined in [ tools.ts:372 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/tools.ts#L372 ) *
342
352
343
353
Default implementation of handleModule
344
354
@@ -347,7 +357,7 @@ Default implementation of handleModule
347
357
Name | Type |
348
358
------ | ------ |
349
359
` type ` | string |
350
- ` source ` | string |
360
+ ` getContentData ` | File [ \" getContentData \" ] |
351
361
` path ` | [ AbstractPath] ( README.md#abstractpath ) |
352
362
` options ` | [ Options] ( README.md#options ) |
353
363
359
369
360
370
▸ ` Const ` ** defaultPathResolve** (` __namedParameters ` : { refPath: [ AbstractPath] ( README.md#abstractpath ) ; relPath: [ AbstractPath] ( README.md#abstractpath ) }): string \| [ AbstractPath] ( README.md#abstractpath )
361
371
362
- * Defined in [ index.ts:50 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/index.ts#L50 ) *
372
+ * Defined in [ index.ts:53 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/index.ts#L53 ) *
363
373
364
374
Default resolve implementation
365
375
resolve() should handle 3 situations :
381
391
382
392
▸ ** loadModule** (` path ` : [ AbstractPath] ( README.md#abstractpath ) , ` options? ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \>
383
393
384
- * Defined in [ index.ts:130 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/index.ts#L130 ) *
394
+ * Defined in [ index.ts:152 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/index.ts#L152 ) *
385
395
386
396
This is the main function.
387
397
This function is intended to be used only to load the entry point of your application.
435
445
436
446
▸ ** loadModuleInternal** (` pathCx ` : [ PathContext] ( README.md#pathcontext ) , ` options ` : [ Options] ( README.md#options ) ): Promise<[ ModuleExport] ( README.md#moduleexport ) \>
437
447
438
- * Defined in [ tools.ts:262 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/23ba651 /src/tools.ts#L262 ) *
448
+ * Defined in [ tools.ts:260 ] ( https://github.com/FranckFreiburger/vue3-sfc-loader/blob/04817e0 /src/tools.ts#L260 ) *
439
449
440
450
#### Parameters:
441
451
0 commit comments