@format.dev/vue 0.0.0 → 0.1.1

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/dist/index.cjs ADDED
@@ -0,0 +1,534 @@
1
+ let vue = require("vue");
2
+
3
+ //#region src/Template.vue
4
+ const _sfc_main$17 = /* @__PURE__ */ (0, vue.defineComponent)({
5
+ __name: "Template",
6
+ setup(__props) {
7
+ const attrs = (0, vue.useAttrs)();
8
+ const slots = (0, vue.useSlots)();
9
+ const tpl = (0, vue.ref)(null);
10
+ (0, vue.onMounted)(() => {
11
+ const el = tpl.value;
12
+ if (!el) return;
13
+ if (el.content.childNodes.length === 0) Array.from(el.childNodes).forEach((node) => el.content.appendChild(node));
14
+ });
15
+ const render = () => (0, vue.h)("template", {
16
+ ...attrs,
17
+ ref: tpl
18
+ }, slots.default?.() ?? []);
19
+ return (_ctx, _cache) => {
20
+ return (0, vue.openBlock)(), (0, vue.createBlock)(render);
21
+ };
22
+ }
23
+ });
24
+ var Template_default = _sfc_main$17;
25
+
26
+ //#endregion
27
+ //#region src/engine-target.ts
28
+ const engineTarget = "0.1.0";
29
+
30
+ //#endregion
31
+ //#region src/sdk-version.ts
32
+ const sdkVersion = "0.1.1";
33
+
34
+ //#endregion
35
+ //#region src/Document.vue
36
+ const _sfc_main$16 = /* @__PURE__ */ (0, vue.defineComponent)({
37
+ inheritAttrs: false,
38
+ __name: "Document",
39
+ props: {
40
+ title: {},
41
+ subject: {},
42
+ author: {},
43
+ keywords: {},
44
+ fonts: {}
45
+ },
46
+ setup(__props) {
47
+ const props = __props;
48
+ const keywordsString = (0, vue.computed)(() => props.keywords?.join(", ") || void 0);
49
+ return (_ctx, _cache) => {
50
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
51
+ "data-sdk": (0, vue.unref)(sdkVersion),
52
+ "data-engine": (0, vue.unref)(engineTarget),
53
+ "data-type": "document",
54
+ "data-title": __props.title,
55
+ "data-subject": __props.subject,
56
+ "data-author": __props.author,
57
+ "data-keywords": keywordsString.value,
58
+ "data-fonts": __props.fonts
59
+ }, {
60
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
61
+ _: 3
62
+ }, 8, [
63
+ "data-sdk",
64
+ "data-engine",
65
+ "data-title",
66
+ "data-subject",
67
+ "data-author",
68
+ "data-keywords",
69
+ "data-fonts"
70
+ ]);
71
+ };
72
+ }
73
+ });
74
+ var Document_default = _sfc_main$16;
75
+
76
+ //#endregion
77
+ //#region src/Layout.vue
78
+ const _sfc_main$15 = /* @__PURE__ */ (0, vue.defineComponent)({
79
+ __name: "Layout",
80
+ props: {
81
+ id: {},
82
+ width: {},
83
+ height: {},
84
+ paginationStrategy: {},
85
+ splitGranularity: {}
86
+ },
87
+ setup(__props) {
88
+ const props = __props;
89
+ const widthPx = (0, vue.computed)(() => `${props.width}px`);
90
+ const heightPx = (0, vue.computed)(() => `${props.height}px`);
91
+ return (_ctx, _cache) => {
92
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
93
+ "data-type": "layout",
94
+ "data-id": __props.id,
95
+ "data-width": widthPx.value,
96
+ "data-height": heightPx.value,
97
+ "data-pagination-strategy": __props.paginationStrategy,
98
+ "data-split-granularity": __props.splitGranularity
99
+ }, {
100
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
101
+ _: 3
102
+ }, 8, [
103
+ "data-id",
104
+ "data-width",
105
+ "data-height",
106
+ "data-pagination-strategy",
107
+ "data-split-granularity"
108
+ ]);
109
+ };
110
+ }
111
+ });
112
+ var Layout_default = _sfc_main$15;
113
+
114
+ //#endregion
115
+ //#region src/Flow.vue
116
+ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
117
+ __name: "Flow",
118
+ props: {
119
+ splitGranularity: {},
120
+ paginationStrategy: {},
121
+ scope: {}
122
+ },
123
+ setup(__props) {
124
+ return (_ctx, _cache) => {
125
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
126
+ "data-type": "flow",
127
+ "data-split-granularity": __props.splitGranularity,
128
+ "data-pagination-strategy": __props.paginationStrategy,
129
+ "data-scope": __props.scope
130
+ }, {
131
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
132
+ _: 3
133
+ }, 8, [
134
+ "data-split-granularity",
135
+ "data-pagination-strategy",
136
+ "data-scope"
137
+ ]);
138
+ };
139
+ }
140
+ });
141
+ var Flow_default = _sfc_main$14;
142
+
143
+ //#endregion
144
+ //#region src/Stream.vue
145
+ const _sfc_main$13 = /* @__PURE__ */ (0, vue.defineComponent)({
146
+ __name: "Stream",
147
+ setup(__props) {
148
+ return (_ctx, _cache) => {
149
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, { "data-type": "stream" }, {
150
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
151
+ _: 3
152
+ });
153
+ };
154
+ }
155
+ });
156
+ var Stream_default = _sfc_main$13;
157
+
158
+ //#endregion
159
+ //#region src/PageBreak.vue
160
+ const _sfc_main$12 = /* @__PURE__ */ (0, vue.defineComponent)({
161
+ __name: "PageBreak",
162
+ setup(__props) {
163
+ return (_ctx, _cache) => {
164
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, { "data-type": "page-break" });
165
+ };
166
+ }
167
+ });
168
+ var PageBreak_default = _sfc_main$12;
169
+
170
+ //#endregion
171
+ //#region src/PageCounter.vue
172
+ const _sfc_main$11 = /* @__PURE__ */ (0, vue.defineComponent)({
173
+ __name: "PageCounter",
174
+ props: {
175
+ type: {},
176
+ as: { default: "span" },
177
+ counterStyle: {}
178
+ },
179
+ setup(__props) {
180
+ const props = __props;
181
+ const style = (0, vue.computed)(() => props.counterStyle ? { "--page-counter-style": props.counterStyle } : void 0);
182
+ return (_ctx, _cache) => {
183
+ return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.as), {
184
+ "data-type": __props.type,
185
+ style: (0, vue.normalizeStyle)(style.value)
186
+ }, null, 8, ["data-type", "style"]);
187
+ };
188
+ }
189
+ });
190
+ var PageCounter_default = _sfc_main$11;
191
+
192
+ //#endregion
193
+ //#region src/PageNumber.vue
194
+ const _sfc_main$10 = /* @__PURE__ */ (0, vue.defineComponent)({
195
+ __name: "PageNumber",
196
+ props: {
197
+ as: {},
198
+ counterStyle: {}
199
+ },
200
+ setup(__props) {
201
+ const props = __props;
202
+ return (_ctx, _cache) => {
203
+ return (0, vue.openBlock)(), (0, vue.createBlock)(PageCounter_default, (0, vue.mergeProps)({ type: "page-number" }, props), null, 16);
204
+ };
205
+ }
206
+ });
207
+ var PageNumber_default = _sfc_main$10;
208
+
209
+ //#endregion
210
+ //#region src/PageCount.vue
211
+ const _sfc_main$9 = /* @__PURE__ */ (0, vue.defineComponent)({
212
+ __name: "PageCount",
213
+ props: {
214
+ as: {},
215
+ counterStyle: {}
216
+ },
217
+ setup(__props) {
218
+ const props = __props;
219
+ return (_ctx, _cache) => {
220
+ return (0, vue.openBlock)(), (0, vue.createBlock)(PageCounter_default, (0, vue.mergeProps)({ type: "page-count" }, props), null, 16);
221
+ };
222
+ }
223
+ });
224
+ var PageCount_default = _sfc_main$9;
225
+
226
+ //#endregion
227
+ //#region src/Counter.vue
228
+ const _sfc_main$8 = /* @__PURE__ */ (0, vue.defineComponent)({
229
+ __name: "Counter",
230
+ props: {
231
+ name: {},
232
+ peek: { type: Boolean },
233
+ reset: { type: Boolean },
234
+ set: {},
235
+ by: {},
236
+ join: {},
237
+ as: { default: "span" },
238
+ counterStyle: {}
239
+ },
240
+ setup(__props) {
241
+ const props = __props;
242
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && props.set !== void 0 && props.by !== void 0) console.error("<Counter>: `set` and `by` are mutually exclusive; `set` jumps to an exact value and wins, `by` is ignored.");
243
+ const action = (0, vue.computed)(() => props.reset ? "reset" : props.set !== void 0 ? "set" : props.peek ? "peek" : "next");
244
+ const value = (0, vue.computed)(() => props.set !== void 0 ? props.set : action.value === "next" ? props.by : void 0);
245
+ return (_ctx, _cache) => {
246
+ return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.as), {
247
+ "data-type": "counter",
248
+ "data-name": __props.name,
249
+ "data-action": action.value,
250
+ "data-value": value.value,
251
+ "data-join": __props.join,
252
+ "data-counter-style": __props.counterStyle
253
+ }, null, 8, [
254
+ "data-name",
255
+ "data-action",
256
+ "data-value",
257
+ "data-join",
258
+ "data-counter-style"
259
+ ]);
260
+ };
261
+ }
262
+ });
263
+ var Counter_default = _sfc_main$8;
264
+
265
+ //#endregion
266
+ //#region src/Ref.vue
267
+ const _sfc_main$7 = /* @__PURE__ */ (0, vue.defineComponent)({
268
+ __name: "Ref",
269
+ props: {
270
+ to: {},
271
+ counter: {},
272
+ page: { type: Boolean },
273
+ as: { default: "span" },
274
+ counterStyle: {}
275
+ },
276
+ setup(__props) {
277
+ const props = __props;
278
+ const counter = (0, vue.computed)(() => props.page ? void 0 : props.counter);
279
+ const page = (0, vue.computed)(() => props.page ? "" : void 0);
280
+ return (_ctx, _cache) => {
281
+ return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.as), {
282
+ "data-type": "ref",
283
+ "data-to": __props.to,
284
+ "data-counter": counter.value,
285
+ "data-page": page.value,
286
+ "data-counter-style": __props.counterStyle
287
+ }, null, 8, [
288
+ "data-to",
289
+ "data-counter",
290
+ "data-page",
291
+ "data-counter-style"
292
+ ]);
293
+ };
294
+ }
295
+ });
296
+ var Ref_default = _sfc_main$7;
297
+
298
+ //#endregion
299
+ //#region src/TableOfContents.vue
300
+ const _sfc_main$6 = /* @__PURE__ */ (0, vue.defineComponent)({
301
+ __name: "TableOfContents",
302
+ props: {
303
+ collect: {},
304
+ leader: {},
305
+ repeatHead: {
306
+ type: Boolean,
307
+ default: void 0
308
+ }
309
+ },
310
+ setup(__props) {
311
+ return (_ctx, _cache) => {
312
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
313
+ "data-type": "toc",
314
+ "data-collect": __props.collect,
315
+ "data-leader": __props.leader,
316
+ "data-repeat-head": __props.repeatHead === void 0 ? void 0 : __props.repeatHead ? "true" : "false"
317
+ }, {
318
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
319
+ _: 3
320
+ }, 8, [
321
+ "data-collect",
322
+ "data-leader",
323
+ "data-repeat-head"
324
+ ]);
325
+ };
326
+ }
327
+ });
328
+ var TableOfContents_default = _sfc_main$6;
329
+
330
+ //#endregion
331
+ //#region src/Footnote.vue
332
+ const _sfc_main$5 = /* @__PURE__ */ (0, vue.defineComponent)({
333
+ __name: "Footnote",
334
+ setup(__props) {
335
+ return (_ctx, _cache) => {
336
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [(0, vue.createCommentVNode)(" a template so the note's text stays inert and out of the inline flow until\n the engine moves it to the footer, leaving just the marker behind "), (0, vue.createVNode)(Template_default, { "data-type": "footnote" }, {
337
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
338
+ _: 3
339
+ })], 2112);
340
+ };
341
+ }
342
+ });
343
+ var Footnote_default = _sfc_main$5;
344
+
345
+ //#endregion
346
+ //#region src/Footnotes.vue
347
+ const _sfc_main$4 = /* @__PURE__ */ (0, vue.defineComponent)({
348
+ __name: "Footnotes",
349
+ props: {
350
+ counterStyle: {},
351
+ restartEachPage: { type: Boolean },
352
+ repeatHead: {
353
+ type: Boolean,
354
+ default: void 0
355
+ }
356
+ },
357
+ setup(__props) {
358
+ return (_ctx, _cache) => {
359
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
360
+ "data-type": "footnotes",
361
+ "data-counter-style": __props.counterStyle,
362
+ "data-restart-each-page": __props.restartEachPage ? "" : void 0,
363
+ "data-repeat-head": __props.repeatHead === void 0 ? void 0 : __props.repeatHead ? "true" : "false"
364
+ }, {
365
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
366
+ _: 3
367
+ }, 8, [
368
+ "data-counter-style",
369
+ "data-restart-each-page",
370
+ "data-repeat-head"
371
+ ]);
372
+ };
373
+ }
374
+ });
375
+ var Footnotes_default = _sfc_main$4;
376
+
377
+ //#endregion
378
+ //#region src/CounterDef.vue
379
+ const _sfc_main$3 = /* @__PURE__ */ (0, vue.defineComponent)({
380
+ __name: "CounterDef",
381
+ props: {
382
+ name: {},
383
+ resetEach: {}
384
+ },
385
+ setup(__props) {
386
+ return (_ctx, _cache) => {
387
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
388
+ "data-type": "counter-def",
389
+ "data-name": __props.name,
390
+ "data-reset-each": __props.resetEach
391
+ }, null, 8, ["data-name", "data-reset-each"]);
392
+ };
393
+ }
394
+ });
395
+ var CounterDef_default = _sfc_main$3;
396
+
397
+ //#endregion
398
+ //#region src/Numbering.vue
399
+ const _sfc_main$2 = /* @__PURE__ */ (0, vue.defineComponent)({
400
+ __name: "Numbering",
401
+ props: { counterStyle: {} },
402
+ setup(__props) {
403
+ return (_ctx, _cache) => {
404
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
405
+ "data-type": "numbering",
406
+ "data-counter-style": __props.counterStyle
407
+ }, {
408
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
409
+ _: 3
410
+ }, 8, ["data-counter-style"]);
411
+ };
412
+ }
413
+ });
414
+ var Numbering_default = _sfc_main$2;
415
+
416
+ //#endregion
417
+ //#region src/NumberingRule.vue
418
+ const _sfc_main$1 = /* @__PURE__ */ (0, vue.defineComponent)({
419
+ __name: "NumberingRule",
420
+ props: {
421
+ match: {},
422
+ counter: {},
423
+ format: {},
424
+ increment: {},
425
+ set: {},
426
+ counterStyle: {},
427
+ insert: {}
428
+ },
429
+ setup(__props) {
430
+ const props = __props;
431
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && props.set !== void 0 && props.increment !== void 0) console.error("<NumberingRule>: `set` and `increment` are mutually exclusive; `set` forces an exact value and wins, `increment` is ignored.");
432
+ return (_ctx, _cache) => {
433
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, {
434
+ "data-type": "numbering-rule",
435
+ "data-match": __props.match,
436
+ "data-counter": __props.counter,
437
+ "data-format": __props.format,
438
+ "data-increment": __props.increment,
439
+ "data-set": __props.set,
440
+ "data-counter-style": __props.counterStyle,
441
+ "data-insert": __props.insert
442
+ }, null, 8, [
443
+ "data-match",
444
+ "data-counter",
445
+ "data-format",
446
+ "data-increment",
447
+ "data-set",
448
+ "data-counter-style",
449
+ "data-insert"
450
+ ]);
451
+ };
452
+ }
453
+ });
454
+ var NumberingRule_default = _sfc_main$1;
455
+
456
+ //#endregion
457
+ //#region src/Scope.vue
458
+ const _sfc_main = /* @__PURE__ */ (0, vue.defineComponent)({
459
+ __name: "Scope",
460
+ props: { counter: {} },
461
+ setup(__props) {
462
+ return (_ctx, _cache) => {
463
+ return (0, vue.openBlock)(), (0, vue.createBlock)(Template_default, { "data-scope": __props.counter }, {
464
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default")]),
465
+ _: 3
466
+ }, 8, ["data-scope"]);
467
+ };
468
+ }
469
+ });
470
+ var Scope_default = _sfc_main;
471
+
472
+ //#endregion
473
+ //#region src/types.ts
474
+ /**
475
+ * How a Flow splits content that overflows a page: at a `sentence`, `word`, or
476
+ * `grapheme` boundary, or `none` to keep the block whole and move it to the next
477
+ * page intact. Use the constant (`SplitGranularity.None`) or the plain string
478
+ * (`'none'`); both are accepted.
479
+ */
480
+ const SplitGranularity = {
481
+ Sentence: "sentence",
482
+ Word: "word",
483
+ Grapheme: "grapheme",
484
+ None: "none"
485
+ };
486
+ /**
487
+ * The dot leader between a contents entry's title and its page number. The default,
488
+ * `dots`, draws it; `none` leaves the run between them blank. Use the constant
489
+ * (`TocLeader.None`) or the plain string (`'none'`); both are accepted.
490
+ */
491
+ const TocLeader = {
492
+ Dots: "dots",
493
+ None: "none"
494
+ };
495
+
496
+ //#endregion
497
+ //#region src/utils.ts
498
+ /**
499
+ * Tagged template for authoring CSS, typically inside a `<style>` element.
500
+ * Returns the string from the raw segments, so CSS escapes (`\2014`,
501
+ * icon-font codepoints, escaped selectors) survive intact. Interpolated
502
+ * `null`, `undefined`, and `false` collapse to an empty string for clean
503
+ * conditional rules. The `css` name also lets editors and the Format docs
504
+ * highlighter treat the contents as CSS.
505
+ */
506
+ function css(parts, ...vals) {
507
+ let out = parts.raw[0] ?? "";
508
+ for (let i = 0; i < vals.length; i++) {
509
+ const v = vals[i];
510
+ out += (v == null || v === false ? "" : String(v)) + parts.raw[i + 1];
511
+ }
512
+ return out;
513
+ }
514
+
515
+ //#endregion
516
+ exports.Counter = Counter_default;
517
+ exports.CounterDef = CounterDef_default;
518
+ exports.Document = Document_default;
519
+ exports.Flow = Flow_default;
520
+ exports.Footnote = Footnote_default;
521
+ exports.Footnotes = Footnotes_default;
522
+ exports.Layout = Layout_default;
523
+ exports.Numbering = Numbering_default;
524
+ exports.NumberingRule = NumberingRule_default;
525
+ exports.PageBreak = PageBreak_default;
526
+ exports.PageCount = PageCount_default;
527
+ exports.PageNumber = PageNumber_default;
528
+ exports.Ref = Ref_default;
529
+ exports.Scope = Scope_default;
530
+ exports.SplitGranularity = SplitGranularity;
531
+ exports.Stream = Stream_default;
532
+ exports.TableOfContents = TableOfContents_default;
533
+ exports.TocLeader = TocLeader;
534
+ exports.css = css;