tjs-lang 0.7.7 → 0.7.8
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/CLAUDE.md +90 -33
- package/bin/docs.js +4 -1
- package/demo/docs.json +45 -11
- package/demo/src/examples.test.ts +1 -0
- package/demo/src/imports.test.ts +16 -4
- package/demo/src/imports.ts +60 -15
- package/demo/src/playground-shared.ts +9 -8
- package/demo/src/tfs-worker.js +205 -147
- package/demo/src/tjs-playground.ts +34 -10
- package/demo/src/ts-playground.ts +24 -8
- package/dist/index.js +118 -101
- package/dist/index.js.map +4 -4
- package/dist/src/lang/bool-coercion.d.ts +50 -0
- package/dist/src/lang/docs.d.ts +31 -6
- package/dist/src/lang/linter.d.ts +8 -0
- package/dist/src/lang/parser-transforms.d.ts +18 -0
- package/dist/src/lang/parser-types.d.ts +2 -0
- package/dist/src/lang/parser.d.ts +3 -0
- package/dist/src/lang/runtime.d.ts +34 -0
- package/dist/src/lang/types.d.ts +9 -1
- package/dist/src/rbac/index.d.ts +1 -1
- package/dist/src/vm/runtime.d.ts +1 -1
- package/dist/tjs-eval.js +38 -36
- package/dist/tjs-eval.js.map +4 -4
- package/dist/tjs-from-ts.js +20 -20
- package/dist/tjs-from-ts.js.map +3 -3
- package/dist/tjs-lang.js +85 -83
- package/dist/tjs-lang.js.map +4 -4
- package/dist/tjs-vm.js +47 -45
- package/dist/tjs-vm.js.map +4 -4
- package/llms.txt +79 -0
- package/package.json +3 -2
- package/src/cli/commands/convert.test.ts +16 -21
- package/src/lang/bool-coercion.test.ts +203 -0
- package/src/lang/bool-coercion.ts +314 -0
- package/src/lang/codegen.test.ts +137 -0
- package/src/lang/docs.test.ts +328 -1
- package/src/lang/docs.ts +424 -24
- package/src/lang/emitters/ast.ts +11 -12
- package/src/lang/emitters/dts.test.ts +41 -0
- package/src/lang/emitters/dts.ts +9 -0
- package/src/lang/emitters/js-tests.ts +9 -4
- package/src/lang/emitters/js.ts +182 -2
- package/src/lang/inference.ts +54 -0
- package/src/lang/linter.test.ts +104 -1
- package/src/lang/linter.ts +124 -1
- package/src/lang/parser-params.ts +31 -0
- package/src/lang/parser-transforms.ts +304 -0
- package/src/lang/parser-types.ts +2 -0
- package/src/lang/parser.test.ts +73 -1
- package/src/lang/parser.ts +34 -1
- package/src/lang/runtime.ts +98 -0
- package/src/lang/types.ts +6 -0
- package/src/rbac/index.ts +2 -2
- package/src/rbac/rules.tjs.d.ts +9 -0
- package/src/vm/atoms/batteries.ts +2 -2
- package/src/vm/runtime.ts +10 -3
- package/dist/src/rbac/rules.d.ts +0 -184
- package/src/rbac/rules.js +0 -338
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from 'tosijs-ui'
|
|
19
19
|
import { codeMirror, CodeMirror } from '../../editors/codemirror/component'
|
|
20
20
|
import { tjs } from '../../src/lang'
|
|
21
|
-
import { rewriteImports } from './imports'
|
|
21
|
+
import { rewriteImports, registerIframeContent } from './imports'
|
|
22
22
|
import { generateDocsMarkdown } from './docs-utils'
|
|
23
23
|
import {
|
|
24
24
|
buildIframeDoc,
|
|
@@ -710,7 +710,7 @@ export class TSPlayground extends Component<TSPlaygroundParts> {
|
|
|
710
710
|
const cssContent = this.parts.cssEditor.value
|
|
711
711
|
const jsCode = this.lastJsCode
|
|
712
712
|
|
|
713
|
-
// Rewrite bare imports to
|
|
713
|
+
// Rewrite bare imports to absolute JSDelivr /+esm URLs
|
|
714
714
|
const rewrittenCode = rewriteImports(jsCode)
|
|
715
715
|
|
|
716
716
|
// Create iframe document
|
|
@@ -746,17 +746,33 @@ export class TSPlayground extends Component<TSPlaygroundParts> {
|
|
|
746
746
|
})
|
|
747
747
|
window.addEventListener('message', this._messageHandler)
|
|
748
748
|
|
|
749
|
-
//
|
|
750
|
-
//
|
|
749
|
+
// Load iframe from a SW-served same-origin URL so the SW controls
|
|
750
|
+
// the iframe's fetches. blob: URLs do not get SW interception in
|
|
751
|
+
// sandboxed contexts (Chrome quirk). See tjs-playground.ts.
|
|
751
752
|
const iframe = this.parts.previewFrame
|
|
752
|
-
const blob = new Blob([iframeDoc], { type: 'text/html' })
|
|
753
|
-
const blobUrl = URL.createObjectURL(blob)
|
|
754
753
|
|
|
755
754
|
if (iframe.dataset.blobUrl) {
|
|
756
755
|
URL.revokeObjectURL(iframe.dataset.blobUrl)
|
|
756
|
+
delete iframe.dataset.blobUrl
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const sessionId = `ts-${Date.now()}-${Math.random()
|
|
760
|
+
.toString(36)
|
|
761
|
+
.slice(2)}`
|
|
762
|
+
const registered = await registerIframeContent(sessionId, iframeDoc)
|
|
763
|
+
|
|
764
|
+
if (registered) {
|
|
765
|
+
iframe.src = `/iframe/${sessionId}`
|
|
766
|
+
} else {
|
|
767
|
+
// SW not active — fall back to blob: (no SW; CDN imports will fail)
|
|
768
|
+
console.warn(
|
|
769
|
+
'[ts-playground] SW unavailable, falling back to blob: iframe'
|
|
770
|
+
)
|
|
771
|
+
const blob = new Blob([iframeDoc], { type: 'text/html' })
|
|
772
|
+
const blobUrl = URL.createObjectURL(blob)
|
|
773
|
+
iframe.dataset.blobUrl = blobUrl
|
|
774
|
+
iframe.src = blobUrl
|
|
757
775
|
}
|
|
758
|
-
iframe.dataset.blobUrl = blobUrl
|
|
759
|
-
iframe.src = blobUrl
|
|
760
776
|
} catch (e: any) {
|
|
761
777
|
this.log(`Error: ${e.message}`)
|
|
762
778
|
this.parts.statusBar.textContent = 'Error'
|