@casualoffice/sheets 0.9.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.
Files changed (92) hide show
  1. package/LICENSE +200 -0
  2. package/dist/embed/embed-runtime.js +537 -0
  3. package/dist/embed/embed.html +29 -0
  4. package/dist/embed/parser.worker.js +48474 -0
  5. package/dist/embed.cjs +225 -0
  6. package/dist/embed.cjs.map +1 -0
  7. package/dist/embed.d.cts +100 -0
  8. package/dist/embed.d.ts +100 -0
  9. package/dist/embed.js +204 -0
  10. package/dist/embed.js.map +1 -0
  11. package/dist/index.cjs +1549 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.cts +9 -0
  14. package/dist/index.d.ts +9 -0
  15. package/dist/index.js +1530 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/parser.worker.cjs +48469 -0
  18. package/dist/parser.worker.cjs.map +1 -0
  19. package/dist/parser.worker.js +48474 -0
  20. package/dist/parser.worker.js.map +1 -0
  21. package/dist/protocol--KyBQUjU.d.cts +171 -0
  22. package/dist/protocol-cEzy7S0i.d.ts +171 -0
  23. package/dist/sheets.cjs +677 -0
  24. package/dist/sheets.cjs.map +1 -0
  25. package/dist/sheets.d.cts +177 -0
  26. package/dist/sheets.d.ts +177 -0
  27. package/dist/sheets.js +658 -0
  28. package/dist/sheets.js.map +1 -0
  29. package/dist/signing.cjs +706 -0
  30. package/dist/signing.cjs.map +1 -0
  31. package/dist/signing.d.cts +141 -0
  32. package/dist/signing.d.ts +141 -0
  33. package/dist/signing.js +683 -0
  34. package/dist/signing.js.map +1 -0
  35. package/dist/styles.cjs +10 -0
  36. package/dist/styles.cjs.map +1 -0
  37. package/dist/styles.d.cts +2 -0
  38. package/dist/styles.d.ts +2 -0
  39. package/dist/styles.js +8 -0
  40. package/dist/styles.js.map +1 -0
  41. package/dist/types-s_O0u6Cg.d.cts +90 -0
  42. package/dist/types-s_O0u6Cg.d.ts +90 -0
  43. package/dist/univer.cjs +220 -0
  44. package/dist/univer.cjs.map +1 -0
  45. package/dist/univer.d.cts +60 -0
  46. package/dist/univer.d.ts +60 -0
  47. package/dist/univer.js +187 -0
  48. package/dist/univer.js.map +1 -0
  49. package/dist/xlsx.cjs +3388 -0
  50. package/dist/xlsx.cjs.map +1 -0
  51. package/dist/xlsx.d.cts +383 -0
  52. package/dist/xlsx.d.ts +383 -0
  53. package/dist/xlsx.js +3383 -0
  54. package/dist/xlsx.js.map +1 -0
  55. package/package.json +293 -0
  56. package/src/embed/EmbedHostTransport.ts +226 -0
  57. package/src/embed/EmbedTransport.ts +323 -0
  58. package/src/embed/EmbedTransport.unit.test.ts +161 -0
  59. package/src/embed/index.ts +40 -0
  60. package/src/embed/protocol.ts +258 -0
  61. package/src/embed-runtime/embed.html +29 -0
  62. package/src/embed-runtime/index.tsx +440 -0
  63. package/src/index.ts +16 -0
  64. package/src/sheets/CasualSheets.tsx +319 -0
  65. package/src/sheets/CasualSheetsIframe.tsx +220 -0
  66. package/src/sheets/api.ts +108 -0
  67. package/src/sheets/index.ts +11 -0
  68. package/src/signing/SigningPane.tsx +374 -0
  69. package/src/signing/SigningProvider.tsx +126 -0
  70. package/src/signing/captures.tsx +316 -0
  71. package/src/signing/controller.ts +151 -0
  72. package/src/signing/controller.unit.test.ts +133 -0
  73. package/src/signing/index.ts +44 -0
  74. package/src/signing/types.ts +89 -0
  75. package/src/styles.ts +16 -0
  76. package/src/univer/index.ts +17 -0
  77. package/src/univer/lazy-plugins.ts +280 -0
  78. package/src/xlsx/_perf.ts +14 -0
  79. package/src/xlsx/_snapshot-constants.ts +15 -0
  80. package/src/xlsx/comments-resource.ts +209 -0
  81. package/src/xlsx/constants.ts +9 -0
  82. package/src/xlsx/data-validation-resource.ts +219 -0
  83. package/src/xlsx/import.ts +35 -0
  84. package/src/xlsx/index.ts +40 -0
  85. package/src/xlsx/page-setup-resource.ts +205 -0
  86. package/src/xlsx/parse-impl.ts +418 -0
  87. package/src/xlsx/parse-in-worker.ts +82 -0
  88. package/src/xlsx/parser.worker.ts +39 -0
  89. package/src/xlsx/passthrough-resource.ts +175 -0
  90. package/src/xlsx/pivot-passthrough.ts +359 -0
  91. package/src/xlsx/style-mapping.ts +171 -0
  92. package/src/xlsx/tables-resource.ts +211 -0
@@ -0,0 +1,171 @@
1
+ import { c as SignatureField, e as SignatureMode, C as CancelReason, f as SignedFieldPayload, b as SignatureCompletePayload } from './types-s_O0u6Cg.cjs';
2
+
3
+ /**
4
+ * Iframe protocol — wire envelopes that match
5
+ * `docs/internal/13-iframe-protocol.md`.
6
+ *
7
+ * Mirror updates to the doc whenever a new envelope shape lands.
8
+ * The discriminator on `type` (always starts with `casual.`) and
9
+ * the per-envelope `data` shape are the contract.
10
+ */
11
+
12
+ type CasualApp = 'docs' | 'sheet';
13
+ /** Common envelope shape — every postMessage on the wire matches this. */
14
+ interface CasualEnvelope<T = unknown> {
15
+ type: string;
16
+ app: CasualApp;
17
+ /** Per-request id for request/response correlation. Empty for fire-and-forget. */
18
+ id?: string;
19
+ /** Protocol version. Bumped only on breaking changes. */
20
+ v: 1;
21
+ data: T;
22
+ }
23
+ interface EditorHelloData {
24
+ capabilities: string[];
25
+ version: string;
26
+ commit: string;
27
+ }
28
+ interface HostHelloData {
29
+ capabilities: string[];
30
+ authToken?: string;
31
+ }
32
+ interface LoadRequestData {
33
+ docId: string;
34
+ }
35
+ interface LoadResponseDataOk {
36
+ ok: true;
37
+ bytes: ArrayBuffer;
38
+ etag?: string;
39
+ fileName: string;
40
+ readOnly?: boolean;
41
+ }
42
+ interface LoadResponseDataErr {
43
+ ok: false;
44
+ code: string;
45
+ message?: string;
46
+ }
47
+ type LoadResponseData = LoadResponseDataOk | LoadResponseDataErr;
48
+ interface SaveRequestData {
49
+ docId: string;
50
+ bytes: ArrayBuffer;
51
+ baseEtag?: string;
52
+ }
53
+ interface SaveResponseDataOk {
54
+ ok: true;
55
+ etag: string;
56
+ }
57
+ interface SaveResponseDataErr {
58
+ ok: false;
59
+ code: string;
60
+ etag?: string;
61
+ message?: string;
62
+ }
63
+ type SaveResponseData = SaveResponseDataOk | SaveResponseDataErr;
64
+ interface SelectionChangedData {
65
+ docs?: {
66
+ paraId: string;
67
+ from: number;
68
+ to: number;
69
+ selectedText: string;
70
+ };
71
+ sheet?: {
72
+ sheet: string;
73
+ from: string;
74
+ to: string;
75
+ };
76
+ }
77
+ interface TelemetryEventData {
78
+ kind: string;
79
+ /** Arbitrary metric fields. */
80
+ [k: string]: unknown;
81
+ }
82
+ interface LockLostData {
83
+ reason: 'taken_by_other' | 'expired' | 'host_revoked';
84
+ }
85
+ interface CommandSetReadOnlyData {
86
+ readOnly: boolean;
87
+ }
88
+ interface CommandSetThemeData {
89
+ theme: 'light' | 'dark' | 'system';
90
+ }
91
+ interface CommandSetLocaleData {
92
+ locale: string;
93
+ }
94
+ /** Host → editor: switch chrome density between the two consumer-facing
95
+ * modes without re-mounting. `preview` hides toolbar / formula bar /
96
+ * side panel / status bar / sheet tabs and runs read-only; `editor`
97
+ * shows the full UI. Mirrors the `viewMode` prop on `<CasualSheetsIframe>`. */
98
+ interface CommandSetViewModeData {
99
+ viewMode: 'preview' | 'editor';
100
+ }
101
+ /** Host → editor: execute a formatting / navigation command against
102
+ * the active selection in the embedded workbook. Hosts (like Casual
103
+ * Drive) build their own toolbar above the iframe and dispatch these
104
+ * commands instead of Univer's built-in ribbon, which the SDK can't
105
+ * ship because the ribbon resolves IRPCChannelService at construction
106
+ * and that service needs a worker the SDK doesn't bundle.
107
+ *
108
+ * v0.6 covered the toggle set; v0.7 adds the rich-format set (font,
109
+ * size, colour, fill) + merge / unmerge. Arg-carrying commands read
110
+ * the relevant field off `args` — every other command ignores it. */
111
+ interface CommandExecuteData {
112
+ command: 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'align-left' | 'align-center' | 'align-right' | 'set-font-family' | 'set-font-size' | 'set-text-color' | 'reset-text-color' | 'set-bg-color' | 'reset-bg-color' | 'merge' | 'unmerge' | 'numfmt-currency' | 'numfmt-percent' | 'numfmt-add-decimal' | 'numfmt-subtract-decimal' | 'numfmt-custom' | 'wrap-toggle' | 'freeze-first-row' | 'freeze-first-column' | 'freeze-none';
113
+ args?: {
114
+ /** Used by `set-font-family`. */
115
+ family?: string;
116
+ /** Used by `set-font-size`. Integer point size. */
117
+ size?: number;
118
+ /** Used by `set-text-color` and `set-bg-color`. Hex like `#1a73e8`. */
119
+ color?: string;
120
+ /** Used by `numfmt-custom`. The Excel-style format string, e.g.
121
+ * `"#,##0.00"`, `"$#,##0"`, `"0.00%"`, `"d-mmm-yy"`. v0.8+. */
122
+ pattern?: string;
123
+ };
124
+ }
125
+ /** Editor → host: emitted whenever the selection's active cell's
126
+ * format flags change. Drive's toolbar mirrors this state in the
127
+ * button "pressed" / value indicators so the surface always reflects
128
+ * what the user would see in the cell. v0.7 widens the payload with
129
+ * the rich-format read-back (fontFamily, fontSize, textColor, bgColor)
130
+ * so the toolbar's font picker / size stepper / colour swatches stay
131
+ * in sync without the host having to poll. */
132
+ interface SelectionFormatStateData {
133
+ bold: boolean;
134
+ italic: boolean;
135
+ underline: boolean;
136
+ strikethrough: boolean;
137
+ align: 'left' | 'center' | 'right' | null;
138
+ /** Defined font family on the active cell, or null when the cell
139
+ * inherits the workbook default. v0.7+. */
140
+ fontFamily: string | null;
141
+ /** Defined font size on the active cell, or null when the cell
142
+ * inherits the workbook default. v0.7+. */
143
+ fontSize: number | null;
144
+ /** Hex text colour like `#1a73e8`, or null when default. v0.7+. */
145
+ textColor: string | null;
146
+ /** Hex background colour, or null when no fill is set. v0.7+. */
147
+ bgColor: string | null;
148
+ }
149
+ /** Editor → host: a fatal error during boot / load. Hosts surface this
150
+ * via the wrapper's `onError` callback. */
151
+ interface CasualErrorData {
152
+ code: 'embed_not_served' | 'load_failed' | 'parse_failed' | 'boot_failed' | 'internal';
153
+ message: string;
154
+ }
155
+ interface SignatureRequestData {
156
+ fields: SignatureField[];
157
+ mode: SignatureMode;
158
+ banner?: string;
159
+ }
160
+ interface SignatureRequestAckData {
161
+ ok: boolean;
162
+ code?: string;
163
+ }
164
+ type SignatureFieldSignedData = SignedFieldPayload;
165
+ type SignatureCompleteData = SignatureCompletePayload;
166
+ interface SignatureCancelData {
167
+ reason: CancelReason;
168
+ }
169
+ declare function isCasualEnvelope(value: unknown): value is CasualEnvelope;
170
+
171
+ export { type CasualApp as C, type EditorHelloData as E, type HostHelloData as H, type LoadRequestData as L, type SaveRequestData as S, type TelemetryEventData as T, type CasualEnvelope as a, type CasualErrorData as b, type CommandExecuteData as c, type CommandSetLocaleData as d, type CommandSetReadOnlyData as e, type CommandSetThemeData as f, type CommandSetViewModeData as g, type LoadResponseData as h, type LoadResponseDataErr as i, type LoadResponseDataOk as j, type LockLostData as k, type SaveResponseData as l, type SaveResponseDataErr as m, type SaveResponseDataOk as n, type SelectionChangedData as o, type SelectionFormatStateData as p, type SignatureCancelData as q, type SignatureCompleteData as r, type SignatureFieldSignedData as s, type SignatureRequestAckData as t, type SignatureRequestData as u, isCasualEnvelope as v };
@@ -0,0 +1,171 @@
1
+ import { c as SignatureField, e as SignatureMode, C as CancelReason, f as SignedFieldPayload, b as SignatureCompletePayload } from './types-s_O0u6Cg.js';
2
+
3
+ /**
4
+ * Iframe protocol — wire envelopes that match
5
+ * `docs/internal/13-iframe-protocol.md`.
6
+ *
7
+ * Mirror updates to the doc whenever a new envelope shape lands.
8
+ * The discriminator on `type` (always starts with `casual.`) and
9
+ * the per-envelope `data` shape are the contract.
10
+ */
11
+
12
+ type CasualApp = 'docs' | 'sheet';
13
+ /** Common envelope shape — every postMessage on the wire matches this. */
14
+ interface CasualEnvelope<T = unknown> {
15
+ type: string;
16
+ app: CasualApp;
17
+ /** Per-request id for request/response correlation. Empty for fire-and-forget. */
18
+ id?: string;
19
+ /** Protocol version. Bumped only on breaking changes. */
20
+ v: 1;
21
+ data: T;
22
+ }
23
+ interface EditorHelloData {
24
+ capabilities: string[];
25
+ version: string;
26
+ commit: string;
27
+ }
28
+ interface HostHelloData {
29
+ capabilities: string[];
30
+ authToken?: string;
31
+ }
32
+ interface LoadRequestData {
33
+ docId: string;
34
+ }
35
+ interface LoadResponseDataOk {
36
+ ok: true;
37
+ bytes: ArrayBuffer;
38
+ etag?: string;
39
+ fileName: string;
40
+ readOnly?: boolean;
41
+ }
42
+ interface LoadResponseDataErr {
43
+ ok: false;
44
+ code: string;
45
+ message?: string;
46
+ }
47
+ type LoadResponseData = LoadResponseDataOk | LoadResponseDataErr;
48
+ interface SaveRequestData {
49
+ docId: string;
50
+ bytes: ArrayBuffer;
51
+ baseEtag?: string;
52
+ }
53
+ interface SaveResponseDataOk {
54
+ ok: true;
55
+ etag: string;
56
+ }
57
+ interface SaveResponseDataErr {
58
+ ok: false;
59
+ code: string;
60
+ etag?: string;
61
+ message?: string;
62
+ }
63
+ type SaveResponseData = SaveResponseDataOk | SaveResponseDataErr;
64
+ interface SelectionChangedData {
65
+ docs?: {
66
+ paraId: string;
67
+ from: number;
68
+ to: number;
69
+ selectedText: string;
70
+ };
71
+ sheet?: {
72
+ sheet: string;
73
+ from: string;
74
+ to: string;
75
+ };
76
+ }
77
+ interface TelemetryEventData {
78
+ kind: string;
79
+ /** Arbitrary metric fields. */
80
+ [k: string]: unknown;
81
+ }
82
+ interface LockLostData {
83
+ reason: 'taken_by_other' | 'expired' | 'host_revoked';
84
+ }
85
+ interface CommandSetReadOnlyData {
86
+ readOnly: boolean;
87
+ }
88
+ interface CommandSetThemeData {
89
+ theme: 'light' | 'dark' | 'system';
90
+ }
91
+ interface CommandSetLocaleData {
92
+ locale: string;
93
+ }
94
+ /** Host → editor: switch chrome density between the two consumer-facing
95
+ * modes without re-mounting. `preview` hides toolbar / formula bar /
96
+ * side panel / status bar / sheet tabs and runs read-only; `editor`
97
+ * shows the full UI. Mirrors the `viewMode` prop on `<CasualSheetsIframe>`. */
98
+ interface CommandSetViewModeData {
99
+ viewMode: 'preview' | 'editor';
100
+ }
101
+ /** Host → editor: execute a formatting / navigation command against
102
+ * the active selection in the embedded workbook. Hosts (like Casual
103
+ * Drive) build their own toolbar above the iframe and dispatch these
104
+ * commands instead of Univer's built-in ribbon, which the SDK can't
105
+ * ship because the ribbon resolves IRPCChannelService at construction
106
+ * and that service needs a worker the SDK doesn't bundle.
107
+ *
108
+ * v0.6 covered the toggle set; v0.7 adds the rich-format set (font,
109
+ * size, colour, fill) + merge / unmerge. Arg-carrying commands read
110
+ * the relevant field off `args` — every other command ignores it. */
111
+ interface CommandExecuteData {
112
+ command: 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'align-left' | 'align-center' | 'align-right' | 'set-font-family' | 'set-font-size' | 'set-text-color' | 'reset-text-color' | 'set-bg-color' | 'reset-bg-color' | 'merge' | 'unmerge' | 'numfmt-currency' | 'numfmt-percent' | 'numfmt-add-decimal' | 'numfmt-subtract-decimal' | 'numfmt-custom' | 'wrap-toggle' | 'freeze-first-row' | 'freeze-first-column' | 'freeze-none';
113
+ args?: {
114
+ /** Used by `set-font-family`. */
115
+ family?: string;
116
+ /** Used by `set-font-size`. Integer point size. */
117
+ size?: number;
118
+ /** Used by `set-text-color` and `set-bg-color`. Hex like `#1a73e8`. */
119
+ color?: string;
120
+ /** Used by `numfmt-custom`. The Excel-style format string, e.g.
121
+ * `"#,##0.00"`, `"$#,##0"`, `"0.00%"`, `"d-mmm-yy"`. v0.8+. */
122
+ pattern?: string;
123
+ };
124
+ }
125
+ /** Editor → host: emitted whenever the selection's active cell's
126
+ * format flags change. Drive's toolbar mirrors this state in the
127
+ * button "pressed" / value indicators so the surface always reflects
128
+ * what the user would see in the cell. v0.7 widens the payload with
129
+ * the rich-format read-back (fontFamily, fontSize, textColor, bgColor)
130
+ * so the toolbar's font picker / size stepper / colour swatches stay
131
+ * in sync without the host having to poll. */
132
+ interface SelectionFormatStateData {
133
+ bold: boolean;
134
+ italic: boolean;
135
+ underline: boolean;
136
+ strikethrough: boolean;
137
+ align: 'left' | 'center' | 'right' | null;
138
+ /** Defined font family on the active cell, or null when the cell
139
+ * inherits the workbook default. v0.7+. */
140
+ fontFamily: string | null;
141
+ /** Defined font size on the active cell, or null when the cell
142
+ * inherits the workbook default. v0.7+. */
143
+ fontSize: number | null;
144
+ /** Hex text colour like `#1a73e8`, or null when default. v0.7+. */
145
+ textColor: string | null;
146
+ /** Hex background colour, or null when no fill is set. v0.7+. */
147
+ bgColor: string | null;
148
+ }
149
+ /** Editor → host: a fatal error during boot / load. Hosts surface this
150
+ * via the wrapper's `onError` callback. */
151
+ interface CasualErrorData {
152
+ code: 'embed_not_served' | 'load_failed' | 'parse_failed' | 'boot_failed' | 'internal';
153
+ message: string;
154
+ }
155
+ interface SignatureRequestData {
156
+ fields: SignatureField[];
157
+ mode: SignatureMode;
158
+ banner?: string;
159
+ }
160
+ interface SignatureRequestAckData {
161
+ ok: boolean;
162
+ code?: string;
163
+ }
164
+ type SignatureFieldSignedData = SignedFieldPayload;
165
+ type SignatureCompleteData = SignatureCompletePayload;
166
+ interface SignatureCancelData {
167
+ reason: CancelReason;
168
+ }
169
+ declare function isCasualEnvelope(value: unknown): value is CasualEnvelope;
170
+
171
+ export { type CasualApp as C, type EditorHelloData as E, type HostHelloData as H, type LoadRequestData as L, type SaveRequestData as S, type TelemetryEventData as T, type CasualEnvelope as a, type CasualErrorData as b, type CommandExecuteData as c, type CommandSetLocaleData as d, type CommandSetReadOnlyData as e, type CommandSetThemeData as f, type CommandSetViewModeData as g, type LoadResponseData as h, type LoadResponseDataErr as i, type LoadResponseDataOk as j, type LockLostData as k, type SaveResponseData as l, type SaveResponseDataErr as m, type SaveResponseDataOk as n, type SelectionChangedData as o, type SelectionFormatStateData as p, type SignatureCancelData as q, type SignatureCompleteData as r, type SignatureFieldSignedData as s, type SignatureRequestAckData as t, type SignatureRequestData as u, isCasualEnvelope as v };